-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/TheDenSS14/TheDen
- Loading branch information
Showing
136 changed files
with
20,472 additions
and
89 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
37 changes: 37 additions & 0 deletions
37
Content.Client/DeltaV/AACTablet/UI/AACBoundUserInterface.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,37 @@ | ||
using Content.Shared.DeltaV.AACTablet; | ||
using Content.Shared.DeltaV.QuickPhrase; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.DeltaV.AACTablet.UI; | ||
|
||
public sealed class AACBoundUserInterface : BoundUserInterface | ||
{ | ||
[ViewVariables] | ||
private AACWindow? _window; | ||
|
||
public AACBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
_window?.Close(); | ||
_window = new AACWindow(); | ||
_window.OpenCentered(); | ||
|
||
_window.PhraseButtonPressed += OnPhraseButtonPressed; | ||
_window.OnClose += Close; | ||
} | ||
|
||
private void OnPhraseButtonPressed(ProtoId<QuickPhrasePrototype> phraseId) | ||
{ | ||
SendMessage(new AACTabletSendPhraseMessage(phraseId)); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
_window?.Orphan(); | ||
} | ||
} |
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 @@ | ||
<controls:FancyWindow xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
Title="AAC Tablet" | ||
Resizable="False" | ||
SetSize="540 300" | ||
MinSize="540 300"> | ||
<ScrollContainer HScrollEnabled="False" Name="WindowBody"> | ||
</ScrollContainer> | ||
</controls:FancyWindow> |
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,152 @@ | ||
using System.Linq; | ||
using System.Numerics; | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared.DeltaV.QuickPhrase; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.DeltaV.AACTablet.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class AACWindow : FancyWindow | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototype = default!; | ||
public event Action<ProtoId<QuickPhrasePrototype>>? PhraseButtonPressed; | ||
|
||
private const float SpaceWidth = 10f; | ||
private const float ParentWidth = 540f; | ||
private const int ColumnCount = 4; | ||
|
||
private const int ButtonWidth = | ||
(int)((ParentWidth - SpaceWidth * 2) / ColumnCount - SpaceWidth * ((ColumnCount - 1f) / ColumnCount)); | ||
|
||
public AACWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
PopulateGui(); | ||
} | ||
|
||
private void PopulateGui() | ||
{ | ||
var phrases = _prototype.EnumeratePrototypes<QuickPhrasePrototype>().ToList(); | ||
|
||
// take ALL phrases and turn them into tabs and groups, so the buttons are sorted and tabbed | ||
var sortedTabs = phrases | ||
.GroupBy(p => p.Tab) | ||
.OrderBy(g => g.Key) | ||
.ToDictionary( | ||
g => g.Key, | ||
g => g.GroupBy(p => p.Group) | ||
.OrderBy(gg => gg.Key) | ||
.ToDictionary( | ||
gg => gg.Key, | ||
gg => gg.OrderBy(p => Loc.GetString(p.Text)).ToList() | ||
) | ||
); | ||
|
||
var tabContainer = CreateTabContainer(sortedTabs); | ||
WindowBody.AddChild(tabContainer); | ||
} | ||
|
||
private TabContainer CreateTabContainer(Dictionary<string, Dictionary<string, List<QuickPhrasePrototype>>> sortedTabs) | ||
{ | ||
var tabContainer = new TabContainer(); | ||
|
||
foreach (var tab in sortedTabs) | ||
{ | ||
var tabName = Loc.GetString(tab.Key); | ||
var boxContainer = CreateBoxContainerForTab(tab.Value); | ||
tabContainer.AddChild(boxContainer); | ||
tabContainer.SetTabTitle(tabContainer.ChildCount - 1, tabName); | ||
} | ||
|
||
return tabContainer; | ||
} | ||
|
||
private BoxContainer CreateBoxContainerForTab(Dictionary<string, List<QuickPhrasePrototype>> groups) | ||
{ | ||
var boxContainer = new BoxContainer | ||
{ | ||
HorizontalExpand = true, | ||
Orientation = BoxContainer.LayoutOrientation.Vertical | ||
}; | ||
|
||
foreach (var group in groups) | ||
{ | ||
var header = CreateHeaderForGroup(group.Key); | ||
var buttonContainer = CreateButtonContainerForGroup(group.Value); | ||
boxContainer.AddChild(header); | ||
boxContainer.AddChild(buttonContainer); | ||
} | ||
|
||
return boxContainer; | ||
} | ||
|
||
private static Label CreateHeaderForGroup(string groupName) | ||
{ | ||
var header = new Label | ||
{ | ||
HorizontalExpand = true, | ||
Text = groupName, | ||
Margin = new Thickness(10, 10, 10, 0), | ||
StyleClasses = { "LabelBig" } | ||
}; | ||
|
||
return header; | ||
} | ||
|
||
private GridContainer CreateButtonContainerForGroup(List<QuickPhrasePrototype> phrases) | ||
{ | ||
var buttonContainer = CreateButtonContainer(); | ||
foreach (var phrase in phrases) | ||
{ | ||
var text = Loc.GetString(phrase.Text); | ||
var button = CreatePhraseButton(text, phrase.StyleClass); | ||
button.OnPressed += _ => OnPhraseButtonPressed(new ProtoId<QuickPhrasePrototype>(phrase.ID)); | ||
buttonContainer.AddChild(button); | ||
} | ||
return buttonContainer; | ||
} | ||
|
||
private static GridContainer CreateButtonContainer() | ||
{ | ||
var buttonContainer = new GridContainer | ||
{ | ||
Margin = new Thickness(10), | ||
Columns = 4 | ||
}; | ||
|
||
return buttonContainer; | ||
} | ||
|
||
private static Button CreatePhraseButton(string text, string styleClass) | ||
{ | ||
var phraseButton = new Button | ||
{ | ||
Access = AccessLevel.Public, | ||
MaxSize = new Vector2(ButtonWidth, ButtonWidth), | ||
ClipText = false, | ||
HorizontalExpand = true, | ||
StyleClasses = { styleClass } | ||
}; | ||
|
||
var buttonLabel = new RichTextLabel | ||
{ | ||
Margin = new Thickness(0, 5), | ||
StyleClasses = { "WhiteText" } | ||
}; | ||
|
||
buttonLabel.SetMessage(text); | ||
phraseButton.AddChild(buttonLabel); | ||
return phraseButton; | ||
} | ||
|
||
private void OnPhraseButtonPressed(ProtoId<QuickPhrasePrototype> phraseId) | ||
{ | ||
PhraseButtonPressed?.Invoke(phraseId); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Content.Client/DeltaV/CartridgeLoader/Cartridges/NanoChatLookupView.xaml
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,15 @@ | ||
<cartridges:NanoChatLookupView | ||
xmlns="https://spacestation14.io" | ||
xmlns:cartridges="clr-namespace:Content.Client.DeltaV.CartridgeLoader.Cartridges" | ||
HorizontalExpand="True" | ||
VerticalExpand="True" | ||
StyleClasses="AngleRect"> | ||
<ScrollContainer Margin="-10" | ||
VerticalExpand="True" | ||
HorizontalExpand="True"> | ||
<BoxContainer Name="ContactsList" | ||
Orientation="Vertical" | ||
VerticalExpand="True" | ||
HorizontalExpand="True" /> | ||
</ScrollContainer> | ||
</cartridges:NanoChatLookupView> |
73 changes: 73 additions & 0 deletions
73
Content.Client/DeltaV/CartridgeLoader/Cartridges/NanoChatLookupView.xaml.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,73 @@ | ||
using System.Numerics; | ||
using Content.Shared.DeltaV.CartridgeLoader.Cartridges; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client.DeltaV.CartridgeLoader.Cartridges; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class NanoChatLookupView : PanelContainer | ||
{ | ||
public NanoChatLookupView() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
} | ||
|
||
public event Action<NanoChatRecipient>? OnStartChat; | ||
|
||
public void UpdateContactList(NanoChatUiState state) | ||
{ | ||
ContactsList.RemoveAllChildren(); | ||
if (state.Contacts is not { } contacts) | ||
{ | ||
ContactsList.AddChild(new Label() { Text = Loc.GetString("nano-chat-look-up-no-server") }); | ||
return; | ||
} | ||
|
||
for (var idx = 0; idx < contacts.Count; idx++) | ||
{ | ||
var contact = contacts[idx]; | ||
var nameLabel = new Label() | ||
{ | ||
Text = contact.Name, | ||
HorizontalAlignment = HAlignment.Left, | ||
HorizontalExpand = true | ||
}; | ||
var numberLabel = new Label() | ||
{ | ||
Text = $"#{contacts[idx].Number:D4}", | ||
HorizontalAlignment = HAlignment.Right, | ||
Margin = new Thickness(0, 0, 36, 0), | ||
}; | ||
var startChatButton = new Button() | ||
{ | ||
Text = "+", | ||
HorizontalAlignment = HAlignment.Right, | ||
MinSize = new Vector2(32, 32), | ||
MaxSize = new Vector2(32, 32), | ||
ToolTip = Loc.GetString("nano-chat-new-chat"), | ||
}; | ||
startChatButton.AddStyleClass("OpenBoth"); | ||
if (contact.Number == state.OwnNumber || state.Recipients.ContainsKey(contact.Number) || state.MaxRecipients <= state.Recipients.Count) | ||
{ | ||
startChatButton.Disabled = true; | ||
} | ||
startChatButton.OnPressed += _ => OnStartChat?.Invoke(contact); | ||
|
||
var panel = new PanelContainer() | ||
{ | ||
HorizontalExpand = true, | ||
}; | ||
|
||
panel.AddChild(nameLabel); | ||
panel.AddChild(numberLabel); | ||
panel.AddChild(startChatButton); | ||
|
||
var styleClass = idx % 2 == 0 ? "PanelBackgroundBaseDark" : "PanelBackgroundLight"; | ||
panel.StyleClasses.Add(styleClass); | ||
|
||
ContactsList.AddChild(panel); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.