Fixed bug with incorrect editor toggling and checking

dev
Shariq Shah 6 years ago
parent 330ec6c3fa
commit e3e471e8bf
  1. 19
      src/game/editor.c
  2. 1
      src/game/editor.h
  3. 3
      src/game/game.c
  4. 2
      todo.txt

@ -66,7 +66,6 @@ static bool editor_widget_v3(struct nk_context* context,
void editor_init(struct Editor* editor) void editor_init(struct Editor* editor)
{ {
editor->enabled = true;
editor->renderer_settings_window = false; editor->renderer_settings_window = false;
editor->camera_looking_around = false; editor->camera_looking_around = false;
editor->selected_entity = NULL; editor->selected_entity = NULL;
@ -198,8 +197,6 @@ void editor_debugvar_slot_set_quat(int index, quat* value)
void editor_update(struct Editor* editor, float dt) void editor_update(struct Editor* editor, float dt)
{ {
if(!editor->enabled) return;
editor_camera_update(editor, dt); editor_camera_update(editor, dt);
struct Game_State* game_state = game_state_get(); struct Game_State* game_state = game_state_get();
@ -216,9 +213,6 @@ void editor_update(struct Editor* editor, float dt)
/* Top Panel */ /* Top Panel */
if(nk_begin(context, "Top Panel", nk_recti(0, 0, win_width, editor->top_panel_height), NK_WINDOW_NO_SCROLLBAR)) if(nk_begin(context, "Top Panel", nk_recti(0, 0, win_width, editor->top_panel_height), NK_WINDOW_NO_SCROLLBAR))
{
nk_layout_row_dynamic(context, editor->top_panel_height, 1);
nk_group_begin(context, "Menubar", NK_WINDOW_NO_SCROLLBAR);
{ {
static float top_panel_ratios[] = { 0.1f, 0.1f, 0.7f, 0.1f }; static float top_panel_ratios[] = { 0.1f, 0.1f, 0.7f, 0.1f };
static int frames = 0; static int frames = 0;
@ -233,15 +227,14 @@ void editor_update(struct Editor* editor, float dt)
frames = 0; frames = 0;
} }
nk_layout_row(context, NK_DYNAMIC, editor->top_panel_height, sizeof(top_panel_ratios) / sizeof(float), top_panel_ratios); nk_layout_row(context, NK_DYNAMIC, editor->top_panel_height - 10, sizeof(top_panel_ratios) / sizeof(float), top_panel_ratios);
if(nk_button_label(context, "Render Settings")) if(nk_button_label(context, "Render Settings"))
editor->renderer_settings_window = !editor->renderer_settings_window; editor->renderer_settings_window = !editor->renderer_settings_window;
if(nk_button_label(context, "Save config")) if(nk_button_label(context, "Save config"))
config_vars_save("config.symtres", DIRT_USER); config_vars_save("config.symtres", DIRT_USER);
nk_spacing(context, 1); nk_spacing(context, 1);
nk_labelf(context, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, "FPS : %.d", fps); nk_labelf(context, NK_TEXT_ALIGN_RIGHT | NK_TEXT_ALIGN_MIDDLE, "FPS : %.d", fps);
} nk_layout_row_dynamic(context, editor->top_panel_height, 1);
nk_group_end(context);
} }
nk_end(context); nk_end(context);
@ -574,8 +567,12 @@ void editor_on_mousebutton(const struct Event* event)
{ {
assert(event->type == EVT_MOUSEBUTTON_PRESSED || event->type == EVT_MOUSEBUTTON_RELEASED); assert(event->type == EVT_MOUSEBUTTON_PRESSED || event->type == EVT_MOUSEBUTTON_RELEASED);
struct Editor* editor = game_state_get()->editor; struct Game_State* game_state = game_state_get();
struct Gui* gui = game_state_get()->gui; struct Editor* editor = game_state->editor;
struct Gui* gui = game_state->gui;
if(game_state->game_mode != GAME_MODE_EDITOR)
return;
if(event->mousebutton.button == MSB_LEFT && if(event->mousebutton.button == MSB_LEFT &&
event->type == EVT_MOUSEBUTTON_RELEASED && event->type == EVT_MOUSEBUTTON_RELEASED &&
!editor->camera_looking_around && !editor->camera_looking_around &&

@ -9,7 +9,6 @@ struct Entity;
struct Editor struct Editor
{ {
bool enabled;
bool renderer_settings_window; bool renderer_settings_window;
bool camera_looking_around; bool camera_looking_around;
struct Entity* selected_entity; struct Entity* selected_entity;

@ -515,7 +515,6 @@ void game_update(float dt, bool* window_should_close)
if(input_map_state_get("Console_Toggle", KS_RELEASED)) console_toggle(game_state->console); if(input_map_state_get("Console_Toggle", KS_RELEASED)) console_toggle(game_state->console);
if(input_map_state_get("Editor_Toggle", KS_RELEASED)) if(input_map_state_get("Editor_Toggle", KS_RELEASED))
{ {
//editor_toggle();
if(game_state->game_mode == GAME_MODE_EDITOR) if(game_state->game_mode == GAME_MODE_EDITOR)
{ {
game_state->game_mode = GAME_MODE_GAME; game_state->game_mode = GAME_MODE_GAME;
@ -551,7 +550,7 @@ void game_post_update(float dt)
void game_debug_gui(float dt) void game_debug_gui(float dt)
{ {
struct Gui* gui_state = gui_state_get(); struct Gui* gui_state = game_state->gui;
struct nk_context* ctx = &gui_state->context; struct nk_context* ctx = &gui_state->context;
/* window flags */ /* window flags */

@ -1,4 +1,5 @@
Todo: Todo:
- Implement proper topbar
- Specific rendering mode for editor related rendering - Specific rendering mode for editor related rendering
- Basic Editor gizmo for transformation i.e. translate/rotate/scale in world and local coordinates - Basic Editor gizmo for transformation i.e. translate/rotate/scale in world and local coordinates
- Add warning to genie build script when running on windows and WindowsSdkVersion cannot be found. This happens when the script is not run from vcvarsall command prompt - Add warning to genie build script when running on windows and WindowsSdkVersion cannot be found. This happens when the script is not run from vcvarsall command prompt
@ -203,7 +204,6 @@ Done:
* Fixed mouse button press/release behaviour by using event callbacks for editor mouse picking * Fixed mouse button press/release behaviour by using event callbacks for editor mouse picking
* Ray picking for editor * Ray picking for editor
* Highlight entity selected in editor in a specific color * Highlight entity selected in editor in a specific color
* Deselect selected entity in editor when nothing is hit on click and an entity is already selected
* Implemented showing a placeholder when an entity other than a static mesh is selected * Implemented showing a placeholder when an entity other than a static mesh is selected
* Prevented ray casting when clicking on editor window and buttons * Prevented ray casting when clicking on editor window and buttons
* Implemented handling drawing other entity types that can be selected in the editor but are not static meshes * Implemented handling drawing other entity types that can be selected in the editor but are not static meshes

Loading…
Cancel
Save