wavelength 1.0.0
Loading...
Searching...
No Matches
RndText Class Reference

Text drawn with a bitmap font as a mesh of one quad per character. More...

#include <rndtext.h>

Inheritance diagram for RndText:
Collaboration diagram for RndText:

Public Types

enum  Align {
  kAlignLeft = 1 , kAlignCenter = 2 , kAlignRight = 4 , kAlignTop = 0x10 ,
  kAlignMiddle = 0x20 , kAlignBottom = 0x40
}
 The bits of mAlign, one vertical and one horizontal. More...
Public Types inherited from RndTransformable
enum  Billboard {
  kBillboardNone = 0 , kBillboardX = 1 , kBillboardY = 2 , kBillboardZ = 4 ,
  kBillboardXZ = 8 , kBillboardXYZ = 16 , kBillboardSimpleXYZ = 32 , kBillboardLocalRotate = 64 ,
  kBillboardScale = 128 , kBillboardScaleX = 129 , kBillboardScaleY = 130 , kBillboardScaleZ = 132 ,
  kBillboardScaleXZ = 136 , kBillboardScaleXYZ = 144 , kBillboardScaleSimpleXYZ = 160
}
 How the world transform turns to face the current camera. More...

Public Member Functions

 RndText (const char *pszName)
 Construct white, empty text aligned to the top left, without a font, wrapping at 100.
 ~RndText () override
 Drop the reference on the font and delete the mesh.
void * operator new (size_t nSize)
 Allocate text, billed to the class name.
void operator delete (void *pBlock)
 Release text.
void ListDrawObjects (std::list< RndObject * > &objects) override
 Add the material of the mesh to a list.
void ListDrawables (std::list< RndDrawable * > &drawables) override
 Add the text unless its mesh is outside the view of the current camera, then the children.
void SetShowing (int nShowing) override
 Show or hide the text, building the mesh when it starts showing and deleting it when it stops.
void SetHighlight (int nHighlight) override
 Set the highlight of the text and of its mesh.
int DrawShowing () override
 Draw the mesh, or the text with the renderer's line font at the local position when there is no mesh.
virtual void SetColor (const Color &color)
 Set the colour of every character.
virtual void SetAlign (int nAlign)
 Set the alignment.
virtual void SetText (const char *pszText)
 Set the text.
virtual void SetFont (RndFont *pFont)
 Set the font.
void Collide (const Segment &segment, std::list< Collision > &collisions) override
 Add each face of the mesh the segment strikes, as strikes of the text, then what the children strike, to a list.
void SetBillboard (int nBillboard) override
 Set the billboard mode of the text and of its mesh.
int UpdateWorldXfm (RndTransformable *pParent, int bForce) override
 Update the world transform of the text, then of its mesh from the text's.
void DumpText (PrnStream &stream) override
 Write a description of the text and its bases.
void Save (BinStream &stream) override
 Write the text and its bases.
void Replace (RndObject *pFrom, RndObject *pTo) override
 Replace the font when it is the object being replaced.
const char * ClassName () const override
 Report the class name.
void Copy (const RndObject *pSource, int nFlags) override
 Copy another text and its bases, then build the mesh again.
void Load (BinStream &stream) override
 Read what Save() wrote, or an earlier version of it, then build the mesh.
void UpdateCursors ()
 Give the text again to every cursor that refers to it.
void SyncText ()
 Copy mPreWrapText to mText with each tab as three spaces, limit it to 800 characters, wrap it when word wrap is on, and build the mesh.
void SetWordWrap (int nWordWrap)
 Turn word wrap on or off.
void SetWrapWidth (float fWrapWidth)
 Set the width lines wrap at.
void SyncDepthTest ()
 Give the mesh the depth test mDepthTest selects.
void SetDepthTest (int nDepthTest)
 Turn the depth test on or off.
float MeasureWidth (const char *pszText, int nCount)
 Measure the advance of a run of characters, without the spacing.
void WrapText (const char *pszText, String &wrapped)
 Break text into lines no wider than mWrapWidth, at the last space where there is one.
int NumLines ()
 Count the lines of mText.
const char * MeasureLine (const char *pszLine, float &fWidth)
 Measure the line of mText that starts at a character, with the spacing.
void BuildMesh ()
 Build a mesh of one quad per character of mText, in the font's material.
void BuildLine (int nFirstChar, const char *pszStart, const char *pszEnd, float fLine, float fWidth)
 Fill the quads of one line of the mesh.
Vector3 CharPosition (int nIndex)
 Report the position of a character of mPreWrapText in the text's space.
int GetAlign () const
RndFont * GetFont () const
const String & GetPreWrapText () const
float GetWrapWidth () const
virtual void Collide (const Vector2 &point, std::list< Collision > &collisions)
 Test a screen point against the collideable and add what it strikes to a list.
Public Member Functions inherited from RndDrawable
 RndDrawable ()
 Construct a showing drawable without a highlight or children.
 ~RndDrawable () override
 Drop the references on the children.
RndDrawable * Parent ()
 Find the drawable whose children include this one.
void Draw ()
 Draw the drawable and then its children, when it is showing.
bool AddDraw (RndDrawable *pDraw, RndDrawable *pBefore)
 Add a child before another.
void RemoveDraw (RndDrawable *pDraw)
 Remove a child.
void ClearDraws ()
 Remove every child.
int GetShowing () const
const std::list< RndDrawable * > & GetDraws () const
Public Member Functions inherited from RndObject
 RndObject (const char *pszName)
 Construct an object and register it under a name.
virtual ~RndObject ()
 Notify every referrer, then erase the registration.
void SetName (const char *pszName)
 Register the object under a different name.
void AddRef (RndObject *pReferrer)
 Register an object as a store of a pointer to this one.
void RemoveRef (RndObject *pReferrer)
 Drop the first registration AddRef() made for a referrer.
const char * GetName () const
const std::list< RndObject * > & GetRefs () const
int GetInternal () const
void SetInternal (int nInternal)
Public Member Functions inherited from RndCollideable
 RndCollideable ()
 Construct a collideable without children.
 ~RndCollideable () override
 Drop the references on the children.
RndCollideable * Parent ()
 Find the collideable whose children include this one.
bool AddCollide (RndCollideable *pCollide)
 Append a child.
void RemoveCollide (RndCollideable *pCollide)
 Remove a child.
Public Member Functions inherited from RndTransformable
 RndTransformable ()
 Construct a transformable with identity transforms, no origin offset, and no billboard.
 ~RndTransformable () override
 Drop the references on the children.
void DumpText (PrnStream &stream) override
 Write a description of the transformable.
void Save (BinStream &stream) override
 Write the transforms, the names of the children, the billboard mode, and the origin.
void Replace (RndObject *pFrom, RndObject *pTo) override
 Replace a child with another object.
void Copy (const RndObject *pSource, int nFlags) override
 Copy the transforms, the billboard mode, the origin, and the children when the flags request them.
void Load (BinStream &stream) override
 Read what Save() wrote, or an earlier version of it.
void SetOrigin (const Vector3 &origin)
 Set the point the world transform subtracts first when there is no billboard.
RndTransformable * Parent ()
 Find the transformable whose children include this object.
bool AddTrans (RndTransformable *pTrans)
 Append a child and mark its world transform dirty.
void RemoveTrans (RndTransformable *pTrans)
 Remove a child.
void ClearTrans ()
 Remove every child.
const Transform & BillboardXfm ()
 Report the world transform turned to face the current camera.
const Transform & GetLocalXfm () const
Transform & GetLocalXfm ()
void SetLocalXfm (const Transform &xfm)
const Transform & GetWorldXfm () const
Transform & GetWorldXfm ()
int GetDirty () const
void SetDirty (int nDirty)
const std::list< RndTransformable * > & GetTransList () const

Static Public Member Functions

static RndObject * New (const char *pszName)
 Create text.
Static Public Member Functions inherited from RndDrawable
static void CollectChildren (std::list< RndObject * > &objects, RndDrawable *pDrawable)
 Append every draw descendant of a drawable, depth first, each before its descendants.
Static Public Member Functions inherited from RndCollideable
static void CollectChildren (std::list< RndObject * > &objects, RndCollideable *pCollideable)
 Append every collision descendant of a collideable, depth first, each before its descendants.
Static Public Member Functions inherited from RndTransformable
static void CollectChildren (std::list< RndObject * > &objects, RndTransformable *pTransformable)
 Append every transform descendant of a transformable, depth first, each before its descendants.

Static Public Attributes

static const char * sClassName
 The class name a .rnd file writes, Text.
static int sRev
 The format version Save() writes and Load() accepts.
Static Public Attributes inherited from RndDrawable
static int sRev
 The format version Save() writes and Load() accepts.
Static Public Attributes inherited from RndObject
static constexpr int kCopyChildLists = 0x200
 The bit of the Copy() flags that copies the child lists of the mix-ins.
Static Public Attributes inherited from RndCollideable
static int sRev
 The format version Save() writes and Load() accepts.
Static Public Attributes inherited from RndTransformable
static int sRev
 The format version Save() writes and Load() accepts.

Protected Member Functions

void ReleaseRefs ()
 Drop the reference on the font and delete the mesh.
void AcquireRefs ()
 Take a reference on the font and build the text again.
Protected Member Functions inherited from RndDrawable
void ReleaseDrawRefs ()
 Drop the reference on every child without emptying the list.
void AcquireDrawRefs ()
 Take a reference on every child.
Protected Member Functions inherited from RndCollideable
void ReleaseCollideRefs ()
 Drop the reference on every child without emptying the list.
void AcquireCollideRefs ()
 Take a reference on every child.
Protected Member Functions inherited from RndTransformable
void ReleaseTransRefs ()
 Drop the reference on every child without emptying the list.
void AcquireTransRefs ()
 Take a reference on every child.

Additional Inherited Members

Protected Attributes inherited from RndDrawable
int mShowing
Protected Attributes inherited from RndObject
std::list< RndObject * > mRefs
String mName
Protected Attributes inherited from RndTransformable
std::list< RndTransformable * > mTransList
Transform mLocalXfm
Transform mWorldXfm
Vector3 mOrigin
int mDirty
int mBillboard

Detailed Description

Text drawn with a bitmap font as a mesh of one quad per character.

The RTTI includes the class name and records RndDrawable, RndCollideable, and RndTransformable as bases. The mesh is rebuilt from mPreWrapText whenever the text, the font, or the layout changes, and only while the text is showing.

Member Enumeration Documentation

◆ Align

The bits of mAlign, one vertical and one horizontal.

Enumerator
kAlignLeft 

Lines start at the origin.

kAlignCenter 

Lines centre on the origin.

kAlignRight 

Lines end at the origin.

kAlignTop 

The first line is at the origin.

kAlignMiddle 

The lines centre on the origin.

kAlignBottom 

The last line is at the origin.

Constructor & Destructor Documentation

◆ RndText()

RndText::RndText ( const char * pszName)
explicit

Construct white, empty text aligned to the top left, without a font, wrapping at 100.

Parameters
pszNameThe registry key.
Ghidra address:
NTSC-U/C: 0x002424e0
Ghidra address:
PAL: 0x0024afb8

◆ ~RndText()

RndText::~RndText ( )
override

Drop the reference on the font and delete the mesh.

Ghidra address:
NTSC-U/C: 0x00391268
Ghidra address:
PAL: 0x003ff970

Member Function Documentation

◆ operator new()

void * RndText::operator new ( size_t nSize)
inline

Allocate text, billed to the class name.

Parameters
nSizeThe object size the compiler supplies.
Returns
The block.

◆ operator delete()

void RndText::operator delete ( void * pBlock)
inline

Release text.

Parameters
pBlockThe block.

◆ ListDrawObjects()

void RndText::ListDrawObjects ( std::list< RndObject * > & objects)
overridevirtual

Add the material of the mesh to a list.

Without a mesh nothing is added. The children are not added.

Parameters
objectsThe list to add to.
Ghidra address:
NTSC-U/C: 0x002439d8
Ghidra address:
PAL: 0x0024c4b0

Reimplemented from RndDrawable.

◆ ListDrawables()

void RndText::ListDrawables ( std::list< RndDrawable * > & drawables)
overridevirtual

Add the text unless its mesh is outside the view of the current camera, then the children.

The bounding sphere spans the first and the last vertex. Text without a mesh is not added.

Parameters
drawablesThe list to add to.
Ghidra address:
NTSC-U/C: 0x00243a78
Ghidra address:
PAL: 0x0024c550

Reimplemented from RndDrawable.

◆ SetShowing()

void RndText::SetShowing ( int nShowing)
overridevirtual

Show or hide the text, building the mesh when it starts showing and deleting it when it stops.

The children are not changed.

Parameters
nShowingNon-zero to show.
Ghidra address:
NTSC-U/C: 0x00243820
Ghidra address:
PAL: 0x0024c2f8

Reimplemented from RndDrawable.

◆ SetHighlight()

void RndText::SetHighlight ( int nHighlight)
overridevirtual

Set the highlight of the text and of its mesh.

Parameters
nHighlightNon-zero to highlight.
Ghidra address:
NTSC-U/C: 0x002437d0
Ghidra address:
PAL: 0x0024c2a8

Reimplemented from RndDrawable.

◆ DrawShowing()

int RndText::DrawShowing ( )
overridevirtual

Draw the mesh, or the text with the renderer's line font at the local position when there is no mesh.

Returns
1, to draw the children.
Ghidra address:
NTSC-U/C: 0x00243738
Ghidra address:
PAL: 0x0024c210

Reimplemented from RndDrawable.

◆ SetColor()

virtual void RndText::SetColor ( const Color & color)
virtual

Set the colour of every character.

Parameters
colorThe colour.
Ghidra address:
NTSC-U/C: 0x00242ae8
Ghidra address:
PAL: 0x0024b5c0

◆ SetAlign()

virtual void RndText::SetAlign ( int nAlign)
virtual

Set the alignment.

Parameters
nAlignThe Align bits.
Ghidra address:
NTSC-U/C: 0x00242b10
Ghidra address:
PAL: 0x0024b5e8

◆ SetText()

virtual void RndText::SetText ( const char * pszText)
virtual

Set the text.

Parameters
pszTextThe text. A newline starts a line.
Ghidra address:
NTSC-U/C: 0x00242d38
Ghidra address:
PAL: 0x0024b810

◆ SetFont()

virtual void RndText::SetFont ( RndFont * pFont)
virtual

Set the font.

Parameters
pFontThe font, or null.
Ghidra address:
NTSC-U/C: 0x00242a90
Ghidra address:
PAL: 0x0024b568

◆ Collide() [1/2]

void RndText::Collide ( const Segment & segment,
std::list< Collision > & collisions )
overridevirtual

Add each face of the mesh the segment strikes, as strikes of the text, then what the children strike, to a list.

Hidden text adds nothing.

Parameters
segmentThe segment, in world space.
collisionsThe list to add to.
Ghidra address:
NTSC-U/C: 0x002418a8
Ghidra address:
PAL: 0x0024a3b0

Reimplemented from RndCollideable.

◆ SetBillboard()

void RndText::SetBillboard ( int nBillboard)
overridevirtual

Set the billboard mode of the text and of its mesh.

Parameters
nBillboardThe Billboard mode.
Ghidra address:
NTSC-U/C: 0x00242dd0
Ghidra address:
PAL: 0x0024b8a8

Reimplemented from RndTransformable.

◆ UpdateWorldXfm()

int RndText::UpdateWorldXfm ( RndTransformable * pParent,
int bForce )
overridevirtual

Update the world transform of the text, then of its mesh from the text's.

Parameters
pParentThe parent, or null.
bForceNon-zero to update even when the transform is not out of date.
Returns
What RndTransformable::UpdateWorldXfm() reports.
Ghidra address:
NTSC-U/C: 0x00243888
Ghidra address:
PAL: 0x0024c360

Reimplemented from RndTransformable.

◆ DumpText()

void RndText::DumpText ( PrnStream & stream)
overridevirtual

Write a description of the text and its bases.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x00241ac8
Ghidra address:
PAL: 0x0024a5d0

Reimplemented from RndDrawable.

◆ Save()

void RndText::Save ( BinStream & stream)
overridevirtual

Write the text and its bases.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x00241ca0
Ghidra address:
PAL: 0x0024a7a8

Reimplemented from RndDrawable.

◆ Replace()

void RndText::Replace ( RndObject * pFrom,
RndObject * pTo )
overridevirtual

Replace the font when it is the object being replaced.

Parameters
pFromThe object being replaced.
pToThe replacement, or null.
Ghidra address:
NTSC-U/C: 0x002419f8
Ghidra address:
PAL: 0x0024a500

Reimplemented from RndDrawable.

◆ ClassName()

const char * RndText::ClassName ( ) const
inlineoverridevirtual

Report the class name.

Returns
sClassName.
Ghidra address:
NTSC-U/C: 0x003916a8
Ghidra address:
PAL: 0x003ffdb0

Implements RndObject.

◆ Copy()

void RndText::Copy ( const RndObject * pSource,
int nFlags )
overridevirtual

Copy another text and its bases, then build the mesh again.

Parameters
pSourceThe text to copy from.
nFlagsThe set of fields to copy.
Ghidra address:
NTSC-U/C: 0x002423e8
Ghidra address:
PAL: 0x0024aec0

Reimplemented from RndDrawable.

◆ Load()

void RndText::Load ( BinStream & stream)
overridevirtual

Read what Save() wrote, or an earlier version of it, then build the mesh.

Parameters
streamThe stream to read from.
Ghidra address:
NTSC-U/C: 0x00241ed8
Ghidra address:
PAL: 0x0024a9c8

Reimplemented from RndDrawable.

◆ UpdateCursors()

void RndText::UpdateCursors ( )

Give the text again to every cursor that refers to it.

Ghidra address:
NTSC-U/C: 0x002417f0
Ghidra address:
PAL: 0x0024a2f8

◆ SyncText()

void RndText::SyncText ( )

Copy mPreWrapText to mText with each tab as three spaces, limit it to 800 characters, wrap it when word wrap is on, and build the mesh.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00242258
Ghidra address:
PAL: 0x0024ad30

◆ SetWordWrap()

void RndText::SetWordWrap ( int nWordWrap)

Turn word wrap on or off.

Parameters
nWordWrapNon-zero to wrap.
Ghidra address:
NTSC-U/C: 0x00242350
Ghidra address:
PAL: 0x0024ae28

◆ SetWrapWidth()

void RndText::SetWrapWidth ( float fWrapWidth)

Set the width lines wrap at.

Parameters
fWrapWidthThe width.
Ghidra address:
NTSC-U/C: 0x00242370
Ghidra address:
PAL: 0x0024ae48

◆ SyncDepthTest()

void RndText::SyncDepthTest ( )

Give the mesh the depth test mDepthTest selects.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00242390
Ghidra address:
PAL: 0x0024ae68

◆ SetDepthTest()

void RndText::SetDepthTest ( int nDepthTest)

Turn the depth test on or off.

The name is inferred.

Parameters
nDepthTestNon-zero to test depth.
Ghidra address:
NTSC-U/C: 0x002423c8
Ghidra address:
PAL: 0x0024aea0

◆ MeasureWidth()

float RndText::MeasureWidth ( const char * pszText,
int nCount )

Measure the advance of a run of characters, without the spacing.

Parameters
pszTextThe characters.
nCountThe number of characters.
Returns
The advance, or 0 without a font.
Ghidra address:
NTSC-U/C: 0x00242b30
Ghidra address:
PAL: 0x0024b608

◆ WrapText()

void RndText::WrapText ( const char * pszText,
String & wrapped )

Break text into lines no wider than mWrapWidth, at the last space where there is one.

