Clean up client game ticker status code.

Fixes #495
This commit is contained in:
Pieter-Jan Briers
2020-02-26 16:42:12 +01:00
parent 0adc134cd4
commit 0e6b55de66
14 changed files with 484 additions and 468 deletions

View File

@@ -178,11 +178,6 @@ namespace Content.Client
_escapeMenuOwner.Initialize(); _escapeMenuOwner.Initialize();
_baseClient.PlayerJoinedGame += (sender, args) =>
{
_stateManager.RequestStateChange<GameScreen>();
};
_baseClient.PlayerJoinedServer += (sender, args) => _baseClient.PlayerJoinedServer += (sender, args) =>
{ {
IoCManager.Resolve<IMapManager>().CreateNewMapEntity(MapId.Nullspace); IoCManager.Resolve<IMapManager>().CreateNewMapEntity(MapId.Nullspace);
@@ -242,7 +237,6 @@ namespace Content.Client
{ {
case ModUpdateLevel.FramePreEngine: case ModUpdateLevel.FramePreEngine:
IoCManager.Resolve<IClientNotifyManager>().FrameUpdate(frameEventArgs); IoCManager.Resolve<IClientNotifyManager>().FrameUpdate(frameEventArgs);
IoCManager.Resolve<IClientGameTicker>().FrameUpdate(frameEventArgs);
IoCManager.Resolve<IChatManager>().FrameUpdate(frameEventArgs); IoCManager.Resolve<IChatManager>().FrameUpdate(frameEventArgs);
break; break;
} }

View File

@@ -41,7 +41,7 @@ namespace Content.Client
private void StateManagerOnOnStateChanged(StateChangedEventArgs obj) private void StateManagerOnOnStateChanged(StateChangedEventArgs obj)
{ {
if (obj.NewState is GameScreen) if (obj.NewState is GameScreenBase)
{ {
// Switched TO GameScreen. // Switched TO GameScreen.
_escapeMenu = new EscapeMenu(_clientConsole, _tileDefinitionManager, _placementManager, _escapeMenu = new EscapeMenu(_clientConsole, _tileDefinitionManager, _placementManager,
@@ -52,7 +52,7 @@ namespace Content.Client
_inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, _inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu,
InputCmdHandler.FromDelegate(s => Enabled())); InputCmdHandler.FromDelegate(s => Enabled()));
} }
else if (obj.OldState is GameScreen) else if (obj.OldState is GameScreenBase)
{ {
// Switched FROM GameScreen. // Switched FROM GameScreen.
_escapeMenu.Dispose(); _escapeMenu.Dispose();

View File

@@ -77,7 +77,7 @@ namespace Content.Client.GameObjects.EntitySystems
return true; return true;
} }
if (!(_stateManager.CurrentState is GameScreen gameScreen)) if (!(_stateManager.CurrentState is GameScreenBase gameScreen))
{ {
return false; return false;
} }

View File

@@ -1,26 +1,10 @@
using System; using System;
using System.Linq;
using Content.Client.Chat;
using Content.Client.Interfaces; using Content.Client.Interfaces;
using Content.Client.Interfaces.Chat; using Content.Client.State;
using Content.Client.UserInterface;
using Content.Shared; using Content.Shared;
using Content.Shared.Input; using Robust.Client.Interfaces.State;
using Robust.Client;
using Robust.Client.Console;
using Robust.Client.Interfaces;
using Robust.Client.Interfaces.Input;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Interfaces.UserInterface;
using Robust.Client.Player;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Network; using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
@@ -30,289 +14,55 @@ namespace Content.Client.GameTicking
{ {
#pragma warning disable 649 #pragma warning disable 649
[Dependency] private IClientNetManager _netManager; [Dependency] private IClientNetManager _netManager;
[Dependency] private IUserInterfaceManager _userInterfaceManager; [Dependency] private IStateManager _stateManager;
[Dependency] private IInputManager _inputManager;
[Dependency] private IBaseClient _baseClient;
[Dependency] private IChatManager _chatManager;
[Dependency] private IClientConsole _console;
[Dependency] private ILocalizationManager _localization;
[Dependency] private IResourceCache _resourceCache;
[Dependency] private IPlayerManager _playerManager;
[Dependency] private IGameHud _gameHud;
[Dependency] private IEntityManager _entityManager;
[Dependency] private IClientPreferencesManager _preferencesManager;
[Dependency] private IPrototypeManager _prototypeManager;
#pragma warning restore 649 #pragma warning restore 649
[ViewVariables] private bool _areWeReady;
[ViewVariables] private CharacterSetupGui _characterSetup;
[ViewVariables] private ChatBox _gameChat;
[ViewVariables] private bool _gameStarted;
[ViewVariables] private bool _initialized; [ViewVariables] private bool _initialized;
[ViewVariables] private LobbyGui _lobby;
[ViewVariables] private string _serverInfoBlob; [ViewVariables] public bool AreWeReady { get; private set; }
[ViewVariables] private DateTime _startTime; [ViewVariables] public bool IsGameStarted { get; private set; }
[ViewVariables] private TickerState _tickerState; [ViewVariables] public string ServerInfoBlob { get; private set; }
[ViewVariables] public DateTime StartTime { get; private set; }
public event Action InfoBlobUpdated;
public event Action LobbyStatusUpdated;
public void Initialize() public void Initialize()
{ {
DebugTools.Assert(!_initialized); DebugTools.Assert(!_initialized);
_netManager.RegisterNetMessage<MsgTickerJoinLobby>(nameof(MsgTickerJoinLobby), _joinLobby); _netManager.RegisterNetMessage<MsgTickerJoinLobby>(nameof(MsgTickerJoinLobby), JoinLobby);
_netManager.RegisterNetMessage<MsgTickerJoinGame>(nameof(MsgTickerJoinGame), _joinGame); _netManager.RegisterNetMessage<MsgTickerJoinGame>(nameof(MsgTickerJoinGame), JoinGame);
_netManager.RegisterNetMessage<MsgTickerLobbyStatus>(nameof(MsgTickerLobbyStatus), _lobbyStatus); _netManager.RegisterNetMessage<MsgTickerLobbyStatus>(nameof(MsgTickerLobbyStatus), LobbyStatus);
_netManager.RegisterNetMessage<MsgTickerLobbyInfo>(nameof(MsgTickerLobbyInfo), _lobbyInfo); _netManager.RegisterNetMessage<MsgTickerLobbyInfo>(nameof(MsgTickerLobbyInfo), LobbyInfo);
_baseClient.RunLevelChanged += BaseClientOnRunLevelChanged;
_playerManager.PlayerListUpdated += PlayerManagerOnPlayerListUpdated;
_initialized = true; _initialized = true;
} }
private void PlayerManagerOnPlayerListUpdated(object sender, EventArgs e) private void JoinLobby(MsgTickerJoinLobby message)
{ {
if (_lobby == null) _stateManager.RequestStateChange<LobbyState>();
{
return;
}
_updatePlayerList();
} }
private void _updatePlayerList() private void LobbyStatus(MsgTickerLobbyStatus message)
{ {
_lobby.OnlinePlayerItemList.Clear(); StartTime = message.StartTime;
foreach (var session in _playerManager.Sessions.OrderBy(s => s.Name)) IsGameStarted = message.IsRoundStarted;
{ AreWeReady = message.YouAreReady;
_lobby.OnlinePlayerItemList.AddItem(session.Name);
} LobbyStatusUpdated?.Invoke();
} }
private void BaseClientOnRunLevelChanged(object sender, RunLevelChangedEventArgs e) private void LobbyInfo(MsgTickerLobbyInfo message)
{ {
if (e.NewLevel != ClientRunLevel.Initialize) ServerInfoBlob = message.TextBlob;
{
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat, null);
return;
}
_tickerState = TickerState.Unset; InfoBlobUpdated?.Invoke();
_lobby?.Dispose();
_lobby = null;
_gameChat?.Dispose();
_gameChat = null;
_gameHud.RootControl.Orphan();
} }
public void FrameUpdate(FrameEventArgs frameEventArgs) private void JoinGame(MsgTickerJoinGame message)
{ {
if (_lobby == null) _stateManager.RequestStateChange<GameScreen>();
{
return;
}
if (_gameStarted)
{
_lobby.StartTime.Text = "";
return;
}
string text;
var difference = _startTime - DateTime.UtcNow;
if (difference.Ticks < 0)
{
if (difference.TotalSeconds < -5)
{
text = _localization.GetString("Right Now?");
}
else
{
text = _localization.GetString("Right Now");
}
}
else
{
text = $"{(int) Math.Floor(difference.TotalMinutes)}:{difference.Seconds:D2}";
}
_lobby.StartTime.Text = _localization.GetString("Round Starts In: {0}", text);
}
private void _lobbyStatus(MsgTickerLobbyStatus message)
{
_startTime = message.StartTime;
_gameStarted = message.IsRoundStarted;
_areWeReady = message.YouAreReady;
_updateLobbyUi();
}
private void _lobbyInfo(MsgTickerLobbyInfo message)
{
_serverInfoBlob = message.TextBlob;
_updateLobbyUi();
}
private void _updateLobbyUi()
{
if (_lobby == null)
{
return;
}
if (_gameStarted)
{
_lobby.ReadyButton.Text = _localization.GetString("Join");
_lobby.ReadyButton.ToggleMode = false;
_lobby.ReadyButton.Pressed = false;
}
else
{
_lobby.StartTime.Text = "";
_lobby.ReadyButton.Text = _localization.GetString("Ready Up");
_lobby.ReadyButton.ToggleMode = true;
_lobby.ReadyButton.Pressed = _areWeReady;
}
_lobby.ServerInfo.SetInfoBlob(_serverInfoBlob);
}
private void _joinLobby(MsgTickerJoinLobby message)
{
if (_tickerState == TickerState.InLobby)
{
return;
}
if (_gameChat != null)
{
_gameChat.Dispose();
_gameChat = null;
}
_gameHud.RootControl.Orphan();
_tickerState = TickerState.InLobby;
_characterSetup = new CharacterSetupGui(_entityManager, _localization, _resourceCache, _preferencesManager, _prototypeManager);
LayoutContainer.SetAnchorPreset(_characterSetup, LayoutContainer.LayoutPreset.Wide);
_characterSetup.CloseButton.OnPressed += args =>
{
_characterSetup.Save();
_lobby.CharacterPreview.UpdateUI();
_userInterfaceManager.StateRoot.AddChild(_lobby);
_userInterfaceManager.StateRoot.RemoveChild(_characterSetup);
};
_lobby = new LobbyGui(_entityManager, _localization, _resourceCache, _preferencesManager);
_userInterfaceManager.StateRoot.AddChild(_lobby);
LayoutContainer.SetAnchorPreset(_lobby, LayoutContainer.LayoutPreset.Wide);
_chatManager.SetChatBox(_lobby.Chat);
_lobby.Chat.DefaultChatFormat = "ooc \"{0}\"";
_lobby.ServerName.Text = _baseClient.GameInfo.ServerName;
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
InputCmdHandler.FromDelegate(s => _focusChat(_lobby.Chat)));
_updateLobbyUi();
_lobby.CharacterPreview.CharacterSetupButton.OnPressed += args =>
{
SetReady(false);
_userInterfaceManager.StateRoot.RemoveChild(_lobby);
_userInterfaceManager.StateRoot.AddChild(_characterSetup);
};
_lobby.ObserveButton.OnPressed += args => _console.ProcessCommand("observe");
_lobby.ReadyButton.OnPressed += args =>
{
if (!_gameStarted)
{
return;
}
_console.ProcessCommand("joingame");
};
_lobby.ReadyButton.OnToggled += args =>
{
SetReady(args.Pressed);
};
_lobby.LeaveButton.OnPressed += args => _console.ProcessCommand("disconnect");
_updatePlayerList();
}
private void SetReady(bool newReady)
{
if (_gameStarted)
{
return;
}
_console.ProcessCommand($"toggleready {newReady}");
}
private void _joinGame(MsgTickerJoinGame message)
{
if (_tickerState == TickerState.InGame)
{
return;
}
_tickerState = TickerState.InGame;
if (_lobby != null)
{
_lobby.Dispose();
_lobby = null;
}
_gameChat = new ChatBox();
_userInterfaceManager.StateRoot.AddChild(_gameChat);
LayoutContainer.SetAnchorAndMarginPreset(_gameChat, LayoutContainer.LayoutPreset.TopRight, margin: 10);
LayoutContainer.SetAnchorAndMarginPreset(_gameChat, LayoutContainer.LayoutPreset.TopRight, margin: 10);
LayoutContainer.SetMarginLeft(_gameChat, -475);
LayoutContainer.SetMarginBottom(_gameChat, 235);
_userInterfaceManager.StateRoot.AddChild(_gameHud.RootControl);
_chatManager.SetChatBox(_gameChat);
_gameChat.DefaultChatFormat = "say \"{0}\"";
_gameChat.Input.PlaceHolder = _localization.GetString("Say something! [ for OOC");
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
InputCmdHandler.FromDelegate(s => _focusChat(_gameChat)));
}
private void _focusChat(ChatBox chat)
{
if (chat == null || _userInterfaceManager.KeyboardFocused != null)
{
return;
}
chat.Input.IgnoreNext = true;
chat.Input.GrabKeyboardFocus();
}
private enum TickerState
{
Unset = 0,
/// <summary>
/// The client is in the lobby.
/// </summary>
InLobby = 1,
/// <summary>
/// The client is NOT in the lobby.
/// Do not confuse this with the client session status.
/// </summary>
InGame = 2
} }
} }
} }

