Workbench update (#760)
* fix workbench icons * workbench search * fix 1 * UI finalize * fix material localization * restore shard sprite * Update sewing_table.yml
This commit is contained in:
@@ -12,6 +12,9 @@ public sealed class CP14WorkbenchBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
private CP14WorkbenchWindow? _window;
|
||||
|
||||
[ViewVariables]
|
||||
private string _search = string.Empty;
|
||||
|
||||
public CP14WorkbenchBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
}
|
||||
@@ -23,6 +26,12 @@ public sealed class CP14WorkbenchBoundUserInterface : BoundUserInterface
|
||||
_window = this.CreateWindow<CP14WorkbenchWindow>();
|
||||
|
||||
_window.OnCraft += entry => SendMessage(new CP14WorkbenchUiCraftMessage(entry.ProtoId));
|
||||
|
||||
_window.OnTextUpdated += search =>
|
||||
{
|
||||
_search = search.Trim().ToLowerInvariant();
|
||||
_window.UpdateFilter(_search);
|
||||
};
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
@@ -32,7 +41,7 @@ public sealed class CP14WorkbenchBoundUserInterface : BoundUserInterface
|
||||
switch (state)
|
||||
{
|
||||
case CP14WorkbenchUiRecipesState recipesState:
|
||||
_window?.UpdateRecipes(recipesState);
|
||||
_window?.UpdateRecipes(recipesState, _search);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
<Control xmlns="https://spacestation14.io">
|
||||
<GridContainer Columns="2">
|
||||
<TextureRect Name="View"
|
||||
Margin="0,0,4,0"
|
||||
MinSize="48 48"
|
||||
HorizontalAlignment="Left"
|
||||
Stretch="KeepAspectCentered"/>
|
||||
<Label Name="Name"/>
|
||||
<EntityPrototypeView
|
||||
Name="EntityView"
|
||||
Margin="0,0,4,0"
|
||||
MinSize="48 48"
|
||||
MaxSize="48 48"
|
||||
Scale="2,2"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalExpand="True" />
|
||||
<TextureRect
|
||||
Name="View"
|
||||
Margin="0,0,4,0"
|
||||
MinSize="48 48"
|
||||
MaxSize="48 48"
|
||||
HorizontalAlignment="Left"
|
||||
Stretch="KeepAspectCentered" />
|
||||
<Label Name="Name" />
|
||||
</GridContainer>
|
||||
</Control>
|
||||
|
||||
@@ -31,7 +31,9 @@ public sealed partial class CP14WorkbenchRecipeControl : Control
|
||||
{
|
||||
var entityName = prototype.Name;
|
||||
Name.Text = count <= 1 ? entityName : $"{entityName} x{count}";
|
||||
View.Texture = _sprite.GetPrototypeIcon(prototype).Default;
|
||||
|
||||
View.Visible = false;
|
||||
EntityView.SetPrototype(prototype);
|
||||
}
|
||||
|
||||
public CP14WorkbenchRecipeControl(StackPrototype prototype, int count) : this()
|
||||
@@ -43,6 +45,7 @@ public sealed partial class CP14WorkbenchRecipeControl : Control
|
||||
if (icon is null)
|
||||
return;
|
||||
|
||||
EntityView.Visible = false;
|
||||
View.Texture = _sprite.Frame0(icon);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<Control xmlns="https://spacestation14.io">
|
||||
<Button Name="Button">
|
||||
<GridContainer Columns="2">
|
||||
<TextureRect Name="View"
|
||||
Margin="0,0,4,0"
|
||||
MinSize="48 48"
|
||||
HorizontalAlignment="Left"
|
||||
Stretch="KeepAspectCentered"/>
|
||||
<EntityPrototypeView Name="View"
|
||||
Margin="0,0,4,0"
|
||||
MinSize="48 48"
|
||||
MaxSize="48 48"
|
||||
Scale="2,2"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalExpand="True"/>
|
||||
<Label Name="Name"/>
|
||||
</GridContainer>
|
||||
</Button>
|
||||
|
||||
@@ -59,6 +59,6 @@ public sealed partial class CP14WorkbenchRequirementControl : Control
|
||||
|
||||
private void UpdateView()
|
||||
{
|
||||
View.Texture = _sprite.GetPrototypeIcon(_recipePrototype.Result).Default;
|
||||
View.SetPrototype(_recipePrototype.Result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,59 +2,68 @@
|
||||
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
Title="{Loc 'cp14-workbench-ui-title'}"
|
||||
MinSize="700 600">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
SetSize="700 500"
|
||||
MinSize="700 300">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<!-- Main -->
|
||||
<BoxContainer HorizontalExpand="True" VerticalExpand="True" Orientation="Horizontal">
|
||||
<GridContainer HorizontalExpand="True" VerticalExpand="True" Columns="2">
|
||||
<!-- Product list (left side UI) -->
|
||||
<BoxContainer SizeFlagsStretchRatio="0.5" HorizontalExpand="True" Orientation="Vertical" Margin="0 0 10 0">
|
||||
<!-- Search Bar -->
|
||||
<LineEdit Name="SearchBar" Margin="4" PlaceHolder="Search" HorizontalExpand="True" />
|
||||
<!-- Crafts container -->
|
||||
<ScrollContainer HorizontalExpand="True" VerticalExpand="True" MinSize="0 200">
|
||||
<BoxContainer Name="CraftsContainer" Orientation="Vertical" HorizontalExpand="True"/>
|
||||
<BoxContainer Name="CraftsContainer" Orientation="Vertical" HorizontalExpand="True" />
|
||||
</ScrollContainer>
|
||||
</BoxContainer>
|
||||
|
||||
<!-- Craft view -->
|
||||
<BoxContainer HorizontalExpand="True" VerticalExpand="True" Orientation="Vertical">
|
||||
<PanelContainer HorizontalExpand="True" VerticalExpand="True">
|
||||
<!-- Background -->
|
||||
<PanelContainer.PanelOverride>
|
||||
<graphics:StyleBoxFlat BackgroundColor="#41332f"/>
|
||||
</PanelContainer.PanelOverride>
|
||||
<!-- Craft view (right side UI) -->
|
||||
<BoxContainer SizeFlagsStretchRatio="0.5" Orientation="Vertical" HorizontalExpand="True"
|
||||
VerticalExpand="True">
|
||||
<PanelContainer HorizontalExpand="True" VerticalExpand="True">
|
||||
<!-- Background -->
|
||||
<PanelContainer.PanelOverride>
|
||||
<graphics:StyleBoxFlat BackgroundColor="#41332f" />
|
||||
</PanelContainer.PanelOverride>
|
||||
|
||||
<!-- Content -->
|
||||
<BoxContainer HorizontalExpand="True" VerticalExpand="True" Orientation="Vertical">
|
||||
<!-- Item info -->
|
||||
<GridContainer HorizontalExpand="True" Columns="2">
|
||||
<!-- Left panel - icon -->
|
||||
<TextureRect Name="ItemView"
|
||||
<!-- Content -->
|
||||
<BoxContainer HorizontalExpand="True" VerticalExpand="True" Orientation="Vertical">
|
||||
<!-- Item info -->
|
||||
<!-- icon -->
|
||||
<EntityPrototypeView Name="ItemView"
|
||||
Scale="2,2"
|
||||
Margin="0,0,4,0"
|
||||
MinSize="64 64"
|
||||
HorizontalAlignment="Left"
|
||||
Stretch="KeepAspectCentered"/>
|
||||
MaxSize="64 64"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
<!-- Right panel - name & description -->
|
||||
<BoxContainer HorizontalExpand="True" VerticalExpand="True" Orientation="Vertical">
|
||||
<Label Name="ItemName" Text="Name"/>
|
||||
<Label Name="ItemDescription" Text="Description" ClipText="True"/>
|
||||
</BoxContainer>
|
||||
</GridContainer>
|
||||
|
||||
<controls:HLine Color="#404040" Thickness="2" Margin="0 5"/>
|
||||
|
||||
<!-- Required title -->
|
||||
<Label Text="{Loc 'cp14-workbench-recipe-list'}"/>
|
||||
|
||||
<!-- Craft requirements content -->
|
||||
<!-- Added by code -->
|
||||
<BoxContainer Name="ItemRequirements" Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True"/>
|
||||
|
||||
<controls:HLine Color="#404040" Thickness="2" Margin="0 5"/>
|
||||
|
||||
<!-- Craft button -->
|
||||
<Button Name="CraftButton" Text="{Loc 'cp14-workbench-craft'}"/>
|
||||
<!-- name & description -->
|
||||
<BoxContainer Margin="5 0 0 0" HorizontalExpand="True" VerticalExpand="True"
|
||||
Orientation="Vertical">
|
||||
<RichTextLabel Name="ItemName" Margin="5" />
|
||||
<RichTextLabel Name="ItemDescription" Margin="5" />
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
</BoxContainer>
|
||||
</GridContainer>
|
||||
|
||||
<controls:HLine Color="#404040" Thickness="2" Margin="0 5" />
|
||||
|
||||
<!-- Required title -->
|
||||
<Label Margin="5 0 0 0" Text="{Loc 'cp14-workbench-recipe-list'}" />
|
||||
|
||||
<!-- Craft requirements content -->
|
||||
<!-- Added by code -->
|
||||
<BoxContainer
|
||||
Margin="5 0 0 0"
|
||||
Name="ItemRequirements"
|
||||
Orientation="Vertical" VerticalExpand="True"
|
||||
HorizontalExpand="True" />
|
||||
|
||||
<controls:HLine Color="#404040" Thickness="5" Margin="0 5" />
|
||||
|
||||
<!-- Craft button -->
|
||||
<Button Name="CraftButton" Text="{Loc 'cp14-workbench-craft'}" />
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</DefaultWindow>
|
||||
|
||||
@@ -19,19 +19,22 @@ public sealed partial class CP14WorkbenchWindow : DefaultWindow
|
||||
[Dependency] private readonly IEntityManager _entity = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
|
||||
private CP14WorkbenchUiRecipesState? _cachedState;
|
||||
|
||||
public event Action<CP14WorkbenchUiRecipesEntry>? OnCraft;
|
||||
public event Action<string>? OnTextUpdated;
|
||||
|
||||
private readonly SpriteSystem _sprite;
|
||||
|
||||
private CP14WorkbenchUiRecipesEntry? _selectedEntry ;
|
||||
private CP14WorkbenchUiRecipesEntry? _selectedEntry;
|
||||
|
||||
public CP14WorkbenchWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
_sprite = _entity.System<SpriteSystem>();
|
||||
|
||||
SearchBar.OnTextChanged += _ =>
|
||||
{
|
||||
OnTextUpdated?.Invoke(SearchBar.Text);
|
||||
};
|
||||
CraftButton.OnPressed += _ =>
|
||||
{
|
||||
if (_selectedEntry is null)
|
||||
@@ -41,13 +44,34 @@ public sealed partial class CP14WorkbenchWindow : DefaultWindow
|
||||
};
|
||||
}
|
||||
|
||||
public void UpdateRecipes(CP14WorkbenchUiRecipesState recipesState)
|
||||
public void UpdateFilter(string? search)
|
||||
{
|
||||
if (_cachedState is null)
|
||||
return;
|
||||
|
||||
UpdateRecipes(_cachedState, search);
|
||||
}
|
||||
|
||||
public void UpdateRecipes(CP14WorkbenchUiRecipesState recipesState, string? search = null)
|
||||
{
|
||||
_cachedState = recipesState;
|
||||
CraftsContainer.RemoveAllChildren();
|
||||
|
||||
List<CP14WorkbenchUiRecipesEntry> uncraftableList = new();
|
||||
foreach (var entry in recipesState.Recipes)
|
||||
{
|
||||
if (search is not null && search != "")
|
||||
{
|
||||
if (!_prototype.TryIndex(entry.ProtoId, out var indexedEntry))
|
||||
continue;
|
||||
|
||||
if (!_prototype.TryIndex(indexedEntry.Result, out var indexedResult))
|
||||
continue;
|
||||
|
||||
if (!indexedResult.Name.Contains(search))
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.Craftable)
|
||||
{
|
||||
var control = new CP14WorkbenchRequirementControl(entry);
|
||||
@@ -89,7 +113,7 @@ public sealed partial class CP14WorkbenchWindow : DefaultWindow
|
||||
|
||||
var result = _prototype.Index(recipe.Result);
|
||||
|
||||
ItemView.Texture = _sprite.GetPrototypeIcon(recipe.Result).Default;
|
||||
ItemView.SetPrototype(recipe.Result);
|
||||
ItemName.Text = result.Name;
|
||||
ItemDescription.Text = result.Description;
|
||||
|
||||
|
||||
@@ -27,8 +27,10 @@ public sealed partial class CP14WorkbenchSystem
|
||||
var recipes = new List<CP14WorkbenchUiRecipesEntry>();
|
||||
foreach (var recipeId in entity.Comp.Recipes)
|
||||
{
|
||||
var recipe = _proto.Index(recipeId);
|
||||
var entry = new CP14WorkbenchUiRecipesEntry(recipeId, CanCraftRecipe(recipe, placedEntities));
|
||||
if (!_proto.TryIndex(recipeId, out var indexedRecipe))
|
||||
continue;
|
||||
|
||||
var entry = new CP14WorkbenchUiRecipesEntry(recipeId, CanCraftRecipe(indexedRecipe, placedEntities));
|
||||
|
||||
recipes.Add(entry);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,10 @@ public sealed partial class CP14WorkbenchSystem : SharedCP14WorkbenchSystem
|
||||
return;
|
||||
}
|
||||
|
||||
var resultEntity = Spawn(_proto.Index(args.Recipe).Result);
|
||||
if (!_proto.TryIndex(args.Recipe, out var indexedRecipe))
|
||||
return;
|
||||
|
||||
var resultEntity = Spawn(indexedRecipe.Result);
|
||||
_stack.TryMergeToContacts(resultEntity);
|
||||
|
||||
_solutionContainer.TryGetSolution(resultEntity, recipe.Solution, out var resultSoln, out var resultSolution);
|
||||
|
||||
@@ -30,7 +30,6 @@ public sealed class CP14WorkbenchUiCraftMessage : BoundUserInterfaceMessage
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CP14WorkbenchUiRecipesState : BoundUserInterfaceState
|
||||
{
|
||||
// It's list (not hashset) BECAUSE CP14WorkbenchComponent contains list of recipes (WHY???)
|
||||
public readonly List<CP14WorkbenchUiRecipesEntry> Recipes;
|
||||
|
||||
public CP14WorkbenchUiRecipesState(List<CP14WorkbenchUiRecipesEntry> recipes)
|
||||
|
||||
@@ -10,7 +10,7 @@ using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared._CP14.Workbench;
|
||||
|
||||
public class SharedCP14WorkbenchSystem : EntitySystem
|
||||
public abstract class SharedCP14WorkbenchSystem : EntitySystem
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
cp14-material-wooden-planks = wooden planks
|
||||
cp14-material-dirt-block = dirt
|
||||
cp14-material-stone-block = stone
|
||||
cp14-material-nail = nails
|
||||
cp14-material-cloth = cloth
|
||||
cp14-material-copper = copper
|
||||
cp14-material-iron = iron
|
||||
cp14-material-gold = gold
|
||||
cp14-material-mithril = mithril
|
||||
cp14-material-lucens-planks = lucens planks
|
||||
cp14-material-cloth = cloth
|
||||
cp14-material-flora = flora material
|
||||
cp14-material-ash = ash
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
cp14-material-wooden-planks = деревянные доски
|
||||
cp14-material-dirt-block = земля
|
||||
cp14-material-stone-block = камень
|
||||
cp14-material-nail = гвозди
|
||||
cp14-material-cloth = ткань
|
||||
cp14-material-copper = медь
|
||||
cp14-material-iron = железо
|
||||
cp14-material-gold = золото
|
||||
cp14-material-mithril = мифрил
|
||||
cp14-material-lucens-planks = люценсовые доски
|
||||
cp14-material-cloth = ткань
|
||||
cp14-material-flora = растительный материал
|
||||
cp14-material-ash = пепел
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
Cold: 4
|
||||
Piercing: 4
|
||||
- type: Sprite
|
||||
sprite: _CP14/Objects/Weapons/Melee/Dagger/ice_dagger.rsi
|
||||
sprite: _CP14/Effects/Magic/ice_shard.rsi
|
||||
layers:
|
||||
- state: shard
|
||||
shader: unshaded
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
unit: materials-unit-plank
|
||||
icon: { sprite: _CP14/Objects/Materials/wood.rsi, state: planks_2 }
|
||||
color: "#874d3a"
|
||||
price: 0 #?
|
||||
price: 0
|
||||
|
||||
- type: material
|
||||
id: CP14Dirt
|
||||
@@ -14,7 +14,7 @@
|
||||
unit: materials-unit-chunk
|
||||
icon: { sprite: _CP14/Objects/Materials/dirt_block.rsi, state: dirt_2 }
|
||||
color: "#5e3f31"
|
||||
price: 0 #?
|
||||
price: 0
|
||||
|
||||
- type: material
|
||||
id: CP14Stone
|
||||
@@ -23,7 +23,7 @@
|
||||
unit: materials-unit-chunk
|
||||
icon: { sprite: _CP14/Objects/Materials/stone_block.rsi, state: stone_2 }
|
||||
color: "#555963"
|
||||
price: 0 #?
|
||||
price: 0
|
||||
|
||||
- type: material
|
||||
id: CP14Nail
|
||||
@@ -32,7 +32,7 @@
|
||||
unit: materials-unit-piece
|
||||
icon: { sprite: _CP14/Objects/Materials/nails.rsi, state: nail_2 }
|
||||
color: "#555963"
|
||||
price: 0 #?
|
||||
price: 0
|
||||
|
||||
- type: material
|
||||
id: CP14Cloth
|
||||
@@ -41,7 +41,7 @@
|
||||
unit: materials-unit-roll
|
||||
icon: { sprite: _CP14/Objects/Materials/cloth.rsi, state: cloth_3 }
|
||||
color: "#d8e3e2"
|
||||
price: 0 #?
|
||||
price: 0
|
||||
|
||||
- type: material
|
||||
id: CP14Copper
|
||||
@@ -50,7 +50,7 @@
|
||||
unit: materials-unit-bar
|
||||
icon: { sprite: _CP14/Objects/Materials/copper_bar.rsi, state: bar_2 }
|
||||
color: "#9a5e22"
|
||||
price: 0 #?
|
||||
price: 0
|
||||
|
||||
- type: material
|
||||
id: CP14Iron
|
||||
@@ -59,7 +59,7 @@
|
||||
unit: materials-unit-bar
|
||||
icon: { sprite: _CP14/Objects/Materials/iron_bar.rsi, state: bar_2 }
|
||||
color: "#9093a1"
|
||||
price: 0 #?
|
||||
price: 0
|
||||
|
||||
- type: material
|
||||
id: CP14Gold
|
||||
@@ -68,7 +68,7 @@
|
||||
unit: materials-unit-bar
|
||||
icon: { sprite: _CP14/Objects/Materials/gold_bar.rsi, state: bar_2 }
|
||||
color: "#FFD700"
|
||||
price: 0 #?
|
||||
price: 0
|
||||
|
||||
- type: material
|
||||
id: CP14Mithril
|
||||
@@ -77,7 +77,7 @@
|
||||
unit: materials-unit-bar
|
||||
icon: { sprite: _CP14/Objects/Materials/mithril_bar.rsi, state: bar_2 }
|
||||
color: "#006c83"
|
||||
price: 0 #?
|
||||
price: 0
|
||||
|
||||
- type: material
|
||||
id: CP14LucensWoodenPlanks
|
||||
@@ -86,7 +86,7 @@
|
||||
unit: materials-unit-bar
|
||||
icon: { sprite: _CP14/Objects/Materials/lucens_wood.rsi, state: planks_2 }
|
||||
color: "#1a1e22"
|
||||
price: 0 #?
|
||||
price: 0
|
||||
|
||||
- type: material
|
||||
id: CP14FloraMaterial
|
||||
@@ -95,7 +95,7 @@
|
||||
unit: materials-unit-bunch
|
||||
icon: { sprite: _CP14/Objects/Materials/flora.rsi, state: grass_material1 }
|
||||
color: "#85903e"
|
||||
price: 0 #?
|
||||
price: 0
|
||||
|
||||
- type: material
|
||||
id: CP14Ash
|
||||
@@ -104,4 +104,4 @@
|
||||
unit: cp14-materials-unit-pile
|
||||
icon: { sprite: _CP14/Objects/Materials/ash.rsi, state: ash_1 }
|
||||
color: "#2d313c"
|
||||
price: 0 #?
|
||||
price: 0
|
||||
|
||||
@@ -110,7 +110,7 @@
|
||||
result: CP14ClothingPantsTrouserDarkBlue
|
||||
|
||||
- type: CP14Recipe
|
||||
id: CP14ClothingDressBlack
|
||||
id: CP14ClothingPantsDressBlack
|
||||
tag: CP14RecipeSewing
|
||||
craftTime: 2
|
||||
entities:
|
||||
@@ -118,7 +118,7 @@
|
||||
CP14DyeBlack: 1
|
||||
stacks:
|
||||
CP14Cloth: 2
|
||||
result: CP14ClothingDressBlack
|
||||
result: CP14ClothingPantsDressBlack
|
||||
|
||||
- type: CP14Recipe
|
||||
id: CP14ClothingPantsSouthernMagician
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"version": 1,
|
||||
"size": {
|
||||
"x": 32,
|
||||
"y": 32
|
||||
},
|
||||
"license": "CLA",
|
||||
"copyright": "Created by TheShuEd",
|
||||
"states": [
|
||||
{
|
||||
"name": "shard"
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Resources/Textures/_CP14/Effects/Magic/ice_shard.rsi/shard.png
Normal file
BIN
Resources/Textures/_CP14/Effects/Magic/ice_shard.rsi/shard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 245 B |
Reference in New Issue
Block a user