Craft menu translate (#88)
This commit is contained in:
@@ -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="Поиск" HorizontalExpand="True"/>
|
||||
<OptionButton Name="Category" Access="Public" MinSize="130 0"/>
|
||||
</BoxContainer>
|
||||
<ItemList Name="Recipes" Access="Public" SelectMode="Single" VerticalExpand="True"/>
|
||||
|
||||
@@ -62,8 +62,12 @@ namespace Content.Client.Construction.UI
|
||||
else
|
||||
_constructionView.OpenCentered();
|
||||
|
||||
if(_selected != null)
|
||||
PopulateInfo(_selected);
|
||||
if (_selected != null)
|
||||
{
|
||||
var name = Loc.GetString($"ent-{_selected.ID}");
|
||||
var desc = Loc.GetString($"ent-{_selected.ID}.desc");
|
||||
PopulateInfo(_selected, name, desc);
|
||||
}
|
||||
}
|
||||
else
|
||||
_constructionView.Close();
|
||||
@@ -139,7 +143,10 @@ namespace Content.Client.Construction.UI
|
||||
|
||||
_selected = (ConstructionPrototype) item.Metadata!;
|
||||
if (_placementManager.IsActive && !_placementManager.Eraser) UpdateGhostPlacement();
|
||||
PopulateInfo(_selected);
|
||||
|
||||
var name = Loc.GetString($"ent-{_selected.ID}");
|
||||
var desc = Loc.GetString($"ent-{_selected.ID}.desc");
|
||||
PopulateInfo(_selected, name, desc);
|
||||
}
|
||||
|
||||
private void OnViewPopulateRecipes(object? sender, (string search, string catagory) args)
|
||||
@@ -162,7 +169,7 @@ namespace Content.Client.Construction.UI
|
||||
|
||||
if (!string.IsNullOrEmpty(search))
|
||||
{
|
||||
if (!recipe.Name.ToLowerInvariant().Contains(search.Trim().ToLowerInvariant()))
|
||||
if (!Loc.GetString($"ent-{recipe.ID}").ToLowerInvariant().Contains(search.Trim().ToLowerInvariant()))
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -175,7 +182,7 @@ namespace Content.Client.Construction.UI
|
||||
recipes.Add(recipe);
|
||||
}
|
||||
|
||||
recipes.Sort((a, b) => string.Compare(a.Name, b.Name, StringComparison.InvariantCulture));
|
||||
recipes.Sort((a, b) => string.Compare(Loc.GetString($"ent-{a.ID}"), Loc.GetString($"ent-{b.ID}"), StringComparison.InvariantCulture));
|
||||
|
||||
foreach (var recipe in recipes)
|
||||
{
|
||||
@@ -214,11 +221,26 @@ namespace Content.Client.Construction.UI
|
||||
_constructionView.Categories = array;
|
||||
}
|
||||
|
||||
private void PopulateInfo(ConstructionPrototype prototype)
|
||||
private void PopulateInfo(ConstructionPrototype prototype, string name, string desc)
|
||||
{
|
||||
var spriteSys = _systemManager.GetEntitySystem<SpriteSystem>();
|
||||
_constructionView.ClearRecipeInfo();
|
||||
_constructionView.SetRecipeInfo(prototype.Name, prototype.Description, spriteSys.Frame0(prototype.Icon), prototype.Type != ConstructionType.Item);
|
||||
|
||||
string recipeName;
|
||||
string recipeDesc;
|
||||
|
||||
if (name[..3] != "ent")
|
||||
{
|
||||
recipeName = name;
|
||||
recipeDesc = desc;
|
||||
}
|
||||
else
|
||||
{
|
||||
recipeName = prototype.Name;
|
||||
recipeDesc = prototype.Description;
|
||||
}
|
||||
|
||||
_constructionView.SetRecipeInfo(recipeName, recipeDesc, spriteSys.Frame0(prototype.Icon), prototype.Type != ConstructionType.Item);
|
||||
|
||||
var stepList = _constructionView.RecipeStepList;
|
||||
GenerateStepList(prototype, stepList);
|
||||
@@ -252,13 +274,24 @@ namespace Content.Client.Construction.UI
|
||||
|
||||
private static ItemList.Item GetItem(ConstructionPrototype recipe, ItemList itemList)
|
||||
{
|
||||
string recipeName = Loc.GetString($"ent-{recipe.ID}");
|
||||
string recipeDesc;
|
||||
|
||||
if (recipeName[..3] != "ent")
|
||||
recipeDesc = Loc.GetString($"ent-{recipe.ID}.desc");
|
||||
else
|
||||
{
|
||||
recipeName = recipe.Name;
|
||||
recipeDesc = recipe.Description;
|
||||
}
|
||||
|
||||
return new(itemList)
|
||||
{
|
||||
Metadata = recipe,
|
||||
Text = recipe.Name,
|
||||
Text = recipeName,
|
||||
Icon = recipe.Icon.Frame0(),
|
||||
TooltipEnabled = true,
|
||||
TooltipText = recipe.Description
|
||||
TooltipText = recipeDesc
|
||||
};
|
||||
}
|
||||
|
||||
@@ -433,7 +466,9 @@ namespace Content.Client.Construction.UI
|
||||
if (_selected == null)
|
||||
return;
|
||||
|
||||
PopulateInfo(_selected);
|
||||
var name = Loc.GetString($"ent-{_selected.ID}");
|
||||
var desc = Loc.GetString($"ent-{_selected.ID}.desc");
|
||||
PopulateInfo(_selected, name, desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user