mirror of
https://github.com/zeldaret/ss
synced 2026-08-20 14:14:40 -04:00
lyt_layout progress
This commit is contained in:
@@ -12,7 +12,6 @@ using namespace ut;
|
||||
// EqualsResName__Q34nw4r3lyt6detailFPCcPCc
|
||||
bool detail::EqualsResName(const char *name1, const char *name2) {
|
||||
return strncmp(name1, name2, NW4R_RES_NAME_SIZE) == 0;
|
||||
;
|
||||
}
|
||||
|
||||
// EqualsMaterialName__Q34nw4r3lyt6detailFPCcPCc
|
||||
@@ -22,7 +21,7 @@ bool detail::EqualsMaterialName(const char *name1, const char *name2) {
|
||||
|
||||
// TestFileHeader__Q34nw4r3lyt6detailFRCQ44nw4r3lyt3res16BinaryFileHeaderUl
|
||||
bool detail::TestFileHeader(const res::BinaryFileHeader &fileHeader, u32 testSig) {
|
||||
return ((testSig == fileHeader.magic) && (fileHeader.byteOrder == NW4R_BYTEORDER_BIG));
|
||||
return ((testSig == detail::GetSignatureInt(fileHeader.signature)) && (fileHeader.byteOrder == NW4R_BYTEORDER_BIG));
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -10,7 +10,8 @@ Group::Group(const res::Group *pResGroup, Pane *pRootPane) : mLink(), mPaneListL
|
||||
Init();
|
||||
strncpy(this->mName, pResGroup->mName, NW4R_RES_NAME_SIZE);
|
||||
this->mName[NW4R_RES_NAME_SIZE] = '\0';
|
||||
const char *paneNameBase = (char *)(&pResGroup[1]);
|
||||
const char *paneNameBase = detail::ConvertOffsetToPtr<char>(pResGroup, sizeof(res::Group));
|
||||
|
||||
for (int i = 0; i < pResGroup->paneNum; i++) {
|
||||
Pane *pFindPane = pRootPane->FindPaneByName(paneNameBase + i * NW4R_RES_NAME_SIZE, true);
|
||||
if (pFindPane) {
|
||||
@@ -49,7 +50,7 @@ GroupContainer::~GroupContainer() {
|
||||
while (it != this->mGroupList.GetEndIter()) {
|
||||
ut::LinkList<Group, 4>::Iterator currIt = it++;
|
||||
this->mGroupList.Erase(currIt);
|
||||
if (!currIt->mbUserAllocated) {
|
||||
if (!currIt->IsUserAllocated()) {
|
||||
Layout::DeleteObj<Group>(&*currIt);
|
||||
}
|
||||
}
|
||||
@@ -64,7 +65,7 @@ void GroupContainer::AppendGroup(Group *pGroup) {
|
||||
Group *GroupContainer::FindGroupByName(const char *findName) {
|
||||
for (ut::LinkList<Group, 4>::Iterator it = this->mGroupList.GetBeginIter(); it != this->mGroupList.GetEndIter();
|
||||
it++) {
|
||||
if (detail::EqualsResName(it->mName, findName)) {
|
||||
if (detail::EqualsResName(it->GetName(), findName)) {
|
||||
return &*it;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
#include <nw4r/lyt/lyt_animation.h>
|
||||
#include <nw4r/lyt/lyt_bounding.h>
|
||||
#include <nw4r/lyt/lyt_group.h>
|
||||
#include <nw4r/lyt/lyt_layout.h>
|
||||
#include <nw4r/lyt/lyt_picture.h>
|
||||
#include <nw4r/lyt/lyt_textBox.h>
|
||||
#include <nw4r/lyt/lyt_window.h>
|
||||
#include <nw4r/ut/ut_RuntimeTypeInfo.h>
|
||||
#include <nw4r/ut/ut_TagProcessorBase.h>
|
||||
|
||||
namespace nw4r {
|
||||
|
||||
namespace lyt {
|
||||
|
||||
// mspAllocator__Q34nw4r3lyt6Layout
|
||||
MEMAllocator *Layout::mspAllocator;
|
||||
|
||||
namespace {
|
||||
|
||||
// SetTagProcessorImpl__Q34nw4r3lyt24@unnamed@lyt_layout_cpp@FPQ34nw4r3lyt4PanePQ34nw4r2ut19TagProcessorBase<w>
|
||||
void SetTagProcessorImpl(Pane *pPane, ut::TagProcessorBase<wchar_t> *pTagProcessor) {
|
||||
TextBox *pTextBox = ut::DynamicCast<TextBox *>(pPane);
|
||||
if (pTextBox) {
|
||||
pTextBox->SetTagProcessor(pTagProcessor);
|
||||
}
|
||||
for (ut::LinkList<Pane, 4>::Iterator it = pPane->GetChildList()->GetBeginIter();
|
||||
it != pPane->GetChildList()->GetEndIter(); ++it) {
|
||||
SetTagProcessorImpl(&*it, pTagProcessor);
|
||||
}
|
||||
}
|
||||
|
||||
// IsIncludeAnimationGroupRef__Q34nw4r3lyt24@unnamed@lyt_layout_cpp@FPQ34nw4r3lyt14GroupContainerPCQ34nw4r3lyt17AnimationGroupRefUsbPQ34nw4r3lyt4Pane
|
||||
// Doesnt match DWARF Vars, but matches
|
||||
bool IsIncludeAnimationGroupRef(GroupContainer *pGroupContainer, const AnimationGroupRef *groupRefs, u16 bindGroupNum,
|
||||
bool bDescendingBind, Pane *pTargetPane) {
|
||||
for (u16 grpIdx = 0; grpIdx < bindGroupNum; grpIdx++) {
|
||||
Group *pGroup = pGroupContainer->FindGroupByName(groupRefs[grpIdx].name);
|
||||
for (ut::LinkList<detail::PaneLink, 0>::Iterator paneList = pGroup->GetPaneList()->GetBeginIter();
|
||||
paneList != pGroup->GetPaneList()->GetEndIter(); paneList++) {
|
||||
const Pane *t = paneList->mTarget;
|
||||
if (t == pTargetPane) {
|
||||
return true;
|
||||
}
|
||||
if (bDescendingBind) {
|
||||
for (const Pane *pParentPane = pTargetPane->GetParent(); pParentPane != nullptr;
|
||||
pParentPane = pParentPane->GetParent()) {
|
||||
if (t == pParentPane) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// __ct__Q34nw4r3lyt6LayoutFv
|
||||
Layout::Layout() : mAnimTransList(), mpRootPane(nullptr), mpGroupContainer(nullptr) {}
|
||||
|
||||
// __dt__Q34nw4r3lyt6LayoutFv
|
||||
Layout::~Layout() {
|
||||
DeleteObj(mpGroupContainer);
|
||||
if (mpRootPane && !mpRootPane->IsUserAllocated()) {
|
||||
DeleteObj(mpRootPane);
|
||||
}
|
||||
ut::LinkList<AnimTransform, 4>::Iterator it = mAnimTransList.GetBeginIter();
|
||||
while (it != mAnimTransList.GetEndIter()) {
|
||||
ut::LinkList<AnimTransform, 4>::Iterator currIt = it++;
|
||||
mAnimTransList.Erase(currIt);
|
||||
DeleteObj(&*currIt);
|
||||
}
|
||||
}
|
||||
|
||||
// Build__Q34nw4r3lyt6LayoutFPCvPQ34nw4r3lyt16ResourceAccessor
|
||||
bool Layout::Build(const void *lytResBuf, ResourceAccessor *pResAcsr) {
|
||||
const res::BinaryFileHeader *pFileHead = (const res::BinaryFileHeader *)(lytResBuf);
|
||||
if (!detail::TestFileHeader(*pFileHead, 'RLYT')) {
|
||||
return false;
|
||||
}
|
||||
if (!detail::TestFileVersion(*pFileHead)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ResBlockSet resBlockSet = {nullptr, nullptr, nullptr, pResAcsr};
|
||||
Pane *pParentPane = nullptr;
|
||||
Pane *pLastPane = nullptr;
|
||||
bool bReadRootGroup = false;
|
||||
int groupNestLevel = 0;
|
||||
|
||||
const void *dataPtr = ((u8 *)lytResBuf + pFileHead->headerSize);
|
||||
for (int i = 0; i < pFileHead->dataBlocks; i++) {
|
||||
const res::DataBlockHeader *pDataBlockHead = (const res::DataBlockHeader *)dataPtr;
|
||||
switch (pDataBlockHead->kind) {
|
||||
case 'lyt1': // Main Layout
|
||||
const res::Layout *pResLyt = ((const res::Layout *)dataPtr);
|
||||
mLayoutSize = pResLyt->layoutSize;
|
||||
break;
|
||||
case 'txl1': // Texture List
|
||||
resBlockSet.pTextureList = (const res::TextureList *)dataPtr;
|
||||
break;
|
||||
case 'fnl1': // Font List
|
||||
resBlockSet.pFontList = (const res::FontList *)dataPtr;
|
||||
break;
|
||||
case 'mat1': // Material
|
||||
resBlockSet.pMaterialList = (const res::MaterialList *)dataPtr;
|
||||
break;
|
||||
case 'wnd1': // Window
|
||||
case 'pan1': // Pane
|
||||
case 'pic1': // Picture
|
||||
case 'txt1': // Text Box
|
||||
case 'bnd1': // Boundary Pane
|
||||
Pane *pPane = BuildPaneObj(pDataBlockHead->kind, dataPtr, resBlockSet);
|
||||
if (pPane) {
|
||||
if (mpRootPane == nullptr) {
|
||||
mpRootPane = pPane;
|
||||
}
|
||||
if (pParentPane) {
|
||||
pParentPane->AppendChild(pPane);
|
||||
}
|
||||
pLastPane = pPane;
|
||||
}
|
||||
break;
|
||||
case 'usd1': // User Data
|
||||
pLastPane->SetExtUserDataList((const res::ExtUserDataList *)dataPtr);
|
||||
break;
|
||||
case 'pas1': // PaneChildren Start
|
||||
pParentPane = pLastPane;
|
||||
break;
|
||||
case 'pae1': // PaneChildren End
|
||||
pLastPane = pParentPane;
|
||||
pParentPane = pLastPane->GetParent();
|
||||
break;
|
||||
case 'grp1': // Group
|
||||
if (!bReadRootGroup) {
|
||||
bReadRootGroup = true;
|
||||
mpGroupContainer = NewObj<GroupContainer>();
|
||||
} else {
|
||||
if (mpGroupContainer && groupNestLevel == 1) {
|
||||
Group *pGroup = NewObj<Group>((const res::Group *)dataPtr, mpRootPane);
|
||||
if (pGroup) {
|
||||
mpGroupContainer->AppendGroup(pGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'grs1': // Group Children Start
|
||||
groupNestLevel++;
|
||||
break;
|
||||
case 'gre1': // Group Children End
|
||||
groupNestLevel--;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
dataPtr = ((u8 *)dataPtr + pDataBlockHead->size);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// CreateAnimTransform__Q34nw4r3lyt6LayoutFv
|
||||
AnimTransform *Layout::CreateAnimTransform() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// CreateAnimTransform__Q34nw4r3lyt6LayoutFPCvPQ34nw4r3lyt16ResourceAccessor
|
||||
AnimTransform *Layout::CreateAnimTransform(const void *animResBuf, ResourceAccessor *pResAcsr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// CreateAnimTransform__Q34nw4r3lyt6LayoutFRCQ34nw4r3lyt12AnimResourcePQ34nw4r3lyt16ResourceAccessor
|
||||
AnimTransform *Layout::CreateAnimTransform(const AnimResource &animRes, ResourceAccessor *pResAcsr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// BindAnimation__Q34nw4r3lyt6LayoutFPQ34nw4r3lyt13AnimTransform
|
||||
void Layout::BindAnimation(AnimTransform *pAnimTrans) {}
|
||||
|
||||
// UnbindAnimation__Q34nw4r3lyt6LayoutFPQ34nw4r3lyt13AnimTransform
|
||||
void Layout::UnbindAnimation(AnimTransform *pAnimTrans) {}
|
||||
|
||||
// UnbindAllAnimation__Q34nw4r3lyt6LayoutFv
|
||||
void Layout::UnbindAllAnimation() {}
|
||||
|
||||
// BindAnimationAuto__Q34nw4r3lyt6LayoutFRCQ34nw4r3lyt12AnimResourcePQ34nw4r3lyt16ResourceAccessor
|
||||
bool Layout::BindAnimationAuto(const AnimResource &animRes, ResourceAccessor *pResAcsr) {
|
||||
return IsIncludeAnimationGroupRef(nullptr, nullptr, 0, 0, nullptr);
|
||||
}
|
||||
|
||||
// SetAnimationEnable__Q34nw4r3lyt6LayoutFPQ34nw4r3lyt13AnimTransformb
|
||||
void Layout::SetAnimationEnable(AnimTransform *pAnimTrans, bool bEnable) {}
|
||||
|
||||
// CalculateMtx__Q34nw4r3lyt6LayoutFRCQ34nw4r3lyt8DrawInfo
|
||||
void Layout::CalculateMtx(const DrawInfo &drawInfo) {}
|
||||
|
||||
// Draw__Q34nw4r3lyt6LayoutFRCQ34nw4r3lyt8DrawInfo
|
||||
void Layout::Draw(const DrawInfo &drawInfo) {}
|
||||
|
||||
// Animate__Q34nw4r3lyt6LayoutFUl
|
||||
void Layout::Animate(u32 option) {}
|
||||
|
||||
// GetLayoutRect__Q34nw4r3lyt6LayoutCFv
|
||||
ut::Rect Layout::GetLayoutRect() const {}
|
||||
|
||||
// SetTagProcessor__Q34nw4r3lyt6LayoutFPQ34nw4r2ut19TagProcessorBase<w>
|
||||
void Layout::SetTagProcessor(ut::TagProcessorBase<wchar_t> *pTagProcessor) {
|
||||
SetTagProcessorImpl(this->mpRootPane, pTagProcessor);
|
||||
}
|
||||
|
||||
// BuildPaneObj__Q34nw4r3lyt6LayoutFlPCvRCQ34nw4r3lyt11ResBlockSet
|
||||
Pane *Layout::BuildPaneObj(s32 kind, const void *dataPtr, const ResBlockSet &resBlockSet) {
|
||||
// Oddly enough the breaks are required here to not inline the function???
|
||||
// Had them as left over from editing and somehow when removing them it just broke Build.
|
||||
// Probably some analysis depth as 3 break statements do it
|
||||
switch (kind) {
|
||||
case 'pan1': {
|
||||
const res::Pane *pResPane = (const res::Pane *)dataPtr;
|
||||
return NewObj<Pane>(pResPane);
|
||||
} break;
|
||||
case 'pic1': {
|
||||
const res::Picture *pResPic = (const res::Picture *)dataPtr;
|
||||
return NewObj<Picture>(pResPic, resBlockSet);
|
||||
} break;
|
||||
case 'txt1': {
|
||||
const res::TextBox *pBlock = (const res::TextBox *)dataPtr;
|
||||
return NewObj<TextBox>(pBlock, resBlockSet);
|
||||
} break;
|
||||
case 'wnd1': {
|
||||
const res::Window *pBlock = (const res::Window *)dataPtr;
|
||||
return NewObj<Window>(pBlock, resBlockSet);
|
||||
} break;
|
||||
case 'bnd1': {
|
||||
const res::Bounding *pResBounding = (const res::Bounding *)dataPtr;
|
||||
return NewObj<Bounding>(pResBounding, resBlockSet);
|
||||
} break;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace lyt
|
||||
|
||||
} // namespace nw4r
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
// SetupGX__Q34nw4r3lyt8MaterialFbUc
|
||||
// BindAnimation__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransform
|
||||
// UnbindAnimation__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransform
|
||||
// UnbindAllAnimation__Q34nw4r3lyt8MaterialFv
|
||||
// Animate__Q34nw4r3lyt8MaterialFv
|
||||
// FindAnimationLink__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransform
|
||||
// FindAnimationLink__Q34nw4r3lyt8MaterialFRCQ34nw4r3lyt12AnimResource
|
||||
// SetAnimationEnable__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransformb
|
||||
// SetAnimationEnable__Q34nw4r3lyt8MaterialFRCQ34nw4r3lyt12AnimResourceb
|
||||
|
||||
+29
-20
@@ -8,12 +8,6 @@
|
||||
#include <nw4r/ut/ut_list.h>
|
||||
|
||||
// ReverseYAxis__22@unnamed@lyt_pane_cpp@FPQ34nw4r4math5MTX34
|
||||
|
||||
void float_order() {
|
||||
0.0f;
|
||||
1.0f;
|
||||
}
|
||||
|
||||
namespace nw4r {
|
||||
|
||||
namespace lyt {
|
||||
@@ -29,6 +23,23 @@ PaneBase::~PaneBase() {}
|
||||
NW4R_UT_RTTI_DEF_BASE(Pane);
|
||||
|
||||
// __ct__Q34nw4r3lyt4PaneFv
|
||||
// Guess pulled from BBA/slight modified
|
||||
Pane::Pane() : mChildList(), mAnimList(), mSize() {
|
||||
this->mpParent = nullptr;
|
||||
this->mpMaterial = nullptr;
|
||||
this->mbUserAllocated = false;
|
||||
this->mpExtUserDataList = nullptr;
|
||||
this->mBasePosition = 4;
|
||||
memset(this->mName, 0, PANE_NAME_SIZE + 1);
|
||||
memset(this->mUserData, 0, PANE_USERDATA_SIZE + 1);
|
||||
this->mTranslate = math::VEC3(0.0f, 0.0f, 0.0f);
|
||||
this->mRotate = math::VEC3(0.0f, 0.0f, 0.0f);
|
||||
this->mScale = math::VEC2(1.0f, 1.0f);
|
||||
this->mSize = Size();
|
||||
this->mAlpha = 0xFF;
|
||||
this->mGlbAlpha = 0xFF;
|
||||
SetVisible(true);
|
||||
}
|
||||
|
||||
// __dt__Q34nw4r2ut38LinkList<Q34nw4r3lyt13AnimationLink,0>Fv
|
||||
|
||||
@@ -69,12 +80,12 @@ Pane::~Pane() {
|
||||
ut::LinkList<Pane, 4>::Iterator currIt = it++;
|
||||
mChildList.Erase(currIt);
|
||||
if (!currIt->mbUserAllocated) {
|
||||
Layout::DeleteObj<Pane>(&*currIt);
|
||||
Layout::DeleteObj(&*currIt);
|
||||
}
|
||||
}
|
||||
this->UnbindAnimationSelf(nullptr);
|
||||
if (this->mpMaterial && !this->mpMaterial->mbUserAllocated) {
|
||||
Layout::DeleteObj<Material>(this->mpMaterial);
|
||||
if (this->mpMaterial && !this->mpMaterial->IsUserAllocated()) {
|
||||
Layout::DeleteObj(this->mpMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,7 +200,7 @@ Pane *Pane::FindPaneByName(const char *findName, bool bRecursive) {
|
||||
|
||||
// FindMaterialByName__Q34nw4r3lyt4PaneFPCcb
|
||||
Material *Pane::FindMaterialByName(const char *findName, bool bRecursive) {
|
||||
if (this->mpMaterial && detail::EqualsMaterialName(this->mpMaterial->mName, findName)) {
|
||||
if (this->mpMaterial && detail::EqualsMaterialName(this->mpMaterial->GetName(), findName)) {
|
||||
return this->mpMaterial;
|
||||
}
|
||||
if (bRecursive) {
|
||||
@@ -501,34 +512,32 @@ u16 Pane::GetExtUserDataNum() const {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
ExtUserData *Pane::GetExtUserData() const {
|
||||
res::ExtUserData *Pane::GetExtUserData() const {
|
||||
if (this->mpExtUserDataList) {
|
||||
return (ExtUserData *)(this->mpExtUserDataList + 1);
|
||||
return detail::ConvertOffsetToPtr<res::ExtUserData>(this->mpExtUserDataList, sizeof(res::ExtUserDataList));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ExtUserData *Pane::FindExtUserDataByName(const char *name) {
|
||||
ExtUserData *pUserData = GetExtUserData();
|
||||
res::ExtUserData *Pane::FindExtUserDataByName(const char *name) {
|
||||
res::ExtUserData *pUserData = GetExtUserData();
|
||||
|
||||
if (!pUserData) {
|
||||
return nullptr;
|
||||
}
|
||||
int i = 0;
|
||||
for (int i = 0; i < this->mpExtUserDataList->num;) {
|
||||
u32 offset = pUserData->stringOffs;
|
||||
for (int i = 0; i < this->mpExtUserDataList->num; i++, pUserData++) {
|
||||
u32 offset = pUserData->nameOffs;
|
||||
const char *str = 0;
|
||||
if (offset != 0) {
|
||||
str = (const char *)(pUserData) + offset;
|
||||
str = detail::ConvertOffsetToPtr<char>(pUserData, offset);
|
||||
} else {
|
||||
str = 0;
|
||||
str = nullptr;
|
||||
}
|
||||
|
||||
if (strcmp(name, str) == 0) {
|
||||
return pUserData;
|
||||
};
|
||||
i++;
|
||||
pUserData++;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user