Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/globed/core/game/VisualPlayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "../../core/data/PlayerDisplayData.hpp"
#include "../../core/game/PlayerStatusIcons.hpp"
#include <Geode/Geode.hpp>
#include <chrono>

namespace globed {

Expand Down Expand Up @@ -103,6 +104,9 @@ class GLOBED_DLL VisualPlayer : public PlayerObject {
// used to call onEnter, onExit
bool m_prevPaused = false;

// used to track how long a player has been paused, for hide-afk
std::chrono::steady_clock::time_point m_pausedSince{};

bool m_prevRotating = false;
bool m_prevMini = false;

Expand Down
3 changes: 3 additions & 0 deletions src/core/SettingsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ SettingsManager::SettingsManager() {
this->registerSetting("core.player.hide-nearby-classic", false);
this->registerSetting("core.player.hide-nearby-plat", false);
this->registerSetting("core.player.hide-practicing", false);
this->registerSetting("core.player.hide-afk", false);
this->registerSetting("core.player.hide-afk-delay", 10.0f);
this->registerLimits("core.player.hide-afk-delay", 0.f, 60.f);
this->registerSetting("core.player.status-icons", true);
this->registerSetting("core.player.rotate-names", true);
this->registerSetting("core.player.death-effects", true);
Expand Down
2 changes: 2 additions & 0 deletions src/core/game/SettingCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ struct CachedSettings {
bool ghostFollower = globed::setting<bool>("core.dev.ghost-follower");
bool forceVisibility = globed::setting<bool>("core.player.force-visibility");
bool hidePracticing = globed::setting<bool>("core.player.hide-practicing");
bool hideAfk = globed::setting<bool>("core.player.hide-afk");
float hideAfkDelay = globed::setting<float>("core.player.hide-afk-delay");
bool hideNearbyClassic = globed::setting<bool>("core.player.hide-nearby-classic");
bool hideNearbyPlat = globed::setting<bool>("core.player.hide-nearby-plat");
bool showNames = globed::setting<bool>("core.player.show-names");
Expand Down
12 changes: 12 additions & 0 deletions src/core/game/VisualPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,20 @@ void VisualPlayer::updateFromData(
bool shouldMiscVisible = !forceHideEverything;
bool shouldIconVisible = !forceHideIcon && !forceHideEverything;

bool hiddenForAfk = false;
if (!m_isLocalPlayer && g_settings.hideAfk && state.isPaused) {
auto now = std::chrono::steady_clock::now();
if (!m_prevPaused) {
m_pausedSince = now;
}
float pausedSecs = std::chrono::duration<float>(now - m_pausedSince).count();
hiddenForAfk = pausedSecs >= g_settings.hideAfkDelay;
}

if (state.isPracticing && g_settings.hidePracticing) {
shouldIconVisible = shouldMiscVisible = false;
} else if (hiddenForAfk) {
shouldIconVisible = shouldMiscVisible = false;
} else if (!forceHideEverything) {
shouldMiscVisible = ((data.isVisible && !m_playingDeathEffect) || g_settings.forceVisibility) && isNearby;
if (!forceHideIcon) {
Expand Down
8 changes: 8 additions & 0 deletions src/ui/settings/SettingsLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,14 @@ void SettingsLayer::addSettings() {
this->addSetting<BoolSettingCell>("core.player.hide-practicing", "Hide Practicing Players",
"Hide players that are in practice mode."
);
this->addSetting<BoolSettingCell>("core.player.hide-afk", "Hide AFK Players",
"Hide players whose game has been paused for at least the duration set below."
);
auto afkDelaySetting = this->addSetting<FloatSettingCell>("core.player.hide-afk-delay", "AFK Countdown (sec)",
"How long a player must stay paused before being hidden. 0 = hide instantly on pause."
);
afkDelaySetting->setPercentageBased(false);
afkDelaySetting->setStep(1.f);
this->addSetting<BoolSettingCell>("core.player.status-icons", "Show Status Icons",
"Show icons indicating player states, such as paused, practicing, voice chatting, editor."
);
Expand Down