private void DrawTweakConfig(BaseTweak t, ref bool hasChange) { var enabled = t.Enabled; if (t.Experimental && !ShowExperimentalTweaks && !enabled) { return; } if (ImGui.Checkbox($"###{t.Key}enabledCheckbox", ref enabled)) { if (enabled) { SimpleLog.Debug($"Enable: {t.Name}"); try { t.Enable(); if (t.Enabled) { EnabledTweaks.Add(t.Key); } } catch (Exception ex) { plugin.Error(t, ex, false, $"Error in Enable for '{t.Name}'"); } } else { SimpleLog.Debug($"Disable: {t.Name}"); try { t.Disable(); } catch (Exception ex) { plugin.Error(t, ex, true, $"Error in Disable for '{t.Name}'"); } EnabledTweaks.RemoveAll(a => a == t.Key); } Save(); } ImGui.SameLine(); var descriptionX = ImGui.GetCursorPosX(); if (!t.DrawConfig(ref hasChange)) { if (ShowTweakDescriptions && !string.IsNullOrEmpty(t.Description)) { ImGui.SetCursorPosX(descriptionX); ImGui.PushStyleColor(ImGuiCol.HeaderHovered, 0x0); ImGui.PushStyleColor(ImGuiCol.HeaderActive, 0x0); ImGui.TreeNodeEx(" ", ImGuiTreeNodeFlags.Leaf | ImGuiTreeNodeFlags.NoTreePushOnOpen); ImGui.PopStyleColor(); ImGui.PopStyleColor(); ImGui.SameLine(); ImGui.PushStyleColor(ImGuiCol.Text, 0xFF888888); ImGui.TextWrapped($"{t.Description}"); ImGui.PopStyleColor(); } } ImGui.Separator(); }
private void DrawTweakConfig(BaseTweak t, ref bool hasChange) { var enabled = t.Enabled; if (t.Experimental && !ShowExperimentalTweaks && !enabled) { return; } if (!enabled && ImGui.GetIO().KeyShift) { if (HiddenTweaks.Contains(t.Key)) { if (ImGui.Button($"S##unhideTweak_{t.Key}", new Vector2(23) * ImGui.GetIO().FontGlobalScale)) { HiddenTweaks.Remove(t.Key); Save(); } if (ImGui.IsItemHovered()) { ImGui.SetTooltip(Loc.Localize("Unhide Tweak", "Unhide Tweak")); } } else { if (ImGui.Button($"H##hideTweak_{t.Key}", new Vector2(23) * ImGui.GetIO().FontGlobalScale)) { HiddenTweaks.Add(t.Key); Save(); } if (ImGui.IsItemHovered()) { ImGui.SetTooltip(Loc.Localize("Hide Tweak", "Hide Tweak")); } } } else if (ImGui.Checkbox($"###{t.Key}enabledCheckbox", ref enabled)) { if (enabled) { SimpleLog.Debug($"Enable: {t.Name}"); try { t.Enable(); if (t.Enabled) { EnabledTweaks.Add(t.Key); } } catch (Exception ex) { plugin.Error(t, ex, false, $"Error in Enable for '{t.Name}'"); } } else { SimpleLog.Debug($"Disable: {t.Name}"); try { t.Disable(); } catch (Exception ex) { plugin.Error(t, ex, true, $"Error in Disable for '{t.Name}'"); } EnabledTweaks.RemoveAll(a => a == t.Key); } Save(); } ImGui.SameLine(); var descriptionX = ImGui.GetCursorPosX(); if (!t.DrawConfig(ref hasChange)) { if (ShowTweakDescriptions && !string.IsNullOrEmpty(t.Description)) { ImGui.SetCursorPosX(descriptionX); ImGui.PushStyleColor(ImGuiCol.HeaderHovered, 0x0); ImGui.PushStyleColor(ImGuiCol.HeaderActive, 0x0); ImGui.TreeNodeEx(" ", ImGuiTreeNodeFlags.Leaf | ImGuiTreeNodeFlags.NoTreePushOnOpen); ImGui.PopStyleColor(); ImGui.PopStyleColor(); ImGui.SameLine(); ImGui.PushStyleColor(ImGuiCol.Text, 0xFF888888); var tweakDescription = t.LocString("Description", t.Description, "Tweak Description"); ImGui.TextWrapped($"{tweakDescription}"); ImGui.PopStyleColor(); } } ImGui.Separator(); }