private void OnDatabasesGUI() { var savedDatabase = new SavedInt($"{nameof(SharedContentEditorWindow)}.Database", 0); savedDatabase.value = GUILayout.SelectionGrid(savedDatabase.value, DatabasesNames, 3); switch (savedDatabase.value) { case 0: // Character Database DrawDatabases <CharacterDatabase, CharacterSettings>(); break; case 1: // Materials Database DrawDatabases <MaterialsDatabase, MaterialSettings>(); break; case 2: // Weapon Database DrawDatabases <WeaponDatabase, WeaponSettings>(); break; case 3: // Character Animator Database DrawDatabases <CharacterAnimatorDatabase, CharacterAnimatorSettings>(); break; default: EditorGUILayout.HelpBox("Unknown or not implemented database has been selected.", MessageType.Error, true); break; } }
public mySavedInt(string name, int defaultvalue) { f = new SavedInt(name, Settings.gameSettingsFile, defaultvalue, true); if (!CSLStatsPanelConfigSettings.configurationsettings.Contains(f)) { CSLStatsPanelConfigSettings.configurationsettings.Add(f); } }
private SavedInt GetSavedInt(T i) { if (!cachedIntSaved.ContainsKey(i)) { cachedIntSaved[i] = new SavedInt(i.ToString(), thisFileName, getDefaultIntValueForProperty(i), true); } return(cachedIntSaved[i]); }
protected void setToFile(T i, int?value) { SavedInt data = GetSavedInt(i); if (value == null) { data.Delete(); } else { data.value = value.Value; } eventOnPropertyChanged?.Invoke(i, null, value, null); }
public UXModRoot(string owner_name, Action <string> log_fun) { owner_name_ = owner_name; log_ = log_fun; keybinds_conf_ = new ConfigFile(this, $"{owner_name_}_Keybinds"); uxmod_conf_ = new ConfigFile(this, "UXMod_Settings"); OSDPanelVisible = new SavedBool("OSDPanelVisible", uxmod_conf_.conf_name_); OSDPanelX = new SavedInt("OSDPanelX", uxmod_conf_.conf_name_); OSDPanelY = new SavedInt("OSDPanelY", uxmod_conf_.conf_name_); // Look for the panel by name var o = GameObject.Find(UXMOD_PANEL_NAME); panel_ = o != null ? new Either <GameObject, OnScreenDisplayPanel>(o) : new Either <GameObject, OnScreenDisplayPanel>( new OnScreenDisplayPanel(this)); }
/// <summary> /// Construct a <see cref="UXLibrary"/> with name of the owner mod and with function to log messages. /// </summary> /// <param name="ownerName">Name of the mod that is using the library</param> /// <param name="logFun"></param> public UxLibrary(string ownerName, Action <string> logFun) { OwnerName = ownerName; Log = logFun; KeybindsConf = new ConfigFile(this, $"{OwnerName}_Keybinds"); UxmodConf = new ConfigFile(this, SETTINGS_FILE); OsdPanelVisible = new SavedBool("OsdPanelVisible", UxmodConf.ConfName); OsdPanelX = new SavedInt("OsdPanelX", UxmodConf.ConfName); OsdPanelY = new SavedInt("OsdPanelY", UxmodConf.ConfName); // Look for the panel by name var o = GameObject.Find(UXMOD_PANEL_NAME); panel_ = o != null ? new Either <GameObject, OnScreenDisplayPanel>(o) : new Either <GameObject, OnScreenDisplayPanel>( new OnScreenDisplayPanel(this)); }
private void initVars(int default_r = 0, int default_g = 0, int default_b = 255, int default_a = 200) { m_r = new SavedInt(m_settingsprefix + "SavedColor_" + m_name + "R", Settings.gameSettingsFile, default_r, true); m_g = new SavedInt(m_settingsprefix + "SavedColor_" + m_name + "G", Settings.gameSettingsFile, default_g, true); m_b = new SavedInt(m_settingsprefix + "SavedColor_" + m_name + "B", Settings.gameSettingsFile, default_b, true); m_a = new SavedInt(m_settingsprefix + "SavedColor_" + m_name + "A", Settings.gameSettingsFile, default_a, true); if (!CSLStatsPanelConfigSettings.configurationsettings.Contains(m_r)) { CSLStatsPanelConfigSettings.configurationsettings.Add(m_r); } if (!CSLStatsPanelConfigSettings.configurationsettings.Contains(m_g)) { CSLStatsPanelConfigSettings.configurationsettings.Add(m_g); } if (!CSLStatsPanelConfigSettings.configurationsettings.Contains(m_b)) { CSLStatsPanelConfigSettings.configurationsettings.Add(m_b); } if (!CSLStatsPanelConfigSettings.configurationsettings.Contains(m_a)) { CSLStatsPanelConfigSettings.configurationsettings.Add(m_a); } }
private static void AddCheckboxPanel(UIHelper group, string mainLabel, SavedBool mainSaved, SavedInt optionsSaved, string[] labels) { var inProcess = false; var checkBoxes = new UICheckBox[labels.Length]; var optionsPanel = default(UIPanel); var mainCheckBox = group.AddCheckbox(mainLabel, mainSaved, OnMainChanged) as UICheckBox; optionsPanel = (group.self as UIComponent).AddUIComponent <UIPanel>(); optionsPanel.autoLayout = true; optionsPanel.autoLayoutDirection = LayoutDirection.Vertical; optionsPanel.autoFitChildrenHorizontally = true; optionsPanel.autoFitChildrenVertically = true; optionsPanel.autoLayoutPadding = new RectOffset(25, 0, 0, 5); var panelHelper = new UIHelper(optionsPanel); for (var i = 0; i < checkBoxes.Length; i += 1) { var index = i; checkBoxes[i] = panelHelper.AddCheckbox(labels[i], optionsSaved == i, (value) => Set(index, value)) as UICheckBox; } SetVisible(); void OnMainChanged(bool value) { mainSaved.value = value; SetVisible(); } void SetVisible() => optionsPanel.isVisible = mainSaved; void Set(int index, bool value) { if (!inProcess) { inProcess = true; optionsSaved.value = index; for (var i = 0; i < checkBoxes.Length; i += 1) { checkBoxes[i].isChecked = optionsSaved == i; } inProcess = false; } } }
public static UITextField AddSavedClampedIntTextfield(this UIHelperBase helper, string label, SavedInt savedInt, int min, int max) { return(helper.AddSavedClampedIntTextfield(label, savedInt, min, max, (_) => { })); }
public static UITextField AddSavedClampedIntTextfield(this UIHelperBase helper, string label, SavedInt savedInt, int min, int max, Action <int> OnSubmit) { UITextField field = null; field = helper.AddTextfield(label, savedInt.value.ToString(), (_) => { }, (string value) => { if (Int32.TryParse(value, out int newValue)) { newValue = Mathf.Clamp(newValue, min, max); if (newValue != savedInt.value) { savedInt.value = newValue; Log.Debug($"option {label} is set to " + savedInt.value); OnSubmit(newValue); } } else { if (field is not null) { field.text = savedInt.value.ToString(); } } }) as UITextField; field.numericalOnly = true; field.allowFloats = false; field.allowNegative = min < 0; Log.Debug($"option {label} is set to " + savedInt.value); return(field); }
private void OnEnable() { RefreshContent(); _activePage = new SavedInt($"{nameof(SharedContentEditorWindow)}.ActivePage", 0); }