From 882880b7cfa0991865607d7e676a796279410f1e Mon Sep 17 00:00:00 2001 From: Shariq Shah Date: Tue, 24 Mar 2020 17:32:18 +1100 Subject: [PATCH] Added door properties to property inspector --- assets/entities/door.symtres | 2 +- src/common/version.h | 2 +- src/game/door.h | 3 +- src/game/editor.c | 57 ++++++++++++++++++++++++++++++++++++ todo.txt | 6 ++-- 5 files changed, 64 insertions(+), 6 deletions(-) diff --git a/assets/entities/door.symtres b/assets/entities/door.symtres index a775f02..ca66151 100644 --- a/assets/entities/door.symtres +++ b/assets/entities/door.symtres @@ -10,7 +10,7 @@ Entity bounding_box_max : 0.500 0.500 0.500 door_speed : 6.000 door_state : 0 - door_mask : 1 + door_mask : 0 door_open_position : -7.000 door_close_position : 0.000 } diff --git a/src/common/version.h b/src/common/version.h index e73c36b..d7a05c1 100755 --- a/src/common/version.h +++ b/src/common/version.h @@ -4,7 +4,7 @@ /* Auto generated version file. DO NOT MODIFY */ #define SYMMETRY_VERSION_MAJOR 0 #define SYMMETRY_VERSION_MINOR 1 -#define SYMMETRY_VERSION_REVISION 339 +#define SYMMETRY_VERSION_REVISION 340 #define SYMMETRY_VERSION_BRANCH "dev" #endif \ No newline at end of file diff --git a/src/game/door.h b/src/game/door.h index 501dc29..3a42ac9 100644 --- a/src/game/door.h +++ b/src/game/door.h @@ -12,7 +12,8 @@ enum Door_State DOOR_CLOSED = 0, DOOR_OPEN, DOOR_CLOSING, - DOOR_OPENING + DOOR_OPENING, + DOOR_STATE_MAX }; void door_init(struct Door* door, int mask); diff --git a/src/game/editor.c b/src/game/editor.c index a96b91f..a3fe5d7 100755 --- a/src/game/editor.c +++ b/src/game/editor.c @@ -33,6 +33,7 @@ #include "debug_vars.h" #include "../common/version.h" #include "sound_source.h" +#include "door.h" #include #include @@ -1747,6 +1748,13 @@ void editor_window_scene_hierarchy(struct nk_context* context, struct Editor* ed nk_tree_pop(context); } + if(nk_tree_push(context, NK_TREE_TAB, "Doors", NK_MAXIMIZED)) + { + for(int i = 0; i < MAX_SCENE_DOORS; i++) + editor_show_entity_in_list(editor, context, scene, &scene->doors[i]); + nk_tree_pop(context); + } + if(nk_tree_push(context, NK_TREE_TAB, "Entities", NK_MAXIMIZED)) { for(int i = 0; i < MAX_SCENE_ENTITIES; i++) @@ -2353,6 +2361,55 @@ void editor_window_property_inspector(struct nk_context* context, struct Editor* nk_tree_pop(context); } } + + /* Door */ + if(entity->type == ET_DOOR) + { + struct Door* door = (struct Door*)entity; + if(nk_tree_push(context, NK_TREE_TAB, "Door", NK_MAXIMIZED)) + { + nk_layout_row_dynamic(context, row_height, 2); + nk_label(context, "State", LABEL_FLAGS_ALIGN_LEFT); + float combo_width = nk_widget_width(context), combo_height = row_height * DOOR_STATE_MAX; + int state = nk_combo_string(context, "Closed\0Open\0Closing\0Opening", door->state, DOOR_STATE_MAX, row_height, nk_vec2(combo_width, combo_height)); + + nk_layout_row_dynamic(context, row_height, 1); + nk_label(context, "Key Mask", NK_TEXT_ALIGN_MIDDLE | NK_TEXT_ALIGN_CENTERED); + nk_layout_row_dynamic(context, row_height, 3); + nk_checkbox_flags_label(context, "Red", &door->mask, DOOR_KEY_MASK_RED); + nk_checkbox_flags_label(context, "Green", &door->mask, DOOR_KEY_MASK_GREEN); + nk_checkbox_flags_label(context, "Blue", &door->mask, DOOR_KEY_MASK_BLUE); + nk_layout_row_dynamic(context, row_height, 1); + nk_property_float(context, "Speed", -FLT_MAX, &door->speed, FLT_MAX, 0.1f, 0.1f); + nk_property_float(context, "Open Pos", -FLT_MAX, &door->open_position, FLT_MAX, 0.1f, 0.1f); + nk_property_float(context, "Close Pos", -FLT_MAX, &door->close_position, FLT_MAX, 0.1f, 0.1f); + + if(nk_button_label(context, "Select Sound Source")) + { + editor_entity_select(editor, door->sound); + nk_tree_pop(context); + nk_end(context); + return; + } + + if(nk_button_label(context, "Select Trigger")) + { + editor_entity_select(editor, door->trigger); + nk_tree_pop(context); + nk_end(context); + return; + } + + if(nk_button_label(context, "Select Static Mesh")) + { + editor_entity_select(editor, door->mesh); + nk_tree_pop(context); + nk_end(context); + return; + } + nk_tree_pop(context); + } + } } else { diff --git a/todo.txt b/todo.txt index 7d49719..be2ff34 100644 --- a/todo.txt +++ b/todo.txt @@ -1,11 +1,10 @@ Todo: - - Add door properties to property inspector in editor - Switch transformation in property inspector to show/modify local transform values by default and show absolute transform values as read-only. - Doors that open using the red/green/blue keys only as a way of progressing the level or cordoing off certain sections - RGB keys to progress to next level - Player/enemies getting hit by bullets - Win/fail States - - Remove excessive repitition in scene related code that handles multiple entity types + - Remove excessive repitition in scene and editor code that handles multiple entity types - Allow switching to editor mode when game is in pause mode - Rendering Additions: - Color grading @@ -419,4 +418,5 @@ Done: * Remove ODE completely * Fixed console not working in game mode * Pause sound when game is in pause mode - * Composite door entity made up of static mesh, sound entity and trigger. Door might require 0-3 keys in order to be opened. \ No newline at end of file + * Composite door entity made up of static mesh, sound entity and trigger. Door might require 0-3 keys in order to be opened. + * Add door properties to property inspector in editor \ No newline at end of file