metaforce/Runtime/GuiSys/CGuiTextSupport.hpp

149 lines
4.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"
2017-01-29 03:58:16 +00:00
#include "CGuiWidget.hpp"
2017-04-02 03:03:37 +00:00
#include "CSaveWorld.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-12-30 06:37:01 +00:00
class CTextExecuteBuffer;
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,
LeftMono,
CenterMono,
RightMono
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,
TopMono,
CenterMono,
RightMono
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;
2017-01-30 04:16:20 +00:00
bool x1_horizontal;
2016-03-18 03:35:16 +00:00
EJustification x4_justification;
EVerticalJustification x8_vertJustification;
2017-04-02 03:03:37 +00:00
const std::vector<CSaveWorld::SScanState>* xc_scanStates;
2016-03-18 03:35:16 +00:00
public:
2017-01-30 04:16:20 +00:00
CGuiTextProperties(bool wordWrap, bool horizontal, EJustification justification,
2017-04-02 03:03:37 +00:00
EVerticalJustification vertJustification,
const std::vector<CSaveWorld::SScanState>* scanStates=nullptr)
2017-01-30 04:16:20 +00:00
: x0_wordWrap(wordWrap), x1_horizontal(horizontal), x4_justification(justification),
2017-04-02 03:03:37 +00:00
x8_vertJustification(vertJustification), xc_scanStates(scanStates) {}
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;
2017-01-24 07:41:33 +00:00
std::u16string 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;
2017-01-30 04:16:20 +00:00
bool x30_imageBaseline = false;
2016-08-15 20:58:07 +00:00
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;
2017-01-27 02:22:52 +00:00
ResId x5c_fontId = -1;
2017-01-29 03:58:16 +00:00
CGuiWidget::EGuiModelDrawFlags m_drawFlags;
2016-08-15 20:58:07 +00:00
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;
2016-12-31 00:51:51 +00:00
std::pair<zeus::CVector2i, zeus::CVector2i> x2dc_oneBufBounds;
2016-08-15 20:58:07 +00:00
2016-12-31 00:51:51 +00:00
std::list<CTextRenderBuffer> x2ec_renderBufferPages;
2016-08-15 20:58:07 +00:00
u32 x300_ = 0;
2016-12-29 05:53:00 +00:00
u32 x304_pageCounter = 0;
bool x308_multipageFlag = false;
2016-12-16 23:05:29 +00:00
2016-12-30 06:37:01 +00:00
CTextRenderBuffer* GetCurrentPageRenderBuffer() const;
bool _GetIsTextSupportFinishedLoading() 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,
2017-01-29 03:58:16 +00:00
const zeus::CColor& geomCol, s32 extX, s32 extY, CSimplePool* store,
CGuiWidget::EGuiModelDrawFlags drawFlags);
2016-03-21 22:01:19 +00:00
float GetCurrentAnimationOverAge() const;
2017-01-09 03:44:00 +00:00
float GetNumCharsTotal() const;
2016-03-21 22:01:19 +00:00
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-12-30 06:37:01 +00:00
void CheckAndRebuildTextBuffer();
bool CheckAndRebuildRenderBuffer();
2016-12-31 00:51:51 +00:00
const std::pair<zeus::CVector2i, zeus::CVector2i>& GetBounds();
void AutoSetExtent();
2016-12-30 06:37:01 +00:00
2016-03-18 03:35:16 +00:00
void Render() const;
void SetGeometryColor(const zeus::CColor& col);
void SetOutlineColor(const zeus::CColor& col);
void SetFontColor(const zeus::CColor& col);
2017-01-24 07:41:33 +00:00
void AddText(const std::u16string& str);
void SetText(const std::u16string& str, bool multipage=false);
2016-12-29 05:53:00 +00:00
void SetText(const std::string& str, bool multipage=false);
2017-01-30 04:16:20 +00:00
void SetJustification(EJustification j);
void SetVerticalJustification(EVerticalJustification j);
void SetImageBaseline(bool b);
2016-03-18 03:35:16 +00:00
bool GetIsTextSupportFinishedLoading() const;
2017-02-12 03:17:18 +00:00
float GetCurTime() const { return x3c_curTime; }
2017-04-13 19:28:31 +00:00
void SetCurTime(float t) { x3c_curTime = t; }
const std::u16string& GetString() const { return x0_string; }
2017-04-02 03:03:37 +00:00
void SetScanStates(const std::vector<CSaveWorld::SScanState>* scanStates);
2016-03-18 03:35:16 +00:00
};
2016-03-10 03:47:37 +00:00
}
#endif // __URDE_CGUITEXTSUPPORT_HPP__