-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Port] Emotions menu / Меню эмоций (#55)
* add: emotions munu * tweak * fix * WD EDIT * test * AI rewiew * rewiew
- Loading branch information
Showing
24 changed files
with
547 additions
and
75 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
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
162 changes: 162 additions & 0 deletions
162
Content.Client/_White/UI/Emotions/EmotionsUIController.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,162 @@ | ||
using System.Linq; | ||
using Content.Client.Chat.Managers; | ||
using Content.Client.Gameplay; | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared.Chat; | ||
using Content.Shared.Chat.Prototypes; | ||
using Content.Shared.Input; | ||
using Robust.Client.UserInterface.Controllers; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Shared.Input.Binding; | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Random; | ||
|
||
namespace Content.Client._White.UI.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 DefaultWindow? _window; | ||
private MenuButton? EmotionsButton => UIManager.GetActiveUIWidgetOrNull<UserInterface.Systems.MenuBar.Widgets.GameTopMenuBar>()?.EmotionsButton; | ||
|
||
private DateTime _lastEmotionTimeUse = DateTime.Now; | ||
private const float EmoteCooldown = 1.5f; | ||
|
||
public void OnStateEntered(GameplayState state) | ||
{ | ||
_window = FormMenu(); | ||
|
||
_window.OnOpen += OnWindowOpened; | ||
_window.OnClose += OnWindowClosed; | ||
|
||
CommandBinds.Builder | ||
.Bind(ContentKeyFunctions.OpenEmotionsMenu, | ||
InputCmdHandler.FromDelegate(_ => ToggleWindow())) | ||
.Register<EmotionsUIController>(); | ||
} | ||
|
||
public void OnStateExited(GameplayState state) | ||
{ | ||
if (_window != null) | ||
{ | ||
_window.OnOpen -= OnWindowOpened; | ||
_window.OnClose -= OnWindowClosed; | ||
|
||
_window.Dispose(); | ||
_window = null; | ||
} | ||
|
||
CommandBinds.Unregister<EmotionsUIController>(); | ||
} | ||
|
||
public void LoadButton() | ||
{ | ||
if (EmotionsButton == null) | ||
return; | ||
|
||
EmotionsButton.OnPressed += EmotionsButtonPressed; | ||
} | ||
|
||
public void UnloadButton() | ||
{ | ||
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; | ||
} | ||
|
||
private void EmotionsButtonPressed(BaseButton.ButtonEventArgs args) | ||
{ | ||
ToggleWindow(); | ||
} | ||
|
||
private void ToggleWindow() | ||
{ | ||
if (_window == null) | ||
return; | ||
|
||
if (_window.IsOpen) | ||
{ | ||
_window.Close(); | ||
return; | ||
} | ||
|
||
_window.Open(); | ||
} | ||
|
||
private void UseEmote(string emote) | ||
{ | ||
var time = (DateTime.Now - _lastEmotionTimeUse).TotalSeconds; | ||
if (time < EmoteCooldown) | ||
return; | ||
|
||
_lastEmotionTimeUse = DateTime.Now; | ||
_chatManager.SendMessage(emote, ChatSelectChannel.Emotes); | ||
} | ||
|
||
private Button CreateEmoteButton(EmotePrototype emote) | ||
{ | ||
var control = new Button | ||
{ | ||
ClipText = true, | ||
HorizontalExpand = true, | ||
VerticalExpand = true, | ||
MinWidth = 120, | ||
MaxWidth = 250, | ||
MaxHeight = 35, | ||
TextAlign = Label.AlignMode.Left, | ||
Text = Loc.GetString(emote.ButtonText) | ||
}; | ||
|
||
control.OnPressed += _ => UseEmote(Loc.GetString(_random.Pick(emote.ChatMessages))); | ||
return control; | ||
} | ||
|
||
private DefaultWindow FormMenu() | ||
{ | ||
var window = new DefaultWindow | ||
{ | ||
Title = Loc.GetString("emotions-menu-title"), | ||
VerticalExpand = true, | ||
HorizontalExpand = true, | ||
MinHeight = 250, | ||
MinWidth = 300 | ||
}; | ||
|
||
var grid = new GridContainer | ||
{ | ||
Columns = 3 | ||
}; | ||
|
||
var emotions = _prototypeManager.EnumeratePrototypes<EmotePrototype>().ToList(); | ||
emotions.Sort((a,b) => string.Compare(Loc.GetString(a.ButtonText), Loc.GetString(b.ButtonText.ToString()), StringComparison.Ordinal)); | ||
|
||
foreach (var emote in emotions) | ||
{ | ||
if (!emote.AllowToEmotionsMenu) | ||
continue; | ||
|
||
var button = CreateEmoteButton(emote); | ||
grid.AddChild(button); | ||
} | ||
|
||
window.Contents.AddChild(grid); | ||
return window; | ||
} | ||
} |
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 @@ | ||
game-hud-open-emotions-menu-button-tooltip = Open emotions menu. |
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,119 @@ | ||
#Scream | ||
emote-chat-button-text-scream = Scream | ||
emote-chat-messages-scream-1 = screams | ||
emote-chat-messages-scream-2 = shrieks | ||
emote-chat-messages-scream-3 = screeches | ||
emote-chat-messages-scream-4 = yells | ||
#Laugh | ||
emote-chat-button-text-laugh = Laugh | ||
emote-chat-messages-laugh-1 = laughs | ||
emote-chat-messages-laugh-2 = chuckles | ||
emote-chat-messages-laugh-3 = giggles | ||
emote-chat-messages-laugh-4 = chortles | ||
#Honk | ||
emote-chat-messages-honk-1 = chortles | ||
#Sigh | ||
emote-chat-button-text-sigh = Sigh | ||
emote-chat-messages-sigh-1 = sighs | ||
#Whistle | ||
emote-chat-button-text-whistle = Whistle | ||
emote-chat-messages-whistle-1 = whistles | ||
#Crying | ||
emote-chat-button-text-crying = Сry | ||
emote-chat-messages-crying-1 = cries | ||
#Squish | ||
emote-chat-messages-squish-1 = squishes | ||
#Chitter | ||
emote-chat-messages-chitter-1 = chitters | ||
#Squeak | ||
emote-chat-messages-squeak-1 = squeaks | ||
#Click | ||
emote-chat-messages-click-1 = clicks | ||
emote-chat-messages-click-2 = click | ||
#Clap | ||
emote-chat-button-text-clap = Clap | ||
emote-chat-messages-clap-1 = сlaps | ||
#Snap | ||
emote-chat-button-text-snap = Snap fingers | ||
emote-chat-messages-snap-1 = snaps | ||
emote-chat-messages-snap-2 = snaps fingers | ||
emote-chat-messages-snap-3 = snaps his fingers | ||
emote-chat-messages-snap-4 = snaps her fingers | ||
emote-chat-messages-snap-5 = snaps their fingers | ||
emote-chat-messages-snap-6 = snaps its fingers | ||
emote-chat-messages-snap-7 = snaps its' fingers | ||
#Salute | ||
emote-chat-button-text-salute = Salute | ||
emote-chat-messages-salute-1 = salutes | ||
#Deathgasp | ||
emote-chat-messages-deathgasp-1 = seizes up and falls limp, {POSS-ADJ($entity)} eyes dead and lifeless... | ||
emote-chat-messages-deathgasp-silicon-1 = seizes up and falls limp, {POSS-ADJ($entity)} lights sputtering into darkness... | ||
emote-chat-messages-deathgasp-ipc-1 = With a hiss of grinding servos and a screech of dying myomers, {CAPITALIZE($entity)} suddenly goes silent. | ||
#Buzz | ||
emote-chat-messages-buzz-1 = buzzes | ||
#Weh | ||
emote-chat-messages-weh-1 = wehs | ||
#Chirp | ||
emote-chat-messages-chirp-1 = chirps | ||
#Beep | ||
emote-chat-messages-beep-1 = beeps | ||
#Boop | ||
emote-chat-messages-boop-1 = boops | ||
#Chime | ||
emote-chat-messages-chime-1 = chimes | ||
#Buzz-Two | ||
emote-chat-messages-buzz-two-1 = buzzes twice | ||
#Ping | ||
emote-chat-messages-ping-1 = pings | ||
#Whirr | ||
emote-chat-messages-whirr-1 = whirrs | ||
#Nod | ||
emote-chat-button-text-nod = Nod | ||
emote-chat-messages-nod-1 = nods | ||
#ShakeHead | ||
emote-chat-button-text-shake-head = Shake head | ||
emote-chat-messages-shake-head-1 = shakes head | ||
#Frown | ||
emote-chat-button-text-frown = Frown | ||
emote-chat-messages-frown-1 = frowns | ||
#Smile | ||
emote-chat-button-text-smile = Smile | ||
emote-chat-messages-smile-1 = smiles |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
ui-options-function-open-emotions-menu = Open emotions menu | ||
ui-options-function-look-up = Look up/Take aim | ||
ui-options-function-auto-get-up = Automatically get up after falling | ||
ui-options-function-hold-look-up = Hold down the key to aim |
Oops, something went wrong.