Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
implement palette saving from ActorEdit tab
Browse files Browse the repository at this point in the history
  • Loading branch information
chirpxiv committed Jan 23, 2023
1 parent 89a886c commit 248aa19
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
17 changes: 16 additions & 1 deletion PalettePlus/Interface/Windows/Tabs/ActorEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using PalettePlus.Palettes;
using PalettePlus.Services;
using PalettePlus.Extensions;
using PalettePlus.Interface.Dialog;
using PalettePlus.Interface.Components;

namespace PalettePlus.Interface.Windows.Tabs {
Expand Down Expand Up @@ -38,7 +39,21 @@ private unsafe void DrawActorEdit(bool firstFrame) {
var actor = ActorList.Selected;
if (actor == null) return;

ImGui.Button("Save"); // TODO Implement
if (ImGui.Button("Save")) {
var name = "";
string? err = null;

var popup = (PopupMenu)PluginGui.GetWindow<PopupMenu>();
popup.Open(() => {
if (NameInput.Draw(ref name, ref err)) {
popup.Close();

var palette = (Palette)Palette.Clone();
palette.Name = name;
PalettePlus.Config.SavedPalettes.Add(palette);
}
});
}

ImGui.SameLine();

Expand Down
10 changes: 9 additions & 1 deletion PalettePlus/Palettes/Palette.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using PalettePlus.Palettes.Attributes;

namespace PalettePlus.Palettes {
public class Palette {
public class Palette : ICloneable {
public string Name = "";

public PaletteConditions Conditions;
Expand All @@ -22,6 +22,14 @@ public Palette(string name = "") {
Name = name;
}

public object Clone() {
var clone = (Palette)MemberwiseClone();
clone.ShaderParams = new();
foreach (var (key, val) in ShaderParams)
clone.ShaderParams.Add(key, val);
return clone;
}

public void SetShaderParam(string key, object value, bool exists) {
if (exists)
ShaderParams[key] = value;
Expand Down

0 comments on commit 248aa19

Please sign in to comment.