View File

@@ -1,10 +1,16 @@
using Robust.Shared.Timing; using System;
namespace Content.Client.Interfaces namespace Content.Client.Interfaces
{ {
public interface IClientGameTicker public interface IClientGameTicker
{ {
bool IsGameStarted { get; }
string ServerInfoBlob { get; }
bool AreWeReady { get; }
DateTime StartTime { get; }
void Initialize(); void Initialize();
void FrameUpdate(FrameEventArgs FrameEventArgs); event Action InfoBlobUpdated;
event Action LobbyStatusUpdated;
} }
} }

View File

@@ -1,171 +1,65 @@
using System.Collections.Generic; using Content.Client.Chat;
using System.Linq; using Content.Client.Interfaces.Chat;
using Content.Client.GameObjects.Components; using Content.Client.UserInterface;
using Content.Shared.GameObjects; using Content.Shared.Input;
using Robust.Client.GameObjects.EntitySystems;
using Robust.Client.Interfaces.GameObjects;
using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Client.Interfaces.Graphics.ClientEye;
using Robust.Client.Interfaces.Input; using Robust.Client.Interfaces.Input;
using Robust.Client.Interfaces.Placement; using Robust.Client.Interfaces.UserInterface;
using Robust.Client.Player; using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
using Robust.Shared.Input; using Robust.Shared.Input;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Map; using Robust.Shared.Localization;
using Robust.Shared.Timing; using Robust.Shared.ViewVariables;
namespace Content.Client.State namespace Content.Client.State
{ {
// OH GOD. public class GameScreen : GameScreenBase
// Ok actually it's fine.
// Instantiated dynamically through the StateManager, Dependencies will be resolved.
public sealed partial class GameScreen : Robust.Client.State.State
{ {
#pragma warning disable 649 #pragma warning disable 649
[Dependency] private readonly IClientEntityManager _entityManager; [Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
[Dependency] private readonly IComponentManager _componentManager; [Dependency] private readonly IGameHud _gameHud;
[Dependency] private readonly IInputManager inputManager; [Dependency] private readonly IInputManager _inputManager;
[Dependency] private readonly IPlayerManager playerManager; [Dependency] private readonly IChatManager _chatManager;
[Dependency] private readonly IPlacementManager placementManager;
[Dependency] private readonly IEyeManager eyeManager;
[Dependency] private readonly IEntitySystemManager entitySystemManager;
[Dependency] private readonly IGameTiming timing;
[Dependency] private readonly IMapManager _mapManager;
#pragma warning restore 649 #pragma warning restore 649
private IEntity lastHoveredEntity; [ViewVariables] private ChatBox _gameChat;
public override void Startup() public override void Startup()
{ {
inputManager.KeyBindStateChanged += OnKeyBindStateChanged; base.Startup();
_gameChat = new ChatBox();
_userInterfaceManager.StateRoot.AddChild(_gameChat);
LayoutContainer.SetAnchorAndMarginPreset(_gameChat, LayoutContainer.LayoutPreset.TopRight, margin: 10);
LayoutContainer.SetAnchorAndMarginPreset(_gameChat, LayoutContainer.LayoutPreset.TopRight, margin: 10);
LayoutContainer.SetMarginLeft(_gameChat, -475);
LayoutContainer.SetMarginBottom(_gameChat, 235);
_userInterfaceManager.StateRoot.AddChild(_gameHud.RootControl);
_chatManager.SetChatBox(_gameChat);
_gameChat.DefaultChatFormat = "say \"{0}\"";
_gameChat.Input.PlaceHolder = Loc.GetString("Say something! [ for OOC");
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
InputCmdHandler.FromDelegate(s => FocusChat(_gameChat)));
} }
public override void Shutdown() public override void Shutdown()
{ {
playerManager.LocalPlayer.DetachEntity(); base.Shutdown();
inputManager.KeyBindStateChanged -= OnKeyBindStateChanged; _gameChat.Dispose();
_gameHud.RootControl.Orphan();
} }
public override void Update(FrameEventArgs e) internal static void FocusChat(ChatBox chat)
{ {
_componentManager.CullRemovedComponents(); if (chat == null || chat.UserInterfaceManager.KeyboardFocused != null)
_entityManager.Update(e.DeltaSeconds);
playerManager.Update(e.DeltaSeconds);
}
public override void FrameUpdate(FrameEventArgs e)
{
placementManager.FrameUpdate(e);
_entityManager.FrameUpdate(e.DeltaSeconds);
var mousePosWorld = eyeManager.ScreenToWorld(new ScreenCoordinates(inputManager.MouseScreenPosition));
var entityToClick = GetEntityUnderPosition(mousePosWorld);
var inRange = false;
if (playerManager.LocalPlayer.ControlledEntity != null && entityToClick != null)
{ {
var playerPos = playerManager.LocalPlayer.ControlledEntity.Transform.WorldPosition;
var entityPos = entityToClick.Transform.WorldPosition;
inRange = (entityPos - playerPos).Length <= VerbUtility.InteractionRange;
}
InteractionOutlineComponent outline;
if (entityToClick == lastHoveredEntity)
{
if (entityToClick != null && entityToClick.TryGetComponent(out outline))
{
outline.UpdateInRange(inRange);
}
return; return;
} }
if (lastHoveredEntity != null && !lastHoveredEntity.Deleted && chat.Input.IgnoreNext = true;
lastHoveredEntity.TryGetComponent(out outline)) chat.Input.GrabKeyboardFocus();
{
outline.OnMouseLeave();
}
lastHoveredEntity = entityToClick;
if (lastHoveredEntity != null && lastHoveredEntity.TryGetComponent(out outline))
{
outline.OnMouseEnter(inRange);
}
}
public IEntity GetEntityUnderPosition(GridCoordinates coordinates)
{
var entitiesUnderPosition = GetEntitiesUnderPosition(coordinates);
return entitiesUnderPosition.Count > 0 ? entitiesUnderPosition[0] : null;
}
public IList<IEntity> GetEntitiesUnderPosition(GridCoordinates coordinates)
{
// Find all the entities intersecting our click
var mapCoords = coordinates.ToMap(_mapManager);
var entities = _entityManager.GetEntitiesIntersecting(mapCoords.MapId, mapCoords.Position);
// Check the entities against whether or not we can click them
var foundEntities = new List<(IEntity clicked, int drawDepth)>();
foreach (var entity in entities)
{
if (entity.TryGetComponent<IClientClickableComponent>(out var component)
&& entity.Transform.IsMapTransform
&& component.CheckClick(coordinates.Position, out var drawDepthClicked))
{
foundEntities.Add((entity, drawDepthClicked));
}
}
if (foundEntities.Count == 0)
return new List<IEntity>();
foundEntities.Sort(new ClickableEntityComparer());
// 0 is the top element.
foundEntities.Reverse();
return foundEntities.Select(a => a.clicked).ToList();
}
internal class ClickableEntityComparer : IComparer<(IEntity clicked, int depth)>
{
public int Compare((IEntity clicked, int depth) x, (IEntity clicked, int depth) y)
{
var val = x.depth.CompareTo(y.depth);
if (val != 0)
{
return val;
}
var transx = x.clicked.Transform;
var transy = y.clicked.Transform;
return transx.GridPosition.Y.CompareTo(transy.GridPosition.Y);
}
}
/// <summary>
/// Converts a state change event from outside the simulation to inside the simulation.
/// </summary>
/// <param name="args">Event data values for a bound key state change.</param>
private void OnKeyBindStateChanged(BoundKeyEventArgs args)
{
var inputSys = entitySystemManager.GetEntitySystem<InputSystem>();
var func = args.Function;
var funcId = inputManager.NetworkBindMap.KeyFunctionID(func);
var mousePosWorld = eyeManager.ScreenToWorld(args.PointerLocation);
var entityToClick = GetEntityUnderPosition(mousePosWorld);
var message = new FullInputCmdMessage(timing.CurTick, funcId, args.State, mousePosWorld,
args.PointerLocation, entityToClick?.Uid ?? EntityUid.Invalid);
// client side command handlers will always be sent the local player session.
var session = playerManager.LocalPlayer.Session;
inputSys.HandleInputCommand(session, func, message);
} }
} }
} }

