Skip to content

Commit

Permalink
Merge pull request space-syndicate#1227 from space-syndicate/upstream…
Browse files Browse the repository at this point in the history
…-sync

Upstream sync
  • Loading branch information
Morb0 authored Jul 28, 2023
2 parents ec0e758 + d132302 commit c4cd8e1
Show file tree
Hide file tree
Showing 649 changed files with 160,517 additions and 319,202 deletions.
51 changes: 0 additions & 51 deletions Content.Client/Animations/AnimationsTestComponent.cs

This file was deleted.

4 changes: 2 additions & 2 deletions Content.Client/Construction/ConstructionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ public override void Initialize()

CommandBinds.Builder
.Bind(ContentKeyFunctions.OpenCraftingMenu,
new PointerInputCmdHandler(HandleOpenCraftingMenu))
new PointerInputCmdHandler(HandleOpenCraftingMenu, outsidePrediction:true))
.Bind(EngineKeyFunctions.Use,
new PointerInputCmdHandler(HandleUse, outsidePrediction: true))
.Bind(ContentKeyFunctions.EditorFlipObject,
new PointerInputCmdHandler(HandleFlip))
new PointerInputCmdHandler(HandleFlip, outsidePrediction:true))
.Register<ConstructionSystem>();

SubscribeLocalEvent<ConstructionGhostComponent, ExaminedEvent>(HandleConstructionGhostExamined);
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/DragDrop/DragDropSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public override void Initialize()
_dropTargetOutOfRangeShader = _prototypeManager.Index<ShaderPrototype>(ShaderDropTargetOutOfRange).Instance();
// needs to fire on mouseup and mousedown so we can detect a drag / drop
CommandBinds.Builder
.BindBefore(EngineKeyFunctions.Use, new PointerInputCmdHandler(OnUse, false), new[] { typeof(SharedInteractionSystem) })
.BindBefore(EngineKeyFunctions.Use, new PointerInputCmdHandler(OnUse, false, true), new[] { typeof(SharedInteractionSystem) })
.Register<DragDropSystem>();
}

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
4 changes: 2 additions & 2 deletions Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public void Populate(HealthAnalyzerScannedUserMessage msg)
text.Append($"{Loc.GetString("health-analyzer-window-entity-health-text", ("entityName", entityName))}\n");


text.Append(String.Format("Temperature: {0}\n", float.IsNaN(msg.Temperature) ? "N/A" : $"{msg.Temperature - 273f:F1} °C"));
text.Append($"{Loc.GetString("health-analyzer-window-entity-temperature-text", ("temperature", float.IsNaN(msg.Temperature) ? "N/A" : $"{msg.Temperature - 273f:F1} °C"))}\n");


text.Append(String.Format("Blood Level: {0}\n", float.IsNaN(msg.BloodLevel) ? "N/A" : $"{msg.BloodLevel * 100:F1} %"));
text.Append($"{Loc.GetString("health-analyzer-window-entity-blood-level-text", ("bloodLevel", float.IsNaN(msg.BloodLevel) ? "N/A" : $"{msg.BloodLevel * 100:F1} %"))}\n");


// Damage
Expand Down

This file was deleted.

19 changes: 0 additions & 19 deletions Content.Client/MachineLinking/UI/SignalPortSelectorMenu.xaml

This file was deleted.

Loading

0 comments on commit c4cd8e1

Please sign in to comment.