-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
235 changed files
with
15,263 additions
and
196,386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
Content.Client/ADT/SlimeHair/SlimeHairBoundUserInterface.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using Content.Shared.Humanoid.Markings; | ||
using Content.Shared.ADT.SlimeHair; | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.UserInterface; | ||
|
||
namespace Content.Client.ADT.SlimeHair; | ||
|
||
public sealed class SlimeHairBoundUserInterface : BoundUserInterface | ||
{ | ||
[ViewVariables] | ||
private SlimeHairWindow? _window; | ||
|
||
public SlimeHairBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
_window = this.CreateWindow<SlimeHairWindow>(); | ||
|
||
_window.OnHairSelected += tuple => SelectHair(SlimeHairCategory.Hair, tuple.id, tuple.slot); | ||
_window.OnHairColorChanged += args => ChangeColor(SlimeHairCategory.Hair, args.marking, args.slot); | ||
_window.OnHairSlotAdded += delegate () { AddSlot(SlimeHairCategory.Hair); }; | ||
_window.OnHairSlotRemoved += args => RemoveSlot(SlimeHairCategory.Hair, args); | ||
|
||
_window.OnFacialHairSelected += tuple => SelectHair(SlimeHairCategory.FacialHair, tuple.id, tuple.slot); | ||
_window.OnFacialHairColorChanged += | ||
args => ChangeColor(SlimeHairCategory.FacialHair, args.marking, args.slot); | ||
_window.OnFacialHairSlotAdded += delegate () { AddSlot(SlimeHairCategory.FacialHair); }; | ||
_window.OnFacialHairSlotRemoved += args => RemoveSlot(SlimeHairCategory.FacialHair, args); | ||
} | ||
|
||
private void SelectHair(SlimeHairCategory category, string marking, int slot) | ||
{ | ||
SendMessage(new SlimeHairSelectMessage(category, marking, slot)); | ||
} | ||
|
||
private void ChangeColor(SlimeHairCategory category, Marking marking, int slot) | ||
{ | ||
SendMessage(new SlimeHairChangeColorMessage(category, new(marking.MarkingColors), slot)); | ||
} | ||
|
||
private void RemoveSlot(SlimeHairCategory category, int slot) | ||
{ | ||
SendMessage(new SlimeHairRemoveSlotMessage(category, slot)); | ||
} | ||
|
||
private void AddSlot(SlimeHairCategory category) | ||
{ | ||
SendMessage(new SlimeHairAddSlotMessage(category)); | ||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
|
||
if (state is not SlimeHairUiState data || _window == null) | ||
{ | ||
return; | ||
} | ||
|
||
_window.UpdateState(data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<DefaultWindow xmlns="https://spacestation14.io" | ||
xmlns:humanoid="clr-namespace:Content.Client.Humanoid" | ||
Title="{Loc 'slime-hair-window-title'}" | ||
MinSize="600 400"> | ||
<BoxContainer> | ||
<humanoid:SingleMarkingPicker Name="HairPicker" Category="Hair" /> | ||
<humanoid:SingleMarkingPicker Name="FacialHairPicker" Category="FacialHair" /> | ||
</BoxContainer> | ||
</DefaultWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Content.Shared.Humanoid.Markings; | ||
using Content.Shared.ADT.SlimeHair; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client.ADT.SlimeHair; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class SlimeHairWindow : DefaultWindow | ||
{ | ||
public Action<(int slot, string id)>? OnHairSelected; | ||
public Action<(int slot, Marking marking)>? OnHairColorChanged; | ||
public Action<int>? OnHairSlotRemoved; | ||
public Action? OnHairSlotAdded; | ||
|
||
public Action<(int slot, string id)>? OnFacialHairSelected; | ||
public Action<(int slot, Marking marking)>? OnFacialHairColorChanged; | ||
public Action<int>? OnFacialHairSlotRemoved; | ||
public Action? OnFacialHairSlotAdded; | ||
|
||
public SlimeHairWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
HairPicker.OnMarkingSelect += args => OnHairSelected!(args); | ||
HairPicker.OnColorChanged += args => OnHairColorChanged!(args); | ||
HairPicker.OnSlotRemove += args => OnHairSlotRemoved!(args); | ||
HairPicker.OnSlotAdd += delegate { OnHairSlotAdded!(); }; | ||
|
||
FacialHairPicker.OnMarkingSelect += args => OnFacialHairSelected!(args); | ||
FacialHairPicker.OnColorChanged += args => OnFacialHairColorChanged!(args); | ||
FacialHairPicker.OnSlotRemove += args => OnFacialHairSlotRemoved!(args); | ||
FacialHairPicker.OnSlotAdd += delegate { OnFacialHairSlotAdded!(); }; | ||
} | ||
|
||
public void UpdateState(SlimeHairUiState state) | ||
{ | ||
HairPicker.UpdateData(state.Hair, state.Species, state.HairSlotTotal); | ||
FacialHairPicker.UpdateData(state.FacialHair, state.Species, state.FacialHairSlotTotal); | ||
|
||
if (!HairPicker.Visible && !FacialHairPicker.Visible) | ||
{ | ||
AddChild(new Label { Text = Loc.GetString("magic-mirror-component-activate-user-has-no-hair") }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Content.Shared.DoAfter; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Audio; | ||
|
||
namespace Content.Server.ADT.SlimeHair; | ||
|
||
/// <summary> | ||
/// Allows humanoids to change their appearance mid-round. | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class SlimeHairComponent : Component | ||
{ | ||
[DataField] | ||
public DoAfterId? DoAfter; | ||
|
||
/// <summary> | ||
/// Magic mirror target, used for validating UI messages. | ||
/// </summary> | ||
[DataField] | ||
public EntityUid? Target; | ||
|
||
/// <summary> | ||
/// doafter time required to add a new slot | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public TimeSpan AddSlotTime = TimeSpan.FromSeconds(2); | ||
|
||
/// <summary> | ||
/// doafter time required to remove a existing slot | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public TimeSpan RemoveSlotTime = TimeSpan.FromSeconds(2); | ||
|
||
/// <summary> | ||
/// doafter time required to change slot | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public TimeSpan SelectSlotTime = TimeSpan.FromSeconds(2); | ||
|
||
/// <summary> | ||
/// doafter time required to recolor slot | ||
/// </summary> | ||
[DataField, ViewVariables(VVAccess.ReadWrite)] | ||
public TimeSpan ChangeSlotTime = TimeSpan.FromSeconds(1); | ||
|
||
/// <summary> | ||
/// Sound emitted when slots are changed | ||
/// </summary> | ||
[DataField] | ||
public SoundSpecifier ChangeHairSound = new SoundPathSpecifier("/Audio/ADT/slime-hair.ogg") | ||
{ | ||
Params = AudioParams.Default.WithVolume(-1f), | ||
}; | ||
|
||
[DataField("hairAction")] | ||
public EntProtoId Action = "ActionSlimeHair"; | ||
|
||
[DataField, AutoNetworkedField] | ||
public EntityUid? ActionEntity; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Content.Shared.ADT.SlimeHair; | ||
using Robust.Shared.Player; | ||
|
||
namespace Content.Server.ADT.SlimeHair; | ||
|
||
/// <summary> | ||
/// Allows humanoids to change their appearance mid-round. | ||
/// </summary> | ||
public sealed partial class SlimeHairSystem | ||
{ | ||
private void InitializeSlimeAbilities() | ||
{ | ||
SubscribeLocalEvent<SlimeHairComponent, SlimeHairActionEvent>(SlimeHairAction); | ||
} | ||
|
||
private void SlimeHairAction(EntityUid uid, SlimeHairComponent comp, SlimeHairActionEvent args) | ||
{ | ||
if (args.Handled) | ||
return; | ||
|
||
if (!TryComp<ActorComponent>(uid, out var actor)) | ||
return; | ||
|
||
_uiSystem.TryOpenUi(uid, SlimeHairUiKey.Key, actor.Owner); | ||
|
||
UpdateInterface(uid, comp); | ||
|
||
args.Handled = true; | ||
} | ||
} |
Oops, something went wrong.