Additional CSlideShow work; amuse voice handle integration

This commit is contained in:
Jack Andersen 2016-09-16 13:43:33 -10:00
parent dae5ea06f5
commit 6ea727e4a8
9 changed files with 191 additions and 87 deletions

View File

@ -8,6 +8,9 @@ namespace DataSpec
struct ITweakSlideShow : BigYAML
{
virtual const zeus::CColor& GetFontColor() const=0;
virtual const zeus::CColor& GetOutlineColor() const=0;
virtual float GetX54() const=0;
};
}

View File

@ -15,8 +15,8 @@ struct CTweakSlideShow : ITweakSlideShow
String<-1> x4_pakName;
String<-1> x14_fontAssetName;
DNAColor x24_;
DNAColor x28_;
DNAColor x24_fontColor;
DNAColor x28_outlineColor;
Value<float> x2c_;
Value<float> x30_;
Value<float> x34_;
@ -32,6 +32,10 @@ struct CTweakSlideShow : ITweakSlideShow
CTweakSlideShow() = default;
CTweakSlideShow(athena::io::IStreamReader& in) { read(in); }
const zeus::CColor& GetFontColor() const { return x24_fontColor; }
const zeus::CColor& GetOutlineColor() const { return x28_outlineColor; }
float GetX54() const { return x54_; }
};
}

View File

@ -14,15 +14,15 @@ class CAudioSys
public:
struct C3DEmitterParmData
{
zeus::CVector3f pos;
zeus::CVector3f dir;
float maxDist;
float distComp;
u32 flags;
u16 sfxId;
u8 maxVol;
u8 minVol;
u8 extra[2];
zeus::CVector3f x0_pos;
zeus::CVector3f xc_dir;
float x18_maxDist;
float x1c_distComp;
u32 x20_flags;
u16 x24_sfxId;
u8 x26_maxVol;
u8 x27_minVol;
u8 x28_extra[2];
};
CAudioSys(amuse::IBackendVoiceAllocator& backend, u8,u8,u8,u8,u32)
: m_engine(backend)

View File

@ -32,4 +32,12 @@ u16 CSfxManager::TranslateSFXID(u16 id)
return ret;
}
CSfxHandle CSfxManager::SfxStop(const CSfxHandle& handle)
{
}
CSfxHandle CSfxManager::SfxStart(u16 id, s16 vol, s16 pan, bool active, s16 prio, bool inArea, s32 areaId)
{
}
}

View File

@ -34,84 +34,94 @@ public:
class CBaseSfxWrapper
{
s16 m_rank;
s16 m_prio;
CSfxHandle m_handle;
TAreaId m_area;
bool m_useAcoustics:1;
bool m_available:1;
bool m_inArea:1;
bool m_looped:1;
bool m_playing:1;
bool m_active:1;
float x4_ = 15.f;
s16 x8_rank = 0;
s16 xa_prio;
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;
};
u16 _dummy = 0;
};
public:
virtual ~CBaseSfxWrapper() {}
virtual void SetActive(bool v) {m_active = v;}
virtual void SetPlaying(bool v) {m_playing = v;}
virtual void SetRank(short v) {m_rank = v;}
virtual void SetInArea(bool v) {m_inArea = v;}
virtual bool IsLooped() const {return m_looped;}
virtual bool IsPlaying() const {return m_playing;}
virtual bool IsActive() const {return m_active;}
virtual bool IsInArea() const {return m_inArea;}
virtual bool UseAcoustics() const {return m_useAcoustics;}
virtual s16 GetRank() const {return m_rank;}
virtual s16 GetPriority() const {return m_prio;}
virtual TAreaId GetArea() const {return m_area;}
virtual CSfxHandle GetSfxHandle() const {return m_handle;}
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 void Play()=0;
virtual void Stop()=0;
virtual bool Ready()=0;
virtual ESfxAudibility GetAudible(const zeus::CVector3f&)=0;
virtual u32 GetVoice() const=0;
virtual const std::shared_ptr<amuse::Voice>& GetVoice() const=0;
void Release() {m_available = true;}
bool Available() const {return m_available;}
void Release() {x14_25_available = true;}
bool Available() const {return x14_25_available;}
CBaseSfxWrapper(bool looped, s16 prio, const CSfxHandle& handle, bool useAcoustics, TAreaId area)
: m_rank(0), m_prio(prio), m_handle(handle), m_area(area), m_useAcoustics(useAcoustics),
m_inArea(0), m_looped(looped), m_playing(0), m_active(0) {}
: 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) {}
};
class CSfxEmitterWrapper : public CBaseSfxWrapper
{
CAudioSys::C3DEmitterParmData m_parmData;
u32 m_emitterHandle = -1;
CAudioSys::C3DEmitterParmData x24_parmData;
std::shared_ptr<amuse::Emitter> x50_emitterHandle;
bool x54_ready = true;
public:
bool IsPlaying() const;
void Play();
void Stop();
bool Ready();
ESfxAudibility GetAudible(const zeus::CVector3f&);
u32 GetVoice() const;
const std::shared_ptr<amuse::Voice>& GetVoice() const { return x50_emitterHandle->getVoice(); }
u32 GetHandle() const {return m_emitterHandle;}
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), m_parmData(data) {}
: CBaseSfxWrapper(looped, prio, handle, useAcoustics, area), x24_parmData(data) {}
};
class CSfxWrapper : public CBaseSfxWrapper
{
u16 m_sfxId;
u32 m_voiceHandle = -1;
s16 m_vol;
s16 m_pan;
u16 x18_sfxId;
std::shared_ptr<amuse::Voice> x1c_voiceHandle;
s16 x20_vol;
s16 x22_pan;
bool x24_ready = true;
public:
bool IsPlaying() const;
void Play();
void Stop();
bool Ready();
ESfxAudibility GetAudible(const zeus::CVector3f&) {return ESfxAudibility::Aud3;}
u32 GetVoice() const {return m_voiceHandle;}
const std::shared_ptr<amuse::Voice>& GetVoice() const {return x1c_voiceHandle;}
void SetVolume(s16 vol) {m_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),
m_sfxId(sfxId), m_vol(vol), m_pan(pan) {}
x18_sfxId(sfxId), x20_vol(vol), x22_pan(pan) {}
};
static CSfxChannel m_channels[4];
@ -141,6 +151,9 @@ 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, s16 vol, s16 pan, bool active, s16 prio, bool inArea, s32 areaId);
};
}

View File

@ -15,19 +15,19 @@ CGuiTextPane::CGuiTextPane(const CGuiWidgetParms& parms, float xDim, float zDim,
const zeus::CVector3f& vec, ResId fontId, const CGuiTextProperties& props,
const zeus::CColor& fontCol, const zeus::CColor& outlineCol,
s32 extentX, s32 extentY)
: CGuiPane(parms, xDim, zDim, vec), x114_textSupport(fontId, props, fontCol, outlineCol,
: CGuiPane(parms, xDim, zDim, vec), xd4_textSupport(fontId, props, fontCol, outlineCol,
zeus::CColor::skWhite, extentX, extentY,
&parms.x0_frame->GetGuiSys().GetResStore()) {}
void CGuiTextPane::Update(float dt)
{
CGuiWidget::Update(dt);
x114_textSupport.Update(dt);
xd4_textSupport.Update(dt);
}
bool CGuiTextPane::GetIsFinishedLoadingWidgetSpecific() const
{
return x114_textSupport.GetIsTextSupportFinishedLoading();
return xd4_textSupport.GetIsTextSupportFinishedLoading();
}
void CGuiTextPane::SetDimensions(const zeus::CVector2f& dim, bool initVBO)
@ -48,13 +48,13 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const
zeus::CVector2f dims = GetDimensions();
if (x114_textSupport.x34_extentX)
dims.x /= float(x114_textSupport.x34_extentX);
if (xd4_textSupport.x34_extentX)
dims.x /= float(xd4_textSupport.x34_extentX);
else
dims.x = 0.f;
if (x114_textSupport.x38_extentY)
dims.y /= float(x114_textSupport.x38_extentY);
if (xd4_textSupport.x38_extentY)
dims.y /= float(xd4_textSupport.x38_extentY);
else
dims.y = 0.f;
@ -65,7 +65,7 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const
zeus::CColor geomCol = xb4_;
geomCol.a *= parms.x0_alphaMod;
const_cast<CGuiTextPane*>(this)->x114_textSupport.SetGeometryColor(geomCol);
const_cast<CGuiTextPane*>(this)->xd4_textSupport.SetGeometryColor(geomCol);
CGraphics::SetDepthWriteMode(xf6_31_depthTest, ERglEnum::LEqual, xf7_24_depthWrite);
@ -75,27 +75,27 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const
case EGuiModelDrawFlags::Opaque:
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One,
ERglBlendFactor::Zero, ERglLogicOp::Clear);
x114_textSupport.Render();
xd4_textSupport.Render();
break;
case EGuiModelDrawFlags::Alpha:
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
x114_textSupport.Render();
xd4_textSupport.Render();
break;
case EGuiModelDrawFlags::Additive:
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
ERglBlendFactor::One, ERglLogicOp::Clear);
x114_textSupport.Render();
xd4_textSupport.Render();
break;
case EGuiModelDrawFlags::AlphaAdditiveOverdraw:
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
x114_textSupport.Render();
const_cast<CGuiTextPane*>(this)->x114_textSupport.SetGeometryColor
xd4_textSupport.Render();
const_cast<CGuiTextPane*>(this)->xd4_textSupport.SetGeometryColor
(geomCol * zeus::CColor(geomCol.a, geomCol.a, geomCol.a, 1.f));
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::One,
ERglBlendFactor::One, ERglLogicOp::Clear);
x114_textSupport.Render();
xd4_textSupport.Render();
break;
}
}

View File

@ -9,18 +9,18 @@ namespace urde
class CGuiTextPane : public CGuiPane
{
CGuiTextSupport x114_textSupport;
CGuiTextSupport xd4_textSupport;
public:
CGuiTextPane(const CGuiWidgetParms& parms, float xDim, float zDim, const zeus::CVector3f& vec,
ResId fontId, const CGuiTextProperties& props, const zeus::CColor& col1,
const zeus::CColor& col2, s32 padX, s32 padY);
FourCC GetWidgetTypeID() const {return FOURCC('TXPN');}
CGuiTextSupport* TextSupport() {return &x114_textSupport;}
const CGuiTextSupport* GetTextSupport() const {return &x114_textSupport;}
CGuiTextSupport* TextSupport() {return &xd4_textSupport;}
const CGuiTextSupport* GetTextSupport() const {return &xd4_textSupport;}
void Update(float dt);
bool GetIsFinishedLoadingWidgetSpecific() const;
std::vector<ResId> GetFontAssets() const {return {x114_textSupport.x5c_fontId};}
std::vector<ResId> GetFontAssets() const {return {xd4_textSupport.x5c_fontId};}
void SetDimensions(const zeus::CVector2f& dim, bool initVBO);
void ScaleDimensions(const zeus::CVector3f& scale);
void Draw(const CGuiWidgetDrawParms& parms) const;

View File

@ -1,11 +1,33 @@
#include "CSlideShow.hpp"
#include "GameGlobalObjects.hpp"
#include "Editor/ProjectManager.hpp"
namespace urde
{
CSlideShow::CSlideShow()
: CIOWin("SlideShow")
: CIOWin("SlideShow"), x5c_slideA(*this), x90_slideB(*this)
{
x130_ = g_tweakSlideShow->GetX54();
x134_24_ = true;
x134_30_ = true;
x135_24_ = true;
/* Originally came from SlideShow tweak */
SObjectTag font = ProjectManager::g_SharedManager->TagFromPath(_S("MP1/NoARAM/FONT_Deface14B.yaml"));
CGuiTextProperties propsA(false, true, EJustification::Center, EVerticalJustification::Bottom);
xc4_textA = std::make_unique<CGuiTextSupport>(font.id, propsA,
g_tweakSlideShow->GetFontColor(),
g_tweakSlideShow->GetOutlineColor(),
zeus::CColor::skWhite, 640, 480, g_SimplePool);
CGuiTextProperties propsB(false, true, EJustification::Right, EVerticalJustification::Bottom);
xc8_textB = std::make_unique<CGuiTextSupport>(font.id, propsB,
g_tweakSlideShow->GetFontColor(),
g_tweakSlideShow->GetOutlineColor(),
zeus::CColor::skWhite, 640, 480, g_SimplePool);
}
CIOWin::EMessageReturn CSlideShow::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue)
@ -13,8 +35,25 @@ CIOWin::EMessageReturn CSlideShow::OnMessage(const CArchitectureMessage& msg, CA
return EMessageReturn::Exit;
}
void CSlideShow::SSlideData::Draw() const
{
if (!IsLoaded())
return;
zeus::CRectangle rect;
const_cast<CTexturedQuadFilterAlpha&>(*m_texQuad).draw(x30_mulColor, 1.f, rect);
zeus::CVector2f centeredOffset((x28_canvasSize.x - m_texQuad->GetTex()->GetWidth()) * 0.5f,
(x28_canvasSize.y - m_texQuad->GetTex()->GetHeight()) * 0.5f);
}
void CSlideShow::Draw() const
{
if (x14_phase == Phase::Five)
{
x5c_slideA.Draw();
x90_slideB.Draw();
}
}
}

