This commit is contained in:
Jack Andersen 2017-07-09 18:57:29 -10:00
commit 7e85ab932b
17 changed files with 137 additions and 32 deletions

View File

@ -144,7 +144,7 @@ void CGuiTextSupport::CheckAndRebuildTextBuffer()
g_TextExecuteBuf->AddColor(EColorType::Outline, x28_outlineColor); g_TextExecuteBuf->AddColor(EColorType::Outline, x28_outlineColor);
std::u16string initStr; std::u16string initStr;
if (x5c_fontId != 0xffffffff) if (x5c_fontId != kInvalidResId)
initStr = hecl::Char16Format(L"&font=%08X;", u32(x5c_fontId)); initStr = hecl::Char16Format(L"&font=%08X;", u32(x5c_fontId));
initStr += x0_string; initStr += x0_string;

View File

@ -93,7 +93,7 @@ class CGuiTextSupport
bool x50_typeEnable = false; bool x50_typeEnable = false;
float x54_chFadeTime = 0.1f; float x54_chFadeTime = 0.1f;
float x58_chRate = 10.0f; float x58_chRate = 10.0f;
ResId x5c_fontId = -1; ResId x5c_fontId = kInvalidResId;
CGuiWidget::EGuiModelDrawFlags m_drawFlags; CGuiWidget::EGuiModelDrawFlags m_drawFlags;
std::experimental::optional<CTextRenderBuffer> x60_renderBuf; std::experimental::optional<CTextRenderBuffer> x60_renderBuf;
std::vector<CToken> x2bc_assets; std::vector<CToken> x2bc_assets;

View File

@ -240,7 +240,7 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len,
{ {
AdvanceCommaPos(); AdvanceCommaPos();
texs.push_back(x0_store.GetObj({SBIG('TXTR'), texs.push_back(x0_store.GetObj({SBIG('TXTR'),
GetAssetIdFromString(&iterable[tokenPos], txtrMap)})); GetAssetIdFromString(&iterable[tokenPos], len, txtrMap)}));
AdvanceTokenPos(); AdvanceTokenPos();
} while (commaPos != iterable.size()); } while (commaPos != iterable.size());
@ -267,7 +267,7 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len,
{ {
AdvanceCommaPos(); AdvanceCommaPos();
texs.push_back(x0_store.GetObj({SBIG('TXTR'), texs.push_back(x0_store.GetObj({SBIG('TXTR'),
GetAssetIdFromString(&iterable[tokenPos], txtrMap)})); GetAssetIdFromString(&iterable[tokenPos], len, txtrMap)}));
AdvanceTokenPos(); AdvanceTokenPos();
} while (commaPos != iterable.size()); } while (commaPos != iterable.size());
@ -286,18 +286,18 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len,
AdvanceCommaPos(); AdvanceCommaPos();
TToken<CTexture> tex = x0_store.GetObj({SBIG('TXTR'), TToken<CTexture> tex = x0_store.GetObj({SBIG('TXTR'),
GetAssetIdFromString(&iterable[tokenPos], txtrMap)}); GetAssetIdFromString(&iterable[tokenPos], len, txtrMap)});
AdvanceTokenPos(); AdvanceTokenPos();
return CFontImageDef(tex, zeus::CVector2f(cropX, cropY)); return CFontImageDef(tex, zeus::CVector2f(cropX, cropY));
} }
} }
TToken<CTexture> tex = x0_store.GetObj({SBIG('TXTR'), GetAssetIdFromString(str, txtrMap)}); TToken<CTexture> tex = x0_store.GetObj({SBIG('TXTR'), GetAssetIdFromString(str, len, txtrMap)});
return CFontImageDef(tex, zeus::CVector2f(1.f, 1.f)); return CFontImageDef(tex, zeus::CVector2f(1.f, 1.f));
} }
ResId CTextParser::GetAssetIdFromString(const char16_t* str, ResId CTextParser::GetAssetIdFromString(const char16_t* str, int len,
const std::vector<std::pair<ResId, ResId>>* txtrMap) const std::vector<std::pair<ResId, ResId>>* txtrMap)
{ {
u8 r = GetColorValue(str); u8 r = GetColorValue(str);
@ -306,6 +306,15 @@ ResId CTextParser::GetAssetIdFromString(const char16_t* str,
u8 a = GetColorValue(str + 6); u8 a = GetColorValue(str + 6);
ResId id = ((r << 24) | (g << 16) | (b << 8) | a) & 0xffffffff; ResId id = ((r << 24) | (g << 16) | (b << 8) | a) & 0xffffffff;
if (len == 16)
{
r = GetColorValue(str + 8);
g = GetColorValue(str + 10);
b = GetColorValue(str + 12);
a = GetColorValue(str + 14);
id = (id << 32) | (((r << 24) | (g << 16) | (b << 8) | a) & 0xffffffff);
}
if (txtrMap) if (txtrMap)
{ {
auto search = std::lower_bound(txtrMap->begin(), txtrMap->end(), id, auto search = std::lower_bound(txtrMap->begin(), txtrMap->end(), id,
@ -319,7 +328,7 @@ ResId CTextParser::GetAssetIdFromString(const char16_t* str,
TToken<CRasterFont> CTextParser::GetFont(const char16_t* str, int len) TToken<CRasterFont> CTextParser::GetFont(const char16_t* str, int len)
{ {
return x0_store.GetObj({SBIG('FONT'), GetAssetIdFromString(str, nullptr)}); return x0_store.GetObj({SBIG('FONT'), GetAssetIdFromString(str, len, nullptr)});
} }
void CTextParser::ParseText(CTextExecuteBuffer& out, const char16_t* str, int len, void CTextParser::ParseText(CTextExecuteBuffer& out, const char16_t* str, int len,

View File

@ -16,7 +16,7 @@ class CTextParser
static u8 GetColorValue(const char16_t* str); static u8 GetColorValue(const char16_t* str);
static u32 FromHex(char16_t ch); static u32 FromHex(char16_t ch);
static s32 ParseInt(const char16_t* str, int len, bool signVal); static s32 ParseInt(const char16_t* str, int len, bool signVal);
static ResId GetAssetIdFromString(const char16_t* str, static ResId GetAssetIdFromString(const char16_t* str, int len,
const std::vector<std::pair<ResId, ResId>>* txtrMap); const std::vector<std::pair<ResId, ResId>>* txtrMap);
static bool Equals(const char16_t* str, int len, const char16_t* other); static bool Equals(const char16_t* str, int len, const char16_t* other);
static bool BeginsWith(const char16_t* str, int len, const char16_t* other); static bool BeginsWith(const char16_t* str, int len, const char16_t* other);

View File

@ -57,6 +57,7 @@ using TAreaId = s32;
#define kInvalidEditorId TEditorId() #define kInvalidEditorId TEditorId()
#define kInvalidUniqueId TUniqueId(-1) #define kInvalidUniqueId TUniqueId(-1)
#define kInvalidAreaId TAreaId(-1) #define kInvalidAreaId TAreaId(-1)
#define kInvalidResId ResId(-1)
} }
#if 0 #if 0

View File

@ -25,7 +25,7 @@ CScriptActor::CScriptActor(TUniqueId uid, const std::string& name, const CEntity
, x2e2_24_(b2) , x2e2_24_(b2)
, x2e2_25_dead(false) , x2e2_25_dead(false)
, x2e2_26_animating(true) , x2e2_26_animating(true)
, x2e2_27_(std::fabs(f3 - 1.f) > 0.00001) , x2e2_27_(std::fabs(1.f - f3) > 0.00001)
, x2e2_28_(false) , x2e2_28_(false)
, x2e2_29_((x2e2_24_ && x2e2_25_dead && x2d8_ != 0)) , x2e2_29_((x2e2_24_ && x2e2_25_dead && x2d8_ != 0))
, x2e2_30_transposeRotate(b4) , x2e2_30_transposeRotate(b4)

View File

@ -50,8 +50,9 @@ void CScriptColorModulate::FadeOutHelper(CStateManager &, TUniqueId, float)
{ {
} }
void CScriptColorModulate::FadeInHelper(CStateManager &, TUniqueId, float) void CScriptColorModulate::FadeInHelper(CStateManager& mgr, TUniqueId uid, float f1)
{ {
} }
void CScriptColorModulate::End(CStateManager& stateMgr) void CScriptColorModulate::End(CStateManager& stateMgr)

View File

@ -8,11 +8,11 @@ namespace urde
CScriptControllerAction::CScriptControllerAction(TUniqueId uid, const std::string& name, CScriptControllerAction::CScriptControllerAction(TUniqueId uid, const std::string& name,
const CEntityInfo& info, bool active, const CEntityInfo& info, bool active,
ControlMapper::ECommands command, bool b1, u32 w1, bool b2) ControlMapper::ECommands command, bool mapScreenResponse, u32 w1, bool deactivateOnClose)
: CEntity(uid, info, active, name), x34_command(command), x38_mapScreenSubaction(w1) : CEntity(uid, info, active, name), x34_command(command), x38_mapScreenSubaction(w1)
{ {
x3c_24_mapScreenResponse = b1; x3c_24_mapScreenResponse = mapScreenResponse;
x3c_25_deactivateOnClose = b2; x3c_25_deactivateOnClose = deactivateOnClose;
} }
void CScriptControllerAction::Accept(IVisitor& visitor) void CScriptControllerAction::Accept(IVisitor& visitor)
@ -22,7 +22,7 @@ void CScriptControllerAction::Accept(IVisitor& visitor)
void CScriptControllerAction::Think(float dt, CStateManager& stateMgr) void CScriptControllerAction::Think(float dt, CStateManager& stateMgr)
{ {
bool old26 = x3c_26_pressed; bool oldPressed = x3c_26_pressed;
if (x3c_24_mapScreenResponse) if (x3c_24_mapScreenResponse)
{ {
if (x38_mapScreenSubaction == 0) if (x38_mapScreenSubaction == 0)
@ -33,7 +33,7 @@ void CScriptControllerAction::Think(float dt, CStateManager& stateMgr)
x3c_26_pressed = ControlMapper::GetDigitalInput(x34_command, stateMgr.GetFinalInput()); x3c_26_pressed = ControlMapper::GetDigitalInput(x34_command, stateMgr.GetFinalInput());
} }
if (GetActive() && x3c_26_pressed != old26) if (GetActive() && x3c_26_pressed != oldPressed)
{ {
if (x3c_26_pressed) if (x3c_26_pressed)
{ {

View File

@ -1,12 +1,17 @@
#include "CScriptCounter.hpp" #include "CScriptCounter.hpp"
#include "CStateManager.hpp"
#include "TCastTo.hpp" #include "TCastTo.hpp"
namespace urde namespace urde
{ {
CScriptCounter::CScriptCounter(TUniqueId uid, const std::string& name, const CEntityInfo& info, CScriptCounter::CScriptCounter(TUniqueId uid, const std::string& name, const CEntityInfo& info,
u32, u32, bool, bool active) s32 initial, s32 max, bool autoReset, bool active)
: CEntity(uid, info, active, name) : CEntity(uid, info, active, name)
, x34_initial(initial)
, x38_current(initial)
, x3c_max(max)
, x40_autoReset(autoReset)
{ {
} }
@ -15,4 +20,61 @@ void CScriptCounter::Accept(IVisitor& visitor)
visitor.Visit(this); visitor.Visit(this);
} }
void CScriptCounter::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)
{
switch(msg)
{
case EScriptObjectMessage::SetToZero:
if (GetActive())
{
x38_current = 0;
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
if (x40_autoReset)
x38_current = x34_initial;
}
break;
case EScriptObjectMessage::SetToMax:
if (GetActive())
{
x38_current = x3c_max;
SendScriptMsgs(EScriptObjectState::MaxReached, stateMgr, EScriptObjectMessage::None);
if (x40_autoReset)
x38_current = x34_initial;
}
break;
case EScriptObjectMessage::Decrement:
if (GetActive() && x38_current > 0)
{
--x38_current;
if (x38_current == 0)
{
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
if (x40_autoReset)
x38_current = x34_initial;
}
}
break;
case EScriptObjectMessage::Increment:
if (GetActive() && x38_current < x3c_max)
{
++x38_current;
if (x38_current >= x3c_max)
{
SendScriptMsgs(EScriptObjectState::Zero, stateMgr, EScriptObjectMessage::None);
if (x40_autoReset)
x38_current = x34_initial;
}
}
break;
case EScriptObjectMessage::Reset:
if (GetActive())
x38_current = x34_initial;
break;
}
CEntity::AcceptScriptMsg(msg, objId, stateMgr);
}
} }

View File

@ -8,11 +8,16 @@ namespace urde
class CScriptCounter : public CEntity class CScriptCounter : public CEntity
{ {
s32 x34_initial;
s32 x38_current;
s32 x3c_max;
bool x40_autoReset;
public: public:
CScriptCounter(TUniqueId, const std::string& name, const CEntityInfo& info, CScriptCounter(TUniqueId, const std::string& name, const CEntityInfo& info,
u32, u32, bool, bool); s32, s32, bool, bool);
void Accept(IVisitor& visitor); void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager &stateMgr);
}; };
} }

View File

@ -1,6 +1,8 @@
#include "CScriptSound.hpp" #include "CScriptSound.hpp"
#include "Character/CModelData.hpp" #include "Character/CModelData.hpp"
#include "Collision/CMaterialList.hpp" #include "Collision/CMaterialList.hpp"
#include "CStateManager.hpp"
#include "CWorld.hpp"
#include "CActorParameters.hpp" #include "CActorParameters.hpp"
#include "TCastTo.hpp" #include "TCastTo.hpp"
@ -45,7 +47,9 @@ void CScriptSound::PreThink(float dt, CStateManager& mgr)
x11d_25_ = false; x11d_25_ = false;
} }
void CScriptSound::Think(float, CStateManager&) {} void CScriptSound::Think(float dt, CStateManager& mgr)
{
}
void CScriptSound::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) void CScriptSound::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{ {
@ -83,7 +87,18 @@ void CScriptSound::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSta
void CScriptSound::PlaySound(CStateManager&) {} void CScriptSound::PlaySound(CStateManager&) {}
void CScriptSound::StopSound() void CScriptSound::StopSound(CStateManager& mgr)
{ {
x11c_24_playing = false;
if (x11c_30_ && x11c_26_)
{
mgr.WorldNC()->StopSound(x100_soundId);
xec_sfxHandle.reset();
}
else if (xec_sfxHandle)
{
CSfxManager::RemoveEmitter(*xec_sfxHandle.get());
xec_sfxHandle.reset();
}
} }
} }

View File

@ -30,7 +30,7 @@ class CScriptSound : public CActor
{ {
struct struct
{ {
bool x11c_24_ : 1; bool x11c_24_playing : 1;
bool x11c_25_ : 1; bool x11c_25_ : 1;
bool x11c_26_ : 1; bool x11c_26_ : 1;
bool x11c_27_ : 1; bool x11c_27_ : 1;
@ -55,7 +55,7 @@ public:
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&); void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void GetOccludedVolumeAmount(const zeus::CVector3f&, const CStateManager&); void GetOccludedVolumeAmount(const zeus::CVector3f&, const CStateManager&);
void PlaySound(CStateManager&); void PlaySound(CStateManager&);
void StopSound(); void StopSound(CStateManager&);
}; };
} }

View File

@ -26,6 +26,11 @@ public:
public: public:
CFlareDef(const TToken<CTexture>& tex, float f1, float f2, const zeus::CColor& color) CFlareDef(const TToken<CTexture>& tex, float f1, float f2, const zeus::CColor& color)
: x0_tex(tex), x8_f1(f1), xc_f2(f2), x10_color(color) { x0_tex.Lock(); } : x0_tex(tex), x8_f1(f1), xc_f2(f2), x10_color(color) { x0_tex.Lock(); }
TToken<CTexture> GetTexture() const;
zeus::CColor GetColor() { return x10_color; }
float GetScale() const;
float GetPosition() const;
}; };
private: private:
EBlendMode x0_blendMode; EBlendMode x0_blendMode;

View File

@ -609,4 +609,8 @@ void CWorld::DrawSky(const zeus::CTransform& xf) const
CGraphics::SetDepthRange(0.125f, 1.f); CGraphics::SetDepthRange(0.125f, 1.f);
} }
void CWorld::StopSound(s16)
{
}
} }

View File

@ -5,6 +5,7 @@
#include "ScriptObjectSupport.hpp" #include "ScriptObjectSupport.hpp"
#include "CGameArea.hpp" #include "CGameArea.hpp"
#include "Graphics/CModel.hpp" #include "Graphics/CModel.hpp"
#include "Audio/CSfxManager.hpp"
#include "AutoMapper/CMapWorld.hpp" #include "AutoMapper/CMapWorld.hpp"
@ -146,6 +147,7 @@ private:
TLockedToken<CModel> x94_skybox; TLockedToken<CModel> x94_skybox;
TLockedToken<CModel> xa4_skyboxB; TLockedToken<CModel> xa4_skyboxB;
TLockedToken<CModel> xb4_skyboxC; TLockedToken<CModel> xb4_skyboxC;
std::vector<CSfxHandle> xc4_sfxHandles;
void LoadSoundGroup(int groupId, ResId agscId, CSoundGroupData& data); void LoadSoundGroup(int groupId, ResId agscId, CSoundGroupData& data);
void LoadSoundGroups(); void LoadSoundGroups();
@ -197,6 +199,7 @@ public:
void PreRender(); void PreRender();
void TouchSky(); void TouchSky();
void DrawSky(const zeus::CTransform& xf) const; void DrawSky(const zeus::CTransform& xf) const;
void StopSound(s16);
}; };
struct CWorldLayers struct CWorldLayers

View File

@ -386,28 +386,28 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in, int propC
zeus::CVector3f centroid; zeus::CVector3f centroid;
centroid.readBig(in); centroid.readBig(in);
float f1 = in.readFloatBig(); float mass = in.readFloatBig();
float f2 = in.readFloatBig(); float zMomentum = in.readFloatBig();
CHealthInfo hInfo(in); CHealthInfo hInfo(in);
CDamageVulnerability dInfo(in); CDamageVulnerability dVuln(in);
ResId staticId = in.readUint32Big(); ResId staticId = in.readUint32Big();
CAnimationParameters aParms = LoadAnimationParameters(in); CAnimationParameters aParms = LoadAnimationParameters(in);
CActorParameters actParms = LoadActorParameters(in); CActorParameters actParms = LoadActorParameters(in);
bool b1 = in.readBool(); bool looping = in.readBool();
bool snow = in.readBool(); bool snow = in.readBool();
bool solid = in.readBool(); bool solid = in.readBool();
bool cameraPassthrough = in.readBool(); bool cameraPassthrough = in.readBool();
bool b5 = in.readBool(); bool active = in.readBool();
u32 w2 = in.readUint32Big(); u32 w2 = in.readUint32Big();
float f3 = in.readFloatBig(); float f3 = in.readFloatBig();
bool b6 = in.readBool(); bool b6 = in.readBool();
bool b7 = in.readBool(); bool castsShadow = in.readBool();
bool b8 = in.readBool(); bool xposeRotate = in.readBool();
bool b9 = in.readBool(); bool b9 = in.readBool();
FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile()); FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile());
@ -435,8 +435,8 @@ CEntity* ScriptLoader::LoadActor(CStateManager& mgr, CInputStream& in, int propC
if ((collisionExtent.x < 0.f || collisionExtent.y < 0.f || collisionExtent.z < 0.f) || collisionExtent.isZero()) if ((collisionExtent.x < 0.f || collisionExtent.y < 0.f || collisionExtent.z < 0.f) || collisionExtent.isZero())
aabb = data.GetBounds(head.x10_transform.getRotation()); aabb = data.GetBounds(head.x10_transform.getRotation());
return new CScriptActor(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, std::move(data), aabb, f1, return new CScriptActor(mgr.AllocateUniqueId(), head.x0_name, info, head.x10_transform, std::move(data), aabb, mass,
f2, list, hInfo, dInfo, actParms, b1, b5, w2, f3, b6, b7, b8, b9); zMomentum, list, hInfo, dVuln, actParms, looping, active, w2, f3, b6, castsShadow, xposeRotate, b9);
} }
CEntity* ScriptLoader::LoadWaypoint(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info) CEntity* ScriptLoader::LoadWaypoint(CStateManager& mgr, CInputStream& in, int propCount, const CEntityInfo& info)

2
nod

@ -1 +1 @@
Subproject commit 8bdbcf0c9080f26c7fdb9364af03f1dd6b74c350 Subproject commit e99290e3c331cf5128b754a63612cd21afcd3c50