# Conflicts: # .github/CODEOWNERS # .github/PULL_REQUEST_TEMPLATE.md # Content.Client/Changelog/ChangelogTab.xaml.cs # Content.Client/Chemistry/UI/ChemMasterWindow.xaml # Content.Client/Entry/EntryPoint.cs # Content.Client/GameTicking/Managers/ClientGameTicker.cs # Content.Client/Launcher/LauncherConnectingGui.xaml # Content.Client/Lobby/LobbyState.cs # Content.Client/Lobby/UI/LobbyGui.xaml # Content.Client/Paper/UI/PaperWindow.xaml.cs # Content.Client/StationRecords/GeneralStationRecordConsoleWindow.xaml.cs # Content.Client/Stylesheets/StyleNano.cs # Content.Client/UserInterface/Screens/SeparatedChatGameScreen.xaml # Content.Client/UserInterface/Systems/Ghost/Widgets/GhostGui.xaml.cs # Content.Client/UserInterface/Systems/MenuBar/Widgets/GameTopMenuBar.xaml # Content.IntegrationTests/Tests/Destructible/DestructibleDamageGroupTest.cs # Content.IntegrationTests/Tests/PostMapInitTest.cs # Content.IntegrationTests/Tests/Power/StationPowerTests.cs # Content.Packaging/ServerPackaging.cs # Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs # Content.Server/Administration/Systems/AdminVerbSystem.Tools.cs # Content.Server/Atmos/TileAtmosphere.cs # Content.Server/Bible/BibleSystem.cs # Content.Server/Chat/Systems/ChatSystem.cs # Content.Server/Content.Server.csproj # Content.Server/Discord/DiscordLink/DiscordLink.cs # Content.Server/GameTicking/GameTicker.LobbyBackground.cs # Content.Server/GameTicking/GameTicker.Spawning.cs # Content.Server/Ghost/GhostSystem.cs # Content.Server/Kitchen/Components/MicrowaveComponent.cs # Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs # Content.Server/Mech/Systems/MechSystem.cs # Content.Server/Medical/CrewMonitoring/CrewMonitoringConsoleSystem.cs # Content.Server/Medical/DefibrillatorSystem.cs # Content.Server/Medical/HealthAnalyzerSystem.cs # Content.Server/Radio/EntitySystems/HeadsetSystem.cs # Content.Server/Remotes/DoorRemoteSystem.cs # Content.Server/RoundEnd/RoundEndSystem.cs # Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs # Content.Server/Silicons/Borgs/BorgSystem.Transponder.cs # Content.Server/Tips/TipsSystem.cs # Content.Server/Traitor/Uplink/UplinkSystem.cs # Content.Server/Weapons/Ranged/Systems/GunSystem.cs # Content.Server/Zombies/ZombieSystem.Transform.cs # Content.Server/Zombies/ZombieSystem.cs # Content.Shared/Bed/BedSystem.cs # Content.Shared/Blocking/BlockingSystem.User.cs # Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs # Content.Shared/Chat/SharedSuicideSystem.cs # Content.Shared/Chemistry/Components/HyposprayComponent.cs # Content.Shared/Chemistry/EntitySystems/HypospraySystem.cs # Content.Shared/Chemistry/EntitySystems/ScoopableSolutionSystem.cs # Content.Shared/Chemistry/EntitySystems/SolutionTransferSystem.cs # Content.Shared/Chemistry/Events/HyposprayEvents.cs # Content.Shared/Content.Shared.csproj # Content.Shared/Damage/Systems/DamageableSystem.cs # Content.Shared/Friction/TileFrictionController.cs # Content.Shared/GameTicking/SharedGameTicker.cs # Content.Shared/Interaction/InteractHand.cs # Content.Shared/Lock/LockSystem.cs # Content.Shared/Medical/Healing/HealingSystem.cs # Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs # Content.Shared/Nutrition/EntitySystems/HungerSystem.cs # Content.Shared/Silicons/StationAi/SharedStationAiSystem.Airlock.cs # Content.Shared/Throwing/ThrowingSystem.cs # Content.Shared/Trigger/Systems/TriggerOnHitscanSystem.cs # Content.Shared/Weapons/Hitscan/Systems/HitscanBasicDamageSystem.cs # Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs # Content.Shared/Weapons/Ranged/Components/BatteryWeaponFireModesComponent.cs # Content.Shared/Weapons/Ranged/Components/HitscanBatteryAmmoProviderComponent.cs # Content.Shared/Weapons/Ranged/Systems/BatteryWeaponFireModesSystem.cs # Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs # Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Battery.cs # Content.Shared/Zombies/ZombieComponent.cs # Content.Shared/_Sunrise/Lobby/LobbyBackgroundPrototype.cs # README.md # Resources/Locale/en-US/_strings/borg/borg.ftl # Resources/Locale/en-US/_strings/chemistry/components/hypospray-component.ftl # Resources/Locale/en-US/_strings/chemistry/components/injector-component.ftl # Resources/Locale/en-US/_strings/commands/pauseatmos-command.ftl # Resources/Locale/en-US/_strings/commands/quick-inspect-command.ftl # Resources/Locale/en-US/_strings/commands/show-wallmounts-command.ftl # Resources/Locale/en-US/_strings/commands/substepatmos-command.ftl # Resources/Locale/en-US/_strings/fluids/components/equip-spray-component.ftl # Resources/Locale/en-US/_strings/game-ticking/game-presets/preset-revolutionary.ftl # Resources/Locale/en-US/_strings/job/job-names.ftl # Resources/Locale/en-US/_strings/lobby/lobby-state-background.ftl # Resources/Locale/en-US/_strings/reagents/meta/medicine.ftl # Resources/Locale/en-US/_strings/reagents/meta/physical-desc.ftl # Resources/Locale/en-US/_strings/silicons/borg-module.ftl # Resources/Locale/en-US/_strings/store/changeling-catalog.ftl # Resources/Locale/en-US/_strings/store/currency.ftl # Resources/Locale/en-US/_strings/store/store.ftl # Resources/Locale/en-US/_strings/store/uplink-catalog.ftl # Resources/Prototypes/Body/Organs/slime.yml # Resources/Prototypes/Catalog/Fills/Backpacks/backpack.yml # Resources/Prototypes/Catalog/Fills/Backpacks/duffelbag.yml # Resources/Prototypes/Catalog/Fills/Boxes/ammunition.yml # Resources/Prototypes/Catalog/Fills/Boxes/emergency.yml # Resources/Prototypes/Catalog/Fills/Crates/antag.yml # Resources/Prototypes/Catalog/Fills/Crates/armory.yml # Resources/Prototypes/Catalog/Fills/Crates/botany.yml # Resources/Prototypes/Catalog/Fills/Crates/fun.yml # Resources/Prototypes/Catalog/Fills/Crates/medical.yml # Resources/Prototypes/Catalog/Fills/Crates/salvage.yml # Resources/Prototypes/Catalog/Fills/Crates/security.yml # Resources/Prototypes/Catalog/Fills/Crates/service.yml # Resources/Prototypes/Catalog/Fills/Crates/syndicate.yml # Resources/Prototypes/Catalog/Fills/Items/belt.yml # Resources/Prototypes/Catalog/Fills/Items/briefcases.yml # Resources/Prototypes/Catalog/Fills/Items/firstaidkits.yml # Resources/Prototypes/Catalog/Fills/Items/toolboxes.yml # Resources/Prototypes/Catalog/Fills/Lockers/dressers.yml # Resources/Prototypes/Catalog/Fills/Lockers/heads.yml # Resources/Prototypes/Catalog/Fills/Lockers/security.yml # Resources/Prototypes/Catalog/VendingMachines/Inventories/theater.yml # Resources/Prototypes/Catalog/uplink_catalog.yml # Resources/Prototypes/Entities/Clothing/Back/backpacks.yml # Resources/Prototypes/Entities/Clothing/Shoes/magboots.yml # Resources/Prototypes/Entities/Debugging/debug_sweps.yml # Resources/Prototypes/Entities/Debugging/stress_test.yml # Resources/Prototypes/Entities/Markers/Spawners/Random/anomaly.yml # Resources/Prototypes/Entities/Markers/Spawners/Random/toy.yml # Resources/Prototypes/Entities/Mobs/Cyborgs/base_borg_chassis.yml # Resources/Prototypes/Entities/Mobs/Cyborgs/xenoborgs.yml # Resources/Prototypes/Entities/Mobs/NPCs/animals.yml # Resources/Prototypes/Entities/Mobs/NPCs/carp.yml # Resources/Prototypes/Entities/Objects/Devices/base_handheld.yml # Resources/Prototypes/Entities/Objects/Fun/Instruments/instruments_misc.yml # Resources/Prototypes/Entities/Objects/Fun/dice_bag.yml # Resources/Prototypes/Entities/Objects/Fun/snap_pops.yml # Resources/Prototypes/Entities/Objects/Materials/Sheets/other.yml # Resources/Prototypes/Entities/Objects/Materials/parts.yml # Resources/Prototypes/Entities/Objects/Misc/identification_cards.yml # Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml # Resources/Prototypes/Entities/Objects/Shields/shields.yml # Resources/Prototypes/Entities/Objects/Specific/Chapel/bibles.yml # Resources/Prototypes/Entities/Objects/Specific/Janitorial/janitor.yml # Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml # Resources/Prototypes/Entities/Objects/Specific/Medical/surgery.yml # Resources/Prototypes/Entities/Objects/Specific/Robotics/borg_modules.yml # Resources/Prototypes/Entities/Objects/Specific/Robotics/mmi.yml # Resources/Prototypes/Entities/Objects/Specific/Service/barber.yml # Resources/Prototypes/Entities/Objects/Tools/glowstick.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Boxes/antimateriel.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Boxes/magnum.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/heavy_rifle.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/light_rifle.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/magnum.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/pistol.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/rifle.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Cartridges/shotgun.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Magazines/light_rifle.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Magazines/magnum.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Magazines/pistol.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Magazines/rifle.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/grenade.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/SpeedLoaders/magnum.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/SpeedLoaders/pistol.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/SpeedLoaders/rifle_light.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/explosives.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Pistols/pistols.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/hitscan.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Rifles/rifles.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/SMGs/smgs.yml # Resources/Prototypes/Entities/Objects/Weapons/Melee/knife.yml # Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml # Resources/Prototypes/Entities/Structures/Furniture/dresser.yml # Resources/Prototypes/Entities/Structures/Machines/lathe.yml # Resources/Prototypes/Entities/Structures/Shuttles/cannons.yml # Resources/Prototypes/Entities/Structures/Walls/walls.yml # Resources/Prototypes/GameRules/roundstart.yml # Resources/Prototypes/GameRules/unknown_shuttles.yml # Resources/Prototypes/InventoryTemplates/aghost_inventory_template.yml # Resources/Prototypes/Loadouts/Jobs/Security/security_officer.yml # Resources/Prototypes/Loadouts/loadout_groups.yml # Resources/Prototypes/Loadouts/role_loadouts.yml # Resources/Prototypes/Maps/Pools/default.yml # Resources/Prototypes/Maps/amber.yml # Resources/Prototypes/Maps/oasis.yml # Resources/Prototypes/Maps/reach.yml # Resources/Prototypes/Objectives/objectiveGroups.yml # Resources/Prototypes/Reagents/Consumable/Drink/alcohol.yml # Resources/Prototypes/Reagents/medicine.yml # Resources/Prototypes/Reagents/narcotics.yml # Resources/Prototypes/Reagents/toxins.yml # Resources/Prototypes/Recipes/Reactions/medicine.yml # Resources/Prototypes/Roles/Jobs/Security/head_of_security.yml # Resources/Prototypes/Roles/Jobs/Security/security_cadet.yml # Resources/Prototypes/Roles/Jobs/Security/security_officer.yml # Resources/Prototypes/Roles/Jobs/Security/warden.yml # Resources/Prototypes/Roles/Jobs/Wildcards/zookeeper.yml # Resources/Prototypes/Roles/play_time_trackers.yml # Resources/Prototypes/Shuttles/shuttle_incoming_event.yml # Resources/Prototypes/Species/species_weights.yml # Resources/Prototypes/Store/presets.yml # Resources/Prototypes/ai_factions.yml # Resources/Prototypes/borg_types.yml # Resources/Prototypes/explosion.yml # Resources/Prototypes/game_presets.yml # Resources/Prototypes/lobbyscreens.yml # Resources/Prototypes/silicon-laws.yml # Resources/Textures/Clothing/Back/Duffels/syndicate.rsi/icon-med.png # Resources/Textures/Clothing/Back/Duffels/syndicate.rsi/meta.json # Resources/Textures/Objects/Specific/Mech/mecha.rsi/meta.json # Resources/Textures/Objects/Specific/Mech/mecha.rsi/ripley-broken.png # Resources/Textures/Objects/Specific/Mech/mecha.rsi/ripley-empty.png # Resources/Textures/Objects/Specific/Mech/mecha.rsi/ripley-open.png # Resources/Textures/Objects/Specific/Mech/mecha.rsi/ripley.png # Resources/Textures/Objects/Specific/Mech/ripley_construction.rsi/ripley_chassis.png # Resources/Textures/Objects/Specific/Mech/ripley_construction.rsi/ripley_harness+o.png # Resources/Textures/Objects/Specific/Mech/ripley_construction.rsi/ripley_harness.png # Resources/Textures/Objects/Specific/Medical/hypospray.rsi/meta.json # Resources/Textures/Objects/Specific/Medical/medical.rsi/meta.json # Resources/Textures/Objects/Weapons/Guns/Projectiles/projectiles.rsi/meta.json # Resources/Textures/Objects/Weapons/Guns/Projectiles/projectiles2.rsi/meta.json # Resources/Textures/Structures/Storage/canister.rsi/meta.json # Resources/Textures/Structures/Storage/tanks.rsi/meta.json # Resources/migration.yml # RobustToolbox # SECURITY.md # SpaceStation14.sln
704 lines
21 KiB
C#
704 lines
21 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using System.Numerics;
|
|
using Content.Client.Administration.Managers;
|
|
using Content.Client.Administration.Systems;
|
|
using Content.Client.Administration.UI.Bwoink;
|
|
using Content.Client.Gameplay;
|
|
using Content.Client.Lobby;
|
|
using Content.Client.Lobby.UI;
|
|
using Content.Client.Stylesheets;
|
|
using Content.Client.UserInterface.Controls;
|
|
using Content.Client.UserInterface.Systems.MenuBar.Widgets;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.CCVar;
|
|
using Content.Shared.Input;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.Audio;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.Input;
|
|
using Robust.Client.Player;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controllers;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.CustomControls;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Input.Binding;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Client.UserInterface.Systems.Bwoink;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSystem>, IOnStateChanged<GameplayState>, IOnStateChanged<LobbyState>
|
|
{
|
|
[Dependency] private readonly IClientAdminManager _adminManager = default!;
|
|
[Dependency] private readonly IConfigurationManager _config = default!;
|
|
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
|
[Dependency] private readonly IClyde _clyde = default!;
|
|
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
|
|
[Dependency] private readonly IInputManager _input = default!;
|
|
[UISystemDependency] private readonly AudioSystem _audio = default!;
|
|
|
|
private BwoinkSystem? _bwoinkSystem;
|
|
private MenuButton? GameAHelpButton => UIManager.GetActiveUIWidgetOrNull<GameTopMenuBar>()?.AHelpButton;
|
|
private Button? LobbyAHelpButton => (UIManager.ActiveScreen as LobbyGui)?.AHelpButton;
|
|
public IAHelpUIHandler? UIHelper;
|
|
private bool _discordRelayActive;
|
|
private bool _hasUnreadAHelp;
|
|
private bool _bwoinkSoundEnabled;
|
|
private string? _aHelpSound;
|
|
|
|
protected override string SawmillName => "c.s.go.es.bwoink";
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeNetworkEvent<BwoinkDiscordRelayUpdated>(DiscordRelayUpdated);
|
|
SubscribeNetworkEvent<BwoinkPlayerTypingUpdated>(PeopleTypingUpdated);
|
|
|
|
// Sunrise-Start
|
|
SubscribeNetworkEvent<SharedBwoinkSystem.BwoinkTextHistoryMessage>(OnBwoinkTextHistoryMessage);
|
|
// Sunrise-End
|
|
|
|
_adminManager.AdminStatusUpdated += OnAdminStatusUpdated;
|
|
_config.OnValueChanged(CCVars.AHelpSound, v => _aHelpSound = v, true);
|
|
_config.OnValueChanged(CCVars.BwoinkSoundEnabled, v => _bwoinkSoundEnabled = v, true);
|
|
}
|
|
|
|
public void UnloadButton()
|
|
{
|
|
if (GameAHelpButton != null)
|
|
GameAHelpButton.OnPressed -= AHelpButtonPressed;
|
|
|
|
if (LobbyAHelpButton != null)
|
|
LobbyAHelpButton.OnPressed -= AHelpButtonPressed;
|
|
}
|
|
|
|
public void LoadButton()
|
|
{
|
|
if (GameAHelpButton != null)
|
|
GameAHelpButton.OnPressed += AHelpButtonPressed;
|
|
|
|
if (LobbyAHelpButton != null)
|
|
LobbyAHelpButton.OnPressed += AHelpButtonPressed;
|
|
}
|
|
|
|
private void OnAdminStatusUpdated()
|
|
{
|
|
if (UIHelper is not { IsOpen: true })
|
|
return;
|
|
EnsureUIHelper();
|
|
}
|
|
|
|
private void AHelpButtonPressed(BaseButton.ButtonEventArgs obj)
|
|
{
|
|
EnsureUIHelper();
|
|
UIHelper!.ToggleWindow();
|
|
}
|
|
|
|
public void OnSystemLoaded(BwoinkSystem system)
|
|
{
|
|
_bwoinkSystem = system;
|
|
_bwoinkSystem.OnBwoinkTextMessageRecieved += ReceivedBwoink;
|
|
_bwoinkSystem.OnBwoinkCooldownReceived += ReceivedCooldown; // Sunrise-Edit
|
|
|
|
_input.SetInputCommand(ContentKeyFunctions.OpenAHelp,
|
|
InputCmdHandler.FromDelegate(_ => ToggleWindow()));
|
|
}
|
|
|
|
public void OnSystemUnloaded(BwoinkSystem system)
|
|
{
|
|
_input.SetInputCommand(ContentKeyFunctions.OpenAHelp, null);
|
|
|
|
DebugTools.Assert(_bwoinkSystem != null);
|
|
_bwoinkSystem!.OnBwoinkTextMessageRecieved -= ReceivedBwoink;
|
|
_bwoinkSystem!.OnBwoinkCooldownReceived -= ReceivedCooldown; // Sunrise-Edit
|
|
_bwoinkSystem = null;
|
|
}
|
|
|
|
private void SetAHelpPressed(bool pressed)
|
|
{
|
|
if (GameAHelpButton != null)
|
|
{
|
|
GameAHelpButton.Pressed = pressed;
|
|
}
|
|
|
|
if (LobbyAHelpButton != null)
|
|
{
|
|
LobbyAHelpButton.Pressed = pressed;
|
|
}
|
|
|
|
UIManager.ClickSound();
|
|
UnreadAHelpRead();
|
|
}
|
|
|
|
private void ReceivedBwoink(object? sender, SharedBwoinkSystem.BwoinkTextMessage message)
|
|
{
|
|
Log.Info($"@{message.UserId}: {message.Text}");
|
|
var localPlayer = _playerManager.LocalSession;
|
|
if (localPlayer == null)
|
|
{
|
|
return;
|
|
}
|
|
if (message.PlaySound && localPlayer.UserId != message.TrueSender && !message.DbLoad) // Sunrise-Edit
|
|
{
|
|
if (_aHelpSound != null && (_bwoinkSoundEnabled || !_adminManager.IsActive()))
|
|
_audio.PlayGlobal(_aHelpSound, Filter.Local(), false);
|
|
_clyde.RequestWindowAttention();
|
|
}
|
|
|
|
EnsureUIHelper();
|
|
|
|
if (!UIHelper!.IsOpen)
|
|
{
|
|
UnreadAHelpReceived();
|
|
}
|
|
|
|
UIHelper!.Receive(message);
|
|
}
|
|
|
|
// Sunrise-Start
|
|
private void ReceivedCooldown(object? sender, BwoinkCooldownMessage message)
|
|
{
|
|
EnsureUIHelper();
|
|
UIHelper?.OnCooldownReceived(message);
|
|
}
|
|
// Sunrise-End
|
|
|
|
private void DiscordRelayUpdated(BwoinkDiscordRelayUpdated args, EntitySessionEventArgs session)
|
|
{
|
|
_discordRelayActive = args.DiscordRelayEnabled;
|
|
UIHelper?.DiscordRelayChanged(_discordRelayActive);
|
|
}
|
|
|
|
private void PeopleTypingUpdated(BwoinkPlayerTypingUpdated args, EntitySessionEventArgs session)
|
|
{
|
|
UIHelper?.PeopleTypingUpdated(args);
|
|
}
|
|
|
|
// Sunrise-Start
|
|
private void OnBwoinkTextHistoryMessage(SharedBwoinkSystem.BwoinkTextHistoryMessage args, EntitySessionEventArgs session)
|
|
{
|
|
EnsureUIHelper();
|
|
UIHelper?.Clean(args.UserId);
|
|
foreach (var msg in args.Messages)
|
|
{
|
|
UIHelper?.Receive(msg);
|
|
}
|
|
UIHelper?.SetLoadDb(args.UserId);
|
|
}
|
|
// Sunrise-End
|
|
|
|
public void EnsureUIHelper()
|
|
{
|
|
var isAdmin = _adminManager.HasFlag(AdminFlags.Adminhelp);
|
|
|
|
if (UIHelper != null && UIHelper.IsAdmin == isAdmin)
|
|
return;
|
|
|
|
UIHelper?.Dispose();
|
|
var ownerUserId = _playerManager.LocalUser!.Value;
|
|
|
|
UIHelper = isAdmin ? new AdminAHelpUIHandler(ownerUserId, _bwoinkSystem) : new UserAHelpUIHandler(ownerUserId, _bwoinkSystem); // Sunrise-Edit
|
|
UIHelper.DiscordRelayChanged(_discordRelayActive);
|
|
|
|
UIHelper.SendMessageAction = (userId, textMessage, playSound, adminOnly) => _bwoinkSystem?.Send(userId, textMessage, playSound, adminOnly);
|
|
UIHelper.InputTextChanged += (channel, text) => _bwoinkSystem?.SendInputTextUpdated(channel, text.Length > 0);
|
|
UIHelper.OnClose += () => { SetAHelpPressed(false); };
|
|
UIHelper.OnOpen += () => { SetAHelpPressed(true); };
|
|
SetAHelpPressed(UIHelper.IsOpen);
|
|
}
|
|
|
|
public void Open()
|
|
{
|
|
var localUser = _playerManager.LocalUser;
|
|
if (localUser == null)
|
|
{
|
|
return;
|
|
}
|
|
EnsureUIHelper();
|
|
if (UIHelper!.IsOpen)
|
|
return;
|
|
UIHelper!.Open(localUser.Value, _discordRelayActive);
|
|
}
|
|
|
|
public void Open(NetUserId userId)
|
|
{
|
|
EnsureUIHelper();
|
|
if (!UIHelper!.IsAdmin)
|
|
return;
|
|
UIHelper?.Open(userId, _discordRelayActive);
|
|
}
|
|
|
|
public void ToggleWindow()
|
|
{
|
|
EnsureUIHelper();
|
|
UIHelper?.ToggleWindow();
|
|
}
|
|
|
|
public void PopOut()
|
|
{
|
|
EnsureUIHelper();
|
|
if (UIHelper is not AdminAHelpUIHandler helper)
|
|
return;
|
|
|
|
if (helper.Window == null || helper.Control == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
helper.Control.Orphan();
|
|
helper.Window.Dispose();
|
|
helper.Window = null;
|
|
helper.EverOpened = false;
|
|
|
|
var monitor = _clyde.EnumerateMonitors().First();
|
|
|
|
helper.ClydeWindow = _clyde.CreateWindow(new WindowCreateParameters
|
|
{
|
|
Maximized = false,
|
|
Title = Loc.GetString("bwoink-admin-title"),
|
|
Monitor = monitor,
|
|
Width = 900,
|
|
Height = 500
|
|
});
|
|
|
|
helper.ClydeWindow.RequestClosed += helper.OnRequestClosed;
|
|
helper.ClydeWindow.DisposeOnClose = true;
|
|
|
|
helper.WindowRoot = _uiManager.CreateWindowRoot(helper.ClydeWindow);
|
|
helper.WindowRoot.AddChild(helper.Control);
|
|
|
|
helper.Control.PopOut.Disabled = true;
|
|
helper.Control.PopOut.Visible = false;
|
|
}
|
|
|
|
private void UnreadAHelpReceived()
|
|
{
|
|
GameAHelpButton?.StyleClasses.Add(StyleClass.Negative);
|
|
LobbyAHelpButton?.StyleClasses.Add(StyleClass.Negative);
|
|
_hasUnreadAHelp = true;
|
|
}
|
|
|
|
private void UnreadAHelpRead()
|
|
{
|
|
GameAHelpButton?.StyleClasses.Remove(StyleClass.Negative);
|
|
LobbyAHelpButton?.StyleClasses.Remove(StyleClass.Negative);
|
|
_hasUnreadAHelp = false;
|
|
}
|
|
|
|
public void OnStateEntered(GameplayState state)
|
|
{
|
|
if (GameAHelpButton != null)
|
|
{
|
|
GameAHelpButton.OnPressed -= AHelpButtonPressed;
|
|
GameAHelpButton.OnPressed += AHelpButtonPressed;
|
|
GameAHelpButton.Pressed = UIHelper?.IsOpen ?? false;
|
|
|
|
if (_hasUnreadAHelp)
|
|
{
|
|
UnreadAHelpReceived();
|
|
}
|
|
else
|
|
{
|
|
UnreadAHelpRead();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnStateExited(GameplayState state)
|
|
{
|
|
if (GameAHelpButton != null)
|
|
GameAHelpButton.OnPressed -= AHelpButtonPressed;
|
|
}
|
|
|
|
public void OnStateEntered(LobbyState state)
|
|
{
|
|
if (LobbyAHelpButton != null)
|
|
{
|
|
LobbyAHelpButton.OnPressed -= AHelpButtonPressed;
|
|
LobbyAHelpButton.OnPressed += AHelpButtonPressed;
|
|
LobbyAHelpButton.Pressed = UIHelper?.IsOpen ?? false;
|
|
|
|
if (_hasUnreadAHelp)
|
|
{
|
|
UnreadAHelpReceived();
|
|
}
|
|
else
|
|
{
|
|
UnreadAHelpRead();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnStateExited(LobbyState state)
|
|
{
|
|
if (LobbyAHelpButton != null)
|
|
LobbyAHelpButton.OnPressed -= AHelpButtonPressed;
|
|
}
|
|
}
|
|
|
|
// please kill all this indirection
|
|
public interface IAHelpUIHandler : IDisposable
|
|
{
|
|
public bool IsAdmin { get; }
|
|
public bool IsOpen { get; }
|
|
public void Receive(SharedBwoinkSystem.BwoinkTextMessage message);
|
|
public void Close();
|
|
public void Open(NetUserId netUserId, bool relayActive);
|
|
public void ToggleWindow();
|
|
public void DiscordRelayChanged(bool active);
|
|
public void PeopleTypingUpdated(BwoinkPlayerTypingUpdated args);
|
|
public void OnCooldownReceived(BwoinkCooldownMessage message); // Sunrise-Edit
|
|
public event Action OnClose;
|
|
public event Action OnOpen;
|
|
public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
|
|
public event Action<NetUserId, string>? InputTextChanged;
|
|
// Sunrise-Start
|
|
public void SetLoadDb(NetUserId userId);
|
|
public void Clean(NetUserId userId);
|
|
// Sunrise-End
|
|
}
|
|
public sealed class AdminAHelpUIHandler : IAHelpUIHandler
|
|
{
|
|
private readonly NetUserId _ownerId;
|
|
private BwoinkSystem? _bwoinkSystem; // Sunrise-Edit
|
|
public AdminAHelpUIHandler(NetUserId owner, BwoinkSystem? bwoinkSystem) // Sunrise-Edit
|
|
{
|
|
_bwoinkSystem = bwoinkSystem; // Sunrise-Edit
|
|
_ownerId = owner;
|
|
}
|
|
private readonly Dictionary<NetUserId, BwoinkPanel> _activePanelMap = new();
|
|
public bool IsAdmin => true;
|
|
public bool IsOpen => Window is { Disposed: false, IsOpen: true } || ClydeWindow is { IsDisposed: false };
|
|
public bool EverOpened;
|
|
|
|
public BwoinkWindow? Window;
|
|
public WindowRoot? WindowRoot;
|
|
public IClydeWindow? ClydeWindow;
|
|
public BwoinkControl? Control;
|
|
|
|
public void Receive(SharedBwoinkSystem.BwoinkTextMessage message)
|
|
{
|
|
var panel = EnsurePanel(message.UserId);
|
|
panel.ReceiveLine(message);
|
|
Control?.OnBwoink(message.UserId);
|
|
}
|
|
|
|
private void OpenWindow()
|
|
{
|
|
if (Window == null)
|
|
return;
|
|
|
|
if (EverOpened)
|
|
Window.Open();
|
|
else
|
|
Window.OpenCentered();
|
|
}
|
|
|
|
public void Close()
|
|
{
|
|
Window?.Close();
|
|
|
|
// popped-out window is being closed
|
|
if (ClydeWindow != null)
|
|
{
|
|
ClydeWindow.RequestClosed -= OnRequestClosed;
|
|
ClydeWindow.Dispose();
|
|
// need to dispose control cause we cant reattach it directly back to the window
|
|
// but orphan panels first so -they- can get readded when the window is opened again
|
|
if (Control != null)
|
|
{
|
|
foreach (var (_, panel) in _activePanelMap)
|
|
{
|
|
panel.Orphan();
|
|
}
|
|
Control?.Dispose();
|
|
}
|
|
// window wont be closed here so we will invoke ourselves
|
|
OnClose?.Invoke();
|
|
}
|
|
}
|
|
|
|
public void ToggleWindow()
|
|
{
|
|
EnsurePanel(_ownerId);
|
|
|
|
if (IsOpen)
|
|
Close();
|
|
else
|
|
OpenWindow();
|
|
}
|
|
|
|
public void DiscordRelayChanged(bool active)
|
|
{
|
|
}
|
|
|
|
public void PeopleTypingUpdated(BwoinkPlayerTypingUpdated args)
|
|
{
|
|
if (_activePanelMap.TryGetValue(args.Channel, out var panel))
|
|
panel.UpdatePlayerTyping(args.PlayerName, args.Typing);
|
|
}
|
|
|
|
// Sunrise-Start
|
|
public void OnCooldownReceived(BwoinkCooldownMessage message)
|
|
{
|
|
// For admins, we might want to show a message in the currently active panel
|
|
// For now, we'll pass it to all panels to handle
|
|
foreach (var (_, panel) in _activePanelMap)
|
|
{
|
|
panel.OnCooldownReceived(message);
|
|
}
|
|
}
|
|
|
|
public void SetLoadDb(NetUserId userId)
|
|
{
|
|
if (_activePanelMap.TryGetValue(userId, out var panel))
|
|
{
|
|
panel.LoadDb = true;
|
|
}
|
|
}
|
|
|
|
public void Clean(NetUserId userId)
|
|
{
|
|
if (_activePanelMap.TryGetValue(userId, out var panel))
|
|
{
|
|
panel.TextOutput.Clear();
|
|
}
|
|
}
|
|
|
|
public void LoadDbMessages(NetUserId userId)
|
|
{
|
|
_bwoinkSystem?.LoadDbMessages(userId);
|
|
}
|
|
// Sunrise-End
|
|
|
|
public event Action? OnClose;
|
|
public event Action? OnOpen;
|
|
public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
|
|
public event Action<NetUserId, string>? InputTextChanged;
|
|
|
|
public void Open(NetUserId channelId, bool relayActive)
|
|
{
|
|
SelectChannel(channelId);
|
|
OpenWindow();
|
|
}
|
|
|
|
public void OnRequestClosed(WindowRequestClosedEventArgs args)
|
|
{
|
|
Close();
|
|
}
|
|
|
|
private void EnsureControl()
|
|
{
|
|
if (Control is { Disposed: false })
|
|
return;
|
|
|
|
Window = new BwoinkWindow();
|
|
Control = Window.Bwoink;
|
|
Window.OnClose += () => { OnClose?.Invoke(); };
|
|
Window.OnOpen += () =>
|
|
{
|
|
OnOpen?.Invoke();
|
|
EverOpened = true;
|
|
};
|
|
|
|
// need to readd any unattached panels..
|
|
foreach (var (_, panel) in _activePanelMap)
|
|
{
|
|
if (!Control!.BwoinkArea.Children.Contains(panel))
|
|
{
|
|
Control!.BwoinkArea.AddChild(panel);
|
|
}
|
|
panel.Visible = false;
|
|
}
|
|
}
|
|
|
|
public void HideAllPanels()
|
|
{
|
|
foreach (var panel in _activePanelMap.Values)
|
|
{
|
|
panel.Visible = false;
|
|
}
|
|
}
|
|
|
|
public BwoinkPanel EnsurePanel(NetUserId channelId)
|
|
{
|
|
EnsureControl();
|
|
|
|
if (_activePanelMap.TryGetValue(channelId, out var existingPanel))
|
|
return existingPanel;
|
|
|
|
_activePanelMap[channelId] = existingPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(channelId, text, Window?.Bwoink.PlaySound.Pressed ?? true, Window?.Bwoink.AdminOnly.Pressed ?? false));
|
|
existingPanel.InputTextChanged += text => InputTextChanged?.Invoke(channelId, text);
|
|
existingPanel.Visible = false;
|
|
if (!Control!.BwoinkArea.Children.Contains(existingPanel))
|
|
Control.BwoinkArea.AddChild(existingPanel);
|
|
|
|
return existingPanel;
|
|
}
|
|
public bool TryGetChannel(NetUserId ch, [NotNullWhen(true)] out BwoinkPanel? bp) => _activePanelMap.TryGetValue(ch, out bp);
|
|
|
|
private void SelectChannel(NetUserId uid)
|
|
{
|
|
EnsurePanel(uid);
|
|
Control!.SelectChannel(uid);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
Window?.Dispose();
|
|
Window = null;
|
|
Control = null;
|
|
// Sunrise-Start
|
|
foreach (var (_, panel) in _activePanelMap)
|
|
{
|
|
panel.LoadDb = false;
|
|
}
|
|
// Sunrise-End
|
|
_activePanelMap.Clear();
|
|
EverOpened = false;
|
|
}
|
|
}
|
|
|
|
public sealed class UserAHelpUIHandler : IAHelpUIHandler
|
|
{
|
|
private readonly NetUserId _ownerId;
|
|
private BwoinkSystem? _bwoinkSystem; // Sunrise-Edit
|
|
public UserAHelpUIHandler(NetUserId owner, BwoinkSystem? bwoinkSystem) // Sunrise-Edit
|
|
{
|
|
_ownerId = owner;
|
|
_bwoinkSystem = bwoinkSystem; // Sunrise-Edit
|
|
}
|
|
public bool IsAdmin => false;
|
|
public bool IsOpen => _window is { Disposed: false, IsOpen: true };
|
|
private DefaultWindow? _window;
|
|
private BwoinkPanel? _chatPanel;
|
|
private bool _discordRelayActive;
|
|
public bool LoadDb;
|
|
|
|
public void Receive(SharedBwoinkSystem.BwoinkTextMessage message)
|
|
{
|
|
DebugTools.Assert(message.UserId == _ownerId);
|
|
EnsureInit(_discordRelayActive);
|
|
_chatPanel!.ReceiveLine(message);
|
|
_window!.OpenCentered();
|
|
}
|
|
|
|
// Sunrise-Start
|
|
public void SetLoadDb(NetUserId userId)
|
|
{
|
|
LoadDb = true;
|
|
}
|
|
|
|
public void Clean(NetUserId userId)
|
|
{
|
|
_chatPanel!.TextOutput.Clear();
|
|
}
|
|
|
|
public bool IsLoadDb(NetUserId userId)
|
|
{
|
|
return LoadDb;
|
|
}
|
|
// Sunrise-End
|
|
|
|
public void Close()
|
|
{
|
|
_window?.Close();
|
|
}
|
|
|
|
public void ToggleWindow()
|
|
{
|
|
EnsureInit(_discordRelayActive);
|
|
if (_window!.IsOpen)
|
|
{
|
|
_window.Close();
|
|
}
|
|
else
|
|
{
|
|
_window.OpenCentered();
|
|
}
|
|
}
|
|
|
|
// user can't pop out their window.
|
|
public void PopOut()
|
|
{
|
|
}
|
|
|
|
public void DiscordRelayChanged(bool active)
|
|
{
|
|
_discordRelayActive = active;
|
|
|
|
if (_chatPanel != null)
|
|
{
|
|
_chatPanel.RelayedToDiscordLabel.Visible = active;
|
|
}
|
|
}
|
|
|
|
public void PeopleTypingUpdated(BwoinkPlayerTypingUpdated args)
|
|
{
|
|
}
|
|
|
|
// Sunrise-Start
|
|
public void OnCooldownReceived(BwoinkCooldownMessage message)
|
|
{
|
|
_chatPanel?.OnCooldownReceived(message);
|
|
}
|
|
// Sunrise-End
|
|
|
|
public event Action? OnClose;
|
|
public event Action? OnOpen;
|
|
public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
|
|
public event Action<NetUserId, string>? InputTextChanged;
|
|
|
|
public void Open(NetUserId channelId, bool relayActive)
|
|
{
|
|
EnsureInit(relayActive);
|
|
_window!.OpenCentered();
|
|
}
|
|
|
|
private void EnsureInit(bool relayActive)
|
|
{
|
|
if (_window is { Disposed: false })
|
|
return;
|
|
_chatPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(_ownerId, text, true, false));
|
|
// Sunrise-Start
|
|
_chatPanel.AHelpDescLabel.Visible = true;
|
|
_chatPanel.AdminWhoButton.Visible = true;
|
|
// Sunrise-End
|
|
_chatPanel.InputTextChanged += text => InputTextChanged?.Invoke(_ownerId, text);
|
|
_chatPanel.RelayedToDiscordLabel.Visible = relayActive;
|
|
_window = new DefaultWindow()
|
|
{
|
|
TitleClass="windowTitleAlert",
|
|
HeaderClass="windowHeaderAlert",
|
|
Title=Loc.GetString("bwoink-user-title"),
|
|
MinSize = new Vector2(900, 500), // Sunrise-Edit
|
|
};
|
|
_window.OnClose += () => { OnClose?.Invoke(); };
|
|
_window.OnOpen += () => { OnOpen?.Invoke(); };
|
|
_window.Contents.AddChild(_chatPanel);
|
|
|
|
// Sunrise-Start
|
|
if (!IsLoadDb(_ownerId))
|
|
{
|
|
_bwoinkSystem?.LoadDbMessages(_ownerId);
|
|
}
|
|
|
|
//var introText = Loc.GetString("bwoink-system-introductory-message");
|
|
//var introMessage = new SharedBwoinkSystem.BwoinkTextMessage( _ownerId, SharedBwoinkSystem.SystemUserId, introText);
|
|
//Receive(introMessage);
|
|
// Sunrise-End
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_window?.Dispose();
|
|
_window = null;
|
|
_chatPanel = null;
|
|
LoadDb = false; // Sunrise-Edit
|
|
}
|
|
}
|