From ab9b10130d06e41d18733928995de7aad1368e1d Mon Sep 17 00:00:00 2001 From: Treeki Date: Mon, 21 Mar 2011 05:06:40 +0100 Subject: lots of work on the LYT api and NSMBW's wrapper for it. still untested --- include/game.h | 195 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) diff --git a/include/game.h b/include/game.h index 152c864..c796337 100755 --- a/include/game.h +++ b/include/game.h @@ -5,6 +5,7 @@ #include #include #include +#include extern "C" { @@ -288,11 +289,13 @@ namespace ut { // I don't need the methods anyway. class LinkListNode { + public: LinkListNode *next; LinkListNode *prev; }; class LinkList { + public: int count; LinkListNode initialNode; }; @@ -300,6 +303,7 @@ namespace ut { class Color : public GXColor { }; class Rect { + public: f32 left; f32 top; f32 right; @@ -457,6 +461,45 @@ namespace lyt { u8 paneIsOwnedBySomeoneElse; u8 _D7; }; + + class TextBox : public Pane { + public: + TextBox(void *, void *); // todo: TextBox((res::TextBox const *,ResBlockSet const &)) + ~TextBox(); + + void *GetRuntimeTypeInfo() const; + + void DrawSelf(const DrawInfo &info); + + ut::Color GetVtxColor(ulong id) const; + void SetVtxColor(ulong id, ut::Color color); + uchar GetVtxColorElement(ulong id) const; + void SetVtxColorElement(ulong id, uchar value); + + virtual void LoadMtx(const DrawInfo &info); + + virtual void AllocStringBuffer(u16 size); + virtual void FreeStringBuffer(); + + virtual u16 SetString(const wchar_t *str, u16 destOffset); + virtual u16 SetString(const wchar_t *str, u16 destOffset, u16 length); + + wchar_t *stringBuf; + + ut::Color colour1, colour2; + void *font; // actually a ut::ResFont or whatever + + float fontSizeX, fontSizeY; + float lineSpace, charSpace; + + void *tagProc; // actually a TagProcessor + + u16 bufferLength; + u16 stringLength; + + u8 alignment; + u8 flags; + }; } @@ -663,6 +706,7 @@ extern "C" void GXDrawDone(); // 801C4FE0 namespace m2d { class Base_c /*: public nw4r::ut::Link what's this? */ { + public: u32 _00; u32 _04; @@ -674,6 +718,7 @@ namespace m2d { }; class Simple_c : public Base_c { + public: nw4r::lyt::Layout layout; nw4r::lyt::DrawInfo drawInfo; @@ -696,6 +741,7 @@ namespace m2d { namespace EGG { class Frustum { + public: GXProjectionType projType; int isCentered; float width; @@ -1108,5 +1154,154 @@ private: +// More layout crap +// This file REALLY needs to be reorganised. + +namespace nw4r { +namespace lyt { + + class ResourceAccessor { + public: + ResourceAccessor(); + virtual ~ResourceAccessor(); + + virtual void *GetResource(u32 dirKey, const char *filename, u32 *sizePtr) = 0; + virtual void *GetFont(const char *name); + }; + + class ArcResourceAccessor : public ResourceAccessor { + public: + ArcResourceAccessor(); + ~ArcResourceAccessor(); + + bool Attach(void *data, const char *rootDirName); + void *GetResource(u32 dirKey, const char *filename, u32 *sizePtr); + void *GetFont(const char *name); + + ARCHandle arc; + u32 unk_20; + ut::LinkList list; // 0x24 + char rootDirName[0x80]; // 0x30 + // class ends at 0xB0 + }; + +} +} + +namespace m2d { + class ResAcc_c { + public: + ResAcc_c(); + virtual ~ResAcc_c(); + virtual void initialSetup(); + + nw4r::lyt::ResourceAccessor *resAccPtr; // 0x04 + u32 unk_08; // 0x08 + nw4r::lyt::ArcResourceAccessor resAcc; // 0x0C + // class ends at 0xBC + }; + + class ResAccLoader_c : public ResAcc_c { + public: + ResAccLoader_c(); + ~ResAccLoader_c(); + + void *buffer; + dDvdLoader_c loader; // 0xC0 + // ends at 0xD4 + + bool loadArc(const char *path); + bool loadArc(const char *path, u8 unk); + void free(); + }; + + class EmbedLayoutBase_c { + public: + u32 unk_00; + u32 unk_04; + + EmbedLayoutBase_c(); + virtual ~EmbedLayoutBase_c(); + + virtual void draw(); + virtual void update(); + virtual bool build(const char *brlytPath, ResAcc_c *resAcc); + + nw4r::lyt::Pane *getRootPane(); + nw4r::lyt::Pane *findPaneByName(const char *name) const; + nw4r::lyt::TextBox *findTextBoxByName(const char *name) const; + nw4r::lyt::Pane *findPictureByName(const char *name) const; // TODO: change to others + nw4r::lyt::Pane *findWindowByName(const char *name) const; + + void animate(); + void calculateMtx(); + + u8 drawOrder; + + nw4r::lyt::Layout layout; // 0x10 + nw4r::lyt::DrawInfo drawInfo; // 0x30 + void *unk_84; // 0x84 -- a ResAcc? referenced in Build() + float posX; // 0x88 + float posY; // 0x8C + float clipX; // 0x90 + float clipY; // 0x94 + float clipWidth; // 0x98 + float clipHeight; // 0x9C + bool clippingEnabled; // 0xA0 + u32 hasAnimations; // 0xA4 + u32 unk_A8; // 0xA8 + }; + + class EmbedLayout_c : public EmbedLayoutBase_c { + public: + EmbedLayout_c(); + ~EmbedLayout_c(); + + bool build(const char *brlytPath, ResAcc_c *resAcc); + + bool loadArc(const char *name, bool isLangSpecific); + bool loadArc(const char *name, u8 unk, bool isLangSpecific); + + bool loadArcForRegion(const char *name); // uses EU/Layout/$name + + // there's also a NedEU one, but should it really be listed here...? + + // does NSMBW even use consts? I have no idea. maybe not + + void getPanes(const char **names, nw4r::lyt::Pane *output, int count) const; + void getWindows(const char **names, nw4r::lyt::Pane *output, int count) const; // TODO: change to others + void getPictures(const char **names, nw4r::lyt::Pane *output, int count) const; + void getTextBoxes(const char **names, nw4r::lyt::TextBox *output, int count) const; + + void setLangStrings(const char **names, const int *msgIDs, int category, int count); + + void loadAnimations(const char **names, int count); + void loadGroups(const char **names, int *animLinkIDs, int count); + + void enableNonLoopAnim(int num, bool goToLastFrame = false); + void enableLoopAnim(int num); + void resetAnim(int num, bool goToLastFrame = false); + void disableAnim(int num); + void disableAllAnimations(); + + bool isAnimOn(int num = -1); + bool isAnyAnimOn(); + + void execAnimations(); + + ResAccLoader_c loader; // 0xAC + void *brlanHandlers; // 0x180 + void *grpHandlers; // 0x184 + bool *animsEnabled; // 0x188 + int brlanCount; // 0x18C + int grpCount; // 0x190 + int lastAnimTouched; // 0x194 + + private: + void fixTextBoxesRecursively(nw4r::lyt::Pane *pane); + }; +} + + #endif -- cgit v1.2.3