Skip to content

Commit

Permalink
Merge branch 'upstream' into 'arumoon-server'
Browse files Browse the repository at this point in the history
Upstream (DB update)

See merge request Workbench-Team/space-station-14!94
  • Loading branch information
AruMoon committed Jul 29, 2023
2 parents e91564a + 24900eb commit 9ee95cd
Show file tree
Hide file tree
Showing 539 changed files with 26,811 additions and 19,315 deletions.
51 changes: 0 additions & 51 deletions Content.Client/Animations/AnimationsTestComponent.cs

This file was deleted.

50 changes: 50 additions & 0 deletions Content.Client/CartridgeLoader/Cartridges/NewsReadUi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Content.Client.UserInterface.Fragments;
using Content.Shared.CartridgeLoader.Cartridges;
using Content.Shared.CartridgeLoader;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;

namespace Content.Client.CartridgeLoader.Cartridges;

public sealed class NewsReadUi : UIFragment
{
private NewsReadUiFragment? _fragment;

public override Control GetUIFragmentRoot()
{
return _fragment!;
}

public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner)
{
_fragment = new NewsReadUiFragment();

_fragment.OnNextButtonPressed += () =>
{
SendNewsReadMessage(NewsReadUiAction.Next, userInterface);
};
_fragment.OnPrevButtonPressed += () =>
{
SendNewsReadMessage(NewsReadUiAction.Prev, userInterface);
};
_fragment.OnNotificationSwithPressed += () =>
{
SendNewsReadMessage(NewsReadUiAction.NotificationSwith, userInterface);
};
}

public override void UpdateState(BoundUserInterfaceState state)
{
if (state is NewsReadBoundUserInterfaceState cast)
_fragment?.UpdateState(cast.Article, cast.TargetNum, cast.TotalNum, cast.NotificationOn);
else if (state is NewsReadEmptyBoundUserInterfaceState empty)
_fragment?.UpdateEmptyState(empty.NotificationOn);
}

private void SendNewsReadMessage(NewsReadUiAction action, BoundUserInterface userInterface)
{
var newsMessage = new NewsReadUiMessageEvent(action);
var message = new CartridgeUiMessage(newsMessage);
userInterface.SendMessage(message);
}
}
54 changes: 54 additions & 0 deletions Content.Client/CartridgeLoader/Cartridges/NewsReadUiFragment.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<cartridges:NewsReadUiFragment xmlns:cartridges="clr-namespace:Content.Client.CartridgeLoader.Cartridges"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns="https://spacestation14.io" Margin="1 0 2 0">
<PanelContainer StyleClasses="BackgroundDark"></PanelContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="5,5,5,5">
<Button
Name="Prev"
MinWidth="64"
HorizontalAlignment="Left"
Text="{Loc 'news-read-ui-past-text'}"
Access="Public"
HorizontalExpand="True"/>
<Button
Name="Next"
MinWidth="64"
HorizontalAlignment="Right"
Text="{Loc 'news-read-ui-next-text'}" />
</BoxContainer>
<controls:StripeBack Name="АrticleNameContainer">
<PanelContainer>
<Label Name="PageNum" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="4,0,0,0"/>
<Label Name="PageName" Align="Center"/>
</PanelContainer>
</controls:StripeBack>
<PanelContainer VerticalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#80808005" />
</PanelContainer.PanelOverride>
<ScrollContainer
Name="PageTextScroll"
HScrollEnabled="False"
HorizontalExpand="True"
MinSize="0 0"
SizeFlagsStretchRatio="2"
VerticalExpand="True">
<BoxContainer
Name="PageTextContainer"
MinSize="0 0"
Orientation="Vertical"
SizeFlagsStretchRatio="2"
VerticalExpand="True">
</BoxContainer>
<RichTextLabel Margin="8,8,8,8" Name="PageText" VerticalAlignment="Top"/>
</ScrollContainer>
</PanelContainer>
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" Margin="5,5,5,5">
<Button
Name="NotificationSwith"
MinWidth="20"/>
<RichTextLabel Margin="5,2,2,2" Name="ShareTime" VerticalAlignment="Top"/>
<RichTextLabel Margin="5,2,2,2" Name="Author" VerticalAlignment="Top" HorizontalAlignment="Right"/>
</BoxContainer>
</cartridges:NewsReadUiFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Content.Client.Message;
using Content.Shared.MassMedia.Systems;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.CartridgeLoader.Cartridges;

[GenerateTypedNameReferences]
public sealed partial class NewsReadUiFragment : BoxContainer
{
public event Action? OnNextButtonPressed;
public event Action? OnPrevButtonPressed;

public event Action? OnNotificationSwithPressed;

public NewsReadUiFragment()
{
RobustXamlLoader.Load(this);
Orientation = LayoutOrientation.Vertical;
HorizontalExpand = true;
VerticalExpand = true;

Next.OnPressed += _ => OnNextButtonPressed?.Invoke();
Prev.OnPressed += _ => OnPrevButtonPressed?.Invoke();
NotificationSwith.OnPressed += _ => OnNotificationSwithPressed?.Invoke();
}

public void UpdateState(NewsArticle article, int targetNum, int totalNum, bool notificationOn)
{
PageNum.Visible = true;
PageText.Visible = true;
ShareTime.Visible = true;
Author.Visible = true;

PageName.Text = article.Name;
PageText.SetMarkup(article.Content);

PageNum.Text = $"{targetNum}/{totalNum}";

NotificationSwith.Text = Loc.GetString(notificationOn ? "news-read-ui-notification-on" : "news-read-ui-notification-off");

string shareTime = article.ShareTime.ToString("hh\\:mm\\:ss");
ShareTime.SetMarkup(Loc.GetString("news-read-ui-time-prefix-text") + " " + shareTime);

Author.SetMarkup(Loc.GetString("news-read-ui-author-prefix") + " " + (article.Author != null ? article.Author : Loc.GetString("news-read-ui-no-author")));
}

public void UpdateEmptyState(bool notificationOn)
{
PageNum.Visible = false;
PageText.Visible = false;
ShareTime.Visible = false;
Author.Visible = false;

PageName.Text = Loc.GetString("news-read-ui-not-found-text");

NotificationSwith.Text = Loc.GetString(notificationOn ? "news-read-ui-notification-on" : "news-read-ui-notification-off");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<cartridges:NotekeeperUiFragment xmlns:cartridges="clr-namespace:Content.Client.CartridgeLoader.Cartridges"
<cartridges:NotekeeperUiFragment xmlns:cartridges="clr-namespace:Content.Client.CartridgeLoader.Cartridges"
xmlns="https://spacestation14.io" Margin="1 0 2 0">
<PanelContainer StyleClasses="BackgroundDark"></PanelContainer>
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
Expand Down
13 changes: 12 additions & 1 deletion Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Content.Client.Chemistry.EntitySystems;
using Content.Client.Guidebook.Richtext;
using Content.Client.Message;
using Content.Client.UserInterface.ControlExtensions;
using Content.Shared.Chemistry.Reaction;
using Content.Shared.Chemistry.Reagent;
using JetBrains.Annotations;
Expand All @@ -20,7 +21,7 @@ namespace Content.Client.Guidebook.Controls;
/// Control for embedding a reagent into a guidebook.
/// </summary>
[UsedImplicitly, GenerateTypedNameReferences]
public sealed partial class GuideReagentEmbed : BoxContainer, IDocumentTag
public sealed partial class GuideReagentEmbed : BoxContainer, IDocumentTag, ISearchableControl
{
[Dependency] private readonly IEntitySystemManager _systemManager = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
Expand All @@ -45,6 +46,16 @@ public GuideReagentEmbed(ReagentPrototype reagent) : this()
GenerateControl(reagent);
}

public bool CheckMatchesSearch(string query)
{
return this.ChildrenContainText(query);
}

public void SetHiddenState(bool state, string query)
{
this.Visible = CheckMatchesSearch(query) ? state : !state;
}

public bool TryParseTag(Dictionary<string, string> args, [NotNullWhen(true)] out Control? control)
{
control = null;
Expand Down
28 changes: 19 additions & 9 deletions Content.Client/Guidebook/Controls/GuidebookWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,24 @@
<fancyTree:FancyTree Name="Tree" VerticalExpand="True" HorizontalExpand="True" Access="Public"/>
<cc:VSeparator StyleClasses="LowDivider" Margin="0 -2"/>
</BoxContainer>
<ScrollContainer Name="Scroll" HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True">
<Control>
<BoxContainer Orientation="Vertical" Name="EntryContainer" Margin="5 5 5 5" Visible="False"/>
<BoxContainer Orientation="Vertical" Name="Placeholder" Margin="5 5 5 5">
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'guidebook-placeholder-text'}"/>
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'guidebook-placeholder-text-2'}"/>
</BoxContainer>
</Control>
</ScrollContainer>
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
<BoxContainer Name="SearchContainer" Visible="False" HorizontalExpand="True">
<LineEdit
Name="SearchBar"
PlaceHolder="{Loc 'guidebook-filter-placeholder-text'}"
HorizontalExpand="True"
Margin="0 5 10 5">
</LineEdit>
</BoxContainer>
<ScrollContainer Name="Scroll" HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True">
<Control>
<BoxContainer Orientation="Vertical" Name="EntryContainer" Margin="5 5 5 5" Visible="False"/>
<BoxContainer Orientation="Vertical" Name="Placeholder" Margin="5 5 5 5">
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'guidebook-placeholder-text'}"/>
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Text="{Loc 'guidebook-placeholder-text-2'}"/>
</BoxContainer>
</Control>
</ScrollContainer>
</BoxContainer>
</SplitContainer>
</controls:FancyWindow>
26 changes: 26 additions & 0 deletions Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Client.Guidebook.RichText;
using Content.Client.UserInterface.ControlExtensions;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Controls.FancyTree;
using JetBrains.Annotations;
Expand All @@ -26,6 +27,11 @@ public GuidebookWindow()
IoCManager.InjectDependencies(this);

Tree.OnSelectedItemChanged += OnSelectionChanged;

SearchBar.OnTextChanged += _ =>
{
HandleFilter();
};
}

private void OnSelectionChanged(TreeItem? item)
Expand All @@ -40,6 +46,7 @@ public void ClearSelectedGuide()
{
Placeholder.Visible = true;
EntryContainer.Visible = false;
SearchContainer.Visible = false;
EntryContainer.RemoveAllChildren();
}

Expand All @@ -48,9 +55,12 @@ private void ShowGuide(GuideEntry entry)
Scroll.SetScrollValue(default);
Placeholder.Visible = false;
EntryContainer.Visible = true;
SearchBar.Text = "";
EntryContainer.RemoveAllChildren();
using var file = _resourceManager.ContentFileReadText(entry.Text);

SearchContainer.Visible = entry.FilterEnabled;

if (!_parsingMan.TryAddMarkup(EntryContainer, file.ReadToEnd()))
{
EntryContainer.AddChild(new Label() { Text = "ERROR: Failed to parse document." });
Expand Down Expand Up @@ -159,4 +169,20 @@ public void HandleClick(string link)
ShowGuide(entry);
}
}

private void HandleFilter()
{
var emptySearch = SearchBar.Text.Trim().Length == 0;

if (Tree.SelectedItem != null && Tree.SelectedItem.Metadata is GuideEntry entry && entry.FilterEnabled)
{
var foundElements = EntryContainer.GetSearchableControls();

foreach (var element in foundElements)
{
element.SetHiddenState(true, SearchBar.Text.Trim());
}
}

}
}
9 changes: 9 additions & 0 deletions Content.Client/Guidebook/Controls/ISearchableControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Content.Client.Guidebook.Controls;
public interface ISearchableControl
{
public bool CheckMatchesSearch(string query);
/// <summary>
/// Sets the hidden state for the control. In simple cases this could just disable/hide it, but you may want more complex behavior for some elements.
/// </summary>
public void SetHiddenState(bool state, string query);
}
5 changes: 5 additions & 0 deletions Content.Client/Guidebook/GuideEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public class GuideEntry
[DataField("children", customTypeSerializer:typeof(PrototypeIdListSerializer<GuideEntryPrototype>))]
public List<string> Children = new();

/// <summary>
/// Enable filtering of items.
/// </summary>
[DataField("filterEnabled")] public bool FilterEnabled = default!;

/// <summary>
/// Priority for sorting top-level guides when shown in a tree / table of contents.
/// If the guide is the child of some other guide, the order simply determined by the order of children in <see cref="Children"/>.
Expand Down
Loading

0 comments on commit 9ee95cd

Please sign in to comment.