Index: source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp =================================================================== --- source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp +++ source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2016 Wildfire Games. +/* Copyright (C) 2017 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -21,6 +21,7 @@ #include "AtlasObject/AtlasObject.h" #include "GameInterface/Messages.h" +#include "General/Datafile.h" #include "ScenarioEditor/ScenarioEditor.h" #include "ScenarioEditor/Tools/Common/Tools.h" @@ -31,13 +32,16 @@ { ID_MapName, ID_MapDescription, + ID_MapPreview, ID_MapReveal, ID_MapType, - ID_MapPreview, - ID_MapTeams, + ID_MapWonderVictoryTime, + ID_MapLockTeams, + ID_MapLastManStanding, ID_MapKW_Demo, ID_MapKW_Naval, ID_RandomScript, + ID_OpenPlayerPanel, ID_RandomSize, ID_RandomSeed, ID_RandomReseed, @@ -46,8 +50,7 @@ ID_SimFast, ID_SimSlow, ID_SimPause, - ID_SimReset, - ID_OpenPlayerPanel + ID_SimReset }; enum @@ -141,14 +144,10 @@ sizer->AddSpacer(5); - // TODO: replace by filenames in binaries/data/mods/public/simulation/data/settings/victory_conditions/ - wxArrayString gameTypes; - gameTypes.Add(_T("conquest")); - gameTypes.Add(_T("conquest_structures")); - gameTypes.Add(_T("conquest_units")); - gameTypes.Add(_T("wonder")); - gameTypes.Add(_T("endless")); - gameTypes.Add(_T("regicide")); + wxArrayString gameTypes = Datafile::EnumerateDataFiles(_T("mods/public/simulation/data/settings/victory_conditions/"), _T("*.json")); + // Discard path and extension of game types + for (wxString& gameType : gameTypes) + gameType = wxFileName(gameType).GetName(); wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5); gridSizer->AddGrowableCol(1); @@ -162,9 +161,16 @@ gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Game type")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); gridSizer->Add(Tooltipped(new wxChoice(this, ID_MapType, wxDefaultPosition, wxDefaultSize, gameTypes), _("Select the game type (or victory condition)")), wxSizerFlags().Expand()); + gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Wonder Victory")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); + gridSizer->Add(Tooltipped(new wxTextCtrl(this, ID_MapWonderVictoryTime, wxEmptyString), + _("Number of minutes that the player has to keep the wonder in order to win.")), wxSizerFlags().Expand()); + gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Lock teams")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); - gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapTeams, wxEmptyString), + gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapLockTeams, wxEmptyString), _("If checked, teams will be locked"))); + gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Last Man Standing")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); + gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapLastManStanding, wxEmptyString), + _("If checked, the last remaining player will win (not the last remaining set of allies)"))); sizer->Add(gridSizer, wxSizerFlags().Expand()); sizer->AddSpacer(5); @@ -209,8 +215,19 @@ else wxDynamicCast(FindWindow(ID_MapType), wxChoice)->SetSelection(0); + if (wxString(m_MapSettings["GameType"]) == L"wonder") + wxDynamicCast(FindWindow(ID_MapWonderVictoryTime), wxTextCtrl)->ChangeValue(wxString(m_MapSettings["WonderDuration"])); + + wxDynamicCast(FindWindow(ID_MapWonderVictoryTime), wxTextCtrl)->Enable(wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection() == L"wonder"); + // lock teams - wxDynamicCast(FindWindow(ID_MapTeams), wxCheckBox)->SetValue(wxString(m_MapSettings["LockTeams"]) == L"true"); + wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->SetValue(wxString(m_MapSettings["LockTeams"]) == L"true"); + + // Last Man Standing + wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->SetValue(wxString(m_MapSettings["LastManStanding"]) == L"true" && + wxString(m_MapSettings["LockTeams"]) != L"true"); + + wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->Enable(!wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue()); // keywords { @@ -248,6 +265,11 @@ // game type / victory conditions m_MapSettings.set("GameType", wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection()); + if (wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection() == L"wonder") + m_MapSettings.setInt("WonderDuration", wxAtoi(wxDynamicCast(FindWindow(ID_MapWonderVictoryTime), wxTextCtrl)->GetValue())); + + wxDynamicCast(FindWindow(ID_MapWonderVictoryTime), wxTextCtrl)->Enable(wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection() == L"wonder"); + // keywords { if (wxDynamicCast(FindWindow(ID_MapKW_Demo), wxCheckBox)->GetValue()) @@ -268,7 +290,15 @@ } // teams locked - m_MapSettings.setBool("LockTeams", wxDynamicCast(FindWindow(ID_MapTeams), wxCheckBox)->GetValue()); + m_MapSettings.setBool("LockTeams", wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue()); + + // Last Man Standing (can't be enabled if teams are locked) + if (wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue()) + wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->SetValue(false); + + wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->Enable(!wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue()); + + m_MapSettings.setBool("LastManStanding", wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->GetValue()); return m_MapSettings; }