/// <summary> /// Called when the game is loaded. Used to set up all persistent objects and properties. /// </summary> public void Start() { fetch = this; "WalkAboutAddUtility.Start".Debug(); activeEVA = false; if (!(FlightGlobals.ActiveVessel?.isEVA ?? false)) { "Add Location utility deactivated: not an EVA".Debug(); } else { var crew = FlightGlobals.ActiveVessel.GetVesselCrew(); if ((crew?.Count ?? 0) != 1) { "Add Location utility deactivated: invalid crew count".Debug(); } else { activeEVA = true; } } GameEvents.onVesselChange.Add(onVesselChange); _config = GetModConfig(); "Add Location utility obtained config".Debug(); if (_config == null) { return; } if (!HighLogic.CurrentGame.Parameters.CustomParams <WA>().UtilityMode) { "Add Location utility deactivated: not in utility mode".Debug(); return; } if (activeEVA) { $"Add Location utility activated on EVA for {FlightGlobals.ActiveVessel.GetVesselCrew()[0].name}".Debug(); } _map = GetLocationMap(); "Add Location utility obtained map object".Debug(); _addUtilityGui = new AddUtilityGui(); if (toolbarControl == null) { toolbarControl = gameObject.AddComponent <ToolbarControl>(); toolbarControl.AddToAllToolbars(GuiOn, GuiOff, ApplicationLauncher.AppScenes.FLIGHT, WalkAbout.MODID, "walkaboutButton_Flight", "WalkAbout/PluginData/WalkAbout-38", "WalkAbout/PluginData/WalkAbout-24", WalkAbout.MODNAME ); } }
/// <summary>Gets the configuration information for this mod.</summary> /// <returns>An object representing the information in the configuration file</returns> public static WalkAboutSettings GetModConfig() { if (_modConfig == null) { _modConfig = new WalkAboutSettings(); var loaded = _modConfig.Load($"{WalkAbout.GetModDirectory()}/Settings.cfg", Constants.DefaultSettings); _modConfig.StatusMessage.Log(); if (!loaded) { return(null); } } return(_modConfig); }
/// <summary> /// Called when the game is loaded. Used to set up all persistent objects and properties. /// </summary> public void Start() { $"Started [Version={Constants.Version}, Debug={DebugExtensions.DebugIsOn}]".Log(); fetch = this; _config = GetModConfig(); "obtained config".Debug(); if (_config == null) { return; } _map = GetLocationMap(); "obtained map object".Debug(); _map.RefreshLocations(); // needed to avoid holding on to other games' data _items = GetAllItems(); "obtained items object".Debug(); _mainGui = PlaceKerbalGui.Instance; _mainGui.GuiCoordinates = _config.GetScreenPosition(); //_mainGui.TopFew = _config.TopFew; _mainGui.MaxItems = HighLogic.CurrentGame.Parameters.CustomParams <WA>().MaxInventoryItems; _mainGui.MaxVolume = HighLogic.CurrentGame.Parameters.CustomParams <WA>().MaxInventoryVolume; $"created MainGui object".Debug(); GetCentrum(); // Initialize the centrum to avoid errors if AddUtility is opened before WalkAbout. GameEvents.OnTechnologyResearched.Remove(ItemRefresh); GameEvents.OnKSCFacilityUpgraded.Remove(MapRefresh); GameEvents.OnTechnologyResearched.Add(ItemRefresh); GameEvents.OnKSCFacilityUpgraded.Add(MapRefresh); if (toolbarControl == null) { toolbarControl = gameObject.AddComponent <ToolbarControl>(); toolbarControl.AddToAllToolbars(GuiOn, GuiOff, ApplicationLauncher.AppScenes.SPACECENTER, MODID, "walkaboutButton_spacecenter", "WalkAbout/PluginData/WalkAbout-38", "WalkAbout/PluginData/WalkAbout-24", MODNAME ); } }