Ticket #4256: 4256_atlas_settings_v1.1.patch

File 4256_atlas_settings_v1.1.patch, 5.5 KB (added by Sandarac, 7 years ago)

Fix issues pointed out by elexis, and use a numerical input element for the wonder victory timeout.

  • source/tools/atlas/AtlasUI/ScenarioEditor/Sections/Map/Map.cpp

     
    1 /* Copyright (C) 2016 Wildfire Games.
     1/* Copyright (C) 2017 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
    44 * 0 A.D. is free software: you can redistribute it and/or modify
     
    2121
    2222#include "AtlasObject/AtlasObject.h"
    2323#include "GameInterface/Messages.h"
     24#include "General/Datafile.h"
    2425#include "ScenarioEditor/ScenarioEditor.h"
    2526#include "ScenarioEditor/Tools/Common/Tools.h"
    2627
     
    3334    ID_MapDescription,
    3435    ID_MapReveal,
    3536    ID_MapType,
     37    ID_WonderVictoryTimes,
    3638    ID_MapPreview,
    37     ID_MapTeams,
     39    ID_MapLockTeams,
     40    ID_MapLastManStanding,
    3841    ID_MapKW_Demo,
    3942    ID_MapKW_Naval,
    4043    ID_RandomScript,
     
    141144
    142145    sizer->AddSpacer(5);
    143146
    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();
    152151
    153152    wxFlexGridSizer* gridSizer = new wxFlexGridSizer(2, 5, 5);
    154153    gridSizer->AddGrowableCol(1);
     
    162161    gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Game type")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
    163162    gridSizer->Add(Tooltipped(new wxChoice(this, ID_MapType, wxDefaultPosition, wxDefaultSize, gameTypes),
    164163        _("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
    165168    gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Lock teams")), wxSizerFlags().Align(wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT));
    166     gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapTeams, wxEmptyString),
     169    gridSizer->Add(Tooltipped(new wxCheckBox(this, ID_MapLockTeams, wxEmptyString),
    167170        _("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)")));
    168174    sizer->Add(gridSizer, wxSizerFlags().Expand());
    169175
    170176    sizer->AddSpacer(5);
     
    209215    else
    210216        wxDynamicCast(FindWindow(ID_MapType), wxChoice)->SetSelection(0);
    211217
     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
    212223    // lock teams
    213     wxDynamicCast(FindWindow(ID_MapTeams), wxCheckBox)->SetValue(wxString(m_MapSettings["LockTeams"]) == L"true");
     224    wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->SetValue(wxString(m_MapSettings["LockTeams"]) == L"true");
    214225
     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
    215232    // keywords
    216233    {
    217234        m_MapSettingsKeywords.clear();
     
    248265    // game type / victory conditions
    249266    m_MapSettings.set("GameType", wxDynamicCast(FindWindow(ID_MapType), wxChoice)->GetStringSelection());
    250267
     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
    251273    // keywords
    252274    {
    253275        if (wxDynamicCast(FindWindow(ID_MapKW_Demo), wxCheckBox)->GetValue())
     
    268290    }
    269291
    270292    // teams locked
    271     m_MapSettings.setBool("LockTeams", wxDynamicCast(FindWindow(ID_MapTeams), wxCheckBox)->GetValue());
     293    m_MapSettings.setBool("LockTeams", wxDynamicCast(FindWindow(ID_MapLockTeams), wxCheckBox)->GetValue());
    272294
     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
    273303    return m_MapSettings;
    274304}
    275305