Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Setup .NET SDK
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- name: Setup .NET SDK
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Rampastring.XNAUI"]
path = Rampastring.XNAUI
url = ../../Rampastring/Rampastring.XNAUI.git
7 changes: 4 additions & 3 deletions ClientCore/ClientCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
<EmbeddedResource Include="Resources\*.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Rampastring.Tools" />
<PackageReference Include="Rampastring.XNAUI.$(Engine)" Condition="'!$(Configuration.Contains(Debug))'" />
<PackageReference Include="Rampastring.XNAUI.$(Engine).Debug" Condition="'$(Configuration.Contains(Debug))'" />
<PackageReference Include="System.Text.Encoding.CodePages" />
<PackageReference Include="Ude.NetStandard" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Rampastring.XNAUI\Rampastring.Tools\Rampastring.Tools.csproj" />
<ProjectReference Include="..\Rampastring.XNAUI\Rampastring.XNAUI.csproj" />
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions ClientGUI/ICompositeControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;

using Rampastring.XNAUI.XNAControls;

namespace ClientGUI;

/// <summary>
/// Indicates that the implementer has sub-controls that need to be exposed to INI system.
/// </summary>
public interface ICompositeControl
{
/// <summary>
/// The sub-controls that are exposed to the INI system.
/// </summary>
/// <remarks>
/// All the sub-controls should have their names set to something
/// unique to each composite control. Utilise <see cref="XNAControl.NameChanged"/>
/// event to set the names of the sub-controls.
/// </remarks>
IReadOnlyList<XNAControl> SubControls { get; }
}
39 changes: 31 additions & 8 deletions ClientGUI/INItializableWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,6 @@ private void ParseExtraControls()
}
}

private void ReadINIRecursive(XNAControl control)
{
ReadINIForControl(control);

foreach (var child in control.Children)
ReadINIRecursive(child);
}

protected override void ParseControlINIAttribute(IniFile iniFile, string key, string value)
{
if (key == "HasCloseButton")
Expand Down Expand Up @@ -178,6 +170,15 @@ static string Localize(XNAControl control, string attributeName, string defaultV
var child = CreateChildControl(control, kvp.Value);
ReadINIForControl(child);
child.Initialize();

if (child is ICompositeControl composite)
{
foreach (var sc in composite.SubControls)
{
ReadINIForControl(sc);
sc.Initialize();
}
}
}
else if (kvp.Key == "$X")
{
Expand Down Expand Up @@ -211,6 +212,28 @@ static string Localize(XNAControl control, string attributeName, string defaultV
throw new FormatException("Invalid format for AnchorPoint: " + kvp.Value);
((XNALabel)control).AnchorPoint = new Vector2(Parser.Instance.GetExprValue(parts[0], control), Parser.Instance.GetExprValue(parts[1], control));
}
else if (kvp.Key == "$OverscrollMargin" && control is XNAScrollPanel scrollPanel)
{
string[] parts = kvp.Value.Split(',');
(int X, int Y) values = parts
.Select(s => Parser.Instance.GetExprValue(s, control))
.ToArray().AsTuple2();
scrollPanel.OverscrollMargin = new(values.X, values.Y);
}
else if (kvp.Key == "$OverscrollMarginX" && control is XNAScrollPanel scrollPanel1)
{
scrollPanel1.OverscrollMargin = scrollPanel1.OverscrollMargin with
{
X = Parser.Instance.GetExprValue(kvp.Value, control)
};
}
else if (kvp.Key == "$OverscrollMarginY" && control is XNAScrollPanel scrollPanel2)
{
scrollPanel2.OverscrollMargin = scrollPanel2.OverscrollMargin with
{
Y = Parser.Instance.GetExprValue(kvp.Value, control)
};
}
else if (kvp.Key == "$LeftClickAction")
{
if (kvp.Value == "Disable")
Expand Down
2 changes: 1 addition & 1 deletion ClientGUI/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private string GetIdentifier()
if (char.IsWhiteSpace(c))
break;

if (!char.IsLetterOrDigit(c) && c != '_' && c != '$')
if (!char.IsLetterOrDigit(c) && c != '_' && c != '$' && c != '.')
break;

identifierName += c.ToString();
Expand Down
5 changes: 3 additions & 2 deletions ClientGUI/XNAClientDropDown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ protected override void ParseControlINIAttribute(IniFile iniFile, string key, st
base.ParseControlINIAttribute(iniFile, key, value);
}

public override void OnMouseLeftDown()
public override void OnMouseLeftDown(InputEventArgs inputEventArgs)
{
base.OnMouseLeftDown();
// no need to set Handled to true since we're not "consuming" the event here, just augmenting
base.OnMouseLeftDown(inputEventArgs);
UpdateToolTipBlock();
}

Expand Down
6 changes: 4 additions & 2 deletions ClientGUI/XNAClientLinkLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ public override void OnMouseLeave()
TextColor = IdleColor;
}

public override void OnLeftClick()
public override void OnLeftClick(InputEventArgs inputEventArgs)
{
inputEventArgs.Handled = true;

ClickSoundEffect?.Play();

OSVersion osVersion = ClientConfiguration.Instance.GetOperatingSystemVersion();
Expand All @@ -110,7 +112,7 @@ public override void OnLeftClick()
else if (!string.IsNullOrEmpty(URL))
ProcessLauncher.StartShellProcess(URL);

base.OnLeftClick();
base.OnLeftClick(inputEventArgs);
}
}
}
24 changes: 24 additions & 0 deletions ClientGUI/XNAClientScrollPanel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System.Collections.Generic;

using Rampastring.XNAUI;
using Rampastring.XNAUI.XNAControls;

namespace ClientGUI;

public class XNAClientScrollPanel : XNAScrollPanel, ICompositeControl
{
public IReadOnlyList<XNAControl> SubControls
=> [ContentPanel, HorizontalScrollBar, VerticalScrollBar, CornerPanel];

public XNAClientScrollPanel(WindowManager windowManager) : base(windowManager) { }

protected override void ComposeControls()
{
// this is needed for the control composition to work properly, as otherwise
// the controls will be initialized twice via INItializableWindow system
AddChildWithoutInitialize(ContentPanel);
AddChildWithoutInitialize(HorizontalScrollBar);
AddChildWithoutInitialize(VerticalScrollBar);
AddChildWithoutInitialize(CornerPanel);
}
}
6 changes: 4 additions & 2 deletions ClientGUI/XNALinkButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ protected override void ParseControlINIAttribute(IniFile iniFile, string key, st
base.ParseControlINIAttribute(iniFile, key, value);
}

public override void OnLeftClick()
public override void OnLeftClick(InputEventArgs inputEventArgs)
{
inputEventArgs.Handled = true;

OSVersion osVersion = ClientConfiguration.Instance.GetOperatingSystemVersion();

if (osVersion == OSVersion.UNIX && !string.IsNullOrEmpty(UnixURL))
ProcessLauncher.StartShellProcess(UnixURL, Arguments);
else if (!string.IsNullOrEmpty(URL))
ProcessLauncher.StartShellProcess(URL, Arguments);

base.OnLeftClick();
base.OnLeftClick(inputEventArgs);
}
}
}
1 change: 0 additions & 1 deletion ClientUpdater/ClientUpdater.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" />
<PackageReference Include="Rampastring.Tools" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ClientCore\ClientCore.csproj" />
Expand Down
Loading
Loading