From 467e1a61ce87458428e23a38de5052177bd90ad3 Mon Sep 17 00:00:00 2001 From: elijah-thomas774 Date: Fri, 24 May 2024 15:55:55 -0400 Subject: [PATCH] lyt_layout progress --- config/SOUE01/splits.txt | 32 ++- config/SOUE01/symbols.txt | 8 +- configure.py | 1 + include/nw4r/ef/ef_animcurve.h | 11 - include/nw4r/ef/ef_creationqueue.h | 38 --- include/nw4r/ef/ef_cube.h | 16 -- include/nw4r/ef/ef_cylinder.h | 16 -- include/nw4r/ef/ef_disc.h | 16 -- include/nw4r/ef/ef_drawbillboardstrategy.h | 19 -- include/nw4r/ef/ef_drawdirectionalstrategy.h | 19 -- include/nw4r/ef/ef_drawfreestrategy.h | 18 -- include/nw4r/ef/ef_drawinfo.h | 11 - include/nw4r/ef/ef_drawlinestrategy.h | 18 -- include/nw4r/ef/ef_draworder.h | 17 -- include/nw4r/ef/ef_draworderbase.h | 18 -- include/nw4r/ef/ef_drawpointstrategy.h | 19 -- include/nw4r/ef/ef_drawsmoothstripestrategy.h | 19 -- include/nw4r/ef/ef_drawstrategy.h | 14 - include/nw4r/ef/ef_drawstrategybuilder.h | 23 -- include/nw4r/ef/ef_drawstrategyimpl.h | 40 --- include/nw4r/ef/ef_drawstripestrategy.h | 19 -- include/nw4r/ef/ef_effect.h | 56 ---- include/nw4r/ef/ef_effectsystem.h | 53 ---- include/nw4r/ef/ef_emform.h | 23 -- include/nw4r/ef/ef_emitter.h | 247 ------------------ include/nw4r/ef/ef_emitterform.h | 17 -- include/nw4r/ef/ef_handle.h | 25 -- include/nw4r/ef/ef_line.h | 16 -- include/nw4r/ef/ef_list.h | 57 ---- include/nw4r/ef/ef_memorymanager.h | 16 -- include/nw4r/ef/ef_memorymanagerbase.h | 40 --- include/nw4r/ef/ef_particle.h | 21 -- include/nw4r/ef/ef_particlemanager.h | 83 ------ include/nw4r/ef/ef_point.h | 16 -- include/nw4r/ef/ef_rand.h | 31 --- include/nw4r/ef/ef_ref.h | 45 ---- include/nw4r/ef/ef_resource.h | 15 -- include/nw4r/ef/ef_sphere.h | 16 -- include/nw4r/ef/ef_torus.h | 16 -- include/nw4r/ef/ef_util.h | 20 -- include/nw4r/lyt/lyt_animation.h | 80 +++++- include/nw4r/lyt/lyt_bounding.h | 15 +- include/nw4r/lyt/lyt_common.h | 20 +- include/nw4r/lyt/lyt_group.h | 15 +- include/nw4r/lyt/lyt_layout.h | 62 ++++- include/nw4r/lyt/lyt_material.h | 39 ++- include/nw4r/lyt/lyt_pane.h | 123 ++++++--- include/nw4r/lyt/lyt_picture.h | 32 +++ include/nw4r/lyt/lyt_textBox.h | 55 ++++ include/nw4r/lyt/lyt_types.h | 65 +++++ include/nw4r/lyt/lyt_window.h | 69 +++++ include/nw4r/ut/ut_RuntimeTypeInfo.h | 33 +-- include/nw4r/ut/ut_algorithm.h | 57 ++-- src/nw4r/lyt/lyt_common.cpp | 3 +- src/nw4r/lyt/lyt_group.cpp | 7 +- src/nw4r/lyt/lyt_layout.cpp | 244 +++++++++++++++++ src/nw4r/lyt/lyt_material.cpp | 10 + src/nw4r/lyt/lyt_pane.cpp | 49 ++-- 58 files changed, 866 insertions(+), 1317 deletions(-) delete mode 100644 include/nw4r/ef/ef_animcurve.h delete mode 100644 include/nw4r/ef/ef_creationqueue.h delete mode 100644 include/nw4r/ef/ef_cube.h delete mode 100644 include/nw4r/ef/ef_cylinder.h delete mode 100644 include/nw4r/ef/ef_disc.h delete mode 100644 include/nw4r/ef/ef_drawbillboardstrategy.h delete mode 100644 include/nw4r/ef/ef_drawdirectionalstrategy.h delete mode 100644 include/nw4r/ef/ef_drawfreestrategy.h delete mode 100644 include/nw4r/ef/ef_drawinfo.h delete mode 100644 include/nw4r/ef/ef_drawlinestrategy.h delete mode 100644 include/nw4r/ef/ef_draworder.h delete mode 100644 include/nw4r/ef/ef_draworderbase.h delete mode 100644 include/nw4r/ef/ef_drawpointstrategy.h delete mode 100644 include/nw4r/ef/ef_drawsmoothstripestrategy.h delete mode 100644 include/nw4r/ef/ef_drawstrategy.h delete mode 100644 include/nw4r/ef/ef_drawstrategybuilder.h delete mode 100644 include/nw4r/ef/ef_drawstrategyimpl.h delete mode 100644 include/nw4r/ef/ef_drawstripestrategy.h delete mode 100644 include/nw4r/ef/ef_effect.h delete mode 100644 include/nw4r/ef/ef_effectsystem.h delete mode 100644 include/nw4r/ef/ef_emform.h delete mode 100644 include/nw4r/ef/ef_emitter.h delete mode 100644 include/nw4r/ef/ef_emitterform.h delete mode 100644 include/nw4r/ef/ef_handle.h delete mode 100644 include/nw4r/ef/ef_line.h delete mode 100644 include/nw4r/ef/ef_list.h delete mode 100644 include/nw4r/ef/ef_memorymanager.h delete mode 100644 include/nw4r/ef/ef_memorymanagerbase.h delete mode 100644 include/nw4r/ef/ef_particle.h delete mode 100644 include/nw4r/ef/ef_particlemanager.h delete mode 100644 include/nw4r/ef/ef_point.h delete mode 100644 include/nw4r/ef/ef_rand.h delete mode 100644 include/nw4r/ef/ef_ref.h delete mode 100644 include/nw4r/ef/ef_resource.h delete mode 100644 include/nw4r/ef/ef_sphere.h delete mode 100644 include/nw4r/ef/ef_torus.h delete mode 100644 include/nw4r/ef/ef_util.h create mode 100644 include/nw4r/lyt/lyt_picture.h create mode 100644 include/nw4r/lyt/lyt_textBox.h create mode 100644 include/nw4r/lyt/lyt_window.h diff --git a/config/SOUE01/splits.txt b/config/SOUE01/splits.txt index 5376ea1d..77753f30 100644 --- a/config/SOUE01/splits.txt +++ b/config/SOUE01/splits.txt @@ -1,17 +1,17 @@ Sections: - .init type:code - extab type:rodata - extabindex type:rodata - .text type:code - .ctors type:rodata - .dtors type:rodata - .rodata type:rodata - .data type:data - .sdata type:data - .sbss type:bss - .sdata2 type:rodata - .sbss2 type:bss - .bss type:bss + .init type:code align:4 + extab type:rodata align:8 + extabindex type:rodata align:4 + .text type:code align:32 + .ctors type:rodata align:16 + .dtors type:rodata align:32 + .rodata type:rodata align:32 + .data type:data align:32 + .sdata type:data align:32 + .sbss type:bss align:16 + .sdata2 type:rodata align:8 + .sbss2 type:bss align:16 + .bss type:bss align:64 toBeSorted/save_file.cpp: .text start:0x800099B0 end:0x80009D28 @@ -332,6 +332,12 @@ nw4r/lyt/lyt_group.cpp: .text start:0x80487EB0 end:0x8048820C .data start:0x8056E4A8 end:0x8056E4B4 +nw4r/lyt/lyt_layout.cpp: + .text start:0x80488210 end:0x80489268 + .data start:0x8056E4B8 end:0x8056E4F8 + .sbss start:0x805766F8 end:0x805766FC + .sdata2 start:0x8057F240 end:0x8057F248 + nw4r/lyt/lyt_resourceAccessor.cpp: .text start:0x80492000 end:0x80492058 .data start:0x8056E7E0 end:0x8056E7F8 diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 764dea4d..2f635c49 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -37074,7 +37074,7 @@ 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 __vt__Q34nw4r3lyt5Group = .data:0x8056E4A8; // type:object size:0xC -lbl_8056E4B8 = .data:0x8056E4B8; // type:object size:0x40 +__vt__Q34nw4r3lyt6Layout = .data:0x8056E4B8; // type:object size:0x40 lbl_8056E4F8 = .data:0x8056E4F8; // type:object size:0x78 lbl_8056E570 = .data:0x8056E570; // type:object size:0x88 lbl_8056E5F8 = .data:0x8056E5F8; // type:object size:0x3C @@ -40876,9 +40876,9 @@ lbl_805766D8 = .sbss:0x805766D8; // type:object size:0x8 data:byte lbl_805766E0 = .sbss:0x805766E0; // type:object size:0x8 data:byte lbl_805766E8 = .sbss:0x805766E8; // type:object size:0x8 data:4byte typeInfo__Q34nw4r3lyt4Pane = .sbss:0x805766F0; // type:object size:0x4 data:4byte -mspAllocator__Q34nw4r3lyt6Layout = .sbss:0x805766F8; // type:object size:0x8 data:4byte -lbl_80576700 = .sbss:0x80576700; // type:object size:0x8 data:4byte -lbl_80576708 = .sbss:0x80576708; // type:object size:0x8 data:4byte +mspAllocator__Q34nw4r3lyt6Layout = .sbss:0x805766F8; // type:object size:0x4 data:4byte +typeInfo__Q34nw4r3lyt7Picture = .sbss:0x80576700; // type:object size:0x4 data:4byte +typeInfo__Q34nw4r3lyt7TextBox = .sbss:0x80576708; // type:object size:0x4 data:4byte lbl_80576710 = .sbss:0x80576710; // type:object size:0x8 data:4byte lbl_80576718 = .sbss:0x80576718; // type:object size:0x8 data:4byte @GUARD@SetSize__Q44nw4r3lyt6detail11TexCoordAryFUc@texCoords = .sbss:0x80576720; // type:object size:0x1 data:byte diff --git a/configure.py b/configure.py index 7d5a6fdb..cc6aa06d 100644 --- a/configure.py +++ b/configure.py @@ -355,6 +355,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(NonMatching, "nw4r/lyt/lyt_layout.cpp"), Object(Matching, "nw4r/lyt/lyt_resourceAccessor.cpp"), Object(Matching, "nw4r/lyt/lyt_arcResourceAccessor.cpp"), Object(Matching, "nw4r/lyt/lyt_common.cpp"), diff --git a/include/nw4r/ef/ef_animcurve.h b/include/nw4r/ef/ef_animcurve.h deleted file mode 100644 index b5b4efca..00000000 --- a/include/nw4r/ef/ef_animcurve.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NW4R_EF_ANIMCURVE_H -#define NW4R_EF_ANIMCURVE_H -#include "common.h" - -namespace nw4r { -namespace ef { -UNKTYPE AnimCurveExecuteF32(u8 *, float *, u32, u16, u32); -} -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_creationqueue.h b/include/nw4r/ef/ef_creationqueue.h deleted file mode 100644 index 0a544783..00000000 --- a/include/nw4r/ef/ef_creationqueue.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef NW4R_EF_CREATIONQUEUE -#define NW4R_EF_CREATIONQUEUE -#include "common.h" -#include "ef_emitter.h" - - -namespace nw4r { -namespace ef { -enum CreationType { CreationType_Particle, CreationType_Emitter }; - -// sizeof(UNK_CREATIONQUEUE) = 0x14 -struct Creation { - u8 mType; // at 0x0 - u16 SHORT_0x2; - EmitterInheritSetting mInheritSetting; // at 0x4 - Particle *mParticle; // at 0x8 - EmitterResource *mResource; // at 0xc -}; - -struct CreationQueue { - CreationQueue(); - void AddParticleCreation(const EmitterInheritSetting *, Particle *, EmitterResource *, u16); - void AddEmitterCreation(const EmitterInheritSetting *, Particle *, EmitterResource *, u16); - - int mSize; - - Creation mCreations[0x400]; - - inline bool IsEmpty() { - return mSize == 0; - } - - void Execute(); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_cube.h b/include/nw4r/ef/ef_cube.h deleted file mode 100644 index 8e091e71..00000000 --- a/include/nw4r/ef/ef_cube.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NW4R_EF_CUBE_H -#define NW4R_EF_CUBE_H -#include "ef_emitterform.h" - -namespace nw4r -{ - namespace ef - { - struct EmitterFormCube : EmitterForm - { - virtual UNKTYPE Emission(Emitter *, ParticleManager *, int, u32, float *, u16, float, const math::MTX34 *); - }; - } -} - -#endif \ No newline at end of file diff --git a/include/nw4r/ef/ef_cylinder.h b/include/nw4r/ef/ef_cylinder.h deleted file mode 100644 index ac27d4e7..00000000 --- a/include/nw4r/ef/ef_cylinder.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NW4R_EF_CYLINDER_H -#define NW4R_EF_CYLINDER_H -#include "ef_emitterform.h" - -namespace nw4r -{ - namespace ef - { - struct EmitterFormCylinder : EmitterForm - { - virtual UNKTYPE Emission(Emitter *, ParticleManager *, int, u32, float *, u16, float, const math::MTX34 *); - }; - } -} - -#endif \ No newline at end of file diff --git a/include/nw4r/ef/ef_disc.h b/include/nw4r/ef/ef_disc.h deleted file mode 100644 index 98d37cb6..00000000 --- a/include/nw4r/ef/ef_disc.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NW4R_EF_DISC_H -#define NW4R_EF_DISC_H -#include "ef_emitterform.h" - -namespace nw4r -{ - namespace ef - { - struct EmitterFormDisc : EmitterForm - { - virtual UNKTYPE Emission(Emitter *, ParticleManager *, int, u32, float *, u16, float, const math::MTX34 *); - }; - } -} - -#endif \ No newline at end of file diff --git a/include/nw4r/ef/ef_drawbillboardstrategy.h b/include/nw4r/ef/ef_drawbillboardstrategy.h deleted file mode 100644 index 291f53e4..00000000 --- a/include/nw4r/ef/ef_drawbillboardstrategy.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef NW4R_EF_DRAW_BILLBOARD_STRATEGY_H -#define NW4R_EF_DRAW_BILLBOARD_STRATEGY_H -#include "common.h" -#include "ef_drawstrategyimpl.h" - -namespace nw4r { -namespace ef { -class DrawBillboardStrategy : public DrawStrategyImpl { -public: - DrawBillboardStrategy(); - virtual ~DrawBillboardStrategy() {} // at 0x8 - virtual UNKTYPE GetCalcAheadFunc(ParticleManager *); // at 0x18 - - void Draw(const DrawInfo &, ParticleManager *); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_drawdirectionalstrategy.h b/include/nw4r/ef/ef_drawdirectionalstrategy.h deleted file mode 100644 index a88630e9..00000000 --- a/include/nw4r/ef/ef_drawdirectionalstrategy.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef NW4R_EF_DRAW_DIRECTIONAL_STRATEGY_H -#define NW4R_EF_DRAW_DIRECTIONAL_STRATEGY_H -#include "common.h" -#include "ef_drawstrategyimpl.h" - -namespace nw4r { -namespace ef { -class DrawDirectionalStrategy : public DrawStrategyImpl { -public: - DrawDirectionalStrategy(); - virtual ~DrawDirectionalStrategy() {} // at 0x8 - virtual UNKTYPE GetCalcAheadFunc(ParticleManager *); // at 0x18 - - void Draw(const DrawInfo &, ParticleManager *); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_drawfreestrategy.h b/include/nw4r/ef/ef_drawfreestrategy.h deleted file mode 100644 index 6de764a9..00000000 --- a/include/nw4r/ef/ef_drawfreestrategy.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef NW4R_EF_DRAW_FREE_STRATEGY_H -#define NW4R_EF_DRAW_FREE_STRATEGY_H -#include "common.h" -#include "ef_drawstrategyimpl.h" - -namespace nw4r { -namespace ef { -class DrawFreeStrategy : public DrawStrategyImpl { -public: - DrawFreeStrategy(); - virtual ~DrawFreeStrategy() {} // at 0x8 - - UNKTYPE Draw(const DrawInfo &, ParticleManager *); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_drawinfo.h b/include/nw4r/ef/ef_drawinfo.h deleted file mode 100644 index 4bbb83b3..00000000 --- a/include/nw4r/ef/ef_drawinfo.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef NW4R_EF_DRAWINFO -#define NW4R_EF_DRAWINFO -#include "common.h" - -namespace nw4r { -namespace ef { -struct DrawInfo {}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_drawlinestrategy.h b/include/nw4r/ef/ef_drawlinestrategy.h deleted file mode 100644 index 46a40d6b..00000000 --- a/include/nw4r/ef/ef_drawlinestrategy.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef NW4R_EF_DRAW_LINE_STRATEGY_H -#define NW4R_EF_DRAW_LINE_STRATEGY_H -#include "common.h" -#include "ef_drawstrategyimpl.h" - -namespace nw4r { -namespace ef { -class DrawLineStrategy : public DrawStrategyImpl { -public: - DrawLineStrategy(); - virtual ~DrawLineStrategy() {} // at 0x8 - - UNKTYPE Draw(const DrawInfo &, ParticleManager *); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_draworder.h b/include/nw4r/ef/ef_draworder.h deleted file mode 100644 index b72c51bb..00000000 --- a/include/nw4r/ef/ef_draworder.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef NW4R_EF_DRAWORDER -#define NW4R_EF_DRAWORDER -#include "common.h" -#include "ef_draworderbase.h" -#include "ef_particlemanager.h" - -namespace nw4r { -namespace ef { -struct DrawOrder : DrawOrderBase { - void Draw(Effect *, const DrawInfo &); - void Add(Effect *, ParticleManager *); - void Remove(Effect *, ParticleManager *); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_draworderbase.h b/include/nw4r/ef/ef_draworderbase.h deleted file mode 100644 index ba42be89..00000000 --- a/include/nw4r/ef/ef_draworderbase.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef NW4R_EF_DRAWORDERBASE -#define NW4R_EF_DRAWORDERBASE -#include "ef_particlemanager.h" -#include "ut_list.h" -#include - - -namespace nw4r { -namespace ef { -struct DrawOrderBase { - virtual void Add(Effect *, ParticleManager *) = 0; - virtual void Remove(Effect *, ParticleManager *) = 0; - virtual void Draw(Effect *, const DrawInfo &) = 0; -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_drawpointstrategy.h b/include/nw4r/ef/ef_drawpointstrategy.h deleted file mode 100644 index 8b037377..00000000 --- a/include/nw4r/ef/ef_drawpointstrategy.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef NW4R_EF_DRAW_POINT_STRATEGY_H -#define NW4R_EF_DRAW_POINT_STRATEGY_H -#include "common.h" -#include "ef_drawstrategyimpl.h" - -namespace nw4r { -namespace ef { -class DrawPointStrategy : public DrawStrategyImpl { -public: - DrawPointStrategy(); - virtual ~DrawPointStrategy() {} // at 0x8 - - void Draw(const DrawInfo &, ParticleManager *); - void InitGraphics(const DrawInfo &, ParticleManager *); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_drawsmoothstripestrategy.h b/include/nw4r/ef/ef_drawsmoothstripestrategy.h deleted file mode 100644 index d76971c4..00000000 --- a/include/nw4r/ef/ef_drawsmoothstripestrategy.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef NW4R_EF_DRAW_SMOOTH_STRIPE_STRATEGY_H -#define NW4R_EF_DRAW_SMOOTH_STRIPE_STRATEGY_H -#include "common.h" -#include "ef_drawstrategyimpl.h" - -namespace nw4r { -namespace ef { -class DrawSmoothStripeStrategy : public DrawStrategyImpl { -public: - DrawSmoothStripeStrategy(); - virtual ~DrawSmoothStripeStrategy() {} // at 0x8 - virtual UNKTYPE GetCalcAheadFunc(ParticleManager *); // at 0x18 - - UNKTYPE Draw(const DrawInfo &, ParticleManager *); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_drawstrategy.h b/include/nw4r/ef/ef_drawstrategy.h deleted file mode 100644 index 34d3c38c..00000000 --- a/include/nw4r/ef/ef_drawstrategy.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef NW4R_EF_DRAWSTRATEGY_H -#define NW4R_EF_DRAWSTRATEGY_H -#include "common.h" - -namespace nw4r { -namespace ef { -struct DrawStrategy { - inline virtual ~DrawStrategy() {} - virtual UNKTYPE Draw(const DrawInfo &, ParticleManager *) = 0; -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_drawstrategybuilder.h b/include/nw4r/ef/ef_drawstrategybuilder.h deleted file mode 100644 index f2de9d2e..00000000 --- a/include/nw4r/ef/ef_drawstrategybuilder.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef NW4R_EF_DRAWSTRATEGYBUILDER_H -#define NW4R_EF_DRAWSTRATEGYBUILDER_H -#include "common.h" - -namespace nw4r { -namespace ef { -enum DrawStrategyType { - DrawStratType_Point, - DrawStratType_Line, - DrawStratType_Free, - DrawStratType_Billboard, - DrawStratType_Directional, - DrawStratType_Stripe, - DrawStratType_SmoothStripe -}; - -struct DrawStrategyBuilder { - virtual DrawStrategy *Create(u32); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_drawstrategyimpl.h b/include/nw4r/ef/ef_drawstrategyimpl.h deleted file mode 100644 index 2a88e87b..00000000 --- a/include/nw4r/ef/ef_drawstrategyimpl.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef NW4R_EF_DRAW_STRATEGY_IMPL_H -#define NW4R_EF_DRAW_STRATEGY_IMPL_H -#include "common.h" -#include "ef_drawstrategy.h" -#include "math_types.h" - -namespace nw4r { -namespace ef { -class DrawStrategyImpl : public DrawStrategy { -public: - struct PrevTexture { - UNKWORD WORD_0x0; - f32 FLOAT_0x4; - f32 FLOAT_0x8; - f32 FLOAT_0xC; - f32 FLOAT_0x10; - UNKWORD WORD_0x14; - UNKWORD WORD_0x18; - math::VEC2 VEC2_0x1C; - f32 FLOAT_0x24; - math::VEC2 VEC2_0x28; - }; - -public: - DrawStrategyImpl(); - virtual UNKTYPE GetGetFirstDrawParticleFunc(int); - virtual UNKTYPE GetGetNextDrawParticleFunc(int); - - void InitTexture(const EmitterDrawSetting &); - void InitTev(const EmitterDrawSetting &, const DrawInfo &); - void InitColor(ParticleManager *, const EmitterDrawSetting &, const DrawInfo &); - -private: - PrevTexture mPrevTextures[3]; // at 0x4 - char UNK_0x94[0xBC - 0x94]; -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_drawstripestrategy.h b/include/nw4r/ef/ef_drawstripestrategy.h deleted file mode 100644 index 2edf9238..00000000 --- a/include/nw4r/ef/ef_drawstripestrategy.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef NW4R_EF_DRAW_STRIPE_STRATEGY_H -#define NW4R_EF_DRAW_STRIPE_STRATEGY_H -#include "common.h" -#include "ef_drawstrategyimpl.h" - -namespace nw4r { -namespace ef { -class DrawStripeStrategy : public DrawStrategyImpl { -public: - DrawStripeStrategy(); - virtual ~DrawStripeStrategy() {} // at 0x8 - virtual UNKTYPE GetCalcAheadFunc(ParticleManager *); // at 0x18 - - UNKTYPE Draw(const DrawInfo &, ParticleManager *); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_effect.h b/include/nw4r/ef/ef_effect.h deleted file mode 100644 index bed4ac26..00000000 --- a/include/nw4r/ef/ef_effect.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef NW4R_EF_EFFECT -#define NW4R_EF_EFFECT -#include "common.h" -#include "ef_list.h" -#include "ef_ref.h" -#include "ef_util.h" -#include "math_types.h" -#include "ut_list.h" - -namespace nw4r { -namespace ef { -struct Effect : ReferencedObject { - EffectSystem *mSystem; // at 0x20 - ActivityList mEmitters; // at 0x24 - u32 INDEX_0x40; - - void (*mEmissionPrologue)(Emitter *, ParticleManager *, int *, u32 *, float *, u16 *, float *, - math::MTX34 *); // at 0x44 - - UNKWORD WORD_0x48; - UNKWORD WORD_0x4C; - u32 mFlags; // at 0x50 - math::MTX34 mRootMtx; // at 0x54 - math::VEC3 VEC_0x84; - ut::List UTLIST_0x90; - DrawOrder *mDrawOrder; // at 0x9c - - Effect(); - ~Effect(); - - virtual bool Initialize(EffectSystem *, EmitterResource *, u16); - virtual Emitter *CreateEmitter(ResEmitter, u8, u16); - virtual void Calc(bool); - virtual void Draw(const DrawInfo &); - - bool SendClosing(); - UNKTYPE DestroyFunc(); - bool Closing(Emitter *); - Emitter *CreateEmitter(EmitterResource *, u8, u16); - bool RetireEmitter(Emitter *); - u16 RetireEmitterAll(); - u16 RetireParticleAll(); - u16 GetNumEmitter() const; - Emitter *GetEmitter(u16); - u16 ForeachParticleManager(Action, u32, bool); - u16 ForeachEmitterFrom(Action, u32, bool, Emitter *); - UNKTYPE SetRootMtx(const math::MTX34 &); - - inline bool GetFlagDisableDraw() { - return mFlags & 2; - } -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_effectsystem.h b/include/nw4r/ef/ef_effectsystem.h deleted file mode 100644 index 68177a21..00000000 --- a/include/nw4r/ef/ef_effectsystem.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef NW4R_EF_EFFECTSYSTEM -#define NW4R_EF_EFFECTSYSTEM -#include "common.h" -#include "ef_creationqueue.h" -#include "ef_list.h" -#include "ef_rand.h" -#include "ef_ref.h" - -namespace nw4r { -namespace ef { -struct EffectSystem { - static bool mDisplayVersion; - - static EffectSystem instance; - - MemoryManager *mMemoryManager; // at 0x0 - DrawOrder *mDrawOrder; // at 0x4 - DrawStrategyBuilder *mDrawStrategyBuilder; // at 0x8 - EmitFormBuilder *mEmitFormBuilder; // at 0xc - CreationQueue mCreationQueue; // at 0x10 - u32 mNumGroup; - ActivityList *ARR_0x5018; - Random mRandom; // at 0x501C - math::VEC3 VEC_0x5020; - math::MTX34 MTX_0x502C; - float FLOAT_0x505C; - float FLOAT_0x5060; - char BYTE_0x5064; - - inline MemoryManager *GetMemoryManager() const { - return mMemoryManager; - } - - EffectSystem(); - ~EffectSystem(); - - static EffectSystem *GetInstance(); - - bool Initialize(u32); - bool Closing(Effect *); - Effect *CreateEffect(const char *, u32, u16); - bool RetireEffect(Effect *); - u16 RetireEffectAll(u32); - u16 RetireEmitterAll(u32); - u16 RetireParticleAll(u32); - - void Calc(u32, bool); - void Draw(const DrawInfo &, u32); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_emform.h b/include/nw4r/ef/ef_emform.h deleted file mode 100644 index c0d00924..00000000 --- a/include/nw4r/ef/ef_emform.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef NW4R_EF_EMFORM_H -#define NW4R_EF_EMFORM_H -#include "common.h" - -namespace nw4r { -namespace ef { -enum EmitFormType { - EmitForm_Disc, - EmitForm_Line, - EmitForm_Cube = 5, - EmitForm_Cylinder = 7, - EmitForm_Sphere, - EmitForm_Point, - EmitForm_Torus -}; - -struct EmitFormBuilder { - virtual EmitterForm *Create(EmitFormType); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_emitter.h b/include/nw4r/ef/ef_emitter.h deleted file mode 100644 index 386eba51..00000000 --- a/include/nw4r/ef/ef_emitter.h +++ /dev/null @@ -1,247 +0,0 @@ -#ifndef NW4R_EF_EMITTER -#define NW4R_EF_EMITTER -#include "ef_animcurve.h" -#include "ef_list.h" -#include "ef_rand.h" -#include "ef_ref.h" -#include "ef_util.h" -#include "ut_list.h" -#include #include "common.h" - - -namespace nw4r { -namespace ef { -struct ResEmitter { - EmitterResource *mPtr; - - inline EmitterResource *ptr() { - return mPtr; - } -}; - -struct EmitterInheritSetting { - s16 SHORT_0x0; - u8 BYTE_0x2; - u8 BYTE_0x3; - u8 BYTE_0x4; - u8 BYTE_0x5; - u8 BYTE_0x6; - u8 BYTE_0x7; -}; - -struct EmitterDesc { - UNKWORD FLAGS_0x0; // at 0x0/0x8 - UNKWORD EMFORMTYPE_0x4; // at 0x4/0xc - u16 SHORT_0x8; // at 0x8/0x10 - u16 SHORT_0xA; // at 0xa/0x12 - s8 SBYTE_0xC; // at 0xc/0x14 - s8 SBYTE_0xD; // at 0xd/0x15 - s8 SBYTE_0xE; // at 0xe/0x16 - s8 SBYTE_0xF; // at 0xf/0x17 - float FLOAT_0x10; // at 0x10/0x18 - u16 SHORT_0x14; // at 0x14/0x1c - u16 SHORT_0x16; // at 0x16/0x1e - u16 SHORT_0x18; // at 0x18/0x20 - s8 BYTE_0x1A; // at 0x1a/0x22 - s8 BYTE_0x1B; // at 0x1b/0x23 - float FLOAT_0x1C; - float FLOAT_0x20; - float FLOAT_0x24; - float FLOAT_0x28; - float FLOAT_0x2C; - float FLOAT_0x30; - u16 SHORT_0x34; - u8 BYTE_0x36; - u8 BYTE_0x37; - float FLOAT_0x38; - float FLOAT_0x3C; - float FLOAT_0x40; - float FLOAT_0x44; - float FLOAT_0x48; - float FLOAT_0x4C; - float FLOAT_0x50; - float FLOAT_0x54; - float FLOAT_0x58; - float FLOAT_0x5C; - - float FLOAT_0x60; - float FLOAT_0x64; - float FLOAT_0x68; - float FLOAT_0x6C; - float FLOAT_0x70; - float FLOAT_0x74; - - float FLOAT_0x78; - float FLOAT_0x7C; - float FLOAT_0x80; - - u8 BYTE_0x84; // at 0x84/0x8c - u8 BYTE_0x85; // at 0x85/0x8d - u8 BYTE_0x86; // at 0x86/0x8e - UNKWORD WORD_0x88; -}; - -struct EmitTrack { - u8 BYTE_0x0; - u8 BYTE_0x1; - u16 SHORT_0x2; - - u8 BYTE_0x4; -}; - -struct EmitterResource { - char UNK_0x0[0x4]; - u32 OFFSET_0x4; - - EmitterDesc STRUCT_0x8; - - inline UNKTYPE *SkipEmitterDesc() { - return (char *)&STRUCT_0x8 + OFFSET_0x4; - } - - inline UNKTYPE *SkipParticleParameterDesc() { - char *particleDesc = (char *)SkipEmitterDesc(); - - return particleDesc + *(int *)particleDesc; - } - - inline u16 NumEmitInitTrack() { - u16 *ptr = (u16 *)SkipParticleParameterDesc(); - - return ptr[(4 * *(ptr += 2)) + 3]; - } - - inline u16 NumEmitTrack() { - u16 *ptr = (u16 *)SkipParticleParameterDesc(); - - return ptr[(4 * *(ptr += 2)) + 2]; - } - - inline EmitTrack *GetEmitTrack(u16 i) { - u16 *ptr = (u16 *)SkipParticleParameterDesc(); - - return reinterpret_cast(ptr)[(2 * *(ptr += 1)) + 1 + i]; - } -}; - -struct Emitter : ReferencedObject { - virtual bool Initialize(Effect *, EmitterResource *, u8); // at 0x10 - virtual Emitter *CreateEmitter(EmitterResource *, EmitterInheritSetting *, Particle *, u16); // at 0x14 - virtual void CalcEmitter(); // at 0x18 - virtual void CalcParticle(); // at 0x1c - virtual void CalcEmission(); // at 0x20 - virtual void CalcBillboard(); // at 0x24 - - u32 mFlags; - UNKWORD WORD_0x24; - - // char UNK_0x28[0x8C]; - float FLOAT_0x28; - float FLOAT_0x2C; - short SHORT_0x30; - short SHORT_0x32; - float FLOAT_0x34; - float FLOAT_0x38; - short SHORT_0x3C; - float FLOAT_0x40; - float FLOAT_0x44; - float FLOAT_0x48; - float FLOAT_0x4C; - float FLOAT_0x50; - float FLOAT_0x54; - float FLOAT_0x58; - float FLOAT_0x5C; - float FLOAT_0x60; - - u8 BYTE_0x64; - s8 BYTE_0x65; - u8 BYTE_0x66; - s8 BYTE_0x67; - - float FLOAT_0x68; - float FLOAT_0x6C; - float FLOAT_0x70; - float FLOAT_0x74; - float FLOAT_0x78; - float FLOAT_0x7C; - float FLOAT_0x80; - float FLOAT_0x84; - float FLOAT_0x88; - float FLOAT_0x8C; - /* - float FLOAT_0x90; - float FLOAT_0x94; - float FLOAT_0x98; - */ - math::VEC3 VEC_0x90; - /* - float FLOAT_0x9C; - float FLOAT_0xA0; - float FLOAT_0xA4; - */ - math::VEC3 VEC_0x9C; - /* - float FLOAT_0xA8; - float FLOAT_0xAC; - float FLOAT_0xB0; - */ - math::VEC3 VEC_0xA8; - - UNKWORD WORD_0xB4; - EmitterResource *mResource; // at 0xb8 - Effect *mEffect; // at 0xbc - ActivityList mManagers; // at 0xc0 - char UNK_0xDA[0x2]; - u8 BYTE_0xDC; - u16 SHORT_0xDE; - u16 SHORT_0xE0; - UNKWORD WORD_0xE4; - u16 SHORT_0xE8; - u16 SHORT_0xEA; - Random mRandom; // at 0xec - EmitterForm *mForm; // at 0xf0 - Emitter *mParent; // at 0xf4 - Particle *REF_0xF8; // at 0xf8 - - EmitterInheritSetting mInheritSettings; // at 0xfc - - bool mMtxDirtyFlag; // at 0x104 - - math::MTX34 mGlobalMtx; // at 0x108 - - Emitter(); - ~Emitter(); - - u16 RetireParticleAll(); - bool SendClosing(); - void DestroyFunc(); - bool Closing(ParticleManager *); - bool RetireParticleManager(ParticleManager *); - u16 RetireParticleManagerAll(); - bool InitializeDatas(EmitterResource *, Effect *); - - ParticleManager *FindParticleManager(EmitterResource *, bool, bool, s8, u8); - UNKTYPE CreateEmitterTmp(EmitterResource *, EmitterInheritSetting *, Particle *, u16); - - float GetLODratio(math::VEC3 &, math::VEC3 &, float, float, float, float); - - u16 ForeachParticleManager(Action, u32, bool, bool); - - UNKTYPE Emission(ParticleManager *, const math::MTX34 *); - - math::MTX34 *CalcGlobalMtx(math::MTX34 *); - UNKTYPE SetMtxDirty(); - - static math::MTX34 *RestructMatrix(math::MTX34 *, math::MTX34 *, bool, bool, s8); - - u16 GetNumParticleManager() const; - ParticleManager *GetParticleManager(u16); - - inline bool GetFlagDisableCalc() const { - return mFlags & 0x200; - } -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_emitterform.h b/include/nw4r/ef/ef_emitterform.h deleted file mode 100644 index 67ba51e0..00000000 --- a/include/nw4r/ef/ef_emitterform.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef NW4R_EF_EMITTERFORM_H -#define NW4R_EF_EMITTERFORM_H -#include "common.h" - -namespace nw4r { -namespace ef { -struct EmitterForm { - virtual UNKTYPE Emission(Emitter *, ParticleManager *, int, u32, float *, u16, float, const math::MTX34 *) = 0; - - UNKTYPE CalcVelocity(math::VEC3 *, Emitter *, const math::VEC3 &, const math::VEC3 &, const math::VEC3 &, - const math::VEC3 &) const; - u16 CalcLife(u16, float, Emitter *); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_handle.h b/include/nw4r/ef/ef_handle.h deleted file mode 100644 index 34b4e1d2..00000000 --- a/include/nw4r/ef/ef_handle.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef NW4R_EF_HANDLE_H -#define NW4R_EF_HANDLE_H -#include "common.h" - -namespace nw4r { -namespace ef { -struct LinkedObject { - char UNK_0x0[8]; - LinkedObject *PTR_0x8; -}; - -struct HandleBase { - LinkedObject *PTR_0x0; - LinkedObject *mPtr; - - HandleBase(); - HandleBase &operator=(const HandleBase &); - HandleBase &operator=(LinkedObject *); - bool IsValid() const; - LinkedObject *GetPtr() const; -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_line.h b/include/nw4r/ef/ef_line.h deleted file mode 100644 index ed8067d9..00000000 --- a/include/nw4r/ef/ef_line.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NW4R_EF_LINE_H -#define NW4R_EF_LINE_H -#include "ef_emitterform.h" - -namespace nw4r -{ - namespace ef - { - struct EmitterFormLine : EmitterForm - { - virtual UNKTYPE Emission(Emitter *, ParticleManager *, int, u32, float *, u16, float, const math::MTX34 *); - }; - } -} - -#endif \ No newline at end of file diff --git a/include/nw4r/ef/ef_list.h b/include/nw4r/ef/ef_list.h deleted file mode 100644 index 09efa06e..00000000 --- a/include/nw4r/ef/ef_list.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef NW4R_EF_LIST -#define NW4R_EF_LIST -#include "common.h" -#include "ut_list.h" - -namespace nw4r { -namespace ef { -// sizeof(ActivityList) = 0x1C -struct ActivityList { - ut::List mActive; - ut::List mClosing; - u16 mNumActive; - - inline void SetOffset(u16 offset) { - ut::List_Init(&mActive, offset); - ut::List_Init(&mClosing, offset); - mNumActive = 0; - } - - inline ActivityList(u16 offset) { - SetOffset(offset); - } - - inline ActivityList() { - SetOffset(0); - } - - inline void Initialize() { - mActive.first = NULL; - mActive.size = 0; - mActive.last = NULL; - - mClosing.first = NULL; - mClosing.size = 0; - mClosing.last = NULL; - - mNumActive = 0; - } - - inline void ToActive(void *pNode) { - ut::List_Append(&mActive, pNode); - mNumActive++; - } - - inline void ToClosing(void *pNode) { - ut::List_Remove(&mActive, pNode); - ut::List_Append(&mClosing, pNode); - } - - inline void ToWait(void *pNode) { - mNumActive--; - } -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_memorymanager.h b/include/nw4r/ef/ef_memorymanager.h deleted file mode 100644 index 198778d3..00000000 --- a/include/nw4r/ef/ef_memorymanager.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NW4R_EF_MEMORYMANAGER -#define NW4R_EF_MEMORYMANAGER -#include "ef_memorymanagerbase.h" - -namespace nw4r -{ - namespace ef - { - struct MemoryManager : MemoryManagerBase - { - - }; - } -} - -#endif \ No newline at end of file diff --git a/include/nw4r/ef/ef_memorymanagerbase.h b/include/nw4r/ef/ef_memorymanagerbase.h deleted file mode 100644 index 61c67bbe..00000000 --- a/include/nw4r/ef/ef_memorymanagerbase.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef NW4R_EF_MEMORYMANAGERBASE -#define NW4R_EF_MEMORYMANAGERBASE -#include "common.h" - -namespace nw4r { -namespace ef { -struct MemoryManagerBase { - virtual ~MemoryManagerBase(); // at 0x8 - virtual UNKTYPE GarbageCollection() = 0; // at 0xc - - virtual Effect *AllocEffect() = 0; // at 0x10 - virtual UNKTYPE FreeEffect(void *) = 0; // at 0x14 - virtual UNKWORD GetNumAllocEffect() const = 0; // at 0x18 - virtual UNKWORD GetNumActiveEffect() const = 0; // at 0x1c - virtual UNKWORD GetNumFreeEffect() const = 0; // at 0x20 - - virtual Emitter *AllocEmitter() = 0; // at 0x24 - virtual UNKTYPE FreeEmitter(void *) = 0; // at 0x28 - virtual UNKWORD GetNumAllocEmitter() const = 0; // at 0x2c - virtual UNKWORD GetNumActiveEmitter() const = 0; // at 0x30 - virtual UNKWORD GetNumFreeEmitter() const = 0; // at 0x34 - - virtual ParticleManager *AllocParticleManager() = 0; // at 0x38 - virtual UNKTYPE FreeParticleManager(void *) = 0; // at 0x3c - virtual UNKWORD GetNumAllocParticleManager() const = 0; // at 0x40 - virtual UNKWORD GetNumActiveParticleManager() const = 0; // at 0x44 - virtual UNKWORD GetNumFreeParticleManager() const = 0; // at 0x48 - - virtual Particle *AllocParticle() = 0; // at 0x4c - virtual UNKTYPE FreeParticle(void *) = 0; // at 0x50 - virtual UNKWORD GetNumAllocParticle() const = 0; // at 0x54 - virtual UNKWORD GetNumActiveParticle() const = 0; // at 0x58 - virtual UNKWORD GetNumFreeParticle() const = 0; // at 0x5c - - virtual void *AllocHeap(u32) = 0; // at 0x60 -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_particle.h b/include/nw4r/ef/ef_particle.h deleted file mode 100644 index f0c36aaf..00000000 --- a/include/nw4r/ef/ef_particle.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef NW4R_EF_PARTICLE_H -#define NW4R_EF_PARTICLE_H -#include "common.h" -#include "ef_ref.h" - -namespace nw4r { -namespace ef { -struct Particle : ReferencedObject { - char UNK_0x20[0x8C]; - - math::VEC3 VEC_0xAC; - math::VEC3 VEC_0xB8; - - char UNK_0xC4[0x4]; - - ParticleManager *mManager; // at 0xc8 -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_particlemanager.h b/include/nw4r/ef/ef_particlemanager.h deleted file mode 100644 index f4fd3b20..00000000 --- a/include/nw4r/ef/ef_particlemanager.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef NW4R_EF_PARTICLEMANAGER -#define NW4R_EF_PARTICLEMANAGER -#include "common.h" -#include "ef_list.h" -#include "ef_ref.h" -#include "math_types.h" -#include "ut_Color.h" - -namespace nw4r { -namespace ef { -struct ParticleManager : ReferencedObject { - struct ParticleModifier { - math::VEC2 mScale; // at 0x0 - math::VEC3 mRotate; // at 0x8 - - struct SimpleLight { - u8 mType; // at 0x0 - ut::Color mAmbColor; // at 0x1 - } mLight; - }; - - UNKTYPE BeginDraw(); - UNKTYPE EndDraw(); - UNKTYPE BeginCalc(bool); - UNKTYPE EndCalc(); - - bool SendClosing(); - UNKTYPE DestroyFunc(); - virtual bool Initialize(Emitter *, EmitterResource *); - virtual UNKTYPE CreateParticle(u16, math::VEC3, math::VEC3, const math::MTX34 *, float, - const EmitterInheritSetting *, Particle *, u16); - virtual UNKTYPE Calc(); - virtual UNKTYPE Draw(const DrawInfo &); - - Emitter *mEmitter; // at 0x20 - EmitterResource *mResource; // at 0x24 - UNKWORD FLAGS_0x28; - char UNK_0x2C[0xC]; - ActivityList EFLIST_0x38; - char UNK_0x54[0x4]; - - ParticleModifier mMod; // at 0x58 - - char UNK_0x74[0x14]; - - s8 BYTE_0x88; - u8 BYTE_0x89; - bool BOOL_0x8A; - - UNKWORD FLAGS_0xB4; - - u16 RetireParticleAll(); - - UNKTYPE CalcGlobalMtx(math::MTX34 *); - - static void ModifierTravFunc_SetSimpleLightType(void *p, u32 payload) { - ParticleManager *mgr = (ParticleManager *)p; - u8 type = (u8)payload; - mgr->mMod.mLight.mType = type; - } - - static void ModifierTravFunc_SetSimpleLightAmbient(void *p, u32 payload) { - ParticleManager *mgr = (ParticleManager *)p; - ut::Color *color = (ut::Color *)payload; - mgr->mMod.mLight.mAmbColor = *color; - } - - static void ModifierTravFunc_SetScale(void *p, u32 payload) { - ParticleManager *mgr = (ParticleManager *)p; - math::VEC2 *scale = (math::VEC2 *)payload; - mgr->mMod.mScale = *scale; - } - - static void ModifierTravFunc_SetRotate(void *p, u32 payload) { - ParticleManager *mgr = (ParticleManager *)p; - math::VEC3 *rot = (math::VEC3 *)payload; - mgr->mMod.mRotate = *rot; - } -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_point.h b/include/nw4r/ef/ef_point.h deleted file mode 100644 index 3fdebae6..00000000 --- a/include/nw4r/ef/ef_point.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NW4R_EF_POINT_H -#define NW4R_EF_POINT_H -#include "ef_emitterform.h" - -namespace nw4r -{ - namespace ef - { - struct EmitterFormPoint : EmitterForm - { - virtual UNKTYPE Emission(Emitter *, ParticleManager *, int, u32, float *, u16, float, const math::MTX34 *); - }; - } -} - -#endif \ No newline at end of file diff --git a/include/nw4r/ef/ef_rand.h b/include/nw4r/ef/ef_rand.h deleted file mode 100644 index 18741a1a..00000000 --- a/include/nw4r/ef/ef_rand.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef NW4R_EF_RAND_H -#define NW4R_EF_RAND_H -#include "common.h" - -namespace nw4r { -namespace ef { -struct Random { - u32 mSeed; // at 0x0 - - inline u32 MixRandomSeed() { - return mSeed = mSeed * 0x343fd + 0x269ec3; - } - - inline void Srand(u32 seed) { - mSeed = seed; - } - - inline u32 Rand() { - // WARNING: THIS INLINE FUNCTION MAY NOT BE ACCURATE - return MixRandomSeed() >> 0x10; - } - - inline float RandFloat() { - // WARNING: THIS INLINE FUNCTION MAY NOT BE ACCURATE - return (float)Rand() / 0xFFFF; - } -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_ref.h b/include/nw4r/ef/ef_ref.h deleted file mode 100644 index 4f71969f..00000000 --- a/include/nw4r/ef/ef_ref.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef NW4R_EF_REF -#define NW4R_EF_REF -#include "common.h" -#include "math_types.h" - -namespace nw4r { -namespace ef { -struct ReferencedObject { - char UNK_0x0[0xC]; - UNKWORD WORD_0xC; - u32 mRefCount; // at 0x10 - char UNK_0x14[0x8]; - - virtual bool SendClosing(); - virtual UNKTYPE DestroyFunc(); - - inline void Initialize() { - mRefCount = 0; - WORD_0xC = 1; - } - - inline void Ref() { - mRefCount++; - } - - inline void UnRef() { - if (--mRefCount == 0 && WORD_0xC == 2) { - SendClosing(); - } - } - - inline void Destroy() { - DestroyFunc(); - WORD_0xC = 2; - if (mRefCount == 0) { - SendClosing(); - } - } -}; - -typedef ReferencedObject UNKREF; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_resource.h b/include/nw4r/ef/ef_resource.h deleted file mode 100644 index ac461516..00000000 --- a/include/nw4r/ef/ef_resource.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef NW4R_EF_RESOURCE -#define NW4R_EF_RESOURCE -#include "common.h" - -namespace nw4r { -namespace ef { -struct Resource { - EmitterResource *_FindEmitter(const char *, EffectProject *) const; - - static Resource *GetInstance(); -}; -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/ef/ef_sphere.h b/include/nw4r/ef/ef_sphere.h deleted file mode 100644 index 88aa9ca2..00000000 --- a/include/nw4r/ef/ef_sphere.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NW4R_EF_SPHERE_H -#define NW4R_EF_SPHERE_H -#include "ef_emitterform.h" - -namespace nw4r -{ - namespace ef - { - struct EmitterFormSphere : EmitterForm - { - virtual UNKTYPE Emission(Emitter *, ParticleManager *, int, u32, float *, u16, float, const math::MTX34 *); - }; - } -} - -#endif \ No newline at end of file diff --git a/include/nw4r/ef/ef_torus.h b/include/nw4r/ef/ef_torus.h deleted file mode 100644 index e9521c19..00000000 --- a/include/nw4r/ef/ef_torus.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef NW4R_EF_TORUS_H -#define NW4R_EF_TORUS_H -#include "ef_emitterform.h" - -namespace nw4r -{ - namespace ef - { - struct EmitterFormTorus : EmitterForm - { - virtual UNKTYPE Emission(Emitter *, ParticleManager *, int, u32, float *, u16, float, const math::MTX34 *); - }; - } -} - -#endif \ No newline at end of file diff --git a/include/nw4r/ef/ef_util.h b/include/nw4r/ef/ef_util.h deleted file mode 100644 index 81ca35ef..00000000 --- a/include/nw4r/ef/ef_util.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef NW4R_EF_UTIL -#define NW4R_EF_UTIL -#include "common.h" -#include "ut_list.h" - -namespace nw4r { -namespace ef { -typedef void (*Action)(void *, u32); - -u16 UtlistToArray(const ut::List *, void **, int); - -UNKTYPE GetDirMtxY(math::MTX34 *, const math::VEC3 &); -UNKTYPE MtxGetRotation(const math::MTX34 &, math::VEC3 *); -UNKTYPE MtxGetTranslate(const math::MTX34 &, math::VEC3 *); -UNKTYPE MtxGetRotationMtx(const math::MTX34 &, math::MTX34 *); -UNKTYPE MtxGetScale(const math::MTX34 &, math::VEC3 *); -} // namespace ef -} // namespace nw4r - -#endif diff --git a/include/nw4r/lyt/lyt_animation.h b/include/nw4r/lyt/lyt_animation.h index c0d9f7cc..90ee30c0 100644 --- a/include/nw4r/lyt/lyt_animation.h +++ b/include/nw4r/lyt/lyt_animation.h @@ -1,21 +1,77 @@ #ifndef NW4R_LYT_ANIMATION_H #define NW4R_LYT_ANIMATION_H #include "common.h" -#include "nw4r/lyt/lyt_common.h" -#include "nw4r/lyt/lyt_resourceAccessor.h" -#include "nw4r/ut/ut_LinkList.h" +#include +#include +#include +#include namespace nw4r { namespace lyt { namespace res { -struct AnimationBlock {}; +struct AnimationBlock { + DataBlockHeader blockHeader; // at 0x00 + u16 frameSize; // at 0x08 + bool loop; // at 0x0A + u8 padding1; // at 0x0B + u16 fileNum; // at 0x0C + u16 animContNum; // at 0x0E + u32 animContOffsetsOffset; // at 0x10 +}; + +struct AnimationTagBlock { + DataBlockHeader blockHeader; // at 0x00 + u16 tagOrder; // at 0x08 + u16 groupNum; // at 0x0A + u32 nameOffset; // at 0x0C + u32 groupsOffset; // at 0x10 + u16 startFrame; // at 0x14 + u16 endFrame; // at 0x16 + u8 flag; // at 0x18 + u8 padding[3]; // at 0x19 +}; + +struct AnimationShareBlock { + DataBlockHeader blockHeader; // at 0x00 + u32 animShareInfoOffset; // at 0x04 + u16 shareNum; // at 0x0C + u8 padding[2]; // at 0x0E +}; } // namespace res -struct AnimationBlock { - res::DataBlockHeader header; // at 0x0 - u16 frameSize; // at 0x8 - bool loop; // at 0xA - // . . . +struct AnimResource { + AnimResource(const void *anmResBuf) { + // TODO + } + + const res::BinaryFileHeader *mpFileHeader; // at 0x00 + const res::AnimationBlock *mpResBlock; // at 0x04 + const res::AnimationTagBlock *mpTagBlock; // at 0x08 + const res::AnimationShareBlock *mpShareBlock; // at 0x0C +}; + +namespace detail { +struct AnimPaneTree { + AnimPaneTree(Pane *pTargetPane, const AnimResource &animRes) : mAnimRes(animRes) { + // TODO + } + + bool IsEnabled() const { + // TODO + return false; + } + + AnimResource mAnimRes; // at 0x00 + u16 mAnimPaneIdx; // at 0x10 + u16 mLinkNum; // at 0x12 + u16 mAnimMatIdx[9]; // at 0x14 + u8 mAnimMatCnt; // at 0x26 +}; +} // namespace detail +struct AnimationGroupRef { + char name[17]; // at 0x00 + u8 flag; // at 0x11 + u8 padding[2]; // at 0x12 }; struct AnimTransform { @@ -31,9 +87,9 @@ struct AnimTransform { virtual void Animate(u32 idx, Pane *pPane) = 0; virtual void Animate(u32 idx, Material *pMaterial) = 0; - ut::LinkListNode mLink; // at 0x0 - AnimationBlock *mpRes; // at 0xC - f32 mFrame; // at 0x10 + ut::LinkListNode mLink; // at 0x4 + res::AnimationBlock *mpRes; // at 0xC + f32 mFrame; // at 0x10 }; struct AnimationLink { diff --git a/include/nw4r/lyt/lyt_bounding.h b/include/nw4r/lyt/lyt_bounding.h index 56740463..0131c016 100644 --- a/include/nw4r/lyt/lyt_bounding.h +++ b/include/nw4r/lyt/lyt_bounding.h @@ -2,6 +2,7 @@ #define NW4R_LYT_BOUNDING_H #include "common.h" #include "nw4r/lyt/lyt_drawInfo.h" +#include "nw4r/lyt/lyt_material.h" #include "nw4r/lyt/lyt_pane.h" namespace nw4r { @@ -10,15 +11,19 @@ namespace res { struct Bounding : Pane {}; } // namespace res -struct ResBlockSet {}; +struct ResBlockSet { + const res::TextureList *pTextureList; // at 0x00 + const res::FontList *pFontList; // at 0x04 + const res::MaterialList *pMaterialList; // at 0x08 + ResourceAccessor *pResAccessor; // at 0x0C +}; -struct Bounding : Pane { +class Bounding : public Pane { +public: Bounding(const res::Bounding *, const ResBlockSet &); virtual ~Bounding(); - virtual const ut::detail::RuntimeTypeInfo *GetRuntimeTypeInfo() const; + NW4R_UT_RTTI_DECL(Bounding); virtual void DrawSelf(const DrawInfo &); - - static ut::detail::RuntimeTypeInfo typeInfo; }; } // namespace lyt } // namespace nw4r diff --git a/include/nw4r/lyt/lyt_common.h b/include/nw4r/lyt/lyt_common.h index 7b488f63..c84d0065 100644 --- a/include/nw4r/lyt/lyt_common.h +++ b/include/nw4r/lyt/lyt_common.h @@ -12,7 +12,14 @@ namespace nw4r { namespace lyt { namespace res { -struct BinaryFileHeader : ut::BinaryFileHeader {}; +struct BinaryFileHeader { + char signature[4]; // at 0x00 + u16 byteOrder; // at 0x04; + u16 version; // at 0x06 + u32 fileSize; // at 0x08 + u16 headerSize; // at 0x0C + u16 dataBlocks; // at 0x0E +}; struct DataBlockHeader { u32 kind; // at 0x0 @@ -46,6 +53,17 @@ void SetVertexFormat(bool, u8); void DrawQuad(const math::VEC2 &, const Size &, u8, const TexCoordData *, const ut::Color *); void DrawQuad(const math::VEC2 &, const Size &, u8, const TexCoordData *, const ut::Color *, u8); void DrawLine(const math::VEC2 &pos, const Size &size, ut::Color color); + +s32 GetSignatureInt(const char *sig) { + return *((s32 *)sig); +} +bool TestFileVersion(const res::BinaryFileHeader &fileHeader) { + u32 majorVer = (fileHeader.version >> 8) & 0xFF; + u32 minorVer = fileHeader.version & 0xFF; + bool ret = majorVer == 0 && (minorVer > 7 && minorVer <= 10); + return ret; +} + } // namespace detail } // namespace lyt } // namespace nw4r diff --git a/include/nw4r/lyt/lyt_group.h b/include/nw4r/lyt/lyt_group.h index 71f429b2..9c732c2b 100644 --- a/include/nw4r/lyt/lyt_group.h +++ b/include/nw4r/lyt/lyt_group.h @@ -23,12 +23,25 @@ struct PaneLink { }; } // namespace detail -struct Group { +class Group { +public: Group(const res::Group *pResGroup, Pane *pRootPane); + virtual ~Group(); void AppendPane(Pane *pPane); void Init(); + ut::LinkList *GetPaneList() { + return &mPaneListLink; + } + bool IsUserAllocated() const { + return mbUserAllocated; + } + const char *GetName() const { + return mName; + } + +private: ut::LinkListNode mLink; // at 0x04 ut::LinkList mPaneListLink; // at 0x0C char mName[NW4R_RES_NAME_SIZE + 1]; // at 0x18 diff --git a/include/nw4r/lyt/lyt_layout.h b/include/nw4r/lyt/lyt_layout.h index 87ce0f67..39714af4 100644 --- a/include/nw4r/lyt/lyt_layout.h +++ b/include/nw4r/lyt/lyt_layout.h @@ -2,13 +2,45 @@ #define NW4R_LYT_LAYOUT_H #include "common.h" #include +#include +#include #include namespace nw4r { namespace lyt { -struct Layout { - // TO-DO: Class members +namespace res { +struct Layout { + DataBlockHeader blockheader; // at 0x00 + u8 originType; // at 0x08 + u8 padding[3]; // at 0x09 + Size layoutSize; // at 0x0C +}; + +} // namespace res + +class Layout { +public: + ut::Rect GetLayoutRect() const; + static Pane *BuildPaneObj(s32 kind, const void *dataPtr, const ResBlockSet &ResBlockSet); + + Layout(); + virtual ~Layout(); // at 0x08 + virtual bool Build(const void *lytResBuf, ResourceAccessor *pResAcsr); // at 0x0C + virtual AnimTransform *CreateAnimTransform(); // at 0x10 + virtual AnimTransform *CreateAnimTransform(const void *animResBuf, ResourceAccessor *pResAcsr); // at 0x14 + virtual AnimTransform *CreateAnimTransform(const AnimResource &animRes, ResourceAccessor *pResAcsr); // at 0x18 + virtual void BindAnimation(AnimTransform *pAnimTrans); // at 0x1C + virtual void UnbindAnimation(AnimTransform *pAnimTrans); // at 0x20 + virtual void UnbindAllAnimation(); // at 0x24 + virtual bool BindAnimationAuto(const AnimResource &animRes, ResourceAccessor *pResAcsr); // at 0x28 + virtual void SetAnimationEnable(AnimTransform *pAnimTrans, bool bEnable); // at 0x2C + virtual void CalculateMtx(const DrawInfo &drawInfo); // at 0x30 + virtual void Draw(const DrawInfo &drawInfo); // at 0x34 + virtual void Animate(u32 option); // at 0x38 + virtual void SetTagProcessor(ut::TagProcessorBase *pTagProcessor); // at 0x3C + + // STATICS static void FreeMemory(void *p) { MEMFreeToAllocator(mspAllocator, p); } @@ -57,6 +89,32 @@ struct Layout { } } + template + static T *NewObj(T2 p2) { + T *obj = (T *)AllocMemory(sizeof(T)); + if (obj) { + return new (obj) T(p2); + } else { + return nullptr; + } + } + + template + static T *NewObj(T2 p2, T3 p3) { + T *obj = (T *)AllocMemory(sizeof(T)); + if (obj) { + return new (obj) T(p2, p3); + } else { + return nullptr; + } + } + +private: + ut::LinkList mAnimTransList; // at 0x04 + Pane *mpRootPane; // at 0x10 + GroupContainer *mpGroupContainer; // at 0x14 + Size mLayoutSize; // at 0x18 + static MEMAllocator *mspAllocator; }; } // namespace lyt diff --git a/include/nw4r/lyt/lyt_material.h b/include/nw4r/lyt/lyt_material.h index e6586c63..7a8d986c 100644 --- a/include/nw4r/lyt/lyt_material.h +++ b/include/nw4r/lyt/lyt_material.h @@ -10,6 +10,15 @@ namespace nw4r { namespace lyt { +namespace res { +struct MaterialList { + DataBlockHeader blockHeader; // at 0x00 + u16 materialNum; // at 0x08 + u8 padding[2]; // at 0x0A +}; + +} // namespace res + struct BitGXNums { union { u32 texSRT; @@ -26,15 +35,26 @@ struct BitGXNums { }; struct Material { - // SetupGX__Q34nw4r3lyt8MaterialFbUc - // BindAnimation__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransform - // UnbindAnimation__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransform - // UnbindAllAnimation__Q34nw4r3lyt8MaterialFv - // Animate__Q34nw4r3lyt8MaterialFv - // FindAnimationLink__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransform - // FindAnimationLink__Q34nw4r3lyt8MaterialFRCQ34nw4r3lyt12AnimResource - // SetAnimationEnable__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransformb - // SetAnimationEnable__Q34nw4r3lyt8MaterialFRCQ34nw4r3lyt12AnimResourceb + // IsBlendModeCap__Q34nw4r3lyt8MaterialCFv + // IsAlphaCompareCap__Q34nw4r3lyt8MaterialCFv + // IsTevSwapCap__Q34nw4r3lyt8MaterialCFv + // IsMatColorCap__Q34nw4r3lyt8MaterialCFv + // IsChanCtrlCap__Q34nw4r3lyt8MaterialCFv + // SetTexSRTElement__Q34nw4r3lyt8MaterialFUlUlf + // GetTexturePtr__Q34nw4r3lyt8MaterialFUc + // GetTexSRTCap__Q34nw4r3lyt8MaterialCFv + // GetIndTexSRTCap__Q34nw4r3lyt8MaterialCFv + // SetIndTexSRTElement__Q34nw4r3lyt8MaterialFUlUlf + + ut::LinkList *GetAnimationList() { + return &mAnimList; + } + bool IsUserAllocated() const { + return mbUserAllocated; + } + const char *GetName() const { + return mName; + } virtual ~Material(); // at 0x08 virtual bool SetupGX(bool bModVtxCok, u8 alpha); // at 0x0C @@ -47,6 +67,7 @@ struct Material { virtual void SetAnimationEnable(AnimTransform *pAnimTrans, bool bEnable); // at 0x28 virtual void SetAnimationEnable(const AnimResource &animRes, bool bEnable); // at 0x2C +private: ut::LinkList mAnimList; // at 0x4 GXColorS10 mTevCols[3]; // at 0x10 ut::Color mTevKCols[4]; // at 0x28 diff --git a/include/nw4r/lyt/lyt_pane.h b/include/nw4r/lyt/lyt_pane.h index 272e226d..d7a83067 100644 --- a/include/nw4r/lyt/lyt_pane.h +++ b/include/nw4r/lyt/lyt_pane.h @@ -16,19 +16,6 @@ namespace nw4r { namespace lyt { - -struct Size { - inline Size() : width(), height() {} - - inline Size &operator=(const Size &rhs) { - width = rhs.width; - height = rhs.height; - return *this; - } - - f32 width, height; -}; - namespace detail { struct PaneBase { PaneBase(); @@ -38,14 +25,17 @@ struct PaneBase { } // namespace detail +namespace res { + // TODO: Find proper place? // GUESS: In the FindExtUserDataByName function it iterates through ExtUserData struct ExtUserData { - u32 stringOffs; - u32 UNK_0x04; - u32 UNK_0x08; + u32 nameOffs; // at 0x00 + u32 datOffs; // at 0x04 + u16 numEntries; // at 0x08 + u8 type; // at 0x0A + u8 padding; // at 0x0B }; -namespace res { struct ExtUserDataList { DataBlockHeader blockHeader; // at 0x00 @@ -67,20 +57,70 @@ struct Pane { }; } // namespace res -struct Pane : detail::PaneBase { +class Pane : detail::PaneBase { +public: // For use with TestBit enum PaneBits { VISIBLE, INFLUENCED_ALPHA, LOCATION_ADJUST }; bool IsVisible() const { return detail::TestBit(mFlag, VISIBLE); } + void SetVisible(bool bVisible) { + detail::SetBit(&mFlag, VISIBLE, bVisible); + } bool IsInfluencedAlpha() const { return detail::TestBit(mFlag, INFLUENCED_ALPHA); } bool IsLocationAdjust() const { return detail::TestBit(mFlag, LOCATION_ADJUST); } + bool IsUserAllocated() const { + return mbUserAllocated; + } + ut::LinkList *GetChildList() { + return &mChildList; + } + ut::LinkList *GetAnimationList() { + return &mAnimList; + } + + const math::MTX34 *GetGlobalMtx() const { + return &mGlbMtx; + } + Pane *GetParent() const { + return mpParent; + } + + const math::VEC2 *GetScale() const { + return &mScale; + } + void SetScale(const math::VEC2 &value) { + mScale = value; + } + + u8 GetAlpha() const { + return mAlpha; + } + void SetAlpha(u8 value) { + mAlpha = value; + } + + const Size *GetSize() const { + return &mSize; + } + void SetSize(const Size &value) { + mSize = value; + } + + const res::ExtUserDataList *GetExtUserDataList() const { + return mpExtUserDataList; + } + void SetExtUserDataList(const res::ExtUserDataList *pBlock) { + mpExtUserDataList = pBlock; + } + + Pane(); Pane(const res::Pane *pBlock); void Init(); void SetName(const char *pName); @@ -96,11 +136,11 @@ struct Pane : detail::PaneBase { math::VEC2 GetVtxPos() const; void CalculateMtxChild(const DrawInfo &drawInfo); u16 GetExtUserDataNum() const; - ExtUserData *GetExtUserData() const; - ExtUserData *FindExtUserDataByName(const char *name); + res::ExtUserData *GetExtUserData() const; + res::ExtUserData *FindExtUserDataByName(const char *name); virtual ~Pane(); // at 0x8 - virtual const ut::detail::RuntimeTypeInfo *GetRuntimeTypeInfo() const; // at 0xC + NW4R_UT_RTTI_DECL(Pane); // at 0x0C virtual void CalculateMtx(const DrawInfo &drawInfo); // at 0x10 virtual void Draw(const DrawInfo &); // at 0x14 virtual void DrawSelf(const DrawInfo &); // at 0x18 @@ -127,27 +167,26 @@ struct Pane : detail::PaneBase { virtual Material *GetMaterial(u32 idx) const; // at 0x6C virtual void LoadMtx(const DrawInfo &drawInfo); // at 0x70 - Pane *mpParent; // at 0x0C - ut::LinkList mChildList; // at 0x10 - ut::LinkList mAnimList; // at 0x1C; - Material *mpMaterial; // at 0x28 - math::VEC3 mTranslate; // at 0x2C - math::VEC3 mRotate; // at 0x38 - math::VEC2 mScale; // at 0x44 - Size mSize; // at 0x4C - math::MTX34 mMtx; // at 0x54 - math::MTX34 mGlbMtx; // at 0x84 - res::ExtUserDataList *mpExtUserDataList; // at 0xB4 - u8 mAlpha; // at 0xB8 - u8 mGlbAlpha; // at 0xB9 - u8 mBasePosition; // at 0xBA - u8 mFlag; // at 0xBB - char mName[PANE_NAME_SIZE + 1]; // at 0xBC - char mUserData[PANE_USERDATA_SIZE + 1]; // at 0xCD - bool mbUserAllocated; // at 0xD6 - u8 mPadding; // at 0xD7 - - static ut::detail::RuntimeTypeInfo typeInfo; +private: + Pane *mpParent; // at 0x0C + ut::LinkList mChildList; // at 0x10 + ut::LinkList mAnimList; // at 0x1C; + Material *mpMaterial; // at 0x28 + math::VEC3 mTranslate; // at 0x2C + math::VEC3 mRotate; // at 0x38 + math::VEC2 mScale; // at 0x44 + Size mSize; // at 0x4C + math::MTX34 mMtx; // at 0x54 + math::MTX34 mGlbMtx; // at 0x84 + const res::ExtUserDataList *mpExtUserDataList; // at 0xB4 + u8 mAlpha; // at 0xB8 + u8 mGlbAlpha; // at 0xB9 + u8 mBasePosition; // at 0xBA + u8 mFlag; // at 0xBB + char mName[PANE_NAME_SIZE + 1]; // at 0xBC + char mUserData[PANE_USERDATA_SIZE + 1]; // at 0xCD + bool mbUserAllocated; // at 0xD6 + u8 mPadding; // at 0xD7 }; } // namespace lyt } // namespace nw4r diff --git a/include/nw4r/lyt/lyt_picture.h b/include/nw4r/lyt/lyt_picture.h new file mode 100644 index 00000000..8df1e561 --- /dev/null +++ b/include/nw4r/lyt/lyt_picture.h @@ -0,0 +1,32 @@ +#ifndef NW4R_LYT_PICTURE_H +#define NW4R_LYT_PICTURE_H + +#include +#include + +namespace nw4r { + +namespace lyt { + +namespace res { + +struct Picture : public Pane {}; + +} // namespace res + +class Picture : public Pane { +public: + Picture(const res::Picture *, const ResBlockSet &resDataSet); + virtual ~Picture(); + NW4R_UT_RTTI_DECL(Picture); + +private: + ut::Color mVtxColors[4]; // at 0xD8 + detail::TexCoordAry mTexCoordAry; // at 0xE8 +}; + +} // namespace lyt + +} // namespace nw4r + +#endif diff --git a/include/nw4r/lyt/lyt_textBox.h b/include/nw4r/lyt/lyt_textBox.h new file mode 100644 index 00000000..4eefc5b4 --- /dev/null +++ b/include/nw4r/lyt/lyt_textBox.h @@ -0,0 +1,55 @@ +#ifndef LYT_TEXT_BOX_H +#define LYT_TEXT_BOX_H + +#include + +namespace nw4r { + +namespace lyt { +namespace res { + +struct TextBox : public Pane { + u16 textBufBytes; // at 0x4C + u16 materialIdx; // at 0x50 + u16 fontIdx; // at 0x52 + u8 textPosition; // at 0x54 + u8 textAlignment; // at 0x55 + u8 padding[2]; // at 0x56 + u32 textStrOffset; // at 0x58 + u32 textCols[2]; // at 0x5C + Size fontSize; // at 0x64 + f32 charSpace; // at 0x6C + f32 lineSpace; // at 0x70 +}; + +} // namespace res + +class TextBox : public Pane { +public: + void SetTagProcessor(ut::TagProcessorBase *pTagProcessor) { + mpTagProcessor = pTagProcessor; + } + + TextBox(const res::TextBox *, const ResBlockSet &resBlockSet); + virtual ~TextBox(); + NW4R_UT_RTTI_DECL(TextBox); + + wchar_t *mTextBuf; // at 0xD8 // ptr to is Guess + ut::Color mTextColors[2]; // at 0xDC + ut::Font *mpFont; // at 0xE4 + Size mFontSize; // at 0xE8 + f32 mLineSpace; // at 0xF0 + f32 mCharSpace; // at 0xF4 + ut::TagProcessorBase *mpTagProcessor; // at 0xF8 + u16 mTextBufBytes; // at 0xFC + u16 mTextLen; // at 0xFE + u8 mTextPosition; // at 0x100 + struct { // + u8 bAllocFont : 1; // + u8 textAligntment : 1; // + } mBits; // at 0x101 +}; + +} // namespace lyt +} // namespace nw4r +#endif diff --git a/include/nw4r/lyt/lyt_types.h b/include/nw4r/lyt/lyt_types.h index e9ece89e..97e5890d 100644 --- a/include/nw4r/lyt/lyt_types.h +++ b/include/nw4r/lyt/lyt_types.h @@ -1,16 +1,81 @@ #ifndef NW4R_LYT_TYPES_H #define NW4R_LYT_TYPES_H +#include #include namespace nw4r { namespace lyt { + +struct Size { + inline Size() : width(), height() {} + + inline Size &operator=(const Size &rhs) { + width = rhs.width; + height = rhs.height; + return *this; + } + + f32 width, height; +}; + +namespace res { +// struct AnimationBlock {}; // in lyt_animation.h +// struct AnimationTagBlock {}; // in lyt_animation.h +// struct AnimationShareBlock {}; // in lyt_animation.h +// struct Bounding {}; // in lyt_bounding.h +// struct Group {}; // in lyt_group.h +// struct Material {}; // in lyt_material.h +// struct Pane {}; // in lyt_pane.h +// struct TextBox {}; // in lyt_textbox.h +// struct Window {}; // in lyt_window.h +// struct BinaryFileHeader {}; // in lyt_common.h + +// IDK Proper place for this one +struct FontList { + DataBlockHeader blockHeader; // at 0x00 + u16 fontNum; // at 0x08 + u8 padding[2]; // at 0x0A +}; + +struct TextureList { + DataBlockHeader blockHeader; // at 0x00 + u16 texNum; // at 0x08 + u8 padding[2]; // at 0x0A +}; + +// belong in Animation? +struct HermiteKey {}; +struct StepKey {}; + +} // namespace res + +struct AnimationShareInfo { + const char *GetSrcPaneName() const { + return srcPaneName; + } + + char srcPaneName[17]; // at 0x00 + char targetGroupName[17]; // at 0x11 + u8 padding[2]; // at 0x12 +}; namespace detail { template inline bool TestBit(T bits, int index) { T mask = 1 << index; return bits & mask; } +template +inline bool SetBit(T *bits, int pos, bool val) { + T mask = T(1 << pos); + *bits = T((*bits & ~mask)) | (val << pos); +} + +template +T *ConvertOffsetToPtr(const void *baseAddress, unsigned int offset) { + return (T *)((u32)baseAddress + offset); +} + } // namespace detail } // namespace lyt diff --git a/include/nw4r/lyt/lyt_window.h b/include/nw4r/lyt/lyt_window.h new file mode 100644 index 00000000..4a3c304a --- /dev/null +++ b/include/nw4r/lyt/lyt_window.h @@ -0,0 +1,69 @@ +#ifndef NW4R_LYT_WINDOW_H +#define NW4R_LYT_WINDOW_H + +#include +#include +#include +#include + +namespace nw4r { + +namespace lyt { + +namespace res { + +// TODO: Idk where this is stored +struct InflationLRTB { + f32 l; // at 0x00 + f32 r; // at 0x04 + f32 t; // at 0x08 + f32 b; // at 0x0C +}; + +struct Window : res::Pane { + InflationLRTB inflation; // at 0x4C + u8 frameNum; // at 0x5C + u8 padding1; // at 0x5D + u8 padding2; // at 0x5E + u8 padding3; // at 0x5F + u32 contentOffset; // at 0x60 + u32 frameOffsetTableOffset; // at 0x64 +}; + +} // namespace res + +struct Content { + ut::Color vtxColors[4]; // at 0x00 + detail::TexCoordAry texCoordAry; // at 0x10 +}; + +struct Frame { + bool textureFlip; // at 0x00 + Material *pMaterial; // at 0x04 +}; + +struct WindowFramSize { + f32 l; // at 0x00 + f32 r; // at 0x04 + f32 t; // at 0x08 + f32 b; // at 0x0C +}; + +class Window : public Pane { +public: + Window(const res::Window *, const ResBlockSet &ResBlockSet); + virtual ~Window(); + NW4R_UT_RTTI_DECL(Window); + +private: + res::InflationLRTB mContentInflation; // at 0x0D8 + Content mContent; // at 0x0E8 + Frame *mFrams; // at 0x100 + u8 mFrameNum; // 0x104 +}; + +} // namespace lyt + +} // namespace nw4r + +#endif diff --git a/include/nw4r/ut/ut_RuntimeTypeInfo.h b/include/nw4r/ut/ut_RuntimeTypeInfo.h index 43c7f3d0..83ac5d85 100644 --- a/include/nw4r/ut/ut_RuntimeTypeInfo.h +++ b/include/nw4r/ut/ut_RuntimeTypeInfo.h @@ -3,30 +3,27 @@ #include // Declare type RTTI and accessor function -#define NW4R_UT_RTTI_DECL(T) \ - static nw4r::ut::detail::RuntimeTypeInfo typeInfo; \ - virtual const nw4r::ut::detail::RuntimeTypeInfo* GetRuntimeTypeInfo() \ - const { \ - return &typeInfo; \ +#define NW4R_UT_RTTI_DECL(T) \ + static nw4r::ut::detail::RuntimeTypeInfo typeInfo; \ + virtual const nw4r::ut::detail::RuntimeTypeInfo *GetRuntimeTypeInfo() const { \ + return &typeInfo; \ } // Define type RTTI (base type) -#define NW4R_UT_RTTI_DEF_BASE(T) \ - nw4r::ut::detail::RuntimeTypeInfo T::typeInfo(NULL) +#define NW4R_UT_RTTI_DEF_BASE(T) nw4r::ut::detail::RuntimeTypeInfo T::typeInfo(NULL) // Define type RTTI (derived type) -#define NW4R_UT_RTTI_DEF_DERIVED(T, BASE) \ - nw4r::ut::detail::RuntimeTypeInfo T::typeInfo(&BASE::typeInfo) +#define NW4R_UT_RTTI_DEF_DERIVED(T, BASE) nw4r::ut::detail::RuntimeTypeInfo T::typeInfo(&BASE::typeInfo) namespace nw4r { namespace ut { namespace detail { struct RuntimeTypeInfo { - RuntimeTypeInfo(const RuntimeTypeInfo* base) : mBase(base) {} + RuntimeTypeInfo(const RuntimeTypeInfo *base) : mBase(base) {} - bool IsDerivedFrom(const RuntimeTypeInfo* base) const { - for (const RuntimeTypeInfo* it = this; it != NULL; it = it->mBase) { + bool IsDerivedFrom(const RuntimeTypeInfo *base) const { + for (const RuntimeTypeInfo *it = this; it != NULL; it = it->mBase) { if (it == base) { return true; } @@ -35,24 +32,22 @@ struct RuntimeTypeInfo { return false; } - const RuntimeTypeInfo* mBase; // at 0x0 + const RuntimeTypeInfo *mBase; // at 0x0 }; template -inline const RuntimeTypeInfo* GetTypeInfoFromPtr_(T* ptr) { +inline const RuntimeTypeInfo *GetTypeInfoFromPtr_(T *ptr) { return &ptr->typeInfo; } } // namespace detail template -inline TDerived DynamicCast(TBase* ptr) { +inline TDerived DynamicCast(TBase *ptr) { // Derived type info - const detail::RuntimeTypeInfo* derivedTypeInfo = - detail::GetTypeInfoFromPtr_(static_cast(NULL)); - + const detail::RuntimeTypeInfo *derivedTypeInfo = detail::GetTypeInfoFromPtr_(static_cast(NULL)); // Downcast if possible - if (ptr->GetRuntimeTypeInfo()->IsDerivedFrom(derivedTypeInfo)) { + if (ptr && ptr->GetRuntimeTypeInfo()->IsDerivedFrom(derivedTypeInfo)) { return static_cast(ptr); } diff --git a/include/nw4r/ut/ut_algorithm.h b/include/nw4r/ut/ut_algorithm.h index 38aa38ab..802d086f 100644 --- a/include/nw4r/ut/ut_algorithm.h +++ b/include/nw4r/ut/ut_algorithm.h @@ -9,20 +9,29 @@ namespace { /** * Value operations */ -template inline T Max(T t1, T t2) { return (t1 < t2) ? t2 : t1; } +template +inline T Max(T t1, T t2) { + return (t1 < t2) ? t2 : t1; +} -template inline T Min(T t1, T t2) { return (t1 > t2) ? t2 : t1; } +template +inline T Min(T t1, T t2) { + return (t1 > t2) ? t2 : t1; +} -template inline T Clamp(T value, T min, T max) { +template +inline T Clamp(T value, T min, T max) { return value > max ? max : (value < min ? min : value); } -template inline T Abs(T x) { +template +inline T Abs(T x) { // Static cast needed to break abs optimization during instruction selection return x < 0 ? static_cast(-x) : static_cast(x); } -template <> f32 inline Abs(register f32 x) { +template <> +f32 inline Abs(register f32 x) { register f32 ax; // clang-format off @@ -37,54 +46,62 @@ template <> f32 inline Abs(register f32 x) { /** * Bit operations */ -template inline T BitExtract(T bits, int pos, int len) { +template +inline T BitExtract(T bits, int pos, int len) { T mask = (1 << len) - 1; return (bits >> pos) & mask; } -template inline bool TestBit(T t, int bitIndexLSB) { +template +inline bool TestBit(T t, int bitIndexLSB) { return BitExtract(t, sizeof(T), bitIndexLSB); } /** * Pointer operations */ -inline u32 GetIntPtr(const void* ptr) { return reinterpret_cast(ptr); } - -template -inline const void* AddOffsetToPtr(const void* ptr, T offset) { - return reinterpret_cast(GetIntPtr(ptr) + offset); +inline u32 GetIntPtr(const void *ptr) { + return reinterpret_cast(ptr); } -inline s32 GetOffsetFromPtr(const void* start, const void* end) { +template +inline const void *AddOffsetToPtr(const void *ptr, T offset) { + return reinterpret_cast(GetIntPtr(ptr) + offset); +} + +inline s32 GetOffsetFromPtr(const void *start, const void *end) { return static_cast(GetIntPtr(end) - GetIntPtr(start)); } -inline int ComparePtr(const void* p1, const void* p2) { +inline int ComparePtr(const void *p1, const void *p2) { return static_cast(GetIntPtr(p1) - GetIntPtr(p2)); } /** * Rounding */ -template inline T RoundUp(T t, unsigned int alignment) { +template +inline T RoundUp(T t, unsigned int alignment) { return (alignment + t - 1) & ~(alignment - 1); } -template inline void* RoundUp(T* t, unsigned int alignment) { +template +inline void *RoundUp(T *t, unsigned int alignment) { u32 value = reinterpret_cast(t); u32 rounded = (alignment + value - 1) & ~(alignment - 1); - return reinterpret_cast(rounded); + return reinterpret_cast(rounded); } -template inline T RoundDown(T t, unsigned int alignment) { +template +inline T RoundDown(T t, unsigned int alignment) { return t & ~(alignment - 1); } -template inline void* RoundDown(T* t, unsigned int alignment) { +template +inline void *RoundDown(T *t, unsigned int alignment) { u32 value = reinterpret_cast(t); u32 rounded = value & ~(alignment - 1); - return reinterpret_cast(rounded); + return reinterpret_cast(rounded); } } // namespace diff --git a/src/nw4r/lyt/lyt_common.cpp b/src/nw4r/lyt/lyt_common.cpp index 795a908f..922cf77b 100644 --- a/src/nw4r/lyt/lyt_common.cpp +++ b/src/nw4r/lyt/lyt_common.cpp @@ -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 { diff --git a/src/nw4r/lyt/lyt_group.cpp b/src/nw4r/lyt/lyt_group.cpp index 493c25fc..82433fdf 100644 --- a/src/nw4r/lyt/lyt_group.cpp +++ b/src/nw4r/lyt/lyt_group.cpp @@ -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(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::Iterator currIt = it++; this->mGroupList.Erase(currIt); - if (!currIt->mbUserAllocated) { + if (!currIt->IsUserAllocated()) { Layout::DeleteObj(&*currIt); } } @@ -64,7 +65,7 @@ void GroupContainer::AppendGroup(Group *pGroup) { Group *GroupContainer::FindGroupByName(const char *findName) { for (ut::LinkList::Iterator it = this->mGroupList.GetBeginIter(); it != this->mGroupList.GetEndIter(); it++) { - if (detail::EqualsResName(it->mName, findName)) { + if (detail::EqualsResName(it->GetName(), findName)) { return &*it; } } diff --git a/src/nw4r/lyt/lyt_layout.cpp b/src/nw4r/lyt/lyt_layout.cpp index e69de29b..75f8a4ee 100644 --- a/src/nw4r/lyt/lyt_layout.cpp +++ b/src/nw4r/lyt/lyt_layout.cpp @@ -0,0 +1,244 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace nw4r { + +namespace lyt { + +// mspAllocator__Q34nw4r3lyt6Layout +MEMAllocator *Layout::mspAllocator; + +namespace { + +// SetTagProcessorImpl__Q34nw4r3lyt24@unnamed@lyt_layout_cpp@FPQ34nw4r3lyt4PanePQ34nw4r2ut19TagProcessorBase +void SetTagProcessorImpl(Pane *pPane, ut::TagProcessorBase *pTagProcessor) { + TextBox *pTextBox = ut::DynamicCast(pPane); + if (pTextBox) { + pTextBox->SetTagProcessor(pTagProcessor); + } + for (ut::LinkList::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::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::Iterator it = mAnimTransList.GetBeginIter(); + while (it != mAnimTransList.GetEndIter()) { + ut::LinkList::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(); + } else { + if (mpGroupContainer && groupNestLevel == 1) { + Group *pGroup = NewObj((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 +void Layout::SetTagProcessor(ut::TagProcessorBase *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(pResPane); + } break; + case 'pic1': { + const res::Picture *pResPic = (const res::Picture *)dataPtr; + return NewObj(pResPic, resBlockSet); + } break; + case 'txt1': { + const res::TextBox *pBlock = (const res::TextBox *)dataPtr; + return NewObj(pBlock, resBlockSet); + } break; + case 'wnd1': { + const res::Window *pBlock = (const res::Window *)dataPtr; + return NewObj(pBlock, resBlockSet); + } break; + case 'bnd1': { + const res::Bounding *pResBounding = (const res::Bounding *)dataPtr; + return NewObj(pResBounding, resBlockSet); + } break; + default: + return nullptr; + } +} + +} // namespace lyt + +} // namespace nw4r diff --git a/src/nw4r/lyt/lyt_material.cpp b/src/nw4r/lyt/lyt_material.cpp index e69de29b..9546dd49 100644 --- a/src/nw4r/lyt/lyt_material.cpp +++ b/src/nw4r/lyt/lyt_material.cpp @@ -0,0 +1,10 @@ + +// SetupGX__Q34nw4r3lyt8MaterialFbUc +// BindAnimation__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransform +// UnbindAnimation__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransform +// UnbindAllAnimation__Q34nw4r3lyt8MaterialFv +// Animate__Q34nw4r3lyt8MaterialFv +// FindAnimationLink__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransform +// FindAnimationLink__Q34nw4r3lyt8MaterialFRCQ34nw4r3lyt12AnimResource +// SetAnimationEnable__Q34nw4r3lyt8MaterialFPQ34nw4r3lyt13AnimTransformb +// SetAnimationEnable__Q34nw4r3lyt8MaterialFRCQ34nw4r3lyt12AnimResourceb diff --git a/src/nw4r/lyt/lyt_pane.cpp b/src/nw4r/lyt/lyt_pane.cpp index 043beb87..9dd360ef 100644 --- a/src/nw4r/lyt/lyt_pane.cpp +++ b/src/nw4r/lyt/lyt_pane.cpp @@ -8,12 +8,6 @@ #include // 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__Q34nw4r2ut38LinkListFv @@ -69,12 +80,12 @@ Pane::~Pane() { ut::LinkList::Iterator currIt = it++; mChildList.Erase(currIt); if (!currIt->mbUserAllocated) { - Layout::DeleteObj(&*currIt); + Layout::DeleteObj(&*currIt); } } this->UnbindAnimationSelf(nullptr); - if (this->mpMaterial && !this->mpMaterial->mbUserAllocated) { - Layout::DeleteObj(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(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(pUserData, offset); } else { - str = 0; + str = nullptr; } if (strcmp(name, str) == 0) { return pUserData; }; - i++; - pUserData++; } return nullptr; }