wavelength 1.0.0
Loading...
Searching...
No Matches
rndbutton.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <vector>
5
6#include "os/binstream.h"
7#include "os/mem.h"
8#include "os/prnstream.h"
9#include "rnd/rndfont.h"
10#include "rnd/rndmat.h"
11#include "rnd/rndmesh.h"
12#include "rnd/rndobject.h"
13#include "rnd/rndtext.h"
14
21class RndButton : public RndObject {
22public:
24 static constexpr int kStateCount = 4;
25
33 explicit RndButton(const char *pszName);
34
41 ~RndButton() override;
42
49 void *operator new(size_t nSize) {
50 return PoolMemAlloc(static_cast<int>(nSize), "Button", 0);
51 }
52
58 void operator delete(void *pBlock) {
59 PoolMemFree(pBlock);
60 }
61
69 void DumpText(PrnStream &stream) override;
70
80 void Save(BinStream &stream) override;
81
92 void Replace(RndObject *pFrom, RndObject *pTo) override;
93
101 const char *ClassName() const override {
102 return sClassName;
103 }
104
115 void Copy(const RndObject *pSource, int nFlags) override;
116
124 void Load(BinStream &stream) override;
125
134 static RndObject *New(const char *pszName) {
135 return new RndButton(pszName);
136 }
137
144 static const char *sClassName;
145
152 static int sRev;
153
159 static int sLoadRev;
160
161protected:
171
181
182private:
183 int mState;
184 RndMesh *mMesh;
185 RndText *mText;
186 std::vector<RndMat *> mMats;
187 std::vector<RndFont *> mFonts;
188};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
Text output stream.
Definition prnstream.h:16
static int sRev
The format version Save() writes and Load() accepts.
Definition rndbutton.h:152
static RndObject * New(const char *pszName)
Create a button.
Definition rndbutton.h:134
const char * ClassName() const override
Report the class name.
Definition rndbutton.h:101
~RndButton() override
Drop the references on the targets and on every palette entry.
void DumpText(PrnStream &stream) override
Write a description of the button and its base.
void Save(BinStream &stream) override
Write the version, the state, the names of the targets, and the palettes.
static const char * sClassName
The class name a .rnd file writes, Button.
Definition rndbutton.h:144
static constexpr int kStateCount
The number of entries each palette starts with.
Definition rndbutton.h:24
RndButton(const char *pszName)
Construct a button in state 0 without targets and with four empty entries in each palette.
void Copy(const RndObject *pSource, int nFlags) override
Copy the state and the palettes of another button.
static int sLoadRev
The version Load() read last.
Definition rndbutton.h:159
void Replace(RndObject *pFrom, RndObject *pTo) override
Replace a target or a palette entry with another object.
void Load(BinStream &stream) override
Read what Save() wrote.
void AcquireRefs()
Take a reference on the targets and on every palette entry.
void ReleaseRefs()
Drop the references on the targets and on every palette entry.
Triangle mesh with a material.
Definition rndmesh.h:31
RndObject(const char *pszName)
Construct an object and register it under a name.
Text drawn with a bitmap font as a mesh of one quad per character.
Definition rndtext.h:27
void * PoolMemAlloc(int nSize, const char *pszTag, int nAlign)
Allocate a block from the pool heaps and bill it to a tag.
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.