Skip to content

Commit

Permalink
Merge pull request #2166 from Kirus59/upstream-merge-66
Browse files Browse the repository at this point in the history
Upstream merge 66
  • Loading branch information
stalengd authored Oct 27, 2024
2 parents 24c9345 + 991cd47 commit db4db6c
Show file tree
Hide file tree
Showing 110 changed files with 4,912 additions and 2,723 deletions.
11 changes: 10 additions & 1 deletion Content.Client/Entry/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Content.Client.DebugMon;
using Content.Client.Eui;
using Content.Client.Fullscreen;
using Content.Client.GameTicking.Managers;
using Content.Client.GhostKick;
using Content.Client.Guidebook;
using Content.Client.Input;
Expand Down Expand Up @@ -79,6 +80,7 @@ public sealed class EntryPoint : GameClient
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly DiscordPlayerInfoManager _discordPlayerInfoManager = default!; // SS220 discord info manager
[Dependency] private readonly DebugMonitorManager _debugMonitorManager = default!;
[Dependency] private readonly TitleWindowManager _titleWindowManager = default!;

public override void Init()
{
Expand Down Expand Up @@ -149,6 +151,12 @@ public override void Init()
_configManager.SetCVar("interface.resolutionAutoScaleMinimum", 0.5f);
}

public override void Shutdown()
{
base.Shutdown();
_titleWindowManager.Shutdown();
}

public override void PostInit()
{
base.PostInit();
Expand All @@ -172,7 +180,8 @@ public override void PostInit()
_discordAuthManager.Initialize(); // Corvax-DiscordAuth
_userInterfaceManager.SetActiveTheme(_configManager.GetCVar(CVars.InterfaceTheme));
_documentParsingManager.Initialize();
_discordPlayerInfoManager.Initialize();
_discordPlayerInfoManager.Initialize(); // SS220 tier info
_titleWindowManager.Initialize();

_baseClient.RunLevelChanged += (_, args) =>
{
Expand Down
62 changes: 62 additions & 0 deletions Content.Client/GameTicking/Managers/TitleWindowManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using Content.Shared.CCVar;
using Robust.Client;
using Robust.Client.Graphics;
using Robust.Shared;
using Robust.Shared.Configuration;

namespace Content.Client.GameTicking.Managers;

public sealed class TitleWindowManager
{
[Dependency] private readonly IBaseClient _client = default!;
[Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IGameController _gameController = default!;

public void Initialize()
{
_cfg.OnValueChanged(CVars.GameHostName, OnHostnameChange, true);
_cfg.OnValueChanged(CCVars.GameHostnameInTitlebar, OnHostnameTitleChange, true);

_client.RunLevelChanged += OnRunLevelChangedChange;
}

public void Shutdown()
{
_cfg.UnsubValueChanged(CVars.GameHostName, OnHostnameChange);
_cfg.UnsubValueChanged(CCVars.GameHostnameInTitlebar, OnHostnameTitleChange);
}

private void OnHostnameChange(string hostname)
{
var defaultWindowTitle = _gameController.GameTitle();

// Since the game assumes the server name is MyServer and that GameHostnameInTitlebar CCVar is true by default
// Lets just... not show anything. This also is used to revert back to just the game title on disconnect.
if (_client.RunLevel == ClientRunLevel.Initialize)
{
_clyde.SetWindowTitle(defaultWindowTitle);
return;
}

if (_cfg.GetCVar(CCVars.GameHostnameInTitlebar))
// If you really dislike the dash I guess change it here
_clyde.SetWindowTitle(hostname + " - " + defaultWindowTitle);
else
_clyde.SetWindowTitle(defaultWindowTitle);
}

// Clients by default assume game.hostname_in_titlebar is true
// but we need to clear it as soon as we join and actually receive the servers preference on this.
// This will ensure we rerun OnHostnameChange and set the correct title bar name.
private void OnHostnameTitleChange(bool colonthree)
{
OnHostnameChange(_cfg.GetCVar(CVars.GameHostName));
}

// This is just used we can rerun the hostname change function when we disconnect to revert back to just the games title.
private void OnRunLevelChangedChange(object? sender, RunLevelChangedEventArgs runLevelChangedEventArgs)
{
OnHostnameChange(_cfg.GetCVar(CVars.GameHostName));
}
}
2 changes: 2 additions & 0 deletions Content.Client/IoC/ClientContentIoC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Content.Client.DebugMon;
using Content.Client.Eui;
using Content.Client.Fullscreen;
using Content.Client.GameTicking.Managers;
using Content.Client.GhostKick;
using Content.Client.Guidebook;
using Content.Client.Launcher;
Expand Down Expand Up @@ -65,6 +66,7 @@ public static void Register()
collection.Register<DebugMonitorManager>();
collection.Register<PlayerRateLimitManager>();
collection.Register<SharedPlayerRateLimitManager, PlayerRateLimitManager>();
collection.Register<TitleWindowManager>();
}
}
}
3 changes: 2 additions & 1 deletion Content.Client/VendingMachines/UI/VendingMachineMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:co="clr-namespace:Content.Client.UserInterface.Controls">
xmlns:co="clr-namespace:Content.Client.UserInterface.Controls"
MinHeight="210">
<BoxContainer Name="MainContainer" Orientation="Vertical">
<LineEdit Name="SearchBar" PlaceHolder="{Loc 'vending-machine-component-search-filter'}" HorizontalExpand="True" Margin ="4 4"/>
<co:SearchListContainer Name="VendingContents" VerticalExpand="True" Margin="4 4"/>
Expand Down
Loading

0 comments on commit db4db6c

Please sign in to comment.