Several architectural fixes and additions

This commit is contained in:
Jack Andersen 2017-01-21 15:40:12 -10:00
parent 00247ca53e
commit 0744a2307a
68 changed files with 508 additions and 586 deletions

View File

@ -88,12 +88,6 @@ static inline uint8_t Convert6To8(uint8_t v)
return (v << 2) | (v >> 4);
}
static inline uint16_t Convert8To16(uint16_t v)
{
/* Swizzle bits: 01234567 -> 0123456701234567 */
return (v << 8) | v;
}
static inline uint8_t Lookup4BPP(const uint8_t* texels, int width, int x, int y)
{
int bwidth = (width + 7) / 8;
@ -305,10 +299,10 @@ static const uint8_t* DecodePaletteSPLT(png_structrp png, png_infop info,
GXEntry.name = (char*)"GX_IA8";
for (int e=0 ; e<numEntries ; ++e)
{
entries[e].red = Convert8To16(data[e*2]);
entries[e].green = Convert8To16(data[e*2]);
entries[e].blue = Convert8To16(data[e*2]);
entries[e].alpha = Convert8To16(data[e*2+1]);
entries[e].red = data[e*2];
entries[e].green = data[e*2];
entries[e].blue = data[e*2];
entries[e].alpha = data[e*2+1];
}
break;
}
@ -320,10 +314,10 @@ static const uint8_t* DecodePaletteSPLT(png_structrp png, png_infop info,
for (int e=0 ; e<numEntries ; ++e)
{
uint16_t texel = hecl::SBig(data16[e]);
entries[e].red = Convert8To16(Convert5To8(texel >> 11 & 0x1f));
entries[e].green = Convert8To16(Convert6To8(texel >> 5 & 0x3f));
entries[e].blue = Convert8To16(Convert5To8(texel & 0x1f));
entries[e].alpha = Convert8To16(0xff);
entries[e].red = Convert5To8(texel >> 11 & 0x1f);
entries[e].green = Convert6To8(texel >> 5 & 0x3f);
entries[e].blue = Convert5To8(texel & 0x1f);
entries[e].alpha = 0xff;
}
break;
}
@ -337,17 +331,17 @@ static const uint8_t* DecodePaletteSPLT(png_structrp png, png_infop info,
uint16_t texel = hecl::SBig(data16[e]);
if (texel & 0x8000)
{
entries[e].red = Convert8To16(Convert5To8(texel >> 10 & 0x1f));
entries[e].green = Convert8To16(Convert5To8(texel >> 5 & 0x1f));
entries[e].blue = Convert8To16(Convert5To8(texel & 0x1f));
entries[e].alpha = Convert8To16(0xff);
entries[e].red = Convert5To8(texel >> 10 & 0x1f);
entries[e].green = Convert5To8(texel >> 5 & 0x1f);
entries[e].blue = Convert5To8(texel & 0x1f);
entries[e].alpha = 0xff;
}
else
{
entries[e].red = Convert8To16(Convert4To8(texel >> 8 & 0xf));
entries[e].green = Convert8To16(Convert4To8(texel >> 4 & 0xf));
entries[e].blue = Convert8To16(Convert4To8(texel & 0xf));
entries[e].alpha = Convert8To16(Convert3To8(texel >> 12 & 0x7));
entries[e].red = Convert4To8(texel >> 8 & 0xf);
entries[e].green = Convert4To8(texel >> 4 & 0xf);
entries[e].blue = Convert4To8(texel & 0xf);
entries[e].alpha = Convert3To8(texel >> 12 & 0x7);
}
}
break;
@ -619,7 +613,7 @@ static std::unique_ptr<uint8_t[]> ReadPalette(png_structp png, png_infop info, s
for (int i=0 ; i<paletteCount ; ++i)
{
png_sPLT_tp palette = &palettes[i];
if (!strcmp(palette->name, "GXPalette"))
if (!strncmp(palette->name, "GX_", 3))
{
if (palette->nentries > 16)
{
@ -633,12 +627,22 @@ static std::unique_ptr<uint8_t[]> ReadPalette(png_structp png, png_infop info, s
if (j < palette->nentries)
{
png_sPLT_entryp entry = &palette->entries[j];
if (palette->depth == 16)
{
*cur++ = entry->red >> 8;
*cur++ = entry->green >> 8;
*cur++ = entry->blue >> 8;
*cur++ = entry->alpha >> 8;
}
else
{
*cur++ = entry->red;
*cur++ = entry->green;
*cur++ = entry->blue;
*cur++ = entry->alpha;
}
}
else
{
*cur++ = 0;
*cur++ = 0;
@ -659,12 +663,22 @@ static std::unique_ptr<uint8_t[]> ReadPalette(png_structp png, png_infop info, s
if (j < palette->nentries)
{
png_sPLT_entryp entry = &palette->entries[j];
if (palette->depth == 16)
{
*cur++ = entry->red >> 8;
*cur++ = entry->green >> 8;
*cur++ = entry->blue >> 8;
*cur++ = entry->alpha >> 8;
}
else
{
*cur++ = entry->red;
*cur++ = entry->green;
*cur++ = entry->blue;
*cur++ = entry->alpha;
}
}
else
{
*cur++ = 0;
*cur++ = 0;

View File

@ -1296,10 +1296,11 @@ bool ANCS::Cook(const hecl::ProjectPath& outPath,
}
/* Write out ANCS */
athena::io::FileWriter w(outPath.getAbsolutePath(), true, false);
hecl::ProjectPath pathOut = inPath.ensureAuxInfo("").getCookedPath(SpecEntMP1);
athena::io::FileWriter w(pathOut.getAbsolutePath(), true, false);
if (w.hasError())
Log.report(logvisor::Fatal, _S("unable to open '%s' for writing"),
outPath.getRelativePath().c_str());
pathOut.getRelativePath().c_str());
ancs.write(w);
return true;

View File

@ -91,12 +91,10 @@ void FRME::Widget::read(athena::io::IStreamReader& __dna_reader)
basis[2] = __dna_reader.readVec3fBig();
/* rotationCenter */
rotationCenter = __dna_reader.readVec3fBig();
/* msgCount */
msgCount = __dna_reader.readInt16Big();
/* funcDefCount */
funcDefCount = __dna_reader.readInt16Big();
/* animControllerCount */
animControllerCount = __dna_reader.readInt16Big();
/* unk1 */
unk1 = __dna_reader.readInt32Big();
/* unk2 */
unk2 = __dna_reader.readInt16Big();
}
void FRME::Widget::write(athena::io::IStreamWriter& __dna_writer) const
@ -128,12 +126,10 @@ void FRME::Widget::write(athena::io::IStreamWriter& __dna_writer) const
__dna_writer.writeVec3fBig(basis[2]);
/* rotationCenter */
__dna_writer.writeVec3fBig(rotationCenter);
/* msgCount */
__dna_writer.writeInt16Big(msgCount);
/* funcDefCount */
__dna_writer.writeInt16Big(funcDefCount);
/* animControllerCount */
__dna_writer.writeInt16Big(animControllerCount);
/* unk1 */
__dna_writer.writeInt32Big(unk1);
/* unk2 */
__dna_writer.writeInt16Big(unk2);
}
size_t FRME::Widget::binarySize(size_t __isz) const

View File

@ -51,9 +51,8 @@ struct FRME : BigDNA
Value<atVec3f> origin;
Value<atVec3f> basis[3];
Value<atVec3f> rotationCenter;
Value<atInt16> msgCount;
Value<atInt16> funcDefCount;
Value<atInt16> animControllerCount;
Value<atInt32> unk1;
Value<atInt16> unk2;
struct BWIGInfo : IWidgetInfo
{

View File

@ -28,6 +28,7 @@
#include "DNAMP1/Tweaks/CTweakSlideShow.hpp"
#include "DNAMP1/Tweaks/CTweakPlayer.hpp"
#include "DNAMP1/Tweaks/CTweakCameraBob.hpp"
#include "DNAMP1/Tweaks/CTweakGame.hpp"
#include "hecl/ClientProcess.hpp"
@ -369,6 +370,8 @@ struct SpecMP1 : SpecBase
return true;
else if (!strcmp(classType, DNAMP1::CTweakCameraBob::DNAType()))
return true;
else if (!strcmp(classType, DNAMP1::CTweakGame::DNAType()))
return true;
else if (!strcmp(classType, DNAMP1::HINT::DNAType()))
return true;
else if (!strcmp(classType, "ATBL"))
@ -520,7 +523,8 @@ struct SpecMP1 : SpecBase
!strcmp(className, "DataSpec::DNAMP1::CTweakGunRes") ||
!strcmp(className, "DataSpec::DNAMP1::CTweakSlideShow") ||
!strcmp(className, "DataSpec::DNAMP1::CTweakPlayer") ||
!strcmp(className, "DataSpec::DNAMP1::CTweakCameraBob"))
!strcmp(className, "DataSpec::DNAMP1::CTweakCameraBob") ||
!strcmp(className, "DataSpec::DNAMP1::CTweakGame"))
{
resTag.type = SBIG('CTWK');
return true;
@ -729,6 +733,12 @@ struct SpecMP1 : SpecBase
cBob.read(reader);
WriteTweak(cBob, out);
}
else if (!classStr.compare(DNAMP1::CTweakGame::DNAType()))
{
DNAMP1::CTweakGame cGame;
cGame.read(reader);
WriteTweak(cGame, out);
}
else if (!classStr.compare(DNAMP1::HINT::DNAType()))
{
DNAMP1::HINT::Cook(in, out);

View File

@ -420,9 +420,6 @@ void ViewManager::stop()
{
m_videoVoice.reset();
m_projManager.shutdown();
CElementGen::Shutdown();
CMoviePlayer::Shutdown();
CLineRenderer::Shutdown();
CDvdFile::Shutdown();
m_iconsToken.doDestroy();
m_viewResources.destroyResData();

View File

@ -1,6 +1,5 @@
set(AUDIO_SOURCES
CAudioSys.hpp CAudioSys.cpp
CAudioStateWin.hpp CAudioStateWin.cpp
CAudioGroupSet.hpp CAudioGroupSet.cpp
CSfxManager.hpp CSfxManager.cpp
CStaticAudioPlayer.hpp CStaticAudioPlayer.cpp

View File

@ -199,9 +199,27 @@ std::shared_ptr<CSfxManager::CSfxWrapper>* CSfxManager::AllocateCSfxWrapper()
return nullptr;
}
void CSfxManager::StopAndRemoveAllEmitters()
{
}
void CSfxManager::DisableAuxCallbacks()
{
}
void CSfxManager::Update()
{
}
void CSfxManager::Shutdown()
{
mpSfxTranslationTable = nullptr;
mpSfxTranslationTableTok = TLockedToken<std::vector<s16>>{};
StopAndRemoveAllEmitters();
DisableAuxCallbacks();
}
}

View File

@ -164,8 +164,11 @@ public:
static u16 TranslateSFXID(u16);
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 StopAndRemoveAllEmitters();
static void DisableAuxCallbacks();
static void Update();
static void Shutdown();
private:
static std::shared_ptr<CSfxWrapper>* AllocateCSfxWrapper();

View File

@ -281,6 +281,17 @@ struct SDSPStream : boo::IAudioVoiceCallback
}
}
static void FreeAllStreams()
{
for (int i=0 ; i<4 ; ++i)
{
SDSPStream& stream = g_Streams[i];
stream.m_booVoice.reset();
stream.x0_active = false;
stream.xd4_ringBuffer.reset();
}
}
static u32 PickFreeStream(SDSPStream*& streamOut, bool oneshot)
{
for (int i=0 ; i<4 ; ++i)
@ -875,6 +886,16 @@ public:
stream = CDSPStreamManager();
}
}
static void Shutdown()
{
SDSPStream::FreeAllStreams();
for (int i=0 ; i<4 ; ++i)
{
CDSPStreamManager& stream = g_Streams[i];
stream = CDSPStreamManager();
}
}
};
CDSPStreamManager CDSPStreamManager::g_Streams[4] = {};
@ -1142,6 +1163,11 @@ void CStreamAudioManager::Initialize()
CDSPStreamManager::Initialize();
}
void CStreamAudioManager::Shutdown()
{
CDSPStreamManager::Shutdown();
}
u8 CStreamAudioManager::g_MusicVolume = 0x7f;
u8 CStreamAudioManager::g_SfxVolume = 0x7f;
bool CStreamAudioManager::g_MusicUnmute = true;

View File

@ -26,6 +26,7 @@ public:
static void TemporaryFadeOut(bool oneshot, float fadeTime);
static void Update(float dt);
static void Initialize();
static void Shutdown();
};
}

