Merge pull request #106 from Caraxi/master

Avoid crashing when clicking Choose with no item selected
This commit is contained in:
goaaats 2020-05-03 16:34:54 +02:00 committed by GitHub
commit 009a4901f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -186,15 +186,23 @@ namespace Dalamud.Interface
ImGui.EndChild();
if (ImGui.Button(Loc.Localize("Choose", "Choose"))) {
OnItemChosen?.Invoke(this, this.searchTask.Result[this.selectedItemIndex]);
// Darken choose button if it shouldn't be clickable
ImGui.PushStyleVar(ImGuiStyleVar.Alpha, this.selectedItemIndex < 0 ? 0.25f : 1);
if (this.closeOnChoose) {
this.selectedItemTex?.Dispose();
isOpen = false;
if (ImGui.Button(Loc.Localize("Choose", "Choose"))) {
try {
OnItemChosen?.Invoke(this, this.searchTask.Result[this.selectedItemIndex]);
if (this.closeOnChoose) {
this.selectedItemTex?.Dispose();
isOpen = false;
}
} catch (Exception ex) {
Log.Error($"Exception in Choose: {ex.Message}");
}
}
ImGui.PopStyleVar();
if (!this.closeOnChoose) {
ImGui.SameLine();
if (ImGui.Button(Loc.Localize("Close", "Close")))