2025-08-09 03:01:01 -07:00
/* Copyright (C) 2025 Wildfire Games.
2023-12-02 16:30:12 -08:00
* This file is part of 0 A . D .
2011-06-09 16:45:12 -07:00
*
2023-12-02 16:30:12 -08:00
* 0 A . D . is free software : you can redistribute it and / or modify
2011-06-09 16:45:12 -07:00
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 2 of the License , or
* ( at your option ) any later version .
*
2023-12-02 16:30:12 -08:00
* 0 A . D . is distributed in the hope that it will be useful ,
2011-06-09 16:45:12 -07:00
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2023-12-02 16:30:12 -08:00
* along with 0 A . D . If not , see < http : //www.gnu.org/licenses/>.
2011-06-09 16:45:12 -07:00
*/
# include "precompiled.h"
# include "Player.h"
2025-08-09 03:01:01 -07:00
# include "tools/atlas/AtlasObject/AtlasObject.h"
# include "tools/atlas/AtlasUI/CustomControls/ColorDialog/ColorDialog.h"
# include "tools/atlas/AtlasUI/General/Observable.h"
# include "tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.h"
# include "tools/atlas/AtlasUI/ScenarioEditor/Sections/Common/Sidebar.h"
# include "tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/Tools.h"
# include "tools/atlas/GameInterface/MessagePasser.h"
# include "tools/atlas/GameInterface/Messages.h"
# include "tools/atlas/GameInterface/Shareable.h"
# include "tools/atlas/GameInterface/SharedTypes.h"
2011-06-09 16:45:12 -07:00
2025-08-09 03:01:01 -07:00
# include <climits>
# include <list>
# include <string>
# include <vector>
# include <wx/arrstr.h>
# include <wx/bookctrl.h>
# include <wx/button.h>
# include <wx/chartype.h>
# include <wx/checkbox.h>
# include <wx/choice.h>
# include <wx/choicebk.h>
# include <wx/clntdata.h>
# include <wx/collpane.h>
# include <wx/colour.h>
# include <wx/colourdata.h>
# include <wx/debug.h>
# include <wx/gdicmn.h>
# include <wx/msgdlg.h>
# include <wx/object.h>
# include <wx/panel.h>
# include <wx/scrolwin.h>
# include <wx/sizer.h>
# include <wx/spinbutt.h>
# include <wx/spinctrl.h>
2025-08-17 10:56:35 -07:00
# include <wx/statbox.h>
2025-08-09 03:01:01 -07:00
# include <wx/stattext.h>
# include <wx/textctrl.h>
# include <wx/toolbar.h>
# include <wx/translation.h>
# include <wx/window.h>
2011-06-09 16:45:12 -07:00
enum
{
ID_NumPlayers ,
ID_PlayerFood ,
ID_PlayerWood ,
ID_PlayerMetal ,
ID_PlayerStone ,
ID_PlayerPop ,
2015-03-15 16:59:48 -07:00
ID_PlayerColor ,
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
ID_DefaultName ,
ID_DefaultCiv ,
2015-03-15 16:59:48 -07:00
ID_DefaultColor ,
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
ID_DefaultAI ,
ID_DefaultFood ,
ID_DefaultWood ,
ID_DefaultMetal ,
ID_DefaultStone ,
ID_DefaultPop ,
ID_DefaultTeam ,
2011-06-13 16:32:41 -07:00
ID_CameraSet ,
ID_CameraView ,
ID_CameraClear
2011-06-09 16:45:12 -07:00
} ;
// TODO: Some of these helper things should be moved out of this file
// and into shared locations
// Helper function for adding tooltips
static wxWindow * Tooltipped ( wxWindow * window , const wxString & tip )
{
window - > SetToolTip ( tip ) ;
return window ;
}
//////////////////////////////////////////////////////////////////////////
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
class DefaultCheckbox : public wxCheckBox
{
public :
DefaultCheckbox ( wxWindow * parent , wxWindowID id , wxWindow * control , bool initialValue = false )
: wxCheckBox ( parent , id , wxEmptyString ) , m_Control ( control )
{
SetValue ( initialValue ) ;
}
virtual void SetValue ( bool value )
{
m_Control - > Enable ( value ) ;
wxCheckBox : : SetValue ( value ) ;
}
void OnChecked ( wxCommandEvent & evt )
{
m_Control - > Enable ( evt . IsChecked ( ) ) ;
evt . Skip ( ) ;
}
private :
wxWindow * m_Control ;
DECLARE_EVENT_TABLE ( ) ;
} ;
BEGIN_EVENT_TABLE ( DefaultCheckbox , wxCheckBox )
EVT_CHECKBOX ( wxID_ANY , DefaultCheckbox : : OnChecked )
END_EVENT_TABLE ( ) ;
2011-06-09 16:45:12 -07:00
class PlayerNotebookPage : public wxPanel
{
public :
2014-09-13 12:34:04 -07:00
PlayerNotebookPage ( wxWindow * parent , const wxString & name , size_t playerID )
: wxPanel ( parent , wxID_ANY ) , m_Name ( name ) , m_PlayerID ( playerID )
2011-06-09 16:45:12 -07:00
{
2011-06-13 16:32:41 -07:00
m_Controls . page = this ;
2011-06-09 16:45:12 -07:00
Freeze ( ) ;
wxBoxSizer * sizer = new wxBoxSizer ( wxVERTICAL ) ;
SetSizer ( sizer ) ;
2011-08-27 16:43:18 -07:00
{
/////////////////////////////////////////////////////////////////////////
// Player Info
wxStaticBoxSizer * playerInfoSizer = new wxStaticBoxSizer ( wxVERTICAL , this , _ ( " Player info " ) ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxFlexGridSizer * gridSizer = new wxFlexGridSizer ( 3 , 5 , 5 ) ;
gridSizer - > AddGrowableCol ( 2 ) ;
2025-08-17 10:56:35 -07:00
wxTextCtrl * nameCtrl = new wxTextCtrl ( playerInfoSizer - > GetStaticBox ( ) , wxID_ANY ) ;
gridSizer - > Add ( new DefaultCheckbox ( playerInfoSizer - > GetStaticBox ( ) , ID_DefaultName , nameCtrl ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL ) ) ;
gridSizer - > Add ( new wxStaticText ( playerInfoSizer - > GetStaticBox ( ) , wxID_ANY , _ ( " Name " ) ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ) ) ;
2011-08-27 16:43:18 -07:00
gridSizer - > Add ( nameCtrl , wxSizerFlags ( 1 ) . Expand ( ) . Align ( wxALIGN_RIGHT ) ) ;
m_Controls . name = nameCtrl ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
2025-08-17 10:56:35 -07:00
wxChoice * civChoice = new wxChoice ( playerInfoSizer - > GetStaticBox ( ) , wxID_ANY ) ;
gridSizer - > Add ( new DefaultCheckbox ( playerInfoSizer - > GetStaticBox ( ) , ID_DefaultCiv , civChoice ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL ) ) ;
gridSizer - > Add ( new wxStaticText ( playerInfoSizer - > GetStaticBox ( ) , wxID_ANY , _ ( " Civilisation " ) ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ) ) ;
2011-08-27 16:43:18 -07:00
gridSizer - > Add ( civChoice , wxSizerFlags ( 1 ) . Expand ( ) . Align ( wxALIGN_RIGHT ) ) ;
m_Controls . civ = civChoice ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
2025-08-17 10:56:35 -07:00
wxButton * colorButton = new wxButton ( playerInfoSizer - > GetStaticBox ( ) , ID_PlayerColor ) ;
gridSizer - > Add ( new DefaultCheckbox ( playerInfoSizer - > GetStaticBox ( ) , ID_DefaultColor , colorButton ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL ) ) ;
gridSizer - > Add ( new wxStaticText ( playerInfoSizer - > GetStaticBox ( ) , wxID_ANY , _ ( " Color " ) ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ) ) ;
2015-03-15 16:59:48 -07:00
gridSizer - > Add ( Tooltipped ( colorButton ,
_ ( " Set player color " ) ) , wxSizerFlags ( 1 ) . Expand ( ) . Align ( wxALIGN_RIGHT ) ) ;
m_Controls . color = colorButton ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
2025-08-17 10:56:35 -07:00
wxChoice * aiChoice = new wxChoice ( playerInfoSizer - > GetStaticBox ( ) , wxID_ANY ) ;
gridSizer - > Add ( new DefaultCheckbox ( playerInfoSizer - > GetStaticBox ( ) , ID_DefaultAI , aiChoice ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL ) ) ;
gridSizer - > Add ( new wxStaticText ( playerInfoSizer - > GetStaticBox ( ) , wxID_ANY , _ ( " AI " ) ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ) ) ;
2011-08-28 20:50:29 -07:00
gridSizer - > Add ( Tooltipped ( aiChoice ,
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
_ ( " Select AI " ) ) , wxSizerFlags ( 1 ) . Expand ( ) . Align ( wxALIGN_RIGHT ) ) ;
2011-08-27 16:43:18 -07:00
m_Controls . ai = aiChoice ;
playerInfoSizer - > Add ( gridSizer , wxSizerFlags ( 1 ) . Expand ( ) ) ;
sizer - > Add ( playerInfoSizer , wxSizerFlags ( ) . Expand ( ) . Border ( wxTOP , 10 ) ) ;
}
{
/////////////////////////////////////////////////////////////////////////
// Resources
wxStaticBoxSizer * resourceSizer = new wxStaticBoxSizer ( wxVERTICAL , this , _ ( " Resources " ) ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxFlexGridSizer * gridSizer = new wxFlexGridSizer ( 3 , 5 , 5 ) ;
gridSizer - > AddGrowableCol ( 2 ) ;
2025-08-17 10:56:35 -07:00
wxSpinCtrl * foodCtrl = new wxSpinCtrl ( resourceSizer - > GetStaticBox ( ) , ID_PlayerFood , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxSP_ARROW_KEYS , 0 , INT_MAX ) ;
gridSizer - > Add ( new DefaultCheckbox ( resourceSizer - > GetStaticBox ( ) , ID_DefaultFood , foodCtrl ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL ) ) ;
gridSizer - > Add ( new wxStaticText ( resourceSizer - > GetStaticBox ( ) , wxID_ANY , _ ( " Food " ) ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ) ) ;
2011-08-28 20:50:29 -07:00
gridSizer - > Add ( Tooltipped ( foodCtrl ,
_ ( " Initial value of food resource " ) ) , wxSizerFlags ( ) . Expand ( ) ) ;
2011-08-27 16:43:18 -07:00
m_Controls . food = foodCtrl ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
2025-08-17 10:56:35 -07:00
wxSpinCtrl * woodCtrl = new wxSpinCtrl ( resourceSizer - > GetStaticBox ( ) , ID_PlayerWood , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxSP_ARROW_KEYS , 0 , INT_MAX ) ;
gridSizer - > Add ( new DefaultCheckbox ( resourceSizer - > GetStaticBox ( ) , ID_DefaultWood , woodCtrl ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL ) ) ;
gridSizer - > Add ( new wxStaticText ( resourceSizer - > GetStaticBox ( ) , wxID_ANY , _ ( " Wood " ) ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ) ) ;
2011-08-28 20:50:29 -07:00
gridSizer - > Add ( Tooltipped ( woodCtrl ,
_ ( " Initial value of wood resource " ) ) , wxSizerFlags ( ) . Expand ( ) ) ;
2011-08-27 16:43:18 -07:00
m_Controls . wood = woodCtrl ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
2025-08-17 10:56:35 -07:00
wxSpinCtrl * metalCtrl = new wxSpinCtrl ( resourceSizer - > GetStaticBox ( ) , ID_PlayerMetal , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxSP_ARROW_KEYS , 0 , INT_MAX ) ;
gridSizer - > Add ( new DefaultCheckbox ( resourceSizer - > GetStaticBox ( ) , ID_DefaultMetal , metalCtrl ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL ) ) ;
gridSizer - > Add ( new wxStaticText ( resourceSizer - > GetStaticBox ( ) , wxID_ANY , _ ( " Metal " ) ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ) ) ;
2011-08-28 20:50:29 -07:00
gridSizer - > Add ( Tooltipped ( metalCtrl ,
_ ( " Initial value of metal resource " ) ) , wxSizerFlags ( ) . Expand ( ) ) ;
2011-08-27 16:43:18 -07:00
m_Controls . metal = metalCtrl ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
2025-08-17 10:56:35 -07:00
wxSpinCtrl * stoneCtrl = new wxSpinCtrl ( resourceSizer - > GetStaticBox ( ) , ID_PlayerStone , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxSP_ARROW_KEYS , 0 , INT_MAX ) ;
gridSizer - > Add ( new DefaultCheckbox ( resourceSizer - > GetStaticBox ( ) , ID_DefaultStone , stoneCtrl ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL ) ) ;
gridSizer - > Add ( new wxStaticText ( resourceSizer - > GetStaticBox ( ) , wxID_ANY , _ ( " Stone " ) ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ) ) ;
2011-08-28 20:50:29 -07:00
gridSizer - > Add ( Tooltipped ( stoneCtrl ,
_ ( " Initial value of stone resource " ) ) , wxSizerFlags ( ) . Expand ( ) ) ;
2011-08-27 16:43:18 -07:00
m_Controls . stone = stoneCtrl ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
2025-08-17 10:56:35 -07:00
wxSpinCtrl * popCtrl = new wxSpinCtrl ( resourceSizer - > GetStaticBox ( ) , ID_PlayerPop , wxEmptyString , wxDefaultPosition , wxDefaultSize , wxSP_ARROW_KEYS , 0 , INT_MAX ) ;
gridSizer - > Add ( new DefaultCheckbox ( resourceSizer - > GetStaticBox ( ) , ID_DefaultPop , popCtrl ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL ) ) ;
gridSizer - > Add ( new wxStaticText ( resourceSizer - > GetStaticBox ( ) , wxID_ANY , _ ( " Pop limit " ) ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT ) ) ;
2011-08-28 20:50:29 -07:00
gridSizer - > Add ( Tooltipped ( popCtrl ,
_ ( " Population limit for this player " ) ) , wxSizerFlags ( ) . Expand ( ) ) ;
2011-08-27 16:43:18 -07:00
m_Controls . pop = popCtrl ;
resourceSizer - > Add ( gridSizer , wxSizerFlags ( 1 ) . Expand ( ) ) ;
sizer - > Add ( resourceSizer , wxSizerFlags ( ) . Expand ( ) . Border ( wxTOP , 10 ) ) ;
}
{
/////////////////////////////////////////////////////////////////////////
// Diplomacy
wxStaticBoxSizer * diplomacySizer = new wxStaticBoxSizer ( wxVERTICAL , this , _ ( " Diplomacy " ) ) ;
wxBoxSizer * boxSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2025-08-17 10:56:35 -07:00
wxChoice * teamCtrl = new wxChoice ( diplomacySizer - > GetStaticBox ( ) , wxID_ANY ) ;
boxSizer - > Add ( new DefaultCheckbox ( diplomacySizer - > GetStaticBox ( ) , ID_DefaultTeam , teamCtrl ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL ) ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
boxSizer - > AddSpacer ( 5 ) ;
2025-08-17 10:56:35 -07:00
boxSizer - > Add ( new wxStaticText ( diplomacySizer - > GetStaticBox ( ) , wxID_ANY , _ ( " Team " ) ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL ) ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
boxSizer - > AddSpacer ( 5 ) ;
2011-08-27 16:43:18 -07:00
teamCtrl - > Append ( _ ( " None " ) ) ;
teamCtrl - > Append ( _T ( " 1 " ) ) ;
teamCtrl - > Append ( _T ( " 2 " ) ) ;
teamCtrl - > Append ( _T ( " 3 " ) ) ;
teamCtrl - > Append ( _T ( " 4 " ) ) ;
boxSizer - > Add ( teamCtrl ) ;
m_Controls . team = teamCtrl ;
diplomacySizer - > Add ( boxSizer , wxSizerFlags ( 1 ) . Expand ( ) ) ;
// TODO: possibly have advanced panel where each player's diplomacy can be set?
// Advanced panel
/*wxCollapsiblePane* advPane = new wxCollapsiblePane(this, wxID_ANY, _("Advanced"));
wxWindow * pane = advPane - > GetPane ( ) ;
diplomacySizer - > Add ( advPane , 0 , wxGROW | wxALL , 2 ) ; */
sizer - > Add ( diplomacySizer , wxSizerFlags ( ) . Expand ( ) . Border ( wxTOP , 10 ) ) ;
}
{
/////////////////////////////////////////////////////////////////////////
// Camera
wxStaticBoxSizer * cameraSizer = new wxStaticBoxSizer ( wxVERTICAL , this , _ ( " Starting Camera " ) ) ;
wxGridSizer * gridSizer = new wxGridSizer ( 3 ) ;
2025-08-17 10:56:35 -07:00
wxButton * cameraSet = new wxButton ( cameraSizer - > GetStaticBox ( ) , ID_CameraSet , _ ( " Set " ) , wxDefaultPosition , wxSize ( 48 , - 1 ) ) ;
2011-08-28 20:50:29 -07:00
gridSizer - > Add ( Tooltipped ( cameraSet ,
2025-08-17 10:56:35 -07:00
_ ( " Set player camera to cameraSizer->GetStaticBox() view " ) ) , wxSizerFlags ( ) . Expand ( ) ) ;
wxButton * cameraView = new wxButton ( cameraSizer - > GetStaticBox ( ) , ID_CameraView , _ ( " View " ) , wxDefaultPosition , wxSize ( 48 , - 1 ) ) ;
2011-08-27 16:43:18 -07:00
cameraView - > Enable ( false ) ;
2011-08-28 20:50:29 -07:00
gridSizer - > Add ( Tooltipped ( cameraView ,
_ ( " View the player camera " ) ) , wxSizerFlags ( ) . Expand ( ) ) ;
2025-08-17 10:56:35 -07:00
wxButton * cameraClear = new wxButton ( cameraSizer - > GetStaticBox ( ) , ID_CameraClear , _ ( " Clear " ) , wxDefaultPosition , wxSize ( 48 , - 1 ) ) ;
2011-08-27 16:43:18 -07:00
cameraClear - > Enable ( false ) ;
2011-08-28 20:50:29 -07:00
gridSizer - > Add ( Tooltipped ( cameraClear ,
_ ( " Clear player camera " ) ) , wxSizerFlags ( ) . Expand ( ) ) ;
2011-08-27 16:43:18 -07:00
cameraSizer - > Add ( gridSizer , wxSizerFlags ( ) . Expand ( ) ) ;
sizer - > Add ( cameraSizer , wxSizerFlags ( ) . Expand ( ) . Border ( wxTOP , 10 ) ) ;
}
2011-06-13 16:32:41 -07:00
2011-06-09 16:45:12 -07:00
Layout ( ) ;
Thaw ( ) ;
}
void OnDisplay ( )
{
}
PlayerPageControls GetControls ( )
{
return m_Controls ;
}
wxString GetPlayerName ( )
{
return m_Name ;
}
size_t GetPlayerID ( )
{
return m_PlayerID ;
}
2011-06-13 16:32:41 -07:00
bool IsCameraDefined ( )
{
return m_CameraDefined ;
}
sCameraInfo GetCamera ( )
{
return m_Camera ;
}
void SetCamera ( sCameraInfo info , bool isDefined = true )
{
m_Camera = info ;
m_CameraDefined = isDefined ;
// Enable/disable controls
wxDynamicCast ( FindWindow ( ID_CameraView ) , wxButton ) - > Enable ( isDefined ) ;
wxDynamicCast ( FindWindow ( ID_CameraClear ) , wxButton ) - > Enable ( isDefined ) ;
}
2011-06-09 16:45:12 -07:00
private :
2015-03-15 16:59:48 -07:00
void OnColor ( wxCommandEvent & evt )
2011-06-09 16:45:12 -07:00
{
2015-03-15 16:59:48 -07:00
// Show color dialog
ColorDialog colorDlg ( this , _T ( " Scenario Editor/PlayerColor " ) , m_Controls . color - > GetBackgroundColour ( ) ) ;
2011-06-09 16:45:12 -07:00
2015-03-15 16:59:48 -07:00
if ( colorDlg . ShowModal ( ) = = wxID_OK )
2011-06-09 16:45:12 -07:00
{
2015-03-15 16:59:48 -07:00
m_Controls . color - > SetBackgroundColour ( colorDlg . GetColourData ( ) . GetColour ( ) ) ;
2016-11-23 06:09:58 -08:00
2011-06-09 16:45:12 -07:00
// Pass event on to next handler
evt . Skip ( ) ;
}
}
2011-06-13 16:32:41 -07:00
void OnCameraSet ( wxCommandEvent & evt )
{
AtlasMessage : : qGetView qryView ;
qryView . Post ( ) ;
SetCamera ( qryView . info , true ) ;
// Pass event on to next handler
evt . Skip ( ) ;
}
void OnCameraView ( wxCommandEvent & WXUNUSED ( evt ) )
{
POST_MESSAGE ( SetView , ( m_Camera ) ) ;
}
void OnCameraClear ( wxCommandEvent & evt )
{
SetCamera ( sCameraInfo ( ) , false ) ;
// Pass event on to next handler
evt . Skip ( ) ;
}
sCameraInfo m_Camera ;
bool m_CameraDefined ;
2011-06-09 16:45:12 -07:00
wxString m_Name ;
size_t m_PlayerID ;
2016-11-23 06:09:58 -08:00
2011-06-09 16:45:12 -07:00
PlayerPageControls m_Controls ;
DECLARE_EVENT_TABLE ( ) ;
} ;
BEGIN_EVENT_TABLE ( PlayerNotebookPage , wxPanel )
2015-03-15 16:59:48 -07:00
EVT_BUTTON ( ID_PlayerColor , PlayerNotebookPage : : OnColor )
2011-06-13 16:32:41 -07:00
EVT_BUTTON ( ID_CameraSet , PlayerNotebookPage : : OnCameraSet )
EVT_BUTTON ( ID_CameraView , PlayerNotebookPage : : OnCameraView )
EVT_BUTTON ( ID_CameraClear , PlayerNotebookPage : : OnCameraClear )
2011-06-09 16:45:12 -07:00
END_EVENT_TABLE ( ) ;
//////////////////////////////////////////////////////////////////////////
class PlayerNotebook : public wxChoicebook
{
public :
2014-09-13 12:34:04 -07:00
PlayerNotebook ( wxWindow * parent )
: wxChoicebook ( parent , wxID_ANY /*, wxDefaultPosition, wxDefaultSize, wxNB_FIXEDWIDTH*/ )
2011-06-09 16:45:12 -07:00
{
}
PlayerPageControls AddPlayer ( wxString name , size_t player )
{
2014-09-13 12:34:04 -07:00
PlayerNotebookPage * playerPage = new PlayerNotebookPage ( this , name , player ) ;
2011-06-09 16:45:12 -07:00
AddPage ( playerPage , name ) ;
m_Pages . push_back ( playerPage ) ;
return playerPage - > GetControls ( ) ;
}
void ResizePlayers ( size_t numPlayers )
{
2011-08-22 14:45:39 -07:00
wxASSERT ( numPlayers < = m_Pages . size ( ) ) ;
2011-06-09 16:45:12 -07:00
// We don't really want to destroy the windows corresponding
2011-08-22 14:45:39 -07:00
// to the tabs, so we've kept them in a vector and will
// only remove and add them to the notebook as needed
int selection = GetSelection ( ) ;
size_t pageCount = GetPageCount ( ) ;
if ( numPlayers > pageCount )
2011-06-09 16:45:12 -07:00
{
2011-08-22 14:45:39 -07:00
// Add previously removed pages
for ( size_t i = pageCount ; i < numPlayers ; + + i )
2011-06-09 16:45:12 -07:00
{
2011-08-22 14:45:39 -07:00
AddPage ( m_Pages [ i ] , m_Pages [ i ] - > GetPlayerName ( ) ) ;
2011-06-09 16:45:12 -07:00
}
2011-08-22 14:45:39 -07:00
}
else
{
// Remove previously added pages
// we have to manually hide them or they remain visible
for ( size_t i = pageCount - 1 ; i > = numPlayers ; - - i )
2011-06-09 16:45:12 -07:00
{
2011-08-22 14:45:39 -07:00
m_Pages [ i ] - > Hide ( ) ;
RemovePage ( i ) ;
2011-06-09 16:45:12 -07:00
}
}
2011-08-22 14:45:39 -07:00
// Workaround for bug on wxGTK 2.8: wxChoice selection doesn't update
// (in fact it loses its selection when adding/removing pages)
GetChoiceCtrl ( ) - > SetSelection ( selection ) ;
2011-06-09 16:45:12 -07:00
}
protected :
void OnPageChanged ( wxChoicebookEvent & evt )
{
if ( evt . GetSelection ( ) > = 0 & & evt . GetSelection ( ) < ( int ) GetPageCount ( ) )
{
static_cast < PlayerNotebookPage * > ( GetPage ( evt . GetSelection ( ) ) ) - > OnDisplay ( ) ;
}
evt . Skip ( ) ;
}
private :
std : : vector < PlayerNotebookPage * > m_Pages ;
DECLARE_EVENT_TABLE ( ) ;
} ;
BEGIN_EVENT_TABLE ( PlayerNotebook , wxChoicebook )
EVT_CHOICEBOOK_PAGE_CHANGED ( wxID_ANY , PlayerNotebook : : OnPageChanged )
END_EVENT_TABLE ( ) ;
//////////////////////////////////////////////////////////////////////////
class PlayerSettingsControl : public wxPanel
{
public :
PlayerSettingsControl ( wxWindow * parent , ScenarioEditor & scenarioEditor ) ;
void CreateWidgets ( ) ;
void LoadDefaults ( ) ;
void ReadFromEngine ( ) ;
AtObj UpdateSettingsObject ( ) ;
private :
void SendToEngine ( ) ;
void OnEdit ( wxCommandEvent & WXUNUSED ( evt ) )
{
if ( ! m_InGUIUpdate )
{
SendToEngine ( ) ;
}
}
void OnEditSpin ( wxSpinEvent & WXUNUSED ( evt ) )
{
if ( ! m_InGUIUpdate )
{
SendToEngine ( ) ;
}
}
2015-03-15 16:59:48 -07:00
void OnPlayerColor ( wxCommandEvent & WXUNUSED ( evt ) )
2011-06-09 16:45:12 -07:00
{
if ( ! m_InGUIUpdate )
{
SendToEngine ( ) ;
2011-08-22 14:45:39 -07:00
2015-03-15 16:59:48 -07:00
// Update player settings, to show new color
2011-08-22 14:45:39 -07:00
POST_MESSAGE ( LoadPlayerSettings , ( false ) ) ;
}
}
void OnNumPlayersText ( wxCommandEvent & WXUNUSED ( evt ) )
{ // Ignore because it will also trigger EVT_SPINCTRL
// and we don't want to handle the same event twice
}
void OnNumPlayersSpin ( wxSpinEvent & evt )
{
if ( ! m_InGUIUpdate )
{
wxASSERT ( evt . GetInt ( ) > 0 ) ;
2016-11-23 06:09:58 -08:00
2011-08-22 14:45:39 -07:00
// When wxMessageBox pops up, wxSpinCtrl loses focus, which
// forces another EVT_SPINCTRL event, which we don't want
// to handle, so we check here for a change
if ( evt . GetInt ( ) = = ( int ) m_NumPlayers )
{
return ; // No change
}
2016-11-23 06:09:58 -08:00
2011-08-22 14:45:39 -07:00
size_t oldNumPlayers = m_NumPlayers ;
m_NumPlayers = evt . GetInt ( ) ;
if ( m_NumPlayers < oldNumPlayers )
{
// Remove players, but check if they own any entities
bool notified = false ;
for ( size_t i = oldNumPlayers ; i > m_NumPlayers ; - - i )
{
qGetPlayerObjects objectsQry ( i ) ;
objectsQry . Post ( ) ;
std : : vector < AtlasMessage : : ObjectID > ids = * objectsQry . ids ;
if ( ids . size ( ) > 0 )
{
if ( ! notified )
{
// TODO: Add option to reassign objects?
if ( wxMessageBox ( _ ( " WARNING: All objects belonging to the removed players will be deleted. Continue anyway? " ) , _ ( " Remove player confirmation " ) , wxICON_EXCLAMATION | wxYES_NO ) ! = wxYES )
{
// Restore previous player count
m_NumPlayers = oldNumPlayers ;
wxDynamicCast ( FindWindow ( ID_NumPlayers ) , wxSpinCtrl ) - > SetValue ( m_NumPlayers ) ;
return ;
}
notified = true ;
}
// Delete objects
// TODO: Merge multiple commands?
POST_COMMAND ( DeleteObjects , ( ids ) ) ;
}
}
}
m_Players - > ResizePlayers ( m_NumPlayers ) ;
SendToEngine ( ) ;
// Reload players, notify observers
POST_MESSAGE ( LoadPlayerSettings , ( true ) ) ;
2011-06-09 16:45:12 -07:00
m_MapSettings . NotifyObservers ( ) ;
}
}
2011-08-22 14:45:39 -07:00
// TODO: we shouldn't hardcode this, but instead dynamically create
// new player notebook pages on demand; of course the default data
// will be limited by the entries in player_defaults.json
2011-06-09 16:45:12 -07:00
static const size_t MAX_NUM_PLAYERS = 8 ;
bool m_InGUIUpdate ;
AtObj m_PlayerDefaults ;
PlayerNotebook * m_Players ;
std : : vector < PlayerPageControls > m_PlayerControls ;
Observable < AtObj > & m_MapSettings ;
2011-08-22 14:45:39 -07:00
size_t m_NumPlayers ;
2011-06-09 16:45:12 -07:00
DECLARE_EVENT_TABLE ( ) ;
} ;
BEGIN_EVENT_TABLE ( PlayerSettingsControl , wxPanel )
2015-03-15 16:59:48 -07:00
EVT_BUTTON ( ID_PlayerColor , PlayerSettingsControl : : OnPlayerColor )
2011-06-13 16:32:41 -07:00
EVT_BUTTON ( ID_CameraSet , PlayerSettingsControl : : OnEdit )
EVT_BUTTON ( ID_CameraClear , PlayerSettingsControl : : OnEdit )
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
EVT_CHECKBOX ( wxID_ANY , PlayerSettingsControl : : OnEdit )
2011-06-09 16:45:12 -07:00
EVT_CHOICE ( wxID_ANY , PlayerSettingsControl : : OnEdit )
2011-08-22 14:45:39 -07:00
EVT_TEXT ( ID_NumPlayers , PlayerSettingsControl : : OnNumPlayersText )
2011-06-09 16:45:12 -07:00
EVT_TEXT ( wxID_ANY , PlayerSettingsControl : : OnEdit )
2011-08-22 14:45:39 -07:00
EVT_SPINCTRL ( ID_NumPlayers , PlayerSettingsControl : : OnNumPlayersSpin )
2011-06-09 16:45:12 -07:00
EVT_SPINCTRL ( ID_PlayerFood , PlayerSettingsControl : : OnEditSpin )
EVT_SPINCTRL ( ID_PlayerWood , PlayerSettingsControl : : OnEditSpin )
EVT_SPINCTRL ( ID_PlayerMetal , PlayerSettingsControl : : OnEditSpin )
EVT_SPINCTRL ( ID_PlayerStone , PlayerSettingsControl : : OnEditSpin )
EVT_SPINCTRL ( ID_PlayerPop , PlayerSettingsControl : : OnEditSpin )
END_EVENT_TABLE ( ) ;
PlayerSettingsControl : : PlayerSettingsControl ( wxWindow * parent , ScenarioEditor & scenarioEditor )
2014-09-13 12:34:04 -07:00
: wxPanel ( parent , wxID_ANY ) , m_InGUIUpdate ( false ) , m_MapSettings ( scenarioEditor . GetMapSettings ( ) ) , m_NumPlayers ( 0 )
2011-06-09 16:45:12 -07:00
{
// To prevent recursion, don't handle GUI events right now
m_InGUIUpdate = true ;
wxStaticBoxSizer * sizer = new wxStaticBoxSizer ( wxVERTICAL , this , _ ( " Player settings " ) ) ;
SetSizer ( sizer ) ;
wxBoxSizer * boxSizer = new wxBoxSizer ( wxHORIZONTAL ) ;
2025-08-17 10:56:35 -07:00
boxSizer - > Add ( new wxStaticText ( sizer - > GetStaticBox ( ) , wxID_ANY , _ ( " Num players " ) ) , wxSizerFlags ( ) . Align ( wxALIGN_CENTER_VERTICAL ) ) ;
wxSpinCtrl * numPlayersSpin = new wxSpinCtrl ( sizer - > GetStaticBox ( ) , ID_NumPlayers , wxEmptyString , wxDefaultPosition , wxSize ( 40 , - 1 ) ) ;
2011-06-09 16:45:12 -07:00
numPlayersSpin - > SetValue ( MAX_NUM_PLAYERS ) ;
numPlayersSpin - > SetRange ( 1 , MAX_NUM_PLAYERS ) ;
boxSizer - > Add ( numPlayersSpin ) ;
sizer - > Add ( boxSizer , wxSizerFlags ( ) . Expand ( ) . Proportion ( 0 ) ) ;
sizer - > AddSpacer ( 5 ) ;
2025-08-17 10:56:35 -07:00
m_Players = new PlayerNotebook ( sizer - > GetStaticBox ( ) ) ;
2011-06-09 16:45:12 -07:00
sizer - > Add ( m_Players , wxSizerFlags ( ) . Expand ( ) . Proportion ( 1 ) ) ;
m_InGUIUpdate = false ;
}
void PlayerSettingsControl : : CreateWidgets ( )
{
// To prevent recursion, don't handle GUI events right now
m_InGUIUpdate = true ;
// Load default civ and player data
wxArrayString civNames ;
wxArrayString civCodes ;
AtlasMessage : : qGetCivData qryCiv ;
qryCiv . Post ( ) ;
2022-02-04 22:24:45 -08:00
std : : vector < std : : vector < std : : wstring > > civData = * qryCiv . data ;
for ( const std : : vector < std : : wstring > & civ : civData )
2011-06-09 16:45:12 -07:00
{
2022-02-04 22:24:45 -08:00
civCodes . Add ( civ [ 0 ] ) ;
civNames . Add ( civ [ 1 ] ) ;
2011-06-09 16:45:12 -07:00
}
2011-06-13 16:32:41 -07:00
// Load AI data
ArrayOfAIData ais ( AIData : : CompareAIData ) ;
AtlasMessage : : qGetAIData qryAI ;
qryAI . Post ( ) ;
2014-02-24 12:22:02 -08:00
AtObj aiData = AtlasObject : : LoadFromJSON ( * qryAI . data ) ;
2011-06-13 16:32:41 -07:00
for ( AtIter a = aiData [ " AIData " ] [ " item " ] ; a . defined ( ) ; + + a )
{
2019-06-03 13:19:53 -07:00
ais . Add ( new AIData ( wxString : : FromUTF8 ( a [ " id " ] ) , wxString : : FromUTF8 ( a [ " data " ] [ " name " ] ) ) ) ;
2011-06-13 16:32:41 -07:00
}
2011-06-09 16:45:12 -07:00
// Create player pages
2011-08-26 15:58:55 -07:00
AtIter playerDefs = m_PlayerDefaults [ " item " ] ;
if ( playerDefs . defined ( ) )
+ + playerDefs ; // Skip gaia
2016-11-23 06:09:58 -08:00
2011-08-26 15:58:55 -07:00
for ( size_t i = 0 ; i < MAX_NUM_PLAYERS ; + + i )
2011-06-09 16:45:12 -07:00
{
// Create new player tab and get controls
2011-08-26 15:58:55 -07:00
wxString name ( _ ( " Unknown " ) ) ;
if ( playerDefs [ " Name " ] . defined ( ) )
name = playerDefs [ " Name " ] ;
2016-11-23 06:09:58 -08:00
2011-08-26 15:58:55 -07:00
PlayerPageControls controls = m_Players - > AddPlayer ( name , i ) ;
2011-06-09 16:45:12 -07:00
m_PlayerControls . push_back ( controls ) ;
// Populate civ choice box
wxChoice * civChoice = controls . civ ;
for ( size_t j = 0 ; j < civNames . Count ( ) ; + + j )
civChoice - > Append ( civNames [ j ] , new wxStringClientData ( civCodes [ j ] ) ) ;
2011-06-13 16:32:41 -07:00
civChoice - > SetSelection ( 0 ) ;
// Populate ai choice box
wxChoice * aiChoice = controls . ai ;
aiChoice - > Append ( _ ( " <None> " ) , new wxStringClientData ( ) ) ;
for ( size_t j = 0 ; j < ais . Count ( ) ; + + j )
aiChoice - > Append ( ais [ j ] - > GetName ( ) , new wxStringClientData ( ais [ j ] - > GetID ( ) ) ) ;
aiChoice - > SetSelection ( 0 ) ;
2011-08-26 15:58:55 -07:00
if ( playerDefs . defined ( ) )
+ + playerDefs ;
2011-06-09 16:45:12 -07:00
}
m_InGUIUpdate = false ;
}
void PlayerSettingsControl : : LoadDefaults ( )
{
AtlasMessage : : qGetPlayerDefaults qryPlayers ;
qryPlayers . Post ( ) ;
2014-02-24 12:22:02 -08:00
AtObj playerData = AtlasObject : : LoadFromJSON ( * qryPlayers . defaults ) ;
2011-06-09 16:45:12 -07:00
m_PlayerDefaults = * playerData [ " PlayerData " ] ;
}
void PlayerSettingsControl : : ReadFromEngine ( )
{
AtlasMessage : : qGetMapSettings qry ;
qry . Post ( ) ;
if ( ! ( * qry . settings ) . empty ( ) )
{
// Prevent error if there's no map settings to parse
2014-02-24 12:22:02 -08:00
m_MapSettings = AtlasObject : : LoadFromJSON ( * qry . settings ) ;
2011-06-09 16:45:12 -07:00
}
2011-06-13 16:32:41 -07:00
else
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
{
// Use blank object, it will be created next
2011-06-13 16:32:41 -07:00
m_MapSettings = AtObj ( ) ;
}
2011-06-09 16:45:12 -07:00
AtIter player = m_MapSettings [ " PlayerData " ] [ " item " ] ;
2011-08-22 14:45:39 -07:00
if ( ! m_MapSettings . defined ( ) | | ! player . defined ( ) | | player . count ( ) = = 0 )
{
// Player data missing - set number of players to max
m_NumPlayers = MAX_NUM_PLAYERS ;
}
else
2015-01-03 09:42:42 -08:00
{
+ + player ; // skip gaia
m_NumPlayers = player . count ( ) ;
}
2011-06-09 16:45:12 -07:00
2011-08-22 14:45:39 -07:00
wxASSERT ( m_NumPlayers < = MAX_NUM_PLAYERS & & m_NumPlayers ! = 0 ) ;
2011-06-09 16:45:12 -07:00
// To prevent recursion, don't handle GUI events right now
m_InGUIUpdate = true ;
2011-08-22 14:45:39 -07:00
wxDynamicCast ( FindWindow ( ID_NumPlayers ) , wxSpinCtrl ) - > SetValue ( m_NumPlayers ) ;
2011-06-09 16:45:12 -07:00
// Remove / add extra player pages as needed
2011-08-22 14:45:39 -07:00
m_Players - > ResizePlayers ( m_NumPlayers ) ;
2011-06-09 16:45:12 -07:00
2011-08-26 15:58:55 -07:00
// Update player controls with player data
AtIter playerDefs = m_PlayerDefaults [ " item " ] ;
if ( playerDefs . defined ( ) )
+ + playerDefs ; // skip gaia
for ( size_t i = 0 ; i < MAX_NUM_PLAYERS ; + + i )
2011-06-09 16:45:12 -07:00
{
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
const PlayerPageControls & controls = m_PlayerControls [ i ] ;
2011-06-09 16:45:12 -07:00
// name
2011-08-26 15:58:55 -07:00
wxString name ( _ ( " Unknown " ) ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
bool defined = player [ " Name " ] . defined ( ) ;
if ( defined )
2019-06-03 13:19:53 -07:00
name = wxString : : FromUTF8 ( player [ " Name " ] ) ;
2011-08-26 15:58:55 -07:00
else if ( playerDefs [ " Name " ] . defined ( ) )
2019-06-03 13:19:53 -07:00
name = wxString : : FromUTF8 ( playerDefs [ " Name " ] ) ;
2011-06-09 16:45:12 -07:00
controls . name - > SetValue ( name ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxDynamicCast ( FindWindowById ( ID_DefaultName , controls . page ) , DefaultCheckbox ) - > SetValue ( defined ) ;
2011-06-09 16:45:12 -07:00
// civ
wxChoice * choice = controls . civ ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
defined = player [ " Civ " ] . defined ( ) ;
2019-06-03 13:19:53 -07:00
wxString civCode = wxString : : FromUTF8 ( defined ? player [ " Civ " ] : playerDefs [ " Civ " ] ) ;
2011-08-22 14:45:39 -07:00
2011-06-09 16:45:12 -07:00
for ( size_t j = 0 ; j < choice - > GetCount ( ) ; + + j )
{
wxStringClientData * str = dynamic_cast < wxStringClientData * > ( choice - > GetClientObject ( j ) ) ;
if ( str - > GetData ( ) = = civCode )
{
choice - > SetSelection ( j ) ;
break ;
}
}
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxDynamicCast ( FindWindowById ( ID_DefaultCiv , controls . page ) , DefaultCheckbox ) - > SetValue ( defined ) ;
2011-06-09 16:45:12 -07:00
2015-03-15 16:59:48 -07:00
// color
wxColor color ;
AtObj clrObj = * player [ " Color " ] ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
defined = clrObj . defined ( ) ;
if ( ! defined )
2015-03-15 16:59:48 -07:00
clrObj = * playerDefs [ " Color " ] ;
color = wxColor ( ( * clrObj [ " r " ] ) . getInt ( ) , ( * clrObj [ " g " ] ) . getInt ( ) , ( * clrObj [ " b " ] ) . getInt ( ) ) ;
controls . color - > SetBackgroundColour ( color ) ;
wxDynamicCast ( FindWindowById ( ID_DefaultColor , controls . page ) , DefaultCheckbox ) - > SetValue ( defined ) ;
2011-06-09 16:45:12 -07:00
2011-06-13 16:32:41 -07:00
// player type
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
defined = player [ " AI " ] . defined ( ) ;
2019-06-03 13:19:53 -07:00
wxString aiID = wxString : : FromUTF8 ( defined ? player [ " AI " ] : playerDefs [ " AI " ] ) ;
2011-06-13 16:32:41 -07:00
choice = controls . ai ;
if ( ! aiID . empty ( ) )
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
{
// AI
2011-06-13 16:32:41 -07:00
for ( size_t j = 0 ; j < choice - > GetCount ( ) ; + + j )
{
wxStringClientData * str = dynamic_cast < wxStringClientData * > ( choice - > GetClientObject ( j ) ) ;
if ( str - > GetData ( ) = = aiID )
{
choice - > SetSelection ( j ) ;
break ;
}
}
}
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
else // Human
2011-06-13 16:32:41 -07:00
choice - > SetSelection ( 0 ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxDynamicCast ( FindWindowById ( ID_DefaultAI , controls . page ) , DefaultCheckbox ) - > SetValue ( defined ) ;
2011-06-13 16:32:41 -07:00
2011-06-09 16:45:12 -07:00
// resources
AtObj resObj = * player [ " Resources " ] ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
defined = resObj . defined ( ) & & resObj [ " food " ] . defined ( ) ;
if ( defined )
2019-06-03 13:19:53 -07:00
controls . food - > SetValue ( ( * resObj [ " food " ] ) . getInt ( ) ) ;
2011-06-09 16:45:12 -07:00
else
controls . food - > SetValue ( 0 ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxDynamicCast ( FindWindowById ( ID_DefaultFood , controls . page ) , DefaultCheckbox ) - > SetValue ( defined ) ;
2011-06-09 16:45:12 -07:00
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
defined = resObj . defined ( ) & & resObj [ " wood " ] . defined ( ) ;
if ( defined )
2019-06-03 13:19:53 -07:00
controls . wood - > SetValue ( ( * resObj [ " wood " ] ) . getInt ( ) ) ;
2011-06-09 16:45:12 -07:00
else
controls . wood - > SetValue ( 0 ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxDynamicCast ( FindWindowById ( ID_DefaultWood , controls . page ) , DefaultCheckbox ) - > SetValue ( defined ) ;
2011-06-09 16:45:12 -07:00
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
defined = resObj . defined ( ) & & resObj [ " metal " ] . defined ( ) ;
if ( defined )
2019-06-03 13:19:53 -07:00
controls . metal - > SetValue ( ( * resObj [ " metal " ] ) . getInt ( ) ) ;
2011-06-09 16:45:12 -07:00
else
controls . metal - > SetValue ( 0 ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxDynamicCast ( FindWindowById ( ID_DefaultMetal , controls . page ) , DefaultCheckbox ) - > SetValue ( defined ) ;
2011-06-09 16:45:12 -07:00
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
defined = resObj . defined ( ) & & resObj [ " stone " ] . defined ( ) ;
if ( defined )
2019-06-03 13:19:53 -07:00
controls . stone - > SetValue ( ( * resObj [ " stone " ] ) . getInt ( ) ) ;
2011-06-09 16:45:12 -07:00
else
controls . stone - > SetValue ( 0 ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxDynamicCast ( FindWindowById ( ID_DefaultStone , controls . page ) , DefaultCheckbox ) - > SetValue ( defined ) ;
2011-06-09 16:45:12 -07:00
// population limit
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
defined = player [ " PopulationLimit " ] . defined ( ) ;
if ( defined )
2019-06-03 13:19:53 -07:00
controls . pop - > SetValue ( ( * player [ " PopulationLimit " ] ) . getInt ( ) ) ;
2011-06-09 16:45:12 -07:00
else
controls . pop - > SetValue ( 0 ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxDynamicCast ( FindWindowById ( ID_DefaultPop , controls . page ) , DefaultCheckbox ) - > SetValue ( defined ) ;
2011-06-09 16:45:12 -07:00
// team
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
defined = player [ " Team " ] . defined ( ) ;
if ( defined )
2011-06-23 15:38:26 -07:00
controls . team - > SetSelection ( ( * player [ " Team " ] ) . getInt ( ) + 1 ) ;
2011-06-09 16:45:12 -07:00
else
controls . team - > SetSelection ( 0 ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
wxDynamicCast ( FindWindowById ( ID_DefaultTeam , controls . page ) , DefaultCheckbox ) - > SetValue ( defined ) ;
2011-06-09 16:45:12 -07:00
2011-06-13 16:32:41 -07:00
// camera
if ( player [ " StartingCamera " ] . defined ( ) )
{
sCameraInfo info ;
2011-06-20 19:56:49 -07:00
// Don't use wxAtof because it depends on locales which
// may cause problems with decimal points
// see: http://www.wxwidgets.org/docs/faqgtk.htm#locale
2011-06-16 14:21:33 -07:00
AtObj camPos = * player [ " StartingCamera " ] [ " Position " ] ;
2011-06-19 12:51:53 -07:00
info . pX = ( float ) ( * camPos [ " x " ] ) . getDouble ( ) ;
info . pY = ( float ) ( * camPos [ " y " ] ) . getDouble ( ) ;
info . pZ = ( float ) ( * camPos [ " z " ] ) . getDouble ( ) ;
2011-06-16 14:21:33 -07:00
AtObj camRot = * player [ " StartingCamera " ] [ " Rotation " ] ;
2011-06-19 12:51:53 -07:00
info . rX = ( float ) ( * camRot [ " x " ] ) . getDouble ( ) ;
info . rY = ( float ) ( * camRot [ " y " ] ) . getDouble ( ) ;
info . rZ = ( float ) ( * camRot [ " z " ] ) . getDouble ( ) ;
2016-11-23 06:09:58 -08:00
2011-06-13 16:32:41 -07:00
controls . page - > SetCamera ( info , true ) ;
}
else
controls . page - > SetCamera ( sCameraInfo ( ) , false ) ;
2011-08-26 15:58:55 -07:00
if ( player . defined ( ) )
+ + player ;
2017-11-24 13:01:12 -08:00
2011-08-26 15:58:55 -07:00
if ( playerDefs . defined ( ) )
+ + playerDefs ;
2011-06-09 16:45:12 -07:00
}
2012-05-10 15:49:04 -07:00
// Send default properties to engine, since they might not be set
SendToEngine ( ) ;
2011-06-09 16:45:12 -07:00
m_InGUIUpdate = false ;
}
AtObj PlayerSettingsControl : : UpdateSettingsObject ( )
{
// Update player data in the map settings
AtObj players ;
2019-06-03 13:19:53 -07:00
players . set ( " @array " , " " ) ;
2011-06-09 16:45:12 -07:00
2011-08-22 14:45:39 -07:00
wxASSERT ( m_NumPlayers < = MAX_NUM_PLAYERS ) ;
2017-11-24 13:01:12 -08:00
AtIter playerDefs = m_PlayerDefaults [ " item " ] ;
if ( playerDefs . defined ( ) )
+ + playerDefs ; // Skip gaia
2011-08-22 14:45:39 -07:00
for ( size_t i = 0 ; i < m_NumPlayers ; + + i )
2011-06-09 16:45:12 -07:00
{
PlayerPageControls controls = m_PlayerControls [ i ] ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
AtObj player ;
2011-06-09 16:45:12 -07:00
// name
wxTextCtrl * text = controls . name ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
if ( text - > IsEnabled ( ) )
2019-06-03 13:19:53 -07:00
player . set ( " Name " , text - > GetValue ( ) . utf8_str ( ) ) ;
2011-06-09 16:45:12 -07:00
// civ
wxChoice * choice = controls . civ ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
if ( choice - > IsEnabled ( ) & & choice - > GetSelection ( ) > = 0 )
2011-06-09 16:45:12 -07:00
{
wxStringClientData * str = dynamic_cast < wxStringClientData * > ( choice - > GetClientObject ( choice - > GetSelection ( ) ) ) ;
2021-06-29 05:41:31 -07:00
player . set ( " Civ " , str - > GetData ( ) . utf8_str ( ) ) ;
2011-06-09 16:45:12 -07:00
}
2017-11-24 13:01:12 -08:00
else
2021-03-23 06:16:53 -07:00
player . unset ( " Civ " ) ;
2011-06-09 16:45:12 -07:00
2015-03-15 16:59:48 -07:00
// color
if ( controls . color - > IsEnabled ( ) )
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
{
2015-03-15 16:59:48 -07:00
wxColor color = controls . color - > GetBackgroundColour ( ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
AtObj clrObj ;
2015-03-15 16:59:48 -07:00
clrObj . setInt ( " r " , ( int ) color . Red ( ) ) ;
clrObj . setInt ( " g " , ( int ) color . Green ( ) ) ;
clrObj . setInt ( " b " , ( int ) color . Blue ( ) ) ;
player . set ( " Color " , clrObj ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
}
2011-06-09 16:45:12 -07:00
2011-06-13 16:32:41 -07:00
// player type
choice = controls . ai ;
2021-06-29 05:41:31 -07:00
if ( choice - > IsEnabled ( ) & & choice - > GetSelection ( ) > 0 )
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
{
2021-06-29 05:41:31 -07:00
// ai - get id
wxStringClientData * str = dynamic_cast < wxStringClientData * > ( choice - > GetClientObject ( choice - > GetSelection ( ) ) ) ;
player . set ( " AI " , str - > GetData ( ) . utf8_str ( ) ) ;
2011-06-13 16:32:41 -07:00
}
2021-06-29 05:41:31 -07:00
else // human
player . unset ( " AI " ) ;
2011-06-13 16:32:41 -07:00
2011-06-09 16:45:12 -07:00
// resources
AtObj resObj ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
if ( controls . food - > IsEnabled ( ) )
2011-06-09 16:45:12 -07:00
resObj . setInt ( " food " , controls . food - > GetValue ( ) ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
if ( controls . wood - > IsEnabled ( ) )
2011-06-09 16:45:12 -07:00
resObj . setInt ( " wood " , controls . wood - > GetValue ( ) ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
if ( controls . metal - > IsEnabled ( ) )
2011-06-09 16:45:12 -07:00
resObj . setInt ( " metal " , controls . metal - > GetValue ( ) ) ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
if ( controls . stone - > IsEnabled ( ) )
2011-06-09 16:45:12 -07:00
resObj . setInt ( " stone " , controls . stone - > GetValue ( ) ) ;
if ( resObj . defined ( ) )
player . set ( " Resources " , resObj ) ;
// population limit
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
if ( controls . pop - > IsEnabled ( ) )
2011-06-09 16:45:12 -07:00
player . setInt ( " PopulationLimit " , controls . pop - > GetValue ( ) ) ;
// team
choice = controls . team ;
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
if ( choice - > IsEnabled ( ) & & choice - > GetSelection ( ) > = 0 )
2011-06-09 16:45:12 -07:00
player . setInt ( " Team " , choice - > GetSelection ( ) - 1 ) ;
2011-06-13 16:32:41 -07:00
// camera
2011-06-13 18:03:35 -07:00
AtObj camObj ;
2011-06-13 16:32:41 -07:00
if ( controls . page - > IsCameraDefined ( ) )
{
sCameraInfo cam = controls . page - > GetCamera ( ) ;
2011-06-16 14:21:33 -07:00
AtObj camPos ;
camPos . setDouble ( " x " , cam . pX ) ;
camPos . setDouble ( " y " , cam . pY ) ;
camPos . setDouble ( " z " , cam . pZ ) ;
camObj . set ( " Position " , camPos ) ;
AtObj camRot ;
camRot . setDouble ( " x " , cam . rX ) ;
camRot . setDouble ( " y " , cam . rY ) ;
camRot . setDouble ( " z " , cam . rZ ) ;
camObj . set ( " Rotation " , camRot ) ;
2011-06-13 16:32:41 -07:00
}
2011-06-13 18:03:35 -07:00
player . set ( " StartingCamera " , camObj ) ;
2011-06-13 16:32:41 -07:00
2011-06-09 16:45:12 -07:00
players . add ( " item " , player ) ;
2017-11-24 13:01:12 -08:00
if ( playerDefs . defined ( ) )
+ + playerDefs ;
2011-06-09 16:45:12 -07:00
}
2016-11-23 06:09:58 -08:00
2011-06-09 16:45:12 -07:00
m_MapSettings . set ( " PlayerData " , players ) ;
return m_MapSettings ;
}
void PlayerSettingsControl : : SendToEngine ( )
{
UpdateSettingsObject ( ) ;
2014-02-24 12:22:02 -08:00
std : : string json = AtlasObject : : SaveToJSON ( m_MapSettings ) ;
2011-06-09 16:45:12 -07:00
// TODO: would be nice if we supported undo for settings changes
POST_COMMAND ( SetMapSettings , ( json ) ) ;
}
//////////////////////////////////////////////////////////////////////////
PlayerSidebar : : PlayerSidebar ( ScenarioEditor & scenarioEditor , wxWindow * sidebarContainer , wxWindow * bottomBarContainer )
: Sidebar ( scenarioEditor , sidebarContainer , bottomBarContainer ) , m_Loaded ( false )
{
2017-08-27 11:47:39 -07:00
wxSizer * scrollSizer = new wxBoxSizer ( wxVERTICAL ) ;
wxScrolledWindow * scrolledWindow = new wxScrolledWindow ( this ) ;
scrolledWindow - > SetScrollRate ( 10 , 10 ) ;
scrolledWindow - > SetSizer ( scrollSizer ) ;
m_MainSizer - > Add ( scrolledWindow , wxSizerFlags ( ) . Proportion ( 1 ) . Expand ( ) ) ;
m_PlayerSettingsCtrl = new PlayerSettingsControl ( scrolledWindow , m_ScenarioEditor ) ;
scrollSizer - > Add ( m_PlayerSettingsCtrl , wxSizerFlags ( ) . Expand ( ) ) ;
2011-06-09 16:45:12 -07:00
}
void PlayerSidebar : : OnCollapse ( wxCollapsiblePaneEvent & WXUNUSED ( evt ) )
{
Freeze ( ) ;
// Toggling the collapsing doesn't seem to update the sidebar layout
// automatically, so do it explicitly here
Layout ( ) ;
Refresh ( ) ; // fixes repaint glitch on Windows
Thaw ( ) ;
}
void PlayerSidebar : : OnFirstDisplay ( )
{
// We do this here becase messages are used which requires simulation to be init'd
m_PlayerSettingsCtrl - > LoadDefaults ( ) ;
m_PlayerSettingsCtrl - > CreateWidgets ( ) ;
m_PlayerSettingsCtrl - > ReadFromEngine ( ) ;
m_Loaded = true ;
Layout ( ) ;
}
void PlayerSidebar : : OnMapReload ( )
{
// Make sure we've loaded the controls
if ( m_Loaded )
{
m_PlayerSettingsCtrl - > ReadFromEngine ( ) ;
}
}
BEGIN_EVENT_TABLE ( PlayerSidebar , Sidebar )
EVT_COLLAPSIBLEPANE_CHANGED ( wxID_ANY , PlayerSidebar : : OnCollapse )
END_EVENT_TABLE ( ) ;