View File

@ -116,6 +116,7 @@ public:
u32 GetFileIdx() const { return x20c_saveFileIdx; }
void SetFileIdx(u32 idx) { x20c_saveFileIdx = idx; }
void SetCardSerial(u64 serial) { x210_cardSerial = serial; }
u64 GetCardSerial() const { return x210_cardSerial; }
void PutTo(CBitStreamWriter& writer) const;
float GetHardModeDamageMultiplier() const;
float GetHardModeWeaponMultiplier() const;

View File

@ -212,11 +212,19 @@ void CIOWinManager::ChangeIOWinPriority(CIOWin* toChange, int pumpPrio, int draw
void CIOWinManager::RemoveAllIOWins()
{
for (IOWinPQNode* node = x0_drawRoot ; node ; node = node->x8_next)
delete node;
for (IOWinPQNode* node = x0_drawRoot ; node ;)
{
IOWinPQNode* n = node;
node = n->x8_next;
delete n;
}
x0_drawRoot = nullptr;
for (IOWinPQNode* node = x4_pumpRoot ; node ; node = node->x8_next)
delete node;
for (IOWinPQNode* node = x4_pumpRoot ; node ;)
{
IOWinPQNode* n = node;
node = n->x8_next;
delete n;
}
x4_pumpRoot = nullptr;
}

View File

@ -32,10 +32,10 @@ public:
const TLockedToken<CStringTable>& GetWorldName() const { return x2c_worldName; }
const TLockedToken<CSaveWorld>& GetSaveWorld() const { return x3c_saveWorld; }
std::wstring GetFrontEndName() const
const wchar_t* GetFrontEndName() const
{
if (!x2c_worldName)
return {};
return L"";
return x2c_worldName->GetString(0);
}
};

View File

@ -8,11 +8,13 @@ CAuiEnergyBarT01::CAuiEnergyBarT01(const CGuiWidgetParms& parms, u32)
{
}
CAuiEnergyBarT01* CAuiEnergyBarT01::Create(CGuiFrame* frame, CInputStream& in, bool flag)
std::shared_ptr<CGuiWidget> CAuiEnergyBarT01::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
u32 a = in.readUint32Big();
return new CAuiEnergyBarT01(parms, a);
std::shared_ptr<CGuiWidget> ret = std::make_shared<CAuiEnergyBarT01>(parms, a);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}
}

View File

@ -5,12 +5,13 @@
namespace urde
{
class CSimplePool;
class CAuiEnergyBarT01 : public CGuiWidget
{
public:
CAuiEnergyBarT01(const CGuiWidgetParms& parms, u32);
static CAuiEnergyBarT01* Create(CGuiFrame* frame, CInputStream& in, bool);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
};
}

View File

@ -0,0 +1,34 @@
#include "CAuiImagePane.hpp"
namespace urde
{
CAuiImagePane::CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, ResId, ResId,
rstl::reserved_vector<zeus::CVector3f, 4>&& coords,
rstl::reserved_vector<zeus::CVector2f, 4>&& uvs, bool)
: CGuiWidget(parms)
{
}
std::shared_ptr<CGuiWidget> CAuiImagePane::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
in.readUint32Big();
in.readUint32Big();
in.readUint32Big();
u32 coordCount = in.readUint32Big();
rstl::reserved_vector<zeus::CVector3f, 4> coords;
for (int i=0 ; i<coordCount ; ++i)
coords.push_back(zeus::CVector3f::ReadBig(in));
u32 uvCount = in.readUint32Big();
rstl::reserved_vector<zeus::CVector2f, 4> uvs;
for (int i=0 ; i<uvCount ; ++i)
uvs.push_back(zeus::CVector2f::ReadBig(in));
std::shared_ptr<CGuiWidget> ret = std::make_shared<CAuiImagePane>(parms, sp, -1, -1,
std::move(coords), std::move(uvs), true);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}
}

View File

@ -5,9 +5,15 @@
namespace urde
{
class CSimplePool;
class CAuiImagePane : public CGuiWidget
{
public:
CAuiImagePane(const CGuiWidgetParms& parms, CSimplePool* sp, ResId, ResId,
rstl::reserved_vector<zeus::CVector3f, 4>&& coords,
rstl::reserved_vector<zeus::CVector2f, 4>&& uvs, bool);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
};
}

View File

@ -101,14 +101,14 @@ bool CAuiMeter::AddWorkerWidget(CGuiWidget* worker)
return true;
}
CAuiMeter* CAuiMeter::Create(CGuiFrame* frame, CInputStream& in, bool flag)
std::shared_ptr<CGuiWidget> CAuiMeter::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
in.readBool();
bool noRoundUp = in.readBool();
u32 maxCapacity = in.readUint32Big();
u32 workerCount = in.readUint32Big();
CAuiMeter* ret = new CAuiMeter(parms, noRoundUp, maxCapacity, workerCount);
std::shared_ptr<CAuiMeter> ret = std::make_shared<CAuiMeter>(parms, noRoundUp, maxCapacity, workerCount);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}

View File

@ -5,6 +5,7 @@
namespace urde
{
class CSimplePool;
class CAuiMeter : public CGuiGroup
{
@ -27,7 +28,7 @@ public:
CGuiWidget* GetWorkerWidget(int id) const;
bool AddWorkerWidget(CGuiWidget* worker);
static CAuiMeter* Create(CGuiFrame* frame, CInputStream& in, bool flag);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
};
}

View File

@ -1,32 +0,0 @@
#include "CGuiBackground.hpp"
namespace urde
{
CGuiBackground::CGuiBackground(const CGuiWidgetParms& parms, float a, float b, const zeus::CVector3f& c,
EGuiTextureClampModeHorz horz, EGuiTextureClampModeVert vert,
CGuiStaticImage::EMaterialType mt, u32 d, u32 e,
std::vector<float>&& rect, bool flag)
: CGuiStaticImage(parms, a, b, c, horz, vert, mt, d, e, std::move(rect), flag)
{
}
CGuiBackground* CGuiBackground::Create(CGuiFrame* frame, CInputStream& in, bool flag)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
float a = in.readFloatBig();
float b = in.readFloatBig();
float c = in.readFloatBig();
float d = in.readFloatBig();
std::vector<float> floats = {a, b, a, d, c, b, c, d};
zeus::CVector3f vec;
vec.readBig(in);
in.readUint32Big();
in.readUint32Big();
in.readUint32Big();
in.readUint32Big();
return nullptr;
}
}

View File

@ -1,22 +0,0 @@
#ifndef __URDE_CGUIBACKGROUND_HPP__
#define __URDE_CGUIBACKGROUND_HPP__
#include "CGuiWidget.hpp"
#include "CGuiStaticImage.hpp"
namespace urde
{
class CGuiBackground : public CGuiStaticImage
{
public:
CGuiBackground(const CGuiWidgetParms& parms, float a, float b, const zeus::CVector3f& c,
EGuiTextureClampModeHorz horz, EGuiTextureClampModeVert vert,
CGuiStaticImage::EMaterialType mt, u32 d, u32 e,
std::vector<float>&& rect, bool flag);
static CGuiBackground* Create(CGuiFrame* frame, CInputStream& in, bool);
};
}
#endif // __URDE_CGUIBACKGROUND_HPP__

View File

@ -46,11 +46,11 @@ void CGuiCamera::Draw(const CGuiWidgetDrawParms& parms) const
CGuiWidget::Draw(parms);
}
CGuiCamera* CGuiCamera::Create(CGuiFrame* frame, CInputStream& in, bool flag)
std::shared_ptr<CGuiWidget> CGuiCamera::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
EProjection proj = EProjection(in.readUint32Big());
CGuiCamera* ret = nullptr;
std::shared_ptr<CGuiCamera> ret = {};
switch (proj)
{
case EProjection::Perspective:
@ -59,7 +59,7 @@ CGuiCamera* CGuiCamera::Create(CGuiFrame* frame, CInputStream& in, bool flag)
float aspect = in.readFloatBig();
float znear = in.readFloatBig();
float zfar = in.readFloatBig();
ret = new CGuiCamera(parms, fov, aspect, znear, zfar);
ret = std::make_shared<CGuiCamera>(parms, fov, aspect, znear, zfar);
break;
}
case EProjection::Orthographic:
@ -70,12 +70,13 @@ CGuiCamera* CGuiCamera::Create(CGuiFrame* frame, CInputStream& in, bool flag)
float bottom = in.readFloatBig();
float znear = in.readFloatBig();
float zfar = in.readFloatBig();
ret = new CGuiCamera(parms, left, right, top, bottom, znear, zfar);
ret = std::make_shared<CGuiCamera>(parms, left, right, top, bottom, znear, zfar);
break;
}
break;
}
frame->SetFrameCamera(ret);
frame->SetFrameCamera(ret->shared_from_this());
ret->ParseBaseInfo(frame, in, parms);
return ret;
}

