wavelength 1.0.0
Loading...
Searching...
No Matches
helppanel.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <vector>
5
6#include "math/vector3.h"
7#include "met/freqpanel.h"
8#include "os/string.h"
9#include "rnd/rndloader.h"
10#include "rnd/rndtext.h"
12#include "rnd/rndview.h"
13#include "script/dataarray.h"
14#include "ui/uicomponent.h"
15#include "ui/uipanel.h"
16#include "ui/uiscreen.h"
17
29class HelpPanel : public FreqPanel {
30public:
36
38#ifdef VIDEO_STANDARD_PAL
39 static constexpr int kNumTexts = 8;
40#else
41 static constexpr int kNumTexts = 7;
42#endif
43
52 HelpPanel(DataArray *pData, const char *pszDir);
53
60 ~HelpPanel() override;
61
73 static UIPanel *New(DataArray *pData, const char *pszDir) {
74 return new HelpPanel(pData, pszDir);
75 }
76
84 void Load() override;
85
92 void Unload() override;
93
101 void FinishLoad() override;
102
111 const char *FontOf(const char *pszName);
112
120 void ParseText(const String &text);
121
128 void ClearHelp();
129
138
147
155 void Refresh();
156
166 void ShowHelp(UIPanel *pPanel, UIComponent *pComponent);
167
176 void ShowActions(UIScreen *pScreen);
177
185 void SetHelpText(const char *pszText);
186
194 void SetActionText(const char *pszText);
195
202 static std::unique_ptr<RndLoader> sLoader;
203
204 alignas(16) float mHelpOrigin[sizeof(Vector3) / sizeof(float)];
205 alignas(
206 16) float mActionOrigin[sizeof(Vector3) / sizeof(float)];
207
208private:
209 RndView *mView;
210 DataArray *mFonts;
211 std::vector<RndText *> mHelpTexts;
212 std::vector<RndText *> mActionTexts;
213 const char *mHelpText;
214 const char *mActionText;
215 std::vector<HelpText> mRuns;
216};
Reference-counted array of script data nodes.
Definition dataarray.h:20
FreqPanel(DataArray *pData, const char *pszDir)
Construct a panel from its script description.
void Load() override
Take a reference to the panel's file through the loader every help panel shares, creating the loader ...
const char * FontOf(const char *pszName)
Report the font of a font name of the help_fonts entry.
static UIPanel * New(DataArray *pData, const char *pszDir)
Create a panel from its script description.
Definition helppanel.h:73
float mActionOrigin[sizeof(Vector3)/sizeof(float)]
Definition helppanel.h:206
void Unload() override
Drop a reference to the panel's file, keeping the shared loader on the last reference.
void LayoutHelp()
Place the runs in the help text objects left to right, and centre them on where the first help text s...
void ShowHelp(UIPanel *pPanel, UIComponent *pComponent)
Show the help of a component, from the <screen>_HELP, <panel>_HELP, or <panel>_<component>_HELP token...
HelpPanel(DataArray *pData, const char *pszDir)
Construct a hidden panel from its script description.
void ShowActions(UIScreen *pScreen)
Show the buttons of a screen, from the <screen>_ACTION or <panel>_ACTION token of the locale,...
void SetHelpText(const char *pszText)
Show a help text.
void LayoutActions()
Place the runs in the button text objects right to left from where the first button text starts.
float mHelpOrigin[sizeof(Vector3)/sizeof(float)]
Definition helppanel.h:204
static std::unique_ptr< RndLoader > sLoader
The loader every help panel shares, or null before the first Load().
Definition helppanel.h:202
static constexpr int kNumTexts
The number of text objects for the help and for the buttons.
Definition helppanel.h:41
void ClearHelp()
Empty the help text objects.
void Refresh()
Show the help of the component that has the focus on the current screen, or clear the help when no pa...
void SetActionText(const char *pszText)
Show a text of the buttons.
~HelpPanel() override
Destroy the panel.
void FinishLoad() override
Find the text objects, the view, and the fonts once the panel's file has loaded, and record where the...
void ParseText(const String &text)
Split a text into runs at its <F<n>> marks into mRuns.
View that shows the children of another view, its children owner, under its own transform and frame.
Definition rndview.h:27
Growable text buffer that is also a PrnStream.
Definition string.h:19
One control of a front-end panel, such as a label, a button, or a list.
Definition uicomponent.h:21
UIPanel(DataArray *pData, const char *pszDir)
Construct a hidden panel from its script description.
One front-end screen, a set of panels shown together with one panel holding the focus.
Definition uiscreen.h:35
One run of a help or button text in one font.
Definition helppanel.h:32
String mText
Definition helppanel.h:34
String mFont
Definition helppanel.h:33
Three-component vector, padded to a PlayStation 2 quadword.
Definition vector3.h:14