fix lathe syncing and tweak ui (#17489)

This commit is contained in:
Nemanja
2023-06-20 02:39:35 -04:00
committed by GitHub
parent 763f6048f2
commit a01f26d3a6
12 changed files with 64 additions and 83 deletions

View File

@@ -29,16 +29,15 @@ namespace Content.Client.Lathe.UI
_menu.OnQueueButtonPressed += _ =>
{
if (_queueMenu.IsOpen)
_queueMenu.Close();
else
_queueMenu.OpenCenteredLeft();
};
_menu.OnServerListButtonPressed += _ =>
{
SendMessage(new ConsoleServerSelectionMessage());
};
_menu.OnServerSyncButtonPressed += _ =>
{
SendMessage(new ConsoleServerSyncMessage());
};
_menu.RecipeQueueAction += (recipe, amount) =>
{
SendMessage(new LatheQueueRecipeMessage(recipe, amount));
@@ -56,7 +55,7 @@ namespace Content.Client.Lathe.UI
case LatheUpdateState msg:
if (_menu != null)
_menu.Recipes = msg.Recipes;
_menu?.PopulateRecipes(Owner.Owner);
_menu?.PopulateRecipes(Lathe);
_menu?.PopulateMaterials(Lathe);
_queueMenu?.PopulateList(msg.Queue);
_queueMenu?.SetInfo(msg.CurrentlyProducing);

View File

@@ -1,86 +1,85 @@
<DefaultWindow
xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
Title="{Loc 'lathe-menu-title'}"
MinSize="300 450"
SetSize="300 450">
<BoxContainer
Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True"
SeparationOverride="5">
<BoxContainer
Orientation="Horizontal"
Align="End"
HorizontalExpand="True"
VerticalExpand="True"
SizeFlagsStretchRatio="1">
HorizontalExpand="True">
<Button
Name="QueueButton"
Text="{Loc 'lathe-menu-queue'}"
TextAlign="Center"
Mode="Press"
SizeFlagsStretchRatio="1">
StyleClasses="OpenRight">
</Button>
<Button
Name="ServerListButton"
Text="{Loc 'lathe-menu-server-list'}"
TextAlign="Center"
Mode="Press"
SizeFlagsStretchRatio="1">
</Button>
<Button
Name="ServerSyncButton"
Text="{Loc 'lathe-menu-sync'}"
TextAlign="Center"
Mode="Press"
SizeFlagsStretchRatio="1">
StyleClasses="OpenLeft">
</Button>
</BoxContainer>
<BoxContainer
Orientation="Horizontal"
HorizontalExpand="True"
VerticalExpand="True"
SizeFlagsStretchRatio="1">
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True">
<LineEdit
Name="SearchBar"
PlaceHolder="{Loc 'lathe-menu-search-designs'}"
HorizontalExpand="True"
SizeFlagsStretchRatio="1">
HorizontalExpand="True">
</LineEdit>
<Button
Name="FilterButton"
Text="{Loc 'lathe-menu-search-filter'}"
TextAlign="Center"
SizeFlagsStretchRatio="1"
Disabled="True">
Margin="5 0 0 0"
Disabled="True"
StyleClasses="ButtonSquare">
</Button>
</BoxContainer>
<ScrollContainer MinHeight="225">
<BoxContainer Orientation="Vertical"
MinHeight="225"
VerticalExpand="True"
HorizontalExpand="True"
SizeFlagsStretchRatio="4">
<PanelContainer VerticalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#1B1B1E" />
</PanelContainer.PanelOverride>
<ScrollContainer VerticalExpand="True" HScrollEnabled="False">
<BoxContainer
Name="RecipeList"
Orientation="Vertical"
SizeFlagsStretchRatio="8"
HorizontalExpand="True"
VerticalExpand="True">
</BoxContainer>
</ScrollContainer>
<BoxContainer
Orientation="Horizontal"
HorizontalExpand="True"
VerticalExpand="True"
SizeFlagsStretchRatio="1">
RectClipContent="True">
</BoxContainer>
</ScrollContainer>
</PanelContainer>
</BoxContainer>
<BoxContainer Orientation="Horizontal"
HorizontalExpand="True">
<Label Margin="8 0 8 0" Text="{Loc 'lathe-menu-amount'}"/>
<LineEdit
Name="AmountLineEdit"
PlaceHolder="0"
Text="1"
HorizontalExpand="True" />
HorizontalExpand="True"/>
</BoxContainer>
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
<ItemList
Name="Materials"
VerticalExpand="True"
SizeFlagsStretchRatio="3">
VerticalExpand="True">
</ItemList>
</BoxContainer>
</BoxContainer>
</DefaultWindow>

View File

@@ -1,5 +1,6 @@
using System.Linq;
using System.Text;
using Content.Client.Stylesheets;
using Content.Shared.Lathe;
using Content.Shared.Materials;
using Content.Shared.Research.Prototypes;
@@ -22,7 +23,6 @@ public sealed partial class LatheMenu : DefaultWindow
public event Action<BaseButton.ButtonEventArgs>? OnQueueButtonPressed;
public event Action<BaseButton.ButtonEventArgs>? OnServerListButtonPressed;
public event Action<BaseButton.ButtonEventArgs>? OnServerSyncButtonPressed;
public event Action<string, int>? RecipeQueueAction;
public List<string> Recipes = new();
@@ -49,15 +49,13 @@ public sealed partial class LatheMenu : DefaultWindow
QueueButton.OnPressed += a => OnQueueButtonPressed?.Invoke(a);
ServerListButton.OnPressed += a => OnServerListButtonPressed?.Invoke(a);
//refresh the bui state
ServerSyncButton.OnPressed += a => OnServerSyncButtonPressed?.Invoke(a);
if (_entityManager.TryGetComponent<LatheComponent>(owner.Lathe, out var latheComponent))
{
if (!latheComponent.DynamicRecipes.Any())
{
ServerListButton.Visible = false;
ServerSyncButton.Visible = false;
QueueButton.RemoveStyleClass(StyleBase.ButtonOpenRight);
//QueueButton.AddStyleClass(StyleBase.ButtonSquare);
}
}
}

View File

@@ -2,11 +2,13 @@
<Button
Name="Button"
HorizontalExpand="True"
TooltipDelay="0.5">
TooltipDelay="0.5"
Margin="0"
StyleClasses="ButtonSquare">
<BoxContainer Orientation="Horizontal">
<TextureRect
Name="RecipeTexture"
Margin="0,0,4,0"
Margin="0 0 4 0"
MinSize="32 32"
Stretch="KeepAspectCentered" />
<Label Name="RecipeName" HorizontalExpand="True" />

View File

@@ -1,6 +1,4 @@
using Content.Shared.Research.Components;
using Content.Shared.Research.Prototypes;
using Content.Shared.Research.Systems;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
@@ -15,7 +13,7 @@ public sealed class ResearchConsoleBoundUserInterface : BoundUserInterface
public ResearchConsoleBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey)
{
SendMessage(new ConsoleServerSyncMessage());
}
protected override void Open()
@@ -36,11 +34,6 @@ public sealed class ResearchConsoleBoundUserInterface : BoundUserInterface
SendMessage(new ConsoleServerSelectionMessage());
};
_consoleMenu.OnSyncButtonPressed += () =>
{
SendMessage(new ConsoleServerSyncMessage());
};
_consoleMenu.OnClose += Close;
_consoleMenu.OpenCentered();

