Exemplo n.º 1
0
        private static void ExportGUI(int windowID)
        {
            GUILayout.BeginVertical();
            GUILayout.Label("Overwrite custom waypoint file '" + CustomWaypoints.CustomWaypointsFileName + "'?");
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Yes"))
            {
                CustomWaypoints.DoExport();
                showExportDialog = false;
            }
            if (GUILayout.Button("No"))
            {
                showExportDialog = false;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUI.DragWindow();
        }
Exemplo n.º 2
0
        private static void DeleteGUI(int windowID)
        {
            GUILayout.BeginVertical();
            GUILayout.Label("Delete custom waypoint '" + selectedWaypoint.name + "'?");
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Yes"))
            {
                CustomWaypoints.RemoveWaypoint(selectedWaypoint);
                windowMode = WindowMode.None;
            }
            if (GUILayout.Button("No"))
            {
                windowMode = WindowMode.None;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUI.DragWindow();
        }
Exemplo n.º 3
0
        void ImportSelectedFile(int cnt)
        {
            var        wayPointFile = waypointFiles[cnt];
            var        fullpath     = string.Join(Path.DirectorySeparatorChar.ToString(), path, wayPointFile);
            ConfigNode master       = new ConfigNode();
            var        configNode   = ConfigNode.Load(fullpath);

            CustomWaypoints.AddWaypointsFromConfig(master, configNode);
            ScenarioCustomWaypoints.Instance.OnLoad(master);

            int count = master.nodes.Count;

            if (count > 0)
            {
                Log.Info("[WM] Imported " + count + " waypoint" + (count != 1 ? "s" : "") + " from " + wayPointFile);
                ScreenMessages.PostScreenMessage("Imported " + count + " waypoint" + (count != 1 ? "s" : "") + " from " + wayPointFile,
                                                 6.0f, ScreenMessageStyle.UPPER_CENTER);
            }
            else
            {
                Log.Info("[WM] No new waypoints found to import");
                ScreenMessages.PostScreenMessage("No new waypoints found to import", 6f);
            }
        }
Exemplo n.º 4
0
 public CustomWaypoints()
 {
     Instance = this;
 }
Exemplo n.º 5
0
        protected void SettingsGUI(int windowID)
        {
            GUILayout.BeginVertical(GUILayout.Width(SETTINGS_WIDTH));

            // Distance calculation method
            GUILayout.Label("Distance calculation", headingStyle);
            GUIContent guiContent = new GUIContent("Lateral", "Calculates distance as the horizontal distance only.  Useful if you're looking to hit a landing spot exactly.");

            if (GUILayout.Toggle(Config.distanceCalcMethod == Config.DistanceCalcMethod.LATERAL, guiContent))
            {
                Config.distanceCalcMethod = Config.DistanceCalcMethod.LATERAL;
            }
            guiContent = new GUIContent("Straight line", "Calculates distance in a direct line.");
            if (GUILayout.Toggle(Config.distanceCalcMethod == Config.DistanceCalcMethod.STRAIGHT_LINE, guiContent))
            {
                Config.distanceCalcMethod = Config.DistanceCalcMethod.STRAIGHT_LINE;
            }
            guiContent = new GUIContent("Compromise", "Uses lateral distance if the vessel and waypoint altitude are relatively close, otherwise uses straight line distance.");
            if (GUILayout.Toggle(Config.distanceCalcMethod == Config.DistanceCalcMethod.COMPROMISE, guiContent))
            {
                Config.distanceCalcMethod = Config.DistanceCalcMethod.COMPROMISE;
            }

            // In-Flight Waypoints :)
            GUILayout.Label("Waypoints to display in-flight", headingStyle);
            guiContent = new GUIContent("All", "Display all waypoints on the given celestial body while in flight.");
            if (GUILayout.Toggle(Config.waypointDisplay == Config.WaypointDisplay.ALL, guiContent))
            {
                Config.waypointDisplay = Config.WaypointDisplay.ALL;
            }
            guiContent = new GUIContent("Active", "Display only the active waypoint while in flight.");
            if (GUILayout.Toggle(Config.waypointDisplay == Config.WaypointDisplay.ACTIVE, guiContent))
            {
                Config.waypointDisplay = Config.WaypointDisplay.ACTIVE;
            }
            guiContent = new GUIContent("None", "Do not display any waypoints while in flight.");
            if (GUILayout.Toggle(Config.waypointDisplay == Config.WaypointDisplay.NONE, guiContent))
            {
                Config.waypointDisplay = Config.WaypointDisplay.NONE;
            }

            // HUD
            GUILayout.Label("Values to display below altimeter", headingStyle);
            if (GUILayout.Toggle(Config.hudDistance, "Distance to target") != Config.hudDistance)
            {
                Config.hudDistance = !Config.hudDistance;
            }
            if (GUILayout.Toggle(Config.hudTime, "Time to target") != Config.hudTime)
            {
                Config.hudTime = !Config.hudTime;
            }
            if (GUILayout.Toggle(Config.hudHeading, "Heading to target") != Config.hudHeading)
            {
                Config.hudHeading = !Config.hudHeading;
            }
            if (GUILayout.Toggle(Config.hudAngle, "Glide slope angles") != Config.hudAngle)
            {
                Config.hudAngle = !Config.hudAngle;
            }

            // Display style
            GUILayout.Label("Location display style", headingStyle);
            if (GUILayout.Toggle(!Config.displayDecimal, "Degrees/Minutes/Seconds") == Config.displayDecimal)
            {
                Config.displayDecimal = false;
            }
            if (GUILayout.Toggle(Config.displayDecimal, "Decimal") != Config.displayDecimal)
            {
                Config.displayDecimal = true;
            }


            // Toolbar
            if (ToolbarManager.ToolbarAvailable)
            {
                GUILayout.Label("Toolbar Display", headingStyle);
                if (GUILayout.Toggle(Config.useStockToolbar, "Show icon in stock toolbar") != Config.useStockToolbar)
                {
                    Config.useStockToolbar = !Config.useStockToolbar;
                    if (Config.useStockToolbar)
                    {
                        SetupToolbar();
                    }
                    else
                    {
                        TeardownToolbar(GameScenes.FLIGHT);
                    }
                }
            }

            // Opacity
            GUILayout.Label("Waypoint Opacity", headingStyle);
            Config.opacity = GUILayout.HorizontalSlider(Config.opacity, 0.3f, 1.0f);

            if (GUILayout.Button(new GUIContent("Export Custom Waypoints", "Exports the custom waypoints to GameData/WaypointManager/CustomWaypoints.cfg")))
            {
                CustomWaypoints.Export();
            }
            if (GUILayout.Button(new GUIContent("Import Custom Waypoints", "Imports the custom waypoints from GameData/WaypointManager/CustomWaypoints.cfg")))
            {
                CustomWaypoints.Import();
            }

            GUILayout.EndVertical();

            GUI.DragWindow();

            SetToolTip(1);
        }
Exemplo n.º 6
0
        private static void WindowGUI(int windowID)
        {
            GUILayout.BeginVertical();

            template.name = GUILayout.TextField(template.name);

            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Label("Latitude", GUILayout.Width(68));
            GUILayout.Label("Longitude", GUILayout.Width(68));
            GUILayout.EndVertical();

            GUILayout.Space(4);

            string val;
            float  floatVal;

            GUILayout.BeginVertical();
            val = GUILayout.TextField(latitude, GUILayout.Width(140));
            if (float.TryParse(val, out floatVal))
            {
                latitude       = val;
                recalcAltitude = true;
            }
            val = GUILayout.TextField(longitude, GUILayout.Width(140));
            if (float.TryParse(val, out floatVal))
            {
                longitude      = val;
                recalcAltitude = true;
            }

            GUILayout.EndVertical();

            GUILayout.Space(4);

            GUILayout.BeginVertical();
            if (GUILayout.Button(Util.GetContractIcon(template.id, template.seed)))
            {
                showIconPicker = !showIconPicker;

                selectedIcon  = Array.IndexOf(icons, icons.Where(c => c.tooltip == template.id).First());
                selectedColor = Array.IndexOf(seeds, template.seed);
                if (selectedIcon == -1)
                {
                    selectedIcon = 0;
                }
                if (selectedColor == -1)
                {
                    selectedColor = 0;
                }
            }
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(80);
            if (GUILayout.Toggle(useTerrainHeight, new GUIContent("Use terrain height for altitude", "Automatically set the altitude to ground level.")) != useTerrainHeight)
            {
                useTerrainHeight = !useTerrainHeight;
                recalcAltitude   = true;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUILayout.Label("Altitude", GUILayout.Width(72));
            val = GUILayout.TextField(altitude, useTerrainHeight ? disabledText : GUI.skin.textField, GUILayout.Width(140));
            if (!useTerrainHeight && float.TryParse(val, out floatVal))
            {
                altitude = val;
            }
            GUILayout.EndHorizontal();

            if (HighLogic.LoadedScene == GameScenes.FLIGHT)
            {
                if (GUILayout.Button(new GUIContent("Use Active Vessel Location", "Set the location parameters to that of the currently active vessel.")))
                {
                    latitude       = FlightGlobals.ActiveVessel.latitude.ToString();
                    longitude      = FlightGlobals.ActiveVessel.longitude.ToString();
                    altitude       = FlightGlobals.ActiveVessel.altitude.ToString();
                    recalcAltitude = true;
                }
            }

            if (HighLogic.LoadedScene == GameScenes.FLIGHT && MapView.MapIsEnabled || HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                string label = mapLocationMode ? "Cancel Set Location" : "Set Location on Map";
                if (GUILayout.Button(new GUIContent(label, "Set the location by clicking on the map.")))
                {
                    mapLocationMode = !mapLocationMode;
                }
            }
            else
            {
                mapLocationMode = false;
            }

            GUILayout.BeginHorizontal();
            bool save   = GUILayout.Button("Save");
            bool apply  = GUILayout.Button("Apply");
            bool cancel = GUILayout.Button("Cancel");

            if (save || apply)
            {
                template.latitude  = double.Parse(latitude);
                template.longitude = double.Parse(longitude);
                template.height    = Util.WaypointHeight(template, targetBody);
                template.altitude  = double.Parse(altitude) - template.height;
                if (windowMode == WindowMode.Add)
                {
                    CustomWaypoints.AddWaypoint(template);
                    selectedWaypoint = template;
                    template         = new Waypoint();
                }
                else
                {
                    selectedWaypoint.id        = template.id;
                    selectedWaypoint.name      = template.name;
                    selectedWaypoint.latitude  = template.latitude;
                    selectedWaypoint.longitude = template.longitude;
                    selectedWaypoint.altitude  = template.altitude;
                    selectedWaypoint.height    = template.height;
                    selectedWaypoint.seed      = template.seed;
                }
            }
            if (save || cancel)
            {
                windowMode = WindowMode.None;
            }
            else if (apply)
            {
                EditWaypoint(selectedWaypoint);
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();

            GUI.DragWindow();

            if (useTerrainHeight && recalcAltitude)
            {
                recalcAltitude = false;
                altitude       = Util.TerrainHeight(double.Parse(latitude), double.Parse(longitude), targetBody).ToString();
            }

            WaypointManager.Instance.SetToolTip(windowID - typeof(WaypointManager).FullName.GetHashCode());
        }
Exemplo n.º 7
0
        protected void SettingsGUI(int windowID)
        {
            GUILayout.BeginVertical(GUILayout.Width(SETTINGS_WIDTH));

            // Distance calculation method
            GUILayout.Label("Distance calculation", headingStyle);
            GUIContent guiContent = new GUIContent("Lateral", "Calculates distance as the horizontal distance only.  Useful if you're looking to hit a landing spot exactly.");

            if (GUILayout.Toggle(Config.distanceCalcMethod == Config.DistanceCalcMethod.LATERAL, guiContent))
            {
                Config.distanceCalcMethod = Config.DistanceCalcMethod.LATERAL;
            }
            guiContent = new GUIContent("Straight line", "Calculates distance in a direct line.");
            if (GUILayout.Toggle(Config.distanceCalcMethod == Config.DistanceCalcMethod.STRAIGHT_LINE, guiContent))
            {
                Config.distanceCalcMethod = Config.DistanceCalcMethod.STRAIGHT_LINE;
            }
            guiContent = new GUIContent("Compromise", "Uses lateral distance if the vessel and waypoint altitude are relatively close, otherwise uses straight line distance.");
            if (GUILayout.Toggle(Config.distanceCalcMethod == Config.DistanceCalcMethod.COMPROMISE, guiContent))
            {
                Config.distanceCalcMethod = Config.DistanceCalcMethod.COMPROMISE;
            }

            // In-Flight Waypoints :)
            GUILayout.Label("Waypoints to display in-flight", headingStyle);
            guiContent = new GUIContent("All", "Display all waypoints on the given celestial body while in flight.");
            if (GUILayout.Toggle(Config.waypointDisplay == Config.WaypointDisplay.ALL, guiContent))
            {
                Config.waypointDisplay = Config.WaypointDisplay.ALL;
            }
            guiContent = new GUIContent("Active", "Display only the active waypoint while in flight.");
            if (GUILayout.Toggle(Config.waypointDisplay == Config.WaypointDisplay.ACTIVE, guiContent))
            {
                Config.waypointDisplay = Config.WaypointDisplay.ACTIVE;
            }
            guiContent = new GUIContent("None", "Do not display any waypoints while in flight.");
            if (GUILayout.Toggle(Config.waypointDisplay == Config.WaypointDisplay.NONE, guiContent))
            {
                Config.waypointDisplay = Config.WaypointDisplay.NONE;
            }

            // HUD
            GUILayout.Label("Values to display below altimeter", headingStyle);
            if (GUILayout.Toggle(Config.hudDistance, "Distance to target") != Config.hudDistance)
            {
                Config.hudDistance = !Config.hudDistance;
            }
            if (GUILayout.Toggle(Config.hudTime, "Time to target") != Config.hudTime)
            {
                Config.hudTime = !Config.hudTime;
            }
            if (GUILayout.Toggle(Config.hudHeading, "Heading to target") != Config.hudHeading)
            {
                Config.hudHeading = !Config.hudHeading;
            }
            if (GUILayout.Toggle(Config.hudAngle, "Glide slope angles") != Config.hudAngle)
            {
                Config.hudAngle = !Config.hudAngle;
            }

            // Display style
            GUILayout.Label("Location display style", headingStyle);
            if (GUILayout.Toggle(!Config.displayDecimal, "Degrees/Minutes/Seconds") == Config.displayDecimal)
            {
                Config.displayDecimal = false;
            }
            if (GUILayout.Toggle(Config.displayDecimal, "Decimal") != Config.displayDecimal)
            {
                Config.displayDecimal = true;
            }

            // Opacity
            GUILayout.Label("Waypoint Opacity", headingStyle);
            GUILayout.BeginHorizontal();
            Config.opacity = GUILayout.HorizontalSlider(Config.opacity, 0.3f, 1.0f);
            GUILayout.Space(5);
            if (GUILayout.Button("Reset", GUILayout.Width(50)))
            {
                Config.opacity = 1.0f;
            }
            GUILayout.EndHorizontal();
            if (GUILayout.Button(new GUIContent("Export Custom Waypoints", "Exports the custom waypoints to GameData/WaypointManager/CustomWaypoints.cfg")))
            {
                CustomWaypoints.Export();
            }
            if (importExportWindow == null)
            {
                if (GUILayout.Button(new GUIContent("Import Custom Waypoints", "Imports the custom waypoints from GameData/WaypointManager/CustomWaypoints.cfg")))
                {
                    if (importExportWindow == null)
                    {
                        importExportWindow = gameObject.AddComponent <ImportExport>();
                    }
                    //CustomWaypoints.Import();
                }
            }
            else
            {
                if (GUILayout.Button(new GUIContent("Cancel Import of Custom Waypoints", "Cancels the import of custom waypoints from GameData/WaypointManager/CustomWaypoints.cfg")))
                {
                    Destroy(importExportWindow);
                }
            }

            GUILayout.Label("UI Scaling (" + (Config.scaling * 100).ToString("F0") + "%)", headingStyle);
            GUILayout.BeginHorizontal();
            Config.scaling = GUILayout.HorizontalSlider(Config.scaling, 0.8f, 1.5f);
            GUILayout.Space(5);
            if (GUILayout.Button("Reset", GUILayout.Width(50)))
            {
                Config.scaling = 1.0f;
            }
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUI.DragWindow();

            SetToolTip(1);
        }