protected AParentDefStatWidget(D def, DefType type) { this.Def = def; this.type = type; this.autoApplySettingsInput = new BoolInputWidget <D>( def, "InGameDefEditor.AutoApplySettings".Translate(), d => IsAutoApply, (d, applyAuto) => { if (applyAuto) { if (!Defs.ApplyStatsAutoDefs.Add(d)) { Log.Warning($"Failed to apply auto load to {Util.GetLabel(d)}"); } else { AddDefsToAutoApply(true); } } else { if (!Defs.ApplyStatsAutoDefs.Remove(d)) { Log.Warning($"Failed to remove auto load from {Util.GetLabel(d)}"); } else { AddDefsToAutoApply(false); } } }); this.disableDefInput = new BoolInputWidget <D>( def, "InGameDefEditor.DisableDef".Translate(), d => IsDisabled, (d, isDisabled) => { if (isDisabled) { if (!Defs.DisabledDefs.Add(d)) { Log.Warning($"Failed to disable {this.DisplayLabel}"); } else { Defs.ApplyStatsAutoDefs.Remove(d); DatabaseUtil.Remove(d); } } else { if (!Defs.DisabledDefs.Remove(d)) { Log.Warning($"Failed to enable {this.DisplayLabel}"); } else { DatabaseUtil.Add(d); } } }, d => { bool enabled = Current.Game == null || IsDisabled; return(new AInputWidget <D, bool> .ShouldDrawInputResult(enabled, (enabled) ? "" : "Cannot disabled defs while a game is not running.")); }); }