resonance 1.0.1
Loading...
Searching...
No Matches
button.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "os/hxstr.h"
6#include "rnd/object.h"
7
8namespace Rnd {
9class Dbg;
10class Font;
11class Mat;
12class Mesh;
13class Stream;
14} // namespace Rnd
15
16namespace Rnd {
17
18class Text;
19
39class Button : public Object {
40public:
51 explicit Button(const HxStr &name);
52
59 virtual ~Button();
60
69 static void *operator new(size_t nSize);
70
78 static void operator delete(void *pBlock);
79
87 virtual void DumpText(Dbg &sink);
88
96 virtual void Save(Stream &stream);
97
109 virtual void Replace(Object *pFrom, Object *pTo);
110
121 virtual const HxStr &ClassName() const;
122
135 virtual void Copy(const Object *pSource, unsigned nFlags);
136
148 virtual void Load(Stream &stream);
149
161 void SetShowing(int nShowing);
162
173 void SetMesh(Mesh *pMesh);
174
185 void SetText(Text *pText);
186
198 void SetMat(int nState, Mat *pMat);
199
211 void SetFont(int nState, Font *pFont);
212
221 void SetState(int nState);
222
223private:
232 void AddObjectRefs();
233
242 void RemoveObjectRefs();
243
244 // Declared in recovered offset order.
245
246public:
255
256private:
257 Mesh *mMesh; // +0x20
258
259public:
269
277 std::vector<Mat *> mMats;
278
288 std::vector<Font *> mFonts;
289};
290
301Button *NewButton(const HxStr &name);
302
312extern Button *(*g_pfnNewButton)(const HxStr &name);
313
323
333
344
357
367extern int g_nRndButtonLoadVersion;
368
369} // namespace Rnd
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
Selectable widget, as one mesh and one text run plus a palette for each.
Definition button.h:39
int mState
The palette entry SetState() last selected.
Definition button.h:254
void SetMesh(Mesh *pMesh)
Replace mMesh, moving this object's reference to the new mesh.
virtual void Replace(Object *pFrom, Object *pTo)
Retarget both targets and every palette entry that refers to the replaced object.
Text * mText
Label drawn over mMesh.
Definition button.h:268
void SetShowing(int nShowing)
Show or hide both targets.
void SetMat(int nState, Mat *pMat)
Replace one entry of mMats, moving this object's reference to the new material.
std::vector< Font * > mFonts
Fonts the state selects among, for mText.
Definition button.h:288
virtual void Load(Stream &stream)
Read this button from stream.
void SetState(int nState)
Select one of mMats and one of mFonts.
std::vector< Mat * > mMats
Materials the state selects among, for mMesh.
Definition button.h:277
virtual const HxStr & ClassName() const
Report the class key a .rnd file writes for a button.
void SetText(Text *pText)
Replace mText, moving this object's reference to the new text.
virtual ~Button()
Drop this object's reference on both targets and on every palette entry.
virtual void Save(Stream &stream)
Write this button to stream at revision 0.
virtual void DumpText(Dbg &sink)
Write a description of this button to sink.
Button(const HxStr &name)
Construct a button with no targets and one empty palette entry each.
virtual void Copy(const Object *pSource, unsigned nFlags)
Copy the state and both palettes of pSource into this button.
void SetFont(int nState, Font *pFont)
Replace one entry of mFonts, moving this object's reference to the new font.
Sink that the engine formats its diagnostic and failure text into.
Definition dbg.h:33
Glyph atlas, either a host font description or a grid of cells inside a material texture.
Definition font.h:59
Surface description a Rnd::Mesh draws with.
Definition mat.h:36
Indexed triangle mesh with one material.
Definition mesh.h:46
Base of every object the renderer can load, resolve by name, and serialise.
Definition object.h:43
Object()
Construct an unnamed object.
Byte stream that every renderer object serialises itself through.
Definition stream.h:31
Run of text drawn as a quad per glyph.
Definition text.h:57
The rendering engine.
Definition animhelper.h:3
void RegisterButtonClass()
Point g_pfnNewButton at NewButton() and register the "Button" class with Rnd::Manager.
Button * NewButton(const HxStr &name)
Allocate and construct a button.
Button * NewButtonThroughHook(const HxStr &name)
Build a button through the creator hook.
Object * CreateRegisteredButton(const HxStr &name)
Build a button for the registered "Button" class.
int g_nRndButtonLoadVersion
Serial revision of the button record currently being read.
HxStr g_buttonClassName
Registered class name of Rnd::Button, the string "Button".