The space stays at the end of its line. The name is inferred.

Parameters
pszTextThe text.
wrappedReceives the wrapped text.
Ghidra address:
NTSC-U/C: 0x00242ba8
Ghidra address:
PAL: 0x0024b680

◆ NumLines()

int RndText::NumLines ( )

Count the lines of mText.

Returns
The count.
Ghidra address:
NTSC-U/C: 0x00242d68
Ghidra address:
PAL: 0x0024b840

◆ MeasureLine()

const char * RndText::MeasureLine ( const char * pszLine,
float & fWidth )

Measure the line of mText that starts at a character, with the spacing.

The name is inferred.

Parameters
pszLineThe first character of the line.
fWidthReceives the width.
Returns
The character after the end of the line.
Ghidra address:
NTSC-U/C: 0x00242e28
Ghidra address:
PAL: 0x0024b900

◆ BuildMesh()

void RndText::BuildMesh ( )

Build a mesh of one quad per character of mText, in the font's material.

Hidden text, text without a font, and empty text get no mesh. The name is inferred.

Ghidra address:
NTSC-U/C: 0x00242ef8
Ghidra address:
PAL: 0x0024b9d0

◆ BuildLine()

void RndText::BuildLine ( int nFirstChar,
const char * pszStart,
const char * pszEnd,
float fLine,
float fWidth )

Fill the quads of one line of the mesh.

The name is inferred.

Parameters
nFirstCharThe index of the line's first quad.
pszStartThe first character of the line.
pszEndThe character after the end of the line.
fLineThe line's position, in lines from the origin.
fWidthThe width of the line.
Ghidra address:
NTSC-U/C: 0x00243338
Ghidra address:
PAL: 0x0024be10

◆ CharPosition()

Vector3 RndText::CharPosition ( int nIndex)

Report the position of a character of mPreWrapText in the text's space.

The name is inferred.

Parameters
nIndexThe index of the character.
Returns
The position, or the origin without a font.
Ghidra address:
NTSC-U/C: 0x00243520
Ghidra address:
PAL: 0x0024bff8

◆ New()

RndObject * RndText::New ( const char * pszName)
inlinestatic

Create text.

Parameters
pszNameThe registry key.
Returns
The text.
Ghidra address:
NTSC-U/C: 0x003916b8
Ghidra address:
PAL: 0x003ffdc0

◆ GetAlign()

int RndText::GetAlign ( ) const
inline
Returns
The Align bits.

◆ GetFont()

RndFont * RndText::GetFont ( ) const
inline
Returns
The font, or null.

◆ GetPreWrapText()

const String & RndText::GetPreWrapText ( ) const
inline
Returns
The text as set.

◆ GetWrapWidth()

float RndText::GetWrapWidth ( ) const
inline
Returns
The width lines wrap at.

◆ ReleaseRefs()

void RndText::ReleaseRefs ( )
protected

Drop the reference on the font and delete the mesh.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00241e38
Ghidra address:
PAL: 0x0024a928

◆ AcquireRefs()

void RndText::AcquireRefs ( )
protected

Take a reference on the font and build the text again.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00241e98
Ghidra address:
PAL: 0x0024a988

◆ Collide() [2/2]

virtual void RndCollideable::Collide ( const Vector2 & point,
std::list< Collision > & collisions )
virtual

Test a screen point against the collideable and add what it strikes to a list.

The base body tests the children.

Parameters
pointThe screen point.
collisionsThe list to add to.
Ghidra address:
NTSC-U/C: 0x00222568
Ghidra address:
PAL: 0x0022b338

Reimplemented from RndCollideable.

Member Data Documentation

◆ sClassName

const char* RndText::sClassName
static

The class name a .rnd file writes, Text.

Ghidra address:
NTSC-U/C: 0x003b0a50
Ghidra address:
PAL: 0x0042f8e8

◆ sRev

int RndText::sRev
static

The format version Save() writes and Load() accepts.

Ghidra address:
NTSC-U/C: 0x003b0a54

The documentation for this class was generated from the following file: