finish setuping UI

This commit is contained in:
Ed
2025-05-22 16:39:25 +03:00
parent 637e38b4b3
commit b0dad26252
4 changed files with 87 additions and 4 deletions

View File

@@ -82,13 +82,37 @@ public sealed partial class CP14WorkplaceWindow : DefaultWindow
OptionCategories.Clear();
OptionCategories.AddItem(Loc.GetString("cp14-recipe-category-all"), AllCategoryId);
//Categories update
var categories = new List<LocId>();
var count = 0;
foreach (var recipe in state.Recipes)
{
if (!_prototype.TryIndex(recipe.Recipe, out var indexedRecipe))
continue;
if(!indexedRecipe.Components.TryGetComponent(CP14WorkplaceRecipeComponent.CompName, out var compData) || compData is not CP14WorkplaceRecipeComponent recipeComp)
continue;
if (recipeComp.Category is null)
continue;
if (categories.Contains(recipeComp.Category.Value))
continue;
categories.Add(recipeComp.Category.Value);
}
categories.Sort((a, b) => string.Compare(Loc.GetString(a), Loc.GetString(b), StringComparison.Ordinal));
foreach (var category in categories)
{
OptionCategories.AddItem(Loc.GetString(category), count);
_categories.Add(count, category);
count++;
}
UpdateRecipesVisibility();
}
private void OnSearchChanged(LineEdit.LineEditEventArgs _)

View File

@@ -1,5 +1,6 @@
using Content.Shared._CP14.Workplace;
using Content.Shared.UserInterface;
using Robust.Server.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Server._CP14.Workplace;
@@ -7,6 +8,7 @@ namespace Content.Server._CP14.Workplace;
public sealed partial class CP14WorkplaceSystem : CP14SharedWorkbenchSystem
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly UserInterfaceSystem _userInterface = default!;
public override void Initialize()
{
@@ -39,10 +41,15 @@ public sealed partial class CP14WorkplaceSystem : CP14SharedWorkbenchSystem
UpdateUIState(ent, args.User);
}
private void UpdateUIState(Entity<CP14WorkplaceComponent> entity, EntityUid user)
{
var recipes = new List<CP14WorkplaceRecipeEntry>();
foreach (var recipe in entity.Comp.CachedRecipes)
{
var entry = new CP14WorkplaceRecipeEntry(recipe, true);
recipes.Add(entry);
}
_userInterface.SetUiState(entity.Owner, CP14WorkplaceUiKey.Key, new CP14WorkplaceState(recipes));
}
private void CacheWorkplaceRecipes(Entity<CP14WorkplaceComponent> entity)

View File

@@ -3,7 +3,7 @@
- BaseStructure
id: CP14BaseWorkplace
categories: [ ForkFiltered ]
abstract: true
name: workplace
components:
- type: Sprite
snapCardinals: true
@@ -16,6 +16,9 @@
key: enum.CP14WorkplaceUiKey.Key
requiresComplex: true
singleUser: true
- type: CP14Workplace
tags:
- CP14RecipeMeltingFurnace
- type: Climbable
- type: Clickable
- type: InteractionOutline

View File

@@ -3,4 +3,53 @@
abstract: true
components:
- type: CP14WorkplaceRecipe
tag: CP14RecipeMeltingFurnace
tag: CP14RecipeMeltingFurnace
category: cp14-recipe-category-tool
- type: entity
id: CP14RecipeBucket
parent: CP14BaseWorkplaceRecipe
name: Крафт верстака
description: Пара досок и вы прекрасны
components:
- type: CP14WorkplaceRecipe
category: cp14-recipe-category-weapon
- type: Sprite
sprite: _CP14/Structures/Furniture/workbench.rsi
state: filler
- type: entity
id: CP14RecipeBucket2
parent: CP14BaseWorkplaceRecipe
name: Крафт верстака 2
description: Пара досок и вы прекрасны
components:
- type: CP14WorkplaceRecipe
category: cp14-recipe-category-weapon
- type: Sprite
sprite: _CP14/Structures/Furniture/workbench.rsi
state: workbench
- type: entity
id: CP14RecipeBucket3
parent: CP14BaseWorkplaceRecipe
name: Крафт верстака 3
description: Пара досок и вы прекрасны
components:
- type: CP14WorkplaceRecipe
category: cp14-recipe-category-armor
- type: Sprite
sprite: _CP14/Structures/Furniture/workbench.rsi
state: cooking_table
- type: entity
id: CP14RecipeBucket4
parent: CP14BaseWorkplaceRecipe
name: Крафт верстака 4
description: Пара досок и вы прекрасны
components:
- type: CP14WorkplaceRecipe
category: cp14-recipe-category-tile
- type: Sprite
sprite: Effects/electricity.rsi
state: electrified