GuiSys and FrontEnd work

This commit is contained in:
Jack Andersen 2016-12-30 14:51:51 -10:00
parent 20677700e0
commit db7c2aeaf2
20 changed files with 496 additions and 79 deletions

View File

@ -10,7 +10,7 @@ namespace urde
class CPersistentOptions
{
friend class CGameState;
bool x0_[98] = {};
u8 x0_[98] = {};
bool x68_[64] = {};
std::vector<std::pair<ResId, TEditorId>> xac_cinematicStates; /* (MLVL, Cinematic) */
u32 xbc_ = 0;
@ -50,6 +50,8 @@ public:
u32 GetLogScanCount() const { return xcc_logScanCount; }
void SetLogScanCount(u32 v) { xcc_logScanCount = v; }
void PutTo(CBitStreamWriter& w) const;
u8* GetNESState() { return x0_; }
};
/** Options tracked per game session */

View File

@ -27,7 +27,7 @@ CTextRenderBuffer* CGuiTextSupport::GetCurrentPageRenderBuffer() const
if (!x308_multipageFlag || x300_ <= x304_pageCounter)
return nullptr;
int idx = 0;
for (const CTextRenderBuffer& buf : x2f0_pageRenderBufs)
for (const CTextRenderBuffer& buf : x2ec_renderBufferPages)
if (idx++ == x304_pageCounter)
return const_cast<CTextRenderBuffer*>(&buf);
return nullptr;
@ -125,6 +125,7 @@ void CGuiTextSupport::Update(float dt)
void CGuiTextSupport::ClearRenderBuffer()
{
x60_renderBuf = std::experimental::nullopt;
x2ec_renderBufferPages.clear();
}
void CGuiTextSupport::CheckAndRebuildTextBuffer()
@ -149,10 +150,8 @@ void CGuiTextSupport::CheckAndRebuildTextBuffer()
bool CGuiTextSupport::CheckAndRebuildRenderBuffer()
{
if (x308_multipageFlag || x60_renderBuf)
{
if (!x308_multipageFlag || x300_)
return true;
}
CheckAndRebuildTextBuffer();
x2bc_assets = g_TextExecuteBuf->GetAssets();
@ -164,11 +163,32 @@ bool CGuiTextSupport::CheckAndRebuildRenderBuffer()
if (x308_multipageFlag)
{
zeus::CVector2i extent(x34_extentX, x38_extentY);
x2ec_renderBufferPages = g_TextExecuteBuf->BuildRenderBufferPages(extent);
}
else
{
x60_renderBuf.emplace(g_TextExecuteBuf->BuildRenderBuffer());
x2dc_oneBufBounds = x60_renderBuf->AccumulateTextBounds();
}
g_TextExecuteBuf->Clear();
Update(0.f);
return true;
}
const std::pair<zeus::CVector2i, zeus::CVector2i>& CGuiTextSupport::GetBounds()
{
CheckAndRebuildRenderBuffer();
return x2dc_oneBufBounds;
}
void CGuiTextSupport::AutoSetExtent()
{
auto& bounds = GetBounds();
x34_extentX = bounds.second.x;
x38_extentY = bounds.second.y;
}
void CGuiTextSupport::Render() const
{
if (CTextRenderBuffer* buf = GetCurrentPageRenderBuffer())

View File

@ -94,11 +94,9 @@ class CGuiTextSupport
std::experimental::optional<CTextRenderBuffer> x60_renderBuf;
std::vector<CToken> x2bc_assets;
TLockedToken<CRasterFont> x2cc_font;
std::pair<zeus::CVector2i, zeus::CVector2i> x2dc_oneBufBounds;
zeus::CVector2f x2dc_;
zeus::CVector2f x2e4_;
std::list<CTextRenderBuffer> x2f0_pageRenderBufs;
std::list<CTextRenderBuffer> x2ec_renderBufferPages;
u32 x300_ = 0;
u32 x304_pageCounter = 0;
bool x308_multipageFlag = false;
@ -119,6 +117,8 @@ public:
void ClearRenderBuffer();
void CheckAndRebuildTextBuffer();
bool CheckAndRebuildRenderBuffer();
const std::pair<zeus::CVector2i, zeus::CVector2i>& GetBounds();
void AutoSetExtent();
void Render() const;
void SetGeometryColor(const zeus::CColor& col);

View File

@ -7,6 +7,10 @@
namespace urde
{
void CInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
}
void CInstruction::GetAssets(std::vector<CToken>& assetsOut) const
{
}
@ -21,6 +25,11 @@ void CColorInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf)
state.SetColor(x4_cType, x8_color);
}
void CColorInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
Invoke(state, buf);
}
void CColorOverrideInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
state.x64_colorOverrides[x4_overrideIdx] = true;
@ -28,6 +37,11 @@ void CColorOverrideInstruction::Invoke(CFontRenderState& state, CTextRenderBuffe
state.x0_drawStrOpts.x4_colors[x4_overrideIdx] = convCol;
}
void CColorOverrideInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
Invoke(state, buf);
}
void CFontInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
buf->AddFontChange(x4_font);
@ -35,6 +49,11 @@ void CFontInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) c
state.RefreshPalette();
}
void CFontInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
Invoke(state, buf);
}
void CFontInstruction::GetAssets(std::vector<CToken>& assetsOut) const
{
assetsOut.push_back(x4_font);
@ -50,6 +69,11 @@ void CLineExtraSpaceInstruction::Invoke(CFontRenderState& state, CTextRenderBuff
state.x78_extraLineSpace = x4_extraSpace;
}
void CLineExtraSpaceInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
Invoke(state, buf);
}
void CLineInstruction::TestLargestFont(s32 monoW, s32 monoH, s32 baseline)
{
if (!x18_largestBaseline)
@ -154,26 +178,52 @@ void CLineInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) c
state.xdc_currentLineInst = this;
}
void CLineInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
if (!state.xdc_currentLineInst)
Invoke(state, buf);
}
void CLineSpacingInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
state.x74_lineSpacing = x4_lineSpacing;
}
void CLineSpacingInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
Invoke(state, buf);
}
void CPopStateInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
state.PopState();
}
void CPopStateInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
Invoke(state, buf);
}
void CPushStateInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
state.PushState();
}
void CPushStateInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
Invoke(state, buf);
}
void CRemoveColorOverrideInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
state.x64_colorOverrides[x4_idx] = false;
}
void CRemoveColorOverrideInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
Invoke(state, buf);
}
void CImageInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
if (x4_image.IsLoaded() && x4_image.x4_texs.size())
@ -193,6 +243,17 @@ void CImageInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf)
}
}
void CImageInstruction::GetAssets(std::vector<CToken>& assetsOut) const
{
for (const CToken& tok : x4_image.x4_texs)
assetsOut.push_back(tok);
}
size_t CImageInstruction::GetAssetCount() const
{
return x4_image.x4_texs.size();
}
void CTextInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
int xOut, yOut;
@ -252,6 +313,11 @@ void CBlockInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf)
SetupPositionLTR(state);
}
void CBlockInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
Invoke(state, buf);
}
void CWordInstruction::InvokeLTR(CFontRenderState& state) const
{
CRasterFont* font = state.x48_font.GetObj();
@ -291,4 +357,9 @@ void CWordInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) c
InvokeLTR(state);
}
void CWordInstruction::PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const
{
state.x108_lineInitialized = false;
}
}

