mirror of
https://github.com/zeldaret/ss
synced 2026-06-03 02:29:00 -04:00
lyt_textBox matching
This commit is contained in:
@@ -28,6 +28,19 @@ inline void SetVtxColElement(ut::Color *cols, u32 idx, u8 value) {
|
||||
((u8 *)cols)[(idx & ~3) + (idx & 3)] = value;
|
||||
}
|
||||
|
||||
inline u8 GetHorizontalPosition(u8 var) {
|
||||
return var % 3;
|
||||
}
|
||||
inline u8 GetVerticalPosition(u8 var) {
|
||||
return var / 3;
|
||||
}
|
||||
inline void SetHorizontalPosition(u8 *pVar, u8 newVal) {
|
||||
*pVar = newVal + GetVerticalPosition(*pVar) * 3;
|
||||
}
|
||||
inline void SetVerticalPosition(u8 *pVar, u8 newVal) {
|
||||
*pVar = newVal * 3 + GetHorizontalPosition(*pVar);
|
||||
}
|
||||
|
||||
typedef math::VEC2 TexCoordData[TEXCOORD_VTX_COUNT];
|
||||
|
||||
class TexCoordAry {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <new.h>
|
||||
#include <nw4r/lyt/lyt_animation.h>
|
||||
#include <nw4r/lyt/lyt_types.h>
|
||||
#include <nw4r/ut/ut_ResFont.h>
|
||||
#include <rvl/MEM/mem_allocator.h>
|
||||
|
||||
namespace nw4r {
|
||||
@@ -70,6 +71,9 @@ public:
|
||||
template <typename T>
|
||||
static T *NewArray(size_t n) {
|
||||
T *array = (T *)AllocMemory(n * sizeof(T));
|
||||
if (!array) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
new (&array[i]) T();
|
||||
@@ -86,6 +90,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void DeletePrimArray(T *objAry) {
|
||||
if (objAry) {
|
||||
FreeMemory(objAry);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T *NewObj() {
|
||||
T *pMem = (T *)AllocMemory(sizeof(T));
|
||||
|
||||
@@ -81,6 +81,14 @@ public:
|
||||
TexMap *GetTexMapAry();
|
||||
TexCoordGen *GetTexCoordGenAry();
|
||||
|
||||
GXColorS10 GetTevColor(u32 idx) const {
|
||||
return mTevCols[idx];
|
||||
}
|
||||
|
||||
ut::Color GetTevKColor(u32 idx) const {
|
||||
return mTevKCols[idx];
|
||||
}
|
||||
|
||||
void SetTexture(u32 texMapIdx, const TexMap &texMap) {
|
||||
GetTexMapAry()[texMapIdx] = texMap;
|
||||
}
|
||||
|
||||
@@ -110,6 +110,12 @@ struct FontList {
|
||||
u8 padding[2]; // at 0x0A
|
||||
};
|
||||
|
||||
struct Font {
|
||||
u32 nameStrOffset; // at 0x0
|
||||
u8 type; // at 0x4
|
||||
u8 padding[3]; // at 0x5
|
||||
};
|
||||
|
||||
struct TextureList {
|
||||
DataBlockHeader blockHeader; // at 0x00
|
||||
u16 texNum; // at 0x08
|
||||
@@ -117,6 +123,7 @@ struct TextureList {
|
||||
};
|
||||
struct TextBox : public Pane {
|
||||
u16 textBufBytes; // at 0x4C
|
||||
u16 textStrBytes; // at 0x4E
|
||||
u16 materialIdx; // at 0x50
|
||||
u16 fontIdx; // at 0x52
|
||||
u8 textPosition; // at 0x54
|
||||
|
||||
@@ -8,17 +8,75 @@ namespace nw4r {
|
||||
namespace lyt {
|
||||
class TextBox : public Pane {
|
||||
public:
|
||||
TextBox(u16 allocStrLen);
|
||||
TextBox(const wchar_t *str, const ut::Font *pFont);
|
||||
TextBox(u16, const wchar_t *str, u16, const ut::Font *pFont);
|
||||
TextBox(const res::TextBox *pBlock, const ResBlockSet &resBlockSet);
|
||||
|
||||
void Init(u16 allocStrLen);
|
||||
|
||||
ut::Rect GetTextDrawRect() const;
|
||||
ut::Rect GetTextDrawRect(const DrawInfo &drawInfo) const;
|
||||
u16 GetStringBufferLength() const;
|
||||
u16 SetStringImpl(const wchar_t *str, u16 dstIdx, u32 strLen);
|
||||
const ut::Font *GetFont() const;
|
||||
void SetFont(const ut::Font *pFont);
|
||||
ut::Rect GetTextDrawRect(ut::TextWriterBase<wchar_t> *pWriter) const;
|
||||
f32 GetTextMagH() const;
|
||||
f32 GetTextMagV() const;
|
||||
f32 GetTextAlignMag() const;
|
||||
UNKTYPE MakeDrawFlag() const;
|
||||
|
||||
ut::Color GetTextColor(u32 type) const {
|
||||
return mTextColors[type / 2];
|
||||
}
|
||||
void SetTextColor(u32 type, ut::Color value) {
|
||||
mTextColors[type] = value;
|
||||
}
|
||||
u8 GetTextPositionH() const {
|
||||
return detail::GetHorizontalPosition(mTextPosition);
|
||||
}
|
||||
void SetTextPositionH(u8 val) {
|
||||
detail::SetHorizontalPosition(&mTextPosition, val);
|
||||
}
|
||||
u8 GetTextPositionV() const {
|
||||
return detail::GetVerticalPosition(mTextPosition);
|
||||
}
|
||||
void SetTextPositionV(u8 val) {
|
||||
detail::SetVerticalPosition(&mTextPosition, val);
|
||||
}
|
||||
|
||||
const Size &GetFontSize() const {
|
||||
return mFontSize;
|
||||
}
|
||||
|
||||
void SetFontSize(const Size &fontSize) {
|
||||
mFontSize = fontSize;
|
||||
}
|
||||
ut::TagProcessorBase<wchar_t> *GetTagProcessor() const {
|
||||
return mpTagProcessor;
|
||||
}
|
||||
void SetTagProcessor(ut::TagProcessorBase<wchar_t> *pTagProcessor) {
|
||||
mpTagProcessor = pTagProcessor;
|
||||
}
|
||||
|
||||
TextBox(const res::TextBox *, const ResBlockSet &resBlockSet);
|
||||
virtual ~TextBox();
|
||||
NW4R_UT_RTTI_DECL(TextBox);
|
||||
virtual void DrawSelf(const DrawInfo &drawInfo); // at 0x18
|
||||
virtual ut::Color GetVtxColor(u32 idx) const; // at 0x24
|
||||
virtual void SetVtxColor(u32 idx, ut::Color value); // at 0x28
|
||||
virtual u8 GetVtxColorElement(u32 idx) const; // at 0x34
|
||||
virtual void SetVtxColorElement(u32 idx, u8 value); // at 0x38
|
||||
virtual void LoadMtx(const DrawInfo &drawInfo); // at 0x70
|
||||
virtual void AllocStringBuffer(u16 minLen); // at 0x
|
||||
virtual void FreeStringBuffer(); // at 0x
|
||||
virtual u16 SetString(const wchar_t *str, u16 dstIdx); // at 0x
|
||||
virtual u16 SetString(const wchar_t *str, u16 dstIdx, u16 strLen); // at 0x
|
||||
|
||||
protected:
|
||||
wchar_t *mTextBuf; // at 0xD8 // ptr to is Guess
|
||||
ut::Color mTextColors[2]; // at 0xDC
|
||||
ut::Font *mpFont; // at 0xE4
|
||||
const ut::Font *mpFont; // at 0xE4
|
||||
Size mFontSize; // at 0xE8
|
||||
f32 mLineSpace; // at 0xF0
|
||||
f32 mCharSpace; // at 0xF4
|
||||
@@ -28,7 +86,7 @@ public:
|
||||
u8 mTextPosition; // at 0x100
|
||||
struct { //
|
||||
u8 bAllocFont : 1; //
|
||||
u8 textAligntment : 1; //
|
||||
u8 textAlignment : 2; //
|
||||
} mBits; // at 0x101
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ inline void SetBit(T *bits, int pos, bool val) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T *ConvertOffsetToPtr(const void *baseAddress, unsigned int offset) {
|
||||
T *ConvertOffsToPtr(const void *baseAddress, unsigned int offset) {
|
||||
return (T *)((u32)baseAddress + offset);
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
@@ -17,6 +17,9 @@ public:
|
||||
Color(int red, int green, int blue, int alpha) {
|
||||
Set(red, green, blue, alpha);
|
||||
}
|
||||
Color(const GXColor &clr) {
|
||||
*this = *(u32 *)&clr;
|
||||
}
|
||||
~Color() {}
|
||||
|
||||
void Set(int red, int green, int blue, int alpha) {
|
||||
|
||||
Reference in New Issue
Block a user