- Timestamp:
- 06/10/11 01:45:12 (14 years ago)
- Location:
- ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections
- Files:
-
- 3 added
- 4 edited
-
Map/Map.cpp (modified) (20 diffs)
-
Map/Map.h (modified) (2 diffs)
-
Object/Object.cpp (modified) (11 diffs)
-
Player (added)
-
Player/Player.cpp (added)
-
Player/Player.h (added)
-
Terrain/Terrain.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp
r9599 r9608 20 20 #include "Map.h" 21 21 22 #include "General/Datafile.h" 22 #include "AtlasObject/AtlasObject.h" 23 #include "AtlasScript/ScriptInterface.h" 24 #include "GameInterface/Messages.h" 25 #include "ScenarioEditor/ScenarioEditor.h" 23 26 #include "ScenarioEditor/Tools/Common/Tools.h" 24 #include "ScenarioEditor/ScenarioEditor.h"25 #include "AtlasScript/ScriptInterface.h"26 27 #include "GameInterface/Messages.h"28 27 29 28 #include "wx/busyinfo.h" … … 36 35 ID_MapReveal, 37 36 ID_MapType, 38 ID_Map NumPlayers,37 ID_MapTeams, 39 38 ID_MapKW_Demo, 40 39 ID_MapKW_Hidden, … … 59 58 SimPaused 60 59 }; 60 61 61 bool IsPlaying(int s) { return (s == SimPlaying || s == SimPlayingFast || s == SimPlayingSlow); } 62 63 // TODO: Some of these helper things should be moved out of this file 64 // and into shared locations 62 65 63 66 // Helper function for adding tooltips … … 79 82 }; 80 83 81 // TODO: Some of these helper things should be moved out of this file 82 // and into shared locations 83 84 class MapSettings : public wxPanel 84 class MapSettingsControl : public wxPanel 85 85 { 86 86 public: 87 MapSettings (wxWindow* parent, ScenarioEditor& scenarioEditor);87 MapSettingsControl(wxWindow* parent, ScenarioEditor& scenarioEditor); 88 88 void CreateWidgets(); 89 89 void ReadFromEngine(); … … 97 97 } 98 98 99 void OnEditSpin(wxSpinEvent& WXUNUSED(evt))100 {101 SendToEngine();102 }103 104 static const size_t MAX_NUM_PLAYERS = 8;105 106 AtObj m_MapSettings;107 99 std::set<std::wstring> m_MapSettingsKeywords; 108 109 100 std::vector<wxChoice*> m_PlayerCivChoices; 110 111 101 ScenarioEditor& m_ScenarioEditor; 102 Observable<AtObj>& m_MapSettings; 112 103 113 104 DECLARE_EVENT_TABLE(); 114 105 }; 115 106 116 BEGIN_EVENT_TABLE(MapSettings, wxPanel) 117 EVT_TEXT(ID_MapName, MapSettings::OnEdit) 118 EVT_TEXT(ID_MapDescription, MapSettings::OnEdit) 119 EVT_CHECKBOX(wxID_ANY, MapSettings::OnEdit) 120 EVT_CHOICE(wxID_ANY, MapSettings::OnEdit) 121 EVT_SPINCTRL(ID_MapNumPlayers, MapSettings::OnEditSpin) 107 BEGIN_EVENT_TABLE(MapSettingsControl, wxPanel) 108 EVT_TEXT(ID_MapName, MapSettingsControl::OnEdit) 109 EVT_TEXT(ID_MapDescription, MapSettingsControl::OnEdit) 110 EVT_CHECKBOX(wxID_ANY, MapSettingsControl::OnEdit) 111 EVT_CHOICE(wxID_ANY, MapSettingsControl::OnEdit) 122 112 END_EVENT_TABLE(); 123 113 124 MapSettings ::MapSettings(wxWindow* parent, ScenarioEditor& scenarioEditor)125 : wxPanel(parent, wxID_ANY), m_ScenarioEditor(scenarioEditor) 114 MapSettingsControl::MapSettingsControl(wxWindow* parent, ScenarioEditor& scenarioEditor) 115 : wxPanel(parent, wxID_ANY), m_ScenarioEditor(scenarioEditor), m_MapSettings(scenarioEditor.GetMapSettings()) 126 116 { 127 117 wxStaticBoxSizer* sizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Map settings")); … … 129 119 } 130 120 131 void MapSettings ::CreateWidgets()121 void MapSettingsControl::CreateWidgets() 132 122 { 133 123 wxSizer* sizer = GetSizer(); … … 146 136 _("Short description used on the map selection screen")), wxSizerFlags().Expand()); 147 137 138 sizer->AddSpacer(5); 139 148 140 wxArrayString gameTypes; 149 141 gameTypes.Add(_T("conquest")); 150 142 gameTypes.Add(_T("endless")); 151 143 152 wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 2 );144 wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 2, 5, 5); 153 145 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Reveal map")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 154 146 gridSizer->Add(new wxCheckBox(this, ID_MapReveal, wxEmptyString)); 155 147 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Game type")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 156 148 gridSizer->Add(new wxChoice(this, ID_MapType, wxDefaultPosition, wxDefaultSize, gameTypes)); 149 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Lock teams")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 150 gridSizer->Add(new wxCheckBox(this, ID_MapTeams, wxEmptyString)); 157 151 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Num players")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 158 wxSpinCtrl* numPlayersSpin = new wxSpinCtrl(this, ID_MapNumPlayers, wxEmptyString, wxDefaultPosition, wxSize(40, -1));159 numPlayersSpin->SetValue(MAX_NUM_PLAYERS);160 numPlayersSpin->SetRange(1, MAX_NUM_PLAYERS);161 gridSizer->Add(numPlayersSpin);162 163 152 sizer->Add(gridSizer); 164 153 165 166 wxArrayString civNames; 167 wxArrayString civCodes; 168 AtlasMessage::qGetCivData qryCiv; 169 qryCiv.Post(); 170 std::vector<std::string> civData = *qryCiv.data; 171 for (size_t i = 0; i < civData.size(); ++i) 172 { 173 AtObj civ = AtlasObject::LoadFromJSON(m_ScenarioEditor.GetScriptInterface().GetContext(), civData[i]); 174 civNames.Add(wxString(civ["Name"])); 175 civCodes.Add(wxString(civ["Code"])); 176 } 177 178 wxCollapsiblePane* playersPane = new wxCollapsiblePane(this, wxID_ANY, _("Player settings"), wxDefaultPosition, wxDefaultSize, wxCP_NO_TLW_RESIZE); 179 wxFlexGridSizer* playersPaneSizer = new wxFlexGridSizer(2); 180 playersPaneSizer->AddGrowableCol(1); 181 playersPaneSizer->Add(new wxStaticText(playersPane->GetPane(), wxID_ANY, _T(""))); 182 playersPaneSizer->Add(new wxStaticText(playersPane->GetPane(), wxID_ANY, _("Civ"))); 183 for (size_t i = 0; i < MAX_NUM_PLAYERS; ++i) 184 { 185 wxString idStr; 186 idStr << (i+1); 187 playersPaneSizer->Add(new wxStaticText(playersPane->GetPane(), wxID_ANY, idStr), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT).Border(wxRIGHT, 2)); 188 wxChoice* civChoice = new wxChoice(playersPane->GetPane(), wxID_ANY); 189 for (size_t j = 0; j < civNames.Count(); ++j) 190 civChoice->Append(civNames[j], new wxStringClientData(civCodes[j])); 191 m_PlayerCivChoices.push_back(civChoice); 192 playersPaneSizer->Add(civChoice); 193 194 // TODO: Team 195 // TODO: Resources? 196 } 197 playersPane->GetPane()->SetSizer(playersPaneSizer); 198 sizer->Add(playersPane, wxSizerFlags().Expand()); 154 sizer->AddSpacer(5); 199 155 200 156 wxStaticBoxSizer* keywordsSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Keywords")); 201 wxFlexGridSizer* kwGridSizer = new wxFlexGridSizer(2, 2 );157 wxFlexGridSizer* kwGridSizer = new wxFlexGridSizer(2, 2, 5, 5); 202 158 kwGridSizer->Add(new wxStaticText(this, wxID_ANY, _("Demo")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 203 159 kwGridSizer->Add(new wxCheckBox(this, ID_MapKW_Demo, wxEmptyString)); … … 208 164 } 209 165 210 void MapSettings ::ReadFromEngine()166 void MapSettingsControl::ReadFromEngine() 211 167 { 212 168 AtlasMessage::qGetMapSettings qry; 213 169 qry.Post(); 214 m_MapSettings = AtlasObject::LoadFromJSON(m_ScenarioEditor.GetScriptInterface().GetContext(), *qry.settings); 170 if (!(*qry.settings).empty()) 171 { 172 // Prevent error if there's no map settings to parse 173 m_MapSettings = AtlasObject::LoadFromJSON(m_ScenarioEditor.GetScriptInterface().GetContext(), *qry.settings); 174 } 215 175 216 176 m_MapSettingsKeywords.clear(); … … 229 189 wxDynamicCast(FindWindow(ID_MapType), wxChoice)->SetSelection(0); 230 190 231 size_t numPlayers = m_MapSettings["PlayerData"]["item"].count(); 232 wxDynamicCast(FindWindow(ID_MapNumPlayers), wxSpinCtrl)->SetValue(numPlayers); 233 234 AtIter player = m_MapSettings["PlayerData"]["item"]; 235 for (size_t i = 0; i < numPlayers && i < MAX_NUM_PLAYERS; ++i, ++player) 236 { 237 wxChoice* choice = m_PlayerCivChoices[i]; 238 choice->Enable(true); 239 wxString civCode(player["Civ"]); 240 for (size_t j = 0; j < choice->GetCount(); ++j) 241 { 242 wxStringClientData* str = dynamic_cast<wxStringClientData*>(choice->GetClientObject(j)); 243 if (str->GetData() == civCode) 244 { 245 choice->SetSelection(j); 246 break; 247 } 248 } 249 } 250 for (size_t i = numPlayers; i < MAX_NUM_PLAYERS; ++i) 251 { 252 wxChoice* choice = m_PlayerCivChoices[i]; 253 choice->SetSelection(0); 254 choice->Enable(false); 255 } 191 wxDynamicCast(FindWindow(ID_MapTeams), wxCheckBox)->SetValue(wxString(m_MapSettings["LockTeams"]) == L"true"); 256 192 257 193 wxDynamicCast(FindWindow(ID_MapKW_Demo), wxCheckBox)->SetValue(m_MapSettingsKeywords.count(L"demo") != 0); … … 259 195 } 260 196 261 AtObj MapSettings ::UpdateSettingsObject()197 AtObj MapSettingsControl::UpdateSettingsObject() 262 198 { 263 199 m_MapSettings.set("Name", wxDynamicCast(FindWindow(ID_MapName), wxTextCtrl)->GetValue()); … … 268 204 269 205 m_MapSettings.set("GameType", wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection()); 270 271 AtIter oldPlayer = m_MapSettings["PlayerData"]["item"];272 AtObj players;273 players.set("@array", L"");274 size_t numPlayers = (size_t)wxDynamicCast(FindWindow(ID_MapNumPlayers), wxSpinCtrl)->GetValue();275 for (size_t i = 0; i < numPlayers && i < MAX_NUM_PLAYERS; ++i)276 {277 wxChoice* choice = m_PlayerCivChoices[i];278 choice->Enable(true);279 AtObj player = *oldPlayer;280 if (choice->GetSelection() >= 0)281 {282 wxStringClientData* str = dynamic_cast<wxStringClientData*>(choice->GetClientObject(choice->GetSelection()));283 player.set("Civ", str->GetData());284 }285 players.add("item", player);286 if (oldPlayer.defined())287 ++oldPlayer;288 }289 for (size_t i = numPlayers; i < MAX_NUM_PLAYERS; ++i)290 {291 wxChoice* choice = m_PlayerCivChoices[i];292 choice->Enable(false);293 }294 m_MapSettings.set("PlayerData", players);295 206 296 207 if (wxDynamicCast(FindWindow(ID_MapKW_Demo), wxCheckBox)->GetValue()) … … 303 214 else 304 215 m_MapSettingsKeywords.erase(L"hidden"); 216 217 m_MapSettings.setBool("LockTeams", wxDynamicCast(FindWindow(ID_MapTeams), wxCheckBox)->GetValue()); 305 218 306 219 AtObj keywords; … … 313 226 } 314 227 315 void MapSettings ::SendToEngine()228 void MapSettingsControl::SendToEngine() 316 229 { 317 230 UpdateSettingsObject(); … … 321 234 // TODO: would be nice if we supported undo for settings changes 322 235 323 POST_ MESSAGE(SetMapSettings, (json));236 POST_COMMAND(SetMapSettings, (json)); 324 237 } 325 238 … … 328 241 : Sidebar(scenarioEditor, sidebarContainer, bottomBarContainer), m_SimState(SimInactive) 329 242 { 330 m_MapSettings = new MapSettings(this, m_ScenarioEditor);331 m_MainSizer->Add(m_MapSettings , wxSizerFlags().Expand());243 m_MapSettingsCtrl = new MapSettingsControl(this, m_ScenarioEditor); 244 m_MainSizer->Add(m_MapSettingsCtrl, wxSizerFlags().Expand()); 332 245 333 246 { … … 336 249 sizer->Add(new wxChoice(this, ID_RandomScript), wxSizerFlags().Expand()); 337 250 338 wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 2); 251 sizer->AddSpacer(5); 252 253 wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 2, 5, 5); 339 254 gridSizer->AddGrowableCol(1); 340 255 341 256 wxChoice* sizeChoice = new wxChoice(this, ID_RandomSize); 342 AtObj sizes(Datafile::ReadList("mapsizes"));343 for (AtIter s = sizes["size"]; s.defined(); ++s)344 {345 long tiles = 0;346 wxString(s["@tiles"]).ToLong(&tiles);347 sizeChoice->Append(wxString(s["@name"]), (void*)(intptr_t)tiles);348 }349 sizeChoice->SetSelection(0);350 257 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Map size")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 351 258 gridSizer->Add(sizeChoice, wxSizerFlags().Expand()); … … 353 260 gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Random seed")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); 354 261 wxBoxSizer* seedSizer = new wxBoxSizer(wxHORIZONTAL); 355 seedSizer->Add( new wxTextCtrl(this, ID_RandomSeed, _T("0")), wxSizerFlags(1).Expand());356 seedSizer->Add( new wxButton(this, ID_RandomReseed, _("R"), wxDefaultPosition, wxSize(24, -1)));262 seedSizer->Add(Tooltipped(new wxTextCtrl(this, ID_RandomSeed, _T("0"), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_NUMERIC)), _("Seed value for random map")), wxSizerFlags(1).Expand()); 263 seedSizer->Add(Tooltipped(new wxButton(this, ID_RandomReseed, _("R"), wxDefaultPosition, wxSize(24, -1)), _("New random seed"))); 357 264 gridSizer->Add(seedSizer, wxSizerFlags().Expand()); 358 265 359 266 sizer->Add(gridSizer, wxSizerFlags().Expand()); 267 268 sizer->AddSpacer(5); 360 269 361 270 sizer->Add(new wxButton(this, ID_RandomGenerate, _("Generate map")), wxSizerFlags().Expand()); … … 391 300 void MapSidebar::OnFirstDisplay() 392 301 { 393 m_MapSettings->CreateWidgets(); 394 m_MapSettings->ReadFromEngine(); 395 396 // Load the RMS script list: 397 302 // We do this here becase messages are used which requires simulation to be init'd 303 m_MapSettingsCtrl->CreateWidgets(); 304 m_MapSettingsCtrl->ReadFromEngine(); 305 306 // Load the map sizes list 307 AtlasMessage::qGetMapSizes qrySizes; 308 qrySizes.Post(); 309 AtObj sizes = AtlasObject::LoadFromJSON(m_ScenarioEditor.GetScriptInterface().GetContext(), *qrySizes.sizes); 310 wxChoice* sizeChoice = wxDynamicCast(FindWindow(ID_RandomSize), wxChoice); 311 for (AtIter s = sizes["Sizes"]["item"]; s.defined(); ++s) 312 { 313 long tiles = 0; 314 wxString(s["Tiles"]).ToLong(&tiles); 315 sizeChoice->Append(wxString(s["Name"]), (void*)(intptr_t)tiles); 316 } 317 sizeChoice->SetSelection(0); 318 319 // Load the RMS script list 398 320 AtlasMessage::qGetRMSData qry; 399 321 qry.Post(); 400 322 std::vector<std::string> scripts = *qry.data; 401 402 323 wxChoice* scriptChoice = wxDynamicCast(FindWindow(ID_RandomScript), wxChoice); 403 324 scriptChoice->Clear(); … … 415 336 void MapSidebar::OnMapReload() 416 337 { 417 m_MapSettings ->ReadFromEngine();338 m_MapSettingsCtrl->ReadFromEngine(); 418 339 } 419 340 … … 519 440 // since it's mixing data from three different sources 520 441 521 AtObj settings = m_MapSettings ->UpdateSettingsObject();442 AtObj settings = m_MapSettingsCtrl->UpdateSettingsObject(); 522 443 523 444 AtObj scriptSettings = dynamic_cast<AtObjClientData*>(scriptChoice->GetClientObject(scriptChoice->GetSelection()))->GetValue(); -
ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.h
r9566 r9608 20 20 #include "wx/collpane.h" 21 21 22 class MapSettings ;22 class MapSettingsControl; 23 23 24 24 class MapSidebar : public Sidebar … … 33 33 34 34 private: 35 MapSettings * m_MapSettings;35 MapSettingsControl* m_MapSettingsCtrl; 36 36 37 37 void OnCollapse(wxCollapsiblePaneEvent& evt); -
ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Object/Object.cpp
r9570 r9608 21 21 22 22 #include "Buttons/ToolButton.h" 23 #include "General/Datafile.h" 23 24 #include "ScenarioEditor/ScenarioEditor.h" 24 25 #include "ScenarioEditor/Tools/Common/ObjectSettings.h" 25 26 #include "ScenarioEditor/Tools/Common/MiscState.h" 27 #include "AtlasScript/ScriptInterface.h" 26 28 #include "VariationControl.h" 27 29 … … 33 35 { 34 36 ID_ObjectType = 1, 37 ID_PlayerSelect, 35 38 ID_SelectObject, 36 39 ID_ToggleViewer, … … 56 59 { 57 60 public: 58 ObjectBottomBar(wxWindow* parent, Observable<ObjectSettings>& objectSettings, ObjectSidebarImpl* p);61 ObjectBottomBar(wxWindow* parent, ScenarioEditor& scenarioEditor, Observable<ObjectSettings>& objectSettings, Observable<AtObj>& mapSettings, ObjectSidebarImpl* p); 59 62 60 63 void OnFirstDisplay(); … … 76 79 77 80 ObjectSidebarImpl* p; 81 82 ScenarioEditor& m_ScenarioEditor; 78 83 79 84 DECLARE_EVENT_TABLE(); … … 118 123 m_MainSizer->Add(new wxButton(this, ID_ToggleViewer, _("Switch to Actor Viewer")), wxSizerFlags().Expand()); 119 124 120 m_BottomBar = new ObjectBottomBar(bottomBarContainer, scenarioEditor .GetObjectSettings(), p);125 m_BottomBar = new ObjectBottomBar(bottomBarContainer, scenarioEditor, scenarioEditor.GetObjectSettings(), scenarioEditor.GetMapSettings(), p); 121 126 122 127 p->m_ToolConn = scenarioEditor.GetToolManager().GetCurrentTool().RegisterObserver(0, &ObjectSidebar::OnToolChange, this); … … 220 225 { 221 226 public: 222 PlayerComboBox(wxWindow* parent, wxArrayString& choices, Observable<ObjectSettings>& objectSettings) 223 : wxComboBox(parent, -1, choices[objectSettings.GetPlayerID()], wxDefaultPosition, wxDefaultSize, choices, wxCB_READONLY) 224 , m_ObjectSettings(objectSettings) 225 { 226 m_Conn = m_ObjectSettings.RegisterObserver(1, &PlayerComboBox::OnObjectSettingsChange, this); 227 PlayerComboBox(wxWindow* parent, Observable<ObjectSettings>& objectSettings, Observable<AtObj>& mapSettings) 228 : wxComboBox(parent, ID_PlayerSelect, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, wxCB_READONLY) 229 , m_ObjectSettings(objectSettings), m_MapSettings(mapSettings) 230 { 231 m_ObjectConn = m_ObjectSettings.RegisterObserver(1, &PlayerComboBox::OnObjectSettingsChange, this); 232 m_MapConn = m_MapSettings.RegisterObserver(1, &PlayerComboBox::OnMapSettingsChange, this); 233 } 234 235 void SetPlayers(wxArrayString& names) 236 { 237 m_Players = names; 238 OnMapSettingsChange(m_MapSettings); 227 239 } 228 240 229 241 private: 230 242 231 ObservableScopedConnection m_ Conn;243 ObservableScopedConnection m_ObjectConn; 232 244 Observable<ObjectSettings>& m_ObjectSettings; 245 ObservableScopedConnection m_MapConn; 246 Observable<AtObj>& m_MapSettings; 247 wxArrayString m_Players; 233 248 234 249 void OnObjectSettingsChange(const ObjectSettings& settings) … … 237 252 } 238 253 254 void OnMapSettingsChange(const AtObj& settings) 255 { 256 // Adjust displayed number of players 257 Clear(); 258 size_t numPlayers = settings["PlayerData"]["item"].count(); 259 for (size_t i = 0; i <= numPlayers; ++i) 260 { 261 Append(m_Players[i]); 262 } 263 264 if (m_ObjectSettings.GetPlayerID() > numPlayers) 265 { 266 // Invalid player 267 SetSelection((long)numPlayers); 268 } 269 else 270 { 271 SetSelection((long)m_ObjectSettings.GetPlayerID()); 272 } 273 } 274 239 275 void OnSelect(wxCommandEvent& evt) 240 276 { 241 277 m_ObjectSettings.SetPlayerID(evt.GetInt()); 242 m_ObjectSettings.NotifyObserversExcept(m_ Conn);278 m_ObjectSettings.NotifyObserversExcept(m_ObjectConn); 243 279 } 244 280 … … 251 287 ////////////////////////////////////////////////////////////////////////// 252 288 253 ObjectBottomBar::ObjectBottomBar(wxWindow* parent, Observable<ObjectSettings>& objectSettings, ObjectSidebarImpl* p)254 : wxPanel(parent, wxID_ANY), p(p) 289 ObjectBottomBar::ObjectBottomBar(wxWindow* parent, ScenarioEditor& scenarioEditor, Observable<ObjectSettings>& objectSettings, Observable<AtObj>& mapSettings, ObjectSidebarImpl* p) 290 : wxPanel(parent, wxID_ANY), p(p), m_ScenarioEditor(scenarioEditor) 255 291 { 256 292 m_ViewerWireframe = false; … … 277 313 wxSizer* viewerAnimSizer = new wxStaticBoxSizer(wxVERTICAL, m_ViewerPanel, _("Animation")); 278 314 279 wxString animChoices[] = { 280 _T("idle"), _T("walk"), _T("run"), _T("melee"), _T("death"), _T("build"), 281 _T("gather_fruit"), _T("gather_grain"), _T("gather_meat"), _T("gather_tree"), 282 _T("gather_rock"), _T("gather_ore"), _T("gather_ruins"), _T("gather_treasure") 283 }; // TODO: this list should come from the actor 284 wxChoice* viewerAnimSelector = new wxChoice(m_ViewerPanel, ID_ViewerAnimation, wxDefaultPosition, wxDefaultSize, sizeof(animChoices)/sizeof(animChoices[0]), animChoices); 315 // TODO: this list should come from the actor 316 wxArrayString animChoices; 317 AtObj anims (Datafile::ReadList("animations")); 318 for (AtIter a = anims["item"]; a.defined(); ++a) 319 { 320 animChoices.Add(wxString(*a)); 321 } 322 wxChoice* viewerAnimSelector = new wxChoice(m_ViewerPanel, ID_ViewerAnimation, wxDefaultPosition, wxDefaultSize, animChoices); 285 323 viewerAnimSelector->SetSelection(0); 286 324 viewerAnimSizer->Add(viewerAnimSelector, wxSizerFlags().Expand()); … … 302 340 wxSizer* playerVariationSizer = new wxBoxSizer(wxVERTICAL); 303 341 304 wxArrayString players;305 // TODO: get proper player names306 players.Add(_("Gaia"));307 players.Add(_("Player 1"));308 players.Add(_("Player 2"));309 players.Add(_("Player 3"));310 players.Add(_("Player 4"));311 players.Add(_("Player 5"));312 players.Add(_("Player 6"));313 players.Add(_("Player 7"));314 players.Add(_("Player 8"));315 wxComboBox* playerSelect = new PlayerComboBox(this, players, objectSettings);316 342 // TODO: make this a wxChoice instead 343 wxComboBox* playerSelect = new PlayerComboBox(this, objectSettings, mapSettings); 317 344 playerVariationSizer->Add(playerSelect); 318 345 … … 330 357 void ObjectBottomBar::OnFirstDisplay() 331 358 { 359 // We use messages here because the simulation is not init'd otherwise (causing a crash) 360 361 // Get player names 362 wxArrayString players; 363 AtlasMessage::qGetPlayerDefaults qryPlayers; 364 qryPlayers.Post(); 365 AtObj playerData = AtlasObject::LoadFromJSON(m_ScenarioEditor.GetScriptInterface().GetContext(), *qryPlayers.defaults); 366 AtObj playerDefs = *playerData["PlayerData"]; 367 for (AtIter p = playerDefs["item"]; p.defined(); ++p) 368 { 369 players.Add(wxString(p["Name"])); 370 } 371 wxDynamicCast(FindWindow(ID_PlayerSelect), PlayerComboBox)->SetPlayers(players); 372 332 373 // Initialise the game with the default settings 333 374 POST_MESSAGE(SetViewParamB, (AtlasMessage::eRenderView::ACTOR, L"wireframe", m_ViewerWireframe)); -
ps/trunk/source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Terrain/Terrain.cpp
r9570 r9608 21 21 22 22 #include "Buttons/ToolButton.h" 23 #include "General/Datafile.h"24 23 #include "ScenarioEditor/ScenarioEditor.h" 25 24 #include "ScenarioEditor/Tools/Common/Brushes.h" 26 25 #include "ScenarioEditor/Tools/Common/MiscState.h" 26 #include "AtlasScript/ScriptInterface.h" 27 27 28 28 #include "GameInterface/Messages.h" … … 139 139 std::vector<size_t> sizeTiles; 140 140 141 AtObj sizes(Datafile::ReadList("mapsizes")); 142 for (AtIter s = sizes["size"]; s.defined(); ++s) 141 // Load the map sizes list 142 AtlasMessage::qGetMapSizes qrySizes; 143 qrySizes.Post(); 144 AtObj sizes = AtlasObject::LoadFromJSON(m_ScenarioEditor.GetScriptInterface().GetContext(), *qrySizes.sizes); 145 for (AtIter s = sizes["Sizes"]["item"]; s.defined(); ++s) 143 146 { 144 147 long tiles = 0; 145 wxString(s[" @tiles"]).ToLong(&tiles);146 sizeNames.Add(wxString(s[" @name"]));148 wxString(s["Tiles"]).ToLong(&tiles); 149 sizeNames.Add(wxString(s["Name"])); 147 150 sizeTiles.push_back((size_t)tiles); 148 151 }
Note:
See TracChangeset
for help on using the changeset viewer.