View File

@ -4,14 +4,57 @@
#include "RetroTypes.hpp"
#include "CIOWin.hpp"
#include "CToken.hpp"
#include "GuiSys/CGuiTextSupport.hpp"
#include "Graphics/Shaders/CTexturedQuadFilter.hpp"
#include "Audio/CSfxHandle.hpp"
namespace urde
{
class CTexture;
class CSfxHandle;
class CSlideShow : public CIOWin
{
u32 x14_ = 0;
public:
enum class Phase
{
Zero,
One,
Two,
Three,
Four,
Five
};
struct SSlideData
{
CSlideShow& x0_parent;
u32 x4_ = -1;
u32 x8_ = -1;
std::experimental::optional<CTexturedQuadFilterAlpha> m_texQuad;
zeus::CVector2f x18_vpOffset;
zeus::CVector2f x20_vpSize;
zeus::CVector2f x28_canvasSize;
zeus::CColor x30_mulColor = zeus::CColor::skWhite;
SSlideData(CSlideShow& parent) : x0_parent(parent)
{
x30_mulColor.a = 0.f;
}
void SetTexture(const TLockedToken<CTexture>& tex)
{
m_texQuad.emplace(CCameraFilterPass::EFilterType::Blend, tex);
}
bool IsLoaded() const
{
return m_texQuad && m_texQuad->GetTex().IsLoaded();
}
void Draw() const;
};
private:
Phase x14_phase = Phase::Zero;
u32 x1c_ = 0;
u32 x20_ = 0;
u32 x24_ = 0;
@ -27,36 +70,30 @@ class CSlideShow : public CIOWin
float x50_ = 0.f;
float x54_ = 0.f;
float x58_ = 0.f;
u32 x5c_ = 0;
u32 x60_ = -1;
u32 x64_ = 0;
bool x68_ = false;
u32 x6c_ = 0;
bool x70_ = false;
u32 xc4_ = 0;
u32 xc8_ = 0;
SSlideData x5c_slideA;
SSlideData x90_slideB;
std::unique_ptr<CGuiTextSupport> xc4_textA;
std::unique_ptr<CGuiTextSupport> xc8_textB;
u32 xcc_ = 0;
u32 xd4_ = 0;
u32 xd8_ = 0;
u32 xdc_ = 0;
u32 xe0_ = 0;
u32 xe4_ = 0;
CSfxHandle xe4_;
u32 xe8_ = 0;
u32 xec_ = 0;
u32 xf0_ = 0;
u32 xf4_ = 0;
u32 xfc_ = 0;
u32 x100_ = 0;
u32 x104_ = 0;
u32 x10c_ = 0;
u32 x110_ = 0;
u32 x114_ = 0;
std::vector<CToken> xf8_;
std::vector<CToken> x108_;
u32 x11c_ = 0;
u32 x120_ = 0;
u32 x124_ = 0;
float x128_ = 32.f;
float x12c_ = 32.f;
float x130_;
union
{
@ -66,7 +103,7 @@ class CSlideShow : public CIOWin
bool x134_25_ : 1;
bool x134_26_ : 1;
bool x134_27_ : 1;
bool x134_28_ : 1;
bool x134_28_disableInput : 1;
bool x134_29_ : 1;
bool x134_30_ : 1;
bool x134_31_ : 1;