Add support uint64 values in EnumComboBox
This commit is contained in:
@@ -29,7 +29,7 @@ namespace FlaxEditor.GUI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The cached value from the UI.
|
/// The cached value from the UI.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected int _cachedValue;
|
protected ulong _cachedValue;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// True if has value cached, otherwise false.
|
/// True if has value cached, otherwise false.
|
||||||
@@ -54,7 +54,7 @@ namespace FlaxEditor.GUI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The value.
|
/// The value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Value;
|
public ulong Value;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Entry"/> struct.
|
/// 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="name">The name.</param>
|
||||||
/// <param name="tooltip">The tooltip.</param>
|
/// <param name="tooltip">The tooltip.</param>
|
||||||
/// <param name="value">The value.</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;
|
Name = name;
|
||||||
Tooltip = tooltip;
|
Tooltip = tooltip;
|
||||||
@@ -88,13 +88,13 @@ namespace FlaxEditor.GUI
|
|||||||
public object EnumTypeValue
|
public object EnumTypeValue
|
||||||
{
|
{
|
||||||
get => Enum.ToObject(_enumType, Value);
|
get => Enum.ToObject(_enumType, Value);
|
||||||
set => Value = Convert.ToInt32(value);
|
set => Value = Convert.ToUInt64(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the value.
|
/// Gets or sets the value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Value
|
public ulong Value
|
||||||
{
|
{
|
||||||
get => _cachedValue;
|
get => _cachedValue;
|
||||||
set
|
set
|
||||||
@@ -209,13 +209,13 @@ namespace FlaxEditor.GUI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected void CacheValue()
|
protected void CacheValue()
|
||||||
{
|
{
|
||||||
int value = 0;
|
ulong value = 0;
|
||||||
if (IsFlags)
|
if (IsFlags)
|
||||||
{
|
{
|
||||||
var selection = Selection;
|
var selection = Selection;
|
||||||
for (int i = 0; i < selection.Count; i++)
|
for (int i = 0; i < selection.Count; i++)
|
||||||
{
|
{
|
||||||
int index = selection[i];
|
var index = selection[i];
|
||||||
value |= _entries[index].Value;
|
value |= _entries[index].Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,7 +276,7 @@ namespace FlaxEditor.GUI
|
|||||||
tooltip = tooltipAttr.Text;
|
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
|
// Calculate value that will be set after change
|
||||||
int valueAfter = 0;
|
ulong valueAfter = 0;
|
||||||
bool isSelected = _selectedIndices.Contains(index);
|
bool isSelected = _selectedIndices.Contains(index);
|
||||||
int selectedValue = entries[index].Value;
|
ulong selectedValue = entries[index].Value;
|
||||||
for (int i = 0; i < _selectedIndices.Count; i++)
|
for (int i = 0; i < _selectedIndices.Count; i++)
|
||||||
{
|
{
|
||||||
int selectedIndex = _selectedIndices[i];
|
int selectedIndex = _selectedIndices[i];
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
{
|
{
|
||||||
int* dataValues = (int*)dataPtr;
|
int* dataValues = (int*)dataPtr;
|
||||||
for (int i = 0; i < entries.Count; i++)
|
for (int i = 0; i < entries.Count; i++)
|
||||||
dataValues[i] = entries[i].Value;
|
dataValues[i] = (int)entries[i].Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ namespace FlaxEditor.Surface.Archetypes
|
|||||||
{
|
{
|
||||||
int* dataValues = (int*)dataPtr;
|
int* dataValues = (int*)dataPtr;
|
||||||
for (int i = 0; i < entries.Count; i++)
|
for (int i = 0; i < entries.Count; i++)
|
||||||
dataValues[i] = entries[i].Value;
|
dataValues[i] = (int)entries[i].Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -32,13 +32,13 @@ namespace FlaxEditor.Surface.Elements
|
|||||||
Width = archetype.Size.X;
|
Width = archetype.Size.X;
|
||||||
ParentNode = parentNode;
|
ParentNode = parentNode;
|
||||||
Archetype = archetype;
|
Archetype = archetype;
|
||||||
Value = (int)ParentNode.Values[Archetype.ValueIndex];
|
Value = (ulong)(int)ParentNode.Values[Archetype.ValueIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void OnValueChanged()
|
protected override void OnValueChanged()
|
||||||
{
|
{
|
||||||
if ((int)ParentNode.Values[Archetype.ValueIndex] != Value)
|
if ((int)ParentNode.Values[Archetype.ValueIndex] != (int)Value)
|
||||||
{
|
{
|
||||||
// Edit value
|
// Edit value
|
||||||
ParentNode.SetValue(Archetype.ValueIndex, Value);
|
ParentNode.SetValue(Archetype.ValueIndex, Value);
|
||||||
|
|||||||
Reference in New Issue
Block a user