Some more reworking

This commit is contained in:
Ottermandias 2022-10-19 15:24:27 +02:00
parent 6a4b5fc3b2
commit dad146d043
41 changed files with 1714 additions and 1320 deletions

View file

@ -1,8 +1,8 @@
using System;
using System.Linq;
using System.Security.AccessControl;
using Glamourer.Customization;
using ImGuiNET;
using Newtonsoft.Json.Linq;
using OtterGui;
using OtterGui.Raii;
@ -10,9 +10,9 @@ namespace Glamourer.Gui.Customization;
internal partial class CustomizationDrawer
{
private void DrawListSelector(CustomizationId id)
private void DrawListSelector(CustomizeIndex index)
{
using var _ = SetId(id);
using var _ = SetId(index);
using var bigGroup = ImRaii.Group();
ListCombo();
@ -33,22 +33,22 @@ internal partial class CustomizationDrawer
for (var i = 0; i < _currentCount; ++i)
{
if (ImGui.Selectable($"{_currentOption} #{i + 1}##combo", i == _currentByte.Value))
UpdateValue((CustomizationByteValue)i);
UpdateValue((CustomizeValue)i);
}
}
private void ListInputInt()
{
var tmp = _currentByte.Value + 1;
ImGui.SetNextItemWidth(_inputIntSize);
if (ImGui.InputInt("##text", ref tmp, 1, 1) && tmp > 0 && tmp <= _currentCount)
UpdateValue((CustomizationByteValue)Math.Clamp(tmp - 1, 0, _currentCount - 1));
UpdateValue((CustomizeValue)Math.Clamp(tmp - 1, 0, _currentCount - 1));
ImGuiUtil.HoverTooltip($"Input Range: [1, {_currentCount}]");
}
private void PercentageSelector(CustomizationId id)
private void PercentageSelector(CustomizeIndex index)
{
using var _ = SetId(id);
using var _ = SetId(index);
using var bigGroup = ImRaii.Group();
DrawPercentageSlider();
@ -63,7 +63,7 @@ internal partial class CustomizationDrawer
var tmp = (int)_currentByte.Value;
ImGui.SetNextItemWidth(_comboSelectorSize);
if (ImGui.SliderInt("##slider", ref tmp, 0, _currentCount - 1, "%i", ImGuiSliderFlags.AlwaysClamp))
UpdateValue((CustomizationByteValue)tmp);
UpdateValue((CustomizeValue)tmp);
}
private void PercentageInputInt()
@ -71,7 +71,7 @@ internal partial class CustomizationDrawer
var tmp = (int)_currentByte.Value;
ImGui.SetNextItemWidth(_inputIntSize);
if (ImGui.InputInt("##text", ref tmp, 1, 1))
UpdateValue((CustomizationByteValue)Math.Clamp(tmp, 0, _currentCount - 1));
UpdateValue((CustomizeValue)Math.Clamp(tmp, 0, _currentCount - 1));
ImGuiUtil.HoverTooltip($"Input Range: [0, {_currentCount - 1}]");
}
@ -87,6 +87,14 @@ internal partial class CustomizationDrawer
}
}
// Draw a customize checkbox.
private void DrawCheckbox(CustomizeIndex idx)
{
using var id = SetId(idx);
Checkbox(_set.Option(idx), _customize.Get(idx) != CustomizeValue.Zero,
b => _customize.Set(idx, b ? CustomizeValue.Max : CustomizeValue.Zero));
}
// Integral input for an icon- or color based item.
private void DataInputInt(int currentIndex)
{
@ -95,7 +103,7 @@ internal partial class CustomizationDrawer
if (ImGui.InputInt("##text", ref currentIndex, 1, 1))
{
currentIndex = Math.Clamp(currentIndex - 1, 0, _currentCount - 1);
var data = _set.Data(_currentId, currentIndex, _customize.Face);
var data = _set.Data(_currentIndex, currentIndex, _customize.Face);
UpdateValue(data.Value);
}