View File

@@ -21,10 +21,7 @@
<!-- This is where we put all of the little graphics that display discipline tiers!-->
</BoxContainer>
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalAlignment="Right">
<Button Name="ServerButton" Text="{Loc 'research-console-menu-server-selection-button'}" VerticalExpand="True"/>
<Control MinHeight="5"/>
<!--todo is this button even necessary?!-->
<Button Name="SyncButton" Text="{Loc 'research-console-menu-server-sync-button'}" VerticalExpand="True"/>
<Button Name="ServerButton" Text="{Loc 'research-console-menu-server-selection-button'}" MinHeight="40"/>
</BoxContainer>
</BoxContainer>
<BoxContainer Orientation="Horizontal"

View File

@@ -16,7 +16,6 @@ public sealed partial class ResearchConsoleMenu : FancyWindow
{
public Action<string>? OnTechnologyCardPressed;
public Action? OnServerButtonPressed;
public Action? OnSyncButtonPressed;
[Dependency] private readonly IEntityManager _entity = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
@@ -36,7 +35,6 @@ public sealed partial class ResearchConsoleMenu : FancyWindow
Entity = entity;
ServerButton.OnPressed += _ => OnServerButtonPressed?.Invoke();
SyncButton.OnPressed += _ => OnSyncButtonPressed?.Invoke();
_entity.TryGetComponent(entity, out _technologyDatabase);
}

