mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Removed deprecated AsyncReqComponent
This commit is contained in:
parent
90735d44e3
commit
7f39afe3da
|
@ -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
|
||||
|
||||
|
|
|
@ -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<HttpReq> req, std::function<void(std::shared_ptr<HttpReq>)> onSuccess, std::function<void()> 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<HelpPrompt> AsyncReqComponent::getHelpPrompts()
|
||||
{
|
||||
std::vector<HelpPrompt> prompts;
|
||||
prompts.push_back(HelpPrompt("b", "cancel"));
|
||||
return prompts;
|
||||
}
|
|
@ -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> httpreq = std::make_shared<HttpReq>("cdn.garcya.us", "/wp-content/uploads/2010/04/TD250.jpg");
|
||||
AsyncReqComponent* req = new AsyncReqComponent(mWindow, httpreq,
|
||||
[] (std::shared_ptr<HttpReq> 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<HttpReq> req, std::function<void(std::shared_ptr<HttpReq>)> onSuccess, std::function<void()> onCancel = nullptr);
|
||||
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
void update(int deltaTime) override;
|
||||
void render(const Transform4x4f& parentTrans) override;
|
||||
|
||||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||
private:
|
||||
std::function<void(std::shared_ptr<HttpReq>)> mSuccessFunc;
|
||||
std::function<void()> mCancelFunc;
|
||||
|
||||
unsigned int mTime;
|
||||
std::shared_ptr<HttpReq> mRequest;
|
||||
};
|
||||
|
||||
#endif // ES_APP_COMPONENTS_ASYNC_REQ_COMPONENT_H
|
Loading…
Reference in a new issue