From 1bc5e6250208955700a2ff95073fc545e323bf79 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Tue, 30 Mar 2021 12:51:46 +0900 Subject: [PATCH] Fixes with change window size WIP window size still doesn't change properly --- src/helpers.hpp | 4 ++-- src/raygui.cpp | 4 ++++ src/state.cpp | 13 ++++++++++--- src/state.hpp | 9 ++++----- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/helpers.hpp b/src/helpers.hpp index cc04c86..d9127b9 100644 --- a/src/helpers.hpp +++ b/src/helpers.hpp @@ -173,14 +173,14 @@ namespace Tri { state->get_input_width(), 800, 1920, - true); + state->get_flags().test(State::F_TAB_TOGGLE)); GuiValueBox( {384.0f, 348.0f, 80.0f, 16.0f}, "Height", state->get_input_height(), 600, 1080, - true); + !state->get_flags().test(State::F_TAB_TOGGLE)); const std::string &failMessage = state->failed_message(); if(!failMessage.empty()) { GuiLabel({304.0f, 368.0f, 284.0f, 16.0f}, failMessage.c_str()); diff --git a/src/raygui.cpp b/src/raygui.cpp index bec96f3..9e3d45c 100644 --- a/src/raygui.cpp +++ b/src/raygui.cpp @@ -1,2 +1,6 @@ +#pragma warning(push, 0) + #define RAYGUI_IMPLEMENTATION #include + +#pragma warning(pop) diff --git a/src/state.cpp b/src/state.cpp index c44e627..2d00d34 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -150,8 +150,9 @@ void Tri::State::handle_events() { case KEY_I: flags.flip(F_DISPLAY_CHANGE_SIZE); if(!flags.test(F_DISPLAY_CHANGE_SIZE)) { - inputWidth = width; - inputHeight = height; + close_input_width_height_window(); + } else { + failedMessage = "Press TAB to switch between width/height"; } break; case KEY_E: @@ -164,6 +165,9 @@ void Tri::State::handle_events() { } } break; + case KEY_TAB: + flags.flip(F_TAB_TOGGLE); + break; } } keyPressed = GetKeyPressed(); @@ -394,7 +398,7 @@ std::array& Tri::State::get_bg_color() { return bgColorPickerColor; } -Tri::State::FilenameBufferType* Tri::State::get_save_filename_buffer() { +std::array* Tri::State::get_save_filename_buffer() { return &saveFilenameBuffer; } @@ -505,6 +509,9 @@ bool Tri::State::change_width_height() { } void Tri::State::close_input_width_height_window() { + failedMessage.clear(); + inputWidth = width; + inputHeight = height; flags.reset(F_DISPLAY_CHANGE_SIZE); } diff --git a/src/state.hpp b/src/state.hpp index 53b3061..4ebece4 100644 --- a/src/state.hpp +++ b/src/state.hpp @@ -34,6 +34,7 @@ namespace Tri { F_SELECT_TRI_MODE = 11, F_TRI_EDIT_MODE = 12, F_TRI_EDIT_DRAW_TRI = 13, + F_TAB_TOGGLE = 14, }; private: @@ -44,8 +45,7 @@ namespace Tri { unsigned int height; float dt; float notification_alpha; - typedef std::array NBufferType; - NBufferType notification_text; + std::array notification_text; std::vector tris; unsigned int trisIndex; @@ -58,8 +58,7 @@ namespace Tri { std::array bgColorPickerColor; Color bgColor; - typedef std::array FilenameBufferType; - FilenameBufferType saveFilenameBuffer; + std::array saveFilenameBuffer; std::string failedMessage; RenderTexture2D drawCache; @@ -97,7 +96,7 @@ namespace Tri { std::array& get_color(); std::array& get_bg_color(); - FilenameBufferType* get_save_filename_buffer(); + std::array* get_save_filename_buffer(); bool do_save(); const std::string& failed_message() const; void close_save();