mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Fixed TextListComponent scrolling so text always clips within margins.
Made all gamelists get recreated when GuiScraperMulti closes since there isn't a way to catch FileData changes efficiently yet.
This commit is contained in:
parent
e2458f5d92
commit
b2193c3bf5
|
@ -130,12 +130,9 @@ void TextListComponent<T>::render(const Eigen::Affine3f& parentTrans)
|
||||||
std::shared_ptr<Font>& font = mFont;
|
std::shared_ptr<Font>& font = mFont;
|
||||||
|
|
||||||
if(size() == 0)
|
if(size() == 0)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
const int cutoff = 0;
|
const float entrySize = font->getHeight() + 5;
|
||||||
const int entrySize = (int)font->getHeight() + 5;
|
|
||||||
|
|
||||||
int startEntry = 0;
|
int startEntry = 0;
|
||||||
|
|
||||||
|
@ -144,32 +141,34 @@ void TextListComponent<T>::render(const Eigen::Affine3f& parentTrans)
|
||||||
|
|
||||||
if(size() >= screenCount)
|
if(size() >= screenCount)
|
||||||
{
|
{
|
||||||
startEntry = mCursor - (int)(screenCount * 0.5);
|
startEntry = mCursor - screenCount/2;
|
||||||
if(startEntry < 0)
|
if(startEntry < 0)
|
||||||
startEntry = 0;
|
startEntry = 0;
|
||||||
if(startEntry >= size() - screenCount)
|
if(startEntry >= size() - screenCount)
|
||||||
startEntry = size() - screenCount;
|
startEntry = size() - screenCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
float y = (float)cutoff;
|
float y = 0;
|
||||||
|
|
||||||
int listCutoff = startEntry + screenCount;
|
int listCutoff = startEntry + screenCount;
|
||||||
if(listCutoff > size())
|
if(listCutoff > size())
|
||||||
listCutoff = size();
|
listCutoff = size();
|
||||||
|
|
||||||
|
// draw selector bar
|
||||||
|
if(startEntry < listCutoff)
|
||||||
|
{
|
||||||
|
Renderer::setMatrix(trans);
|
||||||
|
Renderer::drawRect(0.f, (mCursor - startEntry)*entrySize, mSize.x(), font->getHeight(), mSelectorColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// clip to inside margins
|
||||||
Eigen::Vector3f dim(mSize.x(), mSize.y(), 0);
|
Eigen::Vector3f dim(mSize.x(), mSize.y(), 0);
|
||||||
dim = trans * dim - trans.translation();
|
dim = trans * dim - trans.translation();
|
||||||
Renderer::pushClipRect(Eigen::Vector2i((int)trans.translation().x(), (int)trans.translation().y()), Eigen::Vector2i((int)dim.x(), (int)dim.y()));
|
Renderer::pushClipRect(Eigen::Vector2i((int)(trans.translation().x() + mHorizontalMargin), (int)trans.translation().y()),
|
||||||
|
Eigen::Vector2i((int)(dim.x() - mHorizontalMargin*2), (int)dim.y()));
|
||||||
|
|
||||||
for(int i = startEntry; i < listCutoff; i++)
|
for(int i = startEntry; i < listCutoff; i++)
|
||||||
{
|
{
|
||||||
//draw selector bar
|
|
||||||
if(mCursor == i)
|
|
||||||
{
|
|
||||||
Renderer::setMatrix(trans);
|
|
||||||
Renderer::drawRect(0, (int)y, (int)mSize.x(), (int)font->getHeight(), mSelectorColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
typename IList<TextListData, T>::Entry& entry = mEntries.at((unsigned int)i);
|
typename IList<TextListData, T>::Entry& entry = mEntries.at((unsigned int)i);
|
||||||
|
|
||||||
unsigned int color;
|
unsigned int color;
|
||||||
|
@ -276,6 +275,7 @@ void TextListComponent<T>::update(int deltaTime)
|
||||||
Eigen::Vector2f textSize = mFont->sizeText(text);
|
Eigen::Vector2f textSize = mFont->sizeText(text);
|
||||||
|
|
||||||
//it's long enough to marquee
|
//it's long enough to marquee
|
||||||
|
mMarqueeTime += deltaTime;
|
||||||
if(textSize.x() - mMarqueeOffset > mSize.x() - 12 - (mAlignment != ALIGN_CENTER ? mHorizontalMargin : 0))
|
if(textSize.x() - mMarqueeOffset > mSize.x() - 12 - (mAlignment != ALIGN_CENTER ? mHorizontalMargin : 0))
|
||||||
{
|
{
|
||||||
mMarqueeTime += deltaTime;
|
mMarqueeTime += deltaTime;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "GuiScraperMulti.h"
|
#include "GuiScraperMulti.h"
|
||||||
#include "../Renderer.h"
|
#include "../Renderer.h"
|
||||||
#include "../Log.h"
|
#include "../Log.h"
|
||||||
|
#include "../views/ViewController.h"
|
||||||
|
|
||||||
#include "../components/TextComponent.h"
|
#include "../components/TextComponent.h"
|
||||||
#include "../components/ButtonComponent.h"
|
#include "../components/ButtonComponent.h"
|
||||||
|
@ -67,6 +68,13 @@ GuiScraperMulti::GuiScraperMulti(Window* window, const std::queue<ScraperSearchP
|
||||||
doNextSearch();
|
doNextSearch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GuiScraperMulti::~GuiScraperMulti()
|
||||||
|
{
|
||||||
|
// view type probably changed (basic -> detailed)
|
||||||
|
for(auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
|
||||||
|
mWindow->getViewController()->reloadGameListView(*it, false);
|
||||||
|
}
|
||||||
|
|
||||||
void GuiScraperMulti::onSizeChanged()
|
void GuiScraperMulti::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32, -32));
|
mBackground.fitTo(mSize, Vector3f::Zero(), Vector2f(-32, -32));
|
||||||
|
|
|
@ -14,6 +14,7 @@ class GuiScraperMulti : public GuiComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GuiScraperMulti(Window* window, const std::queue<ScraperSearchParams>& searches, bool approveResults);
|
GuiScraperMulti(Window* window, const std::queue<ScraperSearchParams>& searches, bool approveResults);
|
||||||
|
virtual ~GuiScraperMulti();
|
||||||
|
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
std::vector<HelpPrompt> getHelpPrompts() override;
|
std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
|
|
|
@ -18,6 +18,7 @@ public:
|
||||||
// If a basic view detected a metadata change, it can request to recreate
|
// If a basic view detected a metadata change, it can request to recreate
|
||||||
// the current gamelist view (as it may change to be detailed).
|
// the current gamelist view (as it may change to be detailed).
|
||||||
void reloadGameListView(IGameListView* gamelist, bool reloadTheme = false);
|
void reloadGameListView(IGameListView* gamelist, bool reloadTheme = false);
|
||||||
|
inline void reloadGameListView(SystemData* system, bool reloadTheme = false) { reloadGameListView(getGameListView(system).get(), reloadTheme); }
|
||||||
void reloadAll(); // Reload everything with a theme. Used when the "ThemeSet" setting changes.
|
void reloadAll(); // Reload everything with a theme. Used when the "ThemeSet" setting changes.
|
||||||
|
|
||||||
// Navigation.
|
// Navigation.
|
||||||
|
|
Loading…
Reference in a new issue