| 1 |
/* Copyright (C) 2025 Wildfire Games. |
| 2 |
* This file is part of 0 A.D. |
| 3 |
* |
| 4 |
* 0 A.D. is free software: you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation, either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
* |
| 9 |
* 0 A.D. is distributed in the hope that it will be useful, |
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
* GNU General Public License for more details. |
| 13 |
* |
| 14 |
* You should have received a copy of the GNU General Public License |
| 15 |
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
*/ |
| 17 |
|
| 18 |
#include "tools/atlas/AtlasUI/ScenarioEditor/Sections/Common/Sidebar.h" |
| 19 |
#include "tools/atlas/GameInterface/SharedMemory.h" |
| 20 |
|
| 21 |
#include <cstdlib> |
| 22 |
#include <wx/defs.h> |
| 23 |
#include <wx/dynarray.h> |
| 24 |
#include <wx/event.h> |
| 25 |
#include <wx/string.h> |
| 26 |
|
| 27 |
class PlayerNotebookPage; |
| 28 |
class PlayerSettingsControl; |
| 29 |
class ScenarioEditor; |
| 30 |
class wxButton; |
| 31 |
class wxChoice; |
| 32 |
class wxCollapsiblePaneEvent; |
| 33 |
class wxSpinCtrl; |
| 34 |
class wxTextCtrl; |
| 35 |
class wxWindow; |
| 36 |
|
| 37 |
using namespace AtlasMessage; |
| 38 |
|
| 39 |
class PlayerSidebar : public Sidebar |
| 40 |
{ |
| 41 |
public: |
| 42 |
PlayerSidebar(ScenarioEditor& scenarioEditor, wxWindow* sidebarContainer, wxWindow* bottomBarContainer); |
| 43 |
|
| 44 |
virtual void OnMapReload(); |
| 45 |
|
| 46 |
protected: |
| 47 |
virtual void OnFirstDisplay(); |
| 48 |
|
| 49 |
private: |
| 50 |
PlayerSettingsControl* m_PlayerSettingsCtrl; |
| 51 |
|
| 52 |
void OnCollapse(wxCollapsiblePaneEvent& evt); |
| 53 |
|
| 54 |
bool m_Loaded; |
| 55 |
|
| 56 |
DECLARE_EVENT_TABLE(); |
| 57 |
}; |
| 58 |
|
| 59 |
// Controls present on each player page |
| 60 |
struct PlayerPageControls |
| 61 |
{ |
| 62 |
PlayerNotebookPage* page; |
| 63 |
|
| 64 |
wxTextCtrl* name; |
| 65 |
wxChoice* civ; |
| 66 |
wxButton* color; |
| 67 |
wxSpinCtrl* food; |
| 68 |
wxSpinCtrl* wood; |
| 69 |
wxSpinCtrl* stone; |
| 70 |
wxSpinCtrl* metal; |
| 71 |
wxSpinCtrl* pop; |
| 72 |
wxChoice* team; |
| 73 |
wxChoice* ai; |
| 74 |
}; |
| 75 |
|
| 76 |
// Definitions for keeping AI data sorted |
| 77 |
class AIData |
| 78 |
{ |
| 79 |
public: |
| 80 |
AIData(const wxString& id, const wxString& name) |
| 81 |
: m_ID(id), m_Name(name) |
| 82 |
{ |
| 83 |
} |
| 84 |
|
| 85 |
wxString& GetID() |
| 86 |
{ |
| 87 |
return m_ID; |
| 88 |
} |
| 89 |
|
| 90 |
wxString& GetName() |
| 91 |
{ |
| 92 |
return m_Name; |
| 93 |
} |
| 94 |
|
| 95 |
static int CompareAIData(AIData* ai1, AIData* ai2) |
| 96 |
{ |
| 97 |
return ai1->m_Name.Cmp(ai2->m_Name); |
| 98 |
} |
| 99 |
|
| 100 |
private: |
| 101 |
wxString m_ID; |
| 102 |
wxString m_Name; |
| 103 |
}; |
| 104 |
WX_DEFINE_SORTED_ARRAY(AIData*, ArrayOfAIData); |