mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
fix(StyleEditor): save style when adding/importing
This commit is contained in:
parent
4630d448fc
commit
f2d604c4ef
1 changed files with 21 additions and 6 deletions
|
|
@ -89,6 +89,8 @@ namespace Dalamud.Interface.Internal.Windows.StyleEditor
|
||||||
|
|
||||||
if (ImGui.Button(Loc.Localize("StyleEditorAddNew", "Add new style")))
|
if (ImGui.Button(Loc.Localize("StyleEditorAddNew", "Add new style")))
|
||||||
{
|
{
|
||||||
|
this.SaveStyle();
|
||||||
|
|
||||||
var newStyle = StyleModel.DalamudStandard;
|
var newStyle = StyleModel.DalamudStandard;
|
||||||
newStyle.Name = GetRandomName();
|
newStyle.Name = GetRandomName();
|
||||||
config.SavedStyles.Add(newStyle);
|
config.SavedStyles.Add(newStyle);
|
||||||
|
|
@ -152,6 +154,8 @@ namespace Dalamud.Interface.Internal.Windows.StyleEditor
|
||||||
|
|
||||||
if (ImGuiComponents.IconButton(FontAwesomeIcon.FileImport))
|
if (ImGuiComponents.IconButton(FontAwesomeIcon.FileImport))
|
||||||
{
|
{
|
||||||
|
this.SaveStyle();
|
||||||
|
|
||||||
var styleJson = ImGui.GetClipboardText();
|
var styleJson = ImGui.GetClipboardText();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
@ -307,14 +311,10 @@ namespace Dalamud.Interface.Internal.Windows.StyleEditor
|
||||||
|
|
||||||
if (ImGui.Button(Loc.Localize("SaveAndClose", "Save and Close")))
|
if (ImGui.Button(Loc.Localize("SaveAndClose", "Save and Close")))
|
||||||
{
|
{
|
||||||
|
this.SaveStyle();
|
||||||
|
|
||||||
config.ChosenStyle = config.SavedStyles[this.currentSel].Name;
|
config.ChosenStyle = config.SavedStyles[this.currentSel].Name;
|
||||||
|
|
||||||
var newStyle = StyleModel.Get();
|
|
||||||
newStyle.Name = config.ChosenStyle;
|
|
||||||
config.SavedStyles[this.currentSel] = newStyle;
|
|
||||||
newStyle.Apply();
|
|
||||||
|
|
||||||
config.Save();
|
|
||||||
this.didSave = true;
|
this.didSave = true;
|
||||||
|
|
||||||
this.IsOpen = false;
|
this.IsOpen = false;
|
||||||
|
|
@ -342,6 +342,21 @@ namespace Dalamud.Interface.Internal.Windows.StyleEditor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SaveStyle()
|
||||||
|
{
|
||||||
|
if (this.currentSel == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var config = Service<DalamudConfiguration>.Get();
|
||||||
|
|
||||||
|
var newStyle = StyleModel.Get();
|
||||||
|
newStyle.Name = config.ChosenStyle;
|
||||||
|
config.SavedStyles[this.currentSel] = newStyle;
|
||||||
|
newStyle.Apply();
|
||||||
|
|
||||||
|
config.Save();
|
||||||
|
}
|
||||||
|
|
||||||
private static string GetRandomName()
|
private static string GetRandomName()
|
||||||
{
|
{
|
||||||
var data = Service<DataManager>.Get();
|
var data = Service<DataManager>.Get();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue