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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -13,7 +13,6 @@ public sealed partial class ResearchSystem
SubscribeLocalEvent<ResearchClientComponent, MapInitEvent>(OnClientMapInit); SubscribeLocalEvent<ResearchClientComponent, MapInitEvent>(OnClientMapInit);
SubscribeLocalEvent<ResearchClientComponent, ComponentShutdown>(OnClientShutdown); SubscribeLocalEvent<ResearchClientComponent, ComponentShutdown>(OnClientShutdown);
SubscribeLocalEvent<ResearchClientComponent, BoundUIOpenedEvent>(OnClientUIOpen); SubscribeLocalEvent<ResearchClientComponent, BoundUIOpenedEvent>(OnClientUIOpen);
SubscribeLocalEvent<ResearchClientComponent, ConsoleServerSyncMessage>(OnConsoleSync);
SubscribeLocalEvent<ResearchClientComponent, ConsoleServerSelectionMessage>(OnConsoleSelect); SubscribeLocalEvent<ResearchClientComponent, ConsoleServerSelectionMessage>(OnConsoleSelect);
SubscribeLocalEvent<ResearchClientComponent, ResearchClientSyncMessage>(OnClientSyncMessage); SubscribeLocalEvent<ResearchClientComponent, ResearchClientSyncMessage>(OnClientSyncMessage);
@@ -50,14 +49,6 @@ public sealed partial class ResearchSystem
_uiSystem.TryToggleUi(uid, ResearchClientUiKey.Key, (IPlayerSession) args.Session); _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 #endregion
private void OnClientRegistrationChanged(EntityUid uid, ResearchClientComponent component, ref ResearchRegistrationChangedEvent args) 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); serverComponent.Clients.Add(client);
clientComponent.Server = server; clientComponent.Server = server;
SyncClientWithServer(client, clientComponent: clientComponent);
if (dirtyServer) if (dirtyServer)
Dirty(serverComponent); Dirty(serverComponent);
@@ -112,6 +113,7 @@ public sealed partial class ResearchSystem
serverComponent.Clients.Remove(client); serverComponent.Clients.Remove(client);
clientComponent.Server = null; clientComponent.Server = null;
SyncClientWithServer(client, clientComponent: clientComponent);
if (dirtyServer) if (dirtyServer)
{ {

View File

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

View File

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