Various stubs and imps

This commit is contained in:
Jack Andersen 2016-03-18 14:07:31 -10:00
parent ad577754c4
commit ee534de7be
24 changed files with 582 additions and 28 deletions

View File

View File

@ -0,0 +1,30 @@
#ifndef __URDE_CGRAPHICSPALETTE_HPP__
#define __URDE_CGRAPHICSPALETTE_HPP__
#include <memory>
#include "RetroTypes.hpp"
namespace urde
{
enum class EPaletteFormat
{
IA8 = 0x0,
RGB565 = 0x1,
RGB5A3 = 0x2,
};
class CGraphicsPalette
{
EPaletteFormat x0_fmt;
int x4_entryCount;
std::unique_ptr<u16[]> x8_entries;
/* xc_ GXTlutObj here */
public:
CGraphicsPalette(EPaletteFormat fmt, int count)
: x0_fmt(fmt), x4_entryCount(count), x8_entries(new u16[count]) {}
};
}
#endif // __URDE_CGRAPHICSPALETTE_HPP__

View File

@ -16,5 +16,6 @@ add_library(RuntimeCommonGraphics
CTexture.hpp CTextureBoo.cpp
CModel.hpp CModelBoo.cpp
CMoviePlayer.hpp CMoviePlayer.cpp
CGraphicsPalette.hpp CGraphicsPalette.cpp
CGraphics.hpp CGraphics.cpp
${PLAT_SRCS})

View File

