From 0b1e37119c17642f475ee5a065880a24de5049f0 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Fri, 18 Jun 2021 17:55:01 +0200 Subject: [PATCH] [ADD] resum textyre --- .../calibration/HandCalibrator.cpp | 1 - src/scenes/in_Game_Scene.cpp | 38 +++++++++++++++++-- src/scenes/in_Game_Scene.h | 4 ++ 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/computervision/calibration/HandCalibrator.cpp b/src/computervision/calibration/HandCalibrator.cpp index dcf2911..10d2ff5 100644 --- a/src/computervision/calibration/HandCalibrator.cpp +++ b/src/computervision/calibration/HandCalibrator.cpp @@ -18,7 +18,6 @@ namespace computervision { cv::rectangle(output_frame, cv::Rect(0, 0, output_frame.cols, 40), cv::Scalar(0, 0, 0), -1); cv::putText(output_frame, "Hand calibration", cv::Point(output_frame.cols / 2 - 100, 25), cv::FONT_HERSHEY_PLAIN, 2.0, cv::Scalar(18, 219, 65), 2); - cv::putText(output_frame, "press 'b' to calibrate background,then press 's' to calibrate skin tone", cv::Point(5, 35), cv::FONT_HERSHEY_PLAIN, 1.0, cv::Scalar(18, 219, 65), 1); cv::rectangle(output_frame, cv::Rect(0, output_frame.rows - 80, 450, output_frame.cols), cv::Scalar(0, 0, 0), -1); diff --git a/src/scenes/in_Game_Scene.cpp b/src/scenes/in_Game_Scene.cpp index 991231f..21c056b 100644 --- a/src/scenes/in_Game_Scene.cpp +++ b/src/scenes/in_Game_Scene.cpp @@ -174,9 +174,9 @@ namespace scene gui::GuiTexture background(render_engine::loader::LoadTexture("res/background_grey.png"), glm::vec2(0, 0), glm::vec2(1, 1)); pause_guis.push_back(&background); - gui::Button pause_button_resume(render_engine::loader::LoadTexture("res/menu_item_start1.png"), glm::vec2(0.0f, 0.3f), glm::vec2(0.25f, 0.25f)); - pause_button_resume.SetHoverTexture(render_engine::loader::LoadTexture("res/menu_item_start1_hover.png")); - pause_button_resume.SetClickedTexture(render_engine::loader::LoadTexture("res/menu_item_start1_click.png")); + gui::Button pause_button_resume(render_engine::loader::LoadTexture("res/menu_item_resume1.png"), glm::vec2(0.0f, 0.3f), glm::vec2(0.25f, 0.25f)); + pause_button_resume.SetHoverTexture(render_engine::loader::LoadTexture("res/menu_item_resume1_hover.png")); + pause_button_resume.SetClickedTexture(render_engine::loader::LoadTexture("res/menu_item_resume1_click.png")); std::function resume_fun = [this]() { std::cout << "I got clicked on the resume button!" << std::endl; @@ -211,7 +211,9 @@ namespace scene case scene::Game_State::PAUSED: render(); + update_buttons(window); render_pause_menu(); + break; case scene::Game_State::RUNNING: @@ -235,6 +237,27 @@ namespace scene return return_value; } + gui::Button* In_Game_Scene::ConvertGuiTextureToButton(gui::GuiTexture* texture) { + gui::Button* button; + if (texture != NULL) + { + + if (texture->GetType() == gui::GuiType::BUTTON) { + + button = (gui::Button*)texture; + return button; + } + else { + button = nullptr; + return button; + } + } + else { + button = nullptr; + return button; + } + } + /** * renders the game models */ @@ -264,6 +287,15 @@ namespace scene DrawScore(score); } + void scene::In_Game_Scene::update_buttons(GLFWwindow* window) + { + for (gui::GuiTexture* button : pause_guis) { + gui::Button* new_button = ConvertGuiTextureToButton(button); + if (new_button != NULL) + new_button->Update(window); + } + } + //updates certain variables void scene::In_Game_Scene::update(GLFWwindow* window) { diff --git a/src/scenes/in_Game_Scene.h b/src/scenes/in_Game_Scene.h index 7cae8d7..6f80eab 100644 --- a/src/scenes/in_Game_Scene.h +++ b/src/scenes/in_Game_Scene.h @@ -114,6 +114,10 @@ namespace scene * */ void LoadChunk(int model_pos); + + void update_buttons(GLFWwindow* window); + + gui::Button* ConvertGuiTextureToButton(gui::GuiTexture* texture); public: In_Game_Scene(int *score_ptr);