Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 50b21b8

Browse files
committed
Added settings flag for always displaying unheld items when in strategic mode
Added support for flag to gameplay settings menu and held device
1 parent fe20858 commit 50b21b8

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

Entities/HeldDevice.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,12 @@ void HeldDevice::DrawHUD(BITMAP *pTargetBitmap, const Vector &targetPos, int whi
578578
if (pSymbolFont && pTextFont) {
579579
const Activity *activity = g_ActivityMan.GetActivity();
580580
float unheldItemDisplayRange = activity->GetActivityState() == Activity::ActivityState::Running ? g_SettingsMan.GetUnheldItemsHUDDisplayRange() : -1.0F;
581+
if (g_SettingsMan.AlwaysDisplayUnheldItemsInStrategicMode()) {
582+
const GameActivity *gameActivity = dynamic_cast<const GameActivity *>(activity);
583+
if (gameActivity && gameActivity->GetViewState(viewingPlayer) == GameActivity::ViewState::ActorSelect) { unheldItemDisplayRange = -1.0F; }
581584
}
585+
// Note - to avoid item HUDs flickering in and out, we need to add a little leeway when hiding them if they're already displayed.
586+
if (m_SeenByPlayer.at(viewingPlayer) && unheldItemDisplayRange > 0) { unheldItemDisplayRange += 3.0F; }
582587
m_SeenByPlayer.at(viewingPlayer) = unheldItemDisplayRange < 0 || (unheldItemDisplayRange > 0 && g_SceneMan.ShortestDistance(m_Pos, g_SceneMan.GetScrollTarget(whichScreen), g_SceneMan.SceneWrapsX()).GetMagnitude() < unheldItemDisplayRange);
583588

584589
if (m_SeenByPlayer.at(viewingPlayer)) {

Managers/SettingsMan.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace RTE {
2222
m_FlashOnBrainDamage = true;
2323
m_BlipOnRevealUnseen = true;
2424
m_UnheldItemsHUDDisplayRange = 25;
25+
m_AlwaysDisplayUnheldItemsInStrategicMode = true;
2526
m_EndlessMetaGameMode = false;
2627
m_EnableCrabBombs = false;
2728
m_CrabBombThreshold = 42;
@@ -139,6 +140,8 @@ namespace RTE {
139140
reader >> g_MovableMan.m_MaxDroppedItems;
140141
} else if (propName == "UnheldItemsHUDDisplayRange") {
141142
SetUnheldItemsHUDDisplayRange(std::stof(reader.ReadPropValue()));
143+
} else if (propName == "AlwaysDisplayUnheldItemsInStrategicMode") {
144+
reader >> m_AlwaysDisplayUnheldItemsInStrategicMode;
142145
} else if (propName == "SloMoThreshold") {
143146
reader >> g_MovableMan.m_SloMoThreshold;
144147
} else if (propName == "SloMoDurationMS") {
@@ -314,6 +317,7 @@ namespace RTE {
314317
writer.NewPropertyWithValue("BlipOnRevealUnseen", m_BlipOnRevealUnseen);
315318
writer.NewPropertyWithValue("MaxUnheldItems", g_MovableMan.m_MaxDroppedItems);
316319
writer.NewPropertyWithValue("UnheldItemsHUDDisplayRange", m_UnheldItemsHUDDisplayRange);
320+
writer.NewPropertyWithValue("AlwaysDisplayUnheldItemsInStrategicMode", m_AlwaysDisplayUnheldItemsInStrategicMode);
317321
writer.NewPropertyWithValue("SloMoThreshold", g_MovableMan.m_SloMoThreshold);
318322
writer.NewPropertyWithValue("SloMoDurationMS", g_MovableMan.m_SloMoDuration);
319323
writer.NewPropertyWithValue("EndlessMetaGameMode", m_EndlessMetaGameMode);

Managers/SettingsMan.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,18 @@ namespace RTE {
107107
/// <param name="newRadius">The new range in which devices on Scene will show the pick-up HUD, in pixels. 0 means HUDs are hidden, -1 means unlimited range.</param>
108108
void SetUnheldItemsHUDDisplayRange(float newRadius) { m_UnheldItemsHUDDisplayRange = std::floor(newRadius); }
109109

110+
/// <summary>
111+
/// Gets whether or not devices on Scene should always show their pick-up HUD when the player is in strategic mode.
112+
/// </summary>
113+
/// <returns>Whether or not devices on Scene should always show their pick-up HUD when the player is in strategic mode.</returns>
114+
bool AlwaysDisplayUnheldItemsInStrategicMode() const { return m_AlwaysDisplayUnheldItemsInStrategicMode; }
115+
116+
/// <summary>
117+
/// Sets whether or not devices on Scene should always show their pick-up HUD when the player is in strategic mode.
118+
/// </summary>
119+
/// <param name="shouldShowUnheldItemsInStrategicMode">Whether or not devices on Scene should always show their pick-up HUD when the player is in strategic mode.</param>
120+
void SetAlwaysDisplayUnheldItemsInStrategicMode(bool shouldShowUnheldItemsInStrategicMode) { m_AlwaysDisplayUnheldItemsInStrategicMode = shouldShowUnheldItemsInStrategicMode; }
121+
110122
/// <summary>
111123
/// Whether red and white flashes appear when brain is damaged.
112124
/// </summary>
@@ -414,6 +426,7 @@ namespace RTE {
414426
bool m_FlashOnBrainDamage; //!< Whether red flashes on brain damage are on or off.
415427
bool m_BlipOnRevealUnseen; //!< Blip if unseen is revealed.
416428
float m_UnheldItemsHUDDisplayRange; //!< Range in which devices on Scene will show the pick-up HUD, in pixels. 0 means HUDs are hidden, -1 means unlimited range.
429+
bool m_AlwaysDisplayUnheldItemsInStrategicMode; //!< Whether or not devices on Scene should always show their pick-up HUD when when the player is in strategic mode.
417430
bool m_EndlessMetaGameMode; //!< Endless MetaGame mode.
418431
bool m_EnableCrabBombs; //!< Whether all actors (except Brains and Doors) should be annihilated if a number exceeding the crab bomb threshold is released at once.
419432
int m_CrabBombThreshold; //!< The number of crabs needed to be released at once to trigger the crab bomb effect.

Menus/SettingsGameplayGUI.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ namespace RTE {
5858
}
5959
m_UnheldItemsHUDDisplayRangeLabel = dynamic_cast<GUILabel *>(m_GUIControlManager->GetControl("LabelUnheldItemsHUDRangeValue"));
6060
UpdateUnheldItemsHUDDisplayRange();
61+
62+
m_AlwaysDisplayUnheldItemsInStrategicModeCheckbox = dynamic_cast<GUICheckbox *>(m_GUIControlManager->GetControl("CheckboxAlwaysShowUnheldItemsInStrategicMode"));
63+
m_AlwaysDisplayUnheldItemsInStrategicModeCheckbox->SetCheck(g_SettingsMan.AlwaysDisplayUnheldItemsInStrategicMode());
6164
}
6265

6366
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -129,6 +132,8 @@ namespace RTE {
129132
UpdateCrabBombThresholdTextbox();
130133
} else if (guiEvent.GetControl() == m_UnheldItemsHUDDisplayRangeSlider) {
131134
UpdateUnheldItemsHUDDisplayRange();
135+
} else if (guiEvent.GetControl() == m_AlwaysDisplayUnheldItemsInStrategicModeCheckbox) {
136+
g_SettingsMan.SetAlwaysDisplayUnheldItemsInStrategicMode(m_AlwaysDisplayUnheldItemsInStrategicModeCheckbox->GetCheck());
132137
// Update both textboxes when clicking the main CollectionBox, otherwise clicking off focused textboxes does not remove their focus or update the setting values and they will still capture keyboard input.
133138
} else if (guiEvent.GetControl() == m_GameplaySettingsBox && guiEvent.GetMsg() == GUICollectionBox::Clicked && !m_GameplaySettingsBox->HasFocus()) {
134139
UpdateMaxUnheldItemsTextbox();

Menus/SettingsGameplayGUI.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ namespace RTE {
5959
GUITextBox *m_CrabBombThresholdTextbox;
6060
GUISlider *m_UnheldItemsHUDDisplayRangeSlider;
6161
GUILabel *m_UnheldItemsHUDDisplayRangeLabel;
62+
GUICheckbox *m_AlwaysDisplayUnheldItemsInStrategicModeCheckbox;
6263

6364
#pragma region Gameplay Settings Handling
6465
/// <summary>

0 commit comments

Comments
 (0)