|
resonance 1.0.1
|
Run of text drawn as a quad per glyph. More...
#include <text.h>


Public Types | |
| enum | Alignment { kTextAlignLeft = 0x01 , kTextAlignCenter = 0x02 , kTextAlignRight = 0x04 , kTextAlignTop = 0x10 , kTextAlignMiddle = 0x20 , kTextAlignBottom = 0x40 } |
| Bits of the alignment word. More... | |
| Public Types inherited from Rnd::Transformable | |
| enum | Billboard { kBillboardNone = 0 , kBillboardX = 1 , kBillboardY = 2 , kBillboardZ = 4 , kBillboardXZ = 8 , kBillboardXYZ = 16 , kBillboardSimpleXYZ = 32 , kBillboardLocalRotate = 64 , kBillboardScaleX = 129 , kBillboardScaleY = 130 , kBillboardScaleZ = 132 , kBillboardScaleXZ = 136 , kBillboardScaleXYZ = 144 , kBillboardScaleSimpleXYZ = 160 } |
| Mode mBillboard selects, recovered from the name dumper at 0x004f26f0. More... | |
Public Member Functions | |
| Text (const HxStr &name) | |
| Construct an empty white text run. | |
| virtual | ~Text () |
| Release the glyph mesh and drop the reference on the font. | |
| virtual void | SetColor (const Color &color) |
| Set the colour of every glyph. | |
| virtual void | SetAlign (int nAlign) |
| Set which point of the block the origin is. | |
| virtual void | SetText (const HxStr &text) |
| Replace the text. | |
| virtual void | SetFont (Font *pFont) |
| Replace the font. | |
| void | SetWordWrap (int nWordWrap) |
| Set whether long lines are broken at word boundaries. | |
| void | SetWrapWidth (float flWrapWidth) |
| Set the width a wrapped line is broken at. | |
| void | RebuildText () |
| Derive mText from mPreWrapText and rebuild the glyph mesh. | |
| virtual void | DumpText (Dbg &sink) |
| Write a description of this text run to sink. | |
| virtual void | Save (Stream &stream) |
| Write this text run to stream at revision 6. | |
| virtual void | Replace (Object *pFrom, Object *pTo) |
| Retarget the font when it is the object being replaced. | |
| virtual const HxStr & | ClassName () const |
| Report the class key a .rnd file writes for a text run. | |
| virtual void | Copy (const Object *pSource, unsigned nFlags) |
| Copy the state of pSource into this text run. | |
| virtual void | Load (Stream &stream) |
| Read this text run from stream. | |
| virtual void | FindCollisions (const Segment &ray, std::list< Collision > &collisions) |
| Test a ray against the glyph mesh and append what it strikes to sink. | |
| virtual void | SetBillboard (int nBillboard) |
| Set the billboard mode of this object and of its glyph mesh. | |
| virtual int | UpdateWorldXfm (Transformable *pParent, int nForce) |
| Compose the world transform of this object and then of its glyph mesh. | |
| virtual void | SetShowing (int nShowing) |
| Set whether this object draws at all. | |
| virtual void | SetHighlight (int nHighlight) |
| Set whether this object draws with its highlight treatment. | |
| Font * | GetFont () |
| Report the font the text is set in. | |
| virtual int | DrawShowing () |
| Draw the glyph mesh. | |
| float | GetFontWidth (const char *pText, int nCount) |
| Report the total advance of the first nCount characters of pText in this text's font. | |
| Vector3 | CharPosition (int nIndex) |
| Report where one glyph of the laid-out text sits. | |
| void | GetVerticalBounds (float &flTop, float &flBottom) |
| Report the vertical extent of the text block about the origin. | |
| int | CountLines () |
| Report the number of lines of mText, one more than its newline count. | |
| Public Member Functions inherited from Rnd::Drawable | |
| Drawable () | |
| Construct a visible drawable with no children. | |
| virtual | ~Drawable () |
| Drop this object's references on its children. | |
| void | Draw () |
| Draw this object followed by each of its children. | |
| Drawable * | Parent () |
| Report the drawable that draws this one. | |
| void | AddDraw (Drawable *pDraw, Drawable *pBefore) |
| Insert pDraw into mDraws in front of pBefore. | |
| void | AddDraw (Drawable *pDraw) |
| Insert pDraw at the front of mDraws. | |
| void | RemoveDraw (Drawable *pDraw) |
| Erase pDraw from mDraws. | |
| void | RemoveAllDraws () |
| Empty mDraws, dropping this object's reference on every entry. | |
| void | MoveDraw (Drawable *pDraw, int nSteps) |
| Move pDraw nSteps places later in mDraws, or earlier for a negative count. | |
| void | SetShowingRecursive (int nShowing) |
| Set whether this object and every drawable beneath it in mDraws draw at all. | |
| int | GetHighlight () const |
| Report the highlight flag. | |
| int | GetShowing () const |
| Report the showing flag. | |
| std::list< Drawable * > & | GetDraws () |
| Report the child list. | |
| Public Member Functions inherited from Rnd::Object | |
| Object () | |
| Construct an unnamed object. | |
| Object (const HxStr &name) | |
| Construct an object and register it under name. | |
| virtual | ~Object () |
| Erase the registry entry and release the name buffer. | |
| void | SetName (const HxStr &name) |
| Re-register this object under a different name. | |
| void | AddRef (Object *pReferrer) |
| Register pReferrer as a store of a pointer to this object. | |
| void | RemoveRef (Object *pReferrer) |
| Drop one registration made by AddRef(). | |
| Public Member Functions inherited from Rnd::Collideable | |
| Collideable () | |
| Construct a collideable with no children. | |
| virtual | ~Collideable () |
| Drop this object's references on its children. | |
| Collideable * | Parent () |
| Report the collideable that hit-tests this one. | |
| void | AddCollide (Collideable *pCollide) |
| Append pCollide to mCollides. | |
| void | RemoveCollide (Collideable *pCollide) |
| Erase pCollide from mCollides. | |
| virtual void | FindCollisions (const Vector2 &point, std::list< Collision > &collisions) |
| Test a screen point against this object and append what it strikes to collisions. | |
| Public Member Functions inherited from Rnd::Transformable | |
| Transformable () | |
| Construct a dirty transformable with identity transforms and no children. | |
| virtual | ~Transformable () |
| Drop this object's references on its children. | |
| void | AddTrans (Transformable *pTrans) |
| Append pTrans to mTransList and mark it dirty. | |
| void | RemoveTrans (Transformable *pTrans) |
| Erase pTrans from mTransList. | |
| void | RemoveAllTranses () |
| Drop this object's reference on every mTransList entry and empty the list. | |
| Transformable * | Parent () |
| Report the transformable that positions this one. | |
| void | SetOrigin (const float *pOrigin) |
| Set the origin row and mark the transform dirty. | |
| float * | GetDrawXfm () |
| Build the transform this object draws with and return it. | |
Static Public Member Functions | |
| static void * | operator new (size_t nSize) |
| Allocate a text run under the tag "Rnd::Text". | |
| static void | operator delete (void *pBlock) |
| Release a text run to the tagged heap. | |
| Static Public Member Functions inherited from Rnd::Drawable | |
| static Drawable * | Find (const HxStr &name) |
| Resolve a registry key to a drawable. | |
Public Attributes | |
| float | mWrapWidth |
| Width a wrapped line is broken at. | |
| HxStr | mPreWrapText |
| Text as a caller or a file supplied it, before wrapping. | |
| Public Attributes inherited from Rnd::Drawable | |
| int | mShowing |
| Public Attributes inherited from Rnd::Object | |
| HxStr | mName |
| int | mInternal |
| Public Attributes inherited from Rnd::Transformable | |
| float | mLocalXfm [kXfmRowCount][kXfmRowFloatCount] |
| Transform this object is positioned by, before the parent transform is applied. | |
| float | mWorldXfm [kXfmRowCount][kXfmRowFloatCount] |
| Composed world transform. | |
| int | mDirty |
| Set by every writer of a transform field and cleared once UpdateWorldXfm has recomposed. | |
Static Public Attributes | |
| static Text *(* | sNew )(const HxStr &name) |
| Creator the registered "Text" class builds through. | |
Additional Inherited Members | |
| Protected Member Functions inherited from Rnd::Drawable | |
| void | ReleaseDrawsRefs () |
| Drop this object's reference on every mDraws entry without emptying the list. | |
| Protected Member Functions inherited from Rnd::Object | |
| void | ReleaseAllRefs () |
| Tell every referrer to drop its pointer to this object. | |
| Protected Member Functions inherited from Rnd::Collideable | |
| void | ReleaseCollidesRefs () |
| Drop this object's reference on every mCollides entry without emptying the list. | |
| Protected Member Functions inherited from Rnd::Transformable | |
| void | AdoptXfmFrom (const Transformable &owner) |
| Adopt the transform of an owner this object is being detached from. | |
| void | ReleaseTransRefs () |
| Drop this object's reference on every mTransList entry without emptying the list. | |
| Protected Attributes inherited from Rnd::Object | |
| std::list< Object * > | mRefs |
| Protected Attributes inherited from Rnd::Transformable | |
| float | mOrigin [kXfmRowFloatCount] |
| int | mBillboard |
Run of text drawn as a quad per glyph.
Its RTTI descriptor is at 0x008ef4d0. It has three public non-virtual bases whose offsets the descriptor fixes: Rnd::Drawable at +0x00, Rnd::Collideable at +0x14, and Rnd::Transformable at +0x20. All three derive virtually from Rnd::Object, so one shared Object subobject sits at +0x110, which the constructor proves by writing that address into all three virtual-base pointers.
The class is 0x130 bytes, which the factory at 0x004cf800 pins by requesting exactly that many. The last member ends at 0x12c, and the quadword access to mColor gives the class 16-byte alignment, which accounts for the remaining four bytes. The same alignment accounts for the eight bytes between mZTest and the base subobject, since 0x108 is not a 16-byte boundary and 0x110 is. Neither run is an unrecovered field.
Four vtables belong to the class, laid out back to back and each terminated by an all-zero entry. The three-entry table at 0x00822508 is addressed by the Rnd::Transformable vptr with a -0x20 adjustment, the three-entry table at 0x00822528 by the Rnd::Collideable vptr with a -0x14 adjustment, the eight-entry table at 0x00822548 by the Rnd::Drawable vptr with no adjustment, and the eight-entry table at 0x00822590 by the Object subobject vptr with a -0x110 adjustment. Rnd::Drawable is the primary base, so the four virtuals this class declares of its own occupy slots 4 through 7 of its table.
The member titles come from the text DumpText() writes, "font:", " align:", "preWrapText:", "color:", " word wrap:", " wrap width:", "text:", and "mesh:".
Geometry is built rather than drawn directly. The object owns one Rnd::Mesh whose name is the object's own inside [ and _mesh], has four vertices and two triangles per glyph, and takes its material from the font. Every writer of a field that affects layout ends by rebuilding that mesh, and a Text whose font is not a Material font builds nothing at all.
Wrapping retains two strings. mPreWrapText is what a caller or a file supplied, and mText is the same text with a newline inserted at every wrap point. mText is the string the mesh is built from, and it is derived rather than stored, so only mPreWrapText is serialised.
| enum Rnd::Text::Alignment |
Bits of the alignment word.
The six titles and the six bit values come from the printer at 0x004d0450. The printer tests the three vertical bits first and then the three horizontal ones, writing at most one of each. A word is not required to have one bit from each group.
|
explicit |
Construct an empty white text run.
The colour starts fully opaque white, the alignment at Top and Left, the wrap width at 100.0, wrapping disabled, and both strings, the font, and the mesh empty.
| name | The registry key for this object. |
|
virtual |
Release the glyph mesh and drop the reference on the font.
|
static |
Allocate a text run under the tag "Rnd::Text".
| nSize | The object size the compiler supplies. |
|
static |
Release a text run to the tagged heap.
| pBlock | The block. |
|
virtual |
Set the colour of every glyph.
Rnd::Drawable vtable slot 4. The new colour is written over the colour of every vertex the glyph mesh already stores and the mesh is told that its colours changed, so the change takes effect without a rebuild.
| color | The colour. |
|
virtual |
Set which point of the block the origin is.
Rnd::Drawable vtable slot 5.
| nAlign | A set of the Alignment bits. |
|
virtual |
Replace the text.
Rnd::Drawable vtable slot 6. The argument becomes mPreWrapText, and mText and the glyph mesh are derived from it.
| text | The text to draw. |
|
virtual |
Replace the font.
Rnd::Drawable vtable slot 7. A null argument is stored, unlike Rnd::Mesh::SetMat(), which drops the previous material without storing the null.
| pFont | The font, or null for none. |
| void Rnd::Text::SetWordWrap | ( | int | nWordWrap | ) |
Set whether long lines are broken at word boundaries.
| nWordWrap | Non-zero to wrap. |
| void Rnd::Text::SetWrapWidth | ( | float | flWrapWidth | ) |
Set the width a wrapped line is broken at.
| flWrapWidth | The width, in the units the font measures in. |
| void Rnd::Text::RebuildText | ( | ) |
Derive mText from mPreWrapText and rebuild the glyph mesh.
Wrapping is applied only when it is enabled and a font is attached, since wrapping needs glyph widths to measure with. Every setter of a field that affects layout ends here, and the compiler inlined this routine at each of those call sites while retaining the out-of-line body for Load() and Copy().
|
virtual |
Write a description of this text run to sink.
The Rnd::Object description comes first and then each of the three mix-ins, because Rnd::Object is a virtual base and the mix-ins therefore do not write it themselves. Everything below is produced only at a positive dump level, and mText and the mesh only at a dump level of 2 or more.
| sink | The diagnostic sink to write to. |
Reimplemented from Rnd::Drawable.
|
virtual |
Write this text run to stream at revision 6.
| stream | The stream to write to. |
Reimplemented from Rnd::Drawable.
Retarget the font when it is the object being replaced.
Each of the three mix-ins is given the pair first.
| pFrom | The object being replaced. |
| pTo | The replacement, or null. |
Reimplemented from Rnd::Drawable.
|
virtual |
Report the class key a .rnd file writes for a text run.
The returned string is the global at 0x006feca0, which the class registration fills with "Text".
Implements Rnd::Object.
|
virtual |
Copy the state of pSource into this text run.
The colour is not among the fields copied, so a copy draws in whatever colour this object already had. A pSource that is not a Text is dereferenced through the null the cast produces rather than rejected.
| pSource | The text run to copy from. |
| nFlags | The set of fields to copy, passed on to each mix-in. |
Reimplemented from Rnd::Drawable.
|
virtual |
Read this text run from stream.
A revision above 6 produces the report "Can't load new Text" followed by the abort handler of Rnd::TheDbg. The older revisions differ in five ways. Below revision 3 the alignment arrives as an index into a table of six words rather than as the bit set. Below revision 2 the transform is absent and a plain x and y pair stands in for it, becoming the translation row of the local transform with the y component negated and scaled by three quarters. Below revision 1 the colour is absent. Below revision 4 wrapping is absent and the wrap width returns to 100.0. Revision 5 alone writes mText, which this build derives instead, and revision 5 introduced the depth-test flag.
| stream | The stream to read from. |
Reimplemented from Rnd::Drawable.
|
virtual |
Test a ray against the glyph mesh and append what it strikes to sink.
Rnd::Collideable vtable slot 1. Every intersection the mesh records is retargeted at this object, so a caller receives the text run rather than the mesh it happens to own. A text run that is not showing is not tested at all.
| ray | The segment to test along. |
| collisions | The list to append intersections to. |
Reimplemented from Rnd::Collideable.
|
virtual |
Set the billboard mode of this object and of its glyph mesh.
Rnd::Transformable vtable slot 1.
| nBillboard | The billboard mode. |
Reimplemented from Rnd::Transformable.
|
virtual |
Compose the world transform of this object and then of its glyph mesh.
Rnd::Transformable vtable slot 2. The mesh is recomposed against this object, and the base report becomes the force argument of that second call, so the mesh follows unconditionally whenever this object moved.
| pParent | The transformable this one hangs off, or null for a root. |
| nForce | Non-zero to recompose even when nothing is marked dirty. |
Reimplemented from Rnd::Transformable.
|
virtual |
Set whether this object draws at all.
Rnd::Drawable vtable slot 1. Clearing the flag releases the glyph mesh outright rather than hiding it, and setting it rebuilds that mesh. A value equal to the current one is discarded, and the base implementation is not invoked.
| nShowing | Non-zero to draw. |
Reimplemented from Rnd::Drawable.
|
virtual |
Set whether this object draws with its highlight treatment.
Rnd::Drawable vtable slot 2. The glyph mesh receives the same flag.
| nHighlight | Non-zero to highlight. |
Reimplemented from Rnd::Drawable.
|
inline |
Report the font the text is set in.
HudTextMessage's constructor inlines the load, and the out-of-line copy has no caller.
|
virtual |
Draw the glyph mesh.
Rnd::Drawable vtable slot 3. Always reports that the children are still to be drawn, even when there is no mesh.
Public because HudWinMessage::Draw() at 0x0042a830, which Overlay::Draw() inlines, calls it directly on a text from outside the hierarchy.
Reimplemented from Rnd::Drawable.
| float Rnd::Text::GetFontWidth | ( | const char * | pText, |
| int | nCount ) |
Report the total advance of the first nCount characters of pText in this text's font.
Unlike the measurement HowManyFit() inlines, the sum is not truncated. A text with no font measures nothing. The jukebox screens lay their lists out with it. The name is inferred.
| pText | The characters to measure. |
| nCount | How many characters to measure. |
| Vector3 Rnd::Text::CharPosition | ( | int | nIndex | ) |
Report where one glyph of the laid-out text sits.
A text with no glyph mesh or no font reports the origin. A glyph's position is the first vertex of its quad. An index past the last glyph reports the last vertex advanced by the font's tracking, which is how MetHelpScreen::FillTexts() at 0x00313208 measures a whole line. kTextAlignMiddle and kTextAlignBottom then lower the result by half or all of the font's cell size. The name is inferred.
| nIndex | The glyph. |
| void Rnd::Text::GetVerticalBounds | ( | float & | flTop, |
| float & | flBottom ) |
Report the vertical extent of the text block about the origin.
The block is the line count times the font's cell size. kTextAlignMiddle centres it, so the top is half of it and the bottom its negation. kTextAlignBottom puts all of it above the origin, and any other alignment all of it below. A text with no font reports zero for both. The name is inferred.
| flTop | Receives the extent above the origin. |
| flBottom | Receives the extent below the origin, as a negative or zero value. |
| int Rnd::Text::CountLines | ( | ) |
Report the number of lines of mText, one more than its newline count.
The name is inferred.
Creator the registered "Text" class builds through.
| float Rnd::Text::mWrapWidth |
Width a wrapped line is broken at.
Load() clamps a value read from a file below revision 5 into 0 through 1000, and nothing clamps a value SetWrapWidth() receives. Public because MetSaveRemixScreen and the ShowRemixDetails() of MetJukeboxBaseScreen and MetJukeboxEditPlaylistScreen compare it against GetFontWidth() through a plain load, and the image has no accessor. +0xec
| HxStr Rnd::Text::mPreWrapText |
Text as a caller or a file supplied it, before wrapping.
Public because MetConfigControllerScreen (HandleCommand() at 0x00200ba8 and the helpers at 0x00201eb8, 0x00202070, 0x00206b30, and 0x00206ca8) and MetSaveRemixScreen read it directly, and the image has no accessor. +0xf8