View File

@@ -0,0 +1,160 @@
using System.Collections.Generic;
using System.Linq;
using Content.Client.GameObjects.Components;
using Content.Shared.GameObjects;
using Robust.Client.GameObjects.EntitySystems;
using Robust.Client.Interfaces.GameObjects;
using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Client.Interfaces.Graphics.ClientEye;
using Robust.Client.Interfaces.Input;
using Robust.Client.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Input;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Timing;
namespace Content.Client.State
{
// OH GOD.
// Ok actually it's fine.
// Instantiated dynamically through the StateManager, Dependencies will be resolved.
public partial class GameScreenBase : StateBase
{
#pragma warning disable 649
[Dependency] private readonly IClientEntityManager _entityManager;
[Dependency] private readonly IInputManager _inputManager;
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IEyeManager _eyeManager;
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
[Dependency] private readonly IGameTiming _timing;
[Dependency] private readonly IMapManager _mapManager;
#pragma warning restore 649
private IEntity _lastHoveredEntity;
public override void Startup()
{
_inputManager.KeyBindStateChanged += OnKeyBindStateChanged;
}
public override void Shutdown()
{
_playerManager.LocalPlayer.DetachEntity();
_inputManager.KeyBindStateChanged -= OnKeyBindStateChanged;
}
public override void FrameUpdate(FrameEventArgs e)
{
base.FrameUpdate(e);
var mousePosWorld = _eyeManager.ScreenToWorld(new ScreenCoordinates(_inputManager.MouseScreenPosition));
var entityToClick = GetEntityUnderPosition(mousePosWorld);
var inRange = false;
if (_playerManager.LocalPlayer.ControlledEntity != null && entityToClick != null)
{
var playerPos = _playerManager.LocalPlayer.ControlledEntity.Transform.WorldPosition;
var entityPos = entityToClick.Transform.WorldPosition;
inRange = (entityPos - playerPos).Length <= VerbUtility.InteractionRange;
}
InteractionOutlineComponent outline;
if (entityToClick == _lastHoveredEntity)
{
if (entityToClick != null && entityToClick.TryGetComponent(out outline))
{
outline.UpdateInRange(inRange);
}
return;
}
if (_lastHoveredEntity != null && !_lastHoveredEntity.Deleted &&
_lastHoveredEntity.TryGetComponent(out outline))
{
outline.OnMouseLeave();
}
_lastHoveredEntity = entityToClick;
if (_lastHoveredEntity != null && _lastHoveredEntity.TryGetComponent(out outline))
{
outline.OnMouseEnter(inRange);
}
}
public IEntity GetEntityUnderPosition(GridCoordinates coordinates)
{
var entitiesUnderPosition = GetEntitiesUnderPosition(coordinates);
return entitiesUnderPosition.Count > 0 ? entitiesUnderPosition[0] : null;
}
public IList<IEntity> GetEntitiesUnderPosition(GridCoordinates coordinates)
{
// Find all the entities intersecting our click
var mapCoords = coordinates.ToMap(_mapManager);
var entities = _entityManager.GetEntitiesIntersecting(mapCoords.MapId, mapCoords.Position);
// Check the entities against whether or not we can click them
var foundEntities = new List<(IEntity clicked, int drawDepth)>();
foreach (var entity in entities)
{
if (entity.TryGetComponent<IClientClickableComponent>(out var component)
&& entity.Transform.IsMapTransform
&& component.CheckClick(coordinates.Position, out var drawDepthClicked))
{
foundEntities.Add((entity, drawDepthClicked));
}
}
if (foundEntities.Count == 0)
return new List<IEntity>();
foundEntities.Sort(new ClickableEntityComparer());
// 0 is the top element.
foundEntities.Reverse();
return foundEntities.Select(a => a.clicked).ToList();
}
internal class ClickableEntityComparer : IComparer<(IEntity clicked, int depth)>
{
public int Compare((IEntity clicked, int depth) x, (IEntity clicked, int depth) y)
{
var val = x.depth.CompareTo(y.depth);
if (val != 0)
{
return val;
}
var transx = x.clicked.Transform;
var transy = y.clicked.Transform;
return transx.GridPosition.Y.CompareTo(transy.GridPosition.Y);
}
}
/// <summary>
/// Converts a state change event from outside the simulation to inside the simulation.
/// </summary>
/// <param name="args">Event data values for a bound key state change.</param>
private void OnKeyBindStateChanged(BoundKeyEventArgs args)
{
var inputSys = _entitySystemManager.GetEntitySystem<InputSystem>();
var func = args.Function;
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(func);
var mousePosWorld = _eyeManager.ScreenToWorld(args.PointerLocation);
var entityToClick = GetEntityUnderPosition(mousePosWorld);
var message = new FullInputCmdMessage(_timing.CurTick, funcId, args.State, mousePosWorld,
args.PointerLocation, entityToClick?.Uid ?? EntityUid.Invalid);
// client side command handlers will always be sent the local player session.
var session = _playerManager.LocalPlayer.Session;
inputSys.HandleInputCommand(session, func, message);
}
}
}

