metaforce/Runtime/GuiSys/CGuiTextSupport.hpp

130 lines
3.1 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-08-15 20:58:07 +00:00
float x10_ = 0.f;
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;
std::vector<std::pair<float, int>> x44_primStartTimes;
bool x50_typeEnable = false;
float x54_chFadeTime = 0.1f;
float x58_chRate = 10.0f;
ResId x5c_fontId;
std::experimental::optional<CTextRenderBuffer> x60_renderBuf;
2016-03-21 22:01:19 +00:00
bool x2ac_active = false;
std::vector<CToken> x2b0_assets;
2016-08-15 20:58:07 +00:00
TLockedToken<CRasterFont> x2cc_font;
zeus::CVector2f x2dc_;
zeus::CVector2f x2e4_;
std::list<u8> x2f0_;
u32 x300_ = 0;
u32 x304_ = 0;
u32 x308_ = 0;
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;
void SetTypeWriteEffectOptions(bool enable, float chFadeTime, float chRate);
2016-03-18 03:35:16 +00:00
void Update(float dt);
void ClearBuffer();
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);
void SetText(const std::wstring& str);
void SetText(const std::string& str);
bool GetIsTextSupportFinishedLoading() const;
};
2016-03-10 03:47:37 +00:00
}
#endif // __URDE_CGUITEXTSUPPORT_HPP__