CHUDMemoParms fix

This commit is contained in:
Jack Andersen 2018-01-01 00:15:26 -10:00
parent b5c79d0e75
commit fac324f08f
4 changed files with 42 additions and 45 deletions

View File

@ -1,10 +1,10 @@
#include "AssetNameMap.hpp" #include "AssetNameMap.hpp"
#include "athena/MemoryReader.hpp" #include "athena/MemoryReader.hpp"
extern "C" uint8_t ASSET_NAME_MP32[]; extern "C" const uint8_t ASSET_NAME_MP32[];
extern "C" uint32_t ASSET_NAME_MP32_SZ; extern "C" const size_t ASSET_NAME_MP32_SZ;
extern "C" uint8_t ASSET_NAME_MP64[]; extern "C" const uint8_t ASSET_NAME_MP64[];
extern "C" uint32_t ASSET_NAME_MP64_SZ; extern "C" const size_t ASSET_NAME_MP64_SZ;
namespace DataSpec::AssetNameMap namespace DataSpec::AssetNameMap
{ {

View File

@ -1359,7 +1359,7 @@ void CSamusHud::Update(float dt, const CStateManager& mgr,
x5a0_base_model_abutton->SetColor(abuttonColor); x5a0_base_model_abutton->SetColor(abuttonColor);
if (!mgr.GetCameraManager()->IsInCinematicCamera() && oldAPulse < 0.f && x584_abuttonPulse >= 0.f && if (!mgr.GetCameraManager()->IsInCinematicCamera() && oldAPulse < 0.f && x584_abuttonPulse >= 0.f &&
x598_base_basewidget_message->GetIsVisible() && (x558_messageTextAlpha == 0.f || x558_messageTextAlpha >= 1.f)) x598_base_basewidget_message->GetIsVisible() && (x558_messageTextTime == 0.f || x558_messageTextTime >= 1.f))
{ {
CSfxManager::SfxStart(1442, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); CSfxManager::SfxStart(1442, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
} }
@ -1371,8 +1371,8 @@ void CSamusHud::Update(float dt, const CStateManager& mgr,
allTextAlpha = 1.f; allTextAlpha = 1.f;
float messageTextAlpha = 1.f; float messageTextAlpha = 1.f;
if (x558_messageTextAlpha > 0.f) if (x558_messageTextTime > 0.f)
messageTextAlpha = std::min(x558_messageTextAlpha, 1.f); messageTextAlpha = std::min(x558_messageTextTime, 1.f);
else if (!x59c_base_textpane_message->GetIsVisible() && !x598_base_basewidget_message->GetIsVisible()) else if (!x59c_base_textpane_message->GetIsVisible() && !x598_base_basewidget_message->GetIsVisible())
messageTextAlpha = 0.f; messageTextAlpha = 0.f;
@ -1385,10 +1385,10 @@ void CSamusHud::Update(float dt, const CStateManager& mgr,
x550_hudMemoString = TLockedToken<CStringTable>(); x550_hudMemoString = TLockedToken<CStringTable>();
} }
if (x558_messageTextAlpha > 0.f) if (x558_messageTextTime > 0.f)
{ {
x558_messageTextAlpha = std::max(0.f, x558_messageTextAlpha - dt); x558_messageTextTime = std::max(0.f, x558_messageTextTime - dt);
if (x558_messageTextAlpha == 0.f) if (x558_messageTextTime == 0.f)
{ {
x59c_base_textpane_message->TextSupport().SetTypeWriteEffectOptions(false, 0.f, 1.f); x59c_base_textpane_message->TextSupport().SetTypeWriteEffectOptions(false, 0.f, 1.f);
x598_base_basewidget_message->SetVisibility(false, ETraversalMode::Children); x598_base_basewidget_message->SetVisibility(false, ETraversalMode::Children);
@ -1408,8 +1408,8 @@ void CSamusHud::Update(float dt, const CStateManager& mgr,
if (messageWidget == x598_base_basewidget_message) if (messageWidget == x598_base_basewidget_message)
{ {
if (x558_messageTextAlpha > 0.f) if (x558_messageTextTime > 0.f)
x560_messageTextScale = std::min(x558_messageTextAlpha, 1.f); x560_messageTextScale = std::min(x558_messageTextTime, 1.f);
else else
x560_messageTextScale = std::min(x560_messageTextScale + dt, 1.f); x560_messageTextScale = std::min(x560_messageTextScale + dt, 1.f);
@ -1447,7 +1447,7 @@ void CSamusHud::Update(float dt, const CStateManager& mgr,
x594_base_textpane_counter->SetIsVisible(true); x594_base_textpane_counter->SetIsVisible(true);
zeus::CColor counterColor = zeus::CColor::skWhite; zeus::CColor counterColor = zeus::CColor::skWhite;
counterColor.a = zeus::clamp(0.f, std::min(1.f - std::min(x558_messageTextAlpha, 1.f), allTextAlpha), 1.f); counterColor.a = zeus::clamp(0.f, std::min(1.f - std::min(x558_messageTextTime, 1.f), allTextAlpha), 1.f);
x594_base_textpane_counter->SetColor(counterColor); x594_base_textpane_counter->SetColor(counterColor);
} }
else else
@ -1780,21 +1780,21 @@ zeus::CTransform CSamusHud::BuildFinalCameraTransform(const zeus::CQuaternion& r
void CSamusHud::SetMessage(std::u16string_view text, const CHUDMemoParms& info) void CSamusHud::SetMessage(std::u16string_view text, const CHUDMemoParms& info)
{ {
bool isWidgetVisible = x598_base_basewidget_message->GetIsVisible(); bool isWidgetVisible = x598_base_basewidget_message->GetIsVisible();
if (!isWidgetVisible || info.x6_hintMemo) if (!isWidgetVisible || info.IsHintMemo())
{ {
if (info.x5_hintDismissSound) if (info.IsFadeOutOnly())
{ {
if (!info.x6_hintMemo || !isWidgetVisible) if (!info.IsHintMemo() || !isWidgetVisible)
return; return;
CSfxManager::SfxStart(1449, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId); CSfxManager::SfxStart(1449, 1.f, 0.f, false, 0x7f, false, kInvalidAreaId);
return; return;
} }
x598_base_basewidget_message->SetColor(zeus::CColor::skWhite); x598_base_basewidget_message->SetColor(zeus::CColor::skWhite);
x598_base_basewidget_message->SetVisibility(false, ETraversalMode::Children); x598_base_basewidget_message->SetVisibility(false, ETraversalMode::Children);
CGuiWidget* pane = info.x6_hintMemo ? x598_base_basewidget_message : x59c_base_textpane_message; CGuiWidget* pane = info.IsHintMemo() ? x598_base_basewidget_message : x59c_base_textpane_message;
pane->SetVisibility(true, ETraversalMode::Children); pane->SetVisibility(true, ETraversalMode::Children);
x59c_base_textpane_message->TextSupport().SetTypeWriteEffectOptions(true, 0.1f, 40.f); x59c_base_textpane_message->TextSupport().SetTypeWriteEffectOptions(true, 0.1f, 40.f);
if (info.x4_initializeMemo) if (info.IsClearMemoWindow())
{ {
x55c_lastSfxChars = 0.f; x55c_lastSfxChars = 0.f;
x59c_base_textpane_message->TextSupport().SetCurTime(0.f); x59c_base_textpane_message->TextSupport().SetCurTime(0.f);
@ -1812,8 +1812,8 @@ void CSamusHud::SetMessage(std::u16string_view text, const CHUDMemoParms& info)
x59c_base_textpane_message->SetColor(zeus::CColor::skWhite); x59c_base_textpane_message->SetColor(zeus::CColor::skWhite);
x598_base_basewidget_message->SetColor(zeus::CColor::skWhite); x598_base_basewidget_message->SetColor(zeus::CColor::skWhite);
x558_messageTextAlpha = info.x0_alpha; x558_messageTextTime = info.GetDisplayTime();
if (info.x6_hintMemo) if (info.IsHintMemo())
{ {
if (!isWidgetVisible) if (!isWidgetVisible)
{ {

View File

@ -14,6 +14,7 @@
#include "GuiSys/CHudThreatInterface.hpp" #include "GuiSys/CHudThreatInterface.hpp"
#include "GuiSys/CHudVisorBeamMenu.hpp" #include "GuiSys/CHudVisorBeamMenu.hpp"
#include "Graphics/Shaders/CRandomStaticFilter.hpp" #include "Graphics/Shaders/CRandomStaticFilter.hpp"
#include "World/CHUDMemoParms.hpp"
namespace urde namespace urde
{ {
@ -21,23 +22,6 @@ class CGuiFrame;
class CStateManager; class CStateManager;
class CGuiLight; class CGuiLight;
struct CHUDMemoParms
{
float x0_alpha = 0.f;
bool x4_initializeMemo = false;
bool x5_hintDismissSound = false;
bool x6_hintMemo = false;
CHUDMemoParms() = default;
CHUDMemoParms(float alpha, bool initializeMemo, bool hintDismissSound, bool hintMemo)
: x0_alpha(alpha), x4_initializeMemo(initializeMemo),
x5_hintDismissSound(hintDismissSound), x6_hintMemo(hintMemo) {}
CHUDMemoParms(CInputStream& in)
{
x0_alpha = in.readFloatBig();
x4_initializeMemo = in.readBool();
}
};
enum class EHudState enum class EHudState
{ {
Combat, Combat,
@ -182,7 +166,7 @@ class CSamusHud
CHUDMemoParms x548_hudMemoParms; CHUDMemoParms x548_hudMemoParms;
TLockedToken<CStringTable> x550_hudMemoString; TLockedToken<CStringTable> x550_hudMemoString;
u32 x554_hudMemoIdx = 0; u32 x554_hudMemoIdx = 0;
float x558_messageTextAlpha = 0.f; float x558_messageTextTime = 0.f;
float x55c_lastSfxChars = 0.f; float x55c_lastSfxChars = 0.f;
float x560_messageTextScale = 0.f; float x560_messageTextScale = 0.f;
CSfxHandle x564_freeLookSfx; CSfxHandle x564_freeLookSfx;

View File

@ -5,18 +5,31 @@
namespace urde namespace urde
{ {
class CHUDMemoParms class CHUDMemoParms
{ {
float x0_; float x0_dispTime = 0.f;
bool x4_; bool x4_clearMemoWindow = false;
bool x5_ = false; bool x5_fadeOutOnly = false;
bool x6_ = false; bool x6_hintMemo = false;
public: public:
CHUDMemoParms() = default;
CHUDMemoParms(float dispTime, bool clearMemoWindow, bool fadeOutOnly, bool hintMemo)
: x0_dispTime(dispTime), x4_clearMemoWindow(clearMemoWindow),
x5_fadeOutOnly(fadeOutOnly), x6_hintMemo(hintMemo) {}
CHUDMemoParms(CInputStream& in) CHUDMemoParms(CInputStream& in)
: x0_(in.readFloatBig()), {
x4_(in.readBool()) x0_dispTime = in.readFloatBig();
{} x4_clearMemoWindow = in.readBool();
}
float GetDisplayTime() const { return x0_dispTime; }
bool IsClearMemoWindow() const { return x4_clearMemoWindow; }
bool IsFadeOutOnly() const { return x5_fadeOutOnly; }
bool IsHintMemo() const { return x6_hintMemo; }
}; };
} }
#endif // CHUDMEMOPARMS_HPP #endif // CHUDMEMOPARMS_HPP