mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Added busy animation + "WORKING..." to the ScraperSearchComponent.
This commit is contained in:
parent
4db210f770
commit
6d4288f245
|
@ -12,10 +12,8 @@ AnimationFrame BUSY_ANIMATION_FRAMES[] = {
|
||||||
const AnimationDef BUSY_ANIMATION_DEF = { BUSY_ANIMATION_FRAMES, 4, true };
|
const AnimationDef BUSY_ANIMATION_DEF = { BUSY_ANIMATION_FRAMES, 4, true };
|
||||||
|
|
||||||
|
|
||||||
AnimatedImageComponent::AnimatedImageComponent(Window* window, const AnimationDef* def) : GuiComponent(window), mEnabled(false)
|
AnimatedImageComponent::AnimatedImageComponent(Window* window) : GuiComponent(window), mEnabled(false)
|
||||||
{
|
{
|
||||||
if(def)
|
|
||||||
load(def);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimatedImageComponent::load(const AnimationDef* def)
|
void AnimatedImageComponent::load(const AnimationDef* def)
|
||||||
|
@ -46,6 +44,12 @@ void AnimatedImageComponent::load(const AnimationDef* def)
|
||||||
mEnabled = true;
|
mEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AnimatedImageComponent::reset()
|
||||||
|
{
|
||||||
|
mCurrentFrame = 0;
|
||||||
|
mFrameAccumulator = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void AnimatedImageComponent::onSizeChanged()
|
void AnimatedImageComponent::onSizeChanged()
|
||||||
{
|
{
|
||||||
for(auto it = mFrames.begin(); it != mFrames.end(); it++)
|
for(auto it = mFrames.begin(); it != mFrames.end(); it++)
|
||||||
|
|
|
@ -18,10 +18,12 @@ struct AnimationDef
|
||||||
class AnimatedImageComponent : public GuiComponent
|
class AnimatedImageComponent : public GuiComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AnimatedImageComponent(Window* window, const AnimationDef* def = NULL);
|
AnimatedImageComponent(Window* window);
|
||||||
|
|
||||||
void load(const AnimationDef* def); // no reference to def is kept after loading is complete
|
void load(const AnimationDef* def); // no reference to def is kept after loading is complete
|
||||||
|
|
||||||
|
void reset(); // set to frame 0
|
||||||
|
|
||||||
void update(int deltaTime) override;
|
void update(int deltaTime) override;
|
||||||
void render(const Eigen::Affine3f& trans) override;
|
void render(const Eigen::Affine3f& trans) override;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "ImageComponent.h"
|
#include "ImageComponent.h"
|
||||||
#include "RatingComponent.h"
|
#include "RatingComponent.h"
|
||||||
#include "DateTimeComponent.h"
|
#include "DateTimeComponent.h"
|
||||||
|
#include "AnimatedImageComponent.h"
|
||||||
#include "ComponentList.h"
|
#include "ComponentList.h"
|
||||||
#include "../HttpReq.h"
|
#include "../HttpReq.h"
|
||||||
#include "../Settings.h"
|
#include "../Settings.h"
|
||||||
|
@ -14,7 +15,7 @@
|
||||||
#include "../guis/GuiTextEditPopup.h"
|
#include "../guis/GuiTextEditPopup.h"
|
||||||
|
|
||||||
ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type) : GuiComponent(window),
|
ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type) : GuiComponent(window),
|
||||||
mGrid(window, Eigen::Vector2i(4, 3)),
|
mGrid(window, Eigen::Vector2i(4, 3)), mBusyGrid(window, Eigen::Vector2i(3, 1)),
|
||||||
mSearchType(type)
|
mSearchType(type)
|
||||||
{
|
{
|
||||||
addChild(&mGrid);
|
addChild(&mGrid);
|
||||||
|
@ -73,6 +74,14 @@ ScraperSearchComponent::ScraperSearchComponent(Window* window, SearchType type)
|
||||||
mResultList = std::make_shared<ComponentList>(mWindow);
|
mResultList = std::make_shared<ComponentList>(mWindow);
|
||||||
mResultList->setCursorChangedCallback([this](CursorState state) { if(state == CURSOR_STOPPED) updateInfoPane(); });
|
mResultList->setCursorChangedCallback([this](CursorState state) { if(state == CURSOR_STOPPED) updateInfoPane(); });
|
||||||
|
|
||||||
|
mBusyAnimation = std::make_shared<AnimatedImageComponent>(mWindow);
|
||||||
|
mBusyAnimation->load(&BUSY_ANIMATION_DEF);
|
||||||
|
mBusyText = std::make_shared<TextComponent>(mWindow, "WORKING...", Font::get(FONT_SIZE_LARGE), 0x777777FF);
|
||||||
|
|
||||||
|
// col 0 = animation, col 1 = spacer, col 2 = text
|
||||||
|
mBusyGrid.setEntry(mBusyAnimation, Vector2i(0, 0), false, true);
|
||||||
|
mBusyGrid.setEntry(mBusyText, Vector2i(2, 0), false, true);
|
||||||
|
|
||||||
updateViewStyle();
|
updateViewStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +152,20 @@ void ScraperSearchComponent::onSizeChanged()
|
||||||
mDescContainer->setSize(mGrid.getColWidth(1)*boxartCellScale + mGrid.getColWidth(2), mResultDesc->getFont()->getHeight() * 3);
|
mDescContainer->setSize(mGrid.getColWidth(1)*boxartCellScale + mGrid.getColWidth(2), mResultDesc->getFont()->getHeight() * 3);
|
||||||
mResultDesc->setSize(mDescContainer->getSize().x(), 0); // make desc text wrap at edge of container
|
mResultDesc->setSize(mDescContainer->getSize().x(), 0); // make desc text wrap at edge of container
|
||||||
|
|
||||||
|
const float busyGridHeight = mBusyText->getSize().y();
|
||||||
|
const float busyGridWidth = (busyGridHeight + mBusyText->getSize().x()) * 1.03f;
|
||||||
|
if(busyGridWidth > 0 && busyGridHeight > 0)
|
||||||
|
{
|
||||||
|
mBusyGrid.setSize(busyGridWidth, busyGridHeight);
|
||||||
|
|
||||||
|
mBusyGrid.setColWidthPerc(0, (busyGridHeight) / busyGridWidth);
|
||||||
|
mBusyGrid.setColWidthPerc(1, 0.025f);
|
||||||
|
|
||||||
|
// in the far right
|
||||||
|
mBusyGrid.setPosition(mGrid.getColWidth(0) + mGrid.getColWidth(1) + mGrid.getColWidth(2) + (mGrid.getColWidth(3) - busyGridWidth)/2,
|
||||||
|
mGrid.getRowHeight(0) + mGrid.getRowHeight(1) + (mGrid.getRowHeight(2) - busyGridHeight) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
mGrid.onSizeChanged();
|
mGrid.onSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,6 +353,8 @@ void ScraperSearchComponent::render(const Eigen::Affine3f& parentTrans)
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
Renderer::drawRect((int)mResultList->getPosition().x(), (int)mResultList->getPosition().y(),
|
Renderer::drawRect((int)mResultList->getPosition().x(), (int)mResultList->getPosition().y(),
|
||||||
(int)mResultList->getSize().x(), (int)mResultList->getSize().y(), 0x00000011);
|
(int)mResultList->getSize().x(), (int)mResultList->getSize().y(), 0x00000011);
|
||||||
|
|
||||||
|
mBusyGrid.render(trans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,6 +376,11 @@ void ScraperSearchComponent::update(int deltaTime)
|
||||||
{
|
{
|
||||||
GuiComponent::update(deltaTime);
|
GuiComponent::update(deltaTime);
|
||||||
|
|
||||||
|
if(mBlockAccept)
|
||||||
|
{
|
||||||
|
mBusyAnimation->update(deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
if(mThumbnailReq && mThumbnailReq->status() != HttpReq::REQ_IN_PROGRESS)
|
if(mThumbnailReq && mThumbnailReq->status() != HttpReq::REQ_IN_PROGRESS)
|
||||||
{
|
{
|
||||||
updateThumbnail();
|
updateThumbnail();
|
||||||
|
|
|
@ -14,7 +14,7 @@ class TextComponent;
|
||||||
class DateTimeComponent;
|
class DateTimeComponent;
|
||||||
class ScrollableContainer;
|
class ScrollableContainer;
|
||||||
class HttpReq;
|
class HttpReq;
|
||||||
|
class AnimatedImageComponent;
|
||||||
|
|
||||||
class ScraperSearchComponent : public GuiComponent
|
class ScraperSearchComponent : public GuiComponent
|
||||||
{
|
{
|
||||||
|
@ -97,4 +97,8 @@ private:
|
||||||
std::unique_ptr<MDResolveHandle> mMDResolveHandle;
|
std::unique_ptr<MDResolveHandle> mMDResolveHandle;
|
||||||
std::vector<ScraperSearchResult> mScraperResults;
|
std::vector<ScraperSearchResult> mScraperResults;
|
||||||
std::unique_ptr<HttpReq> mThumbnailReq;
|
std::unique_ptr<HttpReq> mThumbnailReq;
|
||||||
|
|
||||||
|
ComponentGrid mBusyGrid;
|
||||||
|
std::shared_ptr<AnimatedImageComponent> mBusyAnimation;
|
||||||
|
std::shared_ptr<TextComponent> mBusyText;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue