Add support uint64 values in EnumComboBox

This commit is contained in:
Wojtek Figat
2021-03-31 12:15:57 +02:00
parent 51926f517e
commit a2825eac87
4 changed files with 14 additions and 14 deletions

View File

@@ -29,7 +29,7 @@ namespace FlaxEditor.GUI
/// <summary>
/// The cached value from the UI.
/// </summary>
protected int _cachedValue;
protected ulong _cachedValue;
/// <summary>
/// True if has value cached, otherwise false.
@@ -54,7 +54,7 @@ namespace FlaxEditor.GUI
/// <summary>
/// The value.
/// </summary>
public int Value;
public ulong Value;
/// <summary>
/// Initializes a new instance of the <see cref="Entry"/> struct.
@@ -62,7 +62,7 @@ namespace FlaxEditor.GUI
/// <param name="name">The name.</param>
/// <param name="tooltip">The tooltip.</param>
/// <param name="value">The value.</param>
public Entry(string name, int value, string tooltip = null)
public Entry(string name, ulong value, string tooltip = null)
{
Name = name;
Tooltip = tooltip;
@@ -88,13 +88,13 @@ namespace FlaxEditor.GUI
public object EnumTypeValue
{
get => Enum.ToObject(_enumType, Value);
set => Value = Convert.ToInt32(value);
set => Value = Convert.ToUInt64(value);
}
/// <summary>
/// Gets or sets the value.
/// </summary>
public int Value
public ulong Value
{
get => _cachedValue;
set
@@ -209,13 +209,13 @@ namespace FlaxEditor.GUI
/// </summary>
protected void CacheValue()
{
int value = 0;
ulong value = 0;
if (IsFlags)
{
var selection = Selection;
for (int i = 0; i < selection.Count; i++)
{
int index = selection[i];
var index = selection[i];
value |= _entries[index].Value;
}
}
@@ -276,7 +276,7 @@ namespace FlaxEditor.GUI
tooltip = tooltipAttr.Text;
}
entries.Add(new Entry(name, Convert.ToInt32(field.GetRawConstantValue()), tooltip));
entries.Add(new Entry(name, Convert.ToUInt64(field.GetRawConstantValue()), tooltip));
}
}
@@ -295,9 +295,9 @@ namespace FlaxEditor.GUI
}
// Calculate value that will be set after change
int valueAfter = 0;
ulong valueAfter = 0;
bool isSelected = _selectedIndices.Contains(index);
int selectedValue = entries[index].Value;
ulong selectedValue = entries[index].Value;
for (int i = 0; i < _selectedIndices.Count; i++)
{
int selectedIndex = _selectedIndices[i];

View File

@@ -137,7 +137,7 @@ namespace FlaxEditor.Surface.Archetypes
{
int* dataValues = (int*)dataPtr;
for (int i = 0; i < entries.Count; i++)
dataValues[i] = entries[i].Value;
dataValues[i] = (int)entries[i].Value;
}
}
else

View File

@@ -177,7 +177,7 @@ namespace FlaxEditor.Surface.Archetypes
{
int* dataValues = (int*)dataPtr;
for (int i = 0; i < entries.Count; i++)
dataValues[i] = entries[i].Value;
dataValues[i] = (int)entries[i].Value;
}
}
else

View File

@@ -32,13 +32,13 @@ namespace FlaxEditor.Surface.Elements
Width = archetype.Size.X;
ParentNode = parentNode;
Archetype = archetype;
Value = (int)ParentNode.Values[Archetype.ValueIndex];
Value = (ulong)(int)ParentNode.Values[Archetype.ValueIndex];
}
/// <inheritdoc />
protected override void OnValueChanged()
{
if ((int)ParentNode.Values[Archetype.ValueIndex] != Value)
if ((int)ParentNode.Values[Archetype.ValueIndex] != (int)Value)
{
// Edit value
ParentNode.SetValue(Archetype.ValueIndex, Value);