From c443e4d9ee6101ef1f4558f2ea7f03601c5413da Mon Sep 17 00:00:00 2001 From: Shariq Shah Date: Mon, 13 May 2019 13:00:34 +1000 Subject: [PATCH] Fixed editor camera right-click bug --- src/game/editor.c | 7 +++++-- src/game/entity.c | 14 +++++++------- src/game/input.c | 6 +++--- todo.txt | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/game/editor.c b/src/game/editor.c index d0544d7..2fef6e4 100755 --- a/src/game/editor.c +++ b/src/game/editor.c @@ -757,7 +757,7 @@ void editor_on_mousebutton_release(const struct Event* event) struct Editor* editor = game_state->editor; struct Gui* gui = game_state->gui; - if(game_state->game_mode != GAME_MODE_EDITOR || nk_window_is_any_hovered(&gui->context) || game_state->console->visible) + if(game_state->game_mode != GAME_MODE_EDITOR || game_state->console->visible) return; if(editor->camera_looking_around) @@ -772,6 +772,9 @@ void editor_on_mousebutton_release(const struct Event* event) editor_axis_set(editor, editor->previous_axis); } + if(nk_window_is_any_hovered(&gui->context)) + return; + if(event->mousebutton.button == MSB_LEFT && !editor->camera_looking_around && nk_item_is_any_active(&gui->context) == 0) @@ -1320,7 +1323,7 @@ void editor_camera_update(struct Editor* editor, float dt) { struct Game_State* game_state = game_state_get(); struct Gui* gui = game_state->gui; - if(nk_window_is_any_hovered(&gui->context) || game_state->console->visible) + if(game_state->console->visible) return; struct Camera* editor_camera = &game_state_get()->scene->cameras[CAM_EDITOR]; diff --git a/src/game/entity.c b/src/game/entity.c index 79d3542..1d7a34b 100755 --- a/src/game/entity.c +++ b/src/game/entity.c @@ -295,22 +295,22 @@ struct Entity* entity_read(struct Parser_Object* object) case ET_LIGHT: { struct Light* light = scene_light_create(scene, name, NULL, LT_POINT); - if(hashmap_value_exists(object->data, "light_type")) light->type = hashmap_int_get(object->data, "type"); + if(hashmap_value_exists(object->data, "light_type")) light->type = hashmap_int_get(object->data, "light_type"); if(hashmap_value_exists(object->data, "outer_angle")) light->outer_angle = hashmap_float_get(object->data, "outer_angle"); if(hashmap_value_exists(object->data, "inner_angle")) light->inner_angle = hashmap_float_get(object->data, "inner_angle"); - if(hashmap_value_exists(object->data, "falloff")) light->falloff = hashmap_float_get(object->data, "falloff"); - if(hashmap_value_exists(object->data, "intensity")) light->intensity = hashmap_float_get(object->data, "intensity"); - if(hashmap_value_exists(object->data, "depth_bias")) light->depth_bias = hashmap_float_get(object->data, "depth_bias"); - if(hashmap_value_exists(object->data, "color")) light->color = hashmap_vec3_get(object->data, "color"); + if(hashmap_value_exists(object->data, "falloff")) light->falloff = hashmap_float_get(object->data, "falloff"); + if(hashmap_value_exists(object->data, "intensity")) light->intensity = hashmap_float_get(object->data, "intensity"); + if(hashmap_value_exists(object->data, "depth_bias")) light->depth_bias = hashmap_float_get(object->data, "depth_bias"); + if(hashmap_value_exists(object->data, "color")) light->color = hashmap_vec3_get(object->data, "color"); if(hashmap_value_exists(object->data, "cast_shadow")) light->cast_shadow = hashmap_bool_get(object->data, "cast_shadow"); if(hashmap_value_exists(object->data, "pcf_enabled")) light->pcf_enabled = hashmap_bool_get(object->data, "pcf_enabled"); - if(hashmap_value_exists(object->data, "radius")) light->radius = hashmap_int_get(object->data, "radius"); + if(hashmap_value_exists(object->data, "radius")) light->radius = hashmap_int_get(object->data, "radius"); new_entity = &light->base; } break; case ET_SOUND_SOURCE: { - struct Sound_Source* sound_source = scene_sound_source_create(scene, name, NULL, "default.wav", ST_WAV, true, true); + struct Sound_Source* sound_source = scene_sound_source_create(scene, name, NULL, "teh_beatz.wav", ST_WAV, true, true); sound_source->type = ST_WAV; sound_source->playing = false; sound_source->loop = false; diff --git a/src/game/input.c b/src/game/input.c index 15e2c67..5704783 100755 --- a/src/game/input.c +++ b/src/game/input.c @@ -35,9 +35,9 @@ void input_init(void) struct Key_Binding left_keys = {KEY_A, KMOD_NONE, KEY_LEFT, KMOD_NONE, KS_INACTIVE}; struct Key_Binding right_keys = {KEY_D, KMOD_NONE, KEY_RIGHT, KMOD_NONE, KS_INACTIVE}; struct Key_Binding turn_right_keys = {KEY_L, KMOD_NONE, KEY_NONE, KMOD_NONE, KS_INACTIVE}; - struct Key_Binding turn_left_keys = {KEY_J, KMOD_NONE, KEY_NONE, KMOD_NONE, KS_INACTIVE}; - struct Key_Binding turn_up_keys = {KEY_I, KMOD_NONE, KEY_NONE, KMOD_NONE, KS_INACTIVE}; - struct Key_Binding turn_down_keys = {KEY_K, KMOD_NONE, KEY_NONE, KMOD_NONE, KS_INACTIVE}; + struct Key_Binding turn_left_keys = {KEY_H, KMOD_NONE, KEY_NONE, KMOD_NONE, KS_INACTIVE}; + struct Key_Binding turn_up_keys = {KEY_K, KMOD_NONE, KEY_NONE, KMOD_NONE, KS_INACTIVE}; + struct Key_Binding turn_down_keys = {KEY_J, KMOD_NONE, KEY_NONE, KMOD_NONE, KS_INACTIVE}; struct Key_Binding sprint_keys = {KEY_LSHIFT, KMOD_NONE, KEY_RSHIFT, KMOD_NONE, KS_INACTIVE}; struct Key_Binding editor_toggle_keys = {KEY_F1, KMOD_NONE, KEY_NONE, KMOD_NONE, KS_INACTIVE}; struct Key_Binding console_toggle_keys = {KEY_TILDE, KMOD_NONE, KEY_NONE, KMOD_NONE, KS_INACTIVE}; diff --git a/todo.txt b/todo.txt index 10443d8..d7149ec 100644 --- a/todo.txt +++ b/todo.txt @@ -1,6 +1,5 @@ Todo: - Finish mesh and material properties serialization to and from file - - Console command to read/write entity to file and add it to scene - Editor functionality to add entity from specific file to scene - Scene read/write to file with scene file only containing names of entity archetypes @@ -112,7 +111,6 @@ Bugs: - Fix hang on fullscreen toggle - Fix axis lines not aligning with grid lines - Fix arc angles resetting when rotating - - Fix editor camera right-click behaviour Done: * Input @@ -305,4 +303,6 @@ Done: * Disabled editor functionalites when console is toggled * Entity to file read/write * Added editor shortcut key to delete selected entity + * Console command to read/write entity to file and add it to scene + * Fix editor camera right-click behaviour