This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32dcafc
commit a38744f
Showing
5 changed files
with
186 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using RotationSolver.Basic.Configuration; | ||
|
||
namespace RotationSolver.Localization; | ||
|
||
internal static class ConfigTranslation | ||
{ | ||
public static string ToName(this JobConfigString config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToName(this JobConfigInt config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToName(this JobConfigFloat config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToName(this PluginConfigInt config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToName(this PluginConfigBool config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToName(this PluginConfigFloat config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToName(this PluginConfigVector4 config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToDescription(this JobConfigString config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToDescription(this JobConfigInt config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToDescription(this JobConfigFloat config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToDescription(this PluginConfigInt config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToDescription(this PluginConfigBool config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToDescription(this PluginConfigFloat config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
|
||
public static string ToDescription(this PluginConfigVector4 config) => config switch | ||
{ | ||
_ => string.Empty, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,81 @@ | ||
namespace RotationSolver.UI.SearchableSettings; | ||
using ECommons.ExcelServices; | ||
using RotationSolver.Basic.Configuration; | ||
using RotationSolver.Localization; | ||
using RotationSolver.UI.SearchableConfigs; | ||
|
||
internal class CheckBoxSearch : ISearchable | ||
namespace RotationSolver.UI.SearchableSettings; | ||
|
||
internal class CheckBoxSearchPlugin : CheckBoxSearch | ||
{ | ||
private PluginConfigBool _config; | ||
public override string ID => _config.ToString(); | ||
|
||
public override string Name => _config.ToName(); | ||
|
||
public override string Description => _config.ToDescription(); | ||
|
||
public CheckBoxSearchPlugin(PluginConfigBool config, params ISearchable[] children) | ||
{ | ||
_config = config; | ||
Children = children; | ||
} | ||
|
||
protected override bool GetValue(Job job) | ||
{ | ||
return Service.ConfigNew.GetValue(_config); | ||
} | ||
|
||
protected override void SetValue(Job job, bool value) | ||
{ | ||
Service.ConfigNew.SetValue(_config, value); | ||
} | ||
} | ||
|
||
internal abstract class CheckBoxSearch : Searchable | ||
{ | ||
public string SearchingKey => throw new NotImplementedException(); | ||
public abstract string ID { get; } | ||
|
||
public ISearchable[] Children { get; protected set; } | ||
|
||
public string Name { get; set; } | ||
public string Description { get; set; } = string.Empty; | ||
protected abstract bool GetValue(Job job); | ||
protected abstract void SetValue(Job job, bool value); | ||
|
||
public void Draw() | ||
public override void Draw(Job job) | ||
{ | ||
var enable = GetValue(job); | ||
if (ImGui.Checkbox($"##{ID}", ref enable)) | ||
{ | ||
SetValue(job, enable); | ||
} | ||
if(ImGui.IsItemHovered()) ShowTooltip(); | ||
|
||
var name = $"{Name}##Config_{ID}"; | ||
if (enable) | ||
{ | ||
var x = ImGui.GetCursorPosX(); | ||
var drawBody = ImGui.TreeNode(name) && Children != null && Children.Length > 0; | ||
if (ImGui.IsItemHovered()) ShowTooltip(); | ||
|
||
if (drawBody) | ||
{ | ||
ImGui.SetCursorPosX(x); | ||
ImGui.BeginGroup(); | ||
foreach (var child in Children) | ||
{ | ||
child.Draw(job); | ||
} | ||
ImGui.EndGroup(); | ||
ImGui.TreePop(); | ||
} | ||
} | ||
else | ||
{ | ||
ImGui.PushStyleColor(ImGuiCol.HeaderHovered, 0x0); | ||
ImGui.PushStyleColor(ImGuiCol.HeaderActive, 0x0); | ||
ImGui.TreeNodeEx(name, ImGuiTreeNodeFlags.Leaf | ImGuiTreeNodeFlags.NoTreePushOnOpen); | ||
if (ImGui.IsItemHovered()) ShowTooltip(); | ||
|
||
ImGui.PopStyleColor(2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
namespace RotationSolver.UI.SearchableSettings; | ||
using ECommons.ExcelServices; | ||
|
||
namespace RotationSolver.UI.SearchableSettings; | ||
|
||
public interface ISearchable | ||
{ | ||
string SearchingKey { get; } | ||
|
||
void Draw(Job job); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using ECommons.ExcelServices; | ||
using RotationSolver.UI.SearchableSettings; | ||
|
||
namespace RotationSolver.UI.SearchableConfigs; | ||
|
||
internal abstract class Searchable : ISearchable | ||
{ | ||
public string SearchingKey => Name + " : " + Description; | ||
public abstract string Name { get; } | ||
public abstract string Description { get; } | ||
public Action DrawTooltip { get; set; } | ||
|
||
public abstract void Draw(Job job); | ||
|
||
protected void ShowTooltip() | ||
{ | ||
ImguiTooltips.ShowTooltip(() => | ||
{ | ||
var showDesc = !string.IsNullOrEmpty(Description); | ||
if (showDesc) | ||
{ | ||
ImGui.TextWrapped(Description); | ||
} | ||
if(showDesc && DrawTooltip != null) | ||
{ | ||
ImGui.Separator(); | ||
} | ||
DrawTooltip?.Invoke(); | ||
}); | ||
} | ||
} |