View File

@ -5,6 +5,7 @@
namespace urde
{
class CSimplePool;
class CGuiCamera : public CGuiWidget
{
@ -40,10 +41,13 @@ public:
float top, float bottom,
float znear, float zfar);
CGuiCamera(const CGuiWidgetParms& parms, float fov, float aspect, float znear, float zfar);
static CGuiCamera* Create(CGuiFrame* frame, CInputStream& in, bool flag);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
zeus::CVector3f ConvertToScreenSpace(const zeus::CVector3f& vec) const;
void Draw(const CGuiWidgetDrawParms& parms) const;
std::shared_ptr<CGuiCamera> shared_from_this()
{ return std::static_pointer_cast<CGuiCamera>(CGuiObject::shared_from_this()); }
};
}

View File

@ -38,7 +38,7 @@ CGuiWidget* CGuiFrame::FindWidget(s16 id) const
void CGuiFrame::SortDrawOrder()
{
std::sort(x2c_widgets.begin(), x2c_widgets.end(),
[](const CGuiWidget* a, const CGuiWidget* b) -> bool
[](const std::shared_ptr<CGuiWidget>& a, const std::shared_ptr<CGuiWidget>& b) -> bool
{
return a->GetWorldPosition().y < b->GetWorldPosition().y;
});
@ -50,7 +50,7 @@ void CGuiFrame::EnableLights(u32 lights) const
zeus::CColor accumColor(zeus::CColor::skBlack);
ERglLight lightId = ERglLight::Zero;
int idx = 0;
for (CGuiLight* light : x3c_lights)
for (auto& light : x3c_lights)
{
if ((lights & (1 << idx)) != 0)
{
@ -75,19 +75,19 @@ void CGuiFrame::DisableLights() const
void CGuiFrame::RemoveLight(CGuiLight* light)
{
x3c_lights[light->GetLoadedIdx()] = nullptr;
x3c_lights[light->GetLoadedIdx()].reset();
}
void CGuiFrame::AddLight(CGuiLight* light)
void CGuiFrame::AddLight(std::shared_ptr<CGuiLight>&& light)
{
x3c_lights[light->GetLoadedIdx()] = light;
x3c_lights[light->GetLoadedIdx()] = std::move(light);
}
bool CGuiFrame::GetIsFinishedLoading() const
{
if (x58_24_loaded)
return true;
for (const CGuiWidget* widget : x2c_widgets)
for (const auto& widget : x2c_widgets)
{
if (widget->GetIsFinishedLoading())
continue;
@ -99,7 +99,7 @@ bool CGuiFrame::GetIsFinishedLoading() const
void CGuiFrame::Touch() const
{
for (const CGuiWidget* widget : x2c_widgets)
for (const auto& widget : x2c_widgets)
widget->Touch();
}
@ -120,7 +120,7 @@ void CGuiFrame::Draw(const CGuiWidgetDrawParms& parms) const
CGraphics::SetBlendMode(ERglBlendMode::Blend, ERglBlendFactor::SrcAlpha,
ERglBlendFactor::InvSrcAlpha, ERglLogicOp::Clear);
for (const CGuiWidget* widget : x2c_widgets)
for (const auto& widget : x2c_widgets)
if (widget->GetIsVisible())
widget->Draw(parms);
}
@ -134,7 +134,7 @@ void CGuiFrame::Initialize()
xc_headWidget->DispatchInitialize();
}
void CGuiFrame::LoadWidgetsInGame(CInputStream& in)
void CGuiFrame::LoadWidgetsInGame(CInputStream& in, CSimplePool* sp)
{
u32 count = in.readUint32Big();
x2c_widgets.reserve(count);
@ -142,7 +142,7 @@ void CGuiFrame::LoadWidgetsInGame(CInputStream& in)
{
DataSpec::DNAFourCC type;
type.read(in);
CGuiWidget* widget = CGuiSys::CreateWidgetInGame(type, in, this);
std::shared_ptr<CGuiWidget> widget = CGuiSys::CreateWidgetInGame(type, in, this, sp);
type = widget->GetWidgetTypeID();
switch (type)
{
@ -151,7 +151,7 @@ void CGuiFrame::LoadWidgetsInGame(CInputStream& in)
case SBIG('BGND'):
break;
default:
x2c_widgets.push_back(widget);
x2c_widgets.push_back(std::move(widget));
break;
}
}
@ -162,22 +162,22 @@ void CGuiFrame::ProcessUserInput(const CFinalInput& input) const
{
if (x4_)
return;
for (CGuiWidget* widget : x2c_widgets)
for (auto& widget : x2c_widgets)
{
if (widget->GetIsActive())
widget->ProcessUserInput(input);
}
}
CGuiFrame* CGuiFrame::CreateFrame(ResId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp)
std::unique_ptr<CGuiFrame> CGuiFrame::CreateFrame(ResId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp)
{
in.readInt32Big();
int a = in.readInt32Big();
int b = in.readInt32Big();
int c = in.readInt32Big();
CGuiFrame* ret = new CGuiFrame(frmeId, sys, a, b, c, sp);
ret->LoadWidgetsInGame(in);
std::unique_ptr<CGuiFrame> ret = std::make_unique<CGuiFrame>(frmeId, sys, a, b, c, sp);
ret->LoadWidgetsInGame(in, sp);
return ret;
}

View File

@ -23,12 +23,12 @@ private:
ResId x0_id;
u32 x4_ = 0;
CGuiSys& x8_guiSys;
CGuiHeadWidget* xc_headWidget = nullptr;
std::unique_ptr<CGuiWidget> x10_rootWidget;
CGuiCamera* x14_camera = nullptr;
std::shared_ptr<CGuiHeadWidget> xc_headWidget;
std::shared_ptr<CGuiWidget> x10_rootWidget;
std::shared_ptr<CGuiCamera> x14_camera;
CGuiWidgetIdDB x18_idDB;
std::vector<CGuiWidget*> x2c_widgets;
std::vector<CGuiLight*> x3c_lights;
std::vector<std::shared_ptr<CGuiWidget>> x2c_widgets;
std::vector<std::shared_ptr<CGuiLight>> x3c_lights;
int x4c_a;
int x50_b;
int x54_c;
@ -39,28 +39,28 @@ public:
CGuiSys& GetGuiSys() {return x8_guiSys;}
CGuiLight* GetFrameLight(int idx) {return x3c_lights[idx];}
CGuiLight* GetFrameLight(int idx) const { return x3c_lights[idx].get(); }
CGuiWidget* FindWidget(const std::string& name) const;
CGuiWidget* FindWidget(s16 id) const;
void SetFrameCamera(CGuiCamera* camr) {x14_camera = camr;}
void SetHeadWidget(CGuiHeadWidget* hwig) {xc_headWidget = hwig;}
void SetFrameCamera(std::shared_ptr<CGuiCamera>&& camr) { x14_camera = std::move(camr); }
void SetHeadWidget(std::shared_ptr<CGuiHeadWidget>&& hwig) { xc_headWidget = std::move(hwig); }
void SortDrawOrder();
void EnableLights(u32 lights) const;
void DisableLights() const;
void RemoveLight(CGuiLight* light);
void AddLight(CGuiLight* light);
void AddLight(std::shared_ptr<CGuiLight>&& light);
bool GetIsFinishedLoading() const;
void Touch() const;
void Update(float dt);
void Draw(const CGuiWidgetDrawParms& parms) const;
void Initialize();
void LoadWidgetsInGame(CInputStream& in);
void LoadWidgetsInGame(CInputStream& in, CSimplePool* sp);
void ProcessUserInput(const CFinalInput& input) const;
CGuiWidgetIdDB& GetWidgetIdDB() {return x18_idDB;}
static CGuiFrame* CreateFrame(ResId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp);
static std::unique_ptr<CGuiFrame> CreateFrame(ResId frmeId, CGuiSys& sys, CInputStream& in, CSimplePool* sp);
};
std::unique_ptr<IObj> RGuiFrameFactoryInGame(const SObjectTag& tag, CInputStream& in,

View File

@ -54,12 +54,12 @@ void CGuiGroup::OnActiveChange()
sel->SetIsActive(true);
}
CGuiGroup* CGuiGroup::Create(CGuiFrame* frame, CInputStream& in, bool flag)
std::shared_ptr<CGuiWidget> CGuiGroup::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
s16 defaultWorker = in.readInt16Big();
bool b = in.readBool();
CGuiGroup* ret = new CGuiGroup(parms, defaultWorker, b);
std::shared_ptr<CGuiWidget> ret = std::make_shared<CGuiGroup>(parms, defaultWorker, b);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}

View File

@ -20,7 +20,7 @@ public:
bool AddWorkerWidget(CGuiWidget* worker);
void OnActiveChange();
static CGuiGroup* Create(CGuiFrame* frame, CInputStream& in, bool flag);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
static void LoadWidgetFnMap();
};

View File

@ -7,11 +7,11 @@ namespace urde
CGuiHeadWidget::CGuiHeadWidget(const CGuiWidgetParms& parms)
: CGuiWidget(parms) {}
CGuiHeadWidget* CGuiHeadWidget::Create(CGuiFrame* frame, CInputStream& in, bool flag)
std::shared_ptr<CGuiWidget> CGuiHeadWidget::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
CGuiHeadWidget* ret = new CGuiHeadWidget(parms);
frame->SetHeadWidget(ret);
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
std::shared_ptr<CGuiHeadWidget> ret = std::make_shared<CGuiHeadWidget>(parms);
frame->SetHeadWidget(ret->shared_from_this());
ret->ParseBaseInfo(frame, in, parms);
return ret;
}

View File

@ -11,7 +11,10 @@ class CGuiHeadWidget : public CGuiWidget
public:
FourCC GetWidgetTypeID() const {return FOURCC('HWIG');}
CGuiHeadWidget(const CGuiWidgetParms& parms);
static CGuiHeadWidget* Create(CGuiFrame* frame, CInputStream& in, bool);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
std::shared_ptr<CGuiHeadWidget> shared_from_this()
{ return std::static_pointer_cast<CGuiHeadWidget>(CGuiObject::shared_from_this()); }
};
}

View File

@ -48,15 +48,15 @@ CLight CGuiLight::BuildLight() const
void CGuiLight::SetIsVisible(bool vis)
{
if (vis)
xb0_frame->AddLight(this);
xb0_frame->AddLight(shared_from_this());
else
xb0_frame->RemoveLight(this);
CGuiWidget::SetIsVisible(vis);
}
CGuiLight* CGuiLight::Create(CGuiFrame* frame, CInputStream& in, bool flag)
std::shared_ptr<CGuiWidget> CGuiLight::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
ELightType tp = ELightType(in.readUint32Big());
float distC = in.readFloatBig();
@ -67,7 +67,7 @@ CGuiLight* CGuiLight::Create(CGuiFrame* frame, CInputStream& in, bool flag)
float angQ = in.readFloatBig();
u32 loadedIdx = in.readUint32Big();
CGuiLight* ret = nullptr;
std::shared_ptr<CGuiLight> ret = {};
switch (tp)
{
case ELightType::Spot:
@ -78,7 +78,7 @@ CGuiLight* CGuiLight::Create(CGuiFrame* frame, CInputStream& in, bool flag)
lt.SetAttenuation(distC, distL, distQ);
lt.SetAngleAttenuation(angC, angL, angQ);
lt.x40_loadedIdx = loadedIdx;
ret = new CGuiLight(parms, lt);
ret = std::make_shared<CGuiLight>(parms, lt);
break;
}
case ELightType::Point:
@ -86,21 +86,21 @@ CGuiLight* CGuiLight::Create(CGuiFrame* frame, CInputStream& in, bool flag)
CLight lt = CLight::BuildPoint(zeus::CVector3f::skZero, parms.x10_color);
lt.SetAttenuation(distC, distL, distQ);
lt.x40_loadedIdx = loadedIdx;
ret = new CGuiLight(parms, lt);
ret = std::make_shared<CGuiLight>(parms, lt);
break;
}
case ELightType::Directional:
{
CLight lt = CLight::BuildDirectional(zeus::CVector3f::skZero, parms.x10_color);
lt.x40_loadedIdx = loadedIdx;
ret = new CGuiLight(parms, lt);
ret = std::make_shared<CGuiLight>(parms, lt);
break;
}
default: break;
}
ret->ParseBaseInfo(frame, in, parms);
frame->AddLight(ret);
frame->AddLight(ret->shared_from_this());
return ret;
}

View File

@ -6,6 +6,7 @@
namespace urde
{
class CSimplePool;
class CGuiLight : public CGuiWidget
{
@ -29,7 +30,10 @@ public:
u32 GetLoadedIdx() const {return x118_loadedIdx;}
const zeus::CColor& GetColor() const {return x11c_color;}
static CGuiLight* Create(CGuiFrame* frame, CInputStream& in, bool);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
std::shared_ptr<CGuiLight> shared_from_this()
{ return std::static_pointer_cast<CGuiLight>(CGuiObject::shared_from_this()); }
};
}

View File

@ -8,14 +8,14 @@
namespace urde
{
CGuiModel::CGuiModel(const CGuiWidgetParms& parms, ResId modelId, u32 lightMask, bool flag)
CGuiModel::CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, ResId modelId, u32 lightMask, bool flag)
: CGuiWidget(parms), x108_modelId(modelId), x10c_lightMask(lightMask)
{
if (!flag || (modelId & 0xffff) == 0xffff ||
parms.x0_frame->GetGuiSys().GetUsageMode() == CGuiSys::EUsageMode::Two)
return;
xf8_model = parms.x0_frame->GetGuiSys().GetResStore().GetObj({SBIG('CMDL'), modelId});
xf8_model = sp->GetObj({SBIG('CMDL'), modelId});
}
std::vector<ResId> CGuiModel::GetModelAssets() const
@ -109,15 +109,15 @@ void CGuiModel::Draw(const CGuiWidgetDrawParms& parms) const
CGuiWidget::Draw(parms);
}
CGuiModel* CGuiModel::Create(CGuiFrame* frame, CInputStream& in, bool flag)
std::shared_ptr<CGuiWidget> CGuiModel::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
ResId model = in.readUint32Big();
in.readUint32Big();
u32 lightMask = in.readUint32Big();
CGuiModel* ret = new CGuiModel(parms, model, lightMask, flag);
std::shared_ptr<CGuiWidget> ret = std::make_shared<CGuiModel>(parms, sp, model, lightMask, true);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}

View File

@ -7,6 +7,7 @@
namespace urde
{
class CSimplePool;
class CGuiModel : public CGuiWidget
{
@ -14,7 +15,7 @@ class CGuiModel : public CGuiWidget
ResId x108_modelId;
u32 x10c_lightMask;
public:
CGuiModel(const CGuiWidgetParms& parms, ResId modelId, u32 lightMask, bool flag);
CGuiModel(const CGuiWidgetParms& parms, CSimplePool* sp, ResId modelId, u32 lightMask, bool flag);
FourCC GetWidgetTypeID() const {return FOURCC('MODL');}
std::vector<ResId> GetModelAssets() const;
@ -22,7 +23,7 @@ public:
void Touch() const;
void Draw(const CGuiWidgetDrawParms& parms) const;
static CGuiModel* Create(CGuiFrame* frame, CInputStream& in, bool);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
};
}

View File

