Changeset View
Changeset View
Standalone View
Standalone View
source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp
/* Copyright (C) 2022 Wildfire Games. | /* Copyright (C) 2022 Wildfire Games. | ||||
Lint: Inaccurate Copyright Year: Inaccurate Copyright Year | |||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 568 Lines • ▼ Show 20 Lines | void MapSidebar::OnMapReload() | ||||
UpdateSimButtons(); | UpdateSimButtons(); | ||||
} | } | ||||
void MapSidebar::UpdateSimButtons() | void MapSidebar::UpdateSimButtons() | ||||
{ | { | ||||
wxButton* button; | wxButton* button; | ||||
button = wxDynamicCast(FindWindow(ID_SimPlay), wxButton); | button = wxDynamicCast(FindWindow(ID_SimPlay), wxButton); | ||||
wxCHECK(button, ); | wxCHECK(button, ); | ||||
Lint: syntaxError syntax error Lint: syntaxError: syntax error | |||||
button->Enable(m_SimState != SimPlaying); | button->Enable(m_SimState != SimPlaying); | ||||
button = wxDynamicCast(FindWindow(ID_SimFast), wxButton); | button = wxDynamicCast(FindWindow(ID_SimFast), wxButton); | ||||
wxCHECK(button, ); | wxCHECK(button, ); | ||||
button->Enable(m_SimState != SimPlayingFast); | button->Enable(m_SimState != SimPlayingFast); | ||||
button = wxDynamicCast(FindWindow(ID_SimSlow), wxButton); | button = wxDynamicCast(FindWindow(ID_SimSlow), wxButton); | ||||
wxCHECK(button, ); | wxCHECK(button, ); | ||||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | void MapSidebar::OnRandomGenerate(wxCommandEvent& WXUNUSED(evt)) | ||||
wxBusyInfo busy(_("Generating map")); | wxBusyInfo busy(_("Generating map")); | ||||
wxBusyCursor busyc; | wxBusyCursor busyc; | ||||
wxString scriptName = wxString::FromUTF8(settings["Script"]); | wxString scriptName = wxString::FromUTF8(settings["Script"]); | ||||
// Copy the old map settings, so we don't lose them if the map generation fails | // Copy the old map settings, so we don't lose them if the map generation fails | ||||
AtObj oldSettings = settings; | AtObj oldSettings = settings; | ||||
// Deactivate tools, so they don't carry forwards into the new CWorld | |||||
// and crash. | |||||
m_ScenarioEditor.GetToolManager().SetCurrentTool(_T("")); | |||||
// TODO: clear the undo buffer, etc | |||||
AtlasMessage::qGenerateMap qry((std::wstring)scriptName.wc_str(), json); | AtlasMessage::qGenerateMap qry((std::wstring)scriptName.wc_str(), json); | ||||
qry.Post(); | qry.Post(); | ||||
if (qry.status < 0) | if (qry.status < 0) | ||||
{ | { | ||||
// Display error message and revert to old map settings | // Display error message and revert to old map settings | ||||
wxLogError(_("Random map script '%s' failed"), scriptName.c_str()); | wxLogError(_("Random map script '%s' failed"), scriptName.c_str()); | ||||
m_MapSettingsCtrl->SetMapSettings(oldSettings); | m_MapSettingsCtrl->SetMapSettings(oldSettings); | ||||
} | } | ||||
m_ScenarioEditor.NotifyOnMapReload(); | m_ScenarioEditor.NotifyOnMapReload(); | ||||
m_ScenarioEditor.GetCommandProc().ClearCommands(); | |||||
Done Inline ActionsShouldn't GetCommandProc().ClearCommands(); be also called after the notification? vladislavbelov: Shouldn't `GetCommandProc().ClearCommands();` be also called after the notification? | |||||
Done Inline ActionsGood Catch :D trompetin17: Good Catch :D | |||||
} | } | ||||
void MapSidebar::OnOpenPlayerPanel(wxCommandEvent& WXUNUSED(evt)) | void MapSidebar::OnOpenPlayerPanel(wxCommandEvent& WXUNUSED(evt)) | ||||
{ | { | ||||
m_ScenarioEditor.SelectPage(_T("PlayerSidebar")); | m_ScenarioEditor.SelectPage(_T("PlayerSidebar")); | ||||
} | } | ||||
void MapSidebar::OnResizeMap(wxCommandEvent& WXUNUSED(evt)) | void MapSidebar::OnResizeMap(wxCommandEvent& WXUNUSED(evt)) | ||||
Show All 21 Lines |
Wildfire Games · Phabricator
Inaccurate Copyright Year