ES-DE/src/components/GuiList.h

80 lines
1.7 KiB
C
Raw Normal View History

#ifndef _GUILIST_H_
#define _GUILIST_H_
#include "../Renderer.h"
#include "../Font.h"
2013-04-08 16:52:40 +00:00
#include "../Gui.h"
#include "../InputManager.h"
#include <vector>
#include <string>
#include "../Sound.h"
//A graphical list. Supports multiple colors for rows and scrolling.
//TODO - add truncation to text rendering if name exceeds a maximum width (a trailing elipses, perhaps).
2012-08-02 04:50:18 +00:00
template <typename listType>
2013-04-08 16:52:40 +00:00
class GuiList : public Gui
{
public:
2013-04-08 16:52:40 +00:00
GuiList(Window* window, int offsetX, int offsetY, Font* font);
~GuiList();
2013-04-08 16:52:40 +00:00
void input(InputConfig* config, Input input);
void update(int deltaTime);
void render();
void addObject(std::string name, listType obj, unsigned int color = 0xFF0000);
void clear();
std::string getSelectedName();
2012-08-02 04:50:18 +00:00
listType getSelectedObject();
int getSelection();
void stopScrolling();
bool isScrolling();
void setSelectorColor(unsigned int selectorColor);
void setSelectedTextColor(unsigned int selectedColor);
void setCentered(bool centered);
void setScrollSound(Sound* sound);
void setTextOffsetX(int textoffsetx);
int getObjectCount();
listType getObject(int i);
void setSelection(int i);
void setFont(Font* f);
2013-04-08 16:52:40 +00:00
int getOffsetX();
int getOffsetY();
private:
static const int SCROLLDELAY = 507;
static const int SCROLLTIME = 200;
2013-04-08 16:52:40 +00:00
int mOffsetX, mOffsetY;
void scroll(); //helper method, scrolls in whatever direction scrollDir is
int mScrollDir, mScrollAccumulator;
bool mScrolling;
Font* mFont;
unsigned int mSelectorColor, mSelectedTextColorOverride;
bool mDrawCentered;
int mTextOffsetX;
2012-08-02 04:50:18 +00:00
struct ListRow
{
std::string name;
listType object;
unsigned int color;
2012-08-02 04:50:18 +00:00
};
std::vector<ListRow> mRowVector;
int mSelection;
Sound* mScrollSound;
};
2012-08-02 04:50:18 +00:00
#include "GuiList.cpp"
#endif