@ -3,14 +3,18 @@
#include <vector>
#include "RetroTypes.hpp"
#include "zeus/CColor.hpp"
namespace urde
{
class CDrawStringOptions
{
friend class CColorOverrideInstruction;
friend class CFontRenderState;
friend class CRasterFont;
u32 x0_ = 0;
std::vector<u32> x4_vec;
std::vector<zeus::CColor> x4_vec;
public:
CDrawStringOptions()
{

View File

View File

@ -0,0 +1,13 @@
#ifndef __URDE_CFONTIMAGEDEF_HPP__
#define __URDE_CFONTIMAGEDEF_HPP__
namespace urde
{
class CFontImageDef
{
};
}
#endif // __URDE_CFONTIMAGEDEF_HPP__

View File

@ -0,0 +1,99 @@
#include "CFontRenderState.hpp"
#include "CRasterFont.hpp"
namespace urde
{
CFontRenderState::CFontRenderState()
{
x20_[0] = zeus::CColor::skWhite;
x20_[1] = zeus::CColor::skGrey;
x20_[2] = zeus::CColor::skWhite;
RefreshPalette();
}
zeus::CColor CFontRenderState::ConvertToTextureSpace(const CTextColor& col) const
{
return col;
}
void CFontRenderState::PopState()
{
static_cast<CSaveableState&>(*this) = xa4_pushedStates.back();
xa4_pushedStates.pop_back();
RefreshPalette();
}
void CFontRenderState::PushState()
{
xa4_pushedStates.push_back(*this);
}
void CFontRenderState::SetColor(EColorType tp, const CTextColor& col)
{
switch (tp)
{
case EColorType::Zero:
case EColorType::One:
case EColorType::Two:
x20_[int(tp)] = col;
break;
case EColorType::Three:
x20_[0] = col;
break;
case EColorType::Four:
x20_[1] = col;
break;
}
RefreshColor(tp);
}
void CFontRenderState::RefreshPalette()
{
RefreshColor(EColorType::Three);
RefreshColor(EColorType::Four);
}
void CFontRenderState::RefreshColor(EColorType tp)
{
switch (tp)
{
case EColorType::Zero:
if (!x14_token)
return;
switch (x14_token.GetObj()->GetMode())
{
case EColorType::Zero:
if (!x30_[0])
x0_drawStrOpts.x4_vec[0] = ConvertToTextureSpace(x20_[0]);
break;
case EColorType::One:
if (!x30_[0])
x0_drawStrOpts.x4_vec[0] = ConvertToTextureSpace(x20_[0]);
break;
default: break;
}
break;
case EColorType::One:
if (!x14_token)
return;
if (x30_[1])
return;
if (x14_token.GetObj()->GetMode() == EColorType::One)
x0_drawStrOpts.x4_vec[1] = ConvertToTextureSpace(x20_[1]);
break;
case EColorType::Two:
if (!x30_[2])
x0_drawStrOpts.x4_vec[2] = ConvertToTextureSpace(x20_[2]);
break;
case EColorType::Three:
RefreshColor(EColorType::Zero);
RefreshColor(EColorType::Two);
break;
case EColorType::Four:
RefreshColor(EColorType::One);
break;
}
}
}

View File

@ -0,0 +1,30 @@
#ifndef __URDE_CFONTRENDERSTATE_HPP__
#define __URDE_CFONTRENDERSTATE_HPP__
#include "CGuiTextSupport.hpp"
#include "CSaveableState.hpp"
#include "CDrawStringOptions.hpp"
namespace urde
{
class CFontRenderState : public CSaveableState
{
u32 x54_ = 0;
CDrawStringOptions x58_drawOpts;
u32 x6c_ = 0;
bool xa0_ = true;
std::vector<CSaveableState> xa4_pushedStates;
public:
CFontRenderState();
zeus::CColor ConvertToTextureSpace(const CTextColor& col) const;
void PopState();
void PushState();
void SetColor(EColorType tp, const CTextColor& col);
void RefreshPalette();
void RefreshColor(EColorType tp);
};
}
#endif // __URDE_CFONTRENDERSTATE_HPP__

View File

@ -0,0 +1,14 @@
#include "CGuiTextSupport.hpp"
#include "CSimplePool.hpp"
namespace urde
{
CGuiTextSupport::CGuiTextSupport(TResId fontId, const CGuiTextProperties& props,
const zeus::CColor& col1, const zeus::CColor& col2,
const zeus::CColor& col3, int, int, CSimplePool* store)
{
store->GetObj({SBIG('FONT'), fontId});
}
}

View File

@ -3,11 +3,13 @@
#include "zeus/CColor.hpp"
#include "RetroTypes.hpp"
#include "CToken.hpp"
#include <string>
namespace urde
{
class CSimplePool;
class CRasterFont;
enum class EJustification
{
@ -17,6 +19,25 @@ enum class EVerticalJustification
{
};
enum class EColorType
{
Zero,
One,
Two,
Three,
Four
};
enum class ETextDirection
{
};
class CTextColor : public zeus::CColor
{
public:
CTextColor(const zeus::CColor& col) : zeus::CColor(col) {}
};
class CGuiTextProperties
{
bool x0_a;
@ -33,8 +54,10 @@ public:
class CGuiTextSupport
{
TResId x50_fontId;
TLockedToken<CRasterFont> x2c0_font;
public:
CGuiTextSupport(u32, const CGuiTextProperties& props,
CGuiTextSupport(TResId fontId, const CGuiTextProperties& props,
const zeus::CColor& col1, const zeus::CColor& col2,
const zeus::CColor& col3, int, int, CSimplePool*);
void GetCurrentAnimationOverAge() const;

View File

@ -0,0 +1,28 @@
#include "CInstruction.hpp"
#include "CFontRenderState.hpp"
namespace urde
{
void CInstruction::GetAssets(std::vector<CToken>& assetsOut) const
{
}
size_t CInstruction::GetAssetCount() const
{
return 0;
}
void CColorInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
state.SetColor(x4_cType, x8_color);
}
void CColorOverrideInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
state.x30_[x4_overrideIdx] = true;
zeus::CColor convCol = state.ConvertToTextureSpace(x8_color);
state.x0_drawStrOpts.x4_vec[x4_overrideIdx] = convCol;
}
}

View File

@ -0,0 +1,84 @@
#ifndef __URDE_CINSTRUCTION_HPP__
#define __URDE_CINSTRUCTION_HPP__
#include "CToken.hpp"
#include "CGuiTextSupport.hpp"
#include <vector>
namespace urde
{
class CFontRenderState;
class CTextRenderBuffer;
class CInstruction
{
public:
virtual ~CInstruction() = default;
virtual void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const=0;
virtual void GetAssets(std::vector<CToken>& assetsOut) const;
virtual size_t GetAssetCount() const;
};
class CColorInstruction : public CInstruction
{
EColorType x4_cType;
CTextColor x8_color;
public:
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
};
class CColorOverrideInstruction : public CInstruction
{
int x4_overrideIdx;
CTextColor x8_color;
public:
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
};
class CFontInstruction : public CInstruction
{
};
class CExtraLineSpaceInstruction : public CInstruction
{
};
class CLineInstruction : public CInstruction
{
};
class CLineSpacingInstruction : public CInstruction
{
};
class CPopStateInstruction : public CInstruction
{
};
class CPushStateInstruction : public CInstruction
{
};
class CRemoveColorOverrideInstruction : public CInstruction
{
};
class CImageInstruction : public CInstruction
{
};
class CTextInstruction : public CInstruction
{
};
class CBlockInstruction : public CInstruction
{
};
class CWordInstruction : public CInstruction
{
};
}
#endif // __URDE_CINSTRUCTION_HPP__

View File

@ -78,4 +78,18 @@ add_library(RuntimeCommonGuiSys
CGuiPane.cpp
CGuiPane.hpp
CGuiMessage.cpp
CGuiMessage.hpp)
CGuiMessage.hpp
CFontRenderState.cpp
CFontRenderState.hpp
CTextExecuteBuffer.cpp
CTextExecuteBuffer.hpp
CTextRenderBuffer.cpp
CTextRenderBuffer.hpp
CInstruction.cpp
CInstruction.hpp
CTextParser.cpp
CTextParser.hpp
CWordBreakTables.cpp
CWordBreakTables.hpp
CFontImageDef.cpp
CFontImageDef.hpp)

View File

@ -1,4 +1,6 @@
#include "GuiSys/CRasterFont.hpp"
#include "CDrawStringOptions.hpp"
#include "CTextRenderBuffer.hpp"
namespace urde
{
@ -30,12 +32,12 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store)
u32 txtrId = in.readUint32Big();
x30_fontInfo = CFontInfo(tmp1, tmp2, tmp3, tmp4, name.c_str());
x80_texture = store.GetObj({'TXTR', txtrId});
u32 mode = in.readUint32Big();
EColorType mode = EColorType(in.readUint32Big());
/* TODO: Make an enum */
if (mode == 1)
x2c_mode = 1;
else if (mode == 0)
x2c_mode = 0;
if (mode == EColorType::One)
x2c_mode = EColorType::One;
else if (mode == EColorType::Zero)
x2c_mode = EColorType::Zero;
u32 glyphCount = in.readUint32Big();
xc_glyphs.reserve(glyphCount);
@ -101,7 +103,7 @@ void CRasterFont::SinglePassDrawString(const CDrawStringOptions& opts, int x, in
{
left += x;
top += glyph->GetBaseline() - y;
renderBuf->AddCharacter(zeus::CVector2i(left, top), *chr, opts.x10_);
renderBuf->AddCharacter(zeus::CVector2i(left, top), *chr, opts.x4_vec[0]);
}
x += glyph->GetC() + glyph->GetB();
}

View File

@ -4,26 +4,14 @@
#include "IOStreams.hpp"
#include "CToken.hpp"
#include "zeus/CVector2i.hpp"
#include "CGuiTextSupport.hpp"
namespace urde
{
class IObjectStore;
class CTexture;
/* TODO: Move these elsewhere */
struct CDrawStringOptions
{
s32 x0_;
u32 x10_;
};
class CTextRenderBuffer
{
public:
void AddCharacter(const zeus::CVector2i& pos, s16 chr, u32 unk)
{
}
};
class CDrawStringOptions;
class CTextRenderBuffer;
/* NOTE: Is this a good place for CGlyph and CKernPair? */
class CGlyph
@ -107,7 +95,7 @@ class CRasterFont
std::vector<std::pair<wchar_t, CGlyph>> xc_glyphs;
std::vector<CKernPair> x1c_kerning;
s32 x28_lineMargin = 0;
s32 x2c_mode = 0;
EColorType x2c_mode = EColorType::Zero;
CFontInfo x30_fontInfo;
TLockedToken<CTexture> x80_texture;
bool x88_ = false;
@ -129,7 +117,7 @@ public:
s32 GetMonoWidth() const { return x4_monoWidth; }
s32 GetMonoHeight() const { return x8_monoHeight; }
s32 GetMode() const { return x2c_mode; }
EColorType GetMode() const { return x2c_mode; }
s32 GetLineMargin() const { return x90_lineMargin; }
s32 GetCarriageAdvance() const { return GetLineMargin() + GetMonoHeight(); }

View File

@ -1,6 +1,7 @@
#ifndef __URDE_CSAVEABLESTATE_HPP__
#define __URDE_CSAVEABLESTATE_HPP__
#include "CGuiTextSupport.hpp"
#include "CDrawStringOptions.hpp"
#include "CToken.hpp"
#include "zeus/CColor.hpp"
@ -11,16 +12,19 @@ class CRasterFont;
class CSaveableState
{
friend class CColorOverrideInstruction;
protected:
CDrawStringOptions x0_drawStrOpts;
TToken<CRasterFont> x14_token;
std::vector<zeus::CColor> x20_;
std::vector<u8> x30_;
std::vector<CTextColor> x20_;
std::vector<bool> x30_;
float x40_ = 1.f;
u32 x44_ = 0;
bool x48_ = false;
u32 x4c_ = 0;
u32 x50_ = 0;
public:
CSaveableState()
{
x20_.resize(3, zeus::CColor::skBlack);

View File

View File

@ -0,0 +1,64 @@
#ifndef __URDE_CTEXTEXECUTEBUFFER_HPP__
#define __URDE_CTEXTEXECUTEBUFFER_HPP__
#include "CSaveableState.hpp"
#include "CGuiTextSupport.hpp"
#include <list>
namespace urde
{
class CInstruction;
class CFontImageDef;
class CTextExecuteBuffer
{
std::list<std::weak_ptr<CInstruction>> x0_instList;
u32 x14_ = 0;
CSaveableState x18_;
u32 x6c_ = 0;
u32 x70_ = 0;
std::list<std::shared_ptr<CInstruction>>::iterator x74_curInst;
u32 x80_ = 0;
u32 x84_ = 0;
u32 x88_ = 0;
u32 x90_ = 0;
u32 x94_ = 0;
u32 x98_ = 0;
public:
CTextExecuteBuffer()
{
x74_curInst = x0_instList.begin();
}
void CreateTextRenderBuffer() const;
std::vector<TResId> GetAssets() const;
void AddString(const wchar_t* str, int);
void AddStringFragment(const wchar_t* str, int);
void WrapOneTTB(const wchar_t* str, int);
void WrapOneLTR(const wchar_t* str, int);
void MoveWordTTB();
void MoveWordLTR();
void StartNewLine();
void StartNewWord();
void TerminateLine();
void TerminateLineTTB();
void TerminateLineLTR();
void AddPopState();
void AddPushState();
void AddVerticalJustification(EVerticalJustification);
void AddJustification(EJustification);
void AddLineExtraSpace(int);
void AddLineSpacing(float);
void AddRemoveColorOverride(int);
void AddColorOverride(int, const CTextColor& color);
void AddColor(EColorType, const CTextColor& color);
void AddImage(const CFontImageDef& image);
void EndBlock();
void BeginBlock(int,int,int,int,ETextDirection,EJustification,EVerticalJustification);
void Clear();
};
}
#endif // __URDE_CTEXTEXECUTEBUFFER_HPP__

View File

View File

@ -0,0 +1,13 @@
#ifndef __URDE_CTEXTPARSER_HPP__
#define __URDE_CTEXTPARSER_HPP__
namespace urde
{
class CTextParser
{
};
}
#endif // __URDE_CTEXTPARSER_HPP__

View File

@ -0,0 +1,72 @@
#include "CTextRenderBuffer.hpp"
#include "CFontImageDef.hpp"
#include "Graphics/CGraphicsPalette.hpp"
namespace urde
{
CTextRenderBuffer::CTextRenderBuffer(EMode mode)
: x0_mode(mode)
{
for (int i=0 ; i<64 ; ++i)
{
x54_palettes[i].reset(new CGraphicsPalette(EPaletteFormat::RGB5A3, 4));
++x50_paletteCount;
}
}
void CTextRenderBuffer::SetPrimitive(const Primitive&, int)
{
}
CTextRenderBuffer::Primitive CTextRenderBuffer::GetPrimitive(int) const
{
}
void CTextRenderBuffer::GetOutStream()
{
}
void CTextRenderBuffer::SetMode(EMode mode)
{
x0_mode = mode;
}
void CTextRenderBuffer::VerifyBuffer()
{
if (x34_blob.empty())
x34_blob.resize(x44_blobSize);
}
void CTextRenderBuffer::Render(const zeus::CColor& col, float) const
{
}
void CTextRenderBuffer::AddImage(const zeus::CVector2i& vec, const CFontImageDef&)
{
}
void CTextRenderBuffer::AddCharacter(const zeus::CVector2i& vec, s16, const zeus::CColor&)
{
}
void CTextRenderBuffer::AddPaletteChange(const CGraphicsPalette& palette)
{
}
void CTextRenderBuffer::AddFontChange(const TToken<CRasterFont>& font)
{
}
int CTextRenderBuffer::GetMatchingPaletteIndex(const CGraphicsPalette& palette)
{
}
CGraphicsPalette* CTextRenderBuffer::GetNextAvailablePalette()
{
if (x254_nextPalette >= 64)
x254_nextPalette = 0;
return x54_palettes[x254_nextPalette++].get();
}
}

View File

@ -0,0 +1,58 @@
#ifndef __URDE_CTEXTRENDERBUFFER_HPP__
#define __URDE_CTEXTRENDERBUFFER_HPP__
#include "zeus/CColor.hpp"
#include "zeus/CVector2i.hpp"
#include "CToken.hpp"
#include "RetroTypes.hpp"
namespace urde
{
class CFontImageDef;
class CGraphicsPalette;
class CRasterFont;
class CTextRenderBuffer
{
public:
struct Primitive
{
u32 x0_;
u32 x4_;
u16 x8_;
u16 xa_;
u16 xc_;
u16 xe_;
};
enum class EMode
{
};
private:
EMode x0_mode;
std::vector<TToken<CRasterFont>> x4_fonts;
std::vector<CFontImageDef> x14_images;
std::vector<int> x24_primOffsets;
std::vector<char> x34_blob;
u32 x44_blobSize = 0;
u32 x50_paletteCount = 0;
std::unique_ptr<CGraphicsPalette> x54_palettes[64];
u32 x254_nextPalette = 0;
public:
CTextRenderBuffer(EMode mode);
void SetPrimitive(const Primitive&, int);
Primitive GetPrimitive(int) const;
void GetOutStream();
void SetMode(EMode mode);
void VerifyBuffer();
void Render(const zeus::CColor& col, float) const;
void AddImage(const zeus::CVector2i& vec, const CFontImageDef&);
void AddCharacter(const zeus::CVector2i& vec, s16, const zeus::CColor&);
void AddPaletteChange(const CGraphicsPalette& palette);
void AddFontChange(const TToken<CRasterFont>& font);
int GetMatchingPaletteIndex(const CGraphicsPalette& palette);
CGraphicsPalette* GetNextAvailablePalette();
};
}
#endif // __URDE_CTEXTRENDERBUFFER_HPP__

View File

View File

@ -0,0 +1,13 @@
#ifndef __URDE_CWORDBREAKTABLES_HPP__
#define __URDE_CWORDBREAKTABLES_HPP__
namespace urde
{
class CWordBreakTables
{
};
}
#endif // __URDE_CWORDBREAKTABLES_HPP__