Debian Codegraph @

source/tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/ObjectSettings.h

raw
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 #ifndef INCLUDED_OBJECTSETTINGS
19 #define INCLUDED_OBJECTSETTINGS
20
21 #include "tools/atlas/AtlasUI/General/Observable.h"
22 #include "tools/atlas/AtlasUI/ScenarioEditor/Tools/Common/MiscState.h"
23
24 #include <set>
25 #include <vector>
26 #include <wx/arrstr.h>
27 #include <wx/string.h>
28
29 namespace AtlasMessage
30 {
31 struct sObjectSettings;
32 }
33
34 // Various settings to be applied to newly created units, or to the currently
35 // selected unit. If a unit is selected or being previewed, it should match
36 // these settings.
37 class ObjectSettings
38 {
39 public:
40 ObjectSettings(Observable<std::vector<AtlasMessage::ObjectID> >& selectedObjects, int view);
41
42 int GetPlayerID() const;
43 void SetPlayerID(int playerID);
44
45 void SetView(int view);
46
47 struct Group
48 {
49 wxArrayString variants;
50 wxString chosen;
51 };
52
53 const std::vector<Group> GetActorVariation() const;
54
55 const std::set<wxString>& GetActorSelections() const;
56 void SetActorSelections(const std::set<wxString>& selections);
57
58 // Constructs new sObjectSettings object from settings
59 AtlasMessage::sObjectSettings GetSettings() const;
60
61 private:
62 Observable<std::vector<AtlasMessage::ObjectID> >& m_SelectedObjects;
63
64 int m_View;
65
66 // 0 = gaia, 1..inf = normal players
67 int m_PlayerID;
68
69 // Set of user-chosen actor selections, potentially a superset of any single
70 // actor's possible variants (since it doesn't get reset if you select
71 // a new actor, and will accumulate variant names)
72 std::set<wxString> m_ActorSelections;
73
74 // List of actor variant groups (each a list of variant names)
75 std::vector<wxArrayString> m_VariantGroups;
76
77 // Observe changes to unit selection
78 ObservableScopedConnection m_Conn;
79 void OnSelectionChange(const std::vector<AtlasMessage::ObjectID>& selection);
80
81 // Transfer current settings to the currently selected unit (if any)
82 void PostToGame();
83 };
84
85 #endif // INCLUDED_OBJECTSETTINGS