diff --git a/STROOP/Controls/VariablePanel/Cells/VariableAngleCell.cs b/STROOP/Controls/VariablePanel/Cells/VariableAngleCell.cs index 7ed6ef8ab..dab3d7115 100644 --- a/STROOP/Controls/VariablePanel/Cells/VariableAngleCell.cs +++ b/STROOP/Controls/VariablePanel/Cells/VariableAngleCell.cs @@ -6,6 +6,7 @@ namespace STROOP.Controls.VariablePanel.Cells; public class VariableAngleCell(VariableNumberCell baseCell) : VariableAngleCell(baseCell) + , INumberVariableCell where TNumber : struct, IConvertible { protected override bool DisplayAsUnsigned() => SavedSettingsConfig.DisplayYawAnglesAsUnsigned; diff --git a/STROOP/Controls/VariablePanel/VariablePanel.cs b/STROOP/Controls/VariablePanel/VariablePanel.cs index c11bf7d5a..2a6cc2ba1 100644 --- a/STROOP/Controls/VariablePanel/VariablePanel.cs +++ b/STROOP/Controls/VariablePanel/VariablePanel.cs @@ -34,8 +34,6 @@ static void ViewInMemoryTab(DescribedMemoryState memoryDescriptor) tab.UpdateHexDisplay(); } - private static int numDummies = 0; - public readonly Func> GetSelectedVars; public Func> getSpecialFuncVariables = null; @@ -411,19 +409,17 @@ private void AddToVarHackTab(List cells) private static CustomVariable CreateDummyVariable() where T : struct, IConvertible { - throw new NotImplementedException(); - // T capturedValue = default(T); - // - // return new CustomVariableView(VariableUtilities.GetWrapperType(typeof(T))) - // { - // Name = $"Dummy {++numDummies} {StringUtilities.Capitalize(typeof(T).Name)}", - // _getterFunction = () => capturedValue.Yield(), - // _setterFunction = (T value) => - // { - // capturedValue = value; - // return true.Yield(); - // } - // }; + T capturedValue = default(T); + + var variable = new CustomVariable("Number"); + variable.getter = () => capturedValue.Yield(); + variable.setter = value => + { + capturedValue = value; + return true.Yield(); + }; + + return variable; } private ToolStripMenuItem CreateFilterItem(string varGroup) diff --git a/STROOP/Utilities/VariableSelectionUtilities.cs b/STROOP/Utilities/VariableSelectionUtilities.cs index 1bf7e6407..da7f48168 100644 --- a/STROOP/Utilities/VariableSelectionUtilities.cs +++ b/STROOP/Utilities/VariableSelectionUtilities.cs @@ -27,7 +27,10 @@ static IEnumerable FilterNumberVariables(IEnumerable cells.OfType().Where(x => x is not IVariableCellData); static double GetNumberValue(this INumberVariableCell cell) - => (double)(Convert.ChangeType(cell.CombineValues().value, TypeCode.Double) ?? double.NaN); + { + var cellValue = cell.CombineValues().value; + return cellValue == null ? double.NaN : (double)(Convert.ChangeType(cellValue, TypeCode.Double)); + } static bool SetValue(this INumberVariableCell cell, double value) => cell.TrySetValue(value.ToString(CultureInfo.InvariantCulture));