Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/TheDenSS14/TheDen
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepyyapril committed Jan 28, 2025
2 parents 7634769 + 6d833ea commit cf682f5
Show file tree
Hide file tree
Showing 136 changed files with 20,472 additions and 89 deletions.
23 changes: 20 additions & 3 deletions Content.Client/Changelog/ChangelogWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.XAML;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Console;

namespace Content.Client.Changelog
{
[GenerateTypedNameReferences]
public sealed partial class ChangelogWindow : FancyWindow
{
[Dependency] private readonly IClientAdminManager _adminManager = default!;
[Dependency] private readonly ChangelogManager _changelog = default!;
[Dependency] private readonly IClientAdminManager _adminManager = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;

public ChangelogWindow()
{
Expand Down Expand Up @@ -67,8 +70,22 @@ private async void PopulateChangelog()
Tabs.SetTabTitle(i++, Loc.GetString($"changelog-tab-title-{changelog.Name}"));
}

var version = typeof(ChangelogWindow).Assembly.GetName().Version ?? new Version(1, 0);
VersionLabel.Text = Loc.GetString("changelog-version-tag", ("version", version.ToString()));
// Try to get the current version from the build.json file
var version = _cfg.GetCVar(CVars.BuildVersion);
var forkId = _cfg.GetCVar(CVars.BuildForkId);

var versionText = Loc.GetString("changelog-version-unknown");

// Make sure these aren't empty, like in a dev env
if (!string.IsNullOrEmpty(version) && !string.IsNullOrEmpty(forkId))
{
versionText = Loc.GetString("changelog-version-tag",
("fork", forkId),
("version", version[..7])); // Only show the first 7 characters
}

// if else statements are ugly, shut up
VersionLabel.Text = versionText;

TabsUpdated();
}
Expand Down
37 changes: 37 additions & 0 deletions Content.Client/DeltaV/AACTablet/UI/AACBoundUserInterface.cs
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();
}
}
9 changes: 9 additions & 0 deletions Content.Client/DeltaV/AACTablet/UI/AACWindow.xaml
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>
152 changes: 152 additions & 0 deletions Content.Client/DeltaV/AACTablet/UI/AACWindow.xaml.cs
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);
}
}
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>
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,33 @@
Margin="0 0 4 0"
StyleClasses="OpenBoth"
ToolTip="{Loc nano-chat-new-chat}" />
<Button Name="LookupButton"
MaxSize="32 32"
StyleClasses="OpenBoth"
Margin="0 0 4 0"
ToolTip="{Loc nano-chat-look-up}">
<TextureRect StyleClasses="ButtonSquare"
TexturePath="/Textures/Interface/VerbIcons/examine.svg.192dpi.png"
Stretch="KeepAspectCentered"
MinSize="18 18" />
</Button>
<Button Name="ListNumberButton"
MaxSize="32 32"
StyleClasses="OpenBoth"
Margin="0 0 4 0"
ToolTip="{Loc nano-chat-list-number}"
ToggleMode="True">
<TextureRect StyleClasses="ButtonSquare"
TexturePath="/Textures/DeltaV/Interface/VerbIcons/hamburger_icon.svg.png"
Stretch="KeepAspectCentered"
MinSize="18 18" />
</Button>
</BoxContainer>
</controls:StripeBack>

<!-- Main content split -->
<BoxContainer Orientation="Horizontal"
<BoxContainer Name="ChatView"
Orientation="Horizontal"
VerticalExpand="True"
HorizontalExpand="True"
Margin="0 5 0 0">
Expand Down Expand Up @@ -174,5 +196,7 @@
</BoxContainer>
</PanelContainer>
</BoxContainer>
<cartridges:NanoChatLookupView Name="LookupView"
Visible="False" />
</BoxContainer>
</cartridges:NanoChatUiFragment>
Loading

0 comments on commit cf682f5

Please sign in to comment.