Debian Codegraph @

engine/include/editor.h

raw
1 // ____ _ __
2 // / __ )____ _____ | | / /___ ___________
3 // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
4 // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
5 // /_____/\____/____/ |__/|__/\__,_/_/ /____/
6 //
7 // A futuristic real-time strategy game.
8 // This file is part of Bos Wars.
9 //
10 /**@name editor.h - The editor file. */
11 //
12 // (c) Copyright 2002-2010 by Lutz Sammer and Jimmy Salmon
13 //
14 // This program is free software; you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation; only version 2 of the License.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 // 02111-1307, USA.
27
28 #ifndef __EDITOR_H__
29 #define __EDITOR_H__
30
31 //@{
32
33 #include <vector>
34 #include <string>
35 #include "icons.h"
36
37 /*----------------------------------------------------------------------------
38 -- Declarations
39 ----------------------------------------------------------------------------*/
40
41 class CUnitType;
42 class CPatchType;
43
44 enum EditorRunningType {
45 EditorNotRunning = 0, /// Not Running
46 EditorStarted = 1, /// Editor Enabled at all
47 EditorCommandLine = 2, /// Called from Command Line
48 EditorEditing = 4, /// Editor is fully running
49 };
50
51 enum EditorStateType {
52 EditorSelecting, /// Select
53 EditorEditPatch, /// Edit patch
54 EditorEditUnit, /// Edit units
55 EditorSetStartLocation /// Set the start location
56 };
57
58 struct CPatchIcon
59 {
60 CPatchIcon(CPatchType *patchType, CGraphic *g) :
61 PatchType(patchType), G(g)
62 {}
63
64 CPatchType *PatchType;
65 CGraphic *G;
66 };
67
68 class CEditor {
69 public:
70 CEditor() : StartUnit(NULL),
71 UnitIndex(0), CursorUnitIndex(-1), SelectedUnitIndex(-1),
72 PatchIndex(0), CursorPatchIndex(-1), SelectedPatchIndex(-1),
73 CursorPlayer(-1), SelectedPlayer(-1), MapLoaded(false),
74 ShowPatchOutlines(false)
75 {};
76 ~CEditor() {};
77
78 void Init();
79
80 std::vector<std::string> UnitTypes; /// Sorted editor unit-type table.
81 std::vector<const CUnitType *> ShownUnitTypes; /// Shown editor unit-type table.
82
83 std::vector<CPatchIcon *> ShownPatchTypes; /// Shown editor patch-type table.
84 std::map<std::string, CPatchIcon *> AllPatchTypes; /// All editor patch-type table.
85
86 IconConfig Select; /// Editor's select icon.
87 IconConfig Units; /// Editor's units icon.
88 IconConfig Patch; /// Editor's patch icon.
89 std::string StartUnitName; /// name of the Unit used to display the start location.
90 const CUnitType *StartUnit; /// Unit used to display the start location.
91
92 int UnitIndex; /// Unit icon draw index.
93 int CursorUnitIndex; /// Unit icon under cursor.
94 int SelectedUnitIndex; /// Unit type to draw.
95
96 int PatchIndex; /// Patch icon draw index.
97 int CursorPatchIndex; /// Patch icon under cursor.
98 int SelectedPatchIndex; /// Patch type to draw.
99
100 int CursorPlayer; /// Player under the cursor.
101 int SelectedPlayer; /// Player selected for draw.
102
103 bool MapLoaded; /// Map loaded in editor
104
105 bool ShowPatchOutlines; /// Show outlines around patches
106 Uint32 PatchOutlineColor; /// Patch outline color
107
108 bool ShowTerrainFlags; /// Show CMapField::Flags
109
110 EditorRunningType Running; /// Editor is running
111
112 EditorStateType State; /// Current editor state
113
114 void TileSelectedPatch();
115 };
116
117 /*----------------------------------------------------------------------------
118 -- Variables
119 ----------------------------------------------------------------------------*/
120
121 extern CEditor Editor;
122
123 extern const char *EditorStartFile; /// Editor CCL start file
124
125 extern bool PatchEditorRunning;
126
127 /*----------------------------------------------------------------------------
128 -- Functions
129 ----------------------------------------------------------------------------*/
130
131 extern void SetEditorSelectIcon(const std::string &icon);
132 extern void SetEditorUnitsIcon(const std::string &icon);
133 extern void SetEditorPatchIcon(const std::string &icon);
134 extern void SetEditorStartUnit(const std::string &name);
135
136 /// Start the editor
137 extern void StartEditor(const std::string &filename);
138
139 /// Save a map from editor
140 extern int EditorSaveMap(const std::string &file);
141
142 /// Start the patch editor
143 extern void StartPatchEditor(const std::string &patchName);
144
145 //@}
146
147 #endif // !__EDITOR_H__