diff --git a/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml b/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml index fd5a7bb161..0371e427fa 100644 --- a/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml +++ b/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml @@ -43,14 +43,12 @@ MinSize="0 0" SizeFlagsStretchRatio="2" VerticalExpand="True"> - + + + + - + diff --git a/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml.cs b/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml.cs index f76adfb866..a3b4a1acdb 100644 --- a/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml.cs +++ b/Content.Client/CartridgeLoader/Cartridges/NewsReaderUiFragment.xaml.cs @@ -1,18 +1,24 @@ +using Content.Client._Sunrise.UserInterface.CustomControls; using Content.Client.Message; using Content.Client.RichText; -using Content.Client.UserInterface.RichText; using Content.Shared.MassMedia.Systems; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.Controls; -using Robust.Client.UserInterface.RichText; using Robust.Client.UserInterface.XAML; using Robust.Shared.Utility; +using Content.Client._Sunrise; +using Robust.Client.ResourceManagement; +using Robust.Client.Graphics; +using Robust.Client.UserInterface; namespace Content.Client.CartridgeLoader.Cartridges; [GenerateTypedNameReferences] public sealed partial class NewsReaderUiFragment : BoxContainer { + [Dependency] private readonly NetTexturesManager _netTexturesManager = default!; + [Dependency] private readonly IResourceCache _resourceCache = default!; + public event Action? OnNextButtonPressed; public event Action? OnPrevButtonPressed; @@ -21,6 +27,7 @@ public sealed partial class NewsReaderUiFragment : BoxContainer public NewsReaderUiFragment() { RobustXamlLoader.Load(this); + IoCManager.InjectDependencies(this); Next.OnPressed += _ => OnNextButtonPressed?.Invoke(); Prev.OnPressed += _ => OnPrevButtonPressed?.Invoke(); @@ -47,6 +54,81 @@ public sealed partial class NewsReaderUiFragment : BoxContainer var author = Loc.GetString("news-read-ui-author-prefix") + " " + (article.Author ?? Loc.GetString("news-read-ui-no-author")); Author.SetMessage(FormattedMessage.FromMarkupPermissive(author), UserFormattableTags.BaseAllowedTags); + // Sunrise-Start + ArticlePhotosContainer.Children.Clear(); + if (article.PhotoPaths != null) + { + foreach (var path in article.PhotoPaths) + { + var photoButton = new ContainerButton + { + HorizontalExpand = true, + Margin = new Thickness(0, 4), + DefaultCursorShape = Control.CursorShape.Hand + }; + + var border = new PanelContainer + { + HorizontalExpand = true, + PanelOverride = new StyleBoxFlat + { + BackgroundColor = Color.Transparent, + BorderColor = Color.Transparent, + BorderThickness = new Thickness(2) + } + }; + + var textureRect = new TextureRect + { + HorizontalExpand = true, + Stretch = TextureRect.StretchMode.KeepAspectCentered, + MinHeight = 150 + }; + + border.AddChild(textureRect); + photoButton.AddChild(border); + ArticlePhotosContainer.AddChild(photoButton); + + photoButton.OnPressed += _ => PhotoPreviewWindow.Open(textureRect.Texture); + + photoButton.OnMouseEntered += _ => + { + if (border.PanelOverride is StyleBoxFlat style) + { + style.BorderColor = Color.White.WithAlpha(0.4f); + } + }; + + photoButton.OnMouseExited += _ => + { + if (border.PanelOverride is StyleBoxFlat style) + { + style.BorderColor = Color.Transparent; + } + }; + + if (_netTexturesManager.EnsureResource(path)) + { + var uploaded = _netTexturesManager.GetUploadedPath(path); + if (_resourceCache.TryGetResource(uploaded, out var tex)) + textureRect.Texture = tex.Texture; + } + else + { + void OnLoaded(string loadedPath) + { + if (loadedPath != path) return; + var uploaded = _netTexturesManager.GetUploadedPath(path); + if (_resourceCache.TryGetResource(uploaded, out var tex)) + textureRect.Texture = tex.Texture; + _netTexturesManager.ResourceLoaded -= OnLoaded; + } + _netTexturesManager.ResourceLoaded += OnLoaded; + } + } + } + // Sunrise-End + Prev.Disabled = targetNum <= 1; Next.Disabled = targetNum >= totalNum; } diff --git a/Content.Client/Lobby/UI/LobbyGui.xaml.cs b/Content.Client/Lobby/UI/LobbyGui.xaml.cs index b6a6ed861c..c8dcb7698a 100644 --- a/Content.Client/Lobby/UI/LobbyGui.xaml.cs +++ b/Content.Client/Lobby/UI/LobbyGui.xaml.cs @@ -154,6 +154,7 @@ namespace Content.Client.Lobby.UI _configurationManager.OnValueChanged(SunriseCCVars.ServerName, OnServerNameChanged, true); Chat.SetChatOpacity(); + Chat.ToggleEmojiButton(true); // Sunrise-Add ServerName.Text = Loc.GetString("ui-lobby-welcome", ("name", _serverName)); LoadIcons(); diff --git a/Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml b/Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml index d12b90918b..480ac024f0 100644 --- a/Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml +++ b/Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml @@ -40,6 +40,24 @@ + + +