Changeset View
Changeset View
Standalone View
Standalone View
source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp
Show All 15 Lines | |||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "Map.h" | #include "Map.h" | ||||
#include "AtlasObject/AtlasObject.h" | #include "AtlasObject/AtlasObject.h" | ||||
#include "GameInterface/Messages.h" | #include "GameInterface/Messages.h" | ||||
#include "General/Datafile.h" | |||||
#include "ScenarioEditor/ScenarioEditor.h" | #include "ScenarioEditor/ScenarioEditor.h" | ||||
#include "ScenarioEditor/Tools/Common/Tools.h" | #include "ScenarioEditor/Tools/Common/Tools.h" | ||||
#include "wx/busyinfo.h" | #include "wx/busyinfo.h" | ||||
#include "wx/filename.h" | #include "wx/filename.h" | ||||
enum | enum | ||||
{ | { | ||||
ID_MapName, | ID_MapName, | ||||
ID_MapDescription, | ID_MapDescription, | ||||
ID_MapPreview, | |||||
ID_MapReveal, | ID_MapReveal, | ||||
ID_MapType, | ID_MapType, | ||||
ID_MapPreview, | ID_MapVictoryDurationTime, | ||||
ID_MapTeams, | ID_MapLockTeams, | ||||
ID_MapLastManStanding, | |||||
ID_MapKW_Demo, | ID_MapKW_Demo, | ||||
ID_MapKW_Naval, | ID_MapKW_Naval, | ||||
ID_RandomScript, | ID_RandomScript, | ||||
ID_OpenPlayerPanel, | |||||
vladislavbelov: What's the reason of the reordering? If alphabetic order, why `ID_Map*` aren't sorted? | |||||
ID_RandomSize, | ID_RandomSize, | ||||
ID_RandomSeed, | ID_RandomSeed, | ||||
ID_RandomReseed, | ID_RandomReseed, | ||||
ID_RandomGenerate, | ID_RandomGenerate, | ||||
ID_SimPlay, | ID_SimPlay, | ||||
ID_SimFast, | ID_SimFast, | ||||
ID_SimSlow, | ID_SimSlow, | ||||
ID_SimPause, | ID_SimPause, | ||||
ID_SimReset, | ID_SimReset | ||||
ID_OpenPlayerPanel | |||||
}; | }; | ||||
enum | enum | ||||
{ | { | ||||
SimInactive, | SimInactive, | ||||
SimPlaying, | SimPlaying, | ||||
SimPlayingFast, | SimPlayingFast, | ||||
SimPlayingSlow, | SimPlayingSlow, | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | void MapSettingsControl::CreateWidgets() | ||||
sizer->Add(0, 2); | sizer->Add(0, 2); | ||||
sizer->Add(new wxStaticText(this, wxID_ANY, _("Description"))); | sizer->Add(new wxStaticText(this, wxID_ANY, _("Description"))); | ||||
sizer->Add(Tooltipped(new wxTextCtrl(this, ID_MapDescription, wxEmptyString, wxDefaultPosition, wxSize(-1, 100), wxTE_MULTILINE), | sizer->Add(Tooltipped(new wxTextCtrl(this, ID_MapDescription, wxEmptyString, wxDefaultPosition, wxSize(-1, 100), wxTE_MULTILINE), | ||||
_("Short description used on the map selection screen")), wxSizerFlags().Expand()); | _("Short description used on the map selection screen")), wxSizerFlags().Expand()); | ||||
sizer->AddSpacer(5); | sizer->AddSpacer(5); | ||||
// TODO: replace by filenames in binaries/data/mods/public/simulation/data/settings/victory_conditions/ | wxArrayString gameTypes = Datafile::EnumerateDataFiles(_T("mods/public/simulation/data/settings/victory_conditions/"), _T("*.json")); | ||||
wxArrayString gameTypes; | // Discard path and extension of game types | ||||
gameTypes.Add(_T("conquest")); | for (wxString& gameType : gameTypes) | ||||
vladislavbelovUnsubmitted Not Done Inline ActionsIt should be: for (const wxString& gameType : gameTypes) vladislavbelov: It should be:
```lang=cpp
for (const wxString& gameType : gameTypes)
``` | |||||
gameTypes.Add(_T("conquest_structures")); | gameType = wxFileName(gameType).GetName(); | ||||
gameTypes.Add(_T("conquest_units")); | |||||
gameTypes.Add(_T("wonder")); | |||||
gameTypes.Add(_T("endless")); | |||||
gameTypes.Add(_T("regicide")); | |||||
gameTypes.Add(_T("capture_the_relic")); | |||||
wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5); | wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5); | ||||
gridSizer->AddGrowableCol(1); | gridSizer->AddGrowableCol(1); | ||||
// TODO: have preview selector tool? | // TODO: have preview selector tool? | ||||
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Preview")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Preview")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | ||||
gridSizer->Add(Tooltipped(new wxTextCtrl(this, ID_MapPreview, wxEmptyString), | gridSizer->Add(Tooltipped(new wxTextCtrl(this, ID_MapPreview, wxEmptyString), | ||||
_("Texture used for map preview")), wxSizerFlags().Expand()); | _("Texture used for map preview")), wxSizerFlags().Expand()); | ||||
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Reveal map")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Reveal map")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | ||||
gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapReveal, wxEmptyString), | gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapReveal, wxEmptyString), | ||||
_("If checked, players won't need to explore"))); | _("If checked, players won't need to explore"))); | ||||
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Game type")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | 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), | gridSizer->Add(Tooltipped(new wxChoice(this, ID_MapType, wxDefaultPosition, wxDefaultSize, gameTypes), | ||||
_("Select the game type (or victory condition)")), wxSizerFlags().Expand()); | _("Select the game type (or victory condition)")), wxSizerFlags().Expand()); | ||||
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Victory duration")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | |||||
gridSizer->Add(Tooltipped(new wxTextCtrl(this, ID_MapVictoryDurationTime, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_DIGITS)), | |||||
vladislavbelovUnsubmitted Not Done Inline ActionswxFILTER_DIGITS doesn't present in the wxWidgets 2.8, so it's invalid. http://docs.wxwidgets.org/2.8/wx_wxtextvalidator.html#wxtextvalidator vladislavbelov: `wxFILTER_DIGITS` doesn't present in the `wxWidgets` 2.8, so it's invalid.
http://docs. | |||||
_("Number of minutes until the player has won (only for certain victory conditions)")), wxSizerFlags().Expand()); | |||||
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Lock teams")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | 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"))); | _("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->Add(gridSizer, wxSizerFlags().Expand()); | ||||
sizer->AddSpacer(5); | sizer->AddSpacer(5); | ||||
wxStaticBoxSizer* keywordsSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Keywords")); | wxStaticBoxSizer* keywordsSizer = new wxStaticBoxSizer(wxVERTICAL, this, _("Keywords")); | ||||
wxFlexGridSizer* kwGridSizer = new wxFlexGridSizer(4, 5, 5); | wxFlexGridSizer* kwGridSizer = new wxFlexGridSizer(4, 5, 5); | ||||
kwGridSizer->Add(new wxStaticText(this, wxID_ANY, _("Demo")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | kwGridSizer->Add(new wxStaticText(this, wxID_ANY, _("Demo")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | ||||
kwGridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapKW_Demo, wxEmptyString), | kwGridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapKW_Demo, wxEmptyString), | ||||
Show All 28 Lines | void MapSettingsControl::ReadFromEngine() | ||||
wxDynamicCast(FindWindow(ID_MapReveal), wxCheckBox)->SetValue(wxString(m_MapSettings["RevealMap"]) == L"true"); | wxDynamicCast(FindWindow(ID_MapReveal), wxCheckBox)->SetValue(wxString(m_MapSettings["RevealMap"]) == L"true"); | ||||
// game type / victory conditions | // game type / victory conditions | ||||
if (m_MapSettings["GameType"].defined()) | if (m_MapSettings["GameType"].defined()) | ||||
wxDynamicCast(FindWindow(ID_MapType), wxChoice)->SetStringSelection(wxString(m_MapSettings["GameType"])); | wxDynamicCast(FindWindow(ID_MapType), wxChoice)->SetStringSelection(wxString(m_MapSettings["GameType"])); | ||||
else | else | ||||
wxDynamicCast(FindWindow(ID_MapType), wxChoice)->SetSelection(0); | wxDynamicCast(FindWindow(ID_MapType), wxChoice)->SetSelection(0); | ||||
if (wxString(m_MapSettings["GameType"]) == L"wonder" || wxString(m_MapSettings["GameType"]) == L"capture_the_relic") | |||||
wxDynamicCast(FindWindow(ID_MapVictoryDurationTime), wxTextCtrl)->ChangeValue(wxString(m_MapSettings["VictoryDuration"])); | |||||
wxString mapGameType = wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection(); | |||||
wxDynamicCast(FindWindow(ID_MapVictoryDurationTime), wxTextCtrl)->Enable(mapGameType == L"wonder" || mapGameType == L"capture_the_relic"); | |||||
// lock teams | // 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 | // keywords | ||||
{ | { | ||||
m_MapSettingsKeywords.clear(); | m_MapSettingsKeywords.clear(); | ||||
for (AtIter keyword = m_MapSettings["Keywords"]["item"]; keyword.defined(); ++keyword) | for (AtIter keyword = m_MapSettings["Keywords"]["item"]; keyword.defined(); ++keyword) | ||||
m_MapSettingsKeywords.insert(std::wstring(keyword)); | m_MapSettingsKeywords.insert(std::wstring(keyword)); | ||||
wxDynamicCast(FindWindow(ID_MapKW_Demo), wxCheckBox)->SetValue(m_MapSettingsKeywords.count(L"demo") != 0); | wxDynamicCast(FindWindow(ID_MapKW_Demo), wxCheckBox)->SetValue(m_MapSettingsKeywords.count(L"demo") != 0); | ||||
Show All 19 Lines | AtObj MapSettingsControl::UpdateSettingsObject() | ||||
// map preview | // map preview | ||||
m_MapSettings.set("Preview", wxDynamicCast(FindWindow(ID_MapPreview), wxTextCtrl)->GetValue()); | m_MapSettings.set("Preview", wxDynamicCast(FindWindow(ID_MapPreview), wxTextCtrl)->GetValue()); | ||||
// reveal map | // reveal map | ||||
m_MapSettings.setBool("RevealMap", wxDynamicCast(FindWindow(ID_MapReveal), wxCheckBox)->GetValue()); | m_MapSettings.setBool("RevealMap", wxDynamicCast(FindWindow(ID_MapReveal), wxCheckBox)->GetValue()); | ||||
// game type / victory conditions | // game type / victory conditions | ||||
m_MapSettings.set("GameType", wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection()); | wxString mapGameType = wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection(); | ||||
m_MapSettings.set("GameType", mapGameType); | |||||
if (mapGameType == L"wonder" || mapGameType == L"capture_the_relic") | |||||
m_MapSettings.setInt("VictoryDuration", wxAtoi(wxDynamicCast(FindWindow(ID_MapVictoryDurationTime), wxTextCtrl)->GetValue())); | |||||
wxDynamicCast(FindWindow(ID_MapVictoryDurationTime), wxTextCtrl)->Enable(mapGameType == L"wonder" || mapGameType == L"capture_the_relic"); | |||||
// keywords | // keywords | ||||
{ | { | ||||
if (wxDynamicCast(FindWindow(ID_MapKW_Demo), wxCheckBox)->GetValue()) | if (wxDynamicCast(FindWindow(ID_MapKW_Demo), wxCheckBox)->GetValue()) | ||||
m_MapSettingsKeywords.insert(L"demo"); | m_MapSettingsKeywords.insert(L"demo"); | ||||
else | else | ||||
m_MapSettingsKeywords.erase(L"demo"); | m_MapSettingsKeywords.erase(L"demo"); | ||||
if (wxDynamicCast(FindWindow(ID_MapKW_Naval), wxCheckBox)->GetValue()) | if (wxDynamicCast(FindWindow(ID_MapKW_Naval), wxCheckBox)->GetValue()) | ||||
m_MapSettingsKeywords.insert(L"naval"); | m_MapSettingsKeywords.insert(L"naval"); | ||||
else | else | ||||
m_MapSettingsKeywords.erase(L"naval"); | m_MapSettingsKeywords.erase(L"naval"); | ||||
AtObj keywords; | AtObj keywords; | ||||
keywords.set("@array", L""); | keywords.set("@array", L""); | ||||
for (std::set<std::wstring>::iterator it = m_MapSettingsKeywords.begin(); it != m_MapSettingsKeywords.end(); ++it) | for (std::set<std::wstring>::iterator it = m_MapSettingsKeywords.begin(); it != m_MapSettingsKeywords.end(); ++it) | ||||
keywords.add("item", it->c_str()); | keywords.add("item", it->c_str()); | ||||
m_MapSettings.set("Keywords", keywords); | m_MapSettings.set("Keywords", keywords); | ||||
} | } | ||||
// teams locked | // 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; | return m_MapSettings; | ||||
} | } | ||||
void MapSettingsControl::SendToEngine() | void MapSettingsControl::SendToEngine() | ||||
{ | { | ||||
UpdateSettingsObject(); | UpdateSettingsObject(); | ||||
Show All 28 Lines | m_MainSizer->Add(m_MapSettingsCtrl, wxSizerFlags().Expand()); | ||||
gridSizer->AddGrowableCol(1); | gridSizer->AddGrowableCol(1); | ||||
wxChoice* sizeChoice = new wxChoice(this, ID_RandomSize); | wxChoice* sizeChoice = new wxChoice(this, ID_RandomSize); | ||||
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Map size")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Map size")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | ||||
gridSizer->Add(sizeChoice, wxSizerFlags().Expand()); | gridSizer->Add(sizeChoice, wxSizerFlags().Expand()); | ||||
gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Random seed")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Random seed")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT)); | ||||
wxBoxSizer* seedSizer = new wxBoxSizer(wxHORIZONTAL); | wxBoxSizer* seedSizer = new wxBoxSizer(wxHORIZONTAL); | ||||
seedSizer->Add(Tooltipped(new wxTextCtrl(this, ID_RandomSeed, _T("0"), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_NUMERIC)), | seedSizer->Add(Tooltipped(new wxTextCtrl(this, ID_RandomSeed, _T("0"), wxDefaultPosition, wxDefaultSize, 0, wxTextValidator(wxFILTER_DIGITS)), | ||||
_("Seed value for random map")), wxSizerFlags(1).Expand()); | _("Seed value for random map")), wxSizerFlags(1).Expand()); | ||||
seedSizer->Add(Tooltipped(new wxButton(this, ID_RandomReseed, _("R"), wxDefaultPosition, wxSize(24, -1)), | seedSizer->Add(Tooltipped(new wxButton(this, ID_RandomReseed, _("R"), wxDefaultPosition, wxSize(24, -1)), | ||||
_("New random seed"))); | _("New random seed"))); | ||||
gridSizer->Add(seedSizer, wxSizerFlags().Expand()); | gridSizer->Add(seedSizer, wxSizerFlags().Expand()); | ||||
sizer->Add(gridSizer, wxSizerFlags().Expand()); | sizer->Add(gridSizer, wxSizerFlags().Expand()); | ||||
sizer->AddSpacer(5); | sizer->AddSpacer(5); | ||||
▲ Show 20 Lines • Show All 253 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
What's the reason of the reordering? If alphabetic order, why ID_Map* aren't sorted?