View File

@@ -0,0 +1,188 @@
using System;
using System.Linq;
using Content.Client.Interfaces;
using Content.Client.Interfaces.Chat;
using Content.Client.UserInterface;
using Content.Shared.Input;
using Robust.Client.Console;
using Robust.Client.Interfaces;
using Robust.Client.Interfaces.Input;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Interfaces.UserInterface;
using Robust.Client.Player;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
namespace Content.Client.State
{
public class LobbyState : StateBase
{
#pragma warning disable 649
[Dependency] private readonly IBaseClient _baseClient;
[Dependency] private readonly IClientConsole _console;
[Dependency] private readonly IChatManager _chatManager;
[Dependency] private readonly IInputManager _inputManager;
[Dependency] private readonly IEntityManager _entityManager;
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly IClientGameTicker _clientGameTicker;
[Dependency] private readonly IPrototypeManager _prototypeManager;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
[Dependency] private readonly IClientPreferencesManager _preferencesManager;
#pragma warning restore 649
[ViewVariables] private CharacterSetupGui _characterSetup;
[ViewVariables] private LobbyGui _lobby;
public override void Startup()
{
_characterSetup = new CharacterSetupGui(_entityManager, _resourceCache, _preferencesManager,
_prototypeManager);
LayoutContainer.SetAnchorPreset(_characterSetup, LayoutContainer.LayoutPreset.Wide);
_characterSetup.CloseButton.OnPressed += args =>
{
_characterSetup.Save();
_lobby.CharacterPreview.UpdateUI();
_userInterfaceManager.StateRoot.AddChild(_lobby);
_userInterfaceManager.StateRoot.RemoveChild(_characterSetup);
};
_lobby = new LobbyGui(_entityManager, _resourceCache, _preferencesManager);
_userInterfaceManager.StateRoot.AddChild(_lobby);
LayoutContainer.SetAnchorPreset(_lobby, LayoutContainer.LayoutPreset.Wide);
_chatManager.SetChatBox(_lobby.Chat);
_lobby.Chat.DefaultChatFormat = "ooc \"{0}\"";
_lobby.ServerName.Text = _baseClient.GameInfo.ServerName;
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
InputCmdHandler.FromDelegate(s => GameScreen.FocusChat(_lobby.Chat)));
UpdateLobbyUi();
_lobby.CharacterPreview.CharacterSetupButton.OnPressed += args =>
{
SetReady(false);
_userInterfaceManager.StateRoot.RemoveChild(_lobby);
_userInterfaceManager.StateRoot.AddChild(_characterSetup);
};
_lobby.ObserveButton.OnPressed += args => _console.ProcessCommand("observe");
_lobby.ReadyButton.OnPressed += args =>
{
if (!_clientGameTicker.IsGameStarted)
{
return;
}
_console.ProcessCommand("joingame");
};
_lobby.ReadyButton.OnToggled += args =>
{
SetReady(args.Pressed);
};
_lobby.LeaveButton.OnPressed += args => _console.ProcessCommand("disconnect");
UpdatePlayerList();
_playerManager.PlayerListUpdated += PlayerManagerOnPlayerListUpdated;
_clientGameTicker.InfoBlobUpdated += UpdateLobbyUi;
_clientGameTicker.LobbyStatusUpdated += UpdateLobbyUi;
}
public override void Shutdown()
{
_playerManager.PlayerListUpdated -= PlayerManagerOnPlayerListUpdated;
_clientGameTicker.InfoBlobUpdated -= UpdateLobbyUi;
_clientGameTicker.LobbyStatusUpdated -= UpdateLobbyUi;
_lobby.Dispose();
_characterSetup.Dispose();
}
public override void FrameUpdate(FrameEventArgs e)
{
if (_clientGameTicker.IsGameStarted)
{
_lobby.StartTime.Text = "";
return;
}
string text;
var difference = _clientGameTicker.StartTime - DateTime.UtcNow;
if (difference.Ticks < 0)
{
if (difference.TotalSeconds < -5)
{
text = Loc.GetString("Right Now?");
}
else
{
text = Loc.GetString("Right Now");
}
}
else
{
text = $"{(int) Math.Floor(difference.TotalMinutes)}:{difference.Seconds:D2}";
}
_lobby.StartTime.Text = Loc.GetString("Round Starts In: {0}", text);
}
private void PlayerManagerOnPlayerListUpdated(object sender, EventArgs e) => UpdatePlayerList();
private void UpdateLobbyUi()
{
if (_lobby == null)
{
return;
}
if (_clientGameTicker.IsGameStarted)
{
_lobby.ReadyButton.Text = Loc.GetString("Join");
_lobby.ReadyButton.ToggleMode = false;
_lobby.ReadyButton.Pressed = false;
}
else
{
_lobby.StartTime.Text = "";
_lobby.ReadyButton.Text = Loc.GetString("Ready Up");
_lobby.ReadyButton.ToggleMode = true;
_lobby.ReadyButton.Pressed = _clientGameTicker.AreWeReady;
}
_lobby.ServerInfo.SetInfoBlob(_clientGameTicker.ServerInfoBlob);
}
private void UpdatePlayerList()
{
_lobby.OnlinePlayerItemList.Clear();
foreach (var session in _playerManager.Sessions.OrderBy(s => s.Name))
{
_lobby.OnlinePlayerItemList.AddItem(session.Name);
}
}
private void SetReady(bool newReady)
{
if (_clientGameTicker.IsGameStarted)
{
return;
}
_console.ProcessCommand($"toggleready {newReady}");
}
}
}

