Skip to content

Commit

Permalink
tran
Browse files Browse the repository at this point in the history
  • Loading branch information
babaevlsdd committed Jun 4, 2024
1 parent 211d39b commit 5fae9e0
Show file tree
Hide file tree
Showing 41 changed files with 402 additions and 403 deletions.
3 changes: 2 additions & 1 deletion Content.Client/Construction/ConstructionSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using Content.Client.Construction.UI;
using Content.Client.Popups;
using Content.Shared.Construction;
using Content.Shared.Construction.Prototypes;
Expand Down Expand Up @@ -89,7 +90,7 @@ private void HandleConstructionGhostExamined(EntityUid uid, ConstructionGhostCom
{
args.PushMarkup(Loc.GetString(
"construction-ghost-examine-message",
("name", component.Prototype.Name)));
("name", ConstructionMenuPresenter.GetLocalizationFromID(component.Prototype.ID))));

if (!_prototypeManager.TryIndex(component.Prototype.Graph, out ConstructionGraphPrototype? graph))
return;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Construction/UI/ConstructionMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="0.4">
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<LineEdit Name="SearchBar" PlaceHolder="Search" HorizontalExpand="True"/>
<LineEdit Name="SearchBar" PlaceHolder="{ Loc 'construction-menu-search'}" HorizontalExpand="True"/>
<OptionButton Name="Category" Access="Public" MinSize="130 0"/>
</BoxContainer>
<ItemList Name="Recipes" Access="Public" SelectMode="Single" VerticalExpand="True"/>
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Construction/UI/ConstructionMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public ConstructionMenu()
Recipes.OnItemDeselected += _ => RecipeSelected?.Invoke(this, null);

