-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init * refactor: move scale to tag argument * fix: chatbox rebuild fix * tweak: add icons for non-humanoid roles like ai and borgs * add: switch option for radio icons * blyat commit * fix
- Loading branch information
Showing
11 changed files
with
251 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Content.Client.UserInterface.Systems.Chat; | ||
using Content.Shared._Sunrise.SunriseCCVars; | ||
using Robust.Client.UserInterface; | ||
using Robust.Shared.Configuration; | ||
|
||
namespace Content.Client._Sunrise.ChatIcons; | ||
|
||
public sealed class ChatIconsSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IConfigurationManager _cfg = default!; | ||
[Dependency] private readonly IUserInterfaceManager _uiMan = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
_cfg.OnValueChanged(SunriseCCVars.ChatIconsEnable, OnRadioIconsChanged, true); | ||
} | ||
|
||
public override void Shutdown() | ||
{ | ||
base.Shutdown(); | ||
|
||
_cfg.UnsubValueChanged(SunriseCCVars.ChatIconsEnable, OnRadioIconsChanged); | ||
} | ||
|
||
private void OnRadioIconsChanged(bool enable) | ||
{ | ||
_uiMan.GetUIController<ChatUIController>().Repopulate(); | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
Content.Client/_Sunrise/UserInterface/RichText/RadioIconTag.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,100 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Numerics; | ||
using Content.Shared._Sunrise.SunriseCCVars; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.ResourceManagement; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.RichText; | ||
using Robust.Shared.Configuration; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Client._Sunrise.UserInterface.RichText; | ||
|
||
public sealed class RadioIconTag : IMarkupTag | ||
{ | ||
[Dependency] private readonly IConfigurationManager _cfg = default!; | ||
[Dependency] private readonly IResourceCache _cache = default!; | ||
|
||
public string Name => "radicon"; | ||
|
||
/// <inheritdoc/> | ||
public bool TryGetControl(MarkupNode node, [NotNullWhen(true)] out Control? control) | ||
{ | ||
if (_cfg.GetCVar(SunriseCCVars.ChatIconsEnable)) | ||
{ | ||
if (!node.Attributes.TryGetValue("path", out var rawPath)) | ||
{ | ||
control = null; | ||
return false; | ||
} | ||
|
||
if (!node.Attributes.TryGetValue("scale", out var scale) || !scale.TryGetLong(out var scaleValue)) | ||
{ | ||
scaleValue = 1; | ||
} | ||
|
||
control = DrawIcon(rawPath.ToString(), scaleValue.Value); | ||
} | ||
else | ||
{ | ||
if (!node.Attributes.TryGetValue("text", out var text)) | ||
{ | ||
control = null; | ||
return false; | ||
} | ||
|
||
if (!node.Attributes.TryGetValue("color", out var color)) | ||
{ | ||
control = null; | ||
return false; | ||
} | ||
|
||
control = DrawText(text.ToString(), color.ToString()); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private Control DrawIcon(string path, long scaleValue) | ||
{ | ||
var texture = new TextureRect(); | ||
|
||
path = ClearString(path); | ||
|
||
texture.TexturePath = path; | ||
texture.TextureScale = new Vector2(scaleValue, scaleValue); | ||
|
||
return texture; | ||
} | ||
|
||
private Control DrawText(string text, string color) | ||
{ | ||
var label = new Label(); | ||
|
||
color = ClearString(color); | ||
text = ClearString(text); | ||
|
||
label.Text = text; | ||
label.FontColorOverride = Color.FromHex(color); | ||
label.FontOverride = new VectorFont(_cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Bold.ttf"), 13); | ||
|
||
return label; | ||
} | ||
|
||
/// <summary> | ||
/// Очищает строку от мусора, который приходит вместе с ней | ||
/// </summary> | ||
/// <remarks> | ||
/// Почему мне приходят строки в говне | ||
/// </remarks> | ||
private static string ClearString(string str) | ||
{ | ||
str = str.Replace("=", ""); | ||
str = str.Replace(" ", ""); | ||
str = str.Replace("\"", ""); | ||
|
||
return str; | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
Content.Client/_Sunrise/UserInterface/RichText/TextureTag.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,42 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Numerics; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.RichText; | ||
|
||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Client._Sunrise.UserInterface.RichText; | ||
|
||
public sealed class TextureTag : IMarkupTag | ||
{ | ||
public string Name => "tex"; | ||
|
||
/// <inheritdoc/> | ||
public bool TryGetControl(MarkupNode node, [NotNullWhen(true)] out Control? control) | ||
{ | ||
if (!node.Attributes.TryGetValue("path", out var rawPath)) | ||
{ | ||
control = null; | ||
return false; | ||
} | ||
|
||
if (!node.Attributes.TryGetValue("scale", out var scale) || !scale.TryGetLong(out var scaleValue)) | ||
{ | ||
scaleValue = 1; | ||
} | ||
|
||
var texture = new TextureRect(); | ||
|
||
var path = rawPath.ToString(); | ||
path = path.Replace("=", ""); | ||
path = path.Replace(" ", ""); | ||
path = path.Replace("\"", ""); | ||
|
||
texture.TexturePath = path; | ||
texture.TextureScale = new Vector2(scaleValue.Value, scaleValue.Value); | ||
|
||
control = texture; | ||
return true; | ||
} | ||
} |
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,2 @@ | ||
radio-icon-tag-short = [radicon path="{$path}" text="{$text}" color="{$color}"] | ||
radio-icon-tag = [radicon path="{$path}" scale={$scale} text="{$text}" color="{$color}"] |
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,2 @@ | ||
texture-tag-short = [tex path="{$path}"] | ||
texture-tag = [tex path="{$path}" scale={$scale}] |