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
1 change: 1 addition & 0 deletions STROOP/Controls/VariablePanel/Cells/VariableAngleCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace STROOP.Controls.VariablePanel.Cells;

public class VariableAngleCell<TNumber>(VariableNumberCell<TNumber> baseCell)
: VariableAngleCell<WinFormsVariablePanelUiContext, TNumber>(baseCell)
, INumberVariableCell
where TNumber : struct, IConvertible
{
protected override bool DisplayAsUnsigned() => SavedSettingsConfig.DisplayYawAnglesAsUnsigned;
Expand Down
26 changes: 11 additions & 15 deletions STROOP/Controls/VariablePanel/VariablePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ static void ViewInMemoryTab(DescribedMemoryState memoryDescriptor)
tab.UpdateHexDisplay();
}

private static int numDummies = 0;

public readonly Func<List<IWinFormsVariableCell>> GetSelectedVars;

public Func<IEnumerable<(string name, SpecialFuncVariables generateVariables)>> getSpecialFuncVariables = null;
Expand Down Expand Up @@ -411,19 +409,17 @@ private void AddToVarHackTab(List<IWinFormsVariableCell> cells)

private static CustomVariable CreateDummyVariable<T>() where T : struct, IConvertible
{
throw new NotImplementedException();
// T capturedValue = default(T);
//
// return new CustomVariableView<T>(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<T>("Number");
variable.getter = () => capturedValue.Yield();
variable.setter = value =>
{
capturedValue = value;
return true.Yield();
};

return variable;
}

private ToolStripMenuItem CreateFilterItem(string varGroup)
Expand Down
5 changes: 4 additions & 1 deletion STROOP/Utilities/VariableSelectionUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ static IEnumerable<INumberVariableCell> FilterNumberVariables(IEnumerable<IWinFo
=> cells.OfType<INumberVariableCell>().Where(x => x is not IVariableCellData<string>);

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));
Expand Down
Loading