metaforce/Runtime/GuiSys/CGuiGroup.cpp

54 lines
1.6 KiB
C++
Raw Permalink Normal View History

#include "Runtime/GuiSys/CGuiGroup.hpp"
2016-03-10 16:23:16 -08:00
2021-04-10 01:42:06 -07:00
namespace metaforce {
2016-03-10 16:23:16 -08:00
2018-12-07 21:30:43 -08:00
void CGuiGroup::LoadWidgetFnMap() {}
2016-03-10 16:23:16 -08:00
2016-03-15 20:37:51 -07:00
CGuiGroup::CGuiGroup(const CGuiWidgetParms& parms, int defaultWorker, bool b)
2018-12-07 21:30:43 -08: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-15 20:37:51 -07:00
}
2018-12-07 21:30:43 -08:00
child = static_cast<CGuiWidget*>(child->GetNextSibling());
}
2016-03-15 20:37:51 -07:00
}
2018-12-07 21:30:43 -08:00
CGuiWidget* CGuiGroup::GetSelectedWidget() { return GetWorkerWidget(xbc_selectedWorker); }
2016-03-15 20:37:51 -07:00
const CGuiWidget* CGuiGroup::GetSelectedWidget() const { return GetWorkerWidget(xbc_selectedWorker); }
2018-12-07 21:30:43 -08:00
bool CGuiGroup::AddWorkerWidget(CGuiWidget* worker) {
++xb8_workerCount;
return true;
2016-03-15 20:37:51 -07:00
}
2018-12-07 21:30:43 -08:00
void CGuiGroup::OnActiveChange() {
CGuiWidget* sel = GetSelectedWidget();
if (sel)
sel->SetIsActive(true);
2016-03-15 20:37:51 -07:00
}
2018-12-07 21:30:43 -08: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-07 21:30:43 -08:00
std::shared_ptr<CGuiWidget> ret = std::make_shared<CGuiGroup>(parms, defaultWorker, b);
ret->ParseBaseInfo(frame, in, parms);
return ret;
2016-03-15 20:37:51 -07:00
}
2021-04-10 01:42:06 -07:00
} // namespace metaforce