Ticket #4256: 4256_atlas_settings_v1.1.patch
File 4256_atlas_settings_v1.1.patch, 5.5 KB (added by , 7 years ago) |
---|
-
source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp
1 /* Copyright (C) 201 6Wildfire Games.1 /* Copyright (C) 2017 Wildfire Games. 2 2 * This file is part of 0 A.D. 3 3 * 4 4 * 0 A.D. is free software: you can redistribute it and/or modify … … 21 21 22 22 #include "AtlasObject/AtlasObject.h" 23 23 #include "GameInterface/Messages.h" 24 #include "General/Datafile.h" 24 25 #include "ScenarioEditor/ScenarioEditor.h" 25 26 #include "ScenarioEditor/Tools/Common/Tools.h" 26 27 … … 33 34 ID_MapDescription, 34 35 ID_MapReveal, 35 36 ID_MapType, 37 ID_WonderVictoryTimes, 36 38 ID_MapPreview, 37 ID_MapTeams, 39 ID_MapLockTeams, 40 ID_MapLastManStanding, 38 41 ID_MapKW_Demo, 39 42 ID_MapKW_Naval, 40 43 ID_RandomScript, … … 141 144 142 145 sizer->AddSpacer(5); 143 146 144 // TODO: replace by filenames in binaries/data/mods/public/simulation/data/settings/victory_conditions/ 145 wxArrayString gameTypes; 146 gameTypes.Add(_T("conquest")); 147 gameTypes.Add(_T("conquest_structures")); 148 gameTypes.Add(_T("conquest_units")); 149 gameTypes.Add(_T("wonder")); 150 gameTypes.Add(_T("endless")); 151 gameTypes.Add(_T("regicide")); 147 wxArrayString gameTypes = Datafile::EnumerateDataFiles(_T("mods/public/simulation/data/settings/victory_conditions/"), _T("*.json")); 148 // Discard path and extension of game types 149 for (wxString& gameType : gameTypes) 150 gameType = wxFileName(gameType).GetName(); 152 151 153 152 wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5); 154 153 gridSizer->AddGrowableCol(1); … … 162 161 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Game type")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 163 162 gridSizer->Add(Tooltipped(new wxChoice(this, ID_MapType, wxDefaultPosition, wxDefaultSize, gameTypes), 164 163 _("Select the game type (or victory condition)")), wxSizerFlags().Expand()); 164 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Wonder Victory")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 165 gridSizer->Add(Tooltipped(new wxTextCtrl(this, ID_WonderVictoryTimes, wxEmptyString), 166 _("Number of minutes that the player has to keep the wonder in order to win.")), wxSizerFlags().Expand()); 167 165 168 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Lock teams")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 166 gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_Map Teams, wxEmptyString),169 gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapLockTeams, wxEmptyString), 167 170 _("If checked, teams will be locked"))); 171 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Last Man Standing")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 172 gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapLastManStanding, wxEmptyString), 173 _("If checked, the last remaining player will win (not the last remaining set of allies)"))); 168 174 sizer->Add(gridSizer, wxSizerFlags().Expand()); 169 175 170 176 sizer->AddSpacer(5); … … 209 215 else 210 216 wxDynamicCast(FindWindow(ID_MapType), wxChoice)->SetSelection(0); 211 217 218 if (wxString(m_MapSettings["GameType"]) == L"wonder") 219 wxDynamicCast(FindWindow(ID_WonderVictoryTimes), wxTextCtrl)->ChangeValue(wxString(m_MapSettings["WonderDuration"])); 220 221 wxDynamicCast(FindWindow(ID_WonderVictoryTimes), wxTextCtrl)->Enable(wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection() == L"wonder"); 222 212 223 // lock teams 213 wxDynamicCast(FindWindow(ID_Map Teams), wxCheckBox)->SetValue(wxString(m_MapSettings["LockTeams"]) == L"true");224 wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->SetValue(wxString(m_MapSettings["LockTeams"]) == L"true"); 214 225 226 // Last Man Standing 227 wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->SetValue(wxString(m_MapSettings["LastManStanding"]) == L"true" && 228 wxString(m_MapSettings["LockTeams"]) != L"true"); 229 230 wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->Enable(!wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue()); 231 215 232 // keywords 216 233 { 217 234 m_MapSettingsKeywords.clear(); … … 248 265 // game type / victory conditions 249 266 m_MapSettings.set("GameType", wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection()); 250 267 268 if (wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection() == L"wonder") 269 m_MapSettings.setInt("WonderDuration", wxAtoi(wxDynamicCast(FindWindow(ID_WonderVictoryTimes), wxTextCtrl)->GetValue())); 270 271 wxDynamicCast(FindWindow(ID_WonderVictoryTimes), wxTextCtrl)->Enable(wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection() == L"wonder"); 272 251 273 // keywords 252 274 { 253 275 if (wxDynamicCast(FindWindow(ID_MapKW_Demo), wxCheckBox)->GetValue()) … … 268 290 } 269 291 270 292 // teams locked 271 m_MapSettings.setBool("LockTeams", wxDynamicCast(FindWindow(ID_Map Teams), wxCheckBox)->GetValue());293 m_MapSettings.setBool("LockTeams", wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue()); 272 294 295 // Last Man Standing (can't be enabled if teams are locked) 296 if (wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue()) 297 wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->SetValue(false); 298 299 wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->Enable(!wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue()); 300 301 m_MapSettings.setBool("LastManStanding", wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->GetValue()); 302 273 303 return m_MapSettings; 274 304 } 275 305