#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; const I32 EDITOR_POLY_SIDES_MAX = 32; 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 }; 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{}; } gui; U8 wireframe{}; GAME_EDITOR_TOOL tool; F32 grid{}; U8 propgrid{}; F32 spritesize{}; U8 drawbsp{}; LIST map_list{}; }; 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 LIST* 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 ); 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; }; 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; }; struct GUI_EDITOR_TEXTUREPICKER : GUI_WINDOW { struct GL_TEX2D** target; struct GL_TEX2D* curselect; I32 scrolloff; LIST files; LIST 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;