private void OnAppLauncherReady() { if (this.appLauncherButton != null) { HSUtils.DebugLog("application launcher button already exists"); return; } var appLauncher = ApplicationLauncher.Instance; if (appLauncher == null) { HSUtils.DebugLog("application launcher instance is null"); //maybe run a coroutine to try again. return; } var scenes = ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.TRACKSTATION | ApplicationLauncher.AppScenes.MAPVIEW | ApplicationLauncher.AppScenes.SPACECENTER; this.appLauncherButton = appLauncher.AddModApplication(appLauncherButton_OnTrue, appLauncherButton_OnFalse, () => { }, () => { }, () => { }, () => { }, scenes, Resources.appLauncherIcon ); }
public void Save() { HSUtils.DebugLog("saving settings"); var t = new ConfigNode(); var config = t.AddNode(NODE_SETTINGS); var nodeWindowPositions = config.AddNode(NODE_WINDOW_POSITIONS); var nodeVisibilities = config.AddNode(NODE_WINDOW_VISIBILITIES); var nodeBottomButtons = config.AddNode(BOTTOM_BUTTONS); saveDicValuesToNode(windowPositions, nodeWindowPositions, WINDOW_POSITION, (node, position) => node.AddNode(position.ToNode())); saveDicValuesToNode(windowVisibilities, nodeVisibilities, WINDOW_VISIBLE, (node, visible) => node.AddValue(VALUE, visible)); saveDicValuesToNode(bottomButtons, nodeBottomButtons, BUTTON_STATE, (node, value) => node.AddValue(VALUE, value)); var nodeVesselTypeVisibility = config.AddNode(NODE_VESSEL_TYPE_VISIBILITY); var typeList = Resources.vesselTypesList; foreach (var type in typeList) { nodeVesselTypeVisibility.AddValue(type.name, type.visible); } t.Save(SettingsFile); }
//blizzy toolbar private void setupToolbar() { HSUtils.DebugLog("HaystackResourceLoader#setupToolbar: toolbar detected, using it."); this.toolbarButton = ToolbarManager.Instance.add("HaystackContinued", toolbarButtonId); this.toolbarButton.Visibility = new GameScenesVisibility(GameScenes.FLIGHT, GameScenes.TRACKSTATION, GameScenes.SPACECENTER); this.toolbarButton.TexturePath = Resources.ToolbarIcon; this.toolbarButton.ToolTip = "Haystack Continued"; this.toolbarButton.OnClick += toolbarButton_OnClick; }
public V this[string name] { get { V ret; return(index.TryGetValue(name, out ret) ? ret : defaultValueFactory()); } set { HSUtils.DebugLog(setDebugMessage, name, value); this.index[name] = value; } }
public void Load(ConfigNode node) { ConfigNode loadNode = node.GetNode(this.GetType().Name); if (loadNode == null) { HSUtils.DebugLog("HiddenVessles#Load: node is null"); return; } var ns = new NodeSeralizer(); ConfigNode.LoadObjectFromConfig(ns, loadNode.GetNode(ns.GetType().FullName)); this.hiddenVessels = ns.hiddenVessels; }
internal static void FocusMapObject(CelestialBody body) { if (!(IsMapActive || IsTrackingCenterActive)) { return; } HSUtils.DebugLog("FocusMapObject(body)"); var cam = getPlanetariumCamera(); foreach (var mapObject in cam.targets) { if (mapObject.celestialBody != null && mapObject.celestialBody.GetInstanceID() == body.GetInstanceID()) { cam.SetTarget(mapObject); return; } } }
private void setupScenarioModule() { ProtoScenarioModule protoScenarioModule = HighLogic.CurrentGame.scenarios.FirstOrDefault(i => i.moduleName == typeof (HaystackScenarioModule).Name); if (protoScenarioModule == null) { HSUtils.DebugLog("adding scenario module"); HighLogic.CurrentGame.AddProtoScenarioModule(typeof (HaystackScenarioModule), HaystackScenarioModule.Scenes); } else { var missing = HaystackScenarioModule.Scenes.Except(protoScenarioModule.targetScenes); foreach (var i in missing) { HSUtils.DebugLog("missing scenario module scene: {0}", i); protoScenarioModule.targetScenes.Add(i); } } }
private void OnAppLauncherDestroyed() { var appLauncher = ApplicationLauncher.Instance; if (appLauncher == null) { HSUtils.DebugLog("OnApplicationLauncherDestroyed: application launcher instance is null."); return; } if (this.appLauncherButton == null) { HSUtils.DebugLog("app launcher button is null."); return; } appLauncher.RemoveModApplication(this.appLauncherButton); this.appLauncherButton = null; }
internal static void FocusMapObject(Vessel vessel) { if (!(IsMapActive || IsTrackingCenterActive)) { return; } HSUtils.DebugLog("FocusMapObject(vessel)"); var cam = getPlanetariumCamera(); if (IsTrackingCenterActive) { foreach (var mapObject in cam.targets) { if (mapObject.vessel != null && mapObject.vessel.GetInstanceID() == vessel.GetInstanceID()) { cam.SetTarget(mapObject); return; } } return; } // else // in flight map mode the active vessel is the only vessel in the list of targets // don't know why but will attempt to maintain that cam.targets.RemoveAll(mapObject => mapObject.vessel != null); var activeVessel = FlightGlobals.ActiveVessel; if (activeVessel != null && activeVessel.GetInstanceID() != vessel.GetInstanceID()) { cam.AddTarget(FlightGlobals.ActiveVessel.mapObject); } cam.AddTarget(vessel.mapObject); cam.SetTarget(vessel.mapObject); }
private void Load() { HSUtils.Log("loading settings"); HSUtils.DebugLog("Settings#Load: start"); var load = ConfigNode.Load(SettingsFile) ?? new ConfigNode(); if (!load.HasNode(NODE_SETTINGS)) { HSUtils.DebugLog("Settings#Load: no settings node"); return; } var config = load.GetNode(NODE_SETTINGS); var nodeWindowPositions = config.GetNode(NODE_WINDOW_POSITIONS) ?? new ConfigNode(); var nodeWindowVisibility = config.GetNode(NODE_WINDOW_VISIBILITIES) ?? new ConfigNode(); var bottomButtons = config.GetNode(BOTTOM_BUTTONS) ?? new ConfigNode(); var defaultPos = new Rect(0, 0, 0, 0); foreach (var i in nodeWindowPositions.nodes) { var node = (ConfigNode)i; var name = node.name; var position = node.FromNode(WINDOW_POSITION, defaultPos); HSUtils.DebugLog("Settings#load name: {0} position: {1}", name, position); this.windowPositions[name] = position; } foreach (var n in nodeWindowVisibility.nodes) { var node = (ConfigNode)n; var name = node.name; var visible = node.FromNode(WINDOW_VISIBLE, false); HSUtils.DebugLog("Settings#Load name: {0} visible: {1}", name, visible); this.windowVisibilities[name] = visible; } foreach (var n in bottomButtons.nodes) { var node = (ConfigNode)n; var name = node.name; var value = node.FromNode(BUTTON_STATE, false); HSUtils.DebugLog("Settings#Load name: {0} value: {1}", name, value); this.bottomButtons[name] = value; } var nodeTypeVisibility = config.GetNode(NODE_VESSEL_TYPE_VISIBILITY) ?? new ConfigNode(); foreach (var i in Resources.vesselTypesList) { i.visible = nodeTypeVisibility.GetBuiltinValue(i.name, true); } }