-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1512 from space-syndicate/upstream-sync
Upstream sync
- Loading branch information
Showing
169 changed files
with
1,247 additions
and
850 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
Content.Client/Guidebook/Controls/GuideTechDisciplineEmbed.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<BoxContainer xmlns="https://spacestation14.io" | ||
Orientation="Vertical"> | ||
<BoxContainer Name="DisciplineContainer" Orientation="Vertical"/> | ||
</BoxContainer> |
60 changes: 60 additions & 0 deletions
60
Content.Client/Guidebook/Controls/GuideTechDisciplineEmbed.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
using Content.Client.Guidebook.Richtext; | ||
using Content.Shared.Research.Prototypes; | ||
using JetBrains.Annotations; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.Guidebook.Controls; | ||
|
||
/// <summary> | ||
/// Control for embedding all the technologies in a discipline into a guidebook. | ||
/// </summary> | ||
[UsedImplicitly, GenerateTypedNameReferences] | ||
public sealed partial class GuideTechDisciplineEmbed : BoxContainer, IDocumentTag | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototype = default!; | ||
|
||
public GuideTechDisciplineEmbed() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
MouseFilter = MouseFilterMode.Stop; | ||
} | ||
|
||
public GuideTechDisciplineEmbed(string group) : this() | ||
{ | ||
var prototypes = _prototype.EnumeratePrototypes<TechnologyPrototype>() | ||
.Where(p => p.Discipline.Equals(group)).OrderBy(p => p.Tier).ThenBy(p => Loc.GetString(p.Name)); | ||
foreach (var tech in prototypes) | ||
{ | ||
var embed = new GuideTechnologyEmbed(tech); | ||
DisciplineContainer.AddChild(embed); | ||
} | ||
} | ||
|
||
public bool TryParseTag(Dictionary<string, string> args, [NotNullWhen(true)] out Control? control) | ||
{ | ||
control = null; | ||
if (!args.TryGetValue("Discipline", out var group)) | ||
{ | ||
Logger.Error("Technology discipline embed tag is missing discipline argument"); | ||
return false; | ||
} | ||
|
||
var prototypes = _prototype.EnumeratePrototypes<TechnologyPrototype>() | ||
.Where(p => p.Discipline.Equals(group)).OrderBy(p => p.Tier).ThenBy(p => Loc.GetString(p.Name)); | ||
foreach (var tech in prototypes) | ||
{ | ||
var embed = new GuideTechnologyEmbed(tech); | ||
DisciplineContainer.AddChild(embed); | ||
} | ||
|
||
control = this; | ||
return true; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Content.Client/Guidebook/Controls/GuideTechnologyEmbed.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<BoxContainer xmlns="https://spacestation14.io" | ||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" | ||
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls" | ||
Orientation="Vertical" | ||
Margin="5 5 5 5"> | ||
<PanelContainer HorizontalExpand="True"> | ||
<PanelContainer.PanelOverride> | ||
<gfx:StyleBoxFlat BorderThickness="1" BorderColor="#777777"/> | ||
</PanelContainer.PanelOverride> | ||
<BoxContainer Orientation="Vertical"> | ||
<PanelContainer Name="DisciplineColorBackground" HorizontalExpand="True" VerticalExpand="False" MinHeight="15"/> | ||
<BoxContainer Orientation="Vertical" Margin="5 5 5 5"> | ||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True"> | ||
<RichTextLabel Name="NameLabel" VerticalAlignment="Bottom" HorizontalExpand="True"/> | ||
<TextureRect Name="TechTexture" VerticalAlignment="Center" HorizontalAlignment="Right"/> | ||
</BoxContainer> | ||
<customControls:HSeparator Margin="10 5 10 10"/> | ||
<RichTextLabel Name="DescriptionLabel"/> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</PanelContainer> | ||
</BoxContainer> |
93 changes: 93 additions & 0 deletions
93
Content.Client/Guidebook/Controls/GuideTechnologyEmbed.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using Content.Client.Guidebook.Richtext; | ||
using Content.Client.Message; | ||
using Content.Client.Research; | ||
using Content.Client.UserInterface.ControlExtensions; | ||
using Content.Shared.Research.Prototypes; | ||
using JetBrains.Annotations; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.Guidebook.Controls; | ||
|
||
/// <summary> | ||
/// Control for embedding a research technology into a guidebook. | ||
/// </summary> | ||
[UsedImplicitly, GenerateTypedNameReferences] | ||
public sealed partial class GuideTechnologyEmbed : BoxContainer, IDocumentTag, ISearchableControl | ||
{ | ||
[Dependency] private readonly IEntitySystemManager _systemManager = default!; | ||
[Dependency] private readonly IPrototypeManager _prototype = default!; | ||
|
||
private readonly ResearchSystem _research; | ||
private readonly SpriteSystem _sprite; | ||
|
||
public GuideTechnologyEmbed() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
_research = _systemManager.GetEntitySystem<ResearchSystem>(); | ||
_sprite = _systemManager.GetEntitySystem<SpriteSystem>(); | ||
MouseFilter = MouseFilterMode.Stop; | ||
} | ||
|
||
public GuideTechnologyEmbed(string technology) : this() | ||
{ | ||
GenerateControl(_prototype.Index<TechnologyPrototype>(technology)); | ||
} | ||
|
||
public GuideTechnologyEmbed(TechnologyPrototype technology) : this() | ||
{ | ||
GenerateControl(technology); | ||
} | ||
|
||
public bool CheckMatchesSearch(string query) | ||
{ | ||
return this.ChildrenContainText(query); | ||
} | ||
|
||
public void SetHiddenState(bool state, string query) | ||
{ | ||
Visible = CheckMatchesSearch(query) ? state : !state; | ||
} | ||
|
||
public bool TryParseTag(Dictionary<string, string> args, [NotNullWhen(true)] out Control? control) | ||
{ | ||
control = null; | ||
if (!args.TryGetValue("Technology", out var id)) | ||
{ | ||
Logger.Error("Technology embed tag is missing technology prototype argument"); | ||
return false; | ||
} | ||
|
||
if (!_prototype.TryIndex<TechnologyPrototype>(id, out var technology)) | ||
{ | ||
Logger.Error($"Specified technology prototype \"{id}\" is not a valid technology prototype"); | ||
return false; | ||
} | ||
|
||
GenerateControl(technology); | ||
|
||
control = this; | ||
return true; | ||
} | ||
|
||
private void GenerateControl(TechnologyPrototype technology) | ||
{ | ||
var discipline = _prototype.Index(technology.Discipline); | ||
|
||
NameLabel.SetMarkup($"[bold]{Loc.GetString(technology.Name)}[/bold]"); | ||
DescriptionLabel.SetMessage(_research.GetTechnologyDescription(technology, includePrereqs: true, disciplinePrototype: discipline)); | ||
TechTexture.Texture = _sprite.Frame0(technology.Icon); | ||
|
||
DisciplineColorBackground.PanelOverride = new StyleBoxFlat | ||
{ | ||
BackgroundColor = discipline.Color | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.