SearchBar.OnTextChanged += _ => PopulateRecipes?.Invoke(this, (SearchBar.Text, Categories[Category.SelectedId]));
/* SearchBar.PlaceHolder = Loc.GetString("construction-menu-title"); */
Category.OnItemSelected += obj =>
{
Category.SelectId(obj.Id);
Expand Down
16 changes: 12 additions & 4 deletions Content.Client/Construction/UI/ConstructionMenuPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private bool WindowOpen
else
_constructionView.OpenCentered();

if(_selected != null)
if (_selected != null)
PopulateInfo(_selected);
}
else
Expand Down Expand Up @@ -166,7 +166,9 @@ private void OnViewPopulateRecipes(object? sender, (string search, string catago

if (!string.IsNullOrEmpty(search))
{
if (!recipe.Name.ToLowerInvariant().Contains(search.Trim().ToLowerInvariant()))
// var defaultSearchAttempt = !recipe.Name.ToLowerInvariant().Contains(search.Trim().ToLowerInvariant());
var locSearchAttempt = !GetLocalizationFromID(recipe.ID).ToLowerInvariant().Contains(search.Trim().ToLowerInvariant());
if (locSearchAttempt)
continue;
}

Expand All @@ -189,6 +191,11 @@ private void OnViewPopulateRecipes(object? sender, (string search, string catago
// There is apparently no way to set which
}

public static string GetLocalizationFromID(string id, bool desc = false)
{
return Loc.GetString($"ent-{id.Replace("Fixture", "").Replace("Recipe", "")}{(desc ? ".desc" : "")}");
}

private void PopulateCategories()
{
var uniqueCategories = new HashSet<string>();
Expand Down Expand Up @@ -222,7 +229,8 @@ private void PopulateInfo(ConstructionPrototype prototype)
{
var spriteSys = _systemManager.GetEntitySystem<SpriteSystem>();
_constructionView.ClearRecipeInfo();
_constructionView.SetRecipeInfo(prototype.Name, prototype.Description, spriteSys.Frame0(prototype.Icon), prototype.Type != ConstructionType.Item);
_constructionView.SetRecipeInfo(
GetLocalizationFromID(prototype.ID), GetLocalizationFromID(prototype.ID, true), spriteSys.Frame0(prototype.Icon), prototype.Type != ConstructionType.Item);

var stepList = _constructionView.RecipeStepList;
GenerateStepList(prototype, stepList);
Expand Down Expand Up @@ -259,7 +267,7 @@ private static ItemList.Item GetItem(ConstructionPrototype recipe, ItemList item
return new(itemList)
{
Metadata = recipe,
Text = recipe.Name,
Text = GetLocalizationFromID(recipe.ID),
Icon = recipe.Icon.Frame0(),
TooltipEnabled = true,
TooltipText = recipe.Description
Expand Down
23 changes: 12 additions & 11 deletions Content.Server/Construction/ConstructionSystem.Guided.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Shared.Popups;
using Content.Shared.Verbs;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

namespace Content.Server.Construction
Expand All @@ -28,7 +29,7 @@ private void OnGuideRequested(RequestConstructionGuide msg, EntitySessionEventAr
if (!_prototypeManager.TryIndex(msg.ConstructionId, out ConstructionPrototype? prototype))
return;

if(GetGuide(prototype) is {} guide)
if (GetGuide(prototype) is { } guide)
RaiseNetworkEvent(new ResponseConstructionGuide(msg.ConstructionId, guide), args.SenderSession.Channel);
}

Expand Down Expand Up @@ -58,7 +59,7 @@ private void AddDeconstructVerb(EntityUid uid, ConstructionComponent component,
//TODO VERBS add more construction verbs? Until then, removing construction category
verb.Text = Loc.GetString("deconstructible-verb-begin-deconstruct");
verb.Icon = new SpriteSpecifier.Texture(
new ("/Textures/Interface/hammer_scaled.svg.192dpi.png"));
new("/Textures/Interface/hammer_scaled.svg.192dpi.png"));

verb.Act = () =>
{
Expand All @@ -81,7 +82,7 @@ private void HandleConstructionExamined(EntityUid uid, ConstructionComponent com
{
using (args.PushGroup(nameof(ConstructionComponent)))
{
if (GetTargetNode(uid, component) is {} target)
if (GetTargetNode(uid, component) is { } target)
{
if (target.Name == component.DeconstructionNode)
{
Expand All @@ -95,7 +96,7 @@ private void HandleConstructionExamined(EntityUid uid, ConstructionComponent com
}
}

if (component.EdgeIndex == null && GetTargetEdge(uid, component) is {} targetEdge)
if (component.EdgeIndex == null && GetTargetEdge(uid, component) is { } targetEdge)
{
var preventStepExamine = false;

Expand All @@ -109,7 +110,7 @@ private void HandleConstructionExamined(EntityUid uid, ConstructionComponent com
return;
}

if (GetCurrentEdge(uid, component) is {} edge)
if (GetCurrentEdge(uid, component) is { } edge)
{
var preventStepExamine = false;

Expand Down Expand Up @@ -149,12 +150,12 @@ private void HandleConstructionExamined(EntityUid uid, ConstructionComponent com
return null;

// If either the start node or the target node are missing, do nothing.
if (GetNodeFromGraph(graph, construction.StartNode) is not {} startNode
|| GetNodeFromGraph(graph, construction.TargetNode) is not {} targetNode)
if (GetNodeFromGraph(graph, construction.StartNode) is not { } startNode
|| GetNodeFromGraph(graph, construction.TargetNode) is not { } targetNode)
return null;

// If there's no path from start to target, do nothing.
if (graph.Path(construction.StartNode, construction.TargetNode) is not {} path
if (graph.Path(construction.StartNode, construction.TargetNode) is not { } path
|| path.Length == 0)
return null;

Expand All @@ -176,7 +177,7 @@ private void HandleConstructionExamined(EntityUid uid, ConstructionComponent com
// Iterate until the penultimate node.
var node = startNode;
var index = 0;
while(node != targetNode)
while (node != targetNode)
{
// Can't find path, therefore can't generate guide...
if (!node.TryGetEdge(path[index].Name, out var edge))
Expand All @@ -197,7 +198,7 @@ private void HandleConstructionExamined(EntityUid uid, ConstructionComponent com
// Now actually list the construction conditions.
foreach (var condition in construction.Conditions)
{
if (condition.GenerateGuideEntry() is not {} conditionEntry)
if (condition.GenerateGuideEntry() is not { } conditionEntry)
continue;

conditionEntry.Padding += 4;
Expand All @@ -208,7 +209,7 @@ private void HandleConstructionExamined(EntityUid uid, ConstructionComponent com
node = path[index++];

// Add a bit of padding if there will be more steps after this.
if(node != targetNode)
if (node != targetNode)
entries.Add(new ConstructionGuideEntry());

continue;
Expand Down
Loading

0 comments on commit 5fae9e0

Please sign in to comment.