Compare commits

...

7 Commits

Author SHA1 Message Date
Leon Friedrich
f8cb1729a3 Version: 210.1.0 2024-02-16 11:21:40 +13:00
Leon Friedrich
fd9d5c8aa8 Make ButtonGroup setter behaviour consistent with comment 2024-02-16 11:19:14 +13:00
Pieter-Jan Briers
4677296934 Add IsNoneSetAllowed mode to ButtonGroup.
This allows a button group to have no button pressed by default, which is the behavior of most radio buttons.
2024-02-15 01:16:33 +01:00
Pieter-Jan Briers
708f5dd376 Un-hardcode C:\Windows in MidiManager
Keeping an eye out for our bros who put Windows on a drive that isn't C:
2024-02-14 14:32:05 +01:00
Pieter-Jan Briers
4a06acda32 NetUserId implement ISelfSerialize
For @VasilisThePikachu
2024-02-14 01:08:38 +01:00
Pieter-Jan Briers
e7beb2032b Version: 210.0.3
This version changes nothing but I need it because I pushed the previous
version after amending it which means the tag is the wrong commit SORRY.
2024-02-13 16:11:47 +01:00
Pieter-Jan Briers
c7bd75f800 Version: 210.0.2 2024-02-13 16:06:28 +01:00
5 changed files with 66 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
<Project>
<!-- This file automatically reset by Tools/version.py -->
<Project>
<!-- This file automatically reset by Tools/version.py -->
<PropertyGroup><Version>210.1.0</Version></PropertyGroup>
</Project>

View File

@@ -54,6 +54,24 @@ END TEMPLATE-->
*None yet*
## 210.1.0
### New features
* `NetUserId` implements `ISelfSerialize` so can be used in data fields.
* `ButtonGroup.IsNoneSetAllowed` to allow a button group to have no buttons pressed by default.
## 210.0.3
## 210.0.2
### Bugfixes
* Revert changes to `TextureRect` too.
## 210.0.1
### Bugfixes

View File

@@ -114,7 +114,7 @@ internal sealed partial class MidiManager : IMidiManager
"/usr/share/sounds/sf2/TimGM6mb.sf2",
};
private const string WindowsSoundfont = @"C:\WINDOWS\system32\drivers\gm.dls";
private static readonly string WindowsSoundfont = $@"{Environment.GetEnvironmentVariable("SystemRoot")}\system32\drivers\gm.dls";
private const string OsxSoundfont =
"/System/Library/Components/CoreAudio.component/Contents/Resources/gs_instruments.dls";

View File

@@ -53,8 +53,17 @@ namespace Robust.Client.UserInterface.Controls
value.InternalButtons.Add(this);
ToggleMode = true;
// Set us to pressed if we're the first button. Doesn't go through the setter to avoid setting off our own error check.
_pressed = value.InternalButtons.Count == 1;
if (value.IsNoneSetAllowed)
{
// Still UNPRESS if there's another pressed button, but don't PRESS it otherwise.
if (value.Pressed != this)
_pressed = false;
}
else
{
// Set us to pressed if we're the first button. Doesn't go through the setter to avoid setting off our own error check.
_pressed = value.InternalButtons.Count == 1;
}
DrawModeChanged();
}
}
@@ -99,7 +108,7 @@ namespace Robust.Client.UserInterface.Controls
return;
}
if (!value && Group != null)
if (!value && Group is { IsNoneSetAllowed: false })
{
throw new InvalidOperationException("Cannot directly unset a grouped button. Set another button in the group instead.");
}
@@ -444,6 +453,26 @@ namespace Robust.Client.UserInterface.Controls
/// </remarks>
public sealed class ButtonGroup
{
/// <summary>
/// Whether it is legal for this button group to have no selected button.
/// </summary>
/// <remarks>
/// If true, it's legal for no button in the group to be active.
/// This is then the initial state of a new group of buttons (no button is automatically selected),
/// and it becomes legal to manually clear the active button through code.
/// The user cannot manually unselect the active button regardless, only by selecting a difference button.
/// </remarks>
public bool IsNoneSetAllowed { get; }
/// <summary>
/// Create a new <see cref="ButtonGroup"/>
/// </summary>
/// <param name="isNoneSetAllowed">The value of <see cref="IsNoneSetAllowed"/> on the new button group.</param>
public ButtonGroup(bool isNoneSetAllowed = false)
{
IsNoneSetAllowed = isNoneSetAllowed;
}
internal readonly List<BaseButton> InternalButtons = new();
public IReadOnlyList<BaseButton> Buttons => InternalButtons;

View File

@@ -4,7 +4,7 @@ using Robust.Shared.Serialization;
namespace Robust.Shared.Network
{
[Serializable, NetSerializable]
public struct NetUserId : IEquatable<NetUserId>
public struct NetUserId : IEquatable<NetUserId>, ISelfSerialize
{
public readonly Guid UserId;
@@ -32,5 +32,15 @@ namespace Robust.Shared.Network
public static implicit operator Guid(NetUserId id) => id.UserId;
public static explicit operator NetUserId(Guid id) => new(id);
void ISelfSerialize.Deserialize(string value)
{
this = (NetUserId) Guid.Parse(value);
}
string ISelfSerialize.Serialize()
{
return ToString();
}
}
}