@ -5,32 +5,26 @@
namespace urde
{
CGuiObject::~CGuiObject()
{
delete x74_child;
delete x78_nextSibling;
}
void CGuiObject::Update(float dt)
{
if (x74_child)
x74_child->Update(dt);
if (x78_nextSibling)
x78_nextSibling->Update(dt);
if (x68_child)
x68_child->Update(dt);
if (x6c_nextSibling)
x6c_nextSibling->Update(dt);
}
void CGuiObject::Draw(const CGuiWidgetDrawParms& parms) const
{
if (x74_child)
x74_child->Draw(parms);
if (x78_nextSibling)
x78_nextSibling->Draw(parms);
if (x68_child)
x68_child->Draw(parms);
if (x6c_nextSibling)
x6c_nextSibling->Draw(parms);
}
void CGuiObject::MoveInWorld(const zeus::CVector3f& vec)
{
if (x70_parent)
x70_parent->RotateW2O(vec);
if (x64_parent)
x64_parent->RotateW2O(vec);
x4_localXF.origin += vec;
Reorthogonalize();
RecalculateTransforms();
@ -65,33 +59,31 @@ zeus::CVector3f CGuiObject::RotateTranslateW2O(const zeus::CVector3f& vec) const
void CGuiObject::MultiplyO2P(const zeus::CTransform& xf)
{
x4_localXF.origin += x64_rotationCenter;
x4_localXF = xf * x4_localXF;
x4_localXF.origin -= x64_rotationCenter;
Reorthogonalize();
RecalculateTransforms();
}
void CGuiObject::AddChildObject(CGuiObject* obj, bool makeWorldLocal, bool atEnd)
{
obj->x70_parent = this;
obj->x64_parent = this;
if (!x74_child)
if (!x68_child)
{
x74_child = obj;
x68_child = obj;
}
else if (atEnd)
{
CGuiObject* prev = nullptr;
CGuiObject* cur = x74_child;
for (; cur ; cur = cur->x78_nextSibling) {prev = cur;}
CGuiObject* cur = x68_child;
for (; cur ; cur = cur->x6c_nextSibling) {prev = cur;}
if (prev)
prev->x78_nextSibling = obj;
prev->x6c_nextSibling = obj;
}
else
{
obj->x78_nextSibling = x74_child;
x74_child = obj;
obj->x6c_nextSibling = x68_child;
x68_child = obj;
}
if (makeWorldLocal)
@ -111,14 +103,14 @@ void CGuiObject::AddChildObject(CGuiObject* obj, bool makeWorldLocal, bool atEnd
CGuiObject* CGuiObject::RemoveChildObject(CGuiObject* obj, bool makeWorldLocal)
{
CGuiObject* prev = nullptr;
CGuiObject* cur = x74_child;
for (; cur && cur != obj ; cur = cur->x78_nextSibling) {prev = cur;}
CGuiObject* cur = x68_child;
for (; cur && cur != obj ; cur = cur->x6c_nextSibling) {prev = cur;}
if (!cur)
return nullptr;
if (prev)
prev->x78_nextSibling = cur->x78_nextSibling;
cur->x78_nextSibling = nullptr;
cur->x70_parent = nullptr;
prev->x6c_nextSibling = cur->x6c_nextSibling;
cur->x6c_nextSibling = nullptr;
cur->x64_parent = nullptr;
if (makeWorldLocal)
cur->x4_localXF = cur->x34_worldXF;
@ -129,22 +121,15 @@ CGuiObject* CGuiObject::RemoveChildObject(CGuiObject* obj, bool makeWorldLocal)
void CGuiObject::RecalculateTransforms()
{
if (x70_parent)
{
x4_localXF.origin += x64_rotationCenter;
x34_worldXF = x70_parent->x34_worldXF * x4_localXF;
x4_localXF.origin -= x64_rotationCenter;
x34_worldXF.origin -= x64_rotationCenter;
}
if (x64_parent)
x34_worldXF = x64_parent->x34_worldXF * x4_localXF;
else
{
x34_worldXF = x4_localXF;
}
if (x78_nextSibling)
x78_nextSibling->RecalculateTransforms();
if (x74_child)
x74_child->RecalculateTransforms();
if (x6c_nextSibling)
x6c_nextSibling->RecalculateTransforms();
if (x68_child)
x68_child->RecalculateTransforms();
}
void CGuiObject::Reorthogonalize()

View File

@ -10,17 +10,16 @@ namespace urde
{
struct CGuiWidgetDrawParms;
class CGuiObject
class CGuiObject : public std::enable_shared_from_this<CGuiObject>
{
protected:
zeus::CTransform x4_localXF;
zeus::CTransform x34_worldXF;
zeus::CVector3f x64_rotationCenter;
CGuiObject* x70_parent = nullptr;
CGuiObject* x74_child = nullptr;
CGuiObject* x78_nextSibling = nullptr;
CGuiObject* x64_parent = nullptr;
CGuiObject* x68_child = nullptr;
CGuiObject* x6c_nextSibling = nullptr;
public:
virtual ~CGuiObject();
virtual ~CGuiObject() = default;
virtual void Update(float dt);
virtual void Draw(const CGuiWidgetDrawParms& parms) const;
virtual void Initialize()=0;
@ -29,7 +28,6 @@ public:
const zeus::CVector3f& GetLocalPosition() const { return x4_localXF.origin; }
void SetLocalPosition(const zeus::CVector3f& pos);
const zeus::CVector3f& GetWorldPosition() const { return x34_worldXF.origin; }
void SetRotationCenter(const zeus::CVector3f& center) {x64_rotationCenter = center;}
void RotateReset();
zeus::CVector3f RotateW2O(const zeus::CVector3f& vec) const;
zeus::CVector3f RotateO2P(const zeus::CVector3f& vec) const;
@ -37,9 +35,9 @@ public:
void MultiplyO2P(const zeus::CTransform& xf);
void AddChildObject(CGuiObject* obj, bool makeWorldLocal, bool atEnd);
CGuiObject* RemoveChildObject(CGuiObject* obj, bool makeWorldLocal);
CGuiObject* GetParent() const {return x70_parent;}
CGuiObject* GetChildObject() const {return x74_child;}
CGuiObject* GetNextSibling() const {return x78_nextSibling;}
CGuiObject* GetParent() const { return x64_parent; }
CGuiObject* GetChildObject() const { return x68_child; }
CGuiObject* GetNextSibling() const { return x6c_nextSibling; }
void RecalculateTransforms();
void Reorthogonalize();
void SetO2WTransform(const zeus::CTransform& xf);

View File

@ -3,9 +3,9 @@
namespace urde
{
CGuiPane::CGuiPane(const CGuiWidgetParms& parms, float xDim, float zDim,
CGuiPane::CGuiPane(const CGuiWidgetParms& parms, const zeus::CVector2f& dim,
const zeus::CVector3f& scaleCenter)
: CGuiWidget(parms), xf8_xDim(xDim), xfc_zDim(zDim), x108_scaleCenter(scaleCenter)
: CGuiWidget(parms), xb8_dim(dim), x108_scaleCenter(scaleCenter)
{
InitializeBuffers();
}
@ -24,15 +24,14 @@ void CGuiPane::ScaleDimensions(const zeus::CVector3f& scale)
void CGuiPane::SetDimensions(const zeus::CVector2f& dim, bool initVBO)
{
xf8_xDim = dim.x;
xfc_zDim = dim.y;
xb8_dim = dim;
if (initVBO)
InitializeBuffers();
}
zeus::CVector2f CGuiPane::GetDimensions() const
{
return {xf8_xDim, xfc_zDim};
return xb8_dim;
}
void CGuiPane::InitializeBuffers()
@ -40,24 +39,24 @@ void CGuiPane::InitializeBuffers()
if (x100_verts.size() < 4)
x100_verts.resize(4);
x100_verts[0].m_pos.assign(-xf8_xDim * 0.5f, 0.f, xfc_zDim * 0.5f);
x100_verts[1].m_pos.assign(-xf8_xDim * 0.5f, 0.f, -xfc_zDim * 0.5f);
x100_verts[2].m_pos.assign(xf8_xDim * 0.5f, 0.f, xfc_zDim * 0.5f);
x100_verts[3].m_pos.assign(xf8_xDim * 0.5f, 0.f, -xfc_zDim * 0.5f);
x100_verts[0].m_pos.assign(-xb8_dim.x * 0.5f, 0.f, xb8_dim.y * 0.5f);
x100_verts[1].m_pos.assign(-xb8_dim.x * 0.5f, 0.f, -xb8_dim.y * 0.5f);
x100_verts[2].m_pos.assign(xb8_dim.x * 0.5f, 0.f, xb8_dim.y * 0.5f);
x100_verts[3].m_pos.assign(xb8_dim.x * 0.5f, 0.f, -xb8_dim.y * 0.5f);
}
void CGuiPane::WriteData(COutputStream& out, bool flag) const
{
}
CGuiPane* CGuiPane::Create(CGuiFrame* frame, CInputStream& in, bool flag)
std::shared_ptr<CGuiWidget> CGuiPane::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
float x = in.readFloatBig();
float z = in.readFloatBig();
zeus::CVector3f scaleCenter;
scaleCenter.readBig(in);
return new CGuiPane(parms, x, z, scaleCenter);
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
zeus::CVector2f dim = zeus::CVector2f::ReadBig(in);
zeus::CVector3f scaleCenter = zeus::CVector3f::ReadBig(in);
std::shared_ptr<CGuiWidget> ret = std::make_shared<CGuiPane>(parms, dim, scaleCenter);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}
}

View File

@ -10,8 +10,7 @@ namespace urde
class CGuiPane : public CGuiWidget
{
protected:
float xf8_xDim;
float xfc_zDim;
zeus::CVector2f xb8_dim;
/* Originally a vert-buffer pointer for GX */
std::vector<specter::View::TexShaderVert> x100_verts;
@ -20,7 +19,7 @@ protected:
zeus::CVector3f x108_scaleCenter;
public:
CGuiPane(const CGuiWidgetParms& parms, float xDim, float zDim, const zeus::CVector3f& scaleCenter);
CGuiPane(const CGuiWidgetParms& parms, const zeus::CVector2f& dim, const zeus::CVector3f& scaleCenter);
FourCC GetWidgetTypeID() const {return FOURCC('PANE');}
virtual void ScaleDimensions(const zeus::CVector3f& scale);
@ -29,7 +28,7 @@ public:
virtual void InitializeBuffers();
virtual void WriteData(COutputStream& out, bool flag) const;
static CGuiPane* Create(CGuiFrame* frame, CInputStream& in, bool);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
};
}

View File

@ -125,16 +125,16 @@ CGuiWidget* CGuiSliderGroup::GetWorkerWidget(int id)
return xcc_sliderRangeWidgets[id];
}
CGuiSliderGroup* CGuiSliderGroup::Create(CGuiFrame* frame, CInputStream& in, bool flag)
std::shared_ptr<CGuiWidget> CGuiSliderGroup::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
float min = in.readFloatBig();
float max = in.readFloatBig();
float cur = in.readFloatBig();
float increment = in.readFloatBig();
CGuiSliderGroup* ret = new CGuiSliderGroup(parms, min, max, cur, increment);
std::shared_ptr<CGuiWidget> ret = std::make_shared<CGuiSliderGroup>(parms, min, max, cur, increment);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}

View File

@ -6,6 +6,7 @@
namespace urde
{
class CSimplePool;
class CGuiSliderGroup : public CGuiCompoundWidget
{
@ -55,7 +56,7 @@ public:
bool AddWorkerWidget(CGuiWidget* worker);
CGuiWidget* GetWorkerWidget(int id);
static CGuiSliderGroup* Create(CGuiFrame* frame, CInputStream& in, bool flag);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
};
}

View File

@ -1,164 +0,0 @@
#include "CGuiStaticImage.hpp"
#include "CGuiFrame.hpp"
#include "CGuiSys.hpp"
#include "CSimplePool.hpp"
#include "Graphics/CGraphics.hpp"
#include "Graphics/CTexture.hpp"
namespace urde
{
CGuiStaticImage::CGuiStaticImage
(const CGuiWidgetParms& parms, float xDim, float zDim,
const zeus::CVector3f& scaleCenter,
EGuiTextureClampModeHorz clampH, EGuiTextureClampModeVert clampV,
CGuiStaticImage::EMaterialType matType, ResId txtrId1, ResId txtrId2,
const std::vector<float>& frame, bool useTexture)
: CGuiPane(parms, xDim, zDim, scaleCenter),
x114_materialType(matType),
x120_textureID1(txtrId1),
x124_textureID2(txtrId2),
x128_clampH(clampH),
x12c_clampV(clampV),
x130_clampedUVs(frame),
x140_UVs(frame)
{
CGuiSys& guiSys = parms.x0_frame->GetGuiSys();
if (useTexture && guiSys.GetUsageMode() != CGuiSys::EUsageMode::Two)
{
if ((txtrId1 & 0xffff) != 0xffff)
x118_texture1 = guiSys.GetResStore().GetObj({SBIG('TXTR'), txtrId1});
if ((txtrId2 & 0xffff) != 0xffff)
x11c_texture2 = guiSys.GetResStore().GetObj({SBIG('TXTR'), txtrId2});
}
SetDimensions({xDim, zDim}, true);
}
void CGuiStaticImage::ScaleDimensions(const zeus::CVector3f& scale)
{
CGuiPane::ScaleDimensions(scale);
zeus::CVector2f dim = GetDimensions();
float resH1 = x140_UVs[4];
float resH0 = x140_UVs[0];
float resV1 = x140_UVs[3];
float resV0 = x140_UVs[1];
float f3 = resH1 - resH0;
float f1 = std::fabs(x100_verts[2].m_pos.x - x100_verts[0].m_pos.x) - dim.x;
switch (x128_clampH)
{
case EGuiTextureClampModeHorz::Right:
resH1 += f3 * f1 / dim.x;
break;
case EGuiTextureClampModeHorz::Left:
resH0 -= f3 * f1 / dim.x;
break;
case EGuiTextureClampModeHorz::Center:
resH1 += f3 * f1 * 0.5f / dim.x;
resH0 -= f3 * f1 * 0.5f / dim.x;
break;
default: break;
}
f3 = resV1 - resV0;
f1 = std::fabs(x100_verts[0].m_pos.z - x100_verts[1].m_pos.z) - dim.y;
switch (x12c_clampV)
{
case EGuiTextureClampModeVert::Top:
resV0 -= f3 * f1 / dim.y;
break;
case EGuiTextureClampModeVert::Bottom:
resV1 += f3 * f1 / dim.y;
break;
case EGuiTextureClampModeVert::Center:
resV1 += f3 * f1 * 0.5f / dim.y;
resV0 -= f3 * f1 * 0.5f / dim.y;
break;
default: break;
}
x130_clampedUVs[0] = resH0;
x130_clampedUVs[1] = resV0;
x130_clampedUVs[2] = resH0;
x130_clampedUVs[3] = resV1;
x130_clampedUVs[4] = resH1;
x130_clampedUVs[5] = resV0;
x130_clampedUVs[6] = resH1;
x130_clampedUVs[7] = resV1;
}
void CGuiStaticImage::Draw(const CGuiWidgetDrawParms& parms) const
{
CGraphics::SetModelMatrix(x34_worldXF * zeus::CTransform::Translate(x108_scaleCenter));
if (GetIsVisible())
{
switch (x114_materialType)
{
case EMaterialType::OneTexture:
x118_texture1->Load(0, CTexture::EClampMode::One);
break;
case EMaterialType::TwoTextures:
x118_texture1->Load(0, CTexture::EClampMode::One);
x11c_texture2->Load(1, CTexture::EClampMode::One);
break;
default: return;
}
CGraphics::SetBlendMode(ERglBlendMode::Blend,
ERglBlendFactor::SrcAlpha,
ERglBlendFactor::InvSrcAlpha,
ERglLogicOp::Clear);
/* Begin tri-strip of verts in x100_verts */
/* Vtx Color xb4_ */
/* UVs x130_clampedUVs[0], x130_clampedUVs[3] */
/* UVs x130_clampedUVs[2], x130_clampedUVs[1] */
/* UVs x130_clampedUVs[4], x130_clampedUVs[7] */
/* UVs x130_clampedUVs[6], x130_clampedUVs[5] */
}
CGuiWidget::Draw(parms);
}
std::vector<ResId> CGuiStaticImage::GetTextureAssets() const
{
std::vector<ResId> ret;
ret.reserve(2);
if ((x120_textureID1 & 0xffff) != 0xffff)
ret.push_back(x120_textureID1);
if ((x124_textureID2 & 0xffff) != 0xffff)
ret.push_back(x124_textureID2);
return ret;
}
CGuiStaticImage* CGuiStaticImage::Create(CGuiFrame* frame, CInputStream& in, bool flag)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
float xDim = in.readFloatBig();
float zDim = in.readFloatBig();
zeus::CVector3f scaleCenter;
scaleCenter.readBig(in);
CGuiStaticImage::EMaterialType matType = CGuiStaticImage::EMaterialType(in.readUint32Big());
ResId txtr1 = in.readUint32Big();
ResId txtr2 = in.readUint32Big();
EGuiTextureClampModeHorz clampH = EGuiTextureClampModeHorz(in.readUint32Big());
EGuiTextureClampModeVert clampV = EGuiTextureClampModeVert(in.readUint32Big());
float a = in.readFloatBig();
float b = in.readFloatBig();
float c = in.readFloatBig();
float d = in.readFloatBig();
std::vector<float> floats = {a, b, a, d, c, b, c, d};
CGuiStaticImage* ret = new CGuiStaticImage(parms, xDim, zDim, scaleCenter, clampH, clampV,
matType, txtr1, txtr2, floats, true);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}
}

View File

@ -1,46 +0,0 @@
#ifndef __URDE_CGUISTATICIMAGE_HPP__
#define __URDE_CGUISTATICIMAGE_HPP__
#include "CGuiPane.hpp"
#include "CToken.hpp"
namespace urde
{
class CTexture;
class CGuiStaticImage : public CGuiPane
{
public:
enum class EMaterialType
{
OneTexture = 0,
TwoTextures = 1
};
private:
EMaterialType x114_materialType;
TLockedToken<CTexture> x118_texture1;
TLockedToken<CTexture> x11c_texture2;
ResId x120_textureID1;
ResId x124_textureID2;
EGuiTextureClampModeHorz x128_clampH;
EGuiTextureClampModeVert x12c_clampV;
std::vector<float> x130_clampedUVs;
std::vector<float> x140_UVs;
public:
CGuiStaticImage(const CGuiWidgetParms& parms, float xDim, float zDim,
const zeus::CVector3f& scaleCenter,
EGuiTextureClampModeHorz clampH, EGuiTextureClampModeVert clampV,
CGuiStaticImage::EMaterialType matType, ResId txtrId1, ResId txtrId2,
const std::vector<float>& frame, bool useTexture);
FourCC GetWidgetTypeID() const {return FOURCC('IMAG');}
void ScaleDimensions(const zeus::CVector3f& scale);
void Draw(const CGuiWidgetDrawParms& parms) const;
std::vector<ResId> GetTextureAssets() const;
static CGuiStaticImage* Create(CGuiFrame* frame, CInputStream& in, bool flag);
};
}
#endif // __URDE_CGUISTATICIMAGE_HPP__

View File

@ -1,11 +1,9 @@
#include "CGuiSys.hpp"
#include "CGuiWidget.hpp"
#include "CGuiHeadWidget.hpp"
#include "CGuiBackground.hpp"
#include "CGuiLight.hpp"
#include "CGuiCamera.hpp"
#include "CGuiGroup.hpp"
#include "CGuiStaticImage.hpp"
#include "CGuiPane.hpp"
#include "CAuiImagePane.hpp"
#include "CAuiMeter.hpp"
@ -25,43 +23,40 @@ CGuiSys* g_GuiSys = nullptr;
CTextExecuteBuffer* g_TextExecuteBuf = nullptr;
CTextParser* g_TextParser = nullptr;
CGuiWidget* CGuiSys::CreateWidgetInGame(FourCC type, CInputStream& in, CGuiFrame* frame)
std::shared_ptr<CGuiWidget> CGuiSys::CreateWidgetInGame(FourCC type, CInputStream& in,
CGuiFrame* frame, CSimplePool* sp)
{
switch (type)
{
case SBIG('BWIG'):
return CGuiWidget::Create(frame, in, false);
return CGuiWidget::Create(frame, in, sp);
case SBIG('HWIG'):
return CGuiHeadWidget::Create(frame, in, false);
case SBIG('BGND'):
return CGuiBackground::Create(frame, in, false);
return CGuiHeadWidget::Create(frame, in, sp);
case SBIG('LITE'):
return CGuiLight::Create(frame, in, false);
return CGuiLight::Create(frame, in, sp);
case SBIG('CAMR'):
return CGuiCamera::Create(frame, in, false);
return CGuiCamera::Create(frame, in, sp);
case SBIG('GRUP'):
return CGuiGroup::Create(frame, in, false);
case SBIG('IMAG'):
return CGuiStaticImage::Create(frame, in, false);
return CGuiGroup::Create(frame, in, sp);
case SBIG('PANE'):
return CGuiPane::Create(frame, in, false);
return CGuiPane::Create(frame, in, sp);
case SBIG('IMGP'):
return CAuiImagePane::Create(frame, in, false);
return CAuiImagePane::Create(frame, in, sp);
case SBIG('METR'):
return CAuiMeter::Create(frame, in, false);
return CAuiMeter::Create(frame, in, sp);
case SBIG('MODL'):
return CGuiModel::Create(frame, in, false);
return CGuiModel::Create(frame, in, sp);
case SBIG('TBGP'):
return CGuiTableGroup::Create(frame, in, false);
return CGuiTableGroup::Create(frame, in, sp);
case SBIG('SLGP'):
return CGuiSliderGroup::Create(frame, in, false);
return CGuiSliderGroup::Create(frame, in, sp);
case SBIG('TXPN'):
return CGuiTextPane::Create(frame, in, false);
return CGuiTextPane::Create(frame, in, sp);
case SBIG('ENRG'):
return CAuiEnergyBarT01::Create(frame, in, false);
return CAuiEnergyBarT01::Create(frame, in, sp);
default: break;
}
return nullptr;
return {};
}
CGuiSys::CGuiSys(IFactory& resFactory, CSimplePool& resStore, EUsageMode mode)

View File

@ -37,7 +37,8 @@ private:
std::unique_ptr<CTextExecuteBuffer> xc_textExecuteBuf;
std::unique_ptr<CTextParser> x10_textParser;
static CGuiWidget* CreateWidgetInGame(FourCC type, CInputStream& in, CGuiFrame* frame);
static std::shared_ptr<CGuiWidget> CreateWidgetInGame(FourCC type, CInputStream& in,
CGuiFrame* frame, CSimplePool* sp);
public:
CGuiSys(IFactory& resFactory, CSimplePool& resStore, EUsageMode mode);

View File

@ -240,9 +240,9 @@ void CGuiTableGroup::DoIncrement()
x104_doMenuSelChange(this, xc4_userSelection);
}
CGuiTableGroup* CGuiTableGroup::Create(CGuiFrame* frame, CInputStream& in, bool flag)
std::shared_ptr<CGuiWidget> CGuiTableGroup::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
int elementCount = in.readInt16Big();
in.readInt16Big();
@ -260,7 +260,7 @@ CGuiTableGroup* CGuiTableGroup::Create(CGuiFrame* frame, CInputStream& in, bool
in.readInt16Big();
in.readInt16Big();
CGuiTableGroup* ret = new CGuiTableGroup(parms, elementCount, defaultSel, selectWraparound);
std::shared_ptr<CGuiWidget> ret = std::make_shared<CGuiTableGroup>(parms, elementCount, defaultSel, selectWraparound);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}

View File

@ -96,7 +96,9 @@ public:
void ProcessUserInput(const CFinalInput& input);
static CGuiTableGroup* Create(CGuiFrame* frame, CInputStream& in, bool);
bool AddWorkerWidget(CGuiWidget* worker) { return true; }
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
};
}

View File

@ -9,13 +9,12 @@
namespace urde
{
CGuiTextPane::CGuiTextPane(const CGuiWidgetParms& parms, float xDim, float zDim,
CGuiTextPane::CGuiTextPane(const CGuiWidgetParms& parms, CSimplePool* sp, const zeus::CVector2f& dim,
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), xd4_textSupport(fontId, props, fontCol, outlineCol,
zeus::CColor::skWhite, extentX, extentY,
&parms.x0_frame->GetGuiSys().GetResStore()) {}
: CGuiPane(parms, dim, vec), xd4_textSupport(fontId, props, fontCol, outlineCol,
zeus::CColor::skWhite, extentX, extentY, sp) {}
void CGuiTextPane::Update(float dt)
{
@ -98,13 +97,11 @@ void CGuiTextPane::Draw(const CGuiWidgetDrawParms& parms) const
}
}
CGuiTextPane* CGuiTextPane::Create(CGuiFrame* frame, CInputStream& in, bool flag)
std::shared_ptr<CGuiWidget> CGuiTextPane::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
float xDim = in.readFloatBig();
float zDim = in.readFloatBig();
zeus::CVector3f vec;
vec.readBig(in);
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
zeus::CVector2f dim = zeus::CVector2f::ReadBig(in);
zeus::CVector3f vec = zeus::CVector3f::ReadBig(in);
u32 fontId = in.readUint32Big();
bool wordWrap = in.readBool();
bool vertical = in.readBool();
@ -117,8 +114,12 @@ CGuiTextPane* CGuiTextPane::Create(CGuiFrame* frame, CInputStream& in, bool flag
outlineCol.readRGBABig(in);
int extentX = in.readFloatBig();
int extentY = in.readFloatBig();
return new CGuiTextPane(parms, xDim, zDim, vec, fontId, props,
std::shared_ptr<CGuiTextPane> ret =
std::make_shared<CGuiTextPane>(parms, sp, dim, vec, fontId, props,
fontCol, outlineCol, extentX, extentY);
ret->ParseBaseInfo(frame, in, parms);
ret->TextSupport()->SetText(L"");
return ret;
}
}

View File

@ -11,9 +11,9 @@ class CGuiTextPane : public CGuiPane
{
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);
CGuiTextPane(const CGuiWidgetParms& parms, CSimplePool* sp, const zeus::CVector2f& dim,
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 &xd4_textSupport;}
@ -25,7 +25,7 @@ public:
void ScaleDimensions(const zeus::CVector3f& scale);
void Draw(const CGuiWidgetDrawParms& parms) const;
static CGuiTextPane* Create(CGuiFrame* frame, CInputStream& in, bool);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
};
}

View File

@ -19,7 +19,7 @@ CGuiWidget::CGuiWidget(const CGuiWidgetParms& parms)
}
CGuiWidget::CGuiWidgetParms
CGuiWidget::ReadWidgetHeader(CGuiFrame* frame, CInputStream& in, bool flag)
CGuiWidget::ReadWidgetHeader(CGuiFrame* frame, CInputStream& in)
{
std::string name = in.readString(-1);
s16 selfId = frame->GetWidgetIdDB().AddWidget(name);
@ -36,13 +36,13 @@ CGuiWidget::ReadWidgetHeader(CGuiFrame* frame, CInputStream& in, bool flag)
return CGuiWidget::CGuiWidgetParms(frame, useAnimController, selfId,
parentId, defaultVis, defaultActive,
cullFaces, color, df, true, flag);
cullFaces, color, df, true, false);
}
CGuiWidget* CGuiWidget::Create(CGuiFrame* frame, CInputStream& in, bool flag)
std::shared_ptr<CGuiWidget> CGuiWidget::Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp)
{
CGuiWidgetParms parms = ReadWidgetHeader(frame, in, flag);
CGuiWidget* ret = new CGuiWidget(parms);
CGuiWidgetParms parms = ReadWidgetHeader(frame, in);
std::shared_ptr<CGuiWidget> ret = std::make_shared<CGuiWidget>(parms);
ret->ParseBaseInfo(frame, in, parms);
return ret;
}
@ -54,26 +54,25 @@ void CGuiWidget::Initialize()
void CGuiWidget::ParseBaseInfo(CGuiFrame* frame, CInputStream& in, const CGuiWidgetParms& parms)
{
CGuiWidget* parent = frame->FindWidget(parms.x8_parentId);
bool a = in.readBool();
if (a)
bool isWorker = in.readBool();
if (isWorker)
xb4_workerId = in.readInt16Big();
zeus::CVector3f trans;
trans.readBig(in);
zeus::CMatrix3f orient;
orient.readBig(in);
zeus::CVector3f trans = zeus::CVector3f::ReadBig(in);
zeus::CMatrix3f orient = zeus::CMatrix3f::ReadBig(in);
x74_transform = zeus::CTransform(orient, trans);
ReapplyXform();
zeus::CVector3f rotCenter;
rotCenter.readBig(in);
SetRotationCenter(rotCenter);
zeus::CVector3f::ReadBig(in);
in.readUint32Big();
in.readUint16Big();
if (a)
if (isWorker)
{
if (!parent->AddWorkerWidget(this))
{
Log.report(logvisor::Warning,
"Warning: Discarding useless worker id. Parent is not a compound widget.");
xb4_workerId = -1;
}
}
parent->AddChildWidget(this, false, true);
}

View File

