2012-07-20 01:08:29 +00:00
|
|
|
#ifndef _GUILIST_H_
|
|
|
|
#define _GUILIST_H_
|
|
|
|
|
|
|
|
#include "../Renderer.h"
|
2012-10-24 15:28:37 +00:00
|
|
|
#include "../Font.h"
|
2013-04-08 16:52:40 +00:00
|
|
|
#include "../Gui.h"
|
2012-07-21 19:06:24 +00:00
|
|
|
#include "../InputManager.h"
|
2012-07-20 01:08:29 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
2012-10-13 18:29:53 +00:00
|
|
|
#include "../Sound.h"
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2012-09-07 21:44:07 +00:00
|
|
|
//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
|
2012-07-20 01:08:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2013-04-08 16:52:40 +00:00
|
|
|
GuiList(Window* window, int offsetX, int offsetY, Font* font);
|
2012-07-21 19:06:24 +00:00
|
|
|
~GuiList();
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2013-04-08 16:52:40 +00:00
|
|
|
void input(InputConfig* config, Input input);
|
|
|
|
void update(int deltaTime);
|
|
|
|
void render();
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2012-10-17 18:21:56 +00:00
|
|
|
void addObject(std::string name, listType obj, unsigned int color = 0xFF0000);
|
2012-07-20 16:14:09 +00:00
|
|
|
void clear();
|
2012-07-20 01:08:29 +00:00
|
|
|
|
|
|
|
std::string getSelectedName();
|
2012-08-02 04:50:18 +00:00
|
|
|
listType getSelectedObject();
|
2012-07-21 19:06:24 +00:00
|
|
|
int getSelection();
|
2012-10-14 17:49:57 +00:00
|
|
|
void stopScrolling();
|
2012-08-16 15:23:23 +00:00
|
|
|
bool isScrolling();
|
2012-08-13 18:32:53 +00:00
|
|
|
|
2012-10-17 18:21:56 +00:00
|
|
|
void setSelectorColor(unsigned int selectorColor);
|
|
|
|
void setSelectedTextColor(unsigned int selectedColor);
|
2012-08-14 01:27:39 +00:00
|
|
|
void setCentered(bool centered);
|
2012-10-13 18:29:53 +00:00
|
|
|
void setScrollSound(Sound* sound);
|
2012-09-15 21:24:33 +00:00
|
|
|
void setTextOffsetX(int textoffsetx);
|
|
|
|
|
2012-10-05 13:44:18 +00:00
|
|
|
int getObjectCount();
|
|
|
|
listType getObject(int i);
|
|
|
|
void setSelection(int i);
|
|
|
|
|
2012-10-31 14:46:06 +00:00
|
|
|
void setFont(Font* f);
|
2013-04-08 16:52:40 +00:00
|
|
|
|
|
|
|
int getOffsetX();
|
|
|
|
int getOffsetY();
|
2012-07-20 01:08:29 +00:00
|
|
|
private:
|
2012-10-01 03:29:55 +00:00
|
|
|
static const int SCROLLDELAY = 507;
|
|
|
|
static const int SCROLLTIME = 200;
|
|
|
|
|
2013-04-08 16:52:40 +00:00
|
|
|
int mOffsetX, mOffsetY;
|
|
|
|
|
2012-10-13 18:29:53 +00:00
|
|
|
void scroll(); //helper method, scrolls in whatever direction scrollDir is
|
|
|
|
|
2012-08-02 01:43:55 +00:00
|
|
|
int mScrollDir, mScrollAccumulator;
|
|
|
|
bool mScrolling;
|
|
|
|
|
2012-10-24 15:28:37 +00:00
|
|
|
Font* mFont;
|
2012-10-17 18:21:56 +00:00
|
|
|
unsigned int mSelectorColor, mSelectedTextColorOverride;
|
2012-08-14 01:27:39 +00:00
|
|
|
bool mDrawCentered;
|
2012-08-04 21:38:37 +00:00
|
|
|
|
2012-09-15 21:24:33 +00:00
|
|
|
int mTextOffsetX;
|
2012-08-02 04:50:18 +00:00
|
|
|
|
|
|
|
struct ListRow
|
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
listType object;
|
2012-10-17 18:21:56 +00:00
|
|
|
unsigned int color;
|
2012-08-02 04:50:18 +00:00
|
|
|
};
|
|
|
|
|
2012-07-27 16:58:27 +00:00
|
|
|
std::vector<ListRow> mRowVector;
|
2012-07-21 19:06:24 +00:00
|
|
|
int mSelection;
|
2012-10-13 18:29:53 +00:00
|
|
|
Sound* mScrollSound;
|
2012-07-20 01:08:29 +00:00
|
|
|
};
|
|
|
|
|
2012-08-02 04:50:18 +00:00
|
|
|
#include "GuiList.cpp"
|
|
|
|
|
2012-07-20 01:08:29 +00:00
|
|
|
#endif
|