mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-27 00:25:38 +00:00
Compile on Linux/gcc again
This better not have broken VS
This commit is contained in:
parent
816247ac20
commit
2886e8e8d8
|
@ -6,6 +6,7 @@
|
||||||
#include "../GuiComponent.h"
|
#include "../GuiComponent.h"
|
||||||
#include "ImageComponent.h"
|
#include "ImageComponent.h"
|
||||||
#include "../resources/Font.h"
|
#include "../resources/Font.h"
|
||||||
|
#include "../Renderer.h"
|
||||||
|
|
||||||
enum CursorState
|
enum CursorState
|
||||||
{
|
{
|
||||||
|
@ -148,9 +149,9 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void remove(typename std::vector<Entry>::iterator& it)
|
void remove(typename std::vector<Entry>::iterator& it)
|
||||||
{
|
{
|
||||||
if(getCursorIndex() > 0 && it - mEntries.begin() <= getCursorIndex())
|
if(mCursor > 0 && it - mEntries.begin() <= mCursor)
|
||||||
{
|
{
|
||||||
setCursorIndex(mCursor - 1);
|
mCursor--;
|
||||||
onCursorChanged(CURSOR_STOPPED);
|
onCursorChanged(CURSOR_STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,22 @@ struct ImageGridData
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class ImageGridComponent : public IList<ImageGridData, T>
|
class ImageGridComponent : public IList<ImageGridData, T>
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
using IList<ImageGridData, T>::mEntries;
|
||||||
|
using IList<ImageGridData, T>::listUpdate;
|
||||||
|
using IList<ImageGridData, T>::listInput;
|
||||||
|
using IList<ImageGridData, T>::listRenderTitleOverlay;
|
||||||
|
using IList<ImageGridData, T>::getTransform;
|
||||||
|
using IList<ImageGridData, T>::mSize;
|
||||||
|
using IList<ImageGridData, T>::mCursor;
|
||||||
|
using IList<ImageGridData, T>::Entry;
|
||||||
|
using IList<ImageGridData, T>::mWindow;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using IList<ImageGridData, T>::size;
|
||||||
|
using IList<ImageGridData, T>::isScrolling;
|
||||||
|
using IList<ImageGridData, T>::stopScrolling;
|
||||||
|
|
||||||
ImageGridComponent(Window* window);
|
ImageGridComponent(Window* window);
|
||||||
|
|
||||||
void add(const std::string& name, const std::string& imagePath, const T& obj);
|
void add(const std::string& name, const std::string& imagePath, const T& obj);
|
||||||
|
@ -79,7 +94,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ImageGridComponent<T>::ImageGridComponent(Window* window) : IList(window)
|
ImageGridComponent<T>::ImageGridComponent(Window* window) : IList<ImageGridData, T>(window)
|
||||||
{
|
{
|
||||||
mEntriesDirty = true;
|
mEntriesDirty = true;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +102,7 @@ ImageGridComponent<T>::ImageGridComponent(Window* window) : IList(window)
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void ImageGridComponent<T>::add(const std::string& name, const std::string& imagePath, const T& obj)
|
void ImageGridComponent<T>::add(const std::string& name, const std::string& imagePath, const T& obj)
|
||||||
{
|
{
|
||||||
Entry entry;
|
typename IList<ImageGridData, T>::Entry entry;
|
||||||
entry.name = name;
|
entry.name = name;
|
||||||
entry.object = obj;
|
entry.object = obj;
|
||||||
entry.data.texture = ResourceManager::getInstance()->fileExists(imagePath) ? TextureResource::get(imagePath) : TextureResource::get(":/button.png");
|
entry.data.texture = ResourceManager::getInstance()->fileExists(imagePath) ? TextureResource::get(imagePath) : TextureResource::get(":/button.png");
|
||||||
|
@ -148,7 +163,7 @@ void ImageGridComponent<T>::render(const Eigen::Affine3f& parentTrans)
|
||||||
it->render(trans);
|
it->render(trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderChildren(trans);
|
GuiComponent::renderChildren(trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
|
@ -22,7 +22,21 @@ struct TextListData
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class TextListComponent : public IList<TextListData, T>
|
class TextListComponent : public IList<TextListData, T>
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
using IList<TextListData, T>::mEntries;
|
||||||
|
using IList<TextListData, T>::listUpdate;
|
||||||
|
using IList<TextListData, T>::listInput;
|
||||||
|
using IList<TextListData, T>::listRenderTitleOverlay;
|
||||||
|
using IList<TextListData, T>::getTransform;
|
||||||
|
using IList<TextListData, T>::mSize;
|
||||||
|
using IList<TextListData, T>::mCursor;
|
||||||
|
using IList<TextListData, T>::Entry;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using IList<TextListData, T>::size;
|
||||||
|
using IList<TextListData, T>::isScrolling;
|
||||||
|
using IList<TextListData, T>::stopScrolling;
|
||||||
|
|
||||||
TextListComponent(Window* window);
|
TextListComponent(Window* window);
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
|
@ -46,7 +60,7 @@ public:
|
||||||
inline void setFont(const std::shared_ptr<Font>& font)
|
inline void setFont(const std::shared_ptr<Font>& font)
|
||||||
{
|
{
|
||||||
mFont = font;
|
mFont = font;
|
||||||
mTitleOverlayFont = Font::get(FONT_SIZE_LARGE, mFont->getPath());
|
this->mTitleOverlayFont = Font::get(FONT_SIZE_LARGE, mFont->getPath());
|
||||||
|
|
||||||
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
|
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
|
||||||
it->data.textCache.reset();
|
it->data.textCache.reset();
|
||||||
|
@ -62,6 +76,7 @@ protected:
|
||||||
virtual void onScroll(int amt) { if(mScrollSound) mScrollSound->play(); }
|
virtual void onScroll(int amt) { if(mScrollSound) mScrollSound->play(); }
|
||||||
virtual void onCursorChanged(const CursorState& state);
|
virtual void onCursorChanged(const CursorState& state);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int MARQUEE_DELAY = 900;
|
static const int MARQUEE_DELAY = 900;
|
||||||
static const int MARQUEE_SPEED = 16;
|
static const int MARQUEE_SPEED = 16;
|
||||||
|
@ -85,7 +100,7 @@ private:
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
TextListComponent<T>::TextListComponent(Window* window) :
|
TextListComponent<T>::TextListComponent(Window* window) :
|
||||||
IList(window)
|
IList<TextListData, T>(window)
|
||||||
{
|
{
|
||||||
mMarqueeOffset = 0;
|
mMarqueeOffset = 0;
|
||||||
mMarqueeTime = -MARQUEE_DELAY;
|
mMarqueeTime = -MARQUEE_DELAY;
|
||||||
|
@ -137,7 +152,7 @@ void TextListComponent<T>::render(const Eigen::Affine3f& parentTrans)
|
||||||
if(listCutoff > size())
|
if(listCutoff > size())
|
||||||
listCutoff = size();
|
listCutoff = size();
|
||||||
|
|
||||||
Eigen::Vector3f dim(getSize().x(), getSize().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(), (int)trans.translation().y()), Eigen::Vector2i((int)dim.x(), (int)dim.y()));
|
||||||
|
|
||||||
|
@ -147,10 +162,10 @@ void TextListComponent<T>::render(const Eigen::Affine3f& parentTrans)
|
||||||
if(mCursor == i)
|
if(mCursor == i)
|
||||||
{
|
{
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
Renderer::drawRect(0, (int)y, (int)getSize().x(), font->getHeight(), mSelectorColor);
|
Renderer::drawRect(0, (int)y, (int)mSize.x(), font->getHeight(), mSelectorColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry& entry = mEntries.at((unsigned int)i);
|
typename IList<TextListData, T>::Entry& entry = mEntries.at((unsigned int)i);
|
||||||
|
|
||||||
unsigned int color;
|
unsigned int color;
|
||||||
if(mCursor == i && mSelectedColor)
|
if(mCursor == i && mSelectedColor)
|
||||||
|
@ -256,7 +271,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
|
||||||
if(textSize.x() - mMarqueeOffset > getSize().x() - 12 - (mAlignment != ALIGN_CENTER ? mHorizontalMargin : 0))
|
if(textSize.x() - mMarqueeOffset > mSize.x() - 12 - (mAlignment != ALIGN_CENTER ? mHorizontalMargin : 0))
|
||||||
{
|
{
|
||||||
mMarqueeTime += deltaTime;
|
mMarqueeTime += deltaTime;
|
||||||
while(mMarqueeTime > MARQUEE_SPEED)
|
while(mMarqueeTime > MARQUEE_SPEED)
|
||||||
|
@ -276,7 +291,7 @@ void TextListComponent<T>::add(const std::string& name, const T& obj, unsigned i
|
||||||
{
|
{
|
||||||
assert(color < COLOR_ID_COUNT);
|
assert(color < COLOR_ID_COUNT);
|
||||||
|
|
||||||
Entry entry;
|
typename IList<TextListData, T>::Entry entry;
|
||||||
entry.name = name;
|
entry.name = name;
|
||||||
entry.object = obj;
|
entry.object = obj;
|
||||||
entry.data.colorId = color;
|
entry.data.colorId = color;
|
||||||
|
@ -336,7 +351,7 @@ void TextListComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme, c
|
||||||
}
|
}
|
||||||
if(elem->has("horizontalMargin"))
|
if(elem->has("horizontalMargin"))
|
||||||
{
|
{
|
||||||
mHorizontalMargin = elem->get<float>("horizontalMargin") * (mParent ? mParent->getSize().x() : (float)Renderer::getScreenWidth());
|
mHorizontalMargin = elem->get<float>("horizontalMargin") * (this->mParent ? this->mParent->getSize().x() : (float)Renderer::getScreenWidth());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue