Resolves that make you flinch (#2423)
* argh * ouch * zap * adds default! * adressed review
This commit is contained in:
@@ -21,6 +21,8 @@ namespace Content.Client.GameObjects.Components.Items
|
|||||||
[ComponentReference(typeof(IItemComponent))]
|
[ComponentReference(typeof(IItemComponent))]
|
||||||
public class ItemComponent : Component, IItemComponent, IDraggable
|
public class ItemComponent : Component, IItemComponent, IDraggable
|
||||||
{
|
{
|
||||||
|
[Dependency] private IResourceCache _resourceCache = default!;
|
||||||
|
|
||||||
public override string Name => "Item";
|
public override string Name => "Item";
|
||||||
public override uint? NetID => ContentNetIDs.ITEM;
|
public override uint? NetID => ContentNetIDs.ITEM;
|
||||||
|
|
||||||
@@ -72,8 +74,7 @@ namespace Content.Client.GameObjects.Components.Items
|
|||||||
|
|
||||||
protected RSI GetRSI()
|
protected RSI GetRSI()
|
||||||
{
|
{
|
||||||
var resourceCache = IoCManager.Resolve<IResourceCache>();
|
return _resourceCache.GetResource<RSIResource>(SharedSpriteComponent.TextureRoot / RsiPath).RSI;
|
||||||
return resourceCache.GetResource<RSIResource>(SharedSpriteComponent.TextureRoot / RsiPath).RSI;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
{
|
{
|
||||||
public class WiresMenu : BaseWindow
|
public class WiresMenu : BaseWindow
|
||||||
{
|
{
|
||||||
|
[Dependency] private IResourceCache _resourceCache = default!;
|
||||||
|
|
||||||
public WiresBoundUserInterface Owner { get; }
|
public WiresBoundUserInterface Owner { get; }
|
||||||
|
|
||||||
private readonly Control _wiresHBox;
|
private readonly Control _wiresHBox;
|
||||||
@@ -34,7 +36,7 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
|
|
||||||
public WiresMenu(WiresBoundUserInterface owner)
|
public WiresMenu(WiresBoundUserInterface owner)
|
||||||
{
|
{
|
||||||
var resourceCache = IoCManager.Resolve<IResourceCache>();
|
IoCManager.InjectDependencies(this);
|
||||||
|
|
||||||
Owner = owner;
|
Owner = owner;
|
||||||
var rootContainer = new LayoutContainer {Name = "WireRoot"};
|
var rootContainer = new LayoutContainer {Name = "WireRoot"};
|
||||||
@@ -42,7 +44,7 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
|
|
||||||
MouseFilter = MouseFilterMode.Stop;
|
MouseFilter = MouseFilterMode.Stop;
|
||||||
|
|
||||||
var panelTex = resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
|
var panelTex = _resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
|
||||||
var back = new StyleBoxTexture
|
var back = new StyleBoxTexture
|
||||||
{
|
{
|
||||||
Texture = panelTex,
|
Texture = panelTex,
|
||||||
@@ -135,8 +137,8 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
|
|
||||||
LayoutContainer.SetAnchorPreset(topContainerWrap, LayoutContainer.LayoutPreset.Wide);
|
LayoutContainer.SetAnchorPreset(topContainerWrap, LayoutContainer.LayoutPreset.Wide);
|
||||||
|
|
||||||
var font = resourceCache.GetFont("/Fonts/Boxfont-round/Boxfont Round.ttf", 13);
|
var font = _resourceCache.GetFont("/Fonts/Boxfont-round/Boxfont Round.ttf", 13);
|
||||||
var fontSmall = resourceCache.GetFont("/Fonts/Boxfont-round/Boxfont Round.ttf", 10);
|
var fontSmall = _resourceCache.GetFont("/Fonts/Boxfont-round/Boxfont Round.ttf", 10);
|
||||||
|
|
||||||
Button helpButton;
|
Button helpButton;
|
||||||
var topRow = new MarginContainer
|
var topRow = new MarginContainer
|
||||||
@@ -255,7 +257,7 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
var mirror = random.Next(2) == 0;
|
var mirror = random.Next(2) == 0;
|
||||||
var flip = random.Next(2) == 0;
|
var flip = random.Next(2) == 0;
|
||||||
var type = random.Next(2);
|
var type = random.Next(2);
|
||||||
var control = new WireControl(wire.Color, wire.Letter, wire.IsCut, flip, mirror, type)
|
var control = new WireControl(wire.Color, wire.Letter, wire.IsCut, flip, mirror, type, _resourceCache)
|
||||||
{
|
{
|
||||||
SizeFlagsVertical = SizeFlags.ShrinkEnd
|
SizeFlagsVertical = SizeFlags.ShrinkEnd
|
||||||
};
|
};
|
||||||
@@ -278,7 +280,7 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
{
|
{
|
||||||
if (status.Value is StatusLightData statusLightData)
|
if (status.Value is StatusLightData statusLightData)
|
||||||
{
|
{
|
||||||
_statusContainer.AddChild(new StatusLight(statusLightData));
|
_statusContainer.AddChild(new StatusLight(statusLightData, _resourceCache));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -305,18 +307,20 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
|
|
||||||
private sealed class WireControl : Control
|
private sealed class WireControl : Control
|
||||||
{
|
{
|
||||||
|
private IResourceCache _resourceCache;
|
||||||
|
|
||||||
private const string TextureContact = "/Textures/Interface/WireHacking/contact.svg.96dpi.png";
|
private const string TextureContact = "/Textures/Interface/WireHacking/contact.svg.96dpi.png";
|
||||||
|
|
||||||
public event Action WireClicked;
|
public event Action WireClicked;
|
||||||
public event Action ContactsClicked;
|
public event Action ContactsClicked;
|
||||||
|
|
||||||
public WireControl(WireColor color, WireLetter letter, bool isCut, bool flip, bool mirror, int type)
|
public WireControl(WireColor color, WireLetter letter, bool isCut, bool flip, bool mirror, int type, IResourceCache resourceCache)
|
||||||
{
|
{
|
||||||
|
_resourceCache = resourceCache;
|
||||||
|
|
||||||
SizeFlagsHorizontal = SizeFlags.ShrinkCenter;
|
SizeFlagsHorizontal = SizeFlags.ShrinkCenter;
|
||||||
MouseFilter = MouseFilterMode.Stop;
|
MouseFilter = MouseFilterMode.Stop;
|
||||||
|
|
||||||
var resourceCache = IoCManager.Resolve<IResourceCache>();
|
|
||||||
|
|
||||||
var layout = new LayoutContainer();
|
var layout = new LayoutContainer();
|
||||||
AddChild(layout);
|
AddChild(layout);
|
||||||
|
|
||||||
@@ -326,7 +330,7 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
SizeFlagsVertical = SizeFlags.ShrinkEnd,
|
SizeFlagsVertical = SizeFlags.ShrinkEnd,
|
||||||
SizeFlagsHorizontal = SizeFlags.ShrinkCenter,
|
SizeFlagsHorizontal = SizeFlags.ShrinkCenter,
|
||||||
Align = Label.AlignMode.Center,
|
Align = Label.AlignMode.Center,
|
||||||
FontOverride = resourceCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 12),
|
FontOverride = _resourceCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 12),
|
||||||
FontColorOverride = Color.Gray,
|
FontColorOverride = Color.Gray,
|
||||||
ToolTip = letter.Name(),
|
ToolTip = letter.Name(),
|
||||||
MouseFilter = MouseFilterMode.Stop
|
MouseFilter = MouseFilterMode.Stop
|
||||||
@@ -337,7 +341,7 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
LayoutContainer.SetGrowVertical(greek, LayoutContainer.GrowDirection.Begin);
|
LayoutContainer.SetGrowVertical(greek, LayoutContainer.GrowDirection.Begin);
|
||||||
LayoutContainer.SetGrowHorizontal(greek, LayoutContainer.GrowDirection.Both);
|
LayoutContainer.SetGrowHorizontal(greek, LayoutContainer.GrowDirection.Both);
|
||||||
|
|
||||||
var contactTexture = resourceCache.GetTexture(TextureContact);
|
var contactTexture = _resourceCache.GetTexture(TextureContact);
|
||||||
var contact1 = new TextureRect
|
var contact1 = new TextureRect
|
||||||
{
|
{
|
||||||
Texture = contactTexture,
|
Texture = contactTexture,
|
||||||
@@ -356,7 +360,7 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
layout.AddChild(contact2);
|
layout.AddChild(contact2);
|
||||||
LayoutContainer.SetPosition(contact2, (0, 60));
|
LayoutContainer.SetPosition(contact2, (0, 60));
|
||||||
|
|
||||||
var wire = new WireRender(color, isCut, flip, mirror, type);
|
var wire = new WireRender(color, isCut, flip, mirror, type, _resourceCache);
|
||||||
|
|
||||||
layout.AddChild(wire);
|
layout.AddChild(wire);
|
||||||
LayoutContainer.SetPosition(wire, (2, 16));
|
LayoutContainer.SetPosition(wire, (2, 16));
|
||||||
@@ -420,8 +424,11 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
"/Textures/Interface/WireHacking/wire_2_copper.svg.96dpi.png"
|
"/Textures/Interface/WireHacking/wire_2_copper.svg.96dpi.png"
|
||||||
};
|
};
|
||||||
|
|
||||||
public WireRender(WireColor color, bool isCut, bool flip, bool mirror, int type)
|
private IResourceCache _resourceCache;
|
||||||
|
|
||||||
|
public WireRender(WireColor color, bool isCut, bool flip, bool mirror, int type, IResourceCache resourceCache)
|
||||||
{
|
{
|
||||||
|
_resourceCache = resourceCache;
|
||||||
_color = color;
|
_color = color;
|
||||||
_isCut = isCut;
|
_isCut = isCut;
|
||||||
_flip = flip;
|
_flip = flip;
|
||||||
@@ -436,10 +443,8 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
|
|
||||||
protected override void Draw(DrawingHandleScreen handle)
|
protected override void Draw(DrawingHandleScreen handle)
|
||||||
{
|
{
|
||||||
var resC = IoCManager.Resolve<IResourceCache>();
|
|
||||||
|
|
||||||
var colorValue = _color.ColorValue();
|
var colorValue = _color.ColorValue();
|
||||||
var tex = resC.GetTexture(_isCut ? TextureCut[_type] : TextureNormal[_type]);
|
var tex = _resourceCache.GetTexture(_isCut ? TextureCut[_type] : TextureNormal[_type]);
|
||||||
|
|
||||||
var l = 0f;
|
var l = 0f;
|
||||||
var r = tex.Width + l;
|
var r = tex.Width + l;
|
||||||
@@ -465,7 +470,7 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
if (_isCut)
|
if (_isCut)
|
||||||
{
|
{
|
||||||
var copper = Color.Orange;
|
var copper = Color.Orange;
|
||||||
var copperTex = resC.GetTexture(TextureCopper[_type]);
|
var copperTex = _resourceCache.GetTexture(TextureCopper[_type]);
|
||||||
handle.DrawTextureRect(copperTex, rect, copper);
|
handle.DrawTextureRect(copperTex, rect, copper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,9 +521,8 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public StatusLight(StatusLightData data)
|
public StatusLight(StatusLightData data, IResourceCache resourceCache)
|
||||||
{
|
{
|
||||||
var resC = IoCManager.Resolve<IResourceCache>();
|
|
||||||
var hsv = Color.ToHsv(data.Color);
|
var hsv = Color.ToHsv(data.Color);
|
||||||
hsv.Z /= 2;
|
hsv.Z /= 2;
|
||||||
var dimColor = Color.FromHsv(hsv);
|
var dimColor = Color.FromHsv(hsv);
|
||||||
@@ -530,7 +534,7 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
{
|
{
|
||||||
new TextureRect
|
new TextureRect
|
||||||
{
|
{
|
||||||
Texture = resC.GetTexture(
|
Texture = resourceCache.GetTexture(
|
||||||
"/Textures/Interface/WireHacking/light_off_base.svg.96dpi.png"),
|
"/Textures/Interface/WireHacking/light_off_base.svg.96dpi.png"),
|
||||||
Stretch = TextureRect.StretchMode.KeepCentered,
|
Stretch = TextureRect.StretchMode.KeepCentered,
|
||||||
ModulateSelfOverride = dimColor
|
ModulateSelfOverride = dimColor
|
||||||
@@ -540,7 +544,7 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
ModulateSelfOverride = data.Color.WithAlpha(0.4f),
|
ModulateSelfOverride = data.Color.WithAlpha(0.4f),
|
||||||
Stretch = TextureRect.StretchMode.KeepCentered,
|
Stretch = TextureRect.StretchMode.KeepCentered,
|
||||||
Texture =
|
Texture =
|
||||||
resC.GetTexture("/Textures/Interface/WireHacking/light_on_base.svg.96dpi.png"),
|
resourceCache.GetTexture("/Textures/Interface/WireHacking/light_on_base.svg.96dpi.png"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -577,7 +581,7 @@ namespace Content.Client.GameObjects.Components.Wires
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var font = IoCManager.Resolve<IResourceCache>().GetFont("/Fonts/Boxfont-round/Boxfont Round.ttf", 12);
|
var font = resourceCache.GetFont("/Fonts/Boxfont-round/Boxfont Round.ttf", 12);
|
||||||
|
|
||||||
var hBox = new HBoxContainer {SeparationOverride = 4};
|
var hBox = new HBoxContainer {SeparationOverride = 4};
|
||||||
hBox.AddChild(new Label
|
hBox.AddChild(new Label
|
||||||
|
|||||||
@@ -34,10 +34,8 @@ namespace Content.Shared.Prototypes.Cargo
|
|||||||
{
|
{
|
||||||
if (_name.Trim().Length != 0)
|
if (_name.Trim().Length != 0)
|
||||||
return _name;
|
return _name;
|
||||||
var protoMan = IoCManager.Resolve<IPrototypeManager>();
|
EntityPrototype prototype = null;
|
||||||
if (protoMan == null)
|
IoCManager.Resolve<IPrototypeManager>()?.TryIndex(_product, out prototype);
|
||||||
return _name;
|
|
||||||
protoMan.TryIndex(_product, out EntityPrototype prototype);
|
|
||||||
if (prototype?.Name != null)
|
if (prototype?.Name != null)
|
||||||
_name = prototype.Name;
|
_name = prototype.Name;
|
||||||
return _name;
|
return _name;
|
||||||
@@ -54,10 +52,8 @@ namespace Content.Shared.Prototypes.Cargo
|
|||||||
{
|
{
|
||||||
if (_description.Trim().Length != 0)
|
if (_description.Trim().Length != 0)
|
||||||
return _description;
|
return _description;
|
||||||
var protoMan = IoCManager.Resolve<IPrototypeManager>();
|
EntityPrototype prototype = null;
|
||||||
if (protoMan == null)
|
IoCManager.Resolve<IPrototypeManager>()?.TryIndex(_product, out prototype);
|
||||||
return _description;
|
|
||||||
protoMan.TryIndex(_product, out EntityPrototype prototype);
|
|
||||||
if (prototype?.Description != null)
|
if (prototype?.Description != null)
|
||||||
_description = prototype.Description;
|
_description = prototype.Description;
|
||||||
return _description;
|
return _description;
|
||||||
@@ -94,6 +90,11 @@ namespace Content.Shared.Prototypes.Cargo
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public string Group => _group;
|
public string Group => _group;
|
||||||
|
|
||||||
|
public CargoProductPrototype()
|
||||||
|
{
|
||||||
|
IoCManager.InjectDependencies(this);
|
||||||
|
}
|
||||||
|
|
||||||
public void LoadFrom(YamlMappingNode mapping)
|
public void LoadFrom(YamlMappingNode mapping)
|
||||||
{
|
{
|
||||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||||
|
|||||||
Reference in New Issue
Block a user