[feat]MeatyOre panel
This commit is contained in:
@@ -71,7 +71,7 @@ public sealed partial class StoreMenu : DefaultWindow
|
||||
disabled = false;
|
||||
}
|
||||
|
||||
WithdrawButton.Disabled = disabled;
|
||||
WithdrawButton.Visible = !disabled;
|
||||
}
|
||||
|
||||
public void UpdateListing(List<ListingData> listings)
|
||||
|
||||
@@ -9,6 +9,7 @@ using Content.Client.UserInterface.Systems.Gameplay;
|
||||
using Content.Client.UserInterface.Systems.Guidebook;
|
||||
using Content.Client.UserInterface.Systems.MenuBar.Widgets;
|
||||
using Content.Client.UserInterface.Systems.Sandbox;
|
||||
using Content.Client.White.MeatyOre;
|
||||
using Robust.Client.UserInterface.Controllers;
|
||||
|
||||
namespace Content.Client.UserInterface.Systems.MenuBar;
|
||||
@@ -24,6 +25,8 @@ public sealed class GameTopMenuBarUIController : UIController
|
||||
[Dependency] private readonly SandboxUIController _sandbox = default!;
|
||||
[Dependency] private readonly GuidebookUIController _guidebook = default!;
|
||||
[Dependency] private readonly EmotionsUIController _emotions = default!;
|
||||
[Dependency] private readonly MeatyOreUIController _meatyOreUIController = default!;
|
||||
|
||||
|
||||
private GameTopMenuBar? GameTopMenuBar => UIManager.GetActiveUIWidgetOrNull<GameTopMenuBar>();
|
||||
|
||||
@@ -47,6 +50,7 @@ public sealed class GameTopMenuBarUIController : UIController
|
||||
_action.UnloadButton();
|
||||
_sandbox.UnloadButton();
|
||||
_emotions.UnloadButton();
|
||||
_meatyOreUIController.UnloadButton();
|
||||
}
|
||||
|
||||
public void LoadButtons()
|
||||
@@ -60,5 +64,6 @@ public sealed class GameTopMenuBarUIController : UIController
|
||||
_action.LoadButton();
|
||||
_sandbox.LoadButton();
|
||||
_emotions.LoadButton();
|
||||
_meatyOreUIController.LoadButton();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +93,16 @@
|
||||
HorizontalExpand="True"
|
||||
AppendStyleClass="{x:Static style:StyleBase.ButtonSquare}"
|
||||
/>
|
||||
<ui:MenuButton
|
||||
Name="MeatyOreButton"
|
||||
Access="Internal"
|
||||
MinSize="42 64"
|
||||
HorizontalExpand="True"
|
||||
Icon="{xe:Tex '/Textures/Interface/meatyore-shop-icon.png'}"
|
||||
AppendStyleClass="{x:Static style:StyleBase.ButtonSquare}"
|
||||
ToolTip="Магазин метеора"
|
||||
ToggleMode="False"
|
||||
/>
|
||||
<ui:MenuButton
|
||||
Name="AHelpButton"
|
||||
Access="Internal"
|
||||
|
||||
65
Content.Client/White/MeatyOre/MeatyOreUIController.cs
Normal file
65
Content.Client/White/MeatyOre/MeatyOreUIController.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using Content.Client.Administration.Managers;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Client.UserInterface.Systems.MenuBar.Widgets;
|
||||
using Content.Client.White.Sponsors;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.White.MeatyOre;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controllers;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Client.White.MeatyOre;
|
||||
|
||||
public sealed class MeatyOreUIController : UIController
|
||||
{
|
||||
[Dependency] private readonly IClientAdminManager _clientAdminManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IEntityNetworkManager _entityNetworkManager = default!;
|
||||
[Dependency] private readonly SponsorsManager _sponsorsManager = default!;
|
||||
|
||||
private bool _buttonLoaded;
|
||||
|
||||
private MenuButton? MeatyOreButton => UIManager.GetActiveUIWidgetOrNull<GameTopMenuBar>()?.MeatyOreButton;
|
||||
public void LoadButton()
|
||||
{
|
||||
MeatyOreButton!.OnPressed += MeatyOreButtonPressed;
|
||||
_buttonLoaded = true;
|
||||
}
|
||||
|
||||
public void UnloadButton()
|
||||
{
|
||||
MeatyOreButton!.OnPressed -= MeatyOreButtonPressed;
|
||||
_buttonLoaded = false;
|
||||
}
|
||||
|
||||
private void MeatyOreButtonPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
_entityNetworkManager.SendSystemNetworkMessage(new MeatyOreShopRequestEvent());
|
||||
}
|
||||
|
||||
public override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
base.FrameUpdate(args);
|
||||
|
||||
if(!_buttonLoaded) return;
|
||||
var shouldBeVisible = CheckButtonVisibility();
|
||||
MeatyOreButton!.Visible = shouldBeVisible;
|
||||
}
|
||||
|
||||
|
||||
private bool CheckButtonVisibility()
|
||||
{
|
||||
if(!_sponsorsManager.TryGetInfo(out var sponsor)) return false;
|
||||
if(sponsor?.Tier == null || sponsor?.MeatyOreCoin == 0) return false;
|
||||
|
||||
var controlledEntity = _playerManager!.LocalPlayer!.ControlledEntity;
|
||||
if(controlledEntity == null) return false;
|
||||
|
||||
if (!_entityManager.HasComponent<HumanoidAppearanceComponent>(controlledEntity)) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user