Adds Gas Analyzer (#1591)
* -Started Gas Analyzer -TemperatureHelpers * Formatting * Adds PopupTooltip to NotifyManager * Revert Tooltip fuckery * Gas Analyzer gives proper error messages * Localization * Added a very wip gas analyzer ui * UI works, doesn't look good but hey * Safety checks * Fancy WIP gas mix bar * Gas Color * Gas Amount shows only 2 decimal places * -Made bar full width -Moved gas list into a table -Some gas bar things * IDropped something * Description * -Percentage -Padding * ItemStatus * -Proper Danger Warnings -Added Warning danger state * Pressure unit Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
This commit is contained in:
@@ -69,6 +69,8 @@ namespace Content.Shared.Atmos
|
||||
/// </summary>
|
||||
public string OverlayPath { get; private set; }
|
||||
|
||||
public string Color { get; private set; }
|
||||
|
||||
public void LoadFrom(YamlMappingNode mapping)
|
||||
{
|
||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||
@@ -81,6 +83,7 @@ namespace Content.Shared.Atmos
|
||||
serializer.DataField(this, x => GasOverlayTexture, "gasOverlayTexture", string.Empty);
|
||||
serializer.DataField(this, x => GasOverlaySprite, "gasOverlaySprite", string.Empty);
|
||||
serializer.DataField(this, x => GasOverlayState, "gasOverlayState", string.Empty);
|
||||
serializer.DataField(this, x => Color, "color", string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Content.Shared.GameObjects.Components
|
||||
{
|
||||
public class SharedGasAnalyzerComponent : Component
|
||||
{
|
||||
public override string Name => "GasAnalyzer";
|
||||
public override uint? NetID => ContentNetIDs.GAS_ANALYZER;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum GasAnalyzerUiKey
|
||||
{
|
||||
Key,
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class GasAnalyzerBoundUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public float Pressure;
|
||||
public float Temperature;
|
||||
public GasEntry[] Gases;
|
||||
public string Error;
|
||||
|
||||
public GasAnalyzerBoundUserInterfaceState(float pressure, float temperature, GasEntry[] gases, string error = null)
|
||||
{
|
||||
Pressure = pressure;
|
||||
Temperature = temperature;
|
||||
Gases = gases;
|
||||
Error = error;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public struct GasEntry
|
||||
{
|
||||
public readonly string Name;
|
||||
public readonly float Amount;
|
||||
public readonly string Color;
|
||||
|
||||
public GasEntry(string name, float amount, string color)
|
||||
{
|
||||
Name = name;
|
||||
Amount = amount;
|
||||
Color = color;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Loc.GetString("{0}: {1:0.##} mol", Name, Amount);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class GasAnalyzerRefreshMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public GasAnalyzerRefreshMessage() {}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum GasAnalyzerDanger
|
||||
{
|
||||
Nominal,
|
||||
Warning,
|
||||
Hazard
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class GasAnalyzerComponentState : ComponentState
|
||||
{
|
||||
public GasAnalyzerDanger Danger;
|
||||
|
||||
public GasAnalyzerComponentState(GasAnalyzerDanger danger) : base(ContentNetIDs.GAS_ANALYZER)
|
||||
{
|
||||
Danger = danger;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,8 @@
|
||||
public const uint THROWN_ITEM = 1054;
|
||||
public const uint STRAP = 1055;
|
||||
public const uint DISPOSABLE = 1056;
|
||||
public const uint DO_AFTER = 1057;
|
||||
public const uint GAS_ANALYZER = 1057;
|
||||
public const uint DO_AFTER = 1058;
|
||||
|
||||
// Net IDs for integration tests.
|
||||
public const uint PREDICTION_TEST = 10001;
|
||||
|
||||
20
Content.Shared/Utility/TemperatureHelpers.cs
Normal file
20
Content.Shared/Utility/TemperatureHelpers.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Content.Shared.Maths;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Content.Shared.Utility
|
||||
{
|
||||
public static class TemperatureHelpers
|
||||
{
|
||||
public static float CelsiusToKelvin(float celsius)
|
||||
{
|
||||
return celsius + PhysicalConstants.ZERO_CELCIUS;
|
||||
}
|
||||
|
||||
public static float KelvinToCelsius(float kelvin)
|
||||
{
|
||||
return kelvin - PhysicalConstants.ZERO_CELCIUS;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user