okey
This commit is contained in:
parent
08c1752182
commit
dfb50aae2d
|
@ -7,10 +7,23 @@ internal class Settings : ITab {
|
||||||
public string Name => "Settings";
|
public string Name => "Settings";
|
||||||
|
|
||||||
private Plugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
|
private int _tab = 0;
|
||||||
private string _extraCode = string.Empty;
|
private string _extraCode = string.Empty;
|
||||||
|
|
||||||
|
private delegate void DrawSettingsDelegate(ref bool anyChanged, ref bool vfx);
|
||||||
|
|
||||||
|
private IReadOnlyList<(string, DrawSettingsDelegate)> Tabs { get; }
|
||||||
|
|
||||||
internal Settings(Plugin plugin) {
|
internal Settings(Plugin plugin) {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
|
|
||||||
|
this.Tabs = new List<(string, DrawSettingsDelegate)> {
|
||||||
|
("General", this.DrawGeneral),
|
||||||
|
("Writer", this.DrawWriter),
|
||||||
|
("Viewer", this.DrawViewer),
|
||||||
|
("Unlocks", this.DrawUnlocks),
|
||||||
|
("Account", this.DrawAccount),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
|
@ -22,29 +35,36 @@ internal class Settings : ITab {
|
||||||
var anyChanged = false;
|
var anyChanged = false;
|
||||||
var vfx = false;
|
var vfx = false;
|
||||||
|
|
||||||
anyChanged |= vfx |= ImGui.Checkbox("Disable in trials", ref this.Plugin.Config.DisableTrials);
|
var widestTabName = this.Tabs
|
||||||
anyChanged |= vfx |= ImGui.Checkbox("Disable in Deep Dungeons", ref this.Plugin.Config.DisableDeepDungeon);
|
.Select(entry => ImGui.CalcTextSize(entry.Item1).X)
|
||||||
anyChanged |= vfx |= ImGui.Checkbox("Remove glow effect from signs", ref this.Plugin.Config.RemoveGlow);
|
.Max();
|
||||||
|
|
||||||
var glyph = this.Plugin.Config.DefaultGlyph + 1;
|
var leftOver = ImGui.GetContentRegionAvail().X - widestTabName - ImGui.GetStyle().ItemSpacing.X - ImGui.GetStyle().FrameBorderSize;
|
||||||
if (ImGui.InputInt("Default glyph", ref glyph)) {
|
if (ImGui.BeginTable("##settings-tabs", 2)) {
|
||||||
this.Plugin.Config.DefaultGlyph = Math.Min(4, Math.Max(0, glyph - 1));
|
ImGui.TableSetupColumn("##names", ImGuiTableColumnFlags.None, widestTabName + ImGui.GetStyle().ItemSpacing.X);
|
||||||
anyChanged = true;
|
ImGui.TableSetupColumn("##content", ImGuiTableColumnFlags.None, leftOver);
|
||||||
}
|
|
||||||
|
|
||||||
if (ImGui.CollapsingHeader("Viewer settings")) {
|
ImGui.TableNextRow();
|
||||||
anyChanged |= ImGui.SliderFloat("Viewer opacity", ref this.Plugin.Config.ViewerOpacity, 0f, 100.0f, $"{this.Plugin.Config.ViewerOpacity:N3}%%");
|
|
||||||
anyChanged |= ImGui.Checkbox("Open the viewer automatically when near a sign", ref this.Plugin.Config.AutoViewer);
|
|
||||||
anyChanged |= ImGui.Checkbox("Close the viewer automatically when no signs are nearby", ref this.Plugin.Config.AutoViewerClose);
|
|
||||||
|
|
||||||
if (this.Plugin.Config.AutoViewerClose) {
|
if (ImGui.TableSetColumnIndex(0)) {
|
||||||
ImGui.TreePush();
|
for (var i = 0; i < this.Tabs.Count; i++) {
|
||||||
anyChanged |= ImGui.Checkbox("Hide viewer titlebar", ref this.Plugin.Config.HideTitlebar);
|
var (name, _) = this.Tabs[i];
|
||||||
ImGui.TreePop();
|
if (ImGui.Selectable($"{name}##tab-{i}", i == this._tab)) {
|
||||||
|
this._tab = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
anyChanged |= ImGui.Checkbox("Lock viewer in place", ref this.Plugin.Config.LockViewer);
|
if (ImGui.TableSetColumnIndex(1)) {
|
||||||
anyChanged |= ImGui.Checkbox("Click through viewer", ref this.Plugin.Config.ClickThroughViewer);
|
if (ImGui.BeginChild("##tab-content-child")) {
|
||||||
|
var (_, draw) = this.Tabs[this._tab];
|
||||||
|
draw(ref anyChanged, ref vfx);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.EndChild();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (anyChanged) {
|
if (anyChanged) {
|
||||||
|
@ -57,12 +77,46 @@ internal class Settings : ITab {
|
||||||
this.Plugin.Messages.SpawnVfx();
|
this.Plugin.Messages.SpawnVfx();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.ExtraCodeInput();
|
|
||||||
this.DeleteAccountButton();
|
|
||||||
|
|
||||||
ImGui.PopTextWrapPos();
|
ImGui.PopTextWrapPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawGeneral(ref bool anyChanged, ref bool vfx) {
|
||||||
|
anyChanged |= vfx |= ImGui.Checkbox("Disable in trials", ref this.Plugin.Config.DisableTrials);
|
||||||
|
anyChanged |= vfx |= ImGui.Checkbox("Disable in Deep Dungeons", ref this.Plugin.Config.DisableDeepDungeon);
|
||||||
|
anyChanged |= vfx |= ImGui.Checkbox("Remove glow effect from signs", ref this.Plugin.Config.RemoveGlow);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawWriter(ref bool anyChanged, ref bool vfx) {
|
||||||
|
var glyph = this.Plugin.Config.DefaultGlyph + 1;
|
||||||
|
if (ImGui.InputInt("Default glyph", ref glyph)) {
|
||||||
|
this.Plugin.Config.DefaultGlyph = Math.Min(4, Math.Max(0, glyph - 1));
|
||||||
|
anyChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawViewer(ref bool anyChanged, ref bool vfx) {
|
||||||
|
anyChanged |= ImGui.SliderFloat("Viewer opacity", ref this.Plugin.Config.ViewerOpacity, 0f, 100.0f, $"{this.Plugin.Config.ViewerOpacity:N3}%%");
|
||||||
|
anyChanged |= ImGui.Checkbox("Open the viewer automatically when near a sign", ref this.Plugin.Config.AutoViewer);
|
||||||
|
anyChanged |= ImGui.Checkbox("Close the viewer automatically when no signs are nearby", ref this.Plugin.Config.AutoViewerClose);
|
||||||
|
|
||||||
|
if (this.Plugin.Config.AutoViewerClose) {
|
||||||
|
ImGui.TreePush();
|
||||||
|
anyChanged |= ImGui.Checkbox("Hide viewer titlebar", ref this.Plugin.Config.HideTitlebar);
|
||||||
|
ImGui.TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
anyChanged |= ImGui.Checkbox("Lock viewer in place", ref this.Plugin.Config.LockViewer);
|
||||||
|
anyChanged |= ImGui.Checkbox("Click through viewer", ref this.Plugin.Config.ClickThroughViewer);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawUnlocks(ref bool anyChanged, ref bool vfx) {
|
||||||
|
this.ExtraCodeInput();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawAccount(ref bool anyChanged, ref bool vfx) {
|
||||||
|
this.DeleteAccountButton();
|
||||||
|
}
|
||||||
|
|
||||||
private void ExtraCodeInput() {
|
private void ExtraCodeInput() {
|
||||||
ImGui.InputText("Extra code", ref this._extraCode, 128);
|
ImGui.InputText("Extra code", ref this._extraCode, 128);
|
||||||
if (!ImGui.Button("Claim")) {
|
if (!ImGui.Button("Claim")) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user