private void DrawButtonArrowLeft(Addon addon) { if (GuiHelper.CompatibilityState(OverrideType.locked, addon) || (GuiHelper.CompatibilityState(OverrideType.version, addon) && !GuiHelper.CompatibilityState(OverrideType.ignore, addon))) { GUILayout.Space(33); //fill the space which would usually taken by the button at this position return; } GUIStyle coloredButtonStyle = GuiHelper.CompatibilityState(OverrideType.name, addon) ? buttonStyleGreen : buttonStyle; string buttonLabel = "\u25C0"; //unicode for a triangle, pointing to the left if (GUILayout.Button(buttonLabel, coloredButtonStyle, GUILayout.Width(25), GUILayout.Height(25))) { if (!GuiHelper.CompatibilityState(OverrideType.name, addon)) { GuiHelper.UpdateCompatibilityState(OverrideType.name, addon); } } }
private void DrawButtonArrowRight(Addon addon) { if (GuiHelper.CompatibilityState(OverrideType.locked, addon) || GuiHelper.CompatibilityState(OverrideType.name, addon)) { GUILayout.Space(25); //fill the space which would usually taken by the button at this position return; } GUIStyle coloredButtonStyle = GuiHelper.CompatibilityState(OverrideType.version, addon) ? buttonStyleGreen : buttonStyle; string buttonLabel = "\u25B6"; //unicode for a triangle, pointing to the right if (GUILayout.Button(buttonLabel, coloredButtonStyle, GUILayout.Width(25), GUILayout.Height(25))) { if (!GuiHelper.CompatibilityState(OverrideType.version, addon)) { GuiHelper.UpdateCompatibilityState(OverrideType.version, null, addon.LocalInfo.KspVersionMaxIsNull && addon.LocalInfo.KspVersionMinIsNull ? addon.LocalInfo.KspVersion.ToString() : addon.LocalInfo.KspVersionMax.ToString()); } } }
/// <summary> /// Draws the updatable add-on list. /// </summary> private void DrawUpdateableListAddons() { // Iterate through all the loaded add-ons. for (int i = 0; i < AddonLibrary.LoadedAddons.Count; ++i) { // Get the current add-on from the library. Addon addon = AddonLibrary.LoadedAddons[i]; // Check that the add-on exists and has an update available. if (addon != null && addon.UpdateAvailable) { // Draw the add-on details inside a horizontal layout container. LayoutHelper.Horizontal(() => { GUILayout.Label(addon.Name, contentLabelStyle, GUILayout.Width(COLUMN_NAME_WIDTH)); GUILayout.Label(addon.LocalVersionString, contentLabelCentredStyle, GUILayout.Width(COLUMN_VERSION_WIDTH)); GUILayout.Label(addon.RemoteVersionString, contentLabelCentredStyle, GUILayout.Width(COLUMN_VERSION_WIDTH)); }); } } }
public static bool CompatibilityState(OverrideType type, Addon addon, string oldVersion = "") //requires -1 instead of * { switch (type) { case OverrideType.name: { return(addon.IsForcedCompatibleByName); } case OverrideType.version: { if (oldVersion != "") { oldVersion = oldVersion.Replace("*", "-1"); bool b = (from d in Configuration.CompatibleVersions where oldVersion == d.Key where d.Value.compatWithVersion.Contains(AddonInfo.ActualKspVersion) select d).Any(); return(b); } return(addon.IsForcedCompatibleByVersion); } case OverrideType.ignore: { return(Configuration.modsIgnoreOverride.Contains(addon.Name)); } case OverrideType.locked: { return(addon.IsLockedByCreator); } default: { return(false); } } }
private void DrawIncompatibleMods() { if (Configuration.OverrideIsDisabledGlobal) { DrawDisabled(); return; } List <Addon> listIncompatibleMods = AddonLibrary.Addons.Where(a => !a.IsCompatible).OrderBy(a => a.Name).ToList(); int m = listIncompatibleMods.Count(); if (m == 0) { DrawNoIncompatibleAddons(); return; } if (Configuration.ShowDefaultValues) { DrawDefaultValues(); } for (int i = 0; i < m; i++) { Addon addon = listIncompatibleMods[i]; GUIStyle coloredLabel = (GuiHelper.CompatibilityState(OverrideType.version, addon) || GuiHelper.CompatibilityState(OverrideType.name, addon)) ? this.labelStyleCyan : GuiHelper.CompatibilityState(OverrideType.ignore, addon) ? this.labelStyleIgnore : this.labelStyleYellow; //highlighting ignored mods VersionInfo versionNumber = addon.LocalInfo.KspVersionMaxIsNull && addon.LocalInfo.KspVersionMinIsNull ? addon.LocalInfo.KspVersion : addon.LocalInfo.KspVersionMax; GUILayout.BeginHorizontal(); DrawButtonArrowLeft(addon); GUILayout.Space(18); GUILayout.Label(addon.Name, coloredLabel, GUILayout.MinWidth(230.0f)); GUILayout.Space(10); GUILayout.Label($"{versionNumber}", coloredLabel, GUILayout.MinWidth(65)); GUILayout.Space(18); DrawButtonArrowRight(addon); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } }
private void DrawUpdateInformation(Addon addon) { GUILayout.Label(addon.Name, this.nameLabelStyle, GUILayout.Width(250.0f)); GUILayout.Label(addon.LocalInfo.Version.ToString(), this.labelStyle, GUILayout.Width(100.0f)); GUILayout.Label(addon.RemoteInfo.Version.ToString(), this.labelStyle, GUILayout.Width(100.0f)); }
private void DrawActionList(DropDownList list, Addon addon) { this.DrawActionListChangeLog(list, addon); this.DrawActionListDownload(list, addon); }
private void DrawActionListDownload(DropDownList list, Addon addon) { if (String.IsNullOrEmpty(addon.RemoteInfo.Download)) { return; } if (GUILayout.Button("Download", this.buttonStyle)) { Application.OpenURL(addon.RemoteInfo.Download); list.ShowList = false; } if (Event.current.type == EventType.repaint) { list.ToolTip.Text = GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) ? list.ToolTip.Text = addon.RemoteInfo.Download : String.Empty; } }
private void DrawActionListChangeLog(DropDownList list, Addon addon) { if (String.IsNullOrEmpty(addon.RemoteInfo.ChangeLog) || !GUILayout.Button("Change Log", this.buttonStyle)) { return; } var changeLogGui = this.gameObject.AddComponent<ChangeLogGui>(); changeLogGui.Name = addon.RemoteInfo.Name; changeLogGui.Text = addon.RemoteInfo.ChangeLog; list.ShowList = false; }
private void DrawActionButton(Addon addon) { if (String.IsNullOrEmpty(addon.RemoteInfo.Download) && String.IsNullOrEmpty(addon.RemoteInfo.ChangeLog)) { return; } (this.actionLists.ContainsKey(addon) ? this.actionLists[addon] : this.CreateActionList(addon)).DrawButton("ACTIONS", this.position, 125.0f); }
private DropDownList CreateActionList(Addon addon) { var actionList = this.gameObject.AddComponent<DropDownList>(); actionList.Addon = addon; actionList.DrawAddonCallback = this.DrawActionList; this.actionLists.Add(addon, actionList); return actionList; }
public static void UpdateCompatibilityState(OverrideType type, Addon addon = null, string versionInfo = "", bool remove = false) { switch (type) { case OverrideType.name: { if (!CompatibilityState(OverrideType.name, addon)) { Configuration.AddOverrideName(addon); return; } Configuration.RemoveOverrideName(addon); return; } case OverrideType.version: { if (validateInput(versionInfo)) { userInput = ""; List <string> inputs = reformatInput(versionInfo); var dictKeys = Configuration.CompatibleVersions.Keys; if (dictKeys.Contains(inputs[0]) && remove) { int j = inputs.Count(); for (int i = 1; i < j; i++) //so far, the list will always have just two entries in this case but just to be sure, I've build the loop anyway { Configuration.RemoveOverrideVersion(inputs[0], inputs[i]); } return; } int m = inputs.Count(); for (int i = 1; i < m; i++) { Configuration.AddOverrideVersion(inputs[0], inputs[i]); } return; } userInput = "INVALID"; return; } case OverrideType.ignore: { if (!CompatibilityState(OverrideType.ignore, addon)) { Configuration.AddToIgnore(addon); return; } Configuration.RemoveFromIgnore(addon); return; } default: { Logger.Log("Unable to update compatibility override"); return; } } }