/// <summary> /// A KSP mod reference /// </summary> /// <param name="displayName">The user friendly name</param> /// <param name="pluginName">The base folder name</param> /// <param name="spacePortId">The Product ID on SpacePort</param> /// <param name="clientVersion">The known client version</param> /// <param name="organic">Was this object created as a result of the plugin's config?</param> public KerbalMod(string displayName, string pluginName, int spacePortId = -1, DateTime? clientVersion = null, bool organic = false) { Debug.Log("Instantiating"); this.DisplayName = displayName; this.PluginName = pluginName; this.SpacePortID = spacePortId; this.ClientVersion = clientVersion; this._spacePortPage = (spacePortId == -1 ? null : new SpacePortPage(spacePortId)); this.Automatic = organic; }
/// <summary> /// Manually override the SpacePort page /// </summary> /// <param name="page">The page to override with</param> public void SetSpacePortPage(SpacePortPage page) { SpacePortID = page.GetSpacePortID(); _spacePortPage = page; }
/// <summary> /// Draw the manual override window /// </summary> /// <param name="windowID">The associated window ID</param> private void RenderManualConfigurationWindow(int windowID) { GUILayout.BeginVertical(); GUILayout.Label("Enter the Kerbal SpacePort URL for this plugin:"); _manualConfigurationUrl = GUILayout.TextField(_manualConfigurationUrl); GUILayout.BeginHorizontal(); GUILayout.Label(_message); GUILayout.FlexibleSpace(); if (GUILayout.Button("Apply", Resources.ACTION_BUTTON_STYLE)) { try { SpacePortPage page = new SpacePortPage(_manualConfigurationUrl); _manualConfiguration.SetSpacePortPage(page); UpdaterConfiguration.SetClientVersion(_manualConfiguration.SpacePortID, null); UpdaterConfiguration.SetOverride(_manualConfiguration.DisplayName, _manualConfiguration.SpacePortID); _manualConfiguration = null; } catch (UriFormatException ex) { _message = "Couldn't use that page: " + ex.Message; } } if (GUILayout.Button("Cancel", Resources.ACTION_BUTTON_STYLE)) { _manualConfiguration = null; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); }