mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 07:05:39 +00:00
More work on system carousel, added title + background image.
This commit is contained in:
parent
fcb8623b3d
commit
0266b2e802
|
@ -309,7 +309,9 @@ Reference
|
||||||
|
|
||||||
#### system
|
#### system
|
||||||
* `image name="header"` - PATH
|
* `image name="header"` - PATH
|
||||||
- A header (logo) image, to be displayed in the system carousel.
|
- A header (logo) image, to be displayed in the system logo carousel.
|
||||||
|
* `image name="systemImage"` - PATH
|
||||||
|
- A background image displayed behind the carousel. Intended to be a picture of the console on a transparent background (an image with no obvious border).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,14 @@ void SystemView::populate()
|
||||||
|
|
||||||
for(auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
|
for(auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
|
||||||
{
|
{
|
||||||
|
const std::shared_ptr<ThemeData>& theme = (*it)->getTheme();
|
||||||
|
|
||||||
Entry e;
|
Entry e;
|
||||||
e.name = (*it)->getName();
|
e.name = (*it)->getName();
|
||||||
e.object = *it;
|
e.object = *it;
|
||||||
|
|
||||||
if((*it)->getTheme()->getElement("system", "header", "image"))
|
// make logo
|
||||||
|
if(theme->getElement("system", "header", "image"))
|
||||||
{
|
{
|
||||||
ImageComponent* logo = new ImageComponent(mWindow);
|
ImageComponent* logo = new ImageComponent(mWindow);
|
||||||
logo->setMaxSize(logoSize());
|
logo->setMaxSize(logoSize());
|
||||||
|
@ -46,7 +49,23 @@ void SystemView::populate()
|
||||||
e.data.logo = std::shared_ptr<GuiComponent>(text);
|
e.data.logo = std::shared_ptr<GuiComponent>(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.data.title = nullptr;
|
// make title
|
||||||
|
e.data.title = std::shared_ptr<TextComponent>(new TextComponent(mWindow));
|
||||||
|
e.data.title->setFont(Font::get(FONT_SIZE_LARGE));
|
||||||
|
e.data.title->setSize(mSize.x(), (float)FONT_SIZE_LARGE);
|
||||||
|
e.data.title->setText((*it)->getFullName());
|
||||||
|
e.data.title->setCentered(true);
|
||||||
|
|
||||||
|
// make background
|
||||||
|
if(theme->getElement("system", "systemImage", "image"))
|
||||||
|
{
|
||||||
|
e.data.background = std::shared_ptr<ImageComponent>(new ImageComponent(mWindow));
|
||||||
|
e.data.background->applyTheme(theme, "system", "systemImage", ThemeFlags::PATH);
|
||||||
|
e.data.background->setOpacity((unsigned char)(255 * 0.75f)); // make it 75% opaque
|
||||||
|
e.data.background->setPosition((mSize.x() - e.data.background->getSize().x()) / 2, (mSize.y() - e.data.background->getSize().y()) / 2); // center it (it's drawn at (0, 0))
|
||||||
|
}else{
|
||||||
|
e.data.background = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
this->add(e);
|
this->add(e);
|
||||||
}
|
}
|
||||||
|
@ -95,10 +114,8 @@ void SystemView::onCursorChanged(const CursorState& state)
|
||||||
{
|
{
|
||||||
float startPos = mCamOffset;
|
float startPos = mCamOffset;
|
||||||
|
|
||||||
const float logoSizeX = logoSize().x() + LOGO_PADDING;
|
float posMax = (float)mEntries.size();
|
||||||
|
float target = (float)mCursor;
|
||||||
float posMax = logoSizeX * mEntries.size();
|
|
||||||
float target = mCursor * logoSizeX;
|
|
||||||
|
|
||||||
// what's the shortest way to get to our target?
|
// what's the shortest way to get to our target?
|
||||||
// it's one of these...
|
// it's one of these...
|
||||||
|
@ -121,7 +138,7 @@ void SystemView::onCursorChanged(const CursorState& state)
|
||||||
if(f >= posMax)
|
if(f >= posMax)
|
||||||
f -= posMax;
|
f -= posMax;
|
||||||
this->mCamOffset = f;
|
this->mCamOffset = f;
|
||||||
}, 400);
|
}, 500);
|
||||||
|
|
||||||
setAnimation(anim);
|
setAnimation(anim);
|
||||||
}
|
}
|
||||||
|
@ -131,30 +148,40 @@ void SystemView::render(const Eigen::Affine3f& parentTrans)
|
||||||
if(size() == 0)
|
if(size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const float logoSizeX = logoSize().x() + LOGO_PADDING;
|
|
||||||
|
|
||||||
Eigen::Affine3f trans = getTransform() * parentTrans;
|
Eigen::Affine3f trans = getTransform() * parentTrans;
|
||||||
|
|
||||||
// draw background image
|
// draw the list elements (titles, backgrounds, logos)
|
||||||
|
|
||||||
// draw system's stats
|
|
||||||
|
|
||||||
// now for the list elements (logos)
|
|
||||||
Eigen::Affine3f logoTrans = trans;
|
Eigen::Affine3f logoTrans = trans;
|
||||||
|
|
||||||
|
const float logoSizeX = logoSize().x() + LOGO_PADDING;
|
||||||
|
|
||||||
int logoCount = (int)(mSize.x() / logoSizeX) + 2; // how many logos we need to draw
|
int logoCount = (int)(mSize.x() / logoSizeX) + 2; // how many logos we need to draw
|
||||||
int center = (int)(mCamOffset / logoSizeX + 0.5f);
|
int center = (int)(mCamOffset);
|
||||||
|
|
||||||
float xOff = (mSize.x() - logoSize().x())/2 - mCamOffset;
|
// draw titles + background images (same transforms)
|
||||||
float yOff = (mSize.y() - logoSize().y())/2;
|
Eigen::Affine3f titleTrans = trans;
|
||||||
|
for(int i = center - 1; i < center + 2; i++)
|
||||||
// this fixes the case where i != mCursor when wrapping around the end back to zero
|
|
||||||
while(center >= (int)mEntries.size())
|
|
||||||
{
|
{
|
||||||
center -= mEntries.size();
|
int index = i;
|
||||||
xOff += logoSizeX * mEntries.size();
|
while(index < 0)
|
||||||
|
index += mEntries.size();
|
||||||
|
while(index >= (int)mEntries.size())
|
||||||
|
index -= mEntries.size();
|
||||||
|
|
||||||
|
titleTrans.translation() = trans.translation() + Eigen::Vector3f((i - mCamOffset) * mSize.x(), 0, 0);
|
||||||
|
|
||||||
|
// background image (might not exist)
|
||||||
|
if(mEntries.at(index).data.background)
|
||||||
|
mEntries.at(index).data.background->render(titleTrans);
|
||||||
|
|
||||||
|
// title (always exists)
|
||||||
|
mEntries.at(index).data.title->render(titleTrans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// draw logos
|
||||||
|
float xOff = (mSize.x() - logoSize().x())/2 - (mCamOffset * logoSizeX);
|
||||||
|
float yOff = (mSize.y() - logoSize().y())/2;
|
||||||
|
|
||||||
for(int i = center - logoCount/2; i < center + logoCount/2 + logoCount%2; i++)
|
for(int i = center - logoCount/2; i < center + logoCount/2 + logoCount%2; i++)
|
||||||
{
|
{
|
||||||
int index = i;
|
int index = i;
|
||||||
|
@ -168,7 +195,7 @@ void SystemView::render(const Eigen::Affine3f& parentTrans)
|
||||||
std::shared_ptr<GuiComponent> comp = mEntries.at(index).data.logo;
|
std::shared_ptr<GuiComponent> comp = mEntries.at(index).data.logo;
|
||||||
if(comp)
|
if(comp)
|
||||||
{
|
{
|
||||||
if(i == mCursor) //scale our selection up
|
if(index == mCursor) //scale our selection up
|
||||||
{
|
{
|
||||||
// fix the centering because we go by left corner and not center (bleh)
|
// fix the centering because we go by left corner and not center (bleh)
|
||||||
logoTrans.translation() -= Eigen::Vector3f((comp->getSize().x() / 2) * (SELECTED_SCALE - 1), (comp->getSize().y() / 2) * (SELECTED_SCALE - 1), 0);
|
logoTrans.translation() -= Eigen::Vector3f((comp->getSize().x() / 2) * (SELECTED_SCALE - 1), (comp->getSize().y() / 2) * (SELECTED_SCALE - 1), 0);
|
||||||
|
|
|
@ -11,8 +11,9 @@ class SystemData;
|
||||||
|
|
||||||
struct SystemViewData
|
struct SystemViewData
|
||||||
{
|
{
|
||||||
std::shared_ptr<TextCache> title;
|
std::shared_ptr<TextComponent> title;
|
||||||
std::shared_ptr<GuiComponent> logo;
|
std::shared_ptr<GuiComponent> logo;
|
||||||
|
std::shared_ptr<ImageComponent> background;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SystemView : public IList<SystemViewData, SystemData*>
|
class SystemView : public IList<SystemViewData, SystemData*>
|
||||||
|
@ -36,5 +37,6 @@ private:
|
||||||
|
|
||||||
void populate();
|
void populate();
|
||||||
|
|
||||||
|
// unit is list index
|
||||||
float mCamOffset;
|
float mCamOffset;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue