mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 10:17:22 +01:00
Add partial copying of color and colordye tables.
This commit is contained in:
parent
cc97ea0ce9
commit
18288815b2
2 changed files with 57 additions and 7 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit 315258f4f8a59d744aa4d2d1f8c31d410d041729
|
Subproject commit 6848397dd77cfcdbff1accd860d5b7e95f8c9fe5
|
||||||
|
|
@ -202,10 +202,9 @@ public partial class MtrlTab
|
||||||
if (Mtrl.Table == null)
|
if (Mtrl.Table == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!ImUtf8.IconButton(FontAwesomeIcon.Paste, "Import an exported row from your clipboard onto this row."u8,
|
if (ImUtf8.IconButton(FontAwesomeIcon.Paste,
|
||||||
|
"Import an exported row from your clipboard onto this row.\n\nRight-Click for more options."u8,
|
||||||
ImGui.GetFrameHeight() * Vector2.One, disabled))
|
ImGui.GetFrameHeight() * Vector2.One, disabled))
|
||||||
return false;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var text = ImGui.GetClipboardText();
|
var text = ImGui.GetClipboardText();
|
||||||
|
|
@ -226,6 +225,57 @@ public partial class MtrlTab
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ColorTablePasteFromClipboardContext(rowIdx, disabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
private unsafe bool ColorTablePasteFromClipboardContext(int rowIdx, bool disabled)
|
||||||
|
{
|
||||||
|
if (!disabled && ImGui.IsItemClicked(ImGuiMouseButton.Right))
|
||||||
|
ImUtf8.OpenPopup("context"u8);
|
||||||
|
|
||||||
|
using var context = ImUtf8.Popup("context"u8);
|
||||||
|
if (!context)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
using var _ = ImRaii.Disabled(disabled);
|
||||||
|
|
||||||
|
IColorTable.ValueTypes copy = 0;
|
||||||
|
IColorDyeTable.ValueTypes dyeCopy = 0;
|
||||||
|
if (ImUtf8.Selectable("Import Colors Only"u8))
|
||||||
|
{
|
||||||
|
copy = IColorTable.ValueTypes.Colors;
|
||||||
|
dyeCopy = IColorDyeTable.ValueTypes.Colors;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImUtf8.Selectable("Import Other Values Only"u8))
|
||||||
|
{
|
||||||
|
copy = ~IColorTable.ValueTypes.Colors;
|
||||||
|
dyeCopy = ~IColorDyeTable.ValueTypes.Colors;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (copy == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var text = ImGui.GetClipboardText();
|
||||||
|
var data = Convert.FromBase64String(text);
|
||||||
|
var row = Mtrl.Table!.RowAsHalves(rowIdx);
|
||||||
|
var halves = new Span<Half>(Unsafe.AsPointer(ref data[0]), row.Length);
|
||||||
|
var dyeRow = Mtrl.DyeTable != null ? Mtrl.DyeTable.RowAsBytes(rowIdx) : [];
|
||||||
|
if (!Mtrl.Table.MergeSpecificValues(row, halves, copy))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Mtrl.DyeTable?.MergeSpecificValues(dyeRow, data.AsSpan(row.Length * 2), dyeCopy);
|
||||||
|
|
||||||
|
UpdateColorTableRowPreview(rowIdx);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ColorTablePairHighlightButton(int pairIdx, bool disabled)
|
private void ColorTablePairHighlightButton(int pairIdx, bool disabled)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue