diff --git a/es-app/CMakeLists.txt b/es-app/CMakeLists.txt index 962abd29b..e83abd0a5 100644 --- a/es-app/CMakeLists.txt +++ b/es-app/CMakeLists.txt @@ -15,7 +15,6 @@ set(ES_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/CollectionSystemManager.h # GuiComponents - ${CMAKE_CURRENT_SOURCE_DIR}/src/components/AsyncReqComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/RatingComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ScraperSearchComponent.h ${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextListComponent.h @@ -74,7 +73,6 @@ set(ES_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/CollectionSystemManager.cpp # GuiComponents - ${CMAKE_CURRENT_SOURCE_DIR}/src/components/AsyncReqComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/RatingComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/components/ScraperSearchComponent.cpp diff --git a/es-app/src/components/AsyncReqComponent.cpp b/es-app/src/components/AsyncReqComponent.cpp deleted file mode 100644 index ed3d7fc7c..000000000 --- a/es-app/src/components/AsyncReqComponent.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// -// AsyncReqComponent.cpp -// -// Deprecated, not in use any longer? -// - -#include "components/AsyncReqComponent.h" - -#include "renderers/Renderer.h" -#include "HttpReq.h" - -AsyncReqComponent::AsyncReqComponent(Window* window, std::shared_ptr req, std::function)> onSuccess, std::function onCancel) - : GuiComponent(window), - mSuccessFunc(onSuccess), mCancelFunc(onCancel), mTime(0), mRequest(req) -{ - -} - -bool AsyncReqComponent::input(InputConfig* config, Input input) -{ - if(input.value != 0 && config->isMappedTo("b", input)) - { - if(mCancelFunc) - mCancelFunc(); - - delete this; - } - - return true; -} - -void AsyncReqComponent::update(int deltaTime) -{ - if(mRequest->status() != HttpReq::REQ_IN_PROGRESS) - { - mSuccessFunc(mRequest); - delete this; - return; - } - - mTime += deltaTime; -} - -void AsyncReqComponent::render(const Transform4x4f& /*parentTrans*/) -{ - Transform4x4f trans = Transform4x4f::Identity(); - trans = trans.translate(Vector3f(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f, 0)); - Renderer::setMatrix(trans); - - Vector3f point(Math::cosf(mTime * 0.01f) * 12, Math::sinf(mTime * 0.01f) * 12, 0); - Renderer::drawRect(point.x(), point.y(), 8.0f, 8.0f, 0x0000FFFF, 0x0000FFFF); -} - -std::vector AsyncReqComponent::getHelpPrompts() -{ - std::vector prompts; - prompts.push_back(HelpPrompt("b", "cancel")); - return prompts; -} diff --git a/es-app/src/components/AsyncReqComponent.h b/es-app/src/components/AsyncReqComponent.h deleted file mode 100644 index 0ca934fdb..000000000 --- a/es-app/src/components/AsyncReqComponent.h +++ /dev/null @@ -1,54 +0,0 @@ -// -// AsyncReqComponent.h -// -// Deprecated, not in use any longer? -// - -#pragma once -#ifndef ES_APP_COMPONENTS_ASYNC_REQ_COMPONENT_H -#define ES_APP_COMPONENTS_ASYNC_REQ_COMPONENT_H - -#include "GuiComponent.h" - -class HttpReq; - -/* - Used to asynchronously run an HTTP request. - Displays a simple animation on the UI to show the application hasn't frozen. Can be canceled by the user pressing B. - - Usage example: - std::shared_ptr httpreq = std::make_shared("cdn.garcya.us", "/wp-content/uploads/2010/04/TD250.jpg"); - AsyncReqComponent* req = new AsyncReqComponent(mWindow, httpreq, - [] (std::shared_ptr r) - { - LOG(LogInfo) << "Request completed"; - LOG(LogInfo) << " error, if any: " << r->getErrorMsg(); - }, [] () - { - LOG(LogInfo) << "Request canceled"; - }); - - mWindow->pushGui(req); - //we can forget about req, since it will always delete itself -*/ - -class AsyncReqComponent : public GuiComponent -{ -public: - - AsyncReqComponent(Window* window, std::shared_ptr req, std::function)> onSuccess, std::function onCancel = nullptr); - - bool input(InputConfig* config, Input input) override; - void update(int deltaTime) override; - void render(const Transform4x4f& parentTrans) override; - - virtual std::vector getHelpPrompts() override; -private: - std::function)> mSuccessFunc; - std::function mCancelFunc; - - unsigned int mTime; - std::shared_ptr mRequest; -}; - -#endif // ES_APP_COMPONENTS_ASYNC_REQ_COMPONENT_H