Ticket #4256: 4256_atlas_settings_v1.patch
File 4256_atlas_settings_v1.patch, 11.8 KB (added by , 7 years ago) |
---|
-
binaries/data/mods/_test.sim/simulation/data/settings/map_sizes.json
1 { 2 "TranslatedKeys": ["Name"], 3 "Data": 4 [ 5 { 6 "Name": "Tiny", 7 "Tiles": 128 8 }, 9 { 10 "Name": "Small", 11 "Tiles": 192 12 }, 13 { 14 "Name": "Medium", 15 "Tiles": 256, 16 "Default": true 17 }, 18 { 19 "Name": "Normal", 20 "Tiles": 320 21 }, 22 { 23 "Name": "Large", 24 "Tiles": 384 25 }, 26 { 27 "Name": "Very Large", 28 "Tiles": 448 29 }, 30 { 31 "Name": "Giant", 32 "Tiles": 512 33 } 34 ] 35 } -
binaries/data/mods/_test.sim/simulation/data/settings/wonder_times.json
Property changes on: binaries/data/mods/_test.sim/simulation/data/settings/map_sizes.json ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
1 { 2 "Times": [0, 1, 3, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 75, 90, 105, 120], 3 "Default": 20 4 } -
source/simulation2/Simulation2.cpp
Property changes on: binaries/data/mods/_test.sim/simulation/data/settings/wonder_times.json ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property
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 … … 946 946 return ReadJSON(L"simulation/data/settings/map_sizes.json"); 947 947 } 948 948 949 std::string CSimulation2::GetWonderDurations() 950 { 951 return ReadJSON(L"simulation/data/settings/wonder_times.json"); 952 } 953 949 954 std::string CSimulation2::GetAIData() 950 955 { 951 956 ScriptInterface& scriptInterface = GetScriptInterface(); -
source/simulation2/Simulation2.h
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 … … 263 263 std::string GetMapSizes(); 264 264 265 265 /** 266 * Get wonder duration data 267 * 268 * @return string containing JSON format data 269 */ 270 std::string GetWonderDurations(); 271 272 /** 266 273 * Get AI data 267 274 * 268 275 * @return string containing JSON format data -
source/simulation2/tests/test_Simulation2.h
1 /* Copyright (C) 201 0Wildfire 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 … … 164 164 165 165 TS_ASSERT_OK(sim.ReloadChangedFile(L"simulation/components/hotload/hotload.js")); 166 166 } 167 168 void test_read_JSON() 169 { 170 CSimulation2 sim(NULL, g_ScriptRuntime, &m_Terrain); 171 172 std::string wonderDurations = sim.GetWonderDurations(); 173 174 TS_ASSERT(!wonderDurations.empty()); 175 TS_ASSERT(wonderDurations.c_str()[0] == '{'); 176 TS_ASSERT(wonderDurations.find("Times") != std::string::npos); 177 TS_ASSERT(wonderDurations.find("55") != std::string::npos); 178 TS_ASSERT(wonderDurations.find("Default") != std::string::npos); 179 180 std::string mapSizes = sim.GetMapSizes(); 181 182 TS_ASSERT(!mapSizes.empty()); 183 TS_ASSERT(mapSizes.c_str()[0] == '{'); 184 TS_ASSERT(mapSizes.find("Data") != std::string::npos); 185 TS_ASSERT(mapSizes.find("384") != std::string::npos); 186 TS_ASSERT(mapSizes.find("Default") != std::string::npos); 187 } 167 188 }; -
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 (size_t i = 0; i < gameTypes.Count(); ++i) 150 gameTypes[i] = wxFileName(gameTypes[i]).GetName(); 152 151 152 wxArrayString wonderDurations; 153 AtlasMessage::qGetWonderDurations qrySizes; 154 qrySizes.Post(); 155 AtObj sizes = AtlasObject::LoadFromJSON(*qrySizes.data); 156 153 157 wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5); 154 158 gridSizer->AddGrowableCol(1); 155 159 // TODO: have preview selector tool? … … 162 166 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Game type")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 163 167 gridSizer->Add(Tooltipped(new wxChoice(this, ID_MapType, wxDefaultPosition, wxDefaultSize, gameTypes), 164 168 _("Select the game type (or victory condition)")), wxSizerFlags().Expand()); 169 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Wonder Victory")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 170 gridSizer->Add(Tooltipped(new wxChoice(this, ID_WonderVictoryTimes, wxDefaultPosition, wxDefaultSize, wonderDurations), 171 _("Number of minutes that the player has to keep the wonder in order to win.")), wxSizerFlags().Expand()); 172 173 // get wonder victory times 174 wxChoice* durationChoice = wxDynamicCast(FindWindow(ID_WonderVictoryTimes), wxChoice); 175 for (AtIter s = sizes["Times"]["item"]; s.defined(); ++s) 176 { 177 long time = 0; 178 wxString(s).ToLong(&time); 179 durationChoice->Append(wxString(s), (void*)(intptr_t)time); 180 } 181 durationChoice->SetSelection(0); 182 165 183 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),184 gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapLockTeams, wxEmptyString), 167 185 _("If checked, teams will be locked"))); 186 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Last Man Standing")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 187 gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapLastManStanding, wxEmptyString), 188 _("If checked, the last remaining player will win (not the last remaining set of allies)"))); 168 189 sizer->Add(gridSizer, wxSizerFlags().Expand()); 169 190 170 191 sizer->AddSpacer(5); … … 209 230 else 210 231 wxDynamicCast(FindWindow(ID_MapType), wxChoice)->SetSelection(0); 211 232 233 if (wxString(m_MapSettings["GameType"]) == L"wonder") 234 wxDynamicCast(FindWindow(ID_WonderVictoryTimes), wxChoice)->SetStringSelection(wxString(m_MapSettings["WonderDuration"])); 235 else 236 wxDynamicCast(FindWindow(ID_WonderVictoryTimes), wxChoice)->SetSelection(0); 237 238 wxDynamicCast(FindWindow(ID_WonderVictoryTimes), wxChoice)->Enable(wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection() == L"wonder"); 239 212 240 // lock teams 213 wxDynamicCast(FindWindow(ID_Map Teams), wxCheckBox)->SetValue(wxString(m_MapSettings["LockTeams"]) == L"true");241 wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->SetValue(wxString(m_MapSettings["LockTeams"]) == L"true"); 214 242 243 // Last Man Standing 244 wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->SetValue(wxString(m_MapSettings["LastManStanding"]) == L"true" && 245 wxString(m_MapSettings["LockTeams"]) != L"true"); 246 wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->Enable(!wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue()); 247 215 248 // keywords 216 249 { 217 250 m_MapSettingsKeywords.clear(); … … 248 281 // game type / victory conditions 249 282 m_MapSettings.set("GameType", wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection()); 250 283 284 if (wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection() == L"wonder") 285 m_MapSettings.setInt("WonderDuration", wxAtoi(wxDynamicCast(FindWindow(ID_WonderVictoryTimes), wxChoice)->GetStringSelection())); 286 else 287 wxDynamicCast(FindWindow(ID_WonderVictoryTimes), wxChoice)->SetSelection(0); 288 289 wxDynamicCast(FindWindow(ID_WonderVictoryTimes), wxChoice)->Enable(wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection() == L"wonder"); 290 251 291 // keywords 252 292 { 253 293 if (wxDynamicCast(FindWindow(ID_MapKW_Demo), wxCheckBox)->GetValue()) … … 268 308 } 269 309 270 310 // teams locked 271 m_MapSettings.setBool("LockTeams", wxDynamicCast(FindWindow(ID_Map Teams), wxCheckBox)->GetValue());311 m_MapSettings.setBool("LockTeams", wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue()); 272 312 313 // Last Man Standing (can't be enabled if teams are locked) 314 if (wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue()) 315 wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->SetValue(false); 316 317 wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->Enable(!wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue()); 318 m_MapSettings.setBool("LastManStanding", wxDynamicCast(FindWindow(ID_MapLastManStanding), wxCheckBox)->GetValue()); 319 273 320 return m_MapSettings; 274 321 } 275 322 -
source/tools/atlas/GameInterface/Handlers/MapHandlers.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 … … 312 312 msg->data = g_Game->GetSimulation2()->GetRMSData(); 313 313 } 314 314 315 QUERYHANDLER(GetWonderDurations) 316 { 317 msg->data = g_Game->GetSimulation2()->GetWonderDurations(); 318 } 319 315 320 BEGIN_COMMAND(ResizeMap) 316 321 { 317 322 int m_OldTiles, m_NewTiles; -
source/tools/atlas/GameInterface/Messages.h
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 … … 198 198 ((std::vector<std::string>, data)) 199 199 ); 200 200 201 QUERY(GetWonderDurations, 202 , 203 ((std::string, data)) 204 ); 205 201 206 COMMAND(ResizeMap, NOMERGE, 202 207 ((int, tiles)) 203 208 );