metaforce/Runtime/GuiSys/CGuiTableGroup.hpp

95 lines
2.5 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
2016-03-10 03:47:37 +00:00
2016-03-11 00:23:16 +00:00
#include "CGuiCompoundWidget.hpp"
2016-03-10 03:47:37 +00:00
2018-12-08 05:30:43 +00:00
namespace urde {
2016-03-10 03:47:37 +00:00
2018-12-08 05:30:43 +00:00
class CGuiTableGroup : public CGuiCompoundWidget {
2016-03-11 00:23:16 +00:00
public:
2018-12-08 05:30:43 +00:00
class CRepeatState {
float x0_timer = 0.f;
public:
bool Update(float dt, bool state);
};
enum class TableSelectReturn { Changed, Unchanged, WrappedAround };
2016-03-18 02:45:45 +00:00
private:
2018-12-08 05:30:43 +00:00
CRepeatState xb8_decRepeat;
CRepeatState xbc_incRepeat;
int xc0_elementCount;
int xc4_userSelection;
int xc8_prevUserSelection;
int xcc_defaultUserSelection;
bool xd0_selectWraparound;
bool xd1_vertical = true;
std::function<void(CGuiTableGroup*)> xd4_doMenuAdvance;
std::function<void(CGuiTableGroup*)> xec_doMenuCancel;
std::function<void(CGuiTableGroup*, int)> x104_doMenuSelChange;
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-03-18 02:45:45 +00:00
public:
2018-12-08 05:30:43 +00:00
CGuiTableGroup(const CGuiWidgetParms& parms, int, int, bool);
FourCC GetWidgetTypeID() const override { return FOURCC('TBGP'); }
2016-03-18 02:45:45 +00:00
2018-12-08 05:30:43 +00:00
void SetMenuAdvanceCallback(std::function<void(CGuiTableGroup*)>&& cb) { xd4_doMenuAdvance = std::move(cb); }
2016-12-14 22:56:59 +00:00
2018-12-08 05:30:43 +00:00
void SetMenuCancelCallback(std::function<void(CGuiTableGroup*)>&& cb) { xec_doMenuCancel = std::move(cb); }
2016-12-14 22:56:59 +00:00
2018-12-08 05:30:43 +00:00
void SetMenuSelectionChangeCallback(std::function<void(CGuiTableGroup*, int)>&& cb) {
x104_doMenuSelChange = std::move(cb);
}
2016-12-14 22:56:59 +00:00
2018-12-08 05:30:43 +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);
2016-12-16 04:35:49 +00:00
}
2018-12-08 05:30:43 +00:00
}
2016-12-16 04:35:49 +00:00
2018-12-08 05:30:43 +00:00
void SetVertical(bool v) { xd1_vertical = v; }
2018-12-08 05:30:43 +00:00
void SetUserSelection(int sel) {
xc8_prevUserSelection = xc4_userSelection;
xc4_userSelection = sel;
}
2016-12-16 04:35:49 +00:00
2018-12-08 05:30:43 +00:00
int GetElementCount() const { return xc0_elementCount; }
2017-05-07 19:35:52 +00:00
2018-12-08 05:30:43 +00:00
int GetUserSelection() const { return xc4_userSelection; }
2016-12-16 04:35:49 +00:00
2019-01-21 04:10:34 +00:00
bool IsWorkerSelectable(int) const;
void SelectWorker(int);
2019-01-22 04:23:51 +00:00
void DoSelectWorker(int);
void SetWorkersMouseActive(bool);
void ProcessUserInput(const CFinalInput& input) override;
2017-01-09 03:44:00 +00:00
bool AddWorkerWidget(CGuiWidget* worker) override { return true; }
2018-12-08 05:30:43 +00:00
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
2016-03-11 00:23:16 +00:00
};
2016-03-10 03:47:37 +00:00
2018-12-08 05:30:43 +00:00
} // namespace urde