mirror of
https://github.com/xivdev/Penumbra.git
synced 2025-12-12 18:27:24 +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,24 +202,74 @@ public partial class MtrlTab
|
|||
if (Mtrl.Table == null)
|
||||
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))
|
||||
try
|
||||
{
|
||||
var text = ImGui.GetClipboardText();
|
||||
var data = Convert.FromBase64String(text);
|
||||
var row = Mtrl.Table.RowAsBytes(rowIdx);
|
||||
var dyeRow = Mtrl.DyeTable != null ? Mtrl.DyeTable.RowAsBytes(rowIdx) : [];
|
||||
if (data.Length != row.Length && data.Length != row.Length + dyeRow.Length)
|
||||
return false;
|
||||
|
||||
data.AsSpan(0, row.Length).TryCopyTo(row);
|
||||
data.AsSpan(row.Length).TryCopyTo(dyeRow);
|
||||
|
||||
UpdateColorTableRowPreview(rowIdx);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
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.RowAsBytes(rowIdx);
|
||||
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 (data.Length != row.Length && data.Length != row.Length + dyeRow.Length)
|
||||
if (!Mtrl.Table.MergeSpecificValues(row, halves, copy))
|
||||
return false;
|
||||
|
||||
data.AsSpan(0, row.Length).TryCopyTo(row);
|
||||
data.AsSpan(row.Length).TryCopyTo(dyeRow);
|
||||
Mtrl.DyeTable?.MergeSpecificValues(dyeRow, data.AsSpan(row.Length * 2), dyeCopy);
|
||||
|
||||
UpdateColorTableRowPreview(rowIdx);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue