diff --git a/src/common/version.h b/src/common/version.h index 59632c3..0a795db 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 334 +#define SYMMETRY_VERSION_REVISION 335 #define SYMMETRY_VERSION_BRANCH "dev" #endif \ No newline at end of file diff --git a/src/game/console.c b/src/game/console.c index 011a346..58807de 100755 --- a/src/game/console.c +++ b/src/game/console.c @@ -84,11 +84,11 @@ void console_toggle(struct Console* console) } } -void console_update(struct Console* console, struct Gui* gui_state, float dt) +void console_update(struct Console* console, struct Gui* gui, float dt) { if(!console->visible) return; - struct nk_context* context = &gui_state->context; + struct nk_context* context = &gui->context; struct Game_State* game_state = game_state_get(); int win_width = 0, win_height = 0; diff --git a/src/game/game.c b/src/game/game.c index 2234bb0..de59ce0 100755 --- a/src/game/game.c +++ b/src/game/game.c @@ -75,7 +75,7 @@ bool game_init(struct Window* window, struct Hashmap* cvars) game_state->scene = calloc(1, sizeof(*game_state->scene)); game_state->console = calloc(1, sizeof(*game_state->console)); game_state->editor = calloc(1, sizeof(*game_state->editor)); - game_state->gui_editor = calloc(1, sizeof(*game_state->gui_editor)); + game_state->gui_editor = calloc(1, sizeof(*game_state->gui_editor)); game_state->gui_game = calloc(1, sizeof(*game_state->gui_game)); game_state->event_manager = calloc(1, sizeof(*game_state->event_manager)); game_state->sound = calloc(1, sizeof(*game_state->sound)); @@ -589,10 +589,12 @@ void game_update(float dt, bool* window_should_close) if(game_state->game_mode == GAME_MODE_PAUSE) { game_state->game_mode = GAME_MODE_GAME; + sound_pause_all(game_state->sound, false); } else if(game_state->game_mode == GAME_MODE_GAME) { game_state->game_mode = GAME_MODE_PAUSE; + sound_pause_all(game_state->sound, true); input_mouse_mode_set(MM_NORMAL); int width = 0, height = 0; window_get_drawable_size(game_state_get()->window, &width, &height); @@ -602,7 +604,7 @@ void game_update(float dt, bool* window_should_close) //game_debug(dt); //game_debug_gui(dt); - console_update(game_state->console, game_state->gui_editor, dt); + console_update(game_state->console, game_state->game_mode == GAME_MODE_EDITOR ? game_state->gui_editor : game_state->gui_game, dt); scene_update(game_state->scene, dt); if(game_state->game_mode == GAME_MODE_EDITOR) { diff --git a/src/game/gui.c b/src/game/gui.c index 769215a..8937af6 100755 --- a/src/game/gui.c +++ b/src/game/gui.c @@ -345,7 +345,7 @@ void gui_on_mousebutton(const struct Event* event) int x = event->mousebutton.x; int y = event->mousebutton.y; int down = event->type == EVT_MOUSEBUTTON_PRESSED ? 1 : 0; - struct nk_context* ctx = game_state->game_mode == GAME_MODE_EDITOR ? &game_state->gui_editor->context : &game_state->gui_game; + struct nk_context* ctx = game_state->game_mode == GAME_MODE_EDITOR ? &game_state->gui_editor->context : &game_state->gui_game->context; if(button == MSB_LEFT) nk_input_button(ctx, NK_BUTTON_LEFT, x, y, down); if(button == MSB_MIDDLE) nk_input_button(ctx, NK_BUTTON_MIDDLE, x, y, down); @@ -359,7 +359,7 @@ void gui_on_mousemotion(const struct Event* event) int y = event->mousemotion.y; int xrel = event->mousemotion.xrel; int yrel = event->mousemotion.yrel; - struct nk_context* ctx = game_state->game_mode == GAME_MODE_EDITOR ? &game_state->gui_editor->context : &game_state->gui_game; + struct nk_context* ctx = game_state->game_mode == GAME_MODE_EDITOR ? &game_state->gui_editor->context : &game_state->gui_game->context; if(ctx->input.mouse.grabbed) { @@ -375,7 +375,7 @@ void gui_on_mousemotion(const struct Event* event) void gui_on_textinput(const struct Event* event) { struct Game_State* game_state = game_state_get(); - struct nk_context* ctx = game_state->game_mode == GAME_MODE_EDITOR ? &game_state->gui_editor->context : &game_state->gui_game; + struct nk_context* ctx = game_state->game_mode == GAME_MODE_EDITOR ? &game_state->gui_editor->context : &game_state->gui_game->context; nk_glyph glyph; memcpy(glyph, event->text_input.text, NK_UTF_SIZE); nk_input_glyph(ctx, glyph); @@ -386,7 +386,7 @@ void gui_on_mousewheel(const struct Event* event) int x = event->mousewheel.x; int y = event->mousewheel.y; struct Game_State* game_state = game_state_get(); - struct nk_context* ctx = game_state->game_mode == GAME_MODE_EDITOR ? &game_state->gui_editor->context : &game_state->gui_game; + struct nk_context* ctx = game_state->game_mode == GAME_MODE_EDITOR ? &game_state->gui_editor->context : &game_state->gui_game->context; nk_input_scroll(ctx, nk_vec2(x, y)); } diff --git a/src/game/gui_game.c b/src/game/gui_game.c index ab89f3b..811eed4 100644 --- a/src/game/gui_game.c +++ b/src/game/gui_game.c @@ -1,6 +1,7 @@ #include "gui_game.h" #include "gui.h" #include "game.h" +#include "../common/log.h" #include "../system/platform.h" static void gui_game_pause_menu(struct nk_context* context); @@ -45,6 +46,12 @@ void gui_game_pause_menu(struct nk_context* context) { nk_layout_row_dynamic(context, 30, 1); nk_label(context, "Hello from the Pause Menu!", NK_TEXT_ALIGN_CENTERED | NK_TEXT_ALIGN_MIDDLE); + + if(nk_button_label(context, "Button")) + { + log_message("Pressed!"); + } + nk_end(context); } } diff --git a/src/system/sound.c b/src/system/sound.c index 12324c6..999ba0b 100755 --- a/src/system/sound.c +++ b/src/system/sound.c @@ -63,6 +63,11 @@ void sound_listener_update(struct Sound* sound) up.x, up.y, up.z); // Up } +void sound_pause_all(struct Sound* sound, bool pause) +{ + Soloud_setPauseAll(sound->soloud_context, pause); +} + void sound_listener_set(struct Sound* sound, struct Entity* listener) { sound->listener = listener; diff --git a/src/system/sound.h b/src/system/sound.h index fc5ca74..7d8b105 100755 --- a/src/system/sound.h +++ b/src/system/sound.h @@ -51,6 +51,7 @@ void sound_master_volume_set(struct Sound* sound, float volume); void sound_listener_set(struct Sound* sound, struct Entity* listener); void sound_update_3d(struct Sound* sound); void sound_listener_update(struct Sound* sound); +void sound_pause_all(struct Sound* sound, bool pause); void sound_source_instance_update_position(struct Sound* sound, uint source_instance, vec3 abs_pos); uint sound_source_instance_create(struct Sound* sound, struct Sound_Source_Buffer* source, bool is3d); diff --git a/todo.txt b/todo.txt index 09a6585..95ab1bb 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,5 @@ Todo: + - Allow switching to editor mode when game is in pause mode - Implement flag for ignoring collisions with certain entities - Implement separate property window for player related variables that can be shown in the editor similar to renderer settings etc - Implement game gui either with a separate nuklear context or as part of existing context @@ -403,4 +404,6 @@ Done: * Implement Triggers * Fix crash where if entity selected in editor is deleted in game mode and then returning to editor mode causes a crash * Add "Select Parent" button to property inspector - * Remove ODE completely \ No newline at end of file + * Remove ODE completely + * Fixed console not working in game mode + * Pause sound when game is in pause mode \ No newline at end of file