From a8343ade6d33bf5bb0e880c4441ae7490f447511 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Wed, 28 Dec 2022 19:32:27 -0800 Subject: [PATCH] Add CGuiObject Former-commit-id: 957679cf97482959faad60f5c3ddea5410396a5f --- asm/GuiSys/CGuiGroup.s | 12 +-- asm/GuiSys/CGuiObject.s | 39 +++++----- asm/GuiSys/CGuiWidget.s | 47 ++++++------ asm/MetroidPrime/CInGameGuiManager.s | 2 +- asm/MetroidPrime/CPauseScreen.s | 4 +- asm/MetroidPrime/HUD/CHudDecoInterface.s | 4 +- asm/MetroidPrime/HUD/CSamusHud.s | 4 +- configure.py | 2 +- include/GuiSys/CGuiObject.hpp | 28 +++++-- include/Kyoto/Math/CVector3f.hpp | 1 + src/GuiSys/CGuiObject.cpp | 97 ++++++++++++++++++++++++ 11 files changed, 175 insertions(+), 65 deletions(-) create mode 100644 src/GuiSys/CGuiObject.cpp diff --git a/asm/GuiSys/CGuiGroup.s b/asm/GuiSys/CGuiGroup.s index 1af576c5..3a4cf0c5 100644 --- a/asm/GuiSys/CGuiGroup.s +++ b/asm/GuiSys/CGuiGroup.s @@ -678,7 +678,7 @@ OnVisible__18CGuiCompoundWidgetFv: /* 802C1A04 002BE964 93 E1 00 0C */ stw r31, 0xc(r1) /* 802C1A08 002BE968 93 C1 00 08 */ stw r30, 8(r1) /* 802C1A0C 002BE96C 7C 7E 1B 78 */ mr r30, r3 -/* 802C1A10 002BE970 48 00 33 21 */ bl GetChildObject__10CGuiObjectFv +/* 802C1A10 002BE970 48 00 33 21 */ bl ChildObject__10CGuiObjectFv /* 802C1A14 002BE974 7C 7F 1B 78 */ mr r31, r3 /* 802C1A18 002BE978 48 00 00 30 */ b lbl_802C1A48 lbl_802C1A1C: @@ -691,7 +691,7 @@ lbl_802C1A1C: /* 802C1A34 002BE994 7F E3 FB 78 */ mr r3, r31 /* 802C1A38 002BE998 48 00 8B F5 */ bl SetIsVisible__10CGuiWidgetFb /* 802C1A3C 002BE99C 7F E3 FB 78 */ mr r3, r31 -/* 802C1A40 002BE9A0 48 00 32 E1 */ bl GetNextSibling__10CGuiObjectFv +/* 802C1A40 002BE9A0 48 00 32 E1 */ bl NextSibling__10CGuiObjectFv /* 802C1A44 002BE9A4 7C 7F 1B 78 */ mr r31, r3 lbl_802C1A48: /* 802C1A48 002BE9A8 28 1F 00 00 */ cmplwi r31, 0 @@ -713,7 +713,7 @@ OnActivate__18CGuiCompoundWidgetFb: /* 802C1A7C 002BE9DC 93 E1 00 0C */ stw r31, 0xc(r1) /* 802C1A80 002BE9E0 93 C1 00 08 */ stw r30, 8(r1) /* 802C1A84 002BE9E4 7C 7E 1B 78 */ mr r30, r3 -/* 802C1A88 002BE9E8 48 00 32 A9 */ bl GetChildObject__10CGuiObjectFv +/* 802C1A88 002BE9E8 48 00 32 A9 */ bl ChildObject__10CGuiObjectFv /* 802C1A8C 002BE9EC 7C 7F 1B 78 */ mr r31, r3 /* 802C1A90 002BE9F0 48 00 00 30 */ b lbl_802C1AC0 lbl_802C1A94: @@ -726,7 +726,7 @@ lbl_802C1A94: /* 802C1AAC 002BEA0C 7F E3 FB 78 */ mr r3, r31 /* 802C1AB0 002BEA10 48 00 8B 35 */ bl SetIsActive__10CGuiWidgetFb /* 802C1AB4 002BEA14 7F E3 FB 78 */ mr r3, r31 -/* 802C1AB8 002BEA18 48 00 32 69 */ bl GetNextSibling__10CGuiObjectFv +/* 802C1AB8 002BEA18 48 00 32 69 */ bl NextSibling__10CGuiObjectFv /* 802C1ABC 002BEA1C 7C 7F 1B 78 */ mr r31, r3 lbl_802C1AC0: /* 802C1AC0 002BEA20 28 1F 00 00 */ cmplwi r31, 0 @@ -747,13 +747,13 @@ GetWorkerWidget__18CGuiCompoundWidgetFi: /* 802C1AF0 002BEA50 90 01 00 14 */ stw r0, 0x14(r1) /* 802C1AF4 002BEA54 93 E1 00 0C */ stw r31, 0xc(r1) /* 802C1AF8 002BEA58 7C 9F 23 78 */ mr r31, r4 -/* 802C1AFC 002BEA5C 48 00 32 3D */ bl GetChildObject__18CGuiCompoundWidgetFv +/* 802C1AFC 002BEA5C 48 00 32 3D */ bl GetChildObject__10CGuiObjectCFv /* 802C1B00 002BEA60 48 00 00 14 */ b lbl_802C1B14 lbl_802C1B04: /* 802C1B04 002BEA64 A8 03 00 B4 */ lha r0, 0xb4(r3) /* 802C1B08 002BEA68 7C 1F 00 00 */ cmpw r31, r0 /* 802C1B0C 002BEA6C 41 82 00 10 */ beq lbl_802C1B1C -/* 802C1B10 002BEA70 48 00 32 19 */ bl GetNextSibling__18CGuiCompoundWidgetFv +/* 802C1B10 002BEA70 48 00 32 19 */ bl GetNextSibling__10CGuiObjectCFv lbl_802C1B14: /* 802C1B14 002BEA74 28 03 00 00 */ cmplwi r3, 0 /* 802C1B18 002BEA78 40 82 FF EC */ bne lbl_802C1B04 diff --git a/asm/GuiSys/CGuiObject.s b/asm/GuiSys/CGuiObject.s index 24712de2..e74f91ab 100644 --- a/asm/GuiSys/CGuiObject.s +++ b/asm/GuiSys/CGuiObject.s @@ -3,8 +3,8 @@ .section .data .balign 8 -.global lbl_803EC8C8 -lbl_803EC8C8: +.global __vt__10CGuiObject +__vt__10CGuiObject: # ROM: 0x3E98C8 .4byte 0 .4byte 0 @@ -40,7 +40,7 @@ SetO2WTransform__10CGuiObjectFRC12CTransform4f: /* 802C4788 002C16E8 48 04 E3 ED */ bl __ct__12CTransform4fFRC12CTransform4f /* 802C478C 002C16EC 7F C3 F3 78 */ mr r3, r30 /* 802C4790 002C16F0 38 81 00 68 */ addi r4, r1, 0x68 -/* 802C4794 002C16F4 48 00 00 1D */ bl sub_802c47b0 +/* 802C4794 002C16F4 48 00 00 1D */ bl SetLocalTransform__10CGuiObjectFRC12CTransform4f /* 802C4798 002C16F8 80 01 00 D4 */ lwz r0, 0xd4(r1) /* 802C479C 002C16FC 83 E1 00 CC */ lwz r31, 0xcc(r1) /* 802C47A0 002C1700 83 C1 00 C8 */ lwz r30, 0xc8(r1) @@ -48,8 +48,8 @@ SetO2WTransform__10CGuiObjectFRC12CTransform4f: /* 802C47A8 002C1708 38 21 00 D0 */ addi r1, r1, 0xd0 /* 802C47AC 002C170C 4E 80 00 20 */ blr -.global sub_802c47b0 -sub_802c47b0: +.global SetLocalTransform__10CGuiObjectFRC12CTransform4f +SetLocalTransform__10CGuiObjectFRC12CTransform4f: /* 802C47B0 002C1710 94 21 FF F0 */ stwu r1, -0x10(r1) /* 802C47B4 002C1714 7C 08 02 A6 */ mflr r0 /* 802C47B8 002C1718 90 01 00 14 */ stw r0, 0x14(r1) @@ -446,28 +446,28 @@ lbl_802C4CF8: /* 802C4D10 002C1C70 38 21 02 F0 */ addi r1, r1, 0x2f0 /* 802C4D14 002C1C74 4E 80 00 20 */ blr -.global GetParent__10CGuiObjectFv -GetParent__10CGuiObjectFv: +.global Parent__10CGuiObjectFv +Parent__10CGuiObjectFv: /* 802C4D18 002C1C78 80 63 00 64 */ lwz r3, 0x64(r3) /* 802C4D1C 002C1C7C 4E 80 00 20 */ blr -.global GetNextSibling__10CGuiObjectFv -GetNextSibling__10CGuiObjectFv: +.global NextSibling__10CGuiObjectFv +NextSibling__10CGuiObjectFv: /* 802C4D20 002C1C80 80 63 00 6C */ lwz r3, 0x6c(r3) /* 802C4D24 002C1C84 4E 80 00 20 */ blr -.global GetNextSibling__18CGuiCompoundWidgetFv -GetNextSibling__18CGuiCompoundWidgetFv: +.global GetNextSibling__10CGuiObjectCFv +GetNextSibling__10CGuiObjectCFv: /* 802C4D28 002C1C88 80 63 00 6C */ lwz r3, 0x6c(r3) /* 802C4D2C 002C1C8C 4E 80 00 20 */ blr -.global GetChildObject__10CGuiObjectFv -GetChildObject__10CGuiObjectFv: +.global ChildObject__10CGuiObjectFv +ChildObject__10CGuiObjectFv: /* 802C4D30 002C1C90 80 63 00 68 */ lwz r3, 0x68(r3) /* 802C4D34 002C1C94 4E 80 00 20 */ blr -.global GetChildObject__18CGuiCompoundWidgetFv -GetChildObject__18CGuiCompoundWidgetFv: +.global GetChildObject__10CGuiObjectCFv +GetChildObject__10CGuiObjectCFv: /* 802C4D38 002C1C98 80 63 00 68 */ lwz r3, 0x68(r3) /* 802C4D3C 002C1C9C 4E 80 00 20 */ blr @@ -946,8 +946,8 @@ __dt__10CGuiObjectFv: /* 802C53E8 002C2348 93 C1 00 08 */ stw r30, 8(r1) /* 802C53EC 002C234C 7C 7E 1B 79 */ or. r30, r3, r3 /* 802C53F0 002C2350 41 82 00 70 */ beq lbl_802C5460 -/* 802C53F4 002C2354 3C 60 80 3F */ lis r3, lbl_803EC8C8@ha -/* 802C53F8 002C2358 38 03 C8 C8 */ addi r0, r3, lbl_803EC8C8@l +/* 802C53F4 002C2354 3C 60 80 3F */ lis r3, __vt__10CGuiObject@ha +/* 802C53F8 002C2358 38 03 C8 C8 */ addi r0, r3, __vt__10CGuiObject@l /* 802C53FC 002C235C 90 1E 00 00 */ stw r0, 0(r30) /* 802C5400 002C2360 80 7E 00 68 */ lwz r3, 0x68(r30) /* 802C5404 002C2364 28 03 00 00 */ cmplwi r3, 0 @@ -988,9 +988,9 @@ lbl_802C5460: __ct__10CGuiObjectFv: /* 802C547C 002C23DC 94 21 FF F0 */ stwu r1, -0x10(r1) /* 802C5480 002C23E0 7C 08 02 A6 */ mflr r0 -/* 802C5484 002C23E4 3C 80 80 3F */ lis r4, lbl_803EC8C8@ha +/* 802C5484 002C23E4 3C 80 80 3F */ lis r4, __vt__10CGuiObject@ha /* 802C5488 002C23E8 90 01 00 14 */ stw r0, 0x14(r1) -/* 802C548C 002C23EC 38 04 C8 C8 */ addi r0, r4, lbl_803EC8C8@l +/* 802C548C 002C23EC 38 04 C8 C8 */ addi r0, r4, __vt__10CGuiObject@l /* 802C5490 002C23F0 93 E1 00 0C */ stw r31, 0xc(r1) /* 802C5494 002C23F4 7C 7F 1B 78 */ mr r31, r3 /* 802C5498 002C23F8 3C 60 80 5A */ lis r3, sIdentity__12CTransform4f@ha @@ -1024,4 +1024,3 @@ lbl_805AE0B8: lbl_805AE0BC: # ROM: 0x3FA95C .float 1.0 - diff --git a/asm/GuiSys/CGuiWidget.s b/asm/GuiSys/CGuiWidget.s index b5ecb674..86f4cb9d 100644 --- a/asm/GuiSys/CGuiWidget.s +++ b/asm/GuiSys/CGuiWidget.s @@ -132,31 +132,31 @@ SetVisibility__10CGuiWidgetFb14ETraversalMode: /* 802CA718 002C7678 48 00 00 70 */ b lbl_802CA788 /* 802CA71C 002C767C 48 00 00 6C */ b lbl_802CA788 lbl_802CA720: -/* 802CA720 002C7680 4B FF A6 11 */ bl GetChildObject__10CGuiObjectFv +/* 802CA720 002C7680 4B FF A6 11 */ bl ChildObject__10CGuiObjectFv /* 802CA724 002C7684 28 03 00 00 */ cmplwi r3, 0 /* 802CA728 002C7688 41 82 00 60 */ beq lbl_802CA788 /* 802CA72C 002C768C 7F C3 F3 78 */ mr r3, r30 -/* 802CA730 002C7690 4B FF A6 01 */ bl GetChildObject__10CGuiObjectFv +/* 802CA730 002C7690 4B FF A6 01 */ bl ChildObject__10CGuiObjectFv /* 802CA734 002C7694 7F E4 FB 78 */ mr r4, r31 /* 802CA738 002C7698 38 A0 00 00 */ li r5, 0 /* 802CA73C 002C769C 4B FF FF AD */ bl SetVisibility__10CGuiWidgetFb14ETraversalMode /* 802CA740 002C76A0 48 00 00 48 */ b lbl_802CA788 lbl_802CA744: -/* 802CA744 002C76A4 4B FF A5 ED */ bl GetChildObject__10CGuiObjectFv +/* 802CA744 002C76A4 4B FF A5 ED */ bl ChildObject__10CGuiObjectFv /* 802CA748 002C76A8 28 03 00 00 */ cmplwi r3, 0 /* 802CA74C 002C76AC 41 82 00 18 */ beq lbl_802CA764 /* 802CA750 002C76B0 7F C3 F3 78 */ mr r3, r30 -/* 802CA754 002C76B4 4B FF A5 DD */ bl GetChildObject__10CGuiObjectFv +/* 802CA754 002C76B4 4B FF A5 DD */ bl ChildObject__10CGuiObjectFv /* 802CA758 002C76B8 7F E4 FB 78 */ mr r4, r31 /* 802CA75C 002C76BC 38 A0 00 00 */ li r5, 0 /* 802CA760 002C76C0 4B FF FF 89 */ bl SetVisibility__10CGuiWidgetFb14ETraversalMode lbl_802CA764: /* 802CA764 002C76C4 7F C3 F3 78 */ mr r3, r30 -/* 802CA768 002C76C8 4B FF A5 B9 */ bl GetNextSibling__10CGuiObjectFv +/* 802CA768 002C76C8 4B FF A5 B9 */ bl NextSibling__10CGuiObjectFv /* 802CA76C 002C76CC 28 03 00 00 */ cmplwi r3, 0 /* 802CA770 002C76D0 41 82 00 18 */ beq lbl_802CA788 /* 802CA774 002C76D4 7F C3 F3 78 */ mr r3, r30 -/* 802CA778 002C76D8 4B FF A5 A9 */ bl GetNextSibling__10CGuiObjectFv +/* 802CA778 002C76D8 4B FF A5 A9 */ bl NextSibling__10CGuiObjectFv /* 802CA77C 002C76DC 7F E4 FB 78 */ mr r4, r31 /* 802CA780 002C76E0 38 A0 00 00 */ li r5, 0 /* 802CA784 002C76E4 4B FF FF 65 */ bl SetVisibility__10CGuiWidgetFb14ETraversalMode @@ -180,7 +180,7 @@ RecalcWidgetColor__10CGuiWidgetF14ETraversalMode: /* 802CA7BC 002C771C 7C 9F 23 78 */ mr r31, r4 /* 802CA7C0 002C7720 93 C1 00 18 */ stw r30, 0x18(r1) /* 802CA7C4 002C7724 7C 7E 1B 78 */ mr r30, r3 -/* 802CA7C8 002C7728 4B FF A5 51 */ bl GetParent__10CGuiObjectFv +/* 802CA7C8 002C7728 4B FF A5 51 */ bl Parent__10CGuiObjectFv /* 802CA7CC 002C772C 7C 65 1B 79 */ or. r5, r3, r3 /* 802CA7D0 002C7730 41 82 00 20 */ beq lbl_802CA7F0 /* 802CA7D4 002C7734 38 61 00 08 */ addi r3, r1, 8 @@ -203,20 +203,20 @@ lbl_802CA7F8: /* 802CA810 002C7770 48 00 00 44 */ b lbl_802CA854 lbl_802CA814: /* 802CA814 002C7774 7F C3 F3 78 */ mr r3, r30 -/* 802CA818 002C7778 4B FF A5 09 */ bl GetNextSibling__10CGuiObjectFv +/* 802CA818 002C7778 4B FF A5 09 */ bl NextSibling__10CGuiObjectFv /* 802CA81C 002C777C 28 03 00 00 */ cmplwi r3, 0 /* 802CA820 002C7780 41 82 00 14 */ beq lbl_802CA834 /* 802CA824 002C7784 7F C3 F3 78 */ mr r3, r30 -/* 802CA828 002C7788 4B FF A4 F9 */ bl GetNextSibling__10CGuiObjectFv +/* 802CA828 002C7788 4B FF A4 F9 */ bl NextSibling__10CGuiObjectFv /* 802CA82C 002C778C 38 80 00 00 */ li r4, 0 /* 802CA830 002C7790 4B FF FF 7D */ bl RecalcWidgetColor__10CGuiWidgetF14ETraversalMode lbl_802CA834: /* 802CA834 002C7794 7F C3 F3 78 */ mr r3, r30 -/* 802CA838 002C7798 4B FF A4 F9 */ bl GetChildObject__10CGuiObjectFv +/* 802CA838 002C7798 4B FF A4 F9 */ bl ChildObject__10CGuiObjectFv /* 802CA83C 002C779C 28 03 00 00 */ cmplwi r3, 0 /* 802CA840 002C77A0 41 82 00 14 */ beq lbl_802CA854 /* 802CA844 002C77A4 7F C3 F3 78 */ mr r3, r30 -/* 802CA848 002C77A8 4B FF A4 E9 */ bl GetChildObject__10CGuiObjectFv +/* 802CA848 002C77A8 4B FF A4 E9 */ bl ChildObject__10CGuiObjectFv /* 802CA84C 002C77AC 38 80 00 00 */ li r4, 0 /* 802CA850 002C77B0 4B FF FF 5D */ bl RecalcWidgetColor__10CGuiWidgetF14ETraversalMode lbl_802CA854: @@ -256,11 +256,11 @@ FindWidget__10CGuiWidgetFs: /* 802CA8C0 002C7820 40 82 00 08 */ bne lbl_802CA8C8 /* 802CA8C4 002C7824 48 00 00 5C */ b lbl_802CA920 lbl_802CA8C8: -/* 802CA8C8 002C7828 4B FF A4 69 */ bl GetChildObject__10CGuiObjectFv +/* 802CA8C8 002C7828 4B FF A4 69 */ bl ChildObject__10CGuiObjectFv /* 802CA8CC 002C782C 28 03 00 00 */ cmplwi r3, 0 /* 802CA8D0 002C7830 41 82 00 20 */ beq lbl_802CA8F0 /* 802CA8D4 002C7834 7F C3 F3 78 */ mr r3, r30 -/* 802CA8D8 002C7838 4B FF A4 59 */ bl GetChildObject__10CGuiObjectFv +/* 802CA8D8 002C7838 4B FF A4 59 */ bl ChildObject__10CGuiObjectFv /* 802CA8DC 002C783C 7F E4 FB 78 */ mr r4, r31 /* 802CA8E0 002C7840 4B FF FF B9 */ bl FindWidget__10CGuiWidgetFs /* 802CA8E4 002C7844 28 03 00 00 */ cmplwi r3, 0 @@ -268,11 +268,11 @@ lbl_802CA8C8: /* 802CA8EC 002C784C 48 00 00 34 */ b lbl_802CA920 lbl_802CA8F0: /* 802CA8F0 002C7850 7F C3 F3 78 */ mr r3, r30 -/* 802CA8F4 002C7854 4B FF A4 2D */ bl GetNextSibling__10CGuiObjectFv +/* 802CA8F4 002C7854 4B FF A4 2D */ bl NextSibling__10CGuiObjectFv /* 802CA8F8 002C7858 28 03 00 00 */ cmplwi r3, 0 /* 802CA8FC 002C785C 41 82 00 20 */ beq lbl_802CA91C /* 802CA900 002C7860 7F C3 F3 78 */ mr r3, r30 -/* 802CA904 002C7864 4B FF A4 1D */ bl GetNextSibling__10CGuiObjectFv +/* 802CA904 002C7864 4B FF A4 1D */ bl NextSibling__10CGuiObjectFv /* 802CA908 002C7868 7F E4 FB 78 */ mr r4, r31 /* 802CA90C 002C786C 4B FF FF 8D */ bl FindWidget__10CGuiWidgetFs /* 802CA910 002C7870 28 03 00 00 */ cmplwi r3, 0 @@ -314,19 +314,19 @@ DispatchInitialize__10CGuiWidgetFv: /* 802CA980 002C78E0 7D 89 03 A6 */ mtctr r12 /* 802CA984 002C78E4 4E 80 04 21 */ bctrl /* 802CA988 002C78E8 7F E3 FB 78 */ mr r3, r31 -/* 802CA98C 002C78EC 4B FF A3 A5 */ bl GetChildObject__10CGuiObjectFv +/* 802CA98C 002C78EC 4B FF A3 A5 */ bl ChildObject__10CGuiObjectFv /* 802CA990 002C78F0 28 03 00 00 */ cmplwi r3, 0 /* 802CA994 002C78F4 41 82 00 10 */ beq lbl_802CA9A4 /* 802CA998 002C78F8 7F E3 FB 78 */ mr r3, r31 -/* 802CA99C 002C78FC 4B FF A3 95 */ bl GetChildObject__10CGuiObjectFv +/* 802CA99C 002C78FC 4B FF A3 95 */ bl ChildObject__10CGuiObjectFv /* 802CA9A0 002C7900 4B FF FF C5 */ bl DispatchInitialize__10CGuiWidgetFv lbl_802CA9A4: /* 802CA9A4 002C7904 7F E3 FB 78 */ mr r3, r31 -/* 802CA9A8 002C7908 4B FF A3 79 */ bl GetNextSibling__10CGuiObjectFv +/* 802CA9A8 002C7908 4B FF A3 79 */ bl NextSibling__10CGuiObjectFv /* 802CA9AC 002C790C 28 03 00 00 */ cmplwi r3, 0 /* 802CA9B0 002C7910 41 82 00 10 */ beq lbl_802CA9C0 /* 802CA9B4 002C7914 7F E3 FB 78 */ mr r3, r31 -/* 802CA9B8 002C7918 4B FF A3 69 */ bl GetNextSibling__10CGuiObjectFv +/* 802CA9B8 002C7918 4B FF A3 69 */ bl NextSibling__10CGuiObjectFv /* 802CA9BC 002C791C 4B FF FF A9 */ bl DispatchInitialize__10CGuiWidgetFv lbl_802CA9C0: /* 802CA9C0 002C7920 80 01 00 14 */ lwz r0, 0x14(r1) @@ -344,11 +344,11 @@ Update__10CGuiWidgetFf: /* 802CA9E4 002C7944 FF E0 08 90 */ fmr f31, f1 /* 802CA9E8 002C7948 93 E1 00 14 */ stw r31, 0x14(r1) /* 802CA9EC 002C794C 7C 7F 1B 78 */ mr r31, r3 -/* 802CA9F0 002C7950 4B FF A3 41 */ bl GetChildObject__10CGuiObjectFv +/* 802CA9F0 002C7950 4B FF A3 41 */ bl ChildObject__10CGuiObjectFv /* 802CA9F4 002C7954 28 03 00 00 */ cmplwi r3, 0 /* 802CA9F8 002C7958 41 82 00 20 */ beq lbl_802CAA18 /* 802CA9FC 002C795C 7F E3 FB 78 */ mr r3, r31 -/* 802CAA00 002C7960 4B FF A3 31 */ bl GetChildObject__10CGuiObjectFv +/* 802CAA00 002C7960 4B FF A3 31 */ bl ChildObject__10CGuiObjectFv /* 802CAA04 002C7964 81 83 00 00 */ lwz r12, 0(r3) /* 802CAA08 002C7968 FC 20 F8 90 */ fmr f1, f31 /* 802CAA0C 002C796C 81 8C 00 0C */ lwz r12, 0xc(r12) @@ -356,11 +356,11 @@ Update__10CGuiWidgetFf: /* 802CAA14 002C7974 4E 80 04 21 */ bctrl lbl_802CAA18: /* 802CAA18 002C7978 7F E3 FB 78 */ mr r3, r31 -/* 802CAA1C 002C797C 4B FF A3 05 */ bl GetNextSibling__10CGuiObjectFv +/* 802CAA1C 002C797C 4B FF A3 05 */ bl NextSibling__10CGuiObjectFv /* 802CAA20 002C7980 28 03 00 00 */ cmplwi r3, 0 /* 802CAA24 002C7984 41 82 00 20 */ beq lbl_802CAA44 /* 802CAA28 002C7988 7F E3 FB 78 */ mr r3, r31 -/* 802CAA2C 002C798C 4B FF A2 F5 */ bl GetNextSibling__10CGuiObjectFv +/* 802CAA2C 002C798C 4B FF A2 F5 */ bl NextSibling__10CGuiObjectFv /* 802CAA30 002C7990 81 83 00 00 */ lwz r12, 0(r3) /* 802CAA34 002C7994 FC 20 F8 90 */ fmr f1, f31 /* 802CAA38 002C7998 81 8C 00 0C */ lwz r12, 0xc(r12) @@ -739,4 +739,3 @@ lbl_803D68F8: .asciz "Warning: Discarding useless worker id. Parent is not a compound widget." .byte 0x3F, 0x3F, 0x28 .4byte 0x3F3F2900 - diff --git a/asm/MetroidPrime/CInGameGuiManager.s b/asm/MetroidPrime/CInGameGuiManager.s index 857b5fc1..edec828c 100644 --- a/asm/MetroidPrime/CInGameGuiManager.s +++ b/asm/MetroidPrime/CInGameGuiManager.s @@ -1365,7 +1365,7 @@ UpdateAutoMapper__17CInGameGuiManagerFR13CStateManagerf: /* 80107BC4 00104B24 80 9F 01 44 */ lwz r4, 0x144(r31) /* 80107BC8 00104B28 80 7F 01 48 */ lwz r3, 0x148(r31) /* 80107BCC 00104B2C 3B C4 00 74 */ addi r30, r4, 0x74 -/* 80107BD0 00104B30 48 1B D1 49 */ bl GetParent__10CGuiObjectFv +/* 80107BD0 00104B30 48 1B D1 49 */ bl Parent__10CGuiObjectFv /* 80107BD4 00104B34 7C 64 1B 78 */ mr r4, r3 /* 80107BD8 00104B38 7F C5 F3 78 */ mr r5, r30 /* 80107BDC 00104B3C 38 61 03 98 */ addi r3, r1, 0x398 diff --git a/asm/MetroidPrime/CPauseScreen.s b/asm/MetroidPrime/CPauseScreen.s index 8e62bc9a..d8b89de3 100644 --- a/asm/MetroidPrime/CPauseScreen.s +++ b/asm/MetroidPrime/CPauseScreen.s @@ -1815,7 +1815,7 @@ lbl_80072180: /* 8007218C 0006F0EC 48 25 86 E1 */ bl SetColor__10CGuiWidgetFRC6CColor lbl_80072190: /* 80072190 0006F0F0 80 7F 00 64 */ lwz r3, 0x64(r31) -/* 80072194 0006F0F4 48 25 2B 9D */ bl GetChildObject__10CGuiObjectFv +/* 80072194 0006F0F4 48 25 2B 9D */ bl ChildObject__10CGuiObjectFv /* 80072198 0006F0F8 7C 79 1B 78 */ mr r25, r3 /* 8007219C 0006F0FC 48 00 00 20 */ b lbl_800721BC lbl_800721A0: @@ -1824,7 +1824,7 @@ lbl_800721A0: /* 800721A8 0006F108 38 84 01 BC */ addi r4, r4, 0x1bc /* 800721AC 0006F10C 48 25 86 C1 */ bl SetColor__10CGuiWidgetFRC6CColor /* 800721B0 0006F110 7F 23 CB 78 */ mr r3, r25 -/* 800721B4 0006F114 48 25 2B 6D */ bl GetNextSibling__10CGuiObjectFv +/* 800721B4 0006F114 48 25 2B 6D */ bl NextSibling__10CGuiObjectFv /* 800721B8 0006F118 7C 79 1B 78 */ mr r25, r3 lbl_800721BC: /* 800721BC 0006F11C 28 19 00 00 */ cmplwi r25, 0 diff --git a/asm/MetroidPrime/HUD/CHudDecoInterface.s b/asm/MetroidPrime/HUD/CHudDecoInterface.s index f55d3f4e..d38e8e1a 100644 --- a/asm/MetroidPrime/HUD/CHudDecoInterface.s +++ b/asm/MetroidPrime/HUD/CHudDecoInterface.s @@ -6982,7 +6982,7 @@ lbl_80195098: /* 801950A0 00192000 48 12 D0 B5 */ bl FindWidget__9CGuiFrameCFPCc /* 801950A4 00192004 28 03 00 00 */ cmplwi r3, 0 /* 801950A8 00192008 41 82 00 D0 */ beq lbl_80195178 -/* 801950AC 0019200C 48 12 FC 85 */ bl GetChildObject__10CGuiObjectFv +/* 801950AC 0019200C 48 12 FC 85 */ bl ChildObject__10CGuiObjectFv /* 801950B0 00192010 3B C1 00 78 */ addi r30, r1, 0x78 /* 801950B4 00192014 7C 7B 1B 78 */ mr r27, r3 /* 801950B8 00192018 48 00 00 B8 */ b lbl_80195170 @@ -7033,7 +7033,7 @@ lbl_80195128: /* 8019515C 001920BC 7F 63 DB 78 */ mr r3, r27 /* 80195160 001920C0 48 12 F6 89 */ bl RecalculateTransforms__10CGuiObjectFv /* 80195164 001920C4 7F 63 DB 78 */ mr r3, r27 -/* 80195168 001920C8 48 12 FB B9 */ bl GetNextSibling__10CGuiObjectFv +/* 80195168 001920C8 48 12 FB B9 */ bl NextSibling__10CGuiObjectFv /* 8019516C 001920CC 7C 7B 1B 78 */ mr r27, r3 lbl_80195170: /* 80195170 001920D0 28 1B 00 00 */ cmplwi r27, 0 diff --git a/asm/MetroidPrime/HUD/CSamusHud.s b/asm/MetroidPrime/HUD/CSamusHud.s index a0b2ffcb..d501ce8f 100644 --- a/asm/MetroidPrime/HUD/CSamusHud.s +++ b/asm/MetroidPrime/HUD/CSamusHud.s @@ -10358,14 +10358,14 @@ InitializeFrameGluePermanent__9CSamusHudFRC13CStateManager: /* 8006D33C 0006A29C 48 25 4E 19 */ bl FindWidget__9CGuiFrameCFPCc /* 8006D340 0006A2A0 90 7E 05 98 */ stw r3, 0x598(r30) /* 8006D344 0006A2A4 80 7E 05 98 */ lwz r3, 0x598(r30) -/* 8006D348 0006A2A8 48 25 79 E9 */ bl GetChildObject__10CGuiObjectFv +/* 8006D348 0006A2A8 48 25 79 E9 */ bl ChildObject__10CGuiObjectFv /* 8006D34C 0006A2AC 3B 80 00 00 */ li r28, 0 /* 8006D350 0006A2B0 48 00 00 14 */ b lbl_8006D364 lbl_8006D354: /* 8006D354 0006A2B4 88 03 00 B6 */ lbz r0, 0xb6(r3) /* 8006D358 0006A2B8 53 80 07 FE */ rlwimi r0, r28, 0, 0x1f, 0x1f /* 8006D35C 0006A2BC 98 03 00 B6 */ stb r0, 0xb6(r3) -/* 8006D360 0006A2C0 48 25 79 C1 */ bl GetNextSibling__10CGuiObjectFv +/* 8006D360 0006A2C0 48 25 79 C1 */ bl NextSibling__10CGuiObjectFv lbl_8006D364: /* 8006D364 0006A2C4 28 03 00 00 */ cmplwi r3, 0 /* 8006D368 0006A2C8 40 82 FF EC */ bne lbl_8006D354 diff --git a/configure.py b/configure.py index b7c11348..da961694 100755 --- a/configure.py +++ b/configure.py @@ -426,7 +426,7 @@ LIBS = [ "GuiSys/CGuiHeadWidget", "GuiSys/CGuiLight", "GuiSys/CGuiModel", - "GuiSys/CGuiObject", + ["GuiSys/CGuiObject", False], "GuiSys/CGuiPane", "GuiSys/CGuiSliderGroup", "GuiSys/CGuiSys", diff --git a/include/GuiSys/CGuiObject.hpp b/include/GuiSys/CGuiObject.hpp index 4c39da5f..0124bd7f 100644 --- a/include/GuiSys/CGuiObject.hpp +++ b/include/GuiSys/CGuiObject.hpp @@ -9,20 +9,34 @@ class CVector2f; class CGuiObject { public: + CGuiObject(); virtual ~CGuiObject(); virtual void Update(float dt); - virtual void Draw(const CGuiWidgetDrawParms& parms); - virtual bool TestCursorHit(const CMatrix4f& vp, const CVector2f& point) const { return false; } + virtual void Draw(const CGuiWidgetDrawParms& parms) const; virtual void Initialize() = 0; + void MoveInWorld(const CVector3f& offset); + CVector3f GetWorldPosition() const; + CVector3f GetLocalPosition() const; + void SetLocalPosition(const CVector3f& pos); + void SetLocalTransform(const CTransform4f& xf); - void RecalculateTransforms(); - const CVector3f& GetLocalPosition() const; + void RotateReset(); - void SetLocalTransform(const CTransform4f& xf) { - x4_localXF = xf; - RecalculateTransforms(); + CVector3f RotateO2P(const CVector3f& vec) const; + CVector3f RotateW2O(const CVector3f& offset) const { + CVector3f ret = x34_worldXF.TransposeRotate(offset); + return ret; } + CVector3f RotateTranslateW2O(const CVector3f& vec) const; + void MultiplyO2P(const CTransform4f& xf); + void RecalculateTransforms(); + void AddChildObject(CGuiObject* child, bool a, bool b); + + void SetParent(CGuiObject* obj) { + x64_parent = obj; + } + private: CTransform4f x4_localXF; CTransform4f x34_worldXF; diff --git a/include/Kyoto/Math/CVector3f.hpp b/include/Kyoto/Math/CVector3f.hpp index 48c29e6a..e0563772 100644 --- a/include/Kyoto/Math/CVector3f.hpp +++ b/include/Kyoto/Math/CVector3f.hpp @@ -17,6 +17,7 @@ enum EDimZ { kDZ }; class CVector3f { public: + CVector3f() {} explicit CVector3f(float x, float y, float z) : mX(x), mY(y), mZ(z) {} CVector3f(const CVector2f& v, float z) : mX(v.GetX()), mY(v.GetY()), mZ(z) {} diff --git a/src/GuiSys/CGuiObject.cpp b/src/GuiSys/CGuiObject.cpp new file mode 100644 index 00000000..3d70c80f --- /dev/null +++ b/src/GuiSys/CGuiObject.cpp @@ -0,0 +1,97 @@ +#include "GuiSys/CGuiObject.hpp" +#include "Kyoto/Alloc/CMemory.hpp" + +CGuiObject::CGuiObject() +: x4_localXF(CTransform4f::Identity()) +, x34_worldXF(CTransform4f::Identity()) +, x64_parent(nullptr) +, x68_child(nullptr) +, x6c_nextSibling(nullptr) {} + +CGuiObject::~CGuiObject() { + delete x68_child; + x68_child = nullptr; + delete x6c_nextSibling; + x6c_nextSibling = nullptr; +} + +void CGuiObject::Update(float dt) { + if (x68_child) { + x68_child->Update(dt); + } + if (x6c_nextSibling) { + x6c_nextSibling->Update(dt); + } +} + +void CGuiObject::Draw(const CGuiWidgetDrawParms& parms) const { + if (x68_child) { + x68_child->Draw(parms); + } + + if (x6c_nextSibling) { + x6c_nextSibling->Draw(parms); + } +} + +void CGuiObject::MoveInWorld(const CVector3f& offset) { + if (x64_parent != nullptr) { + CVector3f pos = x64_parent->RotateW2O(offset); + } + x4_localXF.AddTranslation(offset); + RecalculateTransforms(); +} + +CVector3f CGuiObject::GetWorldPosition() const { + return x34_worldXF.GetTranslation(); +} + +CVector3f CGuiObject::GetLocalPosition() const { + return x4_localXF.GetTranslation(); +} + +void CGuiObject::SetLocalPosition(const CVector3f& pos) { + MoveInWorld(pos - x4_localXF.GetTranslation()); +} + +void CGuiObject::RotateReset() { + CVector3f tmpPos = x4_localXF.GetTranslation(); + x4_localXF = CTransform4f::Identity(); + x4_localXF.SetTranslation(tmpPos); + RecalculateTransforms(); +} + +CVector3f CGuiObject::RotateO2P(const CVector3f& vec) const { + CVector3f tmp = x4_localXF.Rotate(vec); + return tmp; +} + +CVector3f CGuiObject::RotateTranslateW2O(const CVector3f& vec) const { + CVector3f tmp = x34_worldXF.TransposeRotate(vec - x34_worldXF.GetTranslation()); + return tmp; +} + +void CGuiObject::MultiplyO2P(const CTransform4f& xf) { + x4_localXF = xf * x4_localXF; + RecalculateTransforms(); +} + +void CGuiObject::AddChildObject(CGuiObject* obj, bool makeWorldLocal, bool atEnd) { + obj->SetParent(this); + + if (!x68_child) { + x68_child = obj; + } else if (atEnd) { + CGuiObject* prev = nullptr; + CGuiObject* cur = x68_child; + for (; cur; cur = cur->x6c_nextSibling) { + prev = cur; + } + + if (prev) { + prev->x6c_nextSibling = obj; + } + } else { + + } +}