2012-07-20 01:08:29 +00:00
|
|
|
#ifndef _GUILIST_H_
|
|
|
|
#define _GUILIST_H_
|
|
|
|
|
|
|
|
#include "../Renderer.h"
|
|
|
|
#include "../GuiComponent.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-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>
|
2012-07-20 01:08:29 +00:00
|
|
|
class GuiList : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2012-08-04 21:38:37 +00:00
|
|
|
GuiList(int offsetX = 0, int offsetY = 0, Renderer::FontSize fontsize = Renderer::MEDIUM);
|
2012-07-21 19:06:24 +00:00
|
|
|
~GuiList();
|
2012-07-20 01:08:29 +00:00
|
|
|
|
|
|
|
void onRender();
|
2012-08-02 01:43:55 +00:00
|
|
|
void onTick(int deltaTime);
|
2012-07-21 19:06:24 +00:00
|
|
|
void onInput(InputManager::InputButton button, bool keyDown);
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2012-08-02 04:50:18 +00:00
|
|
|
void addObject(std::string name, listType obj, int color = 0xFF0000);
|
2012-07-20 16:14:09 +00:00
|
|
|
void clear();
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2012-08-12 14:43:09 +00:00
|
|
|
void onPause();
|
|
|
|
void onResume();
|
|
|
|
|
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-08-16 15:23:23 +00:00
|
|
|
bool isScrolling();
|
2012-08-13 18:32:53 +00:00
|
|
|
|
|
|
|
void setSelectorColor(int selectorColor);
|
2012-10-01 03:29:55 +00:00
|
|
|
void setSelectedTextColor(int selectedColor);
|
2012-08-14 01:27:39 +00:00
|
|
|
void setCentered(bool centered);
|
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-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;
|
|
|
|
|
2012-08-02 01:43:55 +00:00
|
|
|
int mScrollDir, mScrollAccumulator;
|
|
|
|
bool mScrolling;
|
|
|
|
|
2012-08-04 21:38:37 +00:00
|
|
|
Renderer::FontSize mFont;
|
2012-10-01 03:29:55 +00:00
|
|
|
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;
|
|
|
|
int color;
|
|
|
|
};
|
|
|
|
|
2012-07-27 16:58:27 +00:00
|
|
|
std::vector<ListRow> mRowVector;
|
2012-07-21 19:06:24 +00:00
|
|
|
int mSelection;
|
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
|