View File

@@ -0,0 +1,32 @@
using Robust.Client.Interfaces.GameObjects;
using Robust.Client.Interfaces.Placement;
using Robust.Client.Player;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Timing;
namespace Content.Client.State
{
public abstract class StateBase : Robust.Client.State.State
{
#pragma warning disable 649
[Dependency] private readonly IClientEntityManager _entityManager;
[Dependency] private readonly IComponentManager _componentManager;
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IPlacementManager _placementManager;
#pragma warning restore 649
public override void Update(FrameEventArgs e)
{
_componentManager.CullRemovedComponents();
_entityManager.Update(e.DeltaSeconds);
_playerManager.Update(e.DeltaSeconds);
}
public override void FrameUpdate(FrameEventArgs e)
{
_placementManager.FrameUpdate(e);
_entityManager.FrameUpdate(e.DeltaSeconds);
}
}
}

View File

@@ -28,7 +28,6 @@ namespace Content.Client.UserInterface
public readonly Button CloseButton; public readonly Button CloseButton;
public CharacterSetupGui(IEntityManager entityManager, public CharacterSetupGui(IEntityManager entityManager,
ILocalizationManager localization,
IResourceCache resourceCache, IResourceCache resourceCache,
IClientPreferencesManager preferencesManager, IClientPreferencesManager preferencesManager,
IPrototypeManager prototypeManager) IPrototypeManager prototypeManager)
@@ -67,7 +66,7 @@ namespace Content.Client.UserInterface
CloseButton = new Button CloseButton = new Button
{ {
SizeFlagsHorizontal = SizeFlags.Expand | SizeFlags.ShrinkEnd, SizeFlagsHorizontal = SizeFlags.Expand | SizeFlags.ShrinkEnd,
Text = localization.GetString("Save and close"), Text = Loc.GetString("Save and close"),
StyleClasses = {NanoStyle.StyleClassButtonBig} StyleClasses = {NanoStyle.StyleClassButtonBig}
}; };
@@ -83,7 +82,7 @@ namespace Content.Client.UserInterface
{ {
new Label new Label
{ {
Text = localization.GetString("Character Setup"), Text = Loc.GetString("Character Setup"),
StyleClasses = {NanoStyle.StyleClassLabelHeadingBigger}, StyleClasses = {NanoStyle.StyleClassLabelHeadingBigger},
VAlign = Label.VAlignMode.Center, VAlign = Label.VAlignMode.Center,
SizeFlagsHorizontal = SizeFlags.Expand | SizeFlags.ShrinkCenter SizeFlagsHorizontal = SizeFlags.Expand | SizeFlags.ShrinkCenter
@@ -149,17 +148,14 @@ namespace Content.Client.UserInterface
PanelOverride = new StyleBoxFlat {BackgroundColor = NanoStyle.NanoGold}, PanelOverride = new StyleBoxFlat {BackgroundColor = NanoStyle.NanoGold},
CustomMinimumSize = (2, 0) CustomMinimumSize = (2, 0)
}); });
_humanoidProfileEditor = new HumanoidProfileEditor(localization, preferencesManager, prototypeManager); _humanoidProfileEditor = new HumanoidProfileEditor(preferencesManager, prototypeManager);
_humanoidProfileEditor.OnProfileChanged += newProfile => { UpdateUI(); }; _humanoidProfileEditor.OnProfileChanged += newProfile => { UpdateUI(); };
hBox.AddChild(_humanoidProfileEditor); hBox.AddChild(_humanoidProfileEditor);
UpdateUI(); UpdateUI();
} }
public void Save() public void Save() => _humanoidProfileEditor.Save();
{
_humanoidProfileEditor.Save();
}
private void UpdateUI() private void UpdateUI()
{ {

View File

@@ -48,8 +48,7 @@ namespace Content.Client.UserInterface
public HumanoidCharacterProfile Profile; public HumanoidCharacterProfile Profile;
public event Action<HumanoidCharacterProfile> OnProfileChanged; public event Action<HumanoidCharacterProfile> OnProfileChanged;
public HumanoidProfileEditor(ILocalizationManager localization, public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IPrototypeManager prototypeManager)
IClientPreferencesManager preferencesManager, IPrototypeManager prototypeManager)
{ {
_random = IoCManager.Resolve<IRobustRandom>(); _random = IoCManager.Resolve<IRobustRandom>();
Profile = (HumanoidCharacterProfile) preferencesManager.Preferences.SelectedCharacter; Profile = (HumanoidCharacterProfile) preferencesManager.Preferences.SelectedCharacter;
@@ -83,7 +82,7 @@ namespace Content.Client.UserInterface
var panel = HighlightedContainer(); var panel = HighlightedContainer();
var randomizeEverythingButton = new Button var randomizeEverythingButton = new Button
{ {
Text = localization.GetString("Randomize everything") Text = Loc.GetString("Randomize everything")
}; };
randomizeEverythingButton.OnPressed += args => { RandomizeEverything(); }; randomizeEverythingButton.OnPressed += args => { RandomizeEverything(); };
panel.AddChild(randomizeEverythingButton); panel.AddChild(randomizeEverythingButton);
@@ -100,7 +99,7 @@ namespace Content.Client.UserInterface
{ {
SizeFlagsVertical = SizeFlags.FillExpand SizeFlagsVertical = SizeFlags.FillExpand
}; };
var nameLabel = new Label {Text = localization.GetString("Name:")}; var nameLabel = new Label {Text = Loc.GetString("Name:")};
_nameEdit = new LineEdit _nameEdit = new LineEdit
{ {
CustomMinimumSize = (270, 0), CustomMinimumSize = (270, 0),
@@ -109,7 +108,7 @@ namespace Content.Client.UserInterface
_nameEdit.OnTextChanged += args => { SetName(args.Text); }; _nameEdit.OnTextChanged += args => { SetName(args.Text); };
var nameRandomButton = new Button var nameRandomButton = new Button
{ {
Text = localization.GetString("Randomize"), Text = Loc.GetString("Randomize"),
}; };
nameRandomButton.OnPressed += args => RandomizeName(); nameRandomButton.OnPressed += args => RandomizeName();
hBox.AddChild(nameLabel); hBox.AddChild(nameLabel);
@@ -143,19 +142,19 @@ namespace Content.Client.UserInterface
{ {
var panel = HighlightedContainer(); var panel = HighlightedContainer();
var hBox = new HBoxContainer(); var hBox = new HBoxContainer();
var sexLabel = new Label {Text = localization.GetString("Sex:")}; var sexLabel = new Label {Text = Loc.GetString("Sex:")};
var sexButtonGroup = new ButtonGroup(); var sexButtonGroup = new ButtonGroup();
_sexMaleButton = new Button _sexMaleButton = new Button
{ {
Text = localization.GetString("Male"), Text = Loc.GetString("Male"),
Group = sexButtonGroup Group = sexButtonGroup
}; };
_sexMaleButton.OnPressed += args => { SetSex(Sex.Male); }; _sexMaleButton.OnPressed += args => { SetSex(Sex.Male); };
_sexFemaleButton = new Button _sexFemaleButton = new Button
{ {
Text = localization.GetString("Female"), Text = Loc.GetString("Female"),
Group = sexButtonGroup Group = sexButtonGroup
}; };
_sexFemaleButton.OnPressed += args => { SetSex(Sex.Female); }; _sexFemaleButton.OnPressed += args => { SetSex(Sex.Female); };
@@ -173,7 +172,7 @@ namespace Content.Client.UserInterface
{ {
var panel = HighlightedContainer(); var panel = HighlightedContainer();
var hBox = new HBoxContainer(); var hBox = new HBoxContainer();
var ageLabel = new Label {Text = localization.GetString("Age:")}; var ageLabel = new Label {Text = Loc.GetString("Age:")};
_ageEdit = new LineEdit {CustomMinimumSize = (40, 0)}; _ageEdit = new LineEdit {CustomMinimumSize = (40, 0)};
_ageEdit.OnTextChanged += args => _ageEdit.OnTextChanged += args =>
{ {
@@ -332,13 +331,13 @@ namespace Content.Client.UserInterface
var hBox = new HBoxContainer(); var hBox = new HBoxContainer();
var importButton = new Button var importButton = new Button
{ {
Text = localization.GetString("Import"), Text = Loc.GetString("Import"),
Disabled = true, Disabled = true,
ToolTip = "Not yet implemented!" ToolTip = "Not yet implemented!"
}; };
var exportButton = new Button var exportButton = new Button
{ {
Text = localization.GetString("Export"), Text = Loc.GetString("Export"),
Disabled = true, Disabled = true,
ToolTip = "Not yet implemented!" ToolTip = "Not yet implemented!"
}; };
@@ -356,7 +355,7 @@ namespace Content.Client.UserInterface
var panel = HighlightedContainer(); var panel = HighlightedContainer();
_saveButton = new Button _saveButton = new Button
{ {
Text = localization.GetString("Save"), Text = Loc.GetString("Save"),
SizeFlagsHorizontal = SizeFlags.ShrinkCenter SizeFlagsHorizontal = SizeFlags.ShrinkCenter
}; };
_saveButton.OnPressed += args => { Save(); }; _saveButton.OnPressed += args => { Save(); };

View File

@@ -24,7 +24,6 @@ namespace Content.Client.UserInterface
private readonly Label _summaryLabel; private readonly Label _summaryLabel;
public LobbyCharacterPreviewPanel(IEntityManager entityManager, public LobbyCharacterPreviewPanel(IEntityManager entityManager,
ILocalizationManager localization,
IClientPreferencesManager preferencesManager) IClientPreferencesManager preferencesManager)
{ {
_preferencesManager = preferencesManager; _preferencesManager = preferencesManager;
@@ -32,12 +31,12 @@ namespace Content.Client.UserInterface
var header = new NanoHeading var header = new NanoHeading
{ {
Text = localization.GetString("Character setup") Text = Loc.GetString("Character setup")
}; };
CharacterSetupButton = new Button CharacterSetupButton = new Button
{ {
Text = localization.GetString("Customize"), Text = Loc.GetString("Customize"),
SizeFlagsHorizontal = SizeFlags.None SizeFlagsHorizontal = SizeFlags.None
}; };

View File

@@ -24,7 +24,6 @@ namespace Content.Client.UserInterface
public LobbyCharacterPreviewPanel CharacterPreview { get; } public LobbyCharacterPreviewPanel CharacterPreview { get; }
public LobbyGui(IEntityManager entityManager, public LobbyGui(IEntityManager entityManager,
ILocalizationManager localization,
IResourceCache resourceCache, IResourceCache resourceCache,
IClientPreferencesManager preferencesManager) IClientPreferencesManager preferencesManager)
{ {
@@ -69,7 +68,7 @@ namespace Content.Client.UserInterface
{ {
new Label new Label
{ {
Text = localization.GetString("Lobby"), Text = Loc.GetString("Lobby"),
StyleClasses = {NanoStyle.StyleClassLabelHeadingBigger}, StyleClasses = {NanoStyle.StyleClassLabelHeadingBigger},
/*MarginBottom = 40, /*MarginBottom = 40,
MarginLeft = 8,*/ MarginLeft = 8,*/
@@ -88,7 +87,7 @@ namespace Content.Client.UserInterface
(LeaveButton = new Button (LeaveButton = new Button
{ {
SizeFlagsHorizontal = SizeFlags.ShrinkEnd, SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
Text = localization.GetString("Leave"), Text = Loc.GetString("Leave"),
StyleClasses = {NanoStyle.StyleClassButtonBig}, StyleClasses = {NanoStyle.StyleClassButtonBig},
//GrowHorizontal = GrowDirection.Begin //GrowHorizontal = GrowDirection.Begin
}) })
@@ -115,7 +114,6 @@ namespace Content.Client.UserInterface
CharacterPreview = new LobbyCharacterPreviewPanel( CharacterPreview = new LobbyCharacterPreviewPanel(
entityManager, entityManager,
localization,
preferencesManager) preferencesManager)
{ {
SizeFlagsHorizontal = SizeFlags.None SizeFlagsHorizontal = SizeFlags.None
@@ -147,7 +145,7 @@ namespace Content.Client.UserInterface
{ {
(ObserveButton = new Button (ObserveButton = new Button
{ {
Text = localization.GetString("Observe"), Text = Loc.GetString("Observe"),
StyleClasses = {NanoStyle.StyleClassButtonBig} StyleClasses = {NanoStyle.StyleClassButtonBig}
}), }),
(StartTime = new Label (StartTime = new Label
@@ -160,7 +158,7 @@ namespace Content.Client.UserInterface
(ReadyButton = new Button (ReadyButton = new Button
{ {
ToggleMode = true, ToggleMode = true,
Text = localization.GetString("Ready Up"), Text = Loc.GetString("Ready Up"),
StyleClasses = {NanoStyle.StyleClassButtonBig} StyleClasses = {NanoStyle.StyleClassButtonBig}
}), }),
} }
@@ -181,7 +179,7 @@ namespace Content.Client.UserInterface
{ {
(Chat = new ChatBox (Chat = new ChatBox
{ {
Input = {PlaceHolder = localization.GetString("Say something!")} Input = {PlaceHolder = Loc.GetString("Say something!")}
}) })
} }
}, },
@@ -201,7 +199,7 @@ namespace Content.Client.UserInterface
{ {
new NanoHeading new NanoHeading
{ {
Text = localization.GetString("Online Players"), Text = Loc.GetString("Online Players"),
}, },
new MarginContainer new MarginContainer
{ {
@@ -217,7 +215,7 @@ namespace Content.Client.UserInterface
}, },
new NanoHeading new NanoHeading
{ {
Text = localization.GetString("Server Info"), Text = Loc.GetString("Server Info"),
}, },
new MarginContainer new MarginContainer
{ {
@@ -228,7 +226,7 @@ namespace Content.Client.UserInterface
MarginBottomOverride = 2, MarginBottomOverride = 2,
Children = Children =
{ {
(ServerInfo = new ServerInfo(localization)) (ServerInfo = new ServerInfo())
} }
}, },
} }

View File

@@ -13,7 +13,7 @@ namespace Content.Client.UserInterface
private readonly RichTextLabel _richTextLabel; private readonly RichTextLabel _richTextLabel;
public ServerInfo(ILocalizationManager localization) public ServerInfo()
{ {
_richTextLabel = new RichTextLabel _richTextLabel = new RichTextLabel
{ {
@@ -26,10 +26,10 @@ namespace Content.Client.UserInterface
var uriOpener = IoCManager.Resolve<IUriOpener>(); var uriOpener = IoCManager.Resolve<IUriOpener>();
var discordButton = new Button {Text = localization.GetString("Join us on Discord!")}; var discordButton = new Button {Text = Loc.GetString("Join us on Discord!")};
discordButton.OnPressed += args => uriOpener.OpenUri(DiscordUrl); discordButton.OnPressed += args => uriOpener.OpenUri(DiscordUrl);
var websiteButton = new Button {Text = localization.GetString("Website")}; var websiteButton = new Button {Text = Loc.GetString("Website")};
websiteButton.OnPressed += args => uriOpener.OpenUri(WebsiteUrl); websiteButton.OnPressed += args => uriOpener.OpenUri(WebsiteUrl);
buttons.AddChild(discordButton); buttons.AddChild(discordButton);