View File

@ -17,6 +17,7 @@ class CInstruction
public:
virtual ~CInstruction() = default;
virtual void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const=0;
virtual void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
virtual void GetAssets(std::vector<CToken>& assetsOut) const;
virtual size_t GetAssetCount() const;
};
@ -29,6 +30,7 @@ public:
CColorInstruction(EColorType tp, const CTextColor& color)
: x4_cType(tp), x8_color(color) {}
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
};
class CColorOverrideInstruction : public CInstruction
@ -39,6 +41,7 @@ public:
CColorOverrideInstruction(int idx, const CTextColor& color)
: x4_overrideIdx(idx), x8_color(color) {}
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
};
class CFontInstruction : public CInstruction
@ -47,6 +50,7 @@ class CFontInstruction : public CInstruction
public:
CFontInstruction(const TToken<CRasterFont>& font) : x4_font(font) {}
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void GetAssets(std::vector<CToken>& assetsOut) const;
size_t GetAssetCount() const;
};
@ -57,6 +61,7 @@ class CLineExtraSpaceInstruction : public CInstruction
public:
CLineExtraSpaceInstruction(s32 extraSpace) : x4_extraSpace(extraSpace) {}
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
};
class CLineInstruction : public CInstruction
@ -80,6 +85,7 @@ public:
void TestLargestFont(s32 monoW, s32 monoH, s32 baseline);
void InvokeLTR(CFontRenderState& state) const;
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
};
class CLineSpacingInstruction : public CInstruction
@ -88,18 +94,21 @@ class CLineSpacingInstruction : public CInstruction
public:
CLineSpacingInstruction(float spacing) : x4_lineSpacing(spacing) {}
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
};
class CPopStateInstruction : public CInstruction
{
public:
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
};
class CPushStateInstruction : public CInstruction
{
public:
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
};
class CRemoveColorOverrideInstruction : public CInstruction
@ -108,6 +117,7 @@ class CRemoveColorOverrideInstruction : public CInstruction
public:
CRemoveColorOverrideInstruction(int idx) : x4_idx(idx) {}
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
};
class CImageInstruction : public CInstruction
@ -116,6 +126,8 @@ class CImageInstruction : public CInstruction
public:
CImageInstruction(const CFontImageDef& image) : x4_image(image) {}
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void GetAssets(std::vector<CToken>& assetsOut) const;
size_t GetAssetCount() const;
};
class CTextInstruction : public CInstruction
@ -155,6 +167,7 @@ public:
void TestLargestFont(s32 monoW, s32 monoH, s32 baseline);
void SetupPositionLTR(CFontRenderState& state) const;
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
};
class CWordInstruction : public CInstruction
@ -162,6 +175,7 @@ class CWordInstruction : public CInstruction
public:
void InvokeLTR(CFontRenderState& state) const;
void Invoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
void PageInvoke(CFontRenderState& state, CTextRenderBuffer* buf) const;
};
}

View File

@ -11,7 +11,7 @@
namespace urde
{
CTextRenderBuffer CTextExecuteBuffer::CreateTextRenderBuffer() const
CTextRenderBuffer CTextExecuteBuffer::BuildRenderBuffer() const
{
CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally);
@ -32,6 +32,92 @@ CTextRenderBuffer CTextExecuteBuffer::CreateTextRenderBuffer() const
return ret;
}
CTextRenderBuffer CTextExecuteBuffer::BuildRenderBufferPage(InstList::const_iterator start,
InstList::const_iterator pgStart,
InstList::const_iterator pgEnd) const
{
CTextRenderBuffer ret(CTextRenderBuffer::EMode::AllocTally);
{
CFontRenderState rendState;
for (auto it = start ; it != pgStart ; ++it)
{
const std::shared_ptr<CInstruction>& inst = *it;
inst->PageInvoke(rendState, &ret);
}
for (auto it = pgStart ; it != pgEnd ; ++it)
{
const std::shared_ptr<CInstruction>& inst = *it;
inst->Invoke(rendState, &ret);
}
}
ret.SetMode(CTextRenderBuffer::EMode::BufferFill);
{
CFontRenderState rendState;
for (auto it = start ; it != pgStart ; ++it)
{
const std::shared_ptr<CInstruction>& inst = *it;
inst->PageInvoke(rendState, &ret);
}
for (auto it = pgStart ; it != pgEnd ; ++it)
{
const std::shared_ptr<CInstruction>& inst = *it;
inst->Invoke(rendState, &ret);
}
}
return ret;
}
std::list<CTextRenderBuffer> CTextExecuteBuffer::BuildRenderBufferPages(const zeus::CVector2i& extent) const
{
std::list<CTextRenderBuffer> ret;
for (auto it = x0_instList.begin() ; it != x0_instList.end() ;)
{
const std::shared_ptr<CInstruction>& inst = *it;
CTextRenderBuffer rbuf(CTextRenderBuffer::EMode::AllocTally);
{
CFontRenderState rstate;
for (auto it2 = x0_instList.begin() ; it2 != x0_instList.end() ;)
{
const std::shared_ptr<CInstruction>& inst2 = *it2;
inst2->Invoke(rstate, &rbuf);
}
}
rbuf.SetMode(CTextRenderBuffer::EMode::BufferFill);
InstList::const_iterator pageEnd = it;
{
CFontRenderState rstate;
for (auto it2 = x0_instList.begin() ; it2 != x0_instList.end() ;)
{
const std::shared_ptr<CInstruction>& inst2 = *it2;
if (it2 != it)
{
inst2->PageInvoke(rstate, &rbuf);
}
else
{
inst2->Invoke(rstate, &rbuf);
if (!rbuf.HasSpaceAvailable(zeus::CVector2i{}, extent))
break;
++pageEnd;
}
}
}
ret.push_back(BuildRenderBufferPage(x0_instList.cbegin(), it, pageEnd));
it = pageEnd;
}
return ret;
}
std::vector<CToken> CTextExecuteBuffer::GetAssets() const
{
size_t totalAssets = 0;

View File

@ -17,8 +17,9 @@ class CTextExecuteBuffer
{
friend class CGuiTextSupport;
friend class CTextRenderBufferPages;
using InstList = std::list<std::shared_ptr<CInstruction>>;
std::list<std::shared_ptr<CInstruction>> x0_instList;
InstList x0_instList;
u32 x14_ = 0;
CSaveableState x18_textState;
CBlockInstruction* xa0_curBlock = nullptr;
@ -39,7 +40,11 @@ public:
xa8_curWordIt = x0_instList.begin();
}
CTextRenderBuffer CreateTextRenderBuffer() const;
CTextRenderBuffer BuildRenderBuffer() const;
CTextRenderBuffer BuildRenderBufferPage(InstList::const_iterator start,
InstList::const_iterator pgStart,
InstList::const_iterator pgEnd) const;
std::list<CTextRenderBuffer> BuildRenderBufferPages(const zeus::CVector2i& extent) const;
std::vector<CToken> GetAssets() const;
void AddString(const wchar_t* str, int len);
void AddStringFragment(const wchar_t* str, int len);

View File

@ -36,6 +36,30 @@ void CTextRenderBuffer::BooCharacterInstance::SetMetrics(const CGlyph& glyph,
m_uv[3].assign(glyph.GetEndU(), glyph.GetEndV());
}
CTextRenderBuffer::BooImage::BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset)
: m_imageDef(imgDef)
{
zeus::CVector2f imgSize;
if (imgDef.x4_texs.size())
{
const CTexture& tex = *imgDef.x4_texs[0].GetObj();
imgSize.assign(tex.GetWidth() * imgDef.x14_pointsPerTexel.x,
tex.GetHeight() * imgDef.x14_pointsPerTexel.y);
}
m_imageData.m_pos[0].assign(offset.x, 0.f, offset.y);
m_imageData.m_uv[0].assign(0.f, 0.f);
m_imageData.m_pos[1].assign(offset.x + imgSize.x, 0.f, offset.y);
m_imageData.m_uv[1].assign(1.f, 0.f);
m_imageData.m_pos[2].assign(offset.x, 0.f, offset.y + imgSize.y);
m_imageData.m_uv[2].assign(0.f, 1.f);
m_imageData.m_pos[3].assign(offset.x + imgSize.x, 0.f, offset.y + imgSize.y);
m_imageData.m_uv[3].assign(1.f, 1.f);
}
void CTextRenderBuffer::BooPrimitiveMark::SetOpacity(CTextRenderBuffer& rb, float opacity)
{
switch (m_cmd)
@ -176,7 +200,7 @@ void CTextRenderBuffer::Render(const zeus::CColor& col, float time) const
if (img.m_dirty)
{
img.m_instBuf->load(&img.m_imageData, sizeof(BooImageInstance));
((BooImage&)img).m_dirty = false;
const_cast<BooImage&>(img).m_dirty = false;
}
int idx = int(img.m_imageDef.x0_fps * time) % img.m_dataBinding.size();
CGraphics::SetShaderDataBinding(img.m_dataBinding[idx]);
@ -189,7 +213,7 @@ void CTextRenderBuffer::AddImage(const zeus::CVector2i& offset, const CFontImage
if (x0_mode == EMode::AllocTally)
m_primitiveMarks.push_back({Command::ImageRender, m_imagesCount++, 0});
else
m_images.push_back({image});
m_images.push_back({image, offset});
}
void CTextRenderBuffer::AddCharacter(const zeus::CVector2i& offset, wchar_t ch,
@ -233,41 +257,45 @@ void CTextRenderBuffer::AddFontChange(const TToken<CRasterFont>& font)
m_fontCharacters.push_back({font});
}
CTextRenderBufferPages::CTextRenderBufferPages(CTextExecuteBuffer& buf, const zeus::CVector2i& extent)
bool CTextRenderBuffer::HasSpaceAvailable(const zeus::CVector2i& origin,
const zeus::CVector2i& extent) const
{
for (auto it = buf.x0_instList.begin() ; it != buf.x0_instList.end() ;)
{
std::shared_ptr<CInstruction>& inst = *it;
CTextRenderBuffer rbuf(CTextRenderBuffer::EMode::AllocTally);
std::pair<zeus::CVector2i, zeus::CVector2i> bounds = AccumulateTextBounds();
if (bounds.first.x > bounds.second.x)
return true;
if (0 < origin.y)
return false;
zeus::CVector2i size = bounds.second - bounds.first;
return size.y <= extent.y;
}
std::pair<zeus::CVector2i, zeus::CVector2i> CTextRenderBuffer::AccumulateTextBounds() const
{
CFontRenderState rstate;
for (auto it2 = buf.x0_instList.begin() ; it2 != buf.x0_instList.end() ;)
std::pair<zeus::CVector2i, zeus::CVector2i> ret = std::make_pair(zeus::CVector2i{INT_MAX, INT_MAX},
zeus::CVector2i{INT_MIN, INT_MIN});
for (const BooFontCharacters& chars : m_fontCharacters)
{
std::shared_ptr<CInstruction>& inst2 = *it2;
inst2->Invoke(rstate, &rbuf);
for (const BooCharacterInstance& charInst : chars.m_charData)
{
ret.first.x = std::min(ret.first.x, int(charInst.m_pos[0].x));
ret.first.y = std::min(ret.first.y, int(charInst.m_pos[0].z));
ret.second.x = std::max(ret.second.x, int(charInst.m_pos[3].x));
ret.second.y = std::max(ret.second.y, int(charInst.m_pos[3].z));
}
}
rbuf.SetMode(CTextRenderBuffer::EMode::BufferFill);
for (const BooImage& imgs : m_images)
{
ret.first.x = std::min(ret.first.x, int(imgs.m_imageData.m_pos[0].x));
ret.first.y = std::min(ret.first.y, int(imgs.m_imageData.m_pos[0].z));
ret.second.x = std::max(ret.second.x, int(imgs.m_imageData.m_pos[3].x));
ret.second.y = std::max(ret.second.y, int(imgs.m_imageData.m_pos[3].z));
}
/* TODO: Finish */
{
CFontRenderState rstate;
for (auto it2 = buf.x0_instList.begin() ; it2 != buf.x0_instList.end() ;)
{
std::shared_ptr<CInstruction>& inst2 = *it2;
if (it2 != it)
{
}
else
{
}
}
}
}
return ret;
}
}

