From f8b92ce3aa08b1445c9f956d8166830946562d12 Mon Sep 17 00:00:00 2001 From: navewindre Date: Wed, 3 Sep 2025 20:10:09 +0200 Subject: a --- src/editor/editor.h | 135 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 src/editor/editor.h (limited to 'src/editor/editor.h') diff --git a/src/editor/editor.h b/src/editor/editor.h new file mode 100644 index 0000000..0bf2ab4 --- /dev/null +++ b/src/editor/editor.h @@ -0,0 +1,135 @@ +#pragma once +#include "../gui/base.h" +#include "../util/file.h" +#include "../game/world/map.h" + +const F32 EDITOR_DEFAULT_SPRITE_SIZE = 32.f; + +enum EditorTools_t { + EDITOR_TOOL_NONE, + EDITOR_TOOL_SELECT, + EDITOR_TOOL_WALL, + EDITOR_TOOL_POLY, + EDITOR_TOOL_SPRITE, + EDITOR_TOOL_ENT +}; + +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 { + 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* toollabel; + + struct GUI_LABEL* gridlabel; + + struct GUI_EDITOR_PROPVIEW* props; + I32 map_select{}; + } gui; + + + U8 wireframe{}; + U8 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 ); + +struct GUI_EDITORWINDOW : GUI_WINDOW {}; +struct GUI_EDITOR_3DVIEW : GUI_VIEW {}; +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; +}; + +struct GUI_EDITOR_PROPVIEW : GUI_VIEW { + void* curselect; + U8 seltype; + + GUI_VIEW* itemview; +}; + +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 GUI_EDITOR_TEXTUREPICKER* gui_editor_texturepicker( I32 x, I32 y, I32 w, I32 h, GL_TEX2D** target ); + +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 GAME_EDITOR* editor; -- cgit v1.2.3