Skip to content
Merged
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
7 changes: 2 additions & 5 deletions VisualPinball.Engine/Game/Engines/GamelogicEngineCoil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class GamelogicEngineCoil : IGamelogicEngineDeviceItem
public virtual string Id { get => _id; set => _id = value; }
public virtual string Description { get => _description; set => _description = value; }

public int InternalId;
public string DeviceHint { get => _deviceHint; set => _deviceHint = value; }
public string DeviceItemHint { get => _deviceItemHint; set => _deviceItemHint = value; }
public int NumMatches { get => _numMatches; set => _numMatches = value; }
Expand All @@ -46,13 +45,11 @@ public class GamelogicEngineCoil : IGamelogicEngineDeviceItem
public GamelogicEngineCoil(string id)
{
Id = id;
InternalId = int.TryParse(id, out var internalId) ? internalId : 0;
}

public GamelogicEngineCoil(string id, int internalId)
public GamelogicEngineCoil(int id)
{
Id = id;
InternalId = internalId;
Id = id.ToString();
}
}
}
11 changes: 2 additions & 9 deletions VisualPinball.Engine/Game/Engines/GamelogicEngineLamp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ public class GamelogicEngineLamp : IGamelogicEngineDeviceItem
/// </summary>
public virtual string Description { get => _description; set => _description = value; }

/// <summary>
/// Some gamelogic engines use integers for the ID. In order to avoid repetitive casting, we store it as integer as well.
/// </summary>
public int InternalId;

/// <summary>
/// Which channel this lamp corresponds to.
/// </summary>
Expand Down Expand Up @@ -84,13 +79,11 @@ public class GamelogicEngineLamp : IGamelogicEngineDeviceItem
public GamelogicEngineLamp(string id)
{
Id = id;
InternalId = int.TryParse(id, out var internalId) ? internalId : 0;
}

public GamelogicEngineLamp(string id, int internalId)
public GamelogicEngineLamp(int id)
{
Id = id;
InternalId = internalId;
Id = id.ToString();
}
}

Expand Down
12 changes: 2 additions & 10 deletions VisualPinball.Engine/Game/Engines/GamelogicEngineSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ public class GamelogicEngineSwitch : IGamelogicEngineDeviceItem
/// </summary>
public virtual string Id { get => _id; set => _id = value; }

/// <summary>
/// A numerical identifier that can be used in gamelogic engines that
/// are tied to numerical identifiers.
/// </summary>
public int InternalId;

/// <summary>
/// If true, inverts the signal, i.e. disabled switches return "closed" (true),
/// while enabled switched return "open" (false).
Expand Down Expand Up @@ -76,13 +70,11 @@ public class GamelogicEngineSwitch : IGamelogicEngineDeviceItem
public GamelogicEngineSwitch(string id)
{
Id = id;
InternalId = int.TryParse(id, out var internalId) ? internalId : 0;
}

