Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lathe categories #1242

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions Content.Client/Lathe/UI/LatheMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,23 @@ public void PopulateRecipes()
if (!_prototypeManager.TryIndex(recipe, out var proto))
continue;

if (CurrentCategory != null && proto.Category != CurrentCategory)
continue;
// Category filtering
if (CurrentCategory != null)
{
if (proto.Categories == null)
continue;

bool validRecipe = false;
foreach (var category in proto.Categories)
if (category == CurrentCategory)
{
validRecipe = true;
continue;
}

if (!validRecipe)
continue;
}

if (SearchBar.Text.Trim().Length != 0)
{
Expand Down Expand Up @@ -184,13 +199,16 @@ public void UpdateCategories()
{
var recipe = _prototypeManager.Index(recipeId);

if (recipe.Category == null)
if (recipe.Categories == null)
continue;

if (currentCategories.Contains(recipe.Category.Value))
continue;
foreach (var category in recipe.Categories)
{
if (currentCategories.Contains(category))
continue;

currentCategories.Add(recipe.Category.Value);
currentCategories.Add(category);
}
}

if (Categories != null && (Categories.Count == currentCategories.Count || !Categories.All(currentCategories.Contains)))
Expand Down
6 changes: 3 additions & 3 deletions Content.Shared/Research/Prototypes/LatheRecipePrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public sealed partial class LatheRecipePrototype : IPrototype, IInheritingProtot
public bool ApplyMaterialDiscount = true;

/// <summary>
/// A category used for visually sorting lathe recipes in the UI.
/// List of categories used for visually sorting lathe recipes in the UI.
/// </summary>
[DataField]
public ProtoId<LatheCategoryPrototype>? Category;
[DataField("category")]
public ProtoId<LatheCategoryPrototype>[]? Categories;
}
}
44 changes: 40 additions & 4 deletions Resources/Locale/en-US/lathe/lathe-categories.ftl
Original file line number Diff line number Diff line change
@@ -1,12 +1,48 @@
lathe-category-ammo = Ammo
# Generic
lathe-category-clothing = Clothing
lathe-category-circuitry = Circuitry
lathe-category-lights = Lights
lathe-category-mechs = Mechs
lathe-category-containers = Containers
lathe-category-machines = Machines
lathe-category-parts = Parts
lathe-category-robotics = Robotics
lathe-category-tiles = Tiles
lathe-category-tools = Tools
lathe-category-weapons = Weapons

# Science
lathe-category-experimental = Experimental

lathe-category-computers = Computers
lathe-category-mechs = Mechs
lathe-category-modules = Modules
lathe-category-robotics = Robotics

# Autolathe
lathe-category-kitchenware = Kitchenware
lathe-category-lights = Lights

# Biogen
lathe-category-food = Food
lathe-category-chemicals = Chemicals
lathe-category-materials = Materials

# Cutter
lathe-category-concrete = Concrete
lathe-category-dark = Dark
lathe-category-steel = Steel
lathe-category-white = White
lathe-category-wood = Wood

# Med
lathe-category-medicinal = Medicinal

# Sec
lathe-category-ammo = Ammo
lathe-category-boxes = Boxes
lathe-category-magazines = Magazines

# Uniform
lathe-category-coat = Coat
lathe-category-command = Command
lathe-category-hat = Hat
lathe-category-jumpsuit = Jumpsuit
lathe-category-neck = Neck
2 changes: 2 additions & 0 deletions Resources/Prototypes/Recipes/Lathes/cargo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- type: latheRecipe
id: ConveyorBeltAssembly
result: ConveyorBeltAssembly
category: Circuitry
completetime: 4
materials:
Steel: 250
Expand All @@ -9,6 +10,7 @@
- type: latheRecipe
id: AppraisalTool
result: AppraisalTool
category: Tools
completetime: 4
materials:
Steel: 500
110 changes: 101 additions & 9 deletions Resources/Prototypes/Recipes/Lathes/categories.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# Generic

- type: latheCategory
id: Ammo
name: lathe-category-ammo
id: Clothing
name: lathe-category-clothing

- type: latheCategory
id: Circuitry
name: lathe-category-circuitry

- type: latheCategory
id: Lights
name: lathe-category-lights
id: Containers
name: lathe-category-containers

- type: latheCategory
id: Mech
name: lathe-category-mechs
id: Machines
name: lathe-category-machines

- type: latheCategory
id: Parts
name: lathe-category-parts

- type: latheCategory
id: Robotics
name: lathe-category-robotics
id: Tiles
name: lathe-category-tiles

- type: latheCategory
id: Tools
Expand All @@ -30,8 +32,38 @@
id: Weapons
name: lathe-category-weapons

# Biogen
# Research
- type: latheCategory
id: Experimental
name: lathe-category-experimental

# Science
- type: latheCategory
id: Computers
name: lathe-category-computers

- type: latheCategory
id: Mechs
name: lathe-category-mechs

- type: latheCategory
id: Modules
name: lathe-category-modules

- type: latheCategory
id: Robotics
name: lathe-category-robotics

# Autolathe
- type: latheCategory
id: Kitchenware
name: lathe-category-kitchenware

- type: latheCategory
id: Lights
name: lathe-category-lights

# Biogen
- type: latheCategory
id: Food
name: lathe-category-food
Expand All @@ -43,3 +75,63 @@
- type: latheCategory
id: Materials
name: lathe-category-materials

# Cutter machine
- type: latheCategory
id: Concrete
name: lathe-category-concrete

- type: latheCategory
id: Dark
name: lathe-category-dark

- type: latheCategory
id: Steel
name: lathe-category-steel

- type: latheCategory
id: White
name: lathe-category-white

- type: latheCategory
id: Wood
name: lathe-category-wood

# Medical TechFab
- type: latheCategory
id: Medicinal
name: lathe-category-medicinal

# Security TechFab
- type: latheCategory
id: Ammo
name: lathe-category-ammo

- type: latheCategory
id: Boxes
name: lathe-category-boxes

- type: latheCategory
id: Magazines
name: lathe-category-magazines

# Uniform printer
- type: latheCategory
id: Coat
name: lathe-category-coat

- type: latheCategory
id: Command
name: lathe-category-command

- type: latheCategory
id: Hat
name: lathe-category-hat

- type: latheCategory
id: Jumpsuit
name: lathe-category-jumpsuit

- type: latheCategory
id: Neck
name: lathe-category-neck
Loading