2016-03-10 03:47:37 +00:00
|
|
|
#include "CGuiWidget.hpp"
|
2016-03-11 22:50:15 +00:00
|
|
|
#include "CGuiFrame.hpp"
|
2016-03-14 00:58:19 +00:00
|
|
|
#include "CGuiAnimController.hpp"
|
|
|
|
#include "CGuiLogicalEventTrigger.hpp"
|
2016-03-14 23:32:44 +00:00
|
|
|
#include "CGuiMessage.hpp"
|
2016-03-10 03:47:37 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
2016-03-14 00:58:19 +00:00
|
|
|
static logvisor::Module Log("urde::CGuiWidget");
|
2016-03-10 03:47:37 +00:00
|
|
|
|
2016-03-11 00:23:16 +00:00
|
|
|
typedef bool(CGuiWidget::*FMAF)(CGuiFunctionDef* def, CGuiControllerInfo* info);
|
|
|
|
static std::unordered_map<u32, FMAF> WidgetFnMap;
|
|
|
|
|
|
|
|
void CGuiWidget::LoadWidgetFnMap()
|
|
|
|
{
|
|
|
|
WidgetFnMap.emplace(std::make_pair(2, &CGuiWidget::MAF_StartAnimationSet));
|
|
|
|
WidgetFnMap.emplace(std::make_pair(3, &CGuiWidget::MAF_SendMessage));
|
|
|
|
WidgetFnMap.emplace(std::make_pair(6, &CGuiWidget::MAF_PauseAnim));
|
|
|
|
WidgetFnMap.emplace(std::make_pair(7, &CGuiWidget::MAF_ResumeAnim));
|
|
|
|
WidgetFnMap.emplace(std::make_pair(11, &CGuiWidget::MAF_SetState));
|
|
|
|
WidgetFnMap.emplace(std::make_pair(12, &CGuiWidget::MAF_SetStateOfWidget));
|
|
|
|
}
|
|
|
|
|
2016-03-11 22:50:15 +00:00
|
|
|
CGuiWidget::CGuiWidget(const CGuiWidgetParms& parms)
|
2016-03-14 00:58:19 +00:00
|
|
|
: x7c_selfId(parms.x6_selfId), x7e_parentId(parms.x8_parentId),
|
|
|
|
xbc_color(parms.x10_color), xc0_color2(parms.x10_color),
|
|
|
|
xc4_drawFlags(parms.x14_drawFlags), xc8_frame(parms.x0_frame),
|
2016-03-15 23:23:45 +00:00
|
|
|
xf6_24_pg(parms.xd_g), xf6_25_isVisible(parms.xa_defaultVisible),
|
|
|
|
xf6_26_isActive(parms.xb_defaultActive),
|
2016-03-17 02:18:01 +00:00
|
|
|
xf6_27_(true), xf6_28_eventLock(false),
|
|
|
|
xf6_29_cullFaces(parms.xc_cullFaces), xf6_30_(false),
|
2016-03-14 00:58:19 +00:00
|
|
|
xf6_31_(true), xf7_24_(false), xf7_25_(true)
|
2016-03-11 22:50:15 +00:00
|
|
|
{
|
2016-03-16 03:37:51 +00:00
|
|
|
if (parms.x4_useAnimController)
|
2016-03-14 00:58:19 +00:00
|
|
|
EnsureHasAnimController();
|
2016-03-15 23:23:45 +00:00
|
|
|
RecalcWidgetColor(ETraversalMode::Single);
|
2016-03-11 22:50:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CGuiWidget::CGuiWidgetParms
|
|
|
|
CGuiWidget::ReadWidgetHeader(CGuiFrame* frame, CInputStream& in, bool flag)
|
|
|
|
{
|
|
|
|
std::string name = in.readString(-1);
|
|
|
|
s16 selfId = frame->GetWidgetIdDB().AddWidget(name);
|
|
|
|
std::string parent = in.readString(-1);
|
|
|
|
s16 parentId = frame->GetWidgetIdDB().AddWidget(parent);
|
|
|
|
|
2016-03-16 03:37:51 +00:00
|
|
|
bool useAnimController = in.readBool();
|
2016-03-15 23:23:45 +00:00
|
|
|
bool defaultVis = in.readBool();
|
|
|
|
bool defaultActive = in.readBool();
|
2016-03-17 02:18:01 +00:00
|
|
|
bool cullFaces = in.readBool();
|
2016-03-11 22:50:15 +00:00
|
|
|
zeus::CColor color;
|
2016-03-14 00:58:19 +00:00
|
|
|
color.readRGBABig(in);
|
2016-03-11 22:50:15 +00:00
|
|
|
EGuiModelDrawFlags df = EGuiModelDrawFlags(in.readUint32Big());
|
|
|
|
|
2016-03-16 03:37:51 +00:00
|
|
|
return CGuiWidget::CGuiWidgetParms(frame, useAnimController, selfId,
|
|
|
|
parentId, defaultVis, defaultActive,
|
2016-03-17 02:18:01 +00:00
|
|
|
cullFaces, color, df, true, flag);
|
2016-03-11 22:50:15 +00:00
|
|
|
}
|
|
|
|
|
2016-03-14 00:58:19 +00:00
|
|
|
CGuiWidget* CGuiWidget::Create(CGuiFrame* frame, CInputStream& in, bool flag)
|
2016-03-11 22:50:15 +00:00
|
|
|
{
|
2016-03-14 00:58:19 +00:00
|
|
|
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
|
|
|
|
CGuiWidget* ret = new CGuiWidget(parms);
|
|
|
|
ret->ParseBaseInfo(frame, in, parms);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-03-14 23:32:44 +00:00
|
|
|
bool CGuiWidget::Message(const CGuiMessage& msg)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-14 00:58:19 +00:00
|
|
|
void CGuiWidget::ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWidgetParms& parms)
|
|
|
|
{
|
|
|
|
CGuiWidget* parent = frame->FindWidget(parms.x8_parentId);
|
|
|
|
bool a = in.readBool();
|
|
|
|
if (a)
|
|
|
|
xf4_workerId = in.readInt16Big();
|
|
|
|
zeus::CVector3f trans;
|
|
|
|
trans.readBig(in);
|
|
|
|
zeus::CMatrix3f orient;
|
|
|
|
orient.readBig(in);
|
|
|
|
x80_transform = zeus::CTransform(orient, trans);
|
|
|
|
ReapplyXform();
|
|
|
|
zeus::CVector3f rotCenter;
|
|
|
|
rotCenter.readBig(in);
|
|
|
|
SetRotationCenter(rotCenter);
|
|
|
|
ParseMessages(in, parms);
|
|
|
|
ParseAnimations(in, parms);
|
|
|
|
if (a)
|
|
|
|
if (!parent->AddWorkerWidget(this))
|
|
|
|
{
|
|
|
|
Log.report(logvisor::Warning,
|
|
|
|
"Warning: Discarding useless worker id. Parent is not a compound widget.");
|
|
|
|
xf4_workerId = -1;
|
|
|
|
}
|
|
|
|
parent->AddChildWidget(this, false, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::ParseMessages(CInputStream& in, const CGuiWidgetParms& parms)
|
|
|
|
{
|
|
|
|
s16 count = in.readInt16Big();
|
|
|
|
assert(count == 0);
|
|
|
|
count = in.readInt16Big();
|
|
|
|
assert(count == 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::ParseAnimations(CInputStream& in, const CGuiWidgetParms& parms)
|
|
|
|
{
|
|
|
|
s16 count = in.readInt16Big();
|
|
|
|
assert(count == 0);
|
|
|
|
}
|
|
|
|
|
2016-03-15 23:23:45 +00:00
|
|
|
std::vector<TResId> CGuiWidget::GetTextureAssets() const
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<TResId> CGuiWidget::GetModelAssets() const
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<TResId> CGuiWidget::GetFontAssets() const
|
|
|
|
{
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::Initialize() {}
|
|
|
|
void CGuiWidget::Touch() const {}
|
|
|
|
|
|
|
|
bool CGuiWidget::GetIsVisible() const
|
|
|
|
{
|
|
|
|
return xf6_25_isVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiWidget::GetIsActive() const
|
|
|
|
{
|
|
|
|
return xf6_26_isActive;
|
|
|
|
}
|
|
|
|
|
|
|
|
CGuiTextSupport* CGuiWidget::TextSupport()
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
CGuiTextSupport* CGuiWidget::GetTextSupport() const
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::ModifyRGBA(CGuiWidget* widget)
|
|
|
|
{
|
|
|
|
xb8_ += widget->xb8_;
|
|
|
|
xb4_ = xb8_ + xc0_color2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::RecalculateAllRGBA()
|
|
|
|
{
|
|
|
|
CGuiWidget* parent = static_cast<CGuiWidget*>(GetParent());
|
|
|
|
if (parent)
|
|
|
|
ModifyRGBA(parent);
|
|
|
|
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (nextSib)
|
|
|
|
nextSib->RecalculateAllRGBA();
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->RecalculateAllRGBA();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::InitializeRGBAFactor()
|
|
|
|
{
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->InitializeRGBAFactor();
|
|
|
|
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (nextSib)
|
|
|
|
nextSib->InitializeRGBAFactor();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiWidget::GetIsFinishedLoadingWidgetSpecific() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<CGuiLogicalEventTrigger>>* CGuiWidget::FindTriggerList(int id)
|
|
|
|
{
|
|
|
|
auto search = xcc_triggerMap.find(id);
|
|
|
|
if (search == xcc_triggerMap.cend())
|
|
|
|
return nullptr;
|
|
|
|
return search->second.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::AddTrigger(std::unique_ptr<CGuiLogicalEventTrigger>&& trigger)
|
|
|
|
{
|
|
|
|
int tid = trigger->GetTriggerId();
|
|
|
|
std::vector<std::unique_ptr<CGuiLogicalEventTrigger>>* list = FindTriggerList(tid);
|
|
|
|
if (!list)
|
|
|
|
{
|
|
|
|
auto it =
|
|
|
|
xcc_triggerMap.emplace(std::make_pair(tid,
|
|
|
|
std::make_unique<std::vector<std::unique_ptr<CGuiLogicalEventTrigger>>>()));
|
|
|
|
list = it.first->second.get();
|
|
|
|
}
|
|
|
|
list->push_back(std::move(trigger));
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::unique_ptr<CGuiFunctionDef>>* CGuiWidget::FindFunctionDefList(int id)
|
|
|
|
{
|
|
|
|
auto search = xe0_functionMap.find(id);
|
|
|
|
if (search == xe0_functionMap.cend())
|
|
|
|
return nullptr;
|
|
|
|
return search->second.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::AddFunctionDef(s32 id, std::unique_ptr<CGuiFunctionDef>&& def)
|
|
|
|
{
|
|
|
|
std::vector<std::unique_ptr<CGuiFunctionDef>>* list = FindFunctionDefList(id);
|
|
|
|
if (!list)
|
|
|
|
{
|
|
|
|
auto it =
|
|
|
|
xe0_functionMap.emplace(std::make_pair(id,
|
|
|
|
std::make_unique<std::vector<std::unique_ptr<CGuiFunctionDef>>>()));
|
|
|
|
list = it.first->second.get();
|
|
|
|
}
|
|
|
|
list->push_back(std::move(def));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::SetIdlePosition(const zeus::CVector3f& pos, bool reapply)
|
|
|
|
{
|
|
|
|
x80_transform.m_origin = pos;
|
|
|
|
if (reapply)
|
|
|
|
ReapplyXform();
|
|
|
|
}
|
|
|
|
|
2016-03-14 00:58:19 +00:00
|
|
|
void CGuiWidget::ReapplyXform()
|
|
|
|
{
|
|
|
|
RotateReset();
|
|
|
|
SetLocalPosition(zeus::CVector3f::skZero);
|
|
|
|
MultiplyO2P(x80_transform);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::EnsureHasAnimController()
|
|
|
|
{
|
|
|
|
if (!xb0_animController)
|
|
|
|
{
|
|
|
|
xb0_animController.reset(new CGuiAnimController(
|
|
|
|
CGuiWidgetParms(xc8_frame, false, -1, -1, true, false, false,
|
2016-03-17 22:19:25 +00:00
|
|
|
zeus::CColor::skWhite, EGuiModelDrawFlags::Alpha,
|
2016-03-14 00:58:19 +00:00
|
|
|
true, false), this));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-15 23:23:45 +00:00
|
|
|
void CGuiWidget::BroadcastMessage(int id, CGuiControllerInfo* info)
|
2016-03-14 00:58:19 +00:00
|
|
|
{
|
2016-03-15 23:23:45 +00:00
|
|
|
CGuiFuncParm a((intptr_t(x7c_selfId)));
|
|
|
|
CGuiFuncParm b((intptr_t(id)));
|
|
|
|
CGuiFunctionDef def(0, false, a, b);
|
|
|
|
MAF_SendMessage(&def, info);
|
|
|
|
|
|
|
|
CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (ch)
|
|
|
|
ch->BroadcastMessage(id, info);
|
|
|
|
|
|
|
|
CGuiWidget* sib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (sib)
|
|
|
|
sib->BroadcastMessage(id, info);
|
2016-03-14 00:58:19 +00:00
|
|
|
}
|
|
|
|
|
2016-03-15 23:23:45 +00:00
|
|
|
void CGuiWidget::LockEvents(bool lock)
|
2016-03-14 00:58:19 +00:00
|
|
|
{
|
2016-03-15 23:23:45 +00:00
|
|
|
xf6_28_eventLock = lock;
|
|
|
|
if (lock)
|
|
|
|
DoUnregisterEventHandler();
|
|
|
|
else
|
|
|
|
DoRegisterEventHandler();
|
2016-03-14 00:58:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::UnregisterEventHandler()
|
|
|
|
{
|
|
|
|
bool flag = DoUnregisterEventHandler();
|
|
|
|
if (!flag)
|
|
|
|
{
|
|
|
|
CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (ch)
|
|
|
|
ch->UnregisterEventHandler();
|
|
|
|
}
|
|
|
|
CGuiWidget* sib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (sib && flag)
|
|
|
|
sib->UnregisterEventHandler();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::UnregisterEventHandler(ETraversalMode mode)
|
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
2016-03-15 23:23:45 +00:00
|
|
|
case ETraversalMode::Children:
|
2016-03-14 00:58:19 +00:00
|
|
|
if (!DoUnregisterEventHandler())
|
|
|
|
{
|
|
|
|
CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (ch)
|
|
|
|
ch->UnregisterEventHandler();
|
|
|
|
}
|
|
|
|
break;
|
2016-03-15 23:23:45 +00:00
|
|
|
case ETraversalMode::Single:
|
2016-03-14 00:58:19 +00:00
|
|
|
DoUnregisterEventHandler();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
UnregisterEventHandler();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiWidget::DoUnregisterEventHandler()
|
|
|
|
{
|
2016-03-15 23:23:45 +00:00
|
|
|
for (auto& item : xcc_triggerMap)
|
|
|
|
for (std::unique_ptr<CGuiLogicalEventTrigger>& trigger : *item.second)
|
2016-03-14 00:58:19 +00:00
|
|
|
xc8_frame->ClearMessageMap(trigger.get(), x7c_selfId);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::RegisterEventHandler()
|
|
|
|
{
|
|
|
|
bool flag = DoRegisterEventHandler();
|
|
|
|
if (!flag)
|
|
|
|
{
|
|
|
|
CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (ch)
|
|
|
|
ch->RegisterEventHandler();
|
|
|
|
}
|
|
|
|
CGuiWidget* sib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (sib && flag)
|
|
|
|
sib->RegisterEventHandler();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::RegisterEventHandler(ETraversalMode mode)
|
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
2016-03-15 23:23:45 +00:00
|
|
|
case ETraversalMode::Children:
|
2016-03-14 00:58:19 +00:00
|
|
|
if (!DoRegisterEventHandler())
|
|
|
|
{
|
|
|
|
CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (ch)
|
|
|
|
ch->RegisterEventHandler();
|
|
|
|
}
|
|
|
|
break;
|
2016-03-15 23:23:45 +00:00
|
|
|
case ETraversalMode::Single:
|
2016-03-14 00:58:19 +00:00
|
|
|
DoRegisterEventHandler();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
RegisterEventHandler();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiWidget::DoRegisterEventHandler()
|
|
|
|
{
|
2016-03-15 23:23:45 +00:00
|
|
|
if (xf6_28_eventLock || !GetIsActive())
|
2016-03-14 00:58:19 +00:00
|
|
|
return false;
|
2016-03-15 23:23:45 +00:00
|
|
|
for (auto& item : xcc_triggerMap)
|
|
|
|
for (std::unique_ptr<CGuiLogicalEventTrigger>& trigger : *item.second)
|
2016-03-14 00:58:19 +00:00
|
|
|
xc8_frame->AddMessageMap(trigger.get(), x7c_selfId);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-03-15 23:23:45 +00:00
|
|
|
CGuiWidget* CGuiWidget::RemoveChildWidget(CGuiWidget* widget, bool makeWorldLocal)
|
|
|
|
{
|
|
|
|
return static_cast<CGuiWidget*>(RemoveChildObject(widget, makeWorldLocal));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::AddChildWidget(CGuiWidget* widget, bool makeWorldLocal, bool atEnd)
|
|
|
|
{
|
|
|
|
AddChildObject(widget, makeWorldLocal, atEnd);
|
|
|
|
}
|
|
|
|
|
2016-03-16 20:49:35 +00:00
|
|
|
bool CGuiWidget::AddWorkerWidget(CGuiWidget* worker)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-03-15 23:23:45 +00:00
|
|
|
void CGuiWidget::AddAnim(EGuiAnimBehListID id, CGuiAnimBase* anim)
|
|
|
|
{
|
|
|
|
if (!xb0_animController)
|
|
|
|
{
|
|
|
|
xb0_animController.reset(new CGuiAnimController(
|
|
|
|
CGuiWidgetParms(xc8_frame, false, -1, -1, false, false, false,
|
2016-03-17 22:19:25 +00:00
|
|
|
zeus::CColor::skWhite, EGuiModelDrawFlags::Alpha, true, false), this));
|
2016-03-15 23:23:45 +00:00
|
|
|
}
|
|
|
|
xb0_animController->AddAnimation(anim, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::ResetAllAnimUpdateState()
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
xb0_animController->ResetListUpdateState();
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->ResetAllAnimUpdateState();
|
|
|
|
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (nextSib)
|
|
|
|
nextSib->ResetAllAnimUpdateState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::SetVisibility(bool vis, ETraversalMode mode)
|
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case ETraversalMode::Children:
|
|
|
|
{
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->SetVisibility(vis, ETraversalMode::ChildrenAndSiblings);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ETraversalMode::ChildrenAndSiblings:
|
|
|
|
{
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->SetVisibility(vis, ETraversalMode::ChildrenAndSiblings);
|
|
|
|
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (nextSib)
|
|
|
|
nextSib->SetVisibility(vis, ETraversalMode::ChildrenAndSiblings);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
SetIsVisible(vis);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::SetAnimUpdateState(EGuiAnimBehListID id, bool state)
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
xb0_animController->SetListUpdateState(id, state);
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->SetAnimUpdateState(id, state);
|
|
|
|
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (nextSib)
|
|
|
|
nextSib->SetAnimUpdateState(id, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::SetAnimUpdateState(EGuiAnimBehListID id, bool state, ETraversalMode mode)
|
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case ETraversalMode::Children:
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
xb0_animController->SetListUpdateState(id, state);
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->SetAnimUpdateState(id, state);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ETraversalMode::Single:
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
xb0_animController->SetListUpdateState(id, state);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
SetAnimUpdateState(id, state);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::GetBranchAnimLen(EGuiAnimBehListID id, float& len)
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
{
|
|
|
|
float aLen = xb0_animController->GetAnimSetLength(id);
|
|
|
|
if (aLen > len)
|
|
|
|
len = aLen;
|
|
|
|
}
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->GetBranchAnimLen(id, len);
|
|
|
|
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (nextSib)
|
|
|
|
nextSib->GetBranchAnimLen(id, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::GetBranchAnimLen(EGuiAnimBehListID id, float& len, ETraversalMode mode)
|
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case ETraversalMode::Children:
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
{
|
|
|
|
float aLen = xb0_animController->GetAnimSetLength(id);
|
|
|
|
if (aLen > len)
|
|
|
|
len = aLen;
|
|
|
|
}
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->GetBranchAnimLen(id, len);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ETraversalMode::Single:
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
{
|
|
|
|
float aLen = xb0_animController->GetAnimSetLength(id);
|
|
|
|
if (aLen > len)
|
|
|
|
len = aLen;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
GetBranchAnimLen(id, len);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::IsAllAnimsDone(EGuiAnimBehListID id, bool& isDone)
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
{
|
|
|
|
if (!isDone)
|
|
|
|
return;
|
|
|
|
xb0_animController->IsAnimsDone(id, isDone);
|
|
|
|
}
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->IsAllAnimsDone(id, isDone);
|
|
|
|
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (nextSib)
|
|
|
|
nextSib->IsAllAnimsDone(id, isDone);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::IsAllAnimsDone(EGuiAnimBehListID id, bool& isDone, ETraversalMode mode)
|
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case ETraversalMode::Children:
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
{
|
|
|
|
xb0_animController->IsAnimsDone(id, isDone);
|
|
|
|
if (!isDone)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->IsAllAnimsDone(id, isDone);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ETraversalMode::Single:
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
xb0_animController->IsAnimsDone(id, isDone);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
IsAllAnimsDone(id, isDone);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::InitializeAnimControllers(EGuiAnimBehListID id, float fval, bool flag,
|
|
|
|
EGuiAnimInitMode initMode)
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
xb0_animController->InitTransform(this, id, fval, flag, initMode);
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->InitializeAnimControllers(id, fval, flag, initMode);
|
|
|
|
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (nextSib)
|
|
|
|
nextSib->InitializeAnimControllers(id, fval, flag, initMode);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::InitializeAnimControllers(EGuiAnimBehListID id, float fval, bool flag,
|
|
|
|
EGuiAnimInitMode initMode, ETraversalMode mode)
|
|
|
|
{
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case ETraversalMode::Children:
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
xb0_animController->InitTransform(this, id, fval, flag, initMode);
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->InitializeAnimControllers(id, fval, flag, initMode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ETraversalMode::Single:
|
|
|
|
{
|
|
|
|
if (xb0_animController)
|
|
|
|
xb0_animController->InitTransform(this, id, fval, flag, initMode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
InitializeAnimControllers(id, fval, flag, initMode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::RecalcWidgetColor(ETraversalMode mode)
|
|
|
|
{
|
|
|
|
CGuiWidget* parent = static_cast<CGuiWidget*>(GetParent());
|
|
|
|
if (parent)
|
|
|
|
xc0_color2 = xbc_color * parent->xc0_color2;
|
|
|
|
else
|
|
|
|
xc0_color2 = xbc_color;
|
|
|
|
xb4_ = xb8_ + xc0_color2;
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
{
|
|
|
|
case ETraversalMode::ChildrenAndSiblings:
|
|
|
|
{
|
|
|
|
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (nextSib)
|
|
|
|
nextSib->RecalcWidgetColor(ETraversalMode::ChildrenAndSiblings);
|
|
|
|
}
|
|
|
|
case ETraversalMode::Children:
|
|
|
|
{
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
child->RecalcWidgetColor(ETraversalMode::ChildrenAndSiblings);
|
|
|
|
}
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CGuiWidget* CGuiWidget::FindWidget(s16 id)
|
|
|
|
{
|
|
|
|
if (x7c_selfId == id)
|
|
|
|
return this;
|
|
|
|
CGuiWidget* child = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (child)
|
|
|
|
{
|
|
|
|
CGuiWidget* found = child->FindWidget(id);
|
|
|
|
if (found)
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
CGuiWidget* nextSib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (nextSib)
|
|
|
|
{
|
|
|
|
CGuiWidget* found = nextSib->FindWidget(id);
|
|
|
|
if (found)
|
|
|
|
return found;
|
|
|
|
}
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiWidget::GetIsFinishedLoading() const
|
|
|
|
{
|
|
|
|
bool widgetFinished = GetIsFinishedLoadingWidgetSpecific();
|
|
|
|
if (!xb0_animController)
|
|
|
|
return widgetFinished;
|
|
|
|
return widgetFinished && xb0_animController->GetIsFinishedLoading();
|
|
|
|
}
|
2016-03-14 00:58:19 +00:00
|
|
|
|
|
|
|
void CGuiWidget::InitializeRecursive()
|
|
|
|
{
|
|
|
|
Initialize();
|
|
|
|
CGuiWidget* ch = static_cast<CGuiWidget*>(GetChildObject());
|
|
|
|
if (ch)
|
|
|
|
ch->InitializeRecursive();
|
|
|
|
CGuiWidget* sib = static_cast<CGuiWidget*>(GetNextSibling());
|
|
|
|
if (sib)
|
|
|
|
sib->InitializeRecursive();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::SetColor(const zeus::CColor& color)
|
|
|
|
{
|
|
|
|
xbc_color = color;
|
2016-03-15 23:23:45 +00:00
|
|
|
RecalcWidgetColor(ETraversalMode::Children);
|
2016-03-14 00:58:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CGuiWidget::OnDeActivate() {}
|
|
|
|
void CGuiWidget::OnActivate(bool) {}
|
|
|
|
void CGuiWidget::OnInvisible() {}
|
|
|
|
void CGuiWidget::OnVisible() {}
|
|
|
|
|
2016-03-15 23:23:45 +00:00
|
|
|
void CGuiWidget::SetIsVisible(bool vis)
|
|
|
|
{
|
|
|
|
xf6_25_isVisible = vis;
|
|
|
|
if (vis)
|
|
|
|
OnVisible();
|
|
|
|
else
|
|
|
|
OnInvisible();
|
|
|
|
}
|
|
|
|
|
2016-03-14 00:58:19 +00:00
|
|
|
void CGuiWidget::SetIsActive(bool a, bool b)
|
|
|
|
{
|
|
|
|
if (a == xf6_26_isActive)
|
|
|
|
return;
|
|
|
|
xf6_26_isActive = a;
|
|
|
|
if (a)
|
|
|
|
{
|
2016-03-15 23:23:45 +00:00
|
|
|
RegisterEventHandler(ETraversalMode::Children);
|
2016-03-14 00:58:19 +00:00
|
|
|
OnActivate(b);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-03-15 23:23:45 +00:00
|
|
|
RegisterEventHandler(ETraversalMode::Children);
|
2016-03-14 00:58:19 +00:00
|
|
|
OnDeActivate();
|
|
|
|
}
|
2016-03-11 22:50:15 +00:00
|
|
|
}
|
|
|
|
|
2016-03-11 00:23:16 +00:00
|
|
|
bool CGuiWidget::MAF_StartAnimationSet(CGuiFunctionDef* def, CGuiControllerInfo* info)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiWidget::MAF_SendMessage(CGuiFunctionDef* def, CGuiControllerInfo* info)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiWidget::MAF_PauseAnim(CGuiFunctionDef* def, CGuiControllerInfo* info)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiWidget::MAF_ResumeAnim(CGuiFunctionDef* def, CGuiControllerInfo* info)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiWidget::MAF_SetState(CGuiFunctionDef* def, CGuiControllerInfo* info)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGuiWidget::MAF_SetStateOfWidget(CGuiFunctionDef* def, CGuiControllerInfo* info)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-03-10 03:47:37 +00:00
|
|
|
}
|