Adds the NetProbe cartridge (#12543)

* Implement NetProbeCartridge

* Add audio and a popup when scanning a device
Add some doc comments

* Set program icon

* Add NetProbe cartridge as rare loot to maintenance loot tool spawner

* Make the maximum amount of saved entries configurable
Add a scrollbar that shows when there are more entries than fit on the screen

* Make device net id names translatable
This commit is contained in:
Julian Giebel
2022-11-13 22:36:00 +01:00
committed by GitHub
parent 4ec37c8bc0
commit 0df65e5c2a
11 changed files with 341 additions and 0 deletions

View File

@@ -1,3 +1,6 @@
using Content.Server.DeviceNetwork.Components;
using Robust.Shared.Utility;
namespace Content.Server.DeviceNetwork
{
/// <summary>
@@ -35,5 +38,37 @@ namespace Content.Server.DeviceNetwork
public const string StateEnabled = "state_enabled";
#endregion
#region DisplayHelpers
/// <summary>
/// Converts the unsigned int to string and inserts a number before the last digit
/// </summary>
public static string FrequencyToString(this uint frequency)
{
var result = frequency.ToString();
if (result.Length <= 2)
return result + ".0";
return result.Insert(result.Length - 1, ".");
}
/// <summary>
/// Either returns the localized name representation of the corresponding <see cref="DeviceNetworkComponent.DeviceNetIdDefaults"/>
/// or converts the id to string
/// </summary>
public static string DeviceNetIdToLocalizedName(this int id)
{
if (!Enum.IsDefined(typeof(DeviceNetworkComponent.DeviceNetIdDefaults), id))
return id.ToString();
var result = ((DeviceNetworkComponent.DeviceNetIdDefaults) id).ToString();
var resultKebab = "device-net-id-" + CaseConversion.PascalToKebab(result);
return !Loc.TryGetString(resultKebab, out var name) ? result : name;
}
#endregion
}
}