Better fix for Lalafell and Elezen ears, maybe.

This commit is contained in:
Ottermandias 2023-09-27 22:53:27 +02:00
parent b8dad18f86
commit 550c0c756e
5 changed files with 82 additions and 25 deletions

View file

@ -26,6 +26,7 @@ public class CharaMakeParams : ExcelRow
Percentage = 5, Percentage = 5,
Checkmark = 6, // custom Checkmark = 6, // custom
Nothing = 7, // custom Nothing = 7, // custom
List1Selector = 8, // custom, 1-indexed lists
} }
public struct Menu public struct Menu

View file

@ -293,7 +293,10 @@ public partial class CustomizationOptions
var menu = row.Menus var menu = row.Menus
.Cast<CharaMakeParams.Menu?>() .Cast<CharaMakeParams.Menu?>()
.FirstOrDefault(m => m!.Value.Customize == gameId); .FirstOrDefault(m => m!.Value.Customize == gameId);
return menu?.Type ?? CharaMakeParams.MenuType.ListSelector; var ret = menu?.Type ?? CharaMakeParams.MenuType.ListSelector;
if (c is CustomizeIndex.TailShape && ret is CharaMakeParams.MenuType.ListSelector)
ret = CharaMakeParams.MenuType.List1Selector;
return ret;
}).ToArray(); }).ToArray();
set.Order = CustomizationSet.ComputeOrder(set); set.Order = CustomizationSet.ComputeOrder(set);
} }

View file

@ -87,7 +87,6 @@ public class CustomizationSet
custom = null; custom = null;
return value == CustomizeValue.Zero; return value == CustomizeValue.Zero;
} }
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)] [MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
@ -95,7 +94,7 @@ public class CustomizationSet
{ {
var type = Types[(int)index]; var type = Types[(int)index];
int GetInteger(out CustomizeData? custom) int GetInteger0(out CustomizeData? custom)
{ {
if (value < Count(index)) if (value < Count(index))
{ {
@ -107,6 +106,18 @@ public class CustomizationSet
return -1; return -1;
} }
int GetInteger1(out CustomizeData? custom)
{
if (value > 0 && value < Count(index) + 1)
{
custom = new CustomizeData(index, value, 0, (ushort)(value.Value - 1));
return value.Value;
}
custom = null;
return -1;
}
static int GetBool(CustomizeIndex index, CustomizeValue value, out CustomizeData? custom) static int GetBool(CustomizeIndex index, CustomizeValue value, out CustomizeData? custom)
{ {
if (value == CustomizeValue.Zero) if (value == CustomizeValue.Zero)
@ -147,7 +158,8 @@ public class CustomizationSet
return type switch return type switch
{ {
CharaMakeParams.MenuType.ListSelector => GetInteger(out custom), CharaMakeParams.MenuType.ListSelector => GetInteger0(out custom),
CharaMakeParams.MenuType.List1Selector => GetInteger1(out custom),
CharaMakeParams.MenuType.IconSelector => index switch CharaMakeParams.MenuType.IconSelector => index switch
{ {
CustomizeIndex.Face => Get(Faces, HrothgarFaceHack(value), out custom), CustomizeIndex.Face => Get(Faces, HrothgarFaceHack(value), out custom),
@ -177,7 +189,7 @@ public class CustomizationSet
_ => Invalid(out custom), _ => Invalid(out custom),
}, },
CharaMakeParams.MenuType.IconCheckmark => GetBool(index, value, out custom), CharaMakeParams.MenuType.IconCheckmark => GetBool(index, value, out custom),
CharaMakeParams.MenuType.Percentage => GetInteger(out custom), CharaMakeParams.MenuType.Percentage => GetInteger0(out custom),
CharaMakeParams.MenuType.Checkmark => GetBool(index, value, out custom), CharaMakeParams.MenuType.Checkmark => GetBool(index, value, out custom),
_ => Invalid(out custom), _ => Invalid(out custom),
}; };
@ -195,9 +207,10 @@ public class CustomizationSet
switch (Types[(int)index]) switch (Types[(int)index])
{ {
case CharaMakeParams.MenuType.Percentage: return new CustomizeData(index, (CustomizeValue)idx, 0, (ushort)idx); case CharaMakeParams.MenuType.Percentage: return new CustomizeData(index, (CustomizeValue)idx, 0, (ushort)idx);
case CharaMakeParams.MenuType.ListSelector: return new CustomizeData(index, (CustomizeValue)idx, 0, (ushort)idx); case CharaMakeParams.MenuType.ListSelector: return new CustomizeData(index, (CustomizeValue)idx, 0, (ushort)idx);
case CharaMakeParams.MenuType.Checkmark: return new CustomizeData(index, CustomizeValue.Bool(idx != 0), 0, (ushort)idx); case CharaMakeParams.MenuType.List1Selector: return new CustomizeData(index, (CustomizeValue)(idx + 1), 0, (ushort)idx);
case CharaMakeParams.MenuType.Checkmark: return new CustomizeData(index, CustomizeValue.Bool(idx != 0), 0, (ushort)idx);
} }
return index switch return index switch

View file

@ -89,15 +89,25 @@ public partial class CustomizationDrawer
UpdateValue(_set.Data(_currentIndex, currentIndex + 1, _customize.Face).Value); UpdateValue(_set.Data(_currentIndex, currentIndex + 1, _customize.Face).Value);
} }
private void DrawListSelector(CustomizeIndex index) private void DrawListSelector(CustomizeIndex index, bool indexedBy1)
{ {
using var _ = SetId(index); using var _ = SetId(index);
using var bigGroup = ImRaii.Group(); using var bigGroup = ImRaii.Group();
using var disabled = ImRaii.Disabled(_locked); using var disabled = ImRaii.Disabled(_locked);
ListCombo(); if (indexedBy1)
ImGui.SameLine(); {
ListInputInt(); ListCombo1();
ImGui.SameLine();
ListInputInt1();
}
else
{
ListCombo0();
ImGui.SameLine();
ListInputInt0();
}
if (_withApply) if (_withApply)
{ {
ImGui.SameLine(); ImGui.SameLine();
@ -109,11 +119,42 @@ public partial class CustomizationDrawer
ImGui.TextUnformatted(_currentOption); ImGui.TextUnformatted(_currentOption);
} }
private void ListCombo() private void ListCombo0()
{ {
var offset = GetOffset();
ImGui.SetNextItemWidth(_comboSelectorSize * ImGui.GetIO().FontGlobalScale); ImGui.SetNextItemWidth(_comboSelectorSize * ImGui.GetIO().FontGlobalScale);
var current = _currentByte.Value + offset; var current = _currentByte.Value;
using var combo = ImRaii.Combo("##combo", $"{_currentOption} #{current + 1}");
if (!combo)
return;
for (var i = 0; i < _currentCount; ++i)
{
if (ImGui.Selectable($"{_currentOption} #{i + 1}##combo", i == current))
UpdateValue((CustomizeValue)i);
}
}
private void ListInputInt0()
{
var tmp = _currentByte.Value + 1;
ImGui.SetNextItemWidth(_inputIntSize);
if (ImGui.InputInt("##text", ref tmp, 1, 1))
{
var newValue = (CustomizeValue)(ImGui.GetIO().KeyCtrl
? Math.Clamp(tmp, 1, byte.MaxValue + 1)
: Math.Clamp(tmp, 1, _currentCount));
UpdateValue(newValue - 1);
}
ImGuiUtil.HoverTooltip($"Input Range: [1, {_currentCount}]\n"
+ "Hold Control to force updates with invalid/unknown options at your own risk.");
}
private void ListCombo1()
{
ImGui.SetNextItemWidth(_comboSelectorSize * ImGui.GetIO().FontGlobalScale);
var current = _currentByte.Value;
using var combo = ImRaii.Combo("##combo", $"{_currentOption} #{current}"); using var combo = ImRaii.Combo("##combo", $"{_currentOption} #{current}");
if (!combo) if (!combo)
@ -122,20 +163,19 @@ public partial class CustomizationDrawer
for (var i = 1; i <= _currentCount; ++i) for (var i = 1; i <= _currentCount; ++i)
{ {
if (ImGui.Selectable($"{_currentOption} #{i}##combo", i == current)) if (ImGui.Selectable($"{_currentOption} #{i}##combo", i == current))
UpdateValue((CustomizeValue)i - offset); UpdateValue((CustomizeValue)i);
} }
} }
private void ListInputInt() private void ListInputInt1()
{ {
var offset = GetOffset(); var tmp = (int)_currentByte.Value;
var tmp =_currentByte.Value + offset;
ImGui.SetNextItemWidth(_inputIntSize); ImGui.SetNextItemWidth(_inputIntSize);
if (ImGui.InputInt("##text", ref tmp, 1, 1)) if (ImGui.InputInt("##text", ref tmp, 1, 1))
{ {
var newValue = (CustomizeValue)(ImGui.GetIO().KeyCtrl var newValue = (CustomizeValue)(ImGui.GetIO().KeyCtrl
? Math.Clamp(tmp - offset, 1 - offset, byte.MaxValue) ? Math.Clamp(tmp, 0, byte.MaxValue)
: Math.Clamp(tmp - offset, 1 - offset, _currentCount)); : Math.Clamp(tmp, 1, _currentCount));
UpdateValue(newValue); UpdateValue(newValue);
} }
@ -143,9 +183,6 @@ public partial class CustomizationDrawer
+ "Hold Control to force updates with invalid/unknown options at your own risk."); + "Hold Control to force updates with invalid/unknown options at your own risk.");
} }
private int GetOffset()
=> _currentIndex is CustomizeIndex.TailShape ? 0 : 1;
// Draw a customize checkbox. // Draw a customize checkbox.
private void DrawCheckbox(CustomizeIndex idx) private void DrawCheckbox(CustomizeIndex idx)
{ {

View file

@ -150,7 +150,10 @@ public partial class CustomizationDrawer : IDisposable
DrawMultiIconSelector(); DrawMultiIconSelector();
foreach (var id in _set.Order[CharaMakeParams.MenuType.ListSelector]) foreach (var id in _set.Order[CharaMakeParams.MenuType.ListSelector])
DrawListSelector(id); DrawListSelector(id, false);
foreach (var id in _set.Order[CharaMakeParams.MenuType.List1Selector])
DrawListSelector(id, true);
Functions.IteratePairwise(_set.Order[CharaMakeParams.MenuType.ColorPicker], DrawColorPicker, ImGui.SameLine); Functions.IteratePairwise(_set.Order[CharaMakeParams.MenuType.ColorPicker], DrawColorPicker, ImGui.SameLine);