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
|
|
|
|
#define SCROLLTIME (57*6)
|
|
|
|
|
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-02 01:43:55 +00:00
|
|
|
GuiList(int offsetX = 0, int offsetY = 0);
|
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
|
|
|
|
|
|
|
std::string getSelectedName();
|
2012-08-02 04:50:18 +00:00
|
|
|
listType getSelectedObject();
|
2012-07-21 19:06:24 +00:00
|
|
|
int getSelection();
|
2012-07-20 01:08:29 +00:00
|
|
|
private:
|
2012-08-02 01:43:55 +00:00
|
|
|
int mScrollDir, mScrollAccumulator;
|
|
|
|
bool mScrolling;
|
|
|
|
|
|
|
|
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
|