metaforce/Runtime/GuiSys/CGuiTextSupport.hpp

132 lines
3.2 KiB
C++
Raw Normal View History

2016-03-10 03:47:37 +00:00
#ifndef __URDE_CGUITEXTSUPPORT_HPP__
#define __URDE_CGUITEXTSUPPORT_HPP__
2016-03-18 03:35:16 +00:00
#include "zeus/CColor.hpp"
#include "RetroTypes.hpp"
2016-03-19 00:07:31 +00:00
#include "CToken.hpp"
#include "CTextRenderBuffer.hpp"
#include "optional.hpp"
2016-03-18 03:35:16 +00:00
#include <string>
2016-03-10 03:47:37 +00:00
namespace urde
{
2016-03-18 03:35:16 +00:00
class CSimplePool;
2016-03-19 00:07:31 +00:00
class CRasterFont;
class CTextRenderBuffer;
2016-03-18 03:35:16 +00:00
enum class EJustification
{
2016-03-21 00:25:53 +00:00
Left = 0,
Center,
Right,
Full,
NLeft,
NCenter,
NRight,
2016-03-20 06:37:08 +00:00
Seven,
Eight,
Nine
2016-03-18 03:35:16 +00:00
};
enum class EVerticalJustification
{
2016-03-21 00:25:53 +00:00
Top = 0,
Center,
Bottom,
Full,
NTop,
NCenter,
NBottom,
2016-03-20 06:37:08 +00:00
Seven,
Eight,
Nine
2016-03-18 03:35:16 +00:00
};
2016-03-19 00:07:31 +00:00
enum class EColorType
{
2016-03-21 00:25:53 +00:00
Main,
Outline,
Geometry,
Foreground,
2016-03-21 22:01:19 +00:00
Background
2016-03-19 00:07:31 +00:00
};
enum class ETextDirection
{
2016-03-20 00:32:30 +00:00
Horizontal,
Vertical
2016-03-19 00:07:31 +00:00
};
2016-03-18 03:35:16 +00:00
class CGuiTextProperties
{
2016-03-21 22:01:19 +00:00
friend class CGuiTextSupport;
bool x0_wordWrap;
2016-08-16 22:49:19 +00:00
bool x1_multiline;
2016-03-18 03:35:16 +00:00
EJustification x4_justification;
EVerticalJustification x8_vertJustification;
2016-08-15 20:58:07 +00:00
ETextDirection xc_direction;
2016-03-18 03:35:16 +00:00
public:
2016-08-16 22:49:19 +00:00
CGuiTextProperties(bool wordWrap, bool multiline, EJustification justification,
EVerticalJustification vertJustification,
ETextDirection dir=ETextDirection::Horizontal)
: x0_wordWrap(wordWrap), x1_multiline(multiline), x4_justification(justification),
2016-08-15 20:58:07 +00:00
x8_vertJustification(vertJustification), xc_direction(dir) {}
2016-03-18 03:35:16 +00:00
};
2016-03-10 03:47:37 +00:00
2016-03-18 03:35:16 +00:00
class CGuiTextSupport
{
2016-03-22 02:27:46 +00:00
friend class CGuiTextPane;
2016-03-21 22:01:19 +00:00
std::wstring x0_string;
2016-12-16 23:05:29 +00:00
float x10_curTimeMod900 = 0.f;
2016-08-15 20:58:07 +00:00
CGuiTextProperties x14_props;
zeus::CColor x24_fontColor;
zeus::CColor x28_outlineColor;
zeus::CColor x2c_geometryColor;
s32 x34_extentX;
s32 x38_extentY;
float x3c_curTime = 0.f;
2016-12-16 23:05:29 +00:00
std::vector<std::pair<float, int>> x40_primStartTimes;
2016-08-15 20:58:07 +00:00
bool x50_typeEnable = false;
float x54_chFadeTime = 0.1f;
float x58_chRate = 10.0f;
ResId x5c_fontId;
std::experimental::optional<CTextRenderBuffer> x60_renderBuf;
2016-12-16 23:05:29 +00:00
std::vector<CToken> x2bc_assets;
2016-08-15 20:58:07 +00:00
TLockedToken<CRasterFont> x2cc_font;
zeus::CVector2f x2dc_;
zeus::CVector2f x2e4_;
2016-12-16 23:05:29 +00:00
std::list<CTextRenderBuffer> x2f0_lineRenderBufs;
2016-08-15 20:58:07 +00:00
u32 x300_ = 0;
2016-12-16 23:05:29 +00:00
u32 x304_lineCounter = 0;
bool x308_multilineFlag = false;
CTextRenderBuffer* GetCurrentLineRenderBuffer() const;
2016-08-15 20:58:07 +00:00
2016-03-18 03:35:16 +00:00
public:
2016-04-14 21:42:47 +00:00
CGuiTextSupport(ResId fontId, const CGuiTextProperties& props,
2016-03-22 02:27:46 +00:00
const zeus::CColor& fontCol, const zeus::CColor& outlineCol,
const zeus::CColor& geomCol, s32 extX, s32 extY, CSimplePool* store);
2016-03-21 22:01:19 +00:00
float GetCurrentAnimationOverAge() const;
float GetNumCharsPrinted() const;
float GetTotalAnimationTime() const;
2016-12-16 23:05:29 +00:00
bool IsAnimationDone() const;
2016-03-21 22:01:19 +00:00
void SetTypeWriteEffectOptions(bool enable, float chFadeTime, float chRate);
2016-03-18 03:35:16 +00:00
void Update(float dt);
2016-12-16 23:05:29 +00:00
void ClearRenderBuffer();
2016-03-18 03:35:16 +00:00
void CheckAndRebuildTextRenderBuffer();
void Render() const;
void SetGeometryColor(const zeus::CColor& col);
void SetOutlineColor(const zeus::CColor& col);
void SetFontColor(const zeus::CColor& col);
void AddText(const std::wstring& str);
2016-12-16 23:05:29 +00:00
void SetText(const std::wstring& str, bool multiline=false);
void SetText(const std::string& str, bool multiline=false);
2016-03-18 03:35:16 +00:00
bool GetIsTextSupportFinishedLoading() const;
};
2016-03-10 03:47:37 +00:00
}
#endif // __URDE_CGUITEXTSUPPORT_HPP__