Merge remote-tracking branch 'github/recovery'

This commit is contained in:
Luke Street 2020-03-18 00:45:49 -04:00
commit fcf7044bf2
17 changed files with 211 additions and 140 deletions

View File

@ -16,7 +16,7 @@ public:
return msg;
}
void Clear() { m_list.clear(); }
operator bool() const { return m_list.size() != 0; }
explicit operator bool() const { return !m_list.empty(); }
};
} // namespace urde

View File

@ -31,15 +31,15 @@ CGameHintInfo::SHintLocation::SHintLocation(CInputStream& in, s32)
, x8_areaId(in.readUint32Big())
, xc_stringId(in.readUint32Big()) {}
int CGameHintInfo::FindHintIndex(const char* str) {
int CGameHintInfo::FindHintIndex(std::string_view str) {
const std::vector<CGameHint>& gameHints = g_MemoryCardSys->GetHints();
const auto& it = std::find_if(gameHints.begin(), gameHints.end(),
[&str](const CGameHint& gh) -> bool { return gh.GetName() == str; });
const auto it =
std::find_if(gameHints.cbegin(), gameHints.cend(), [&str](const CGameHint& gh) { return gh.GetName() == str; });
return (it != gameHints.end() ? it - gameHints.begin() : -1);
return it != gameHints.cend() ? it - gameHints.cbegin() : -1;
}
CFactoryFnReturn FHintFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer, CObjectReference*) {
CFactoryFnReturn FHintFactory(const SObjectTag&, CInputStream& in, const CVParamTransfer&, CObjectReference*) {
in.readUint32Big();
s32 version = in.readInt32Big();

View File

@ -42,8 +42,8 @@ private:
public:
CGameHintInfo(CInputStream&, s32);
const std::vector<CGameHint>& GetHints() const { return x0_hints; }
static int FindHintIndex(const char* str);
static int FindHintIndex(std::string_view str);
};
CFactoryFnReturn FHintFactory(const SObjectTag&, CInputStream&, const CVParamTransfer, CObjectReference*);
CFactoryFnReturn FHintFactory(const SObjectTag&, CInputStream&, const CVParamTransfer&, CObjectReference*);
} // namespace urde

View File

@ -578,43 +578,51 @@ const CHintOptions::SHintState* CHintOptions::GetCurrentDisplayedHint() const {
return nullptr;
}
void CHintOptions::DelayHint(const char* name) {
int idx = CGameHintInfo::FindHintIndex(name);
if (idx == -1)
void CHintOptions::DelayHint(std::string_view name) {
const int idx = CGameHintInfo::FindHintIndex(name);
if (idx == -1) {
return;
}
if (x10_nextHintIdx == idx)
for (SHintState& state : x0_hintStates)
if (x10_nextHintIdx == idx) {
for (SHintState& state : x0_hintStates) {
state.x4_time += 60.f;
}
}
x0_hintStates[idx].x0_state = EHintState::Delayed;
}
void CHintOptions::ActivateImmediateHintTimer(const char* name) {
int idx = CGameHintInfo::FindHintIndex(name);
if (idx == -1)
void CHintOptions::ActivateImmediateHintTimer(std::string_view name) {
const int idx = CGameHintInfo::FindHintIndex(name);
if (idx == -1) {
return;
}
SHintState& hintState = x0_hintStates[idx];
const CGameHintInfo::CGameHint& hint = g_MemoryCardSys->GetHints()[idx];
if (hintState.x0_state != EHintState::Zero)
if (hintState.x0_state != EHintState::Zero) {
return;
}
hintState.x0_state = EHintState::Waiting;
hintState.x4_time = hint.GetImmediateTime();
}
void CHintOptions::ActivateContinueDelayHintTimer(const char* name) {
void CHintOptions::ActivateContinueDelayHintTimer(std::string_view name) {
int idx = x10_nextHintIdx;
if (idx != 0)
if (idx != 0) {
idx = CGameHintInfo::FindHintIndex(name);
if (idx == -1)
}
if (idx == -1) {
return;
}
SHintState& hintState = x0_hintStates[idx];
const CGameHintInfo::CGameHint& hint = g_MemoryCardSys->GetHints()[idx];
if (hintState.x0_state != EHintState::Displaying)
if (hintState.x0_state != EHintState::Displaying) {
return;
}
hintState.x4_time = hint.GetTextTime();
}

View File

@ -1,6 +1,7 @@
#pragma once
#include <array>
#include <string_view>
#include <vector>
#include "Runtime/CSaveWorld.hpp"
@ -205,9 +206,9 @@ public:
void SetNextHintTime();
void InitializeMemoryState();
const SHintState* GetCurrentDisplayedHint() const;
void DelayHint(const char* name);
void ActivateImmediateHintTimer(const char* name);
void ActivateContinueDelayHintTimer(const char* name);
void DelayHint(std::string_view name);
void ActivateImmediateHintTimer(std::string_view name);
void ActivateContinueDelayHintTimer(std::string_view name);
void DismissDisplayedHint();
u32 GetNextHintIdx() const;
const std::vector<SHintState>& GetHintStates() const { return x0_hintStates; }

View File

@ -76,7 +76,7 @@ public:
ECardResult result;
CardResult(ECardResult res) : result(res) {}
operator ECardResult() const { return result; }
operator bool() const { return result != ECardResult::READY; }
explicit operator bool() const { return result != ECardResult::READY; }
};
struct CardFileHandle {

View File

@ -9,7 +9,7 @@
namespace urde {
static float ClampZeroToOne(float in) { return std::max(0.f, std::min(1.f, in)); }
static constexpr float ClampZeroToOne(float in) { return std::clamp(in, 0.0f, 1.0f); }
u32 RotationAndOffsetStorage::DataSizeInBytes(u32 rotPerFrame, u32 transPerFrame, u32 frameCount) {
return (transPerFrame * 12 + rotPerFrame * 16) * frameCount;

View File

@ -1,5 +1,7 @@
#include "Runtime/Character/CAnimSourceReader.hpp"
#include <algorithm>
#include "Runtime/Character/CBoolPOINode.hpp"
#include "Runtime/Character/CFBStreamedAnimReader.hpp"
#include "Runtime/Character/CInt32POINode.hpp"
@ -27,27 +29,33 @@ CCharAnimTime CAnimSourceInfo::GetAnimationDuration() const { return x4_token->G
std::set<std::pair<std::string, s32>> CAnimSourceReaderBase::GetUniqueParticlePOIs() const {
const std::vector<CParticlePOINode>& particleNodes = x4_sourceInfo->GetParticlePOIStream();
std::set<std::pair<std::string, s32>> ret;
for (const CParticlePOINode& node : particleNodes)
if (node.GetUnique())
ret.insert(std::make_pair(std::string(node.GetString()), node.GetIndex()));
for (const CParticlePOINode& node : particleNodes) {
if (node.GetUnique()) {
ret.emplace(node.GetString(), node.GetIndex());
}
}
return ret;
}
std::set<std::pair<std::string, s32>> CAnimSourceReaderBase::GetUniqueInt32POIs() const {
const std::vector<CInt32POINode>& int32Nodes = x4_sourceInfo->GetInt32POIStream();
std::set<std::pair<std::string, s32>> ret;
for (const CInt32POINode& node : int32Nodes)
if (node.GetUnique())
ret.insert(std::make_pair(std::string(node.GetString()), node.GetIndex()));
for (const CInt32POINode& node : int32Nodes) {
if (node.GetUnique()) {
ret.emplace(node.GetString(), node.GetIndex());
}
}
return ret;
}
std::set<std::pair<std::string, s32>> CAnimSourceReaderBase::GetUniqueBoolPOIs() const {
const std::vector<CBoolPOINode>& boolNodes = x4_sourceInfo->GetBoolPOIStream();
std::set<std::pair<std::string, s32>> ret;
for (const CBoolPOINode& node : boolNodes)
if (node.GetUnique())
ret.insert(std::make_pair(std::string(node.GetString()), node.GetIndex()));
for (const CBoolPOINode& node : boolNodes) {
if (node.GetUnique()) {
ret.emplace(node.GetString(), node.GetIndex());
}
}
return ret;
}
@ -165,24 +173,36 @@ u32 CAnimSourceReaderBase::VGetSoundPOIList(const CCharAnimTime& time, CSoundPOI
}
bool CAnimSourceReaderBase::VGetBoolPOIState(const char* name) const {
for (const auto& node : x24_boolStates)
if (node.first == name)
return node.second;
return false;
const auto iter = std::find_if(x24_boolStates.cbegin(), x24_boolStates.cend(),
[name](const auto& entry) { return entry.first == name; });
if (iter == x24_boolStates.cend()) {
return false;
}
return iter->second;
}
s32 CAnimSourceReaderBase::VGetInt32POIState(const char* name) const {
for (const auto& node : x34_int32States)
if (node.first == name)
return node.second;
return 0;
const auto iter = std::find_if(x34_int32States.cbegin(), x34_int32States.cend(),
[name](const auto& entry) { return entry.first == name; });
if (iter == x34_int32States.cend()) {
return 0;
}
return iter->second;
}
CParticleData::EParentedMode CAnimSourceReaderBase::VGetParticlePOIState(const char* name) const {
for (const auto& node : x44_particleStates)
if (node.first == name)
return node.second;
return CParticleData::EParentedMode::Initial;
const auto iter = std::find_if(x44_particleStates.cbegin(), x44_particleStates.cend(),
[name](const auto& entry) { return entry.first == name; });
if (iter == x44_particleStates.cend()) {
return CParticleData::EParentedMode::Initial;
}
return iter->second;
}
CAnimSourceReaderBase::CAnimSourceReaderBase(std::unique_ptr<IAnimSourceInfo>&& sourceInfo, const CCharAnimTime& time)

View File

@ -5,10 +5,6 @@
namespace urde {
CCharAnimTime CCharAnimTime::Infinity() {
return {EType::Infinity, 1.f};
}
bool CCharAnimTime::EqualsZero() const {
if (x4_type == EType::ZeroIncreasing || x4_type == EType::ZeroSteady || x4_type == EType::ZeroDecreasing)
return true;

View File

@ -16,13 +16,12 @@ private:
EType x4_type = EType::ZeroSteady;
public:
CCharAnimTime() = default;
CCharAnimTime(CInputStream& in) : x0_time(in.readFloatBig()), x4_type(EType(in.readUint32Big())) {}
CCharAnimTime(float time) : x0_time(time), x4_type(x0_time != 0.f ? EType::NonZero : EType::ZeroSteady) {}
constexpr CCharAnimTime() = default;
constexpr CCharAnimTime(float time) : x0_time(time), x4_type(x0_time != 0.f ? EType::NonZero : EType::ZeroSteady) {}
constexpr CCharAnimTime(EType type, float t) : x0_time(t), x4_type(type) {}
explicit CCharAnimTime(CInputStream& in) : x0_time(in.readFloatBig()), x4_type(EType(in.readUint32Big())) {}
CCharAnimTime(EType type, const float& t) : x0_time(t), x4_type(type) {}
static CCharAnimTime Infinity();
static constexpr CCharAnimTime Infinity() { return {EType::Infinity, 1.0f}; }
float GetSeconds() const { return x0_time; }
bool EqualsZero() const;

View File

@ -9,14 +9,14 @@
#include "TCastTo.hpp" // Generated file, do not modify include path
namespace urde {
static const CMaterialList gkDefaultCollisionActorMaterials =
constexpr CMaterialList skDefaultCollisionActorMaterials =
CMaterialList(EMaterialTypes::Solid, EMaterialTypes::CollisionActor, EMaterialTypes::ScanPassthrough,
EMaterialTypes::CameraPassthrough);
CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, const zeus::CVector3f& extent,
const zeus::CVector3f& center, bool active, float mass, std::string_view name)
: CPhysicsActor(uid1, active, "CollisionActor", CEntityInfo(aId, CEntity::NullConnectionList),
zeus::CTransform(), CModelData::CModelDataNull(), gkDefaultCollisionActorMaterials,
zeus::CTransform(), CModelData::CModelDataNull(), skDefaultCollisionActorMaterials,
zeus::skNullBox, SMoverData(mass), CActorParameters::None(), 0.3f, 0.1f)
, x258_primitiveType(EPrimitiveType::OBBTreeGroup)
, x25c_owner(uid2)
@ -35,7 +35,7 @@ CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, co
CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, const zeus::CVector3f& boxSize,
bool active, float mass, std::string_view name)
: CPhysicsActor(uid1, active, "CollisionActor", CEntityInfo(aId, CEntity::NullConnectionList),
zeus::CTransform(), CModelData::CModelDataNull(), gkDefaultCollisionActorMaterials,
zeus::CTransform(), CModelData::CModelDataNull(), skDefaultCollisionActorMaterials,
zeus::skNullBox, SMoverData(mass), CActorParameters::None(), 0.3f, 0.1f)
, x258_primitiveType(EPrimitiveType::AABox)
, x25c_owner(uid2)
@ -54,7 +54,7 @@ CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, co
CCollisionActor::CCollisionActor(TUniqueId uid1, TAreaId aId, TUniqueId uid2, bool active, float radius, float mass,
std::string_view name)
: CPhysicsActor(uid1, active, "CollisionActor", CEntityInfo(aId, CEntity::NullConnectionList),
zeus::CTransform(), CModelData::CModelDataNull(), gkDefaultCollisionActorMaterials,
zeus::CTransform(), CModelData::CModelDataNull(), skDefaultCollisionActorMaterials,
zeus::skNullBox, SMoverData(mass), CActorParameters::None(), 0.3f, 0.1f)
, x258_primitiveType(EPrimitiveType::Sphere)
, x25c_owner(uid2)

View File

@ -8,13 +8,14 @@ CFontImageDef::CFontImageDef(const std::vector<TToken<CTexture>>& texs, float in
const zeus::CVector2f& cropFactor)
: x0_fps(interval), x14_cropFactor(cropFactor) {
x4_texs.reserve(texs.size());
for (const TToken<CTexture>& tok : texs)
x4_texs.push_back(tok);
for (const TToken<CTexture>& tok : texs) {
x4_texs.emplace_back(tok);
}
}
CFontImageDef::CFontImageDef(const TToken<CTexture>& tex, const zeus::CVector2f& cropFactor)
: x0_fps(0.f), x14_cropFactor(cropFactor) {
x4_texs.push_back(tex);
x4_texs.emplace_back(tex);
}
bool CFontImageDef::IsLoaded() const {

View File

@ -1,5 +1,7 @@
#include "Runtime/GuiSys/CHudEnergyInterface.hpp"
#include <array>
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Audio/CSfxManager.hpp"
#include "Runtime/GuiSys/CAuiEnergyBarT01.hpp"
@ -10,12 +12,15 @@
namespace urde {
static const CAuiEnergyBarT01::FCoordFunc CoordFuncs[] = {
constexpr std::array<CAuiEnergyBarT01::FCoordFunc, 5> CoordFuncs{
CHudEnergyInterface::CombatEnergyCoordFunc, CHudEnergyInterface::CombatEnergyCoordFunc,
CHudEnergyInterface::XRayEnergyCoordFunc, CHudEnergyInterface::ThermalEnergyCoordFunc,
CHudEnergyInterface::BallEnergyCoordFunc};
CHudEnergyInterface::XRayEnergyCoordFunc, CHudEnergyInterface::ThermalEnergyCoordFunc,
CHudEnergyInterface::BallEnergyCoordFunc,
};
static const float Tesselations[] = {0.2f, 0.2f, 0.1f, 0.2f, 1.f};
constexpr std::array Tesselations{
0.2f, 0.2f, 0.1f, 0.2f, 1.f,
};
CHudEnergyInterface::CHudEnergyInterface(CGuiFrame& selHud, float tankEnergy, int totalEnergyTanks, int numTanksFilled,
bool energyLow, EHudType hudType)
@ -33,8 +38,8 @@ CHudEnergyInterface::CHudEnergyInterface(CGuiFrame& selHud, float tankEnergy, in
x28_textpane_energywarning = static_cast<CGuiTextPane*>(selHud.FindWidget("textpane_energywarning"));
x2c_energybart01_energybar = static_cast<CAuiEnergyBarT01*>(selHud.FindWidget("energybart01_energybar"));
x2c_energybart01_energybar->SetCoordFunc(CoordFuncs[int(hudType)]);
x2c_energybart01_energybar->SetTesselation(Tesselations[int(hudType)]);
x2c_energybart01_energybar->SetCoordFunc(CoordFuncs[size_t(hudType)]);
x2c_energybart01_energybar->SetTesselation(Tesselations[size_t(hudType)]);
ITweakGuiColors::VisorEnergyBarColors barColors = g_tweakGuiColors->GetVisorEnergyBarColors(int(hudType));
ITweakGuiColors::VisorEnergyInitColors initColors = g_tweakGuiColors->GetVisorEnergyInitColors(int(hudType));

View File

@ -1,5 +1,7 @@
#include "Runtime/GuiSys/CHudMissileInterface.hpp"
#include <array>
#include "Runtime/CStateManager.hpp"
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/GuiSys/CAuiEnergyBarT01.hpp"
@ -10,11 +12,14 @@
namespace urde {
static const CAuiEnergyBarT01::FCoordFunc CoordFuncs[] = {CHudMissileInterface::CombatMissileBarCoordFunc, nullptr,
CHudMissileInterface::XRayMissileBarCoordFunc,
CHudMissileInterface::ThermalMissileBarCoordFunc, nullptr};
constexpr std::array<CAuiEnergyBarT01::FCoordFunc, 5> CoordFuncs{
CHudMissileInterface::CombatMissileBarCoordFunc, nullptr, CHudMissileInterface::XRayMissileBarCoordFunc,
CHudMissileInterface::ThermalMissileBarCoordFunc, nullptr,
};
static const float IconTranslateRanges[] = {6.05f, 0.f, 0.f, 8.4f, 0.f};
constexpr std::array IconTranslateRanges{
6.05f, 0.f, 0.f, 8.4f, 0.f,
};
CHudMissileInterface::CHudMissileInterface(CGuiFrame& selHud, int missileCapacity, int numMissiles, float chargeFactor,
bool missilesActive, EHudType hudType, const CStateManager& mgr)
@ -45,7 +50,7 @@ CHudMissileInterface::CHudMissileInterface(CGuiFrame& selHud, int missileCapacit
x64_energybart01_missilebar->SetEmptyColor(g_tweakGuiColors->GetMissileBarEmpty());
x64_energybart01_missilebar->SetFilledColor(g_tweakGuiColors->GetMissileBarFilled());
x64_energybart01_missilebar->SetShadowColor(g_tweakGuiColors->GetMissileBarShadow());
x64_energybart01_missilebar->SetCoordFunc(CoordFuncs[int(hudType)]);
x64_energybart01_missilebar->SetCoordFunc(CoordFuncs[size_t(hudType)]);
x64_energybart01_missilebar->SetTesselation(hudType == EHudType::Combat ? 1.f : 0.1f);
x64_energybart01_missilebar->SetMaxEnergy(5.f);
x64_energybart01_missilebar->SetFilledDrainSpeed(g_tweakGui->GetEnergyBarFilledSpeed());
@ -121,8 +126,8 @@ void CHudMissileInterface::Update(float dt, const CStateManager& mgr) {
if (x58_28_notXRay) {
x74_basewidget_missileicon->SetLocalTransform(
x10_missleIconXf *
zeus::CTransform::Translate(0.f, 0.f,
x8_numMissles * IconTranslateRanges[int(x0_hudType)] / float(x4_missileCapacity)));
zeus::CTransform::Translate(
0.f, 0.f, x8_numMissles * IconTranslateRanges[size_t(x0_hudType)] / float(x4_missileCapacity)));
}
if (x58_27_hasArrows) {
@ -236,28 +241,30 @@ CHudMissileInterface::EInventoryStatus CHudMissileInterface::GetMissileInventory
}
std::pair<zeus::CVector3f, zeus::CVector3f> CHudMissileInterface::CombatMissileBarCoordFunc(float t) {
float z = t * IconTranslateRanges[int(EHudType::Combat)];
const float z = t * IconTranslateRanges[size_t(EHudType::Combat)];
return {zeus::CVector3f(0.f, 0.f, z), zeus::CVector3f(0.3f, 0.f, z)};
}
std::pair<zeus::CVector3f, zeus::CVector3f> CHudMissileInterface::XRayMissileBarCoordFunc(float t) {
float theta = 0.8f * (t - 0.5f);
float x = 9.55f * std::cos(theta);
float z = 9.55f * std::sin(theta);
const float theta = 0.8f * (t - 0.5f);
const float x = 9.55f * std::cos(theta);
const float z = 9.55f * std::sin(theta);
return {zeus::CVector3f(x - 0.4f, 0.f, z), zeus::CVector3f(x, 0.f, z)};
}
std::pair<zeus::CVector3f, zeus::CVector3f> CHudMissileInterface::ThermalMissileBarCoordFunc(float t) {
float transRange = IconTranslateRanges[int(EHudType::Thermal)];
float a = 0.08f * transRange;
float b = t * transRange;
const float transRange = IconTranslateRanges[size_t(EHudType::Thermal)];
const float a = 0.08f * transRange;
const float b = t * transRange;
float c;
if (b < a)
if (b < a) {
c = b / a;
else if (b < transRange - a)
} else if (b < transRange - a) {
c = 1.f;
else
} else {
c = 1.f - (b - (transRange - a)) / a;
}
return {zeus::CVector3f(-0.5f * c - 0.1f, 0.f, b), zeus::CVector3f(-0.1f, 0.f, b)};
}

View File

@ -1,5 +1,7 @@
#include "Runtime/GuiSys/CHudThreatInterface.hpp"
#include <array>
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/GuiSys/CAuiEnergyBarT01.hpp"
#include "Runtime/GuiSys/CGuiFrame.hpp"
@ -10,11 +12,14 @@
namespace urde {
static const CAuiEnergyBarT01::FCoordFunc CoordFuncs[] = {CHudThreatInterface::CombatThreatBarCoordFunc, nullptr,
CHudThreatInterface::XRayThreatBarCoordFunc,
CHudThreatInterface::ThermalThreatBarCoordFunc, nullptr};
constexpr std::array<CAuiEnergyBarT01::FCoordFunc, 5> CoordFuncs{
CHudThreatInterface::CombatThreatBarCoordFunc, nullptr, CHudThreatInterface::XRayThreatBarCoordFunc,
CHudThreatInterface::ThermalThreatBarCoordFunc, nullptr,
};
static const float IconTranslateRanges[] = {6.05f, 0.f, 0.f, 8.4f, 0.f};
constexpr std::array IconTranslateRanges{
6.05f, 0.f, 0.f, 8.4f, 0.f,
};
CHudThreatInterface::CHudThreatInterface(CGuiFrame& selHud, EHudType hudType, float threatDist)
: x4_hudType(hudType), x10_threatDist(threatDist) {
@ -42,7 +47,7 @@ CHudThreatInterface::CHudThreatInterface(CGuiFrame& selHud, EHudType hudType, fl
x6c_energybart01_threatbar->SetFilledColor(g_tweakGuiColors->GetThreatBarFilled());
x6c_energybart01_threatbar->SetShadowColor(g_tweakGuiColors->GetThreatBarShadow());
x6c_energybart01_threatbar->SetEmptyColor(g_tweakGuiColors->GetThreatBarEmpty());
x6c_energybart01_threatbar->SetCoordFunc(CoordFuncs[int(hudType)]);
x6c_energybart01_threatbar->SetCoordFunc(CoordFuncs[size_t(hudType)]);
x6c_energybart01_threatbar->SetTesselation(hudType == EHudType::Combat ? 1.f : 0.1f);
x6c_energybart01_threatbar->SetMaxEnergy(g_tweakGui->GetThreatRange());
x6c_energybart01_threatbar->SetFilledDrainSpeed(9999.f);
@ -133,7 +138,7 @@ void CHudThreatInterface::Update(float dt) {
x5c_basewidget_threaticon->SetLocalTransform(
x18_threatIconXf * zeus::CTransform::Translate(0.f, 0.f,
std::max(0.f, maxThreatEnergy - x10_threatDist) *
IconTranslateRanges[int(x4_hudType)] / maxThreatEnergy));
IconTranslateRanges[size_t(x4_hudType)] / maxThreatEnergy));
}
if (x68_textpane_threatwarning) {
@ -203,28 +208,30 @@ void CHudThreatInterface::Update(float dt) {
}
std::pair<zeus::CVector3f, zeus::CVector3f> CHudThreatInterface::CombatThreatBarCoordFunc(float t) {
float z = IconTranslateRanges[int(EHudType::Combat)] * t;
const float z = IconTranslateRanges[size_t(EHudType::Combat)] * t;
return {zeus::CVector3f(-0.3f, 0.f, z), zeus::CVector3f(0.f, 0.f, z)};
}
std::pair<zeus::CVector3f, zeus::CVector3f> CHudThreatInterface::XRayThreatBarCoordFunc(float t) {
float theta = 0.8f * (t - 0.5f);
float x = -9.55f * std::cos(theta);
float z = 9.55f * std::sin(theta);
const float theta = 0.8f * (t - 0.5f);
const float x = -9.55f * std::cos(theta);
const float z = 9.55f * std::sin(theta);
return {zeus::CVector3f(0.4f + x, 0.f, z), zeus::CVector3f(x, 0.f, z)};
}
std::pair<zeus::CVector3f, zeus::CVector3f> CHudThreatInterface::ThermalThreatBarCoordFunc(float t) {
float transRange = IconTranslateRanges[int(EHudType::Thermal)];
float a = 0.08f * transRange;
float b = t * transRange;
const float transRange = IconTranslateRanges[size_t(EHudType::Thermal)];
const float a = 0.08f * transRange;
const float b = t * transRange;
float c;
if (b < a)
if (b < a) {
c = b / a;
else if (b < transRange - a)
} else if (b < transRange - a) {
c = 1.f;
else
} else {
c = 1.f - (b - (transRange - a)) / a;
}
return {zeus::CVector3f(0.1f, 0.f, b), zeus::CVector3f(0.5f * c + 0.1f, 0.f, b)};
}

View File

@ -1,5 +1,7 @@
#include "Runtime/GuiSys/CHudVisorBeamMenu.hpp"
#include <array>
#include "Runtime/CGameState.hpp"
#include "Runtime/GameGlobalObjects.hpp"
#include "Runtime/Audio/CSfxManager.hpp"
@ -10,22 +12,40 @@
namespace urde {
static const char* BaseMenuNames[] = {"BaseWidget_VisorMenu", "BaseWidget_BeamMenu"};
static const char* TextNames[] = {"TextPane_VisorMenu", "TextPane_BeamMenu"};
static const char* BaseTitleNames[] = {"basewidget_visormenutitle", "basewidget_beammenutitle"};
static const char* ModelNames[] = {"model_visor", "model_beam"};
static const char MenuItemOrders[2][4] = {{'1', '0', '3', '2'}, {'3', '2', '1', '0'}};
static const int MenuStringIdx[2][4] = {
{0, 2, 1, 3}, // Combat, XRay, Scan, Thermal
{4, 5, 6, 7} // Power, Ice, Wave, Plasma
constexpr std::array BaseMenuNames{
"BaseWidget_VisorMenu",
"BaseWidget_BeamMenu",
};
static const u16 SelectionSfxs[] = {SFXui_select_visor, SFXui_select_beam};
constexpr std::array TextNames{
"TextPane_VisorMenu",
"TextPane_BeamMenu",
};
constexpr std::array BaseTitleNames{
"basewidget_visormenutitle",
"basewidget_beammenutitle",
};
constexpr std::array ModelNames{
"model_visor",
"model_beam",
};
constexpr std::array<std::array<char, 4>, 2> MenuItemOrders{{
{'1', '0', '3', '2'},
{'3', '2', '1', '0'},
}};
constexpr std::array<std::array<int, 4>, 2> MenuStringIdx{{
{0, 2, 1, 3}, // Combat, XRay, Scan, Thermal
{4, 5, 6, 7}, // Power, Ice, Wave, Plasma
}};
constexpr std::array<u16, 2> SelectionSfxs{
SFXui_select_visor,
SFXui_select_beam,
};
CHudVisorBeamMenu::CHudVisorBeamMenu(CGuiFrame& baseHud, EHudVisorBeamMenu type,
const rstl::reserved_vector<bool, 4>& enables)
@ -43,19 +63,23 @@ CHudVisorBeamMenu::CHudVisorBeamMenu(CGuiFrame& baseHud, EHudVisorBeamMenu type,
else
swappedType = x4_type;
x20_textpane_menu = static_cast<CGuiTextPane*>(x0_baseHud.FindWidget(TextNames[int(swappedType)]));
x1c_basewidget_menutitle = x0_baseHud.FindWidget(BaseTitleNames[int(swappedType)]);
x18_basewidget_menu = x0_baseHud.FindWidget(BaseMenuNames[int(swappedType)]);
x20_textpane_menu = static_cast<CGuiTextPane*>(x0_baseHud.FindWidget(TextNames[size_t(swappedType)]));
x1c_basewidget_menutitle = x0_baseHud.FindWidget(BaseTitleNames[size_t(swappedType)]);
x18_basewidget_menu = x0_baseHud.FindWidget(BaseMenuNames[size_t(swappedType)]);
x24_model_ghost = static_cast<CGuiModel*>(x0_baseHud.FindWidget(fmt::format(fmt("{}ghost"), ModelNames[int(x4_type)])));
x24_model_ghost =
static_cast<CGuiModel*>(x0_baseHud.FindWidget(fmt::format(fmt("{}ghost"), ModelNames[size_t(x4_type)])));
x28_menuItems.resize(4);
for (int i = 0; i < 4; ++i) {
for (size_t i = 0; i < x28_menuItems.size(); i++) {
const auto modelName = ModelNames[size_t(x4_type)];
const auto menuItemOrder = MenuItemOrders[size_t(x4_type)][i];
SMenuItem& item = x28_menuItems[i];
item.x0_model_loz = static_cast<CGuiModel*>(
x0_baseHud.FindWidget(fmt::format(fmt("{}loz{}"), ModelNames[int(x4_type)], MenuItemOrders[int(x4_type)][i])));
item.x4_model_icon = static_cast<CGuiModel*>(
x0_baseHud.FindWidget(fmt::format(fmt("{}icon{}"), ModelNames[int(x4_type)], MenuItemOrders[int(x4_type)][i])));
item.x0_model_loz =
static_cast<CGuiModel*>(x0_baseHud.FindWidget(fmt::format(fmt("{}loz{}"), modelName, menuItemOrder)));
item.x4_model_icon =
static_cast<CGuiModel*>(x0_baseHud.FindWidget(fmt::format(fmt("{}icon{}"), modelName, menuItemOrder)));
item.xc_opacity = enables[i] ? 1.f : 0.f;
}
@ -71,7 +95,8 @@ CHudVisorBeamMenu::CHudVisorBeamMenu(CGuiFrame& baseHud, EHudVisorBeamMenu type,
titleColor.a() = 0.f;
x1c_basewidget_menutitle->SetColor(titleColor);
x20_textpane_menu->TextSupport().SetText(g_MainStringTable->GetString(MenuStringIdx[int(x4_type)][x8_selectedItem]));
x20_textpane_menu->TextSupport().SetText(
g_MainStringTable->GetString(MenuStringIdx[size_t(x4_type)][x8_selectedItem]));
for (int i = 0; i < 4; ++i) {
SMenuItem& item = x28_menuItems[i];
@ -130,9 +155,9 @@ void CHudVisorBeamMenu::Update(float dt, bool init) {
else
swappedType = x4_type;
x18_basewidget_menu = x0_baseHud.FindWidget(BaseMenuNames[int(swappedType)]);
x20_textpane_menu = static_cast<CGuiTextPane*>(x0_baseHud.FindWidget(TextNames[int(swappedType)]));
x1c_basewidget_menutitle = x0_baseHud.FindWidget(BaseTitleNames[int(swappedType)]);
x18_basewidget_menu = x0_baseHud.FindWidget(BaseMenuNames[size_t(swappedType)]);
x20_textpane_menu = static_cast<CGuiTextPane*>(x0_baseHud.FindWidget(TextNames[size_t(swappedType)]));
x1c_basewidget_menutitle = x0_baseHud.FindWidget(BaseTitleNames[size_t(swappedType)]);
for (int i = 0; i < 4; ++i) {
SMenuItem& item = x28_menuItems[i];
@ -146,7 +171,7 @@ void CHudVisorBeamMenu::Update(float dt, bool init) {
zeus::CColor activeColor = g_tweakGuiColors->GetVisorBeamMenuItemActive();
zeus::CColor inactiveColor = g_tweakGuiColors->GetVisorBeamMenuItemInactive();
zeus::CColor lozColor = g_tweakGuiColors->GetVisorBeamMenuLozColor();
zeus::CColor tmpColors[4];
std::array<zeus::CColor, 4> tmpColors;
for (int i = 0; i < 4; ++i) {
SMenuItem& item = x28_menuItems[i];
@ -262,13 +287,14 @@ void CHudVisorBeamMenu::SetSelection(int selection, int pending, float interp) {
return;
if (pending != selection) {
if (x6c_animPhase != EAnimPhase::SelectFlash)
CSfxManager::SfxStart(SelectionSfxs[int(x4_type)], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
if (x6c_animPhase != EAnimPhase::SelectFlash) {
CSfxManager::SfxStart(SelectionSfxs[size_t(x4_type)], 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
}
x6c_animPhase = EAnimPhase::SelectFlash;
} else if (interp < 1.f) {
x6c_animPhase = EAnimPhase::Animate;
x20_textpane_menu->TextSupport().SetText(
g_MainStringTable->GetString(MenuStringIdx[int(x4_type)][x8_selectedItem]));
g_MainStringTable->GetString(MenuStringIdx[size_t(x4_type)][x8_selectedItem]));
x20_textpane_menu->TextSupport().SetTypeWriteEffectOptions(true, 0.1f, 16.f);
} else {
if (x6c_animPhase != EAnimPhase::Steady)

View File

@ -396,12 +396,13 @@ void CScriptSpecialFunction::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId
}
case ESpecialFunction::RedundantHintSystem: {
CHintOptions& hintOptions = g_GameState->HintOptions();
if (msg == EScriptObjectMessage::Action)
hintOptions.ActivateContinueDelayHintTimer(xec_locatorName.c_str());
else if (msg == EScriptObjectMessage::Increment)
hintOptions.ActivateImmediateHintTimer(xec_locatorName.c_str());
else if (msg == EScriptObjectMessage::Decrement)
hintOptions.DelayHint(xec_locatorName.c_str());
if (msg == EScriptObjectMessage::Action) {
hintOptions.ActivateContinueDelayHintTimer(xec_locatorName);
} else if (msg == EScriptObjectMessage::Increment) {
hintOptions.ActivateImmediateHintTimer(xec_locatorName);
} else if (msg == EScriptObjectMessage::Decrement) {
hintOptions.DelayHint(xec_locatorName);
}
break;
}
case ESpecialFunction::Billboard: {