lyt_group matching

This commit is contained in:
elijah-thomas774
2024-05-23 01:05:22 -04:00
parent 08e0e57034
commit 752f760c32
8 changed files with 107 additions and 17 deletions
+4
View File
@@ -328,6 +328,10 @@ nw4r/lyt/lyt_pane.cpp:
.sbss start:0x805766F0 end:0x805766F8
.sdata2 start:0x8057F220 end:0x8057F240
nw4r/lyt/lyt_group.cpp:
.text start:0x80487EB0 end:0x8048820C
.data start:0x8056E4A8 end:0x8056E4B4
nw4r/lyt/lyt_resourceAccessor.cpp:
.text start:0x80492000 end:0x80492058
.data start:0x8056E7E0 end:0x8056E7F8
+1 -1
View File
@@ -37073,7 +37073,7 @@ lbl_8056E350 = .data:0x8056E350; // type:object size:0x38
lbl_8056E388 = .data:0x8056E388; // type:object size:0x60
lbl_8056E3E8 = .data:0x8056E3E8; // type:object size:0x46 scope:local data:string
__vt__Q34nw4r3lyt4Pane = .data:0x8056E430; // type:object size:0x74
lbl_8056E4A8 = .data:0x8056E4A8; // type:object size:0x10
__vt__Q34nw4r3lyt5Group = .data:0x8056E4A8; // type:object size:0xC
lbl_8056E4B8 = .data:0x8056E4B8; // type:object size:0x40
lbl_8056E4F8 = .data:0x8056E4F8; // type:object size:0x78
lbl_8056E570 = .data:0x8056E570; // type:object size:0x88
+1
View File
@@ -354,6 +354,7 @@ config.libs = [
[
Object(Matching, "nw4r/lyt/lyt_init.cpp"),
Object(Matching, "nw4r/lyt/lyt_pane.cpp"),
Object(Matching, "nw4r/lyt/lyt_group.cpp"),
Object(Matching, "nw4r/lyt/lyt_resourceAccessor.cpp"),
Object(Matching, "nw4r/lyt/lyt_arcResourceAccessor.cpp"),
Object(Matching, "nw4r/lyt/lyt_common.cpp"),
+1
View File
@@ -12,6 +12,7 @@ struct DrawInfo {
bool isYAxisUp() const {
// NYI
return false;
}
// field accessors
const math::VEC2 &GetLocationAdjustScale() const {
+16 -14
View File
@@ -9,37 +9,39 @@ namespace nw4r {
namespace lyt {
namespace res {
struct Group {
char UNK_0x0[0x8];
char mName[NW4R_RES_NAME_SIZE]; // at 0x8
u16 SHORT_0x18;
DataBlockHeader blockHeader; // at 0x00 "grp1"
char mName[NW4R_RES_NAME_SIZE]; // at 0x08
u16 paneNum; // at 0x18
u16 padding; // at 0x1A
};
} // namespace res
namespace detail {
struct PaneLink {
ut::LinkListNode mNode; // at 0x0
Pane *PANE_0x8;
ut::LinkListNode mLink; // at 0x0
Pane *mTarget; // at 0x08
};
} // namespace detail
struct Group {
Group(const res::Group *, Pane *);
Group(const res::Group *pResGroup, Pane *pRootPane);
virtual ~Group();
void AppendPane(Pane *);
void AppendPane(Pane *pPane);
void Init();
ut::LinkListNode mNode; // at 0x4
ut::LinkList<detail::PaneLink, 0> mPaneList; // at 0xC
char mName[NW4R_RES_NAME_SIZE]; // at 0x18
bool mIsUserAllocated; // at 0x29
ut::LinkListNode mLink; // at 0x04
ut::LinkList<detail::PaneLink, 0> mPaneListLink; // at 0x0C
char mName[NW4R_RES_NAME_SIZE + 1]; // at 0x18
bool mbUserAllocated; // at 0x29
u8 mPadding[2]; // at 0x2A
};
struct GroupContainer {
~GroupContainer();
void AppendGroup(Group *);
Group *FindGroupByName(const char *);
void AppendGroup(Group *pGroup);
Group *FindGroupByName(const char *findName);
ut::LinkList<Group, 4> mGroups; // at 0x4
ut::LinkList<Group, 4> mGroupList; // at 0x4
};
} // namespace lyt
} // namespace nw4r
+5 -1
View File
@@ -50,7 +50,11 @@ struct Layout {
template <typename T>
static T *NewObj() {
T *obj = (T *)AllocMemory(sizeof(T));
return new (obj) T();
if (obj) {
return new (obj) T();
} else {
return nullptr;
}
}
static MEMAllocator *mspAllocator;
+76
View File
@@ -0,0 +1,76 @@
#include <nw4r/lyt/lyt_group.h>
#include <nw4r/lyt/lyt_layout.h>
namespace nw4r {
namespace lyt {
// __ct__Q34nw4r3lyt5GroupFPCQ44nw4r3lyt3res5GroupPQ34nw4r3lyt4Pane
Group::Group(const res::Group *pResGroup, Pane *pRootPane) : mLink(), mPaneListLink() {
Init();
strncpy(this->mName, pResGroup->mName, NW4R_RES_NAME_SIZE);
this->mName[NW4R_RES_NAME_SIZE] = '\0';
const char *paneNameBase = (char *)(&pResGroup[1]);
for (int i = 0; i < pResGroup->paneNum; i++) {
Pane *pFindPane = pRootPane->FindPaneByName(paneNameBase + i * NW4R_RES_NAME_SIZE, true);
if (pFindPane) {
AppendPane(pFindPane);
}
}
}
// Init__Q34nw4r3lyt5GroupFv
void Group::Init() {
this->mbUserAllocated = false;
}
// __dt__Q34nw4r3lyt5GroupFv
Group::~Group() {
ut::LinkList<detail::PaneLink, 0>::Iterator it = this->mPaneListLink.GetBeginIter();
while (it != this->mPaneListLink.GetEndIter()) {
ut::LinkList<detail::PaneLink, 0>::Iterator currIt = it++;
this->mPaneListLink.Erase(currIt);
Layout::DeleteObj<detail::PaneLink>(&*currIt);
}
}
// AppendPane__Q34nw4r3lyt5GroupFPQ34nw4r3lyt4Pane
void Group::AppendPane(Pane *pPane) {
detail::PaneLink *pPaneLink = Layout::NewObj<detail::PaneLink>();
if (pPaneLink) {
pPaneLink->mTarget = pPane;
this->mPaneListLink.PushBack(pPaneLink);
}
}
//__dt__Q34nw4r3lyt14GroupContainerFv
GroupContainer::~GroupContainer() {
ut::LinkList<Group, 4>::Iterator it = this->mGroupList.GetBeginIter();
while (it != this->mGroupList.GetEndIter()) {
ut::LinkList<Group, 4>::Iterator currIt = it++;
this->mGroupList.Erase(currIt);
if (!currIt->mbUserAllocated) {
Layout::DeleteObj<Group>(&*currIt);
}
}
}
// AppendGroup__Q34nw4r3lyt14GroupContainerFPQ34nw4r3lyt5Group
void GroupContainer::AppendGroup(Group *pGroup) {
this->mGroupList.PushBack(pGroup);
}
// FindGroupByName__Q34nw4r3lyt14GroupContainerFPCc
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)) {
return &*it;
}
}
return nullptr;
}
} // namespace lyt
} // namespace nw4r
+3 -1
View File
@@ -28,13 +28,13 @@ PaneBase::~PaneBase() {}
NW4R_UT_RTTI_DEF_BASE(Pane);
// 80486a70
// __ct__Q34nw4r3lyt4PaneFv
// __dt__Q34nw4r2ut38LinkList<Q34nw4r3lyt13AnimationLink,0>Fv
// __dt__Q34nw4r2ut28LinkList<Q34nw4r3lyt4Pane,4>Fv
// 80486a70
// __ct__Q34nw4r3lyt4PaneFPCQ44nw4r3lyt3res4Pane
Pane::Pane(const res::Pane *pBlock) : mChildList(), mAnimList(), mSize() {
this->mpParent = nullptr;
@@ -205,6 +205,8 @@ Material *Pane::FindMaterialByName(const char *findName, bool bRecursive) {
}
// CalculateMtx__Q34nw4r3lyt4PaneFRCQ34nw4r3lyt8DrawInfo
// Matches for SS, applying the rotation and scale seems to be different accross versions.
// Also look out for the Bottom CalculateMtxChild section. In other version this is actually seperated differently
void Pane::CalculateMtx(const DrawInfo &drawInfo) {
if (!IsVisible() && !drawInfo.IsInvisiblePaneCalculateMtx()) {
return;