Skip to content
Draft
17 changes: 17 additions & 0 deletions CelesteNet.Client/CelesteNetClientSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,23 @@ public class PlayerListUIMenu {
[SettingSubText("modoptions_celestenetclient_hideownchannelhint")]
public bool HideOwnChannelName { get; set; } = false;

[SettingSubText("modoptions_celestenetclient_hideownlocationhint")]
public CelesteNetPlayerListComponent.LocationVisibility HideOwnLocation {
get => _HideOwnLocation;
set
{
if (_HideOwnLocation == value)
return;

_HideOwnLocation = value;

if (CelesteNetClientModule.Instance.Context != null)
CelesteNetClientModule.Instance.Context.Main.StateUpdated = true;
}
}

private CelesteNetPlayerListComponent.LocationVisibility _HideOwnLocation = CelesteNetPlayerListComponent.LocationVisibility.Always;

[SettingSubText("modoptions_celestenetclient_plscrollmodehint")]
public CelesteNetPlayerListComponent.ScrollModes PlayerListScrollMode { get; set; } = CelesteNetPlayerListComponent.ScrollModes.HoldTab;

Expand Down
2 changes: 1 addition & 1 deletion CelesteNet.Client/Components/CelesteNetChatComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class CelesteNetChatComponent : CelesteNetGameComponent {
public Color PublicChatColor = Color.White;

// will get filled out once we join the server
protected string CurrentChannelName = "main";
public string CurrentChannelName = "main";

public float? RenderPositionY { get; private set; } = null;

Expand Down
27 changes: 25 additions & 2 deletions CelesteNet.Client/Components/CelesteNetMainComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ public class CelesteNetMainComponent : CelesteNetGameComponent {

private ILHook ILHookTransitionRoutine;

private string PreviousChannelName = "main";
private string CurrentChannelName => CelesteNetClientModule.Instance.Context?.Chat.CurrentChannelName;

public CelesteNetMainComponent(CelesteNetClientContext context, Game game)
: base(context, game) {

Expand Down Expand Up @@ -781,6 +784,12 @@ public override void Update(GameTime gameTime) {
level.Add(PlayerNameTag = new(Player, Client.PlayerInfo.DisplayName));
}
PlayerNameTag.Alpha = Settings.InGameHUD.ShowOwnName ? 1f : 0f;

if (CurrentChannelName != PreviousChannelName)
{
PreviousChannelName = CurrentChannelName;
StateUpdated = true;
}
}

public override void Tick() {
Expand Down Expand Up @@ -920,14 +929,28 @@ private void ILTransitionRoutine(ILContext il) {

public void SendState() {
try {
Client?.SendAndHandle(new DataPlayerState {
DataPlayerState playerState = new DataPlayerState {
Player = Client.PlayerInfo,
SID = Session?.Area.GetSID() ?? MapEditorArea?.SID ?? "",
Mode = Session?.Area.Mode ?? MapEditorArea?.Mode ?? AreaMode.Normal,
Level = Session?.Level ?? (MapEditorArea != null ? LevelDebugMap : ""),
Idle = ForceIdle.Count != 0 || (Player?.Scene is Level level && (level.FrozenOrPaused || level.Overlay != null)),
Interactive = Settings.InGame.Interactions
});
};
bool hideLocation = Client.Settings.PlayerListUI.HideOwnLocation switch
{
CelesteNetPlayerListComponent.LocationVisibility.Always => false,
CelesteNetPlayerListComponent.LocationVisibility.HiddenInMain => CurrentChannelName == "main",
CelesteNetPlayerListComponent.LocationVisibility.PrivateChannels => !CurrentChannelName.StartsWith("!"),
CelesteNetPlayerListComponent.LocationVisibility.Never => true,
_ => throw new ArgumentException("Invalid LocationVisibility value!", nameof(Client.Settings.PlayerListUI.HideOwnLocation))
};
if (hideLocation) {
playerState.SID = "";
playerState.Mode = AreaMode.Normal;
playerState.Level = "";
}
Client?.SendAndHandle(playerState);
} catch (Exception e) {
Logger.Log(LogLevel.INF, "client-main", $"Error in SendState:\n{e}");
Context.DisposeSafe();
Expand Down
7 changes: 7 additions & 0 deletions CelesteNet.Client/Components/CelesteNetPlayerListComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,5 +1137,12 @@ public override void Render(float y, float scale, ref Vector2 sizeAll, float alp

}

public enum LocationVisibility
{
Always,
HiddenInMain,
PrivateChannels,
Never
}
}
}
2 changes: 2 additions & 0 deletions Dialog/English.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
MODOPTIONS_CELESTENETCLIENT_RESETGENERALHINT= Resets the options above to defaults, excluding Name/Key
MODOPTIONS_CELESTENETCLIENT_HIDEOWNCHANNEL= Hide your channel name
MODOPTIONS_CELESTENETCLIENT_HIDEOWNCHANNELHINT= Intended for streamers.{n}Prevents leaking your channel name when receiving a message or opening the player list.
MODOPTIONS_CELESTENETCLIENT_HIDEOWNLOCATION= Location Visibility
MODOPTIONS_CELESTENETCLIENT_HIDEOWNLOCATIONHINT= Hides the map you're playing.{n}Useful when mapping in secret.
MODOPTIONS_CELESTENETCLIENT_SETTINGS= Settings

MODOPTIONS_CELESTENETCLIENT_EXTRASERVERS_SLIDER= Switch Servers
Expand Down