Work on CSaveUI and CSfxManager

This commit is contained in:
Jack Andersen 2016-12-28 19:53:00 -10:00
parent e05d69376e
commit b3cae0d4d5
17 changed files with 489 additions and 184 deletions

View File

@ -23,8 +23,8 @@ public:
float x1c_distComp;
u32 x20_flags;
u16 x24_sfxId;
u8 x26_maxVol;
u8 x27_minVol;
float x26_maxVol;
float x27_minVol;
u8 x28_extra[2];
};
CAudioSys(boo::IAudioVoiceEngine* voiceEngine,

View File

@ -3,7 +3,6 @@ set(AUDIO_SOURCES
CAudioStateWin.hpp CAudioStateWin.cpp
CAudioGroupSet.hpp CAudioGroupSet.cpp
CSfxManager.hpp CSfxManager.cpp
CSfxHandle.hpp CSfxHandle.cpp
CStaticAudioPlayer.hpp CStaticAudioPlayer.cpp
g721.c g721.h)

View File

@ -1,29 +0,0 @@
#include "CSfxHandle.hpp"
namespace urde
{
u32 CSfxHandle::mRefCount = 0;
CSfxHandle::CSfxHandle(u32 idx)
{
x0_index = (idx & 0xFFF) | ((++mRefCount) << 14);
}
void CSfxHandle::operator =(const CSfxHandle& other)
{
if (x0_index == other.x0_index)
return;
x0_index = other.x0_index;
}
bool CSfxHandle::operator !=(const CSfxHandle& other) const
{
return x0_index != other.x0_index;
}
bool CSfxHandle::operator ==(const CSfxHandle& other) const
{
return x0_index == other.x0_index;
}
}

View File

@ -1,27 +0,0 @@
#ifndef __URDE_CSFXHANDLE_HPP__
#define __URDE_CSFXHANDLE_HPP__
#include "RetroTypes.hpp"
namespace urde
{
class CSfxHandle
{
static u32 mRefCount;
u32 x0_index = 0;
public:
CSfxHandle() = default;
CSfxHandle(const CSfxHandle&) = default;
CSfxHandle(u32 idx);
void operator =(const CSfxHandle& other);
bool operator !=(const CSfxHandle& other) const;
bool operator ==(const CSfxHandle& other) const;
u32 GetIndex() const { return x0_index; }
static CSfxHandle NullHandle() { return {}; }
};
}
#endif // __URDE_CSFXHANDLE_HPP__

View File

@ -4,6 +4,120 @@ namespace urde
{
std::vector<s16>* CSfxManager::mpSfxTranslationTable = nullptr;
CSfxManager::CSfxChannel CSfxManager::m_channels[4];
rstl::reserved_vector<std::shared_ptr<CSfxManager::CSfxEmitterWrapper>, 128> CSfxManager::m_emitterWrapperPool;
rstl::reserved_vector<std::shared_ptr<CSfxManager::CSfxWrapper>, 128> CSfxManager::m_wrapperPool;
CSfxManager::ESfxChannels CSfxManager::m_currentChannel;
bool CSfxManager::m_doUpdate;
void* CSfxManager::m_usedSounds;
bool CSfxManager::m_muted;
bool CSfxManager::m_auxProcessingEnabled;
float CSfxManager::m_reverbAmount = 1.f;
u16 CSfxManager::kMaxPriority;
u16 CSfxManager::kMedPriority;
u16 CSfxManager::kInternalInvalidSfxId;
u32 CSfxManager::kAllAreas;
bool CSfxManager::CSfxWrapper::IsPlaying() const
{
if (CBaseSfxWrapper::IsPlaying() && x1c_voiceHandle)
return x1c_voiceHandle->state() == amuse::VoiceState::Playing;
return false;
}
void CSfxManager::CSfxWrapper::Play()
{
x1c_voiceHandle = CAudioSys::GetAmuseEngine().fxStart(x18_sfxId, x20_vol, x22_pan);
if (x1c_voiceHandle)
{
if (CSfxManager::IsAuxProcessingEnabled() && UseAcoustics())
x1c_voiceHandle->setReverbVol(m_reverbAmount);
SetPlaying(true);
}
x24_ready = false;
}
void CSfxManager::CSfxWrapper::Stop()
{
if (x1c_voiceHandle)
{
x1c_voiceHandle->keyOff();
SetPlaying(false);
x1c_voiceHandle.reset();
}
}
bool CSfxManager::CSfxWrapper::Ready()
{
if (IsLooped())
return true;
return x24_ready;
}
bool CSfxManager::CSfxEmitterWrapper::IsPlaying() const
{
if (IsLooped())
return CBaseSfxWrapper::IsPlaying();
if (CBaseSfxWrapper::IsPlaying() && x50_emitterHandle)
return x50_emitterHandle->getVoice()->state() == amuse::VoiceState::Playing;
return false;
}
void CSfxManager::CSfxEmitterWrapper::Play()
{
if (CSfxManager::IsAuxProcessingEnabled() && UseAcoustics())
x1a_reverb = m_reverbAmount;
else
x1a_reverb = 0.f;
x50_emitterHandle = CAudioSys::GetAmuseEngine().addEmitter(
x24_parmData.x0_pos.v, x24_parmData.xc_dir.v,
x24_parmData.x18_maxDist, x24_parmData.x1c_distComp,
x24_parmData.x24_sfxId, x24_parmData.x27_minVol,
x24_parmData.x26_maxVol);
if (x50_emitterHandle)
SetPlaying(true);
x54_ready = false;
}
void CSfxManager::CSfxEmitterWrapper::Stop()
{
if (x50_emitterHandle)
{
x50_emitterHandle->getVoice()->keyOff();
SetPlaying(false);
x50_emitterHandle.reset();
}
}
bool CSfxManager::CSfxEmitterWrapper::Ready()
{
if (IsLooped())
return true;
return x54_ready;
}
CSfxManager::ESfxAudibility CSfxManager::CSfxEmitterWrapper::GetAudible(const zeus::CVector3f& vec)
{
float magSq = (x24_parmData.x0_pos - vec).magSquared();
float maxDist = x24_parmData.x18_maxDist * x24_parmData.x18_maxDist;
if (magSq < maxDist * 0.25f)
return ESfxAudibility::Aud3;
else if (magSq < maxDist * 0.5f)
return ESfxAudibility::Aud2;
else if (magSq < maxDist)
return ESfxAudibility::Aud1;
return ESfxAudibility::Aud0;
}
CSfxManager::CSfxManager()
{
m_emitterWrapperPool.resize(128);
m_wrapperPool.resize(128);
}
void CSfxManager::AddListener(ESfxChannels,
const zeus::CVector3f& vec1, const zeus::CVector3f& vec2,
const zeus::CVector3f& right, const zeus::CVector3f& up,
@ -32,14 +146,36 @@ u16 CSfxManager::TranslateSFXID(u16 id)
return ret;
}
CSfxHandle CSfxManager::SfxStop(const CSfxHandle& handle)
void CSfxManager::SfxStop(const CSfxHandle& handle)
{
return {};
if (handle)
handle->Stop();
}
CSfxHandle CSfxManager::SfxStart(u16 id, float vol, float pan, bool active, s16 prio, bool inArea, s32 areaId)
CSfxHandle CSfxManager::SfxStart(u16 id, float vol, float pan, bool useAcoustics, s16 prio, bool looped, s32 areaId)
{
return {};
if (m_muted || id == 0xffff)
return {};
std::shared_ptr<CSfxWrapper>* wrapper = AllocateCSfxWrapper();
if (!wrapper)
return {};
*wrapper = std::make_shared<CSfxWrapper>(looped, prio, id, vol, pan, useAcoustics, areaId);
return std::static_pointer_cast<CBaseSfxWrapper>(*wrapper);
}
std::shared_ptr<CSfxManager::CSfxWrapper>* CSfxManager::AllocateCSfxWrapper()
{
for (std::shared_ptr<CSfxWrapper>& existing : m_wrapperPool)
if (!existing || existing->Available())
return &existing;
return nullptr;
}
void CSfxManager::Update()
{
}
}

View File

@ -3,7 +3,6 @@
#include <vector>
#include "../RetroTypes.hpp"
#include "CSfxHandle.hpp"
#include "zeus/CVector3f.hpp"
#include "CAudioSys.hpp"
@ -14,6 +13,8 @@ class CSfxManager
{
static std::vector<s16>* mpSfxTranslationTable;
public:
CSfxManager();
enum class ESfxChannels
{
Zero,
@ -32,57 +33,61 @@ public:
{
};
class CBaseSfxWrapper
class CBaseSfxWrapper;
using CSfxHandle = std::shared_ptr<CBaseSfxWrapper>;
class CBaseSfxWrapper : public std::enable_shared_from_this<CBaseSfxWrapper>
{
float x4_ = 15.f;
s16 x8_rank = 0;
s16 xa_prio;
CSfxHandle xc_handle;
//CSfxHandle xc_handle;
TAreaId x10_area;
union
{
struct
{
bool x14_24_useAcoustics:1;
bool x14_25_available:1;
bool x14_26_inArea:1;
bool x14_27_looped:1;
bool x14_28_playing:1;
bool x14_29_active:1;
bool x14_24_isActive:1;
bool x14_25_isPlaying:1;
bool x14_26_looped:1;
bool x14_27_inArea:1;
bool x14_28_available:1;
bool x14_29_useAcoustics:1;
};
u16 _dummy = 0;
};
public:
virtual ~CBaseSfxWrapper() {}
virtual void SetActive(bool v) {x14_29_active = v;}
virtual void SetPlaying(bool v) {x14_28_playing = v;}
virtual void SetRank(short v) {x8_rank = v;}
virtual void SetInArea(bool v) {x14_26_inArea = v;}
virtual bool IsLooped() const {return x14_27_looped;}
virtual bool IsPlaying() const {return x14_28_playing;}
virtual bool IsActive() const {return x14_29_active;}
virtual bool IsInArea() const {return x14_26_inArea;}
virtual bool UseAcoustics() const {return x14_24_useAcoustics;}
virtual s16 GetRank() const {return x8_rank;}
virtual s16 GetPriority() const {return xa_prio;}
virtual TAreaId GetArea() const {return x10_area;}
virtual CSfxHandle GetSfxHandle() const {return xc_handle;}
virtual ~CBaseSfxWrapper() = default;
virtual void SetActive(bool v) { x14_24_isActive = v; }
virtual void SetPlaying(bool v) { x14_25_isPlaying = v; }
virtual void SetRank(short v) { x8_rank = v; }
virtual void SetInArea(bool v) { x14_27_inArea = v; }
virtual bool IsInArea() const { return x14_27_inArea; }
virtual bool IsPlaying() const { return x14_25_isPlaying; }
virtual bool UseAcoustics() const { return x14_29_useAcoustics; }
virtual bool IsLooped() const { return x14_26_looped; }
virtual bool IsActive() const { return x14_24_isActive; }
virtual s16 GetRank() const { return x8_rank; }
virtual s16 GetPriority() const { return xa_prio; }
virtual TAreaId GetArea() const { return x10_area; }
virtual CSfxHandle GetSfxHandle() { return shared_from_this(); }
virtual void Play()=0;
virtual void Stop()=0;
virtual bool Ready()=0;
virtual ESfxAudibility GetAudible(const zeus::CVector3f&)=0;
virtual const std::shared_ptr<amuse::Voice>& GetVoice() const=0;
void Release() {x14_25_available = true;}
bool Available() const {return x14_25_available;}
void Release() { x14_28_available = true; }
bool Available() const { return x14_28_available; }
CBaseSfxWrapper(bool looped, s16 prio, const CSfxHandle& handle, bool useAcoustics, TAreaId area)
: x8_rank(0), xa_prio(prio), xc_handle(handle), x10_area(area), x14_24_useAcoustics(useAcoustics),
x14_26_inArea(0), x14_27_looped(looped), x14_28_playing(0), x14_29_active(0) {}
CBaseSfxWrapper(bool looped, s16 prio, /*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area)
: x8_rank(0), xa_prio(prio), /*xc_handle(handle),*/ x10_area(area), x14_24_isActive(true), x14_25_isPlaying(false),
x14_26_looped(looped), x14_27_inArea(true), x14_28_available(false), x14_29_useAcoustics(useAcoustics) {}
};
class CSfxEmitterWrapper : public CBaseSfxWrapper
{
float x1a_reverb;
CAudioSys::C3DEmitterParmData x24_parmData;
std::shared_ptr<amuse::Emitter> x50_emitterHandle;
bool x54_ready = true;
@ -97,47 +102,49 @@ public:
const std::shared_ptr<amuse::Emitter>& GetHandle() const { return x50_emitterHandle; }
CSfxEmitterWrapper(bool looped, s16 prio, const CAudioSys::C3DEmitterParmData& data,
const CSfxHandle& handle, bool useAcoustics, TAreaId area)
: CBaseSfxWrapper(looped, prio, handle, useAcoustics, area), x24_parmData(data) {}
/*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area)
: CBaseSfxWrapper(looped, prio, /*handle,*/ useAcoustics, area), x24_parmData(data) {}
};
class CSfxWrapper : public CBaseSfxWrapper
{
u16 x18_sfxId;
std::shared_ptr<amuse::Voice> x1c_voiceHandle;
s16 x20_vol;
s16 x22_pan;
float x20_vol;
float x22_pan;
bool x24_ready = true;
public:
bool IsPlaying() const;
void Play();
void Stop();
bool Ready();
ESfxAudibility GetAudible(const zeus::CVector3f&) {return ESfxAudibility::Aud3;}
const std::shared_ptr<amuse::Voice>& GetVoice() const {return x1c_voiceHandle;}
ESfxAudibility GetAudible(const zeus::CVector3f&) { return ESfxAudibility::Aud3; }
const std::shared_ptr<amuse::Voice>& GetVoice() const { return x1c_voiceHandle; }
void SetVolume(s16 vol) {x20_vol = vol;}
void SetVolume(s16 vol) { x20_vol = vol; }
CSfxWrapper(bool looped, s16 prio, u16 sfxId, s16 vol, s16 pan,
const CSfxHandle& handle, bool useAcoustics, TAreaId area)
: CBaseSfxWrapper(looped, prio, handle, useAcoustics, area),
CSfxWrapper(bool looped, s16 prio, u16 sfxId, float vol, float pan,
/*const CSfxHandle& handle,*/ bool useAcoustics, TAreaId area)
: CBaseSfxWrapper(looped, prio, /*handle,*/ useAcoustics, area),
x18_sfxId(sfxId), x20_vol(vol), x22_pan(pan) {}
};
static CSfxChannel m_channels[4];
static rstl::reserved_vector<CSfxEmitterWrapper, 128> m_emitterWrapperPool;
static rstl::reserved_vector<CSfxWrapper, 128> m_wrapperPool;
static rstl::reserved_vector<std::shared_ptr<CSfxEmitterWrapper>, 128> m_emitterWrapperPool;
static rstl::reserved_vector<std::shared_ptr<CSfxWrapper>, 128> m_wrapperPool;
static ESfxChannels m_currentChannel;
static bool m_doUpdate;
static void* m_usedSounds;
static bool m_muted;
static bool m_auxProcessingEnabled;
static float m_reverbAmount;
static u16 kMaxPriority;
static u16 kMedPriority;
static u16 kInternalInvalidSfxId;
static u32 kAllAreas;
static bool IsAuxProcessingEnabled() { return m_auxProcessingEnabled; }
static void SetChannel(ESfxChannels) {}
static void KillAll(ESfxChannels) {}
static void TurnOnChannel(ESfxChannels) {}
@ -154,10 +161,17 @@ public:
static void RemoveEmitter(const CSfxHandle&) {}
static void PitchBend(const CSfxHandle&, s32) {}
static u16 TranslateSFXID(u16);
static CSfxHandle SfxStop(const CSfxHandle& handle);
static CSfxHandle SfxStart(u16 id, float vol, float pan, bool active, s16 prio, bool inArea, s32 areaId);
static void SfxStop(const CSfxHandle& handle);
static CSfxHandle SfxStart(u16 id, float vol, float pan, bool useAcoustics, s16 prio, bool looped, s32 areaId);
static void Update();
private:
static std::shared_ptr<CSfxWrapper>* AllocateCSfxWrapper();
};
using CSfxHandle = CSfxManager::CSfxHandle;
}
#endif // __URDE_CSFXMANAGER_HPP__

View File

@ -22,13 +22,13 @@ CGuiTextSupport::CGuiTextSupport(ResId fontId, const CGuiTextProperties& props,
CTextRenderBuffer* CGuiTextSupport::GetCurrentLineRenderBuffer() const
{
if (x60_renderBuf && !x308_multilineFlag)
if (x60_renderBuf && !x308_multipageFlag)
return const_cast<CTextRenderBuffer*>(&*x60_renderBuf);
if (!x308_multilineFlag || x300_ <= x304_lineCounter)
if (!x308_multipageFlag || x300_ <= x304_pageCounter)
return nullptr;
int idx = 0;
for (const CTextRenderBuffer& buf : x2f0_lineRenderBufs)
if (idx++ == x304_lineCounter)
for (const CTextRenderBuffer& buf : x2f0_pageRenderBufs)
if (idx++ == x304_pageCounter)
return const_cast<CTextRenderBuffer*>(&buf);
return nullptr;
}
@ -192,7 +192,7 @@ void CGuiTextSupport::AddText(const std::wstring& str)
ClearRenderBuffer();
}
void CGuiTextSupport::SetText(const std::wstring& str, bool multiline)
void CGuiTextSupport::SetText(const std::wstring& str, bool multipage)
{
if (x0_string.compare(str))
{
@ -200,14 +200,14 @@ void CGuiTextSupport::SetText(const std::wstring& str, bool multiline)
x3c_curTime = 0.f;
x0_string = str;
ClearRenderBuffer();
x308_multilineFlag = multiline;
x304_lineCounter = 0;
x308_multipageFlag = multipage;
x304_pageCounter = 0;
}
}
void CGuiTextSupport::SetText(const std::string& str, bool multiline)
void CGuiTextSupport::SetText(const std::string& str, bool multipage)
{
SetText(hecl::UTF8ToWide(str), multiline);
SetText(hecl::UTF8ToWide(str), multipage);
}
bool CGuiTextSupport::GetIsTextSupportFinishedLoading() const

View File

@ -97,10 +97,10 @@ class CGuiTextSupport
zeus::CVector2f x2dc_;
zeus::CVector2f x2e4_;
std::list<CTextRenderBuffer> x2f0_lineRenderBufs;
std::list<CTextRenderBuffer> x2f0_pageRenderBufs;
u32 x300_ = 0;
u32 x304_lineCounter = 0;
bool x308_multilineFlag = false;
u32 x304_pageCounter = 0;
bool x308_multipageFlag = false;
CTextRenderBuffer* GetCurrentLineRenderBuffer() const;
@ -121,8 +121,8 @@ public:
void SetOutlineColor(const zeus::CColor& col);
void SetFontColor(const zeus::CColor& col);
void AddText(const std::wstring& str);
void SetText(const std::wstring& str, bool multiline=false);
void SetText(const std::string& str, bool multiline=false);
void SetText(const std::wstring& str, bool multipage=false);
void SetText(const std::string& str, bool multipage=false);
bool GetIsTextSupportFinishedLoading() const;
};

View File

@ -0,0 +1,6 @@
#include "CGuiWidgetDrawParms.hpp"
namespace urde
{
CGuiWidgetDrawParms CGuiWidgetDrawParms::Default;
}

View File

@ -6,10 +6,12 @@ namespace urde
struct CGuiWidgetDrawParms
{
float x0_alphaMod;
float x4_;
float x8_;
float xc_;
float x0_alphaMod = 1.f;
float x4_ = 0.f;
float x8_ = 0.f;
float xc_ = 0.f;
static CGuiWidgetDrawParms Default;
};
}

View File

@ -676,7 +676,7 @@ CFrontEndUI::SFusionBonusFrame::SFusionBonusFrame()
bool CFrontEndUI::SFusionBonusFrame::DoUpdateWithSaveUI(float dt, CSaveUI* saveUi)
{
bool flag = (saveUi && saveUi->GetUIType() != CSaveUI::UIType::Sixteen) ? false : true;
bool flag = (saveUi && saveUi->GetUIType() != CSaveUI::UIType::SaveProgress) ? false : true;
x10_remTime = std::max(x10_remTime - dt, 0.f);
zeus::CColor geomCol(zeus::CColor::skWhite);

View File

@ -194,7 +194,7 @@ public:
return v >= EState::CardMount && v <= EState::CardFormat;
}
static bool IsOperationDestructive(EState v)
static bool IsCardWriting(EState v)
{
if (v < EState::CardProbe)
return false;

View File

@ -6,6 +6,7 @@
#include "GuiSys/CGuiTableGroup.hpp"
#include "GuiSys/CGuiTextPane.hpp"
#include "GuiSys/CGuiWidgetDrawParms.hpp"
#include "Audio/CSfxManager.hpp"
namespace urde
{
@ -22,8 +23,8 @@ void CSaveUI::ResetCardDriver()
bool importState = (x0_instIdx == 0 && !x90_needsDriverReset);
x6c_cardDriver = ConstructCardDriver(importState);
x6c_cardDriver->StartCardProbe();
x10_uiType = UIType::Zero;
FinishedLoading();
x10_uiType = UIType::Empty;
SetUIText();
}
CIOWin::EMessageReturn CSaveUI::Update(float dt)
@ -44,14 +45,14 @@ CIOWin::EMessageReturn CSaveUI::Update(float dt)
else
x80_iowRet = CIOWin::EMessageReturn::Exit;
}
else if (x6c_cardDriver->x10_state == EState::CardCheckDone && x10_uiType != UIType::Fourteen)
else if (x6c_cardDriver->x10_state == EState::CardCheckDone && x10_uiType != UIType::NotOriginalCard)
{
if (x6c_cardDriver->x28_cardSerial && x8_serial)
if (x6c_cardDriver->x28_cardSerial != x8_serial)
{
if (x93_secondaryInst)
{
x10_uiType = UIType::Fourteen;
x91_ = true;
x10_uiType = UIType::NotOriginalCard;
x91_uiTextDirty = true;
}
else
{
@ -71,8 +72,8 @@ CIOWin::EMessageReturn CSaveUI::Update(float dt)
UIType oldTp = x10_uiType;
x10_uiType = SelectUIType();
if (oldTp == x10_uiType || x91_)
FinishedLoading();
if (oldTp != x10_uiType || x91_uiTextDirty)
SetUIText();
if (x6c_cardDriver->x10_state == EState::NoCard)
{
@ -129,79 +130,282 @@ bool CSaveUI::PumpLoad()
x6c_cardDriver->StartCardProbe();
x10_uiType = SelectUIType();
FinishedLoading();
SetUIText();
return true;
}
CSaveUI::UIType CSaveUI::SelectUIType() const
{
if (x6c_cardDriver->x10_state == EState::NoCard)
return UIType::Three;
return UIType::NoCardFound;
switch (x10_uiType)
{
case UIType::Thirteen:
case UIType::Fourteen:
case UIType::Fifteen:
case UIType::ProgressWillBeLost:
case UIType::NotOriginalCard:
case UIType::AllDataWillBeLost:
return x10_uiType;
default: break;
}
if (CMemoryCardDriver::IsCardBusy(x6c_cardDriver->x10_state))
{
if (!CMemoryCardDriver::IsOperationDestructive(x6c_cardDriver->x10_state))
return UIType::Two;
return UIType::One;
if (CMemoryCardDriver::IsCardWriting(x6c_cardDriver->x10_state))
return UIType::BusyWriting;
return UIType::BusyReading;
}
if (x6c_cardDriver->x10_state == EState::Ready)
{
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardStillFull)
return UIType::Twelve;
return UIType::Sixteen;
return UIType::StillInsufficientSpace;
return UIType::SaveProgress;
}
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardBroken)
return UIType::Four;
return UIType::NeedsFormatBroken;
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardWrongCharacterSet)
return UIType::Five;
return UIType::NeedsFormatEncoding;
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardWrongDevice)
return UIType::Seven;
return UIType::WrongDevice;
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardFull)
{
if (x6c_cardDriver->x10_state == EState::CardCheckFailed)
return UIType::Eight;
return UIType::Nine;
return UIType::InsufficientSpaceBadCheck;
return UIType::InsufficientSpaceOKCheck;
}
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardNon8KSectors)
return UIType::Ten;
return UIType::IncompatibleCard;
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::FileCorrupted)
return UIType::Eleven;
return UIType::SaveCorrupt;
if (x6c_cardDriver->x14_error == CMemoryCardDriver::EError::CardIOError)
return UIType::Six;
return UIType::CardDamaged;
return UIType::Zero;
return UIType::Empty;
}
void CSaveUI::FinishedLoading()
void CSaveUI::SetUIText()
{
x91_uiTextDirty = false;
u32 msgA = -1;
u32 msgB = -1;
u32 opt0 = -1;
u32 opt1 = -1;
u32 opt2 = -1;
switch (x10_uiType)
{
case UIType::BusyReading:
msgB = 24; // Reading
break;
case UIType::BusyWriting:
msgB = 25; // Writing
break;
case UIType::NoCardFound:
msgB = 0; // No card found
opt0 = 17; // Continue without saving
opt1 = 18; // Retry
break;
case UIType::NeedsFormatBroken:
msgB = 1; // Needs format (card broken)
opt0 = 17; // Continue without saving
opt1 = 18; // Retry
opt2 = 20; // Format
break;
case UIType::NeedsFormatEncoding:
msgB = 2; // Needs format (wrong char set)
opt0 = 17; // Continue without saving
opt1 = 18; // Retry
opt2 = 20; // Format
break;
case UIType::CardDamaged:
msgB = 3; // Damaged
opt0 = 17; // Continue without saving
opt1 = 18; // Retry
break;
case UIType::WrongDevice:
msgB = 5; // Invalid device
opt0 = 17; // Continue without saving
opt1 = 18; // Retry
break;
case UIType::InsufficientSpaceOKCheck:
msgB = 6; // Insufficient space (completely filled)
opt0 = 17; // Continue without saving
opt1 = 18; // Retry
opt2 = 19; // Manage memory card
break;
case UIType::InsufficientSpaceBadCheck:
msgB = bool(x0_instIdx) + 9; // Insufficient space A or B
opt0 = 17; // Continue without saving
opt1 = 18; // Retry
opt2 = 19; // Manage memory card
break;
case UIType::IncompatibleCard:
msgB = 7; // Incompatible card
opt0 = 17; // Continue without saving
opt1 = 18; // Retry
break;
case UIType::SaveCorrupt:
msgB = 4; // Save corrupt
opt0 = 22; // Delete corrupt file
opt1 = 17; // Continue without saving
opt2 = 18; // Retry
break;
case UIType::StillInsufficientSpace:
if (x0_instIdx == 1)
{
msgB = 10; // Insufficient space B
opt0 = 17; // Continue without saving
opt1 = 18; // Retry
opt2 = 19; // Manage memory card
}
else
{
msgB = 9; // Insufficient space A
opt0 = 17; // Continue without saving
opt1 = 18; // Retry
opt2 = 19; // Manage memory card
}
break;
case UIType::ProgressWillBeLost:
msgA = 28; // Warning
msgB = 11; // Progress will be lost
opt0 = 21; // Cancel
opt1 = 16; // Continue
break;
case UIType::NotOriginalCard:
msgA = 28; // Warning
msgB = 12; // Not the original card
opt0 = x0_instIdx == 1 ? 21 : 17; // Cancel : continue without saving
opt1 = 16; // Continue
break;
case UIType::AllDataWillBeLost:
msgA = 28; // Warning
msgB = 13; // All card data will be erased
opt0 = 16; // Continue
opt1 = 21; // Cancel
break;
case UIType::SaveProgress:
if (x0_instIdx == 1)
{
msgB = 8; // Save progress?
opt0 = 14; // Yes
opt1 = 15; // No
}
break;
default: break;
}
std::wstring msgAStr;
if (msgA != -1)
msgAStr = x38_strgMemoryCard->GetString(msgA);
std::wstring msgBStr;
if (msgB != -1)
msgBStr = x38_strgMemoryCard->GetString(msgB);
x54_textpane_message->TextSupport()->SetText(msgAStr + msgBStr);
std::wstring opt0Str;
if (opt0 != -1)
opt0Str = x38_strgMemoryCard->GetString(opt0);
x5c_textpane_choice0->TextSupport()->SetText(opt0Str);
std::wstring opt1Str;
if (opt1 != -1)
opt1Str = x38_strgMemoryCard->GetString(opt1);
x60_textpane_choice1->TextSupport()->SetText(opt1Str);
std::wstring opt2Str;
if (opt2 != -1)
opt2Str = x38_strgMemoryCard->GetString(opt2);
x64_textpane_choice2->TextSupport()->SetText(opt2Str);
std::wstring opt3Str;
x68_textpane_choice3->TextSupport()->SetText(opt3Str);
x5c_textpane_choice0->SetB627(opt0 != -1);
x60_textpane_choice1->SetB627(opt1 != -1);
x64_textpane_choice2->SetB627(opt2 != -1);
x68_textpane_choice3->SetB627(false);
x58_tablegroup_choices->SetIsActive(opt0 != -1 || opt1 != -1 || opt2 != -1);
SetUIColors();
}
void CSaveUI::SetUIColors()
{
x58_tablegroup_choices->SetColors(zeus::CColor::skWhite,
zeus::CColor{0.627450f, 0.627450f, 0.627450f, 0.784313f});
}
void CSaveUI::Draw() const
{
//if (x50_loadedFrame)
//x50_loadedFrame->Draw(CGuiWidgetDrawParams::Default());
if (x50_loadedFrame)
x50_loadedFrame->Draw(CGuiWidgetDrawParms::Default);
}
void CSaveUI::ContinueWithoutSaving()
{
x80_iowRet = CIOWin::EMessageReturn::RemoveIOWin;
g_GameState->SetCardSerial(0);
}
void CSaveUI::DoAdvance(CGuiTableGroup* caller)
{
int userSel = x58_tablegroup_choices->GetUserSelection();
s32 sfx = -1;
switch (x10_uiType)
{
case UIType::NoCardFound:
case UIType::CardDamaged:
case UIType::WrongDevice:
case UIType::IncompatibleCard:
if (userSel == 0)
{
/* Continue without saving */
if (x0_instIdx == 1)
x80_iowRet = CIOWin::EMessageReturn::RemoveIOWinAndExit;
else
ContinueWithoutSaving();
sfx = x8c_navBackSfx;
}
else if (userSel == 1)
{
/* Retry */
ResetCardDriver();
sfx = x84_navConfirmSfx;
}
break;
case UIType::NeedsFormatBroken:
case UIType::NeedsFormatEncoding:
case UIType::InsufficientSpaceBadCheck:
case UIType::InsufficientSpaceOKCheck:
case UIType::SaveCorrupt:
case UIType::StillInsufficientSpace:
case UIType::NotOriginalCard:
case UIType::AllDataWillBeLost:
case UIType::SaveProgress:
default: break;
}
if (sfx >= 0)
CSfxManager::SfxStart(sfx, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
void CSaveUI::DoSelectionChange(CGuiTableGroup* caller)

View File

@ -24,33 +24,33 @@ class CSaveUI
public:
enum class UIType
{
Zero,
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Eleven,
Twelve,
Thirteen,
Fourteen,
Fifteen,
Sixteen
Empty = 0,
BusyReading = 1,
BusyWriting = 2,
NoCardFound = 3,
NeedsFormatBroken = 4,
NeedsFormatEncoding = 5,
CardDamaged = 6,
WrongDevice = 7,
InsufficientSpaceBadCheck = 8,
InsufficientSpaceOKCheck = 9,
IncompatibleCard = 10,
SaveCorrupt = 11,
StillInsufficientSpace = 12,
ProgressWillBeLost = 13,
NotOriginalCard = 14,
AllDataWillBeLost = 15,
SaveProgress = 16
};
bool IsDrawConditional()
{
switch (x10_uiType)
{
case UIType::Sixteen:
case UIType::Zero:
case UIType::One:
case UIType::Two:
case UIType::SaveProgress:
case UIType::Empty:
case UIType::BusyReading:
case UIType::BusyWriting:
return false;
default:
return true;
@ -60,7 +60,7 @@ public:
private:
u32 x0_instIdx;
u64 x8_serial;
UIType x10_uiType = UIType::Zero;
UIType x10_uiType = UIType::Empty;
TLockedToken<CTexture> x14_txtrSaveBanner;
TLockedToken<CTexture> x20_txtrSaveIcon0;
TLockedToken<CTexture> x2c_txtrSaveIcon1;
@ -80,18 +80,20 @@ private:
u32 x88_navMoveSfx = 1461;
u32 x8c_navBackSfx = 1459;
bool x90_needsDriverReset = false;
bool x91_ = false;
bool x91_uiTextDirty = false;
bool x92_ = false;
bool x93_secondaryInst;
void ResetCardDriver();
void ContinueWithoutSaving();
public:
static std::unique_ptr<CMemoryCardDriver> ConstructCardDriver(bool importState);
CIOWin::EMessageReturn Update(float dt);
bool PumpLoad();
UIType SelectUIType() const;
void FinishedLoading();
void SetUIText();
void SetUIColors();
void Draw() const;
void DoAdvance(CGuiTableGroup* caller);

View File

@ -6,12 +6,11 @@
#include "CToken.hpp"
#include "GuiSys/CGuiTextSupport.hpp"
#include "Graphics/Shaders/CTexturedQuadFilter.hpp"
#include "Audio/CSfxHandle.hpp"
#include "Audio/CSfxManager.hpp"
namespace urde
{
class CTexture;
class CSfxHandle;
class CDependencyGroup;
class CSlideShow : public CIOWin

View File

@ -4,12 +4,12 @@
#include "CEntity.hpp"
#include "Graphics/CGraphics.hpp"
#include "Graphics/CSimpleShadow.hpp"
#include "Audio/CSfxHandle.hpp"
#include "zeus/zeus.hpp"
#include "Collision/CMaterialFilter.hpp"
#include "Character/CModelData.hpp"
#include "Character/CActorLights.hpp"
#include "Collision/CCollisionResponseData.hpp"
#include "Audio/CSfxManager.hpp"
namespace urde
{
@ -22,7 +22,6 @@ class CDamageVulnerability;
class CLightParameters;
class CScannableObjectInfo;
class CScriptWater;
class CSfxHandle;
class CSimpleShadow;
class CActor : public CEntity

2
amuse

@ -1 +1 @@
Subproject commit 72d0df7d461841b7fca2b3c38c3dd61ccb798fd6
Subproject commit df167556fbded7d8bcdf72306921a6594374121c