fix: check if template was changed
This commit is contained in:
parent
ac19ac6792
commit
19e3b67f3e
@ -118,33 +118,40 @@ internal class Write : ITab {
|
|||||||
|
|
||||||
const string placeholder = "****";
|
const string placeholder = "****";
|
||||||
|
|
||||||
void DrawPicker(string id, IReadOnlyList<string> items, ref int x) {
|
bool DrawPicker(string id, IReadOnlyList<string> items, ref int x) {
|
||||||
var preview = x == -1 ? "" : items[x].Replace("{0}", placeholder);
|
var preview = x == -1 ? "" : items[x].Replace("{0}", placeholder);
|
||||||
if (!ImGui.BeginCombo(id, preview)) {
|
if (!ImGui.BeginCombo(id, preview)) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
using var endCombo = new OnDispose(ImGui.EndCombo);
|
using var endCombo = new OnDispose(ImGui.EndCombo);
|
||||||
|
|
||||||
|
var changed = false;
|
||||||
if (ImGui.Selectable("<none>")) {
|
if (ImGui.Selectable("<none>")) {
|
||||||
x = -1;
|
x = -1;
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i < items.Count; i++) {
|
for (var i = 0; i < items.Count; i++) {
|
||||||
var template = items[i].Replace("{0}", placeholder);
|
var template = items[i].Replace("{0}", placeholder);
|
||||||
if (ImGui.Selectable(template, i == x)) {
|
if (!ImGui.Selectable(template, i == x)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
x = i;
|
x = i;
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawTemplatePicker(string id, IReadOnlyList<string> items, ref int x, ref (int, int) word) {
|
void DrawTemplatePicker(string id, IReadOnlyList<string> items, ref int x, ref (int, int) word) {
|
||||||
var wasAdvanced = this.Pack?.Templates[x].Words != null;
|
var wasAdvanced = this.Pack?.Templates.Get(x)?.Words != null;
|
||||||
if (wasAdvanced) {
|
|
||||||
|
var changed = DrawPicker(id, items, ref x);
|
||||||
|
if (changed && wasAdvanced) {
|
||||||
word = (-1, -1);
|
word = (-1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawPicker(id, items, ref x);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawSpecificWordPicker(string id, Template template, ref (int, int) x) {
|
void DrawSpecificWordPicker(string id, Template template, ref (int, int) x) {
|
||||||
|
Loading…
Reference in New Issue
Block a user