2016-03-10 03:47:37 +00:00
|
|
|
#ifndef __URDE_CGUITABLEGROUP_HPP__
|
|
|
|
#define __URDE_CGUITABLEGROUP_HPP__
|
|
|
|
|
2016-03-11 00:23:16 +00:00
|
|
|
#include "CGuiCompoundWidget.hpp"
|
2016-03-10 03:47:37 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
2016-03-11 00:23:16 +00:00
|
|
|
class CGuiTableGroup : public CGuiCompoundWidget
|
|
|
|
{
|
|
|
|
public:
|
2017-01-09 03:44:00 +00:00
|
|
|
class CRepeatState
|
2016-03-18 02:45:45 +00:00
|
|
|
{
|
2017-01-09 03:44:00 +00:00
|
|
|
float x0_timer = 0.f;
|
|
|
|
public:
|
|
|
|
bool Update(float dt, bool state);
|
2016-03-18 02:45:45 +00:00
|
|
|
};
|
2017-01-09 03:44:00 +00:00
|
|
|
|
2016-12-16 04:35:49 +00:00
|
|
|
enum class TableSelectReturn
|
|
|
|
{
|
|
|
|
Changed,
|
|
|
|
Unchanged,
|
|
|
|
WrappedAround
|
|
|
|
};
|
2016-12-15 22:37:34 +00:00
|
|
|
|
2016-03-18 02:45:45 +00:00
|
|
|
private:
|
2017-01-09 03:44:00 +00:00
|
|
|
CRepeatState xb8_decRepeat;
|
|
|
|
CRepeatState xbc_incRepeat;
|
2016-12-16 04:35:49 +00:00
|
|
|
int xc0_elementCount;
|
|
|
|
int xc4_userSelection;
|
|
|
|
int xc8_prevUserSelection;
|
|
|
|
int xcc_defaultUserSelection;
|
|
|
|
bool xd0_selectWraparound;
|
2017-01-09 03:44:00 +00:00
|
|
|
bool xd1_vertical = true;
|
2016-12-16 23:05:29 +00:00
|
|
|
std::function<void(CGuiTableGroup*)> xd4_doMenuAdvance;
|
|
|
|
std::function<void(CGuiTableGroup*)> xec_doMenuCancel;
|
2017-01-09 03:44:00 +00:00
|
|
|
std::function<void(CGuiTableGroup*, int)> x104_doMenuSelChange;
|
|
|
|
|
|
|
|
bool IsWorkerSelectable(int) const;
|
|
|
|
void SelectWorker(int);
|
|
|
|
void DeactivateWorker(CGuiWidget* widget);
|
|
|
|
void ActivateWorker(CGuiWidget* widget);
|
|
|
|
|
|
|
|
TableSelectReturn DecrementSelectedRow();
|
|
|
|
TableSelectReturn IncrementSelectedRow();
|
|
|
|
void DoSelectPrevRow();
|
|
|
|
void DoSelectNextRow();
|
|
|
|
|
|
|
|
void DoCancel();
|
|
|
|
void DoAdvance();
|
|
|
|
bool PreDecrement();
|
|
|
|
void DoDecrement();
|
|
|
|
bool PreIncrement();
|
|
|
|
void DoIncrement();
|
2016-12-15 22:37:34 +00:00
|
|
|
|
2016-03-18 02:45:45 +00:00
|
|
|
public:
|
2016-12-15 22:37:34 +00:00
|
|
|
CGuiTableGroup(const CGuiWidgetParms& parms, int, int, bool);
|
2016-03-18 02:45:45 +00:00
|
|
|
FourCC GetWidgetTypeID() const {return FOURCC('TBGP');}
|
|
|
|
|
2016-12-16 23:05:29 +00:00
|
|
|
void SetMenuAdvanceCallback(std::function<void(CGuiTableGroup*)>&& cb)
|
2016-12-14 22:56:59 +00:00
|
|
|
{
|
|
|
|
xd4_doMenuAdvance = std::move(cb);
|
|
|
|
}
|
|
|
|
|
2016-12-16 23:05:29 +00:00
|
|
|
void SetMenuCancelCallback(std::function<void(CGuiTableGroup*)>&& cb)
|
2016-12-14 22:56:59 +00:00
|
|
|
{
|
|
|
|
xec_doMenuCancel = std::move(cb);
|
|
|
|
}
|
|
|
|
|
2017-01-09 03:44:00 +00:00
|
|
|
void SetMenuSelectionChangeCallback(std::function<void(CGuiTableGroup*, int)>&& cb)
|
2016-12-14 22:56:59 +00:00
|
|
|
{
|
|
|
|
x104_doMenuSelChange = std::move(cb);
|
|
|
|
}
|
|
|
|
|
2016-12-16 04:35:49 +00:00
|
|
|
void SetColors(const zeus::CColor& selected, const zeus::CColor& unselected)
|
|
|
|
{
|
|
|
|
int id = -1;
|
|
|
|
while (CGuiWidget* worker = GetWorkerWidget(++id))
|
|
|
|
{
|
|
|
|
if (id == xc4_userSelection)
|
|
|
|
worker->SetColor(selected);
|
|
|
|
else
|
|
|
|
worker->SetColor(unselected);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-09 03:44:00 +00:00
|
|
|
void SetVertical(bool v) { xd1_vertical = v; }
|
2016-12-15 22:37:34 +00:00
|
|
|
|
2016-12-16 04:35:49 +00:00
|
|
|
void SetUserSelection(int sel)
|
|
|
|
{
|
|
|
|
xc8_prevUserSelection = xc4_userSelection;
|
|
|
|
xc4_userSelection = sel;
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetUserSelection() const { return xc4_userSelection; }
|
|
|
|
|
2017-01-09 03:44:00 +00:00
|
|
|
void ProcessUserInput(const CFinalInput& input);
|
|
|
|
|
2016-03-18 02:45:45 +00:00
|
|
|
static CGuiTableGroup* Create(CGuiFrame* frame, CInputStream& in, bool);
|
2016-03-11 00:23:16 +00:00
|
|
|
};
|
2016-03-10 03:47:37 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __URDE_CGUITABLEGROUP_HPP__
|