Skip to content

Commit 80e47b6

Browse files
authored
Синхронизация кз на вики и кз в гайдбуке игры (corvax-team#364)
* исправлена лишняя статья про вульп в гайдбуке * все остальное... * правки
1 parent c531778 commit 80e47b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2184
-143
lines changed

Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public sealed partial class GuidebookWindow : FancyWindow, ILinkClickHandler, IA
2020
{
2121
[Dependency] private readonly DocumentParsingManager _parsingMan = default!;
2222
[Dependency] private readonly IResourceManager _resourceManager = default!;
23+
// WL-Changes-start
24+
[Dependency] private readonly IUriOpener _uriOpener = default!;
25+
// WL-Changes-end
2326

2427
private Dictionary<ProtoId<GuideEntryPrototype>, GuideEntry> _entries = new();
2528

@@ -43,16 +46,35 @@ public GuidebookWindow()
4346

4447
public void HandleClick(string link)
4548
{
46-
if (!_entries.TryGetValue(link, out var entry))
47-
return;
49+
// WL-Changes-start
50+
if (_entries.TryGetValue(link, out var entry))
51+
{
4852

49-
if (Tree.TryGetIndexFromMetadata(entry, out var index))
53+
if (Tree.TryGetIndexFromMetadata(entry, out var index))
54+
{
55+
Tree.ExpandParentEntries(index.Value);
56+
Tree.SetSelectedIndex(index);
57+
}
58+
else
59+
ShowGuide(entry);
60+
}
61+
else if (link.StartsWith("http://", StringComparison.OrdinalIgnoreCase) ||
62+
link.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
5063
{
51-
Tree.ExpandParentEntries(index.Value);
52-
Tree.SetSelectedIndex(index);
64+
try
65+
{
66+
_uriOpener.OpenUri(link);
67+
}
68+
catch (Exception exc)
69+
{
70+
_sawmill.Error($"Failed to open URI '{link}': {exc.Message}");
71+
}
5372
}
5473
else
55-
ShowGuide(entry);
74+
{
75+
_sawmill.Warning($"Guidebook link to unknown entry: {link}");
76+
}
77+
// WL-Changes-end
5678
}
5779

5880
public void HandleAnchor(IPrototypeLinkControl prototypeLinkControl)

Content.Client/Guidebook/Richtext/TextLinkTag.cs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Diagnostics.CodeAnalysis;
1+
using System.Diagnostics.CodeAnalysis;
22
using JetBrains.Annotations;
33
using Robust.Client.UserInterface;
44
using Robust.Client.UserInterface.Controls;
@@ -19,24 +19,34 @@ public sealed class TextLinkTag : IMarkupTagHandler
1919
/// <inheritdoc/>
2020
public bool TryCreateControl(MarkupNode node, [NotNullWhen(true)] out Control? control)
2121
{
22-
if (!node.Value.TryGetString(out var text)
23-
|| !node.Attributes.TryGetValue("link", out var linkParameter)
24-
|| !linkParameter.TryGetString(out var link))
25-
{
26-
control = null;
22+
// WL-Changes-start
23+
control = null;
24+
25+
if (!node.Value.TryGetString(out var text))
2726
return false;
28-
}
2927

30-
var label = new Label();
31-
label.Text = text;
28+
var label = new RichTextLabel()
29+
{
30+
MouseFilter = Control.MouseFilterMode.Stop,
31+
DefaultCursorShape = Control.CursorShape.Hand,
32+
Margin = new Thickness(1),
33+
HorizontalExpand = true,
34+
VerticalExpand = true,
35+
};
36+
37+
label.SetMessage(text, defaultColor: LinkColor);
38+
39+
label.OnMouseEntered += _ => label.SetMessage(text, defaultColor: Color.LightSkyBlue);
40+
label.OnMouseExited += _ => label.SetMessage(text, defaultColor: Color.CornflowerBlue);
3241

33-
label.MouseFilter = Control.MouseFilterMode.Stop;
34-
label.FontColorOverride = LinkColor;
35-
label.DefaultCursorShape = Control.CursorShape.Hand;
42+
if (node.Attributes.TryGetValue("tip", out var tipParameter) &&
43+
tipParameter.TryGetString(out var tipText))
44+
label.ToolTip = tipText;
3645

37-
label.OnMouseEntered += _ => label.FontColorOverride = Color.LightSkyBlue;
38-
label.OnMouseExited += _ => label.FontColorOverride = Color.CornflowerBlue;
39-
label.OnKeyBindDown += args => OnKeybindDown(args, link, label);
46+
if (node.Attributes.TryGetValue("link", out var linkParameter) &&
47+
linkParameter.TryGetString(out var link))
48+
label.OnKeyBindDown += args => OnKeybindDown(args, link, label);
49+
// WL-Changes-end
4050

4151
control = label;
4252
return true;
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
using Content.Client.Administration.UI.CustomControls;
2+
using Content.Client.Guidebook.Richtext;
3+
using JetBrains.Annotations;
4+
using Robust.Client.Graphics;
5+
using Robust.Client.UserInterface;
6+
using Robust.Client.UserInterface.Controls;
7+
using Robust.Shared.Utility;
8+
using System.Diagnostics.CodeAnalysis;
9+
using System.Numerics;
10+
11+
namespace Content.Client._WL.Guidebook.RichText.InfoControls;
12+
13+
[UsedImplicitly]
14+
public abstract class BaseInfoControl : PanelContainer, IDocumentTag
15+
{
16+
protected abstract ResPath InfoTexturePath { get; }
17+
protected abstract Color DefaultControlColor { get; }
18+
protected abstract LocId TitleLocalizationKey { get; }
19+
protected virtual float TextureInterpolateBetweenFactor => 0.2f;
20+
protected virtual Vector2 TextureScale => new(0.5f);
21+
22+
private PanelContainer? _rightFooterPanel;
23+
private Control? _mainBox;
24+
private bool _suppressChildAdded;
25+
26+
public virtual bool TryParseTag(Dictionary<string, string> args, [NotNullWhen(true)] out Control? control)
27+
{
28+
HorizontalExpand = true;
29+
30+
_suppressChildAdded = true;
31+
32+
var controlColor = DefaultControlColor;
33+
if (args.TryGetValue("Color", out var color))
34+
controlColor = Color.FromHex(color);
35+
36+
_mainBox = new BoxContainer()
37+
{
38+
Orientation = BoxContainer.LayoutOrientation.Horizontal,
39+
HorizontalExpand = true,
40+
Margin = new Thickness(10, 10, 10, 15),
41+
};
42+
43+
var leftSeparator = new VSeparator(controlColor);
44+
leftSeparator.MinSize = new Vector2(4, 5);
45+
46+
var rightContentBox = new BoxContainer()
47+
{
48+
Orientation = BoxContainer.LayoutOrientation.Vertical,
49+
HorizontalExpand = true
50+
};
51+
52+
var rightContentTitlePanel = new PanelContainer()
53+
{
54+
HorizontalExpand = true,
55+
};
56+
57+
var rightContentTitleBackground = new PanelContainer()
58+
{
59+
HorizontalExpand = true,
60+
PanelOverride = new StyleBoxFlat
61+
{
62+
BackgroundColor = controlColor.WithAlpha(0.5f),
63+
}
64+
};
65+
66+
var rightContentTitleBox = new BoxContainer()
67+
{
68+
Orientation = BoxContainer.LayoutOrientation.Horizontal,
69+
HorizontalExpand = true,
70+
Margin = new Thickness(5, 0, 0, 0)
71+
};
72+
73+
var infoTexture = new TextureButton
74+
{
75+
Modulate = Color.InterpolateBetween(controlColor, Color.White, TextureInterpolateBetweenFactor),
76+
HorizontalAlignment = HAlignment.Left,
77+
VerticalAlignment = VAlignment.Center,
78+
TexturePath = InfoTexturePath.CanonPath,
79+
Scale = TextureScale,
80+
Margin = new Thickness(0, 3)
81+
};
82+
83+
var rightContentTitleLabel = new RichTextLabel()
84+
{
85+
Text = Loc.GetString(TitleLocalizationKey),
86+
HorizontalAlignment = HAlignment.Left,
87+
VerticalAlignment = VAlignment.Center,
88+
Margin = new Thickness(6, 0)
89+
};
90+
91+
_rightFooterPanel = new PanelContainer()
92+
{
93+
HorizontalExpand = true,
94+
Margin = new Thickness(5, 1, 1, 1)
95+
};
96+
97+
rightContentTitleBox.AddChild(infoTexture);
98+
rightContentTitleBox.AddChild(rightContentTitleLabel);
99+
100+
rightContentTitlePanel.AddChild(rightContentTitleBackground);
101+
rightContentTitlePanel.AddChild(rightContentTitleBox);
102+
103+
rightContentBox.AddChild(rightContentTitlePanel);
104+
rightContentBox.AddChild(_rightFooterPanel);
105+
106+
_mainBox.AddChild(leftSeparator);
107+
_mainBox.AddChild(rightContentBox);
108+
109+
AddChild(_mainBox);
110+
111+
_suppressChildAdded = false;
112+
113+
control = this;
114+
return true;
115+
}
116+
117+
protected override void ChildAdded(Control newChild)
118+
{
119+
base.ChildAdded(newChild);
120+
121+
if (_suppressChildAdded)
122+
return;
123+
124+
if (newChild == _mainBox)
125+
return;
126+
127+
if (_rightFooterPanel == null)
128+
return;
129+
130+
newChild.Orphan();
131+
_rightFooterPanel.AddChild(newChild);
132+
}
133+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using JetBrains.Annotations;
2+
using Robust.Shared.Utility;
3+
using System.Numerics;
4+
5+
namespace Content.Client._WL.Guidebook.RichText.InfoControls;
6+
7+
[UsedImplicitly]
8+
public sealed class Note : BaseInfoControl
9+
{
10+
protected override ResPath InfoTexturePath => new("/Textures/Interface/Nano/help.png");
11+
12+
protected override Color DefaultControlColor => Color.FromHex("#154884");
13+
14+
protected override LocId TitleLocalizationKey => "guidebook-info-control-note";
15+
16+
protected override Vector2 TextureScale => new(1.1f, 1.1f);
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using JetBrains.Annotations;
2+
using Robust.Shared.Utility;
3+
4+
namespace Content.Client._WL.Guidebook.RichText.InfoControls;
5+
6+
[UsedImplicitly]
7+
public sealed class Warning : BaseInfoControl
8+
{
9+
protected override ResPath InfoTexturePath => new("/Textures/Interface/info.svg.192dpi.png");
10+
protected override Color DefaultControlColor => Color.FromHex("#914416");
11+
protected override LocId TitleLocalizationKey => "guidebook-info-control-warning";
12+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
guidebook-info-control-note = [bold]Примечание[/bold]
2+
guidebook-info-control-warning = [bold]Предупреждение[/bold]

0 commit comments

Comments
 (0)