1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
#pragma once
#include "../gui/base.h"
#include "../util/file.h"
#include "../game/world/map.h"
const F32 EDITOR_DEFAULT_SPRITE_SIZE = 32.f;
const F32 EDITOR_DEFAULT_POLY_SIDES = 6.f;
const F32 EDITOR_DEFAULT_WALL_HEIGHT = 80.f;
const F32 EDITOR_DEFAULT_PLACEMENT_HEIGHT = 0.f;
const I32 EDITOR_POLY_SIDES_MIN = 3;
enum EditorTools_t {
EDITOR_TOOL_NONE,
EDITOR_TOOL_SELECT,
EDITOR_TOOL_WALL,
EDITOR_TOOL_POLY,
EDITOR_TOOL_SPRITE,
EDITOR_TOOL_ENT
};
enum EditorWallShape_t {
EDITOR_WALLSHAPE_LINE = 0,
EDITOR_WALLSHAPE_POLYGON = 1
};
enum EditorSelectType_t {
EDITOR_SELECT_NONE,
EDITOR_SELECT_WALL,
EDITOR_SELECT_POLY,
EDITOR_SELECT_WVERTEX, // wall vertex
EDITOR_SELECT_PVERTEX, // polygon vertex
EDITOR_SELECT_SPRITE,
EDITOR_SELECT_ENT,
EDITOR_SELECT_ORIGIN,
EDITOR_SELECT_SURFPROPS
};
enum EditorUndoType_t {
EDITOR_UNDO_NONE = 0,
EDITOR_UNDO_CREATE_WALLS = 1,
EDITOR_UNDO_CREATE_POLY = 2
};
struct GAME_EDITOR;
typedef void( *EDITOR_GRID_DEP_CALLBACK )( GAME_EDITOR* e );
struct GAME_EDITOR_TOOL {
U8 type;
/* shapes */
I32 wallshape;
F32 polysides;
F32 wallheight;
F32 placementheight;
GL_TEX2D* tex;
/* entity */
U32 entclass;
void* entprops;
};
struct GAME_EDITOR {
GAME_DATA* game;
struct WORLD_MAP* map;
struct GUI_EDITORWINDOW* wnd;
struct EDITOR_GUI {
struct GUI_WINDOW* new_map_popup;
struct GUI_EDITOR_2DVIEW* v2d;
struct GUI_EDITOR_3DVIEW* v3d;
struct GUI_LABEL* gridlabel;
struct GUI_EDITOR_PROPVIEW* props;
struct GUI_EDITOR_TOOLVIEW* tool;
I32 map_select{};
I32 props_w{300};
I32 props_h{300};
I32 view_h{370};
GUI_VIEW* assets{};
GUI_VIEW* status{};
I32 assets_scroll{};
I32 view_mode{};
I32 view2d_type{};
GUI_BASE* header_toolbar{};
GUI_LABEL* header_viewtype_label{};
GUI_BUTTON* header_back{};
GUI_BUTTON* header_mode_2d{};
GUI_BUTTON* header_mode_3d{};
GUI_BUTTON* header_mode_sim{};
GUI_BASE* header_viewtype{};
} gui;
U8 wireframe{};
GAME_EDITOR_TOOL tool;
F32 grid{};
U8 propgrid{};
F32 spritesize{};
U8 drawbsp{};
struct GRID_DEPENDENCY {
void* tag{};
EDITOR_GRID_DEP_CALLBACK cb{};
};
LIST<GRID_DEPENDENCY> grid_dependencies{};
LIST<GUI_LIST_ENTRY> map_list{};
struct EDITOR_UNDO_ACTION {
U8 type{};
I32 start_idx{};
LIST<MAP_WALL> walls{};
LIST<MAP_POLYGON> polys{};
};
LIST<EDITOR_UNDO_ACTION> undo_actions{};
LIST<EDITOR_UNDO_ACTION> redo_actions{};
};
extern GAME_EDITOR* editor_create( struct GAME_DATA* game );
extern void editor_destroy( GAME_EDITOR* editor );
extern STAT editor_load_map( GAME_EDITOR* e, const char* mapname );
extern STAT editor_save_map( GAME_EDITOR* e );
extern STAT editor_new_map( GAME_EDITOR* e, const char* mapname );
extern STAT editor_close( GAME_EDITOR* e );
extern void editor_resize( GAME_EDITOR* e, I32 w, I32 h );
extern void editor_register_grid_dependency( GAME_EDITOR* e, void* tag, EDITOR_GRID_DEP_CALLBACK cb );
extern void editor_notify_grid_change( GAME_EDITOR* e );
extern LIST<GUI_LIST_ENTRY>* editor_get_map_list( GAME_EDITOR* e );
extern void editor_load_map_cb( void* );
extern void editor_new_map_cb( void* );
extern void editor_create_map_view( GAME_EDITOR* e );
extern void editor_update_properties_column( GAME_EDITOR* e );
extern void editor_undo_clear( GAME_EDITOR* e );
extern void editor_undo_record_create_walls( GAME_EDITOR* e, I32 start_idx, I32 count );
extern void editor_undo_record_create_poly( GAME_EDITOR* e, I32 start_idx );
extern U8 editor_undo( GAME_EDITOR* e );
extern U8 editor_redo( GAME_EDITOR* e );
struct GUI_EDITORWINDOW : GUI_WINDOW {};
struct GUI_EDITOR_3DVIEW : GUI_VIEW {
U8 heldoutbounds;
};
struct GUI_EDITOR_2DVIEW : GUI_VIEW {
F32 scale;
F32 posx, posy;
I32 moffx, moffy;
F32 voffx, voffy;
U8 dragheld;
U8 held;
U8 heldoutbounds;
I32 oldmx, oldmy;
F32 mremainx, mremainy;
void* curselect;
U8 seltype;
void* curdrag;
U8 dragtype;
U8 dragmoved;
U8 poly_drag;
VEC2 poly_start;
VEC2 poly_end;
I32 pending_wall_undo_idx;
};
struct GUI_EDITOR_PROPVIEW : GUI_VIEW {
void* curselect;
U8 seltype;
GUI_VIEW* itemview;
};
struct GUI_EDITOR_TOOLVIEW : GUI_VIEW {
GUI_VIEW* itemview;
U8 wallshape_dropdown_open;
I32 scroll;
I32 content_h;
};
struct GUI_EDITOR_TEXTUREPICKER : GUI_WINDOW {
struct GL_TEX2D** target;
struct GL_TEX2D* curselect;
I32 scrolloff;
LIST<FILE_ENTRY> files;
LIST<struct GL_TEX2D*> textures;
I32 scrollheight;
U32 rowcount;
char search[256];
U32 curload;
U8 loaded;
GL_TEX2D* heldselect;
GUI_LABEL* densitylabel;
GUI_CALLBACK cb;
};
extern GUI_EDITORWINDOW* gui_editorwindow( I32 w, I32 h );
extern GUI_EDITOR_2DVIEW* gui_editor_2dview( I32 x, I32 y, I32 w, I32 h );
extern GUI_EDITOR_3DVIEW* gui_editor_3dview( I32 x, I32 y, I32 w, I32 h );
extern GUI_EDITOR_PROPVIEW* gui_editor_propview( I32 x, I32 y, I32 w, I32 h );
extern void gui_editor_propview_select( GUI_EDITOR_PROPVIEW* e, void* what, U8 seltype );
extern void gui_editor_propview_update( GUI_EDITOR_PROPVIEW* e );
extern GUI_EDITOR_TOOLVIEW* gui_editor_toolview( I32 x, I32 y, I32 w, I32 h );
extern void gui_editor_toolview_update( GUI_EDITOR_TOOLVIEW* view );
extern GUI_EDITOR_TEXTUREPICKER* gui_editor_texturepicker( I32 x, I32 y, I32 w, I32 h, GL_TEX2D** target );
extern GAME_EDITOR* editor;
|