View File

@@ -41,6 +41,7 @@ namespace Content.Server.Lathe
SubscribeLocalEvent<LatheComponent, RefreshPartsEvent>(OnPartsRefresh);
SubscribeLocalEvent<LatheComponent, UpgradeExamineEvent>(OnUpgradeExamine);
SubscribeLocalEvent<LatheComponent, TechnologyDatabaseModifiedEvent>(OnDatabaseModified);
SubscribeLocalEvent<LatheComponent, ResearchRegistrationChangedEvent>(OnResearchRegistrationChanged);
SubscribeLocalEvent<LatheComponent, LatheQueueRecipeMessage>(OnLatheQueueRecipeMessage);
SubscribeLocalEvent<LatheComponent, LatheSyncRequestMessage>(OnLatheSyncRequestMessage);
@@ -262,6 +263,11 @@ namespace Content.Server.Lathe
UpdateUserInterfaceState(uid, component);
}
private void OnResearchRegistrationChanged(EntityUid uid, LatheComponent component, ref ResearchRegistrationChangedEvent args)
{
UpdateUserInterfaceState(uid, component);
}
protected override bool HasRecipe(EntityUid uid, LatheRecipePrototype recipe, LatheComponent component)
{
return GetAvailableRecipes(uid, component).Contains(recipe.ID);

View File

@@ -13,7 +13,6 @@ public sealed partial class ResearchSystem
SubscribeLocalEvent<ResearchClientComponent, MapInitEvent>(OnClientMapInit);
SubscribeLocalEvent<ResearchClientComponent, ComponentShutdown>(OnClientShutdown);
SubscribeLocalEvent<ResearchClientComponent, BoundUIOpenedEvent>(OnClientUIOpen);
SubscribeLocalEvent<ResearchClientComponent, ConsoleServerSyncMessage>(OnConsoleSync);
SubscribeLocalEvent<ResearchClientComponent, ConsoleServerSelectionMessage>(OnConsoleSelect);
SubscribeLocalEvent<ResearchClientComponent, ResearchClientSyncMessage>(OnClientSyncMessage);
@@ -50,14 +49,6 @@ public sealed partial class ResearchSystem
_uiSystem.TryToggleUi(uid, ResearchClientUiKey.Key, (IPlayerSession) args.Session);
}
private void OnConsoleSync(EntityUid uid, ResearchClientComponent component, ConsoleServerSyncMessage args)
{
if (!this.IsPowered(uid, EntityManager))
return;
SyncClientWithServer(uid);
}
#endregion
private void OnClientRegistrationChanged(EntityUid uid, ResearchClientComponent component, ref ResearchRegistrationChangedEvent args)

View File

@@ -71,6 +71,7 @@ public sealed partial class ResearchSystem
serverComponent.Clients.Add(client);
clientComponent.Server = server;
SyncClientWithServer(client, clientComponent: clientComponent);
if (dirtyServer)
Dirty(serverComponent);
@@ -112,6 +113,7 @@ public sealed partial class ResearchSystem
serverComponent.Clients.Remove(client);
clientComponent.Server = null;
SyncClientWithServer(client, clientComponent: clientComponent);
if (dirtyServer)
{

View File

@@ -19,12 +19,6 @@ namespace Content.Shared.Research.Components
}
}
[Serializable, NetSerializable]
public sealed class ConsoleServerSyncMessage : BoundUserInterfaceMessage
{
}
[Serializable, NetSerializable]
public sealed class ConsoleServerSelectionMessage : BoundUserInterfaceMessage
{

View File

@@ -40,6 +40,8 @@
interfaces:
- key: enum.LatheUiKey.Key
type: LatheBoundUserInterface
- key: enum.ResearchClientUiKey.Key
type: ResearchClientBoundUserInterface
- type: Transform
anchored: true
- type: Pullable