@ -10,6 +10,7 @@ namespace urde
class CGuiFrame;
class CGuiTextSupport;
class CFinalInput;
class CSimplePool;
enum class ETraversalMode
{
@ -90,8 +91,8 @@ protected:
public:
CGuiWidget(const CGuiWidgetParms& parms);
static CGuiWidgetParms ReadWidgetHeader(CGuiFrame* frame, CInputStream& in, bool);
static CGuiWidget* Create(CGuiFrame* frame, CInputStream& in, bool);
static CGuiWidgetParms ReadWidgetHeader(CGuiFrame* frame, CInputStream& in);
static std::shared_ptr<CGuiWidget> Create(CGuiFrame* frame, CInputStream& in, CSimplePool* sp);
virtual void Update(float dt);
virtual void Draw(const CGuiWidgetDrawParms& drawParms) const;

View File

@ -25,8 +25,6 @@ set(GUISYS_SOURCES
CGuiModel.hpp
CGuiSliderGroup.cpp
CGuiSliderGroup.hpp
CGuiStaticImage.cpp
CGuiStaticImage.hpp
CGuiSys.cpp
CGuiSys.hpp
CGuiTableGroup.cpp
@ -56,8 +54,6 @@ set(GUISYS_SOURCES
CGuiWidgetIdDB.hpp
CGuiHeadWidget.cpp
CGuiHeadWidget.hpp
CGuiBackground.cpp
CGuiBackground.hpp
CGuiPane.cpp
CGuiPane.hpp
CFontRenderState.cpp

View File

@ -58,11 +58,11 @@ void CStringTable::LoadStringTable(CInputStream &in)
m_bufLen = dataLen;
x4_data.reset(new u8[dataLen]);
in.readUBytesToBuf(x4_data.get(), dataLen);
for (u32 i = 0 ; i<x0_stringCount ; i += 4)
{
u32* off = reinterpret_cast<u32*>(x4_data.get() + i);
u32* off = reinterpret_cast<u32*>(x4_data.get());
for (u32 i = 0 ; i < x0_stringCount ; ++i, ++off)
*off = hecl::SBig(*off);
}
for (u32 i = x0_stringCount * 4 ; i < dataLen ; i += 2)
{
u16* chr = reinterpret_cast<u16*>(x4_data.get() + i);
@ -70,14 +70,13 @@ void CStringTable::LoadStringTable(CInputStream &in)
}
}
std::wstring CStringTable::GetString(s32 str) const
const wchar_t* CStringTable::GetString(s32 str) const
{
if (str < 0 || u32(str) >= x0_stringCount)
return L"Invalid";
u32 off = *(reinterpret_cast<u32*>(x4_data.get() + str * 4));
CMemoryInStream tmp(x4_data.get() + off, m_bufLen - off);
return tmp.readWString();
u32 off = *reinterpret_cast<u32*>(x4_data.get() + str * 4);
return reinterpret_cast<wchar_t*>(x4_data.get() + off);
}
void CStringTable::SetLanguage(s32 lang)

View File

@ -17,7 +17,7 @@ public:
CStringTable(CInputStream& in);
void LoadStringTable(CInputStream& in);
std::wstring GetString(s32) const;
const wchar_t* GetString(s32) const;
static void SetLanguage(s32);
};

View File

@ -271,6 +271,7 @@ void CTextExecuteBuffer::StartNewLine()
xa8_curWordIt = x0_instList.emplace(x0_instList.cend(),
std::make_shared<CLineInstruction>(x18_textState.x80_just, x18_textState.x84_vjust));
xa4_curLine = static_cast<CLineInstruction*>(xa8_curWordIt->get());
xbc_spaceDistance = 0;
StartNewWord();
@ -426,8 +427,8 @@ void CTextExecuteBuffer::BeginBlock(s32 offX, s32 offY, s32 padX, s32 padY,
ETextDirection dir, EJustification just,
EVerticalJustification vjust)
{
x0_instList.emplace(x0_instList.cend(),
std::make_shared<CBlockInstruction>(offX, offY, padX, padY, dir, just, vjust));
xa0_curBlock = static_cast<CBlockInstruction*>(x0_instList.emplace(x0_instList.cend(),
std::make_shared<CBlockInstruction>(offX, offY, padX, padY, dir, just, vjust))->get());
if (x18_textState.x48_font)
{
@ -435,8 +436,7 @@ void CTextExecuteBuffer::BeginBlock(s32 offX, s32 offY, s32 padX, s32 padY,
s32 baseline = font->GetBaseline();
s32 monoH = font->GetMonoHeight();
s32 monoW = font->GetMonoWidth();
static_cast<CBlockInstruction&>(*x0_instList.back()).
TestLargestFont(monoW, monoH, baseline);
xa0_curBlock->TestLargestFont(monoW, monoH, baseline);
}
x18_textState.x0_drawStrOpts.x0_direction = dir;

View File

@ -33,27 +33,12 @@ class IMain
{
public:
virtual ~IMain() = default;
virtual void RegisterResourceTweaks() {}
virtual void ResetGameState()=0;
virtual void StreamNewGameState(CBitStreamReader&, u32 idx) {}
virtual void CheckTweakManagerDebugOptions() {}
virtual void Init(const hecl::Runtime::FileStoreManager& storeMgr,
boo::IAudioVoiceEngine* voiceEngine,
amuse::IBackendVoiceAllocator& backend)=0;
virtual void Draw()=0;
virtual bool Proc()=0;
virtual void Shutdown()=0;
virtual bool CheckReset()=0;
virtual bool CheckTerminate()=0;
virtual void DrawDebugMetrics(double, CStopWatch&) {}
virtual void DoPreDrawMetrics(){}
virtual void FillInAssetIDs()=0;
virtual bool LoadAudio()=0;
virtual void ShutdownSubsystems()=0;
virtual EGameplayResult GetGameplayResult() const=0;
virtual void SetGameplayResult(EGameplayResult wl)=0;
virtual void SetFlowState(EFlowState s)=0;
virtual EFlowState GetFlowState() const=0;
};
}

View File

@ -1,16 +1,20 @@
#include "CAudioStateWin.hpp"
#include "CSfxManager.hpp"
#include "Audio/CSfxManager.hpp"
#include "CArchitectureMessage.hpp"
#include "CArchitectureQueue.hpp"
#include "GameGlobalObjects.hpp"
#include "CGameState.hpp"
#include "IMain.hpp"
#include "MP1.hpp"
namespace urde
{
namespace MP1
{
CIOWin::EMessageReturn CAudioStateWin::OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue)
{
CMain* m = static_cast<CMain*>(g_Main);
const EArchMsgType msgType = msg.GetType();
if (msgType == EArchMsgType::SetGameState)
{
@ -20,7 +24,7 @@ CIOWin::EMessageReturn CAudioStateWin::OnMessage(const CArchitectureMessage& msg
else if (msgType == EArchMsgType::QuitGameplay)
{
if (g_GameState->GetWorldTransitionManager()->GetTransType() == CWorldTransManager::ETransType::Disabled ||
g_Main->GetFlowState() != EFlowState::Zero)
m->GetFlowState() != EFlowState::Zero)
{
CSfxManager::SetChannel(CSfxManager::ESfxChannels::Zero);
CSfxManager::KillAll(CSfxManager::ESfxChannels::One);
@ -30,3 +34,4 @@ CIOWin::EMessageReturn CAudioStateWin::OnMessage(const CArchitectureMessage& msg
}
}
}

View File

@ -1,10 +1,12 @@
#ifndef __URDE_CAUDIOSTATEWIN_HPP__
#define __URDE_CAUDIOSTATEWIN_HPP__
#ifndef __URDE_MP1_CAUDIOSTATEWIN_HPP__
#define __URDE_MP1_CAUDIOSTATEWIN_HPP__
#include "../CIOWin.hpp"
namespace urde
{
namespace MP1
{
class CAudioStateWin : public CIOWin
{
public:
@ -12,6 +14,7 @@ public:
CIOWin::EMessageReturn OnMessage(const CArchitectureMessage& msg, CArchitectureQueue& queue);
};
}
}
#endif // __URDE_CAUDIOSTATEWIN_HPP__
#endif // __URDE_MP1_CAUDIOSTATEWIN_HPP__

View File

@ -286,7 +286,7 @@ void CFrontEndUI::SNewFileSelectFrame::DeactivateNewGamePopup()
x64_fileSelections[x20_tablegroup_fileselect->GetUserSelection()].
x0_base->SetColor(zeus::CColor::skWhite);
x60_textpane_cancel->TextSupport()->SetText("");
x60_textpane_cancel->TextSupport()->SetText(L"");
}
void CFrontEndUI::SNewFileSelectFrame::ActivateNewGamePopup()
@ -339,7 +339,7 @@ void CFrontEndUI::SNewFileSelectFrame::ResetFrame()
for (int i=2 ; i>=0 ; --i)
x20_tablegroup_fileselect->GetWorkerWidget(i)->SetIsSelectable(true);
x60_textpane_cancel->TextSupport()->SetText("");
x60_textpane_cancel->TextSupport()->SetText(L"");
}
void CFrontEndUI::SNewFileSelectFrame::ActivateErase()
@ -1718,6 +1718,8 @@ void CFrontEndUI::SOptionsFrontEndFrame::Draw() const
CFrontEndUI::CFrontEndUI()
: CIOWin("FrontEndUI")
{
CMain* m = static_cast<CMain*>(g_Main);
x18_rndA = std::min(rand() * 3 / RAND_MAX, 2);
x1c_rndB = std::min(rand() * 3 / RAND_MAX, 2);
@ -1725,7 +1727,9 @@ CFrontEndUI::CFrontEndUI()
x38_pressStart = g_SimplePool->GetObj("TXTR_PressStart");
x44_frontendAudioGrp = g_SimplePool->GetObj("FrontEnd_AGSC");
g_Main->ResetGameState();
xdc_saveUI = std::make_unique<CSaveUI>(ESaveContext::FrontEnd, g_GameState->GetCardSerial());
m->ResetGameState();
g_GameState->SetCurrentWorldId(g_DefaultWorldTag.id);
for (int i=0 ; CDvdFile::FileExists(GetAttractMovieFileName(i).c_str()) ; ++i)
@ -1912,12 +1916,19 @@ void CFrontEndUI::Draw() const
/* Render movie */
auto vidDimensions = xcc_curMoviePtr->GetVideoDimensions();
float aspectRatio = vidDimensions.first / float(vidDimensions.second);
float verticalOff = (CGraphics::g_ViewportResolution.x / aspectRatio - CGraphics::g_ViewportResolution.y) * 0.5f;
xcc_curMoviePtr->SetFrame(zeus::CVector3f(0.f, -verticalOff, 0.f),
zeus::CVector3f(CGraphics::g_ViewportResolution.x, verticalOff, 0.f),
zeus::CVector3f(0.f, CGraphics::g_ViewportResolution.y + verticalOff, 0.f),
zeus::CVector3f(CGraphics::g_ViewportResolution.x,
CGraphics::g_ViewportResolution.y + verticalOff, 0.f));
float vpAspectRatio = CGraphics::g_ViewportResolution.x / float(CGraphics::g_ViewportResolution.y);
if (vpAspectRatio >= 1.78f)
{
float hPad = 1.78f / vpAspectRatio;
float vPad = 1.78f / aspectRatio;
xcc_curMoviePtr->SetFrame({-hPad, vPad, 0.f}, {-hPad, -vPad, 0.f}, {hPad, -vPad, 0.f}, {hPad, vPad, 0.f});
}
else
{
float vPad = vpAspectRatio / aspectRatio;
xcc_curMoviePtr->SetFrame({-1.f, vPad, 0.f}, {-1.f, -vPad, 0.f}, {1.f, -vPad, 0.f}, {1.f, vPad, 0.f});
}
xcc_curMoviePtr->DrawFrame();
}

View File

@ -31,7 +31,8 @@ void CMFGame::Draw() const
CMFGameLoader::CMFGameLoader() : CMFGameLoaderBase("CMFGameLoader")
{
switch (g_Main->GetFlowState())
CMain* m = static_cast<CMain*>(g_Main);
switch (m->GetFlowState())
{
case EFlowState::Five:
case EFlowState::Six:

View File

@ -24,6 +24,7 @@ set(MP1_SOURCES
CQuitScreen.hpp CQuitScreen.cpp
CCredits.hpp CCredits.cpp
CStateSetterFlow.hpp CStateSetterFlow.cpp
CAudioStateWin.hpp CAudioStateWin.cpp
MP1.hpp MP1.cpp)
runtime_add_list(MP1 MP1_SOURCES)

View File

@ -33,18 +33,45 @@ void CTweaks::RegisterTweaks()
{
ProjectResourceFactoryMP1& factory = ProjectManager::g_SharedManager->resourceFactoryMP1();
std::experimental::optional<CMemoryInStream> strm;
const SObjectTag* tag;
const SObjectTag* tag = factory.GetResourceIdByName("SlideShow");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakSlideShow = new DataSpec::DNAMP1::CTweakSlideShow(*strm);
/* Particle */
/* Player */
tag = factory.GetResourceIdByName("Player");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakPlayer = new DataSpec::DNAMP1::CTweakPlayer(*strm);
/* CameraBob */
tag = factory.GetResourceIdByName("CameraBob");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
CPlayerCameraBob::ReadTweaks(*strm);
/* Ball */
/* PlayerGun */
/* Targeting */
/* Game */
tag = factory.GetResourceIdByName("Game");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakGame = new DataSpec::DNAMP1::CTweakGame(*strm);
/* GuiColors */
/* AutoMapper */
/* Gui */
/* PlayerControls */
/* PlayerControls2 */
/* SlideShow */
tag = factory.GetResourceIdByName("SlideShow");
strm.emplace(factory.LoadResourceSync(*tag).release(), factory.ResourceSize(*tag));
g_tweakSlideShow = new DataSpec::DNAMP1::CTweakSlideShow(*strm);
}
void CTweaks::RegisterResourceTweaks()

View File

@ -35,10 +35,12 @@ CGameArchitectureSupport::CGameArchitectureSupport(CMain& parent, boo::IAudioVoi
g_tweakPlayer->GetRightLogicalThreshold()),
x44_guiSys(*g_ResFactory, *g_SimplePool, CGuiSys::EUsageMode::Zero)
{
CMain* m = static_cast<CMain*>(g_Main);
g_GuiSys = &x44_guiSys;
x30_inputGenerator.startScanning();
CStreamAudioManager::Initialize();
g_Main->ResetGameState();
m->ResetGameState();
std::shared_ptr<CIOWin> splash = std::make_shared<CSplashScreen>(CSplashScreen::ESplashScreen::Nintendo);
x58_ioWinManager.AddIOWin(splash, 1000, 10000);
@ -141,11 +143,35 @@ void CGameArchitectureSupport::PreloadAudio()
x88_audioLoadStatus = EAudioLoadStatus::Loading;
}
void CGameArchitectureSupport::UnloadAudio()
{
for (int i=0 ; i<5 ; ++i)
{
const AudioGroupInfo& info = StaticAudioGroups[i];
const SObjectTag* tag = g_ResFactory->GetResourceIdByName(info.name);
const std::string& name = CAudioSys::SysGetGroupSetName(tag->id);
CAudioSys::SysRemoveGroupFromAmuse(name);
CAudioSys::SysUnloadAudioGroupSet(name);
}
x8c_pendingAudioGroups = std::vector<TToken<CAudioGroupSet>>();
x88_audioLoadStatus = EAudioLoadStatus::Uninitialized;
}
void CGameArchitectureSupport::Draw()
{
x58_ioWinManager.Draw();
}
CGameArchitectureSupport::~CGameArchitectureSupport()
{
x58_ioWinManager.RemoveAllIOWins();
UnloadAudio();
CSfxManager::Shutdown();
CStreamAudioManager::Shutdown();
}
CMain::CMain(IFactory& resFactory, CSimplePool& resStore,
boo::IGraphicsDataFactory* gfxFactory,
boo::IGraphicsCommandQueue* cmdQ,
@ -249,8 +275,19 @@ void CMain::Draw()
x164_archSupport->Draw();
}
void CMain::ShutdownSubsystems()
{
CMoviePlayer::Shutdown();
CLineRenderer::Shutdown();
CDecalManager::Shutdown();
CElementGen::Shutdown();
CAnimData::FreeCache();
}
void CMain::Shutdown()
{
x164_archSupport.reset();
ShutdownSubsystems();
TShader<CThermalColdFilter>::Shutdown();
TShader<CThermalHotFilter>::Shutdown();
TShader<CSpaceWarpFilter>::Shutdown();

View File

@ -29,7 +29,7 @@
#include "GuiSys/CConsoleOutputWindow.hpp"
#include "GuiSys/CErrorOutputWindow.hpp"
#include "GuiSys/CTextParser.hpp"
#include "Audio/CAudioStateWin.hpp"
#include "CAudioStateWin.hpp"
#include "GameGlobalObjects.hpp"
#include "CArchitectureQueue.hpp"
#include "CTimeProvider.hpp"
@ -157,8 +157,11 @@ class CGameArchitectureSupport
public:
CGameArchitectureSupport(CMain& parent, boo::IAudioVoiceEngine* voiceEngine,
amuse::IBackendVoiceAllocator& backend);
~CGameArchitectureSupport();
void PreloadAudio();
bool LoadAudio();
void UnloadAudio();
void UpdateTicks();
void Update();
void Draw();
@ -268,7 +271,7 @@ public:
void DoPredrawMetrics() {}
void FillInAssetIDs();
bool LoadAudio();
void ShutdownSubsystems() {}
void ShutdownSubsystems();
EGameplayResult GetGameplayResult() const { return xe4_gameplayResult; }
void SetGameplayResult(EGameplayResult wl) { xe4_gameplayResult = wl; }
void SetManageCard(bool v) { x160_28_manageCard = v; }

View File

@ -26,4 +26,10 @@ void CDecalManager::Initialize()
m_LastDecalCreatedIndex = -1;
m_LastDecalCreatedAssetId = -1;
}
void CDecalManager::Shutdown()
{
}
}

View File

@ -28,6 +28,7 @@ class CDecalManager
static rstl::reserved_vector<s32, 64> m_ActiveIndexList;
public:
static void Initialize();
static void Shutdown();
};
}

2
hecl

@ -1 +1 @@
Subproject commit 2f606a03a98bd5c2d06410bcfb597fbedede4a81
Subproject commit b02a7baff487bbf86102c8531e98147e00b9c54e

2
jbus

@ -1 +1 @@
Subproject commit 9db987d3ddbc178883a7b2168367fe8b4ec29c05
Subproject commit b8c42676ce9055bc48f9f7d75eb9f8964e6cfda3

@ -1 +1 @@
Subproject commit 03e7124c5f576033c10ad2d0a116e4a331c0381d
Subproject commit 66bc6b4caf32b3f9d936c2809e3d8bfa458bcce5