diff --git a/CMakeLists.txt b/CMakeLists.txt index 93b87a664..ab3020b15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -177,6 +177,7 @@ set(ES_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiDetectDevice.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiFastSelect.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiMetaDataEd.h + ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiMsgBoxOk.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiGameList.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiGameScraper.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiInputConfig.h @@ -233,6 +234,7 @@ set(ES_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiDetectDevice.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiFastSelect.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiMetaDataEd.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiMsgBoxOk.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiGameList.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiGameScraper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/GuiInputConfig.cpp diff --git a/src/components/GuiMsgBoxOk.cpp b/src/components/GuiMsgBoxOk.cpp new file mode 100644 index 000000000..049890021 --- /dev/null +++ b/src/components/GuiMsgBoxOk.cpp @@ -0,0 +1,46 @@ +#include "GuiMsgBoxOk.h" +#include "../Renderer.h" + +GuiMsgBoxOk::GuiMsgBoxOk(Window* window, const std::string& text, std::function callback) : GuiComponent(window), + mCallback(callback), + mText(window), + mOkText(window) +{ + mText.setCentered(true); + mText.setColor(0x00BB00FF); + mText.setSize((float)Renderer::getScreenWidth(), 0); + mText.setText(text); + + mOkText.setCentered(true); + mOkText.setColor(0x0044BBFF); + mOkText.setFont(Font::get(FONT_SIZE_SMALL)); + mOkText.setSize((float)Renderer::getScreenWidth(), 0); + mOkText.setText("[A]"); + + mText.setPosition(0, (Renderer::getScreenHeight() - mText.getSize().y() - mOkText.getSize().y()) / 2); + mOkText.setPosition(0, mText.getPosition().y() + mText.getSize().y()); +} + +bool GuiMsgBoxOk::input(InputConfig* config, Input input) +{ + if(input.value != 0 && + (config->isMappedTo("a", input) || config->isMappedTo("b", input))) + { + if(mCallback) + mCallback(); + + delete this; + return true; + } + + return false; +} + +void GuiMsgBoxOk::render(const Eigen::Affine3f& parentTrans) +{ + float height = mText.getSize().y() + mOkText.getSize().y(); + Renderer::setMatrix(parentTrans); + Renderer::drawRect(0, (int)((Renderer::getScreenHeight() - height) / 2), Renderer::getScreenWidth(), (int)height, 0x111111FF); + mText.render(parentTrans); + mOkText.render(parentTrans); +} diff --git a/src/components/GuiMsgBoxOk.h b/src/components/GuiMsgBoxOk.h new file mode 100644 index 000000000..4898c4e5d --- /dev/null +++ b/src/components/GuiMsgBoxOk.h @@ -0,0 +1,20 @@ +#pragma once + +#include "../GuiComponent.h" +#include "TextComponent.h" +#include + +class GuiMsgBoxOk : public GuiComponent +{ +public: + GuiMsgBoxOk(Window* window, const std::string& msg, std::function okCallback = nullptr); + + bool input(InputConfig* config, Input input) override; + void render(const Eigen::Affine3f& parentTrans) override; + +private: + std::function mCallback; + + TextComponent mText; + TextComponent mOkText; +}; diff --git a/src/components/GuiScraperStart.cpp b/src/components/GuiScraperStart.cpp index ecb789636..6dd3e9bef 100644 --- a/src/components/GuiScraperStart.cpp +++ b/src/components/GuiScraperStart.cpp @@ -1,4 +1,5 @@ #include "GuiScraperStart.h" +#include "GuiMsgBoxOk.h" GuiScraperStart::GuiScraperStart(Window* window) : GuiComponent(window), mBox(window, ":/frame.png"), @@ -55,6 +56,8 @@ GuiScraperStart::GuiScraperStart(Window* window) : GuiComponent(window), void GuiScraperStart::start() { std::queue searches = getSearches(mSystemsOpt.getSelectedObjects(), mFiltersOpt.getSelectedObjects()[0]); + + mWindow->pushGui(new GuiMsgBoxOk(mWindow, "this isn't implemented yet")); } std::queue GuiScraperStart::getSearches(std::vector systems, GameFilterFunc selector)