[feat] Emote panel, monkey rsi fix

This commit is contained in:
rhailrake
2023-04-28 05:08:05 +06:00
committed by Aviu00
parent 07bc0bb754
commit c71ac26fdc
21 changed files with 338 additions and 241 deletions

View File

@@ -55,6 +55,7 @@ namespace Content.Client.Input
human.AddFunction(ContentKeyFunctions.UseItemInHand);
human.AddFunction(ContentKeyFunctions.AltUseItemInHand);
human.AddFunction(ContentKeyFunctions.OpenCharacterMenu);
human.AddFunction(ContentKeyFunctions.OpenEmotionsMenu);
human.AddFunction(ContentKeyFunctions.ActivateItemInWorld);
human.AddFunction(ContentKeyFunctions.ThrowItemInHand);
human.AddFunction(ContentKeyFunctions.AltActivateItemInWorld);

View File

@@ -209,6 +209,7 @@ namespace Content.Client.Options.UI.Tabs
AddButton(ContentKeyFunctions.CycleChatChannelForward);
AddButton(ContentKeyFunctions.CycleChatChannelBackward);
AddButton(ContentKeyFunctions.OpenCharacterMenu);
AddButton(ContentKeyFunctions.OpenEmotionsMenu);
AddButton(ContentKeyFunctions.OpenCraftingMenu);
AddButton(ContentKeyFunctions.OpenGuidebook);
AddButton(ContentKeyFunctions.OpenInventoryMenu);

View File

@@ -0,0 +1,139 @@
using System.Linq;
using Content.Client.Chat.Managers;
using Content.Client.Gameplay;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.Emotions.Windows;
using Content.Shared.Chat;
using Content.Shared.Chat.Prototypes;
using Content.Shared.Input;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Input.Binding;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
namespace Content.Client.UserInterface.Systems.Emotions;
public sealed class EmotionsUIController : UIController, IOnStateChanged<GameplayState>
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
private EmotionsWindow? _window;
private MenuButton? EmotionsButton => UIManager.GetActiveUIWidgetOrNull<MenuBar.Widgets.GameTopMenuBar>()?.EmotionsButton;
private DateTime _lastEmotionTimeUse = DateTime.Now;
private float _emoteCooldown = 1.5f;
public void OnStateEntered(GameplayState state)
{
DebugTools.Assert(_window == null);
_window = UIManager.CreateWindow<EmotionsWindow>();
_window.OnOpen += OnWindowOpened;
_window.OnClose += OnWindowClosed;
var emotions = _prototypeManager.EnumeratePrototypes<EmotePrototype>().ToList();
emotions.Sort((a,b) => string.Compare(a.ButtonText, b.ButtonText.ToString(), StringComparison.Ordinal));
foreach (var emote in emotions)
{
var control = new Button();
control.OnPressed += _ => UseEmote(_random.Pick(emote.ChatMessages));
control.Text = emote.ButtonText;
control.HorizontalExpand = true;
control.VerticalExpand = true;
control.MaxWidth = 250;
control.MaxHeight = 50;
_window.EmotionsContainer.AddChild(control);
}
CommandBinds.Builder
.Bind(ContentKeyFunctions.OpenEmotionsMenu,
InputCmdHandler.FromDelegate(_ => ToggleWindow()))
.Register<EmotionsUIController>();
}
public void UnloadButton()
{
if (EmotionsButton == null)
{
return;
}
EmotionsButton.OnPressed -= EmotionsButtonPressed;
}
private void UseEmote(string emote)
{
var timeSpan = DateTime.Now - _lastEmotionTimeUse;
var seconds = timeSpan.TotalSeconds;
if (seconds < _emoteCooldown)
{
return;
}
_lastEmotionTimeUse = DateTime.Now;
_chatManager.SendMessage(emote, ChatSelectChannel.Emotes);
}
public void LoadButton()
{
if (EmotionsButton == null)
{
return;
}
EmotionsButton.OnPressed += EmotionsButtonPressed;
}
private void OnWindowOpened()
{
if (EmotionsButton != null)
EmotionsButton.Pressed = true;
}
private void OnWindowClosed()
{
if (EmotionsButton != null)
EmotionsButton.Pressed = false;
}
public void OnStateExited(GameplayState state)
{
if (_window != null)
{
_window.OnOpen -= OnWindowOpened;
_window.OnClose -= OnWindowClosed;
_window.Dispose();
_window = null;
}
CommandBinds.Unregister<EmotionsUIController>();
}
private void EmotionsButtonPressed(BaseButton.ButtonEventArgs args)
{
ToggleWindow();
}
private void ToggleWindow()
{
if (_window == null)
return;
if (_window.IsOpen)
{
_window.Close();
return;
}
_window.Open();
}
}

View File

@@ -0,0 +1,12 @@
<windows:EmotionsWindow
xmlns="https://spacestation14.io"
xmlns:windows="clr-namespace:Content.Client.UserInterface.Systems.Emotions.Windows"
Title="Меню эмоций"
VerticalExpand="True"
HorizontalExpand="True"
MinHeight="250"
MinWidth="300">
<GridContainer Name="EmotionsContainer" Access="Public" Columns="3">
</GridContainer>
</windows:EmotionsWindow>

View File

@@ -0,0 +1,13 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.UserInterface.Systems.Emotions.Windows;
[GenerateTypedNameReferences]
public sealed partial class EmotionsWindow : DefaultWindow
{
public EmotionsWindow()
{
RobustXamlLoader.Load(this);
}
}

View File

@@ -3,6 +3,7 @@ using Content.Client.UserInterface.Systems.Admin;
using Content.Client.UserInterface.Systems.Bwoink;
using Content.Client.UserInterface.Systems.Character;
using Content.Client.UserInterface.Systems.Crafting;
using Content.Client.UserInterface.Systems.Emotions;
using Content.Client.UserInterface.Systems.EscapeMenu;
using Content.Client.UserInterface.Systems.Gameplay;
using Content.Client.UserInterface.Systems.Guidebook;
@@ -22,6 +23,7 @@ public sealed class GameTopMenuBarUIController : UIController
[Dependency] private readonly ActionUIController _action = default!;
[Dependency] private readonly SandboxUIController _sandbox = default!;
[Dependency] private readonly GuidebookUIController _guidebook = default!;
[Dependency] private readonly EmotionsUIController _emotions = default!;
private GameTopMenuBar? GameTopMenuBar => UIManager.GetActiveUIWidgetOrNull<GameTopMenuBar>();
@@ -44,6 +46,7 @@ public sealed class GameTopMenuBarUIController : UIController
_ahelp.UnloadButton();
_action.UnloadButton();
_sandbox.UnloadButton();
_emotions.UnloadButton();
}
public void LoadButtons()
@@ -56,5 +59,6 @@ public sealed class GameTopMenuBarUIController : UIController
_ahelp.LoadButton();
_action.LoadButton();
_sandbox.LoadButton();
_emotions.LoadButton();
}
}

View File

@@ -43,6 +43,16 @@
HorizontalExpand="True"
AppendStyleClass="{x:Static style:StyleBase.ButtonSquare}"
/>
<ui:MenuButton
Name="EmotionsButton"
Access="Internal"
Icon="{xe:Tex '/Textures/Interface/emotions.svg.192dpi.png'}"
ToolTip="{Loc 'game-hud-open-emotions-menu-button-tooltip'}"
BoundKey = "{x:Static is:ContentKeyFunctions.OpenEmotionsMenu}"
MinSize="42 64"
HorizontalExpand="True"
AppendStyleClass="{x:Static style:StyleBase.ButtonSquare}"
/>
<ui:MenuButton
Name="CraftingButton"
Access="Internal"

View File

@@ -23,6 +23,8 @@ public partial class ChatSystem
var emotes = _prototypeManager.EnumeratePrototypes<EmotePrototype>();
foreach (var emote in emotes)
{
if (emote.ChatTriggers == null)
continue;
foreach (var word in emote.ChatTriggers)
{
var lowerWord = word.ToLower();

View File

@@ -184,6 +184,9 @@ public sealed partial class ChatSystem : SharedChatSystem
{
if (HasComp<GhostComponent>(source))
{
if(desiredType == InGameICChatType.Emote)
return;
// Ghosts can only send dead chat messages, so we'll forward it to InGame OOC.
TrySendInGameOOCMessage(source, message, InGameOOCChatType.Dead, range == ChatTransmitRange.HideChat, shell, player);
return;

View File

@@ -31,7 +31,7 @@ public sealed class BodyEmotesSystem : EntitySystem
return;
var cat = args.Emote.Category;
if (cat.HasFlag(EmoteCategory.Hands))
if (cat.HasFlag(EmoteCategory.Gesture))
{
args.Handled = TryEmoteHands(uid, args.Emote, component);
}

View File

@@ -33,7 +33,14 @@ public sealed partial class EmotePrototype : IPrototype
/// All words should be unique across all emote prototypes.
/// </summary>
[DataField("chatTriggers")]
public HashSet<string> ChatTriggers = new();
public HashSet<string>? ChatTriggers = new();
/// <summary>
/// Текст для кнопки в эмоут меню.
/// Бля ну или как это описать, вы поняли короче. ¯\_(ツ)_/¯
/// </summary>
[DataField("buttonText")]
public string ButtonText { get; } = "Unknown";
}
/// <summary>
@@ -46,6 +53,6 @@ public enum EmoteCategory : byte
{
Invalid = 0,
Vocal = 1 << 0,
Hands = 1 << 1,
Gesture = 1 << 1,
General = byte.MaxValue
}

View File

@@ -25,6 +25,7 @@ namespace Content.Shared.Input
public static readonly BoundKeyFunction CycleChatChannelBackward = "CycleChatChannelBackward";
public static readonly BoundKeyFunction EscapeContext = "EscapeContext";
public static readonly BoundKeyFunction OpenCharacterMenu = "OpenCharacterMenu";
public static readonly BoundKeyFunction OpenEmotionsMenu = "OpenEmotionsMenu";
public static readonly BoundKeyFunction OpenCraftingMenu = "OpenCraftingMenu";
public static readonly BoundKeyFunction OpenGuidebook = "OpenGuidebook";
public static readonly BoundKeyFunction OpenInventoryMenu = "OpenInventoryMenu";

View File

@@ -1,45 +1,23 @@
- type: emote
id: Sneeze
buttonText: Чихать
category: Vocal
chatMessages: [sneezes]
chatMessages: [чихает]
- type: emote
id: Cough
buttonText: Кашлять
category: Vocal
chatMessages: [coughs]
chatMessages: [кашляет]
chatTriggers:
- cough
- coughs
- type: emote
id: CatMeow
category: Vocal
chatMessages: [meows]
- type: emote
id: CatHisses
category: Vocal
chatMessages: [hisses]
- type: emote
id: MonkeyScreeches
category: Vocal
chatMessages: [screeches]
- type: emote
id: RobotBeep
category: Vocal
chatMessages: [beeps]
- type: emote
id: Yawn
buttonText: Зевать
category: Vocal
chatMessages: [yawns]
chatMessages: [зевает]
chatTriggers:
- yawn
- yawns
- type: emote
id: Snore
category: Vocal
chatMessages: [snores]

View File

@@ -1,208 +0,0 @@
# vocal emotes
- type: emote
id: Scream
category: Vocal
chatMessages: [screams!]
chatTriggers:
- scream
- screams
- screams.
- screams!
- screaming
- screamed
- shriek
- shrieks
- shrieks.
- shrieks!
- shrieking
- shrieked
- screech
- screeches
- screeches.
- screeches!
- screeching
- screeched
- yell
- yells
- yells.
- yells!
- yelled
- yelling
- type: emote
id: Laugh
category: Vocal
chatMessages: [laughs]
chatTriggers:
- laugh
- laughs
- laughs.
- laughs!
- laughing
- laughed
- chuckle
- chuckles
- chuckles.
- chuckles!
- chuckled
- chuckling
- giggle
- giggles
- giggles.
- giggles!
- giggling
- giggled
- type: emote
id: Honk
category: Vocal
chatMessages: [honks]
- type: emote
id: Sigh
category: Vocal
chatMessages: [sighs]
chatTriggers:
- sigh
- sighs
- sighed
- sigh.
- sighs.
- sighed.
- type: emote
id: Whistle
category: Vocal
chatMessages: [whistle]
chatTriggers:
- whistle
- whistle.
- whistle!
- whistles
- whistles.
- whistles!
- whistleblowing
- whistleblowing.
- whistleblowing!
- type: emote
id: Crying
category: Vocal
chatMessages: [crying]
chatTriggers:
- cry
- cry.
- cry!
- crying
- crying.
- crying!
- cries
- cries.
- cries!
- type: emote
id: Squish
category: Vocal
chatMessages: [squishing]
chatTriggers:
- squish
- squish.
- squish!
- squishing
- squishing.
- squishing!
- squishes
- squishes.
- squishes!
- type: emote
id: Chitter
category: Vocal
chatMessages: [chitters.]
chatTriggers:
- chitter
- chitter.
- chitter!
- chitters
- chitters.
- chitters!
- chittered
- chittered.
- chittered!
- type: emote
id: Squeak
category: Vocal
chatMessages: [squeaks.]
chatTriggers:
- squeak
- squeak.
- squeak!
- squeaks
- squeaks.
- squeaks!
- squeaked
- squeaked.
- squeaked!
- type: emote
id: Click
category: Vocal
chatMessages: [click.]
chatTriggers:
- click
- click.
- click!
- clicks
- clicks.
- clicks!
# hand emotes
- type: emote
id: Clap
category: Hands
chatMessages: [claps!]
chatTriggers:
- clap
- claps
- claps.
- claps!
- clapping
- clapped
- type: emote
id: Snap
category: Hands
chatMessages: [snaps fingers] # snaps <{THEIR($ent)}> fingers?
chatTriggers:
- snap
- snaps
- snapping
- snapped
- snap fingers
- snaps fingers
- snaps fingers.
- snaps fingers!
- snaps their fingers
- snaps their fingers.
- snaps their fingers!
- snapping fingers
- snapped fingers
- type: emote
id: Salute
category: Hands
chatMessages: [Salute]
chatTriggers:
- salute
- salute.
- salute!
- salutes
- salutes.
- salutes!
- type: emote
id: DefaultDeathgasp
chatMessages: ["emote-deathgasp"]
chatTriggers:
- deathgasp

View File

@@ -0,0 +1,108 @@
- type: emote
id: Scream
category: Vocal
buttonText: Кричать
chatMessages: [кричит, орет, вопит, рявкает]
chatTriggers:
- кричит
- закричал
- закричала
- орет
- заорал
- заорала
- визжит
- завизжал
- завизжала
- взвизгнул
- взвизгнула
- рявкает
- рявкнул
- рявкнула
- вопит
- type: emote
id: Laugh
category: Vocal
buttonText: Смеяться
chatMessages: [смеется, ржет, усмехается, хохочет, гогочет]
chatTriggers:
- смеется
- просмеялся
- засмеялся
- засмеялась
- хихикает
- хихикнул
- хихикнула
- хихикает
- ржет
- усмехается
- усмехнулась
- усмехнулся
- хохочет
- гогочет
- type: emote
id: Clap
category: Gesture
buttonText: Хлопать
chatMessages: [хлопает]
chatTriggers:
- хлопает
- захлопала
- захлопал
- похлопал
- type: emote
id: Snap
category: Gesture
buttonText: Щелкать пальцами
chatMessages: [щелкает пальцами]
chatTriggers:
- щелкает пальцами
- щелкает
- щелкнул
- щелкнула
- щелкунл пальцами
- щелкунла пальцами
- type: emote
id: WaveHand
category: Gesture
buttonText: Махать рукой
chatMessages: [машет рукой]
- type: emote
id: Nod
category: Gesture
buttonText: Кивать
chatMessages: [кивает]
- type: emote
id: ShakeHead
category: Gesture
buttonText: Покачать головой
chatMessages: [качает головой]
- type: emote
id: Frown
category: Gesture
buttonText: Хмуриться
chatMessages: [хмурится]
- type: emote
id: Smile
category: Gesture
buttonText: Улыбаться
chatMessages: [улыбается]
- type: emote
id: Sniff
category: Gesture
buttonText: Принюхиваться
chatMessages: [принюхивается]
- type: emote
id: LickLips
category: Gesture
buttonText: Облизываться
chatMessages: [облизывается]

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="86.000000pt" height="86.000000pt" viewBox="0 0 86.000000 86.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.16, written by Peter Selinger 2001-2019
</metadata>
<g transform="translate(0.000000,86.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
</g>
</svg>

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

View File

@@ -0,0 +1,2 @@
sample:
filter: true

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

View File

@@ -10,6 +10,14 @@
{
"name": "monkey",
"directions": 4
}
},
{
"name": "dead",
"delays": [
[
1
]
]
}
]
}

View File

@@ -183,6 +183,9 @@ binds:
- function: OpenCharacterMenu
type: State
key: C
- function: OpenEmotionsMenu
type: State
key: Y
- function: TextCursorSelect
# TextCursorSelect HAS to be above ExamineEntity
# So that LineEdit receives it correctly.