summaryrefslogtreecommitdiff
path: root/src/editor
diff options
context:
space:
mode:
Diffstat (limited to 'src/editor')
-rw-r--r--src/editor/editor.cpp9
-rw-r--r--src/editor/editor_infobox.cpp2
-rw-r--r--src/editor/editor_menubar.cpp30
-rw-r--r--src/editor/properties.cpp6
-rw-r--r--src/editor/properties.h13
-rw-r--r--src/editor/toolview.cpp20
6 files changed, 45 insertions, 35 deletions
diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp
index dee5080..e2267b8 100644
--- a/src/editor/editor.cpp
+++ b/src/editor/editor.cpp
@@ -604,8 +604,8 @@ STAT editor_new_map( GAME_EDITOR* e, const char* mapname ) {
WORLD_MAP* m = new WORLD_MAP;
defer( map_free( e->game, m ) );
- strcpy( m->name, mapname );
- strcat( m->name, ".hmap" );
+ m->name = mapname;
+ m->name += ".hmap";
m->startpos = { 10.f, 10.f, 0.f };
m->props.push( { .clr = { 1.f, 1.f, 1.f, 1.f } } );
@@ -641,11 +641,10 @@ STAT editor_save_map( GAME_EDITOR* e ) {
if( !serialized ) return STAT_ERR;
defer( cfg_free( serialized ) );
- char full_path[256];
- sprintf( full_path, "../assets/maps/%s", e->map->name );
+ STR full_path = { "../assets/maps/%s", e->map->name.data };
if( !OK( cfg_save( serialized, full_path ) ) ) {
- dlog( "failed to save map %s", full_path );
+ dlog( "failed to save map %s", full_path.data );
return STAT_ERR;
}
diff --git a/src/editor/editor_infobox.cpp b/src/editor/editor_infobox.cpp
index 9f9060d..479b59d 100644
--- a/src/editor/editor_infobox.cpp
+++ b/src/editor/editor_infobox.cpp
@@ -100,7 +100,7 @@ static void gui_editor_infobox_draw_assets( GUI_EDITOR_INFOBOX* box, I32 panel_x
I32 text_x = tx + EDITOR_ASSETS_THUMB + 8;
CLR txt = ui_clr.txt;
if( map_entry ) {
- gui_draw_str( text_x, row_y + 7, ALIGN_L, FNT_JPN12, txt, "[map] -> %s", map->name );
+ gui_draw_str( text_x, row_y + 7, ALIGN_L, FNT_JPN12, txt, "[map] -> %s", map->name.data );
} else if( p->tex ) {
gui_draw_str( text_x, row_y + 7, ALIGN_L, FNT_JPN12, txt, "[%d] -> %s", idx - 1, p->tex->name );
} else {
diff --git a/src/editor/editor_menubar.cpp b/src/editor/editor_menubar.cpp
index b89d1c6..cfb12a3 100644
--- a/src/editor/editor_menubar.cpp
+++ b/src/editor/editor_menubar.cpp
@@ -66,7 +66,7 @@ void editor_raise_header_toolbar( GAME_EDITOR* e ) {
parent->children.push( bar );
}
-static void editor_contextmenu_set_item(
+void editor_contextmenu_set_item(
EDITOR_CONTEXTMENU_ITEM* item,
const char* text,
EDITOR_CONTEXTMENU_CALLBACK cb = 0,
@@ -84,38 +84,38 @@ static void editor_contextmenu_set_item(
item->enabled_cb = enabled_cb;
}
-static void editor_contextmenu_save_cb( void* ) {
+void editor_contextmenu_save_cb( void* ) {
if( editor )
editor_save_map( editor );
}
-static void editor_contextmenu_undo_cb( void* ) {
+void editor_contextmenu_undo_cb( void* ) {
if( editor )
editor_undo( editor );
}
-static void editor_contextmenu_redo_cb( void* ) {
+void editor_contextmenu_redo_cb( void* ) {
if( editor )
editor_redo( editor );
}
-static void editor_contextmenu_set_view_mode_cb( void* data ) {
+void editor_contextmenu_set_view_mode_cb( void* data ) {
editor_set_view_mode( (I32)(I64)data );
}
-static void editor_contextmenu_set_tool_cb( void* data ) {
+void editor_contextmenu_set_tool_cb( void* data ) {
editor_settool( (U8)(I64)data );
}
-static U8 editor_contextmenu_undo_enabled( const EDITOR_CONTEXTMENU_ITEM* ) {
+U8 editor_contextmenu_undo_enabled( const EDITOR_CONTEXTMENU_ITEM* ) {
return editor && editor->undo_actions.size > 0;
}
-static U8 editor_contextmenu_redo_enabled( const EDITOR_CONTEXTMENU_ITEM* ) {
+U8 editor_contextmenu_redo_enabled( const EDITOR_CONTEXTMENU_ITEM* ) {
return editor && editor->redo_actions.size > 0;
}
-static void editor_toolbar_init_entries( GUI_EDITOR_TOOLBAR* bar ) {
+void editor_toolbar_init_entries( GUI_EDITOR_TOOLBAR* bar ) {
if( !bar )
return;
@@ -146,7 +146,7 @@ static void editor_toolbar_init_entries( GUI_EDITOR_TOOLBAR* bar ) {
editor_contextmenu_set_item( &bar->entries[3].items[4], "object", editor_contextmenu_set_tool_cb, (void*)(I64)EDITOR_TOOL_OBJECT );
}
-static I32 editor_toolbar_root_width( const EDITOR_CONTEXTMENU_ITEM* entry ) {
+I32 editor_toolbar_root_width( const EDITOR_CONTEXTMENU_ITEM* entry ) {
if( !entry )
return 44;
@@ -155,7 +155,7 @@ static I32 editor_toolbar_root_width( const EDITOR_CONTEXTMENU_ITEM* entry ) {
return max( 44, text_w + 16 );
}
-static void editor_toolbar_root_rect( GUI_EDITOR_TOOLBAR* bar, I32 idx, I32* rx, I32* ry, I32* rw, I32* rh ) {
+void editor_toolbar_root_rect( GUI_EDITOR_TOOLBAR* bar, I32 idx, I32* rx, I32* ry, I32* rw, I32* rh ) {
I32 x = gui_relx( bar );
I32 y = gui_rely( bar );
I32 cx = x + 8;
@@ -172,11 +172,11 @@ struct EDITOR_TOOLBAR_HIT {
I32 root{-1};
};
-static U8 editor_toolbar_pt_in_rect( I32 mx, I32 my, I32 x, I32 y, I32 w, I32 h ) {
+U8 editor_toolbar_pt_in_rect( I32 mx, I32 my, I32 x, I32 y, I32 w, I32 h ) {
return mx >= x && mx < x + w && my >= y && my < y + h;
}
-static EDITOR_TOOLBAR_HIT editor_toolbar_hit_test( GUI_EDITOR_TOOLBAR* bar, I32 mx, I32 my ) {
+EDITOR_TOOLBAR_HIT editor_toolbar_hit_test( GUI_EDITOR_TOOLBAR* bar, I32 mx, I32 my ) {
EDITOR_TOOLBAR_HIT hit{};
for( I32 i = 0; i < (I32)bar->entries.size; ++i ) {
I32 x = 0, y = 0, w = 0, h = 0;
@@ -190,7 +190,7 @@ static EDITOR_TOOLBAR_HIT editor_toolbar_hit_test( GUI_EDITOR_TOOLBAR* bar, I32
return hit;
}
-static void gui_editor_toolbar_draw_fn( void* ptr ) {
+void gui_editor_toolbar_draw_fn( void* ptr ) {
GUI_EDITOR_TOOLBAR* bar = (GUI_EDITOR_TOOLBAR*)ptr;
I32 x = gui_relx( bar );
I32 y = gui_rely( bar );
@@ -229,7 +229,7 @@ static void gui_editor_toolbar_draw_fn( void* ptr ) {
}
}
-static void gui_editor_toolbar_input_fn( void* ptr ) {
+void gui_editor_toolbar_input_fn( void* ptr ) {
GUI_EDITOR_TOOLBAR* bar = (GUI_EDITOR_TOOLBAR*)ptr;
I32 mx = 0, my = 0;
gui_cursor_pos( &mx, &my );
diff --git a/src/editor/properties.cpp b/src/editor/properties.cpp
index ac21bb0..f3e9473 100644
--- a/src/editor/properties.cpp
+++ b/src/editor/properties.cpp
@@ -139,7 +139,7 @@ void gui_editor_propview_create_wallprops( GUI_EDITOR_PROPVIEW* view ) {
} );
gui_label( x, y, "idx: %d", wall_idx ); y += space;
- y += gui_editor_propview_surfprops_subentry( view, x, y, &s->propid, props );
+ y += gui_editor_propview_surfprops_subentry( view, x, y, &s->propid.id, props );
GUI_VECTORINPUT* posinput;
posinput = gui_vectorinput( x, y, propview_input_width( view ), "start", (F32*)&s->start, 3, -INFINITY, INFINITY, step ); y += (space+18);
@@ -162,7 +162,7 @@ void gui_editor_propview_create_polyprops( GUI_EDITOR_PROPVIEW* view ) {
I32 action_x = propview_action_x( view );
gui_label( x, y, "idx: %d", poly_idx ); y += space;
- y += gui_editor_propview_surfprops_subentry( view, x, y, &p->propid, props );
+ y += gui_editor_propview_surfprops_subentry( view, x, y, &p->propid.id, props );
gui_label( x, y, "vertices: %d", p->vertices.size ); y += space;
I32 idx = 0;
@@ -192,7 +192,7 @@ void gui_editor_propview_create_mapprops( GUI_EDITOR_PROPVIEW* view ) {
F32 step = editor->propgrid? editor->grid : 0.25f;
- gui_label( x, y, "name: %s", m->name ); y += space;
+ gui_label( x, y, "name: %s", m->name.data ); y += space;
gui_label( x, y, "walls: %d", m->walls.size ); y += space;
gui_label( x, y, "polygons: %d", m->polygons.size ); y += space;
gui_label( x, y, "props: %d", m->props.size ); y += space;
diff --git a/src/editor/properties.h b/src/editor/properties.h
index 34ac765..01edbbf 100644
--- a/src/editor/properties.h
+++ b/src/editor/properties.h
@@ -1,7 +1,6 @@
#pragma once
#include "../gamedef.h"
-#include <concepts>
#if IS_EDITOR
#include <math.h>
@@ -34,9 +33,15 @@ enum EditorPropType_t {
EPROP_I64,
EPROP_F32,
EPROP_F64,
+ EPROP_VEC2,
+ EPROP_VEC3,
+ EPROP_VEC4,
+ EPROP_CLR,
+ EPROP_MAPPROP,
EPROP_STRING,
EPROP_OBJ,
EPROP_LIST,
+ EPROP_TEXTURE,
EPROP_TEXTURE_LIST,
};
@@ -72,6 +77,12 @@ struct EDITOR_PROP {
template <> struct __eprop_type<F32> { static const U8 type = EPROP_F32; };
template <> struct __eprop_type<F64> { static const U8 type = EPROP_F64; };
template <> struct __eprop_type<STR> { static const U8 type = EPROP_STRING; };
+ template <> struct __eprop_type<struct CLR> { static const U8 type = EPROP_CLR; };
+ template <> struct __eprop_type<struct VEC2> { static const U8 type = EPROP_VEC2; };
+ template <> struct __eprop_type<struct VEC3> { static const U8 type = EPROP_VEC3; };
+ template <> struct __eprop_type<struct VEC4> { static const U8 type = EPROP_VEC4; };
+ template <> struct __eprop_type<struct MAP_PROPREF> { static const U8 type = EPROP_MAPPROP; };
+ template <> struct __eprop_type<struct GL_TEX2D*> { static const U8 type = EPROP_TEXTURE; };
template <__eobject_base T> struct __eprop_type<T> { static const U8 type = EPROP_OBJ; };
template <typename LT> struct __eprop_type<LIST<LT>> { static const U8 type = EPROP_LIST; };
template <> struct __eprop_type<LIST<struct MAP_TEXTURE_ENTRY*>> { static const U8 type = EPROP_TEXTURE_LIST; };
diff --git a/src/editor/toolview.cpp b/src/editor/toolview.cpp
index 25c308d..6bbaa3a 100644
--- a/src/editor/toolview.cpp
+++ b/src/editor/toolview.cpp
@@ -22,11 +22,11 @@ GUI_EDITOR_TOOLVIEW* gui_editor_toolview_from_item_child( GUI_BASE* child ) {
}
I32 gui_editor_toolview_visible_h( GUI_EDITOR_TOOLVIEW* view ) {
- return std::max( 1, view->h - 4 );
+ return max( 1, view->h - 4 );
}
I32 gui_editor_toolview_max_scroll( GUI_EDITOR_TOOLVIEW* view ) {
- return std::max( 0, view->content_h - gui_editor_toolview_visible_h( view ) );
+ return max( 0, view->content_h - gui_editor_toolview_visible_h( view ) );
}
void gui_editor_toolview_clamp_scroll( GUI_EDITOR_TOOLVIEW* view ) {
@@ -34,7 +34,7 @@ void gui_editor_toolview_clamp_scroll( GUI_EDITOR_TOOLVIEW* view ) {
return;
I32 max_scroll = gui_editor_toolview_max_scroll( view );
- view->scroll = std::min( std::max( 0, view->scroll ), max_scroll );
+ view->scroll = min( max( 0, view->scroll ), max_scroll );
if( view->itemview ) {
view->itemview->y = TOOLVIEW_TITLE_OFFSET - view->scroll;
}
@@ -417,17 +417,17 @@ void gui_editor_toolview_draw_scrollbar( GUI_EDITOR_TOOLVIEW* view, I32 x, I32 y
I32 track_x = x + view->w - TOOLVIEW_SCROLLBAR_W - 3;
I32 track_y = y + 2;
- I32 track_h = std::max( 8, h - 4 );
+ I32 track_h = max( 8, h - 4 );
gui_draw_frect( track_x, track_y, TOOLVIEW_SCROLLBAR_W, track_h, ui_clr.bg_alt );
gui_draw_rect( track_x, track_y, TOOLVIEW_SCROLLBAR_W, track_h, ui_clr.border );
I32 visible_h = gui_editor_toolview_visible_h( view );
- I32 thumb_h = std::max( TOOLVIEW_SCROLLBAR_MIN_H, ( track_h * visible_h ) / std::max( 1, view->content_h ) );
- thumb_h = std::min( thumb_h, track_h );
- I32 travel = std::max( 1, track_h - thumb_h );
- I32 thumb_y = track_y + ( travel * view->scroll ) / std::max( 1, max_scroll );
+ I32 thumb_h = max( TOOLVIEW_SCROLLBAR_MIN_H, ( track_h * visible_h ) / max( 1, view->content_h ) );
+ thumb_h = min( thumb_h, track_h );
+ I32 travel = max( 1, track_h - thumb_h );
+ I32 thumb_y = track_y + ( travel * view->scroll ) / max( 1, max_scroll );
- gui_draw_frect( track_x + 1, thumb_y + 1, TOOLVIEW_SCROLLBAR_W - 2, std::max( 1, thumb_h - 2 ), ui_clr.txt );
+ gui_draw_frect( track_x + 1, thumb_y + 1, TOOLVIEW_SCROLLBAR_W - 2, max( 1, thumb_h - 2 ), ui_clr.txt );
}
void gui_editor_toolview_draw_fn( void* ptr ) {
@@ -453,7 +453,7 @@ void gui_editor_toolview_draw_fn( void* ptr ) {
if( max_scroll > 0 )
clip_w -= TOOLVIEW_SCROLLBAR_W + 2;
- gui_draw_push_clip( x + 2, y + 2, std::max( 1, clip_w ), std::max( 1, h - 4 ) );
+ gui_draw_push_clip( x + 2, y + 2, max( 1, clip_w ), max( 1, h - 4 ) );
view->itemview->draw_fn( view->itemview );
gui_draw_pop_clip();
gui_editor_toolview_draw_scrollbar( view, x, y, h );