metaforce/Runtime/GuiSys/CGuiGroup.cpp

54 lines
1.6 KiB
C++
Raw Normal View History

#include "Runtime/GuiSys/CGuiGroup.hpp"
2016-03-11 00:23:16 +00:00
2021-04-10 08:42:06 +00:00
namespace metaforce {
2016-03-11 00:23:16 +00:00
2018-12-08 05:30:43 +00:00
void CGuiGroup::LoadWidgetFnMap() {}
2016-03-11 00:23:16 +00:00
2016-03-16 03:37:51 +00:00
CGuiGroup::CGuiGroup(const CGuiWidgetParms& parms, int defaultWorker, bool b)
2018-12-08 05:30:43 +00:00
: CGuiCompoundWidget(parms), xbc_selectedWorker(defaultWorker), xc0_b(b) {}
void CGuiGroup::SelectWorkerWidget(int workerId, bool setActive, bool setVisible) {
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
while (child) {
if (child->GetWorkerId() == workerId) {
CGuiWidget* sel = GetSelectedWidget();
if (setActive) {
sel->SetIsActive(false);
child->SetIsActive(true);
}
if (setVisible) {
sel->SetVisibility(false, ETraversalMode::Single);
child->SetVisibility(true, ETraversalMode::Single);
}
break;
2016-03-16 03:37:51 +00:00
}
2018-12-08 05:30:43 +00:00
child = static_cast<CGuiWidget*>(child->GetNextSibling());
}
2016-03-16 03:37:51 +00:00
}
2018-12-08 05:30:43 +00:00
CGuiWidget* CGuiGroup::GetSelectedWidget() { return GetWorkerWidget(xbc_selectedWorker); }
2016-03-16 03:37:51 +00:00
const CGuiWidget* CGuiGroup::GetSelectedWidget() const { return GetWorkerWidget(xbc_selectedWorker); }
2018-12-08 05:30:43 +00:00
bool CGuiGroup::AddWorkerWidget(CGuiWidget* worker) {
++xb8_workerCount;
return true;
2016-03-16 03:37:51 +00:00
}
2018-12-08 05:30:43 +00:00
void CGuiGroup::OnActiveChange() {
CGuiWidget* sel = GetSelectedWidget();
if (sel)
sel->SetIsActive(true);
2016-03-16 03:37:51 +00:00
}
2018-12-08 05:30:43 +00:00
std::shared_ptr<CGuiWidget> CGuiGroup::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp) {
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
s16 defaultWorker = in.ReadInt16();
bool b = in.ReadBool();
2018-12-08 05:30:43 +00:00
std::shared_ptr<CGuiWidget> ret = std::make_shared<CGuiGroup>(parms, defaultWorker, b);
ret->ParseBaseInfo(frame, in, parms);
return ret;
2016-03-16 03:37:51 +00:00
}
2021-04-10 08:42:06 +00:00
} // namespace metaforce