View File

@ -31,6 +31,7 @@ public:
FontChange,
PaletteChange
};
#if 0
struct Primitive
{
CTextColor x0_color1;
@ -40,6 +41,7 @@ public:
wchar_t xc_glyph;
u8 xe_imageIndex;
};
#endif
enum class EMode
{
AllocTally,
@ -55,6 +57,7 @@ private:
std::vector<char> x34_bytecode;
u32 x44_blobSize = 0;
u32 x48_curBytecodeOffset = 0;
u8 x4c_activeFont;
u32 x50_paletteCount = 0;
std::array<std::unique_ptr<CGraphicsPalette>, 64> x54_palettes;
u32 x254_nextPalette = 0;
@ -106,10 +109,7 @@ private:
std::vector<boo::IShaderDataBinding*> m_dataBinding;
BooImageInstance m_imageData;
bool m_dirty = true;
BooImage(const CFontImageDef& imgDef)
: m_imageDef(imgDef)
{
}
BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset);
};
std::vector<BooImage> m_images;
@ -153,12 +153,9 @@ public:
void AddCharacter(const zeus::CVector2i& offset, wchar_t ch, const zeus::CColor& color);
void AddPaletteChange(const zeus::CColor& main, const zeus::CColor& outline);
void AddFontChange(const TToken<CRasterFont>& font);
};
class CTextRenderBufferPages
{
public:
CTextRenderBufferPages(CTextExecuteBuffer&, const zeus::CVector2i&);
bool HasSpaceAvailable(const zeus::CVector2i& origin, const zeus::CVector2i& extent) const;
std::pair<zeus::CVector2i, zeus::CVector2i> AccumulateTextBounds() const;
};
}

View File

@ -191,7 +191,8 @@ CFrontEndUI::SNewFileSelectFrame::ProcessUserInput(const CFinalInput& input)
void CFrontEndUI::SNewFileSelectFrame::Draw() const
{
if (x1c_loadedFrame && x10c_inputEnable)
x1c_loadedFrame->Draw(CGuiWidgetDrawParms::Default);
}
void CFrontEndUI::SNewFileSelectFrame::HandleActiveChange(CGuiTableGroup* active)
@ -485,6 +486,36 @@ CFrontEndUI::SGBASupportFrame::SGBASupportFrame()
x18_gbaLink = g_SimplePool->GetObj("FRME_GBALink");
}
void CFrontEndUI::SGBASupportFrame::SGBALinkFrame::SetUIText(EUIType tp)
{
}
void CFrontEndUI::SGBASupportFrame::SGBALinkFrame::ProcessUserInput(const CFinalInput &input, bool sui)
{
}
void CFrontEndUI::SGBASupportFrame::SGBALinkFrame::Update(float dt)
{
}
void CFrontEndUI::SGBASupportFrame::SGBALinkFrame::FinishedLoading()
{
}
void CFrontEndUI::SGBASupportFrame::SGBALinkFrame::Draw()
{
}
CFrontEndUI::SGBASupportFrame::SGBALinkFrame::SGBALinkFrame(const CGuiFrame* linkFrame, CGBASupport* support, bool)
{
}
void CFrontEndUI::SGBASupportFrame::FinishedLoading()
{
x28_tablegroup_options = static_cast<CGuiTableGroup*>(x24_loadedFrame->FindWidget("tablegroup_options"));
@ -550,9 +581,14 @@ CFrontEndUI::SGBASupportFrame::ProcessUserInput(const CFinalInput& input, CSaveU
}
void CFrontEndUI::SGBASupportFrame::Draw() const
{
if (!x38_)
return;
if (x0_gbaLinkFrame)
{
}
}
void CFrontEndUI::SGBASupportFrame::DoOptionsCancel(CGuiTableGroup* caller)
{
@ -688,14 +724,14 @@ void CFrontEndUI::SNesEmulatorFrame::SetMode(EMode mode)
case EMode::Emulator:
x8_quitScreen.reset();
break;
case EMode::QuitNESMetroid:
x8_quitScreen = std::make_unique<CQuitScreen>(EQuitType::QuitNESMetroid);
case EMode::SaveProgress:
x8_quitScreen = std::make_unique<CQuitScreen>(EQuitType::SaveProgress);
break;
case EMode::ContinuePlaying:
x8_quitScreen = std::make_unique<CQuitScreen>(EQuitType::ContinuePlaying);
break;
case EMode::SaveProgress:
x8_quitScreen = std::make_unique<CQuitScreen>(EQuitType::SaveProgress);
case EMode::QuitNESMetroid:
x8_quitScreen = std::make_unique<CQuitScreen>(EQuitType::QuitNESMetroid);
break;
default: break;
}
@ -717,20 +753,20 @@ void CFrontEndUI::SNesEmulatorFrame::ProcessUserInput(const CFinalInput& input,
case EMode::Emulator:
x4_nesEmu->ProcessUserInput(input, 4);
if (input.ControllerIdx() == 0 && input.PL())
SetMode(EMode::SaveProgress);
SetMode(EMode::QuitNESMetroid);
break;
case EMode::QuitNESMetroid:
case EMode::ContinuePlaying:
case EMode::SaveProgress:
case EMode::ContinuePlaying:
case EMode::QuitNESMetroid:
x8_quitScreen->ProcessUserInput(input);
break;
default: break;
}
}
bool CFrontEndUI::SNesEmulatorFrame::DoUpdateWithSaveUI(float dt, CSaveUI* saveUi)
bool CFrontEndUI::SNesEmulatorFrame::Update(float dt, CSaveUI* saveUi)
{
bool flag = (saveUi && saveUi->GetUIType() != CSaveUI::EUIType::SaveProgress) ? false : true;
bool doUpdate = (saveUi && saveUi->GetUIType() != CSaveUI::EUIType::SaveProgress) ? false : true;
x10_remTime = std::max(x10_remTime - dt, 0.f);
zeus::CColor geomCol(zeus::CColor::skWhite);
@ -738,14 +774,104 @@ bool CFrontEndUI::SNesEmulatorFrame::DoUpdateWithSaveUI(float dt, CSaveUI* saveU
xc_textSupport->SetGeometryColor(geomCol);
if (xc_textSupport->GetIsTextSupportFinishedLoading())
{
xc_textSupport->AutoSetExtent();
xc_textSupport->ClearRenderBuffer();
}
if (!doUpdate)
return false;
switch (x0_mode)
{
case EMode::Emulator:
{
x4_nesEmu->Update();
if (!x4_nesEmu->WantsQuit())
x14_emulationSuspended = false;
if (x4_nesEmu->WantsQuit() && !x14_emulationSuspended)
{
x14_emulationSuspended = true;
if (saveUi && !saveUi->IsSavingDisabled())
{
SetMode(EMode::SaveProgress);
break;
}
SetMode(EMode::ContinuePlaying);
break;
}
if (x4_nesEmu->WantsLoad() && saveUi)
x4_nesEmu->LoadState(g_GameState->SystemOptions().GetNESState());
break;
}
case EMode::SaveProgress:
{
if (saveUi)
{
EQuitAction action = x8_quitScreen->Update(dt);
if (action == EQuitAction::Yes)
{
memmove(g_GameState->SystemOptions().GetNESState(), x4_nesEmu->GetSaveState(), 18);
saveUi->SaveNESState();
SetMode(EMode::ContinuePlaying);
}
else if (action == EQuitAction::No)
SetMode(EMode::ContinuePlaying);
}
else
SetMode(EMode::ContinuePlaying);
break;
}
case EMode::ContinuePlaying:
{
EQuitAction action = x8_quitScreen->Update(dt);
if (action == EQuitAction::Yes)
SetMode(EMode::Emulator);
else if (action == EQuitAction::No)
return true;
break;
}
case EMode::QuitNESMetroid:
{
EQuitAction action = x8_quitScreen->Update(dt);
if (action == EQuitAction::Yes)
return true;
else if (action == EQuitAction::No)
SetMode(EMode::Emulator);
break;
}
default: break;
}
return false;
}
void CFrontEndUI::SNesEmulatorFrame::Draw(CSaveUI* saveUi) const
{
zeus::CColor mulColor = zeus::CColor::skWhite;
bool doDraw = (saveUi && saveUi->GetUIType() != CSaveUI::EUIType::SaveProgress) ? false : true;
if (doDraw)
mulColor = zeus::CColor::skBlack;
else if (x8_quitScreen)
mulColor = zeus::CColor{0.376470f, 0.376470f, 0.376470f, 1.f};
x4_nesEmu->Draw(mulColor, x15_enableFiltering);
if (!doDraw && x8_quitScreen)
x8_quitScreen->Draw();
if (x10_remTime >= 7.5f)
return;
if (x10_remTime <= 0.f)
return;
if (xc_textSupport->GetIsTextSupportFinishedLoading())
{
CGraphics::SetModelMatrix(zeus::CTransform::Translate(-280.f, 0.f, -160.f));
xc_textSupport->Render();
}
}
CFrontEndUI::SOptionsFrontEndFrame::SOptionsFrontEndFrame()
@ -1306,7 +1432,7 @@ CIOWin::EMessageReturn CFrontEndUI::Update(float dt, CArchitectureQueue& queue)
if (xec_emuFrme)
{
if (xec_emuFrme->DoUpdateWithSaveUI(dt, xdc_saveUI.get()))
if (xec_emuFrme->Update(dt, xdc_saveUI.get()))
{
xec_emuFrme.reset();
xf4_curAudio->StartMixing();

View File

@ -171,6 +171,28 @@ public:
struct SGBASupportFrame
{
struct SGBALinkFrame
{
enum class EUIType
{
Zero,
One,
Two,
Three,
Four,
Five,
Six,
Seven
};
void SetUIText(EUIType tp);
void ProcessUserInput(const CFinalInput &input, bool sui);
void Update(float dt);
void FinishedLoading();
void Draw();
SGBALinkFrame(const CGuiFrame* linkFrame, CGBASupport* support, bool);
};
enum class EAction
{
Zero,
@ -178,7 +200,7 @@ public:
Two
};
u32 x0_ = 0;
std::unique_ptr<SGBALinkFrame> x0_gbaLinkFrame;
std::unique_ptr<CGBASupport> x4_gbaSupport;
TLockedToken<CGuiFrame> xc_gbaScreen;
TLockedToken<CGuiFrame> x18_gbaLink;
@ -236,9 +258,9 @@ public:
enum class EMode
{
Emulator,
QuitNESMetroid,
SaveProgress,
ContinuePlaying,
SaveProgress
QuitNESMetroid
};
EMode x0_mode = EMode::Emulator;
@ -246,13 +268,13 @@ public:
std::unique_ptr<CQuitScreen> x8_quitScreen;
std::unique_ptr<CGuiTextSupport> xc_textSupport;
float x10_remTime = 8.f;
bool x14_ = false;
bool x15_ = true;
bool x14_emulationSuspended = false;
bool x15_enableFiltering = true;
SNesEmulatorFrame();
void SetMode(EMode mode);
void ProcessUserInput(const CFinalInput& input, CSaveUI* sui);
bool DoUpdateWithSaveUI(float dt, CSaveUI* saveUi);
bool Update(float dt, CSaveUI* saveUi);
void Draw(CSaveUI* saveUi) const;
};

View File

@ -768,6 +768,11 @@ void CMemoryCardDriver::BuildNewFileSlot(u32 saveIdx)
g_GameState->SystemOptions().SetPlayerHasFusion(fusionBackup);
}
void CMemoryCardDriver::EraseFileSlot(u32 saveIdx)
{
xe4_fileSlots[saveIdx].reset();
}
void CMemoryCardDriver::BuildExistingFileSlot(u32 saveIdx)
{
g_GameState->SetFileIdx(saveIdx);

View File

@ -184,6 +184,7 @@ public:
void ClearFileInfo() { x198_fileInfo.reset(); }
void BuildNewFileSlot(u32 saveIdx);
void EraseFileSlot(u32 saveIdx);
void BuildExistingFileSlot(u32 saveIdx);
void InitializeFileInfo();
void WriteBackupBuf();

View File

@ -1,4 +1,6 @@
#include "CNESEmulator.hpp"
#include "CGameState.hpp"
#include <string.h>
namespace urde
{
@ -10,5 +12,21 @@ void CNESEmulator::ProcessUserInput(const CFinalInput& input, int)
}
void CNESEmulator::Update()
{
}
void CNESEmulator::Draw(const zeus::CColor& mulColor, bool filtering)
{
}
void CNESEmulator::LoadState(const u8* state)
{
memmove(x39_loadState, state, 18);
x38_stateLoaded = true;
}
}
}

View File

@ -1,6 +1,8 @@
#ifndef __URDE_CNESEMULATOR_HPP__
#define __URDE_CNESEMULATOR_HPP__
#include "RetroTypes.hpp"
namespace urde
{
class CFinalInput;
@ -10,8 +12,19 @@ namespace MP1
class CNESEmulator
{
bool x20_wantsQuit = false;
u8 x21_saveState[18];
bool x34_wantsLoad = false;
bool x38_stateLoaded = false;
u8 x39_loadState[18];
public:
void ProcessUserInput(const CFinalInput& input, int);
void Update();
void Draw(const zeus::CColor& mulColor, bool filtering);
void LoadState(const u8* state);
const u8* GetSaveState() const { return x21_saveState; }
bool WantsQuit() const { return x20_wantsQuit; }
bool WantsLoad() const { return x34_wantsLoad; }
};
}

View File

@ -80,7 +80,7 @@ void CQuitScreen::DoAdvance(CGuiTableGroup* caller)
}
}
EQuitAction CQuitScreen::Update()
EQuitAction CQuitScreen::Update(float dt)
{
if (!x10_loadedFrame && x4_frame.IsLoaded())
FinishedLoading();

View File

@ -44,7 +44,7 @@ public:
void FinishedLoading();
void DoSelectionChange(CGuiTableGroup* caller);
void DoAdvance(CGuiTableGroup* caller);
EQuitAction Update();
EQuitAction Update(float dt);
void Draw();
void ProcessUserInput(const CFinalInput& input);
CQuitScreen(EQuitType pos);

View File

@ -19,7 +19,7 @@ using EError = CMemoryCardDriver::EError;
void CSaveUI::ResetCardDriver()
{
x92_ = false;
x92_savingDisabled = false;
x6c_cardDriver.reset();
bool importState = (x0_saveCtx == ESaveContext::FrontEnd && !x90_needsDriverReset);
x6c_cardDriver = ConstructCardDriver(importState);
@ -502,7 +502,7 @@ void CSaveUI::DoAdvance(CGuiTableGroup* caller)
else
{
x6c_cardDriver->ClearError();
x92_ = true;
x92_savingDisabled = true;
sfx = x84_navConfirmSfx;
}
}
@ -615,9 +615,9 @@ void CSaveUI::StartGame(int idx)
x80_iowRet = CIOWin::EMessageReturn::Exit;
}
void CSaveUI::EraseGame(int idx)
void CSaveUI::SaveNESState()
{
if (!x92_)
if (!x92_savingDisabled)
{
x90_needsDriverReset = true;
x8_serial = x6c_cardDriver->x28_cardSerial;
@ -625,6 +625,13 @@ void CSaveUI::EraseGame(int idx)
}
}
void CSaveUI::EraseGame(int idx)
{
x6c_cardDriver->EraseFileSlot(idx);
x90_needsDriverReset = true;
x6c_cardDriver->StartFileCreateTransactional();
}
const CGameState::GameFileStateInfo* CSaveUI::GetGameData(int idx) const
{
return x6c_cardDriver->GetGameFileStateInfo(idx);

View File

@ -87,7 +87,7 @@ private:
u32 x8c_navBackSfx = 1459;
bool x90_needsDriverReset = false;
bool x91_uiTextDirty = false;
bool x92_ = false;
bool x92_savingDisabled = false;
bool x93_inGame;
void ResetCardDriver();
@ -108,9 +108,11 @@ public:
void ProcessUserInput(const CFinalInput& input);
void StartGame(int idx);
void SaveNESState();
void EraseGame(int idx);
const CGameState::GameFileStateInfo* GetGameData(int idx) const;
EUIType GetUIType() const { return x10_uiType; }
bool IsSavingDisabled() const { return x92_savingDisabled; }
CSaveUI(ESaveContext saveCtx, u64 serial);
};

@ -1 +1 @@
Subproject commit ee942606b6b6f72f48a1e6c761b530500f0f2841
Subproject commit e961af19ee4d69ef8e7f9cb912058b8397027973