public GamelogicEngineSwitch(string id, int internalId)
public GamelogicEngineSwitch(int id)
{
Id = id;
InternalId = internalId;
Id = id.ToString();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public class CoilListData : IManagerListData, IDeviceListData<GamelogicEngineCoi
public string Element;

public string Id;
public int InternalId { get; set; }
public ICoilDeviceComponent Device;
public string DeviceItem { get; set; }

Expand All @@ -44,7 +43,6 @@ public class CoilListData : IManagerListData, IDeviceListData<GamelogicEngineCoi

public CoilListData(CoilMapping coilMapping) {
Id = coilMapping.Id;
InternalId = coilMapping.InternalId;
Description = coilMapping.Description;
Destination = coilMapping.Destination;
Device = coilMapping.Device;
Expand All @@ -61,7 +59,6 @@ public CoilListData(CoilMapping coilMapping) {
public void Update()
{
CoilMapping.Id = Id;
CoilMapping.InternalId = InternalId;
CoilMapping.Description = Description;
CoilMapping.Destination = Destination;
CoilMapping.Device = Device;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ private void RenderDestination(CoilListData coilListData, Rect cellRect, Action<
} else if (index == CoilDestination.Lamp) {
_tableComponent.MappingConfig.AddLamp(new LampMapping {
Id = coilListData.Id,
InternalId = coilListData.InternalId,
Source = LampSource.Lamp,
IsCoil = true,
Description = coilListData.Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ protected override void CloneData(string undoName, string newName, CoilListData
RecordUndo(undoName);
TableComponent.MappingConfig.AddCoil(new CoilMapping {
Id = data.Id,
InternalId = data.InternalId,
Description = data.Description,
Destination = data.Destination,
Device = data.Device,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public interface IDeviceListData<out T> where T : IGamelogicEngineDeviceItem
{
IDeviceComponent<T> DeviceComponent { get; }
string DeviceItem { get; set; }
int InternalId { get; set; }
string Description { get; set; }

void ClearDevice();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public class LampListData : IManagerListData, IDeviceListData<GamelogicEngineLam
[ManagerListColumn(Order = 0, HeaderName = "ID", Width = 135)]
public string Name => Id;

public int InternalId { get; set; }

[ManagerListColumn(Order = 1, HeaderName = "Description", Width = 300)]
public string Description { get; set; }

Expand Down Expand Up @@ -55,7 +53,6 @@ public class LampListData : IManagerListData, IDeviceListData<GamelogicEngineLam
public LampListData(LampMapping lampMapping)
{
Id = lampMapping.Id;
InternalId = lampMapping.InternalId;
IsCoil = lampMapping.IsCoil;
Source = lampMapping.Source;
Description = lampMapping.Description;
Expand All @@ -71,7 +68,6 @@ public LampListData(LampMapping lampMapping)
public void Update()
{
LampMapping.Id = Id;
LampMapping.InternalId = InternalId;
LampMapping.IsCoil = IsCoil;
LampMapping.Source = Source;
LampMapping.Description = Description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@ private void RenderCoilId(Dictionary<string, LampState> lampStatuses, LampListDa
EditorGUI.DrawTextureTransparent(iconRect, icon, ScaleMode.ScaleToFit);
GUI.color = guiColor;
}
cellRect.x += 20;
cellRect.width -= 20;

EditorGUI.LabelField(cellRect, lampListData.InternalId.ToString());
}

protected override void RenderDeviceElement(LampListData listData, Rect cellRect, Action<LampListData> updateAction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ protected override void CloneData(string undoName, string newName, LampListData

TableComponent.MappingConfig.AddLamp(new LampMapping {
Id = data.Id,
InternalId = data.InternalId,
Description = data.Description,
Device = data.Device,
DeviceItem = data.DeviceItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,21 @@ protected virtual void OnIconClick(TListData data, bool pressedDown)

protected void RenderId(Dictionary<string, TStatus> statuses, ref string id, Action<string> setId, TListData listData, Rect cellRect, Action<TListData> updateAction)
{
const float idWidth = 25f;
const float padding = 2f;

// add some padding
cellRect.x += padding;
cellRect.width -= 2 * padding;

var dropdownRect = cellRect;
dropdownRect.width -= idWidth + 2 * padding;

var idRect = cellRect;
idRect.width = idWidth;
idRect.x += cellRect.width - idWidth;


var options = new List<string>(GleItems.Select(entry => entry.Id).ToArray());
if (options.Count > 0) {
options.Add("");
}
options.Add("Add...");

if (Application.isPlaying && statuses != null) {

var iconRect = cellRect;
iconRect.width = 20;

Expand Down Expand Up @@ -108,13 +101,6 @@ protected void RenderId(Dictionary<string, TStatus> statuses, ref string id, Act
updateAction(listData);
}
}

EditorGUI.BeginChangeCheck();
var value = EditorGUI.IntField(idRect, listData.InternalId);
if (EditorGUI.EndChangeCheck()) {
listData.InternalId = value;
updateAction(listData);
}
}

protected void RenderDescription(TListData listData, Rect cellRect, Action<TListData> updateAction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ protected override IList<TreeViewItem> BuildRows(TreeViewItem root)
} else if (bVal == null) {
compareResult = -1;
} else {
compareResult = aVal.CompareTo(bVal);
if (aVal is string && bVal is string && int.TryParse((string)aVal, out int aNum) && int.TryParse((string)bVal, out int bNum)) {
compareResult = aNum.CompareTo(bNum);
}
else {
compareResult = aVal.CompareTo(bVal);
}
}
}
// not equal in this column, then return that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class SwitchListData : IManagerListData, IDeviceListData<GamelogicEngineS
public int PulseDelay;

public string Id;
public int InternalId { get; set; }
public string InputActionMap;
public string InputAction;
public SwitchConstant Constant;
Expand All @@ -53,7 +52,6 @@ public class SwitchListData : IManagerListData, IDeviceListData<GamelogicEngineS

public SwitchListData(SwitchMapping switchMapping) {
Id = switchMapping.Id;
InternalId = switchMapping.InternalId;
NormallyClosed = switchMapping.IsNormallyClosed;
Description = switchMapping.Description;
Source = switchMapping.Source;
Expand All @@ -76,7 +74,6 @@ public SwitchListData(SwitchMapping switchMapping) {
public void Update()
{
SwitchMapping.Id = Id;
SwitchMapping.InternalId = InternalId;
SwitchMapping.IsNormallyClosed = NormallyClosed;
SwitchMapping.Description = Description;
SwitchMapping.Source = Source;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ protected override void CloneData(string undoName, string newName, SwitchListDat

TableComponent.MappingConfig.AddSwitch(new SwitchMapping {
Id = data.Id,
InternalId = data.InternalId,
IsNormallyClosed = data.NormallyClosed,
Description = data.Description,
Source = data.Source,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public class WireListData : IManagerListData, IDeviceListData<IGamelogicEngineDe

public IDeviceComponent<IGamelogicEngineDeviceItem> DeviceComponent => DestinationDevice;
public string DeviceItem { get => DestinationDeviceItem; set => DestinationDeviceItem = value; }
public int InternalId { get; set; }

public WireListData(WireMapping wireMapping)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ public void ShouldCorrectlyPrintCoilInfo()
{
var coil = new CoilMapping {
Id = "c_left_flipper",
InternalId = 12,
Description = "Left Flipper"
};
coil.ToString().Should().Be("coil c_left_flipper (12) Left Flipper");
coil.ToString().Should().Be("coil c_left_flipper Left Flipper");
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
using System.Globalization;
using System.Text;
using NLog;
using NLog.LayoutRenderers.Wrappers;
using Unity.Mathematics;
using UnityEngine;
using Logger = NLog.Logger;
Expand Down Expand Up @@ -242,7 +241,6 @@ protected override Material CreateMaterial()

public override void UpdateFrame(DisplayFrameFormat format, byte[] source)
{
Debug.Log($"Getting segment data!");
ushort[] target;
switch (format) {
case DisplayFrameFormat.Dmd2:
Expand Down
2 changes: 1 addition & 1 deletion VisualPinball.Unity/VisualPinball.Unity/Game/CoilPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private void HandleCoilEvent(object sender, CoilEventArgs coilEvent)
}

if (destConfig.IsLampCoil) {
_lampPlayer!.HandleCoilEvent(coilEvent.Id, coilEvent.InternalId, coilEvent.IsEnabled);
_lampPlayer!.HandleCoilEvent(coilEvent.Id, coilEvent.IsEnabled);
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,6 @@ public readonly struct CoilEventArgs
/// </summary>
public readonly string Id;

/// Internal ID of the coil.
/// </summary>
public readonly int InternalId;

/// <summary>
/// State of the coil, true if the coil is under voltage, false if not.
/// </summary>
Expand All @@ -225,14 +221,6 @@ public readonly struct CoilEventArgs
public CoilEventArgs(string id, bool isEnabled)
{
Id = id;
InternalId = int.TryParse(id, out var internalId) ? internalId : 0;
IsEnabled = isEnabled;
}

public CoilEventArgs(string id, int internalId, bool isEnabled)
{
Id = id;
InternalId = internalId;
IsEnabled = isEnabled;
}
}
Expand All @@ -244,11 +232,6 @@ public readonly struct LampEventArgs
/// </summary>
public readonly string Id;

/// <summary>
/// Internal ID of the lamp. Some lamps have multiple internal IDs per ID, like RGBs.
/// </summary>
public readonly int InternalId;

/// <summary>
/// The intensity of the light. The range is dependent on the GLE,
/// i.e. PinMAME sends 0-255 or sometimes 0-8 for GI. MPF sends 0-1.
Expand All @@ -269,16 +252,6 @@ public readonly struct LampEventArgs
public LampEventArgs(string id, float value, LampSource source = LampSource.Lamp)
{
Id = id;
InternalId = int.TryParse(id, out var internalId) ? internalId : 0;
Value = value;
Source = source;
IsCoil = false;
}

public LampEventArgs(string id, int internalId, float value, LampSource source = LampSource.Lamp)
{
Id = id;
InternalId = internalId;
Value = value;
Source = source;
IsCoil = false;
Expand All @@ -287,7 +260,6 @@ public LampEventArgs(string id, int internalId, float value, LampSource source =
public LampEventArgs(string id, float value, bool isCoil, LampSource source = LampSource.Lamp)
{
Id = id;
InternalId = int.TryParse(id, out var internalId) ? internalId : 0;
Value = value;
Source = source;
IsCoil = isCoil;
Expand Down
Loading