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-08-02 01:43:55 +00:00
|
|
|
#define SCROLLDELAY 507
|
2012-08-16 15:23:23 +00:00
|
|
|
#define SCROLLTIME (57*5)
|
2012-08-02 01:43:55 +00:00
|
|
|
|
2012-07-27 16:58:27 +00:00
|
|
|
//this should really be a template
|
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-08-14 01:27:39 +00:00
|
|
|
void setCentered(bool centered);
|
2012-07-20 01:08:29 +00:00
|
|
|
private:
|
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-08-13 18:32:53 +00:00
|
|
|
int mSelectorColor;
|
2012-08-14 01:27:39 +00:00
|
|
|
bool mDrawCentered;
|
2012-08-04 21:38:37 +00:00
|
|
|
|
2012-08-02 01:43:55 +00:00
|
|
|
int mOffsetX, mOffsetY;
|
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
|