public void OnGUI()
        {
            if (visible && !ImportExport.helpDialogVisible)
            {
                if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
                {
                    newClick = true;
                }

                if (HighLogic.LoadedScene == GameScenes.FLIGHT || HighLogic.LoadedScene == GameScenes.TRACKSTATION)
                {
                    // Draw the marker for custom waypoints that are currently being created
                    CustomWaypointGUI.DrawMarker();
                }

                if (HighLogic.LoadedSceneIsFlight && !MapView.MapIsEnabled)
                {
                    SetupStyles();

                    WaypointData.CacheWaypointData();

                    foreach (WaypointData wpd in WaypointData.Waypoints)
                    {
                        DrawWaypoint(wpd);
                    }
                }

                if (HighLogic.LoadedSceneIsFlight && (!MapView.MapIsEnabled || ContractSystem.Instance == null))
                {
                    ShowNavigationWindow();
                }
            }
        }
 public static void Export()
 {
     if (File.Exists(CustomWaypointsFileName))
     {
         CustomWaypointGUI.ShowExportDialog();
     }
     else
     {
         DoExport();
     }
 }
        private void NavigationWindow(int windowID)
        {
            if (selectedWaypoint == null)
            {
                return;
            }

            GUILayout.BeginVertical();
            if (!Util.IsNavPoint(selectedWaypoint))
            {
                if (GUILayout.Button("Activate Navigation", HighLogic.Skin.button, GUILayout.ExpandWidth(true)))
                {
                    NavWaypoint.fetch.Setup(selectedWaypoint);
                    NavWaypoint.fetch.Activate();
                    selectedWaypoint = null;
                }
            }
            else
            {
                if (GUILayout.Button("Deactivate Navigation", HighLogic.Skin.button, GUILayout.ExpandWidth(true)))
                {
                    NavWaypoint.fetch.Clear();
                    NavWaypoint.fetch.Deactivate();
                    selectedWaypoint = null;
                }
            }
            if (CustomWaypoints.Instance.IsCustom(selectedWaypoint))
            {
                if (GUILayout.Button("Edit Custom Waypoint", HighLogic.Skin.button, GUILayout.ExpandWidth(true)))
                {
                    CustomWaypointGUI.EditWaypoint(selectedWaypoint);
                    selectedWaypoint = null;
                }
                if (GUILayout.Button("Delete Custom Waypoint", HighLogic.Skin.button, GUILayout.ExpandWidth(true)))
                {
                    CustomWaypointGUI.DeleteWaypoint(selectedWaypoint);
                    selectedWaypoint = null;
                }
            }
            GUILayout.EndVertical();
        }
        public void OnGUI()
        {
            if (visible)
            {
                if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
                {
                    newClick = true;
                }

                if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedScene == GameScenes.TRACKSTATION)
                {
                    // Draw the marker for custom waypoints that are currently being created
                    CustomWaypointGUI.DrawMarker();

                    // Draw waypoints if not in career mode
                    if (ContractSystem.Instance == null && MapView.MapIsEnabled)
                    {
                        foreach (WaypointData wpd in WaypointData.Waypoints)
                        {
                            if (wpd.celestialBody != null && wpd.waypoint.celestialName == wpd.celestialBody.name)
                            {
                                if (Event.current.type == EventType.Repaint)
                                {
                                    wpd.SetAlpha();
                                    Util.DrawWaypoint(wpd.celestialBody, wpd.waypoint.latitude, wpd.waypoint.longitude,
                                                      wpd.waypoint.altitude, wpd.waypoint.id, wpd.waypoint.seed, wpd.currentAlpha);
                                }

                                // Handling clicking on the waypoint
                                if (Event.current.type == EventType.MouseUp && Event.current.button == 0)
                                {
                                    HandleClick(wpd);
                                }

                                // Draw hint text
                                if (Event.current.type == EventType.Repaint)
                                {
                                    HintText(wpd);
                                }
                            }
                        }
                    }
                }

                if (HighLogic.LoadedSceneIsFlight && !MapView.MapIsEnabled)
                {
                    SetupStyles();

                    WaypointData.CacheWaypointData();

                    foreach (WaypointData wpd in WaypointData.Waypoints)
                    {
                        DrawWaypoint(wpd);
                    }
                }

                if (HighLogic.LoadedSceneIsFlight && (!MapView.MapIsEnabled || ContractSystem.Instance == null))
                {
                    ShowNavigationWindow();
                }
            }
        }
Exemple #5
0
        protected void WaypointLineGUI(WaypointData wpd)
        {
            if (!wpd.waypoint.visible)
            {
                return;
            }

            GUILayout.BeginHorizontal(GUILayout.Height(32));

            // Contract icon
            GUILayout.Label(ContractIcon(wpd), GUILayout.ExpandWidth(false), GUILayout.Height(38), GUILayout.Width(38));
            GUILayout.Space(2);

            // Celestial body icon
            GUILayout.Label(CelestialBodyIcon(wpd.celestialBody.name), GUILayout.ExpandWidth(false));
            GUILayout.Space(2);

            GUILayout.BeginVertical();

            // Waypoint name, distance
            GUILayout.BeginHorizontal();
            string name = wpd.waypoint.name;

            if (wpd.waypoint.isClustered)
            {
                name += " " + StringUtilities.IntegerToGreek(wpd.waypoint.index);
            }
            GUILayout.Label(name, labelStyle, GUILayout.Height(16), GUILayout.Width(GUI_WIDTH - 240), GUILayout.ExpandWidth(false));
            if (FlightGlobals.currentMainBody == wpd.celestialBody)
            {
                GUILayout.Label("Dist: " + Util.PrintDistance(wpd), labelStyle, GUILayout.Height(16), GUILayout.ExpandWidth(false));
            }
            GUILayout.EndHorizontal();

            // Waypoint location
            GUILayout.BeginHorizontal();
            GUILayout.Label("Lat: " + Util.FormatCoordinate(wpd.waypoint.latitude, true), labelStyle, GUILayout.Height(16), GUILayout.Width(GUI_WIDTH / 2.0f - 72.0f), GUILayout.ExpandWidth(false));
            GUILayout.Label("Lon: " + Util.FormatCoordinate(wpd.waypoint.longitude, false), labelStyle, GUILayout.Height(16), GUILayout.ExpandWidth(false));
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();

            if (CustomWaypoints.Instance.IsCustom(wpd.waypoint))
            {
                GUILayout.BeginVertical();
                GUILayout.Space(8);
                GUILayout.BeginHorizontal();

                if (GUILayout.Button(new GUIContent(Config.editWaypointIcon, "Edit Waypoint"), GUI.skin.label))
                {
                    CustomWaypointGUI.EditWaypoint(wpd.waypoint);
                }
                if (GUILayout.Button(new GUIContent(Config.deleteWaypointIcon, "Delete Waypoint"), GUI.skin.label))
                {
                    CustomWaypointGUI.DeleteWaypoint(wpd.waypoint);
                }

                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }

            // Active waypoint toggle
            GUILayout.BeginVertical();
            GUILayout.Space(8);
            bool isNavPoint = Util.IsNavPoint(wpd.waypoint);

            if (GUILayout.Toggle(isNavPoint, (string)null) != isNavPoint)
            {
                if (isNavPoint)
                {
                    NavWaypoint.fetch.Clear();
                    NavWaypoint.fetch.Deactivate();
                }
                else
                {
                    NavWaypoint.fetch.Setup(wpd.waypoint);
                    NavWaypoint.fetch.Activate();
                }
            }
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUILayout.Space(6);
        }
Exemple #6
0
        protected void WindowGUI(int windowID)
        {
            GUILayout.BeginVertical(GUILayout.Width(GUI_WIDTH));

            // Output grouping selectors
            GUILayout.BeginHorizontal();
            GUILayout.Label("Group by: ", GUILayout.ExpandWidth(false));
            if (ContractSystem.Instance != null)
            {
                if (GUILayout.Toggle(Config.displayMode == Config.DisplayMode.CONTRACT, "Contract"))
                {
                    Config.displayMode = Config.DisplayMode.CONTRACT;
                }
            }
            else
            {
                Config.displayMode = Config.DisplayMode.CELESTIAL_BODY;
            }
            if (GUILayout.Toggle(Config.displayMode == Config.DisplayMode.CELESTIAL_BODY, "Celestial Body"))
            {
                Config.displayMode = Config.DisplayMode.CELESTIAL_BODY;
            }

            GUILayout.FlexibleSpace();
            if (GUILayout.Button(new GUIContent(Config.addWaypointIcon, "Create Custom Waypoint"), GUI.skin.label))
            {
                CustomWaypointGUI.AddWaypoint();
            }
            GUILayout.Space(4);
            if (GUILayout.Button(new GUIContent(Config.settingsIcon, "Settings"), GUI.skin.label))
            {
                showSettings = !showSettings;
                if (!showSettings)
                {
                    Config.Save();
                }
            }
            GUILayout.EndHorizontal();

            scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.ExpandWidth(true), GUILayout.Height(520));

            if (Config.displayMode == Config.DisplayMode.CONTRACT)
            {
                foreach (WaypointData.ContractContainer cc in WaypointData.ContractContainers)
                {
                    if (GUILayout.Button(cc.title, headerButtonStyle, GUILayout.MaxWidth(GUI_WIDTH - 24.0f)))
                    {
                        cc.hidden = !cc.hidden;
                    }

                    if (!cc.hidden)
                    {
                        foreach (WaypointData wpd in cc.waypointByContract.OrderBy(wp => wp.waypoint.name + wp.waypoint.index))
                        {
                            WaypointLineGUI(wpd);
                        }
                    }
                }
            }
            else
            {
                foreach (KeyValuePair <CelestialBody, List <WaypointData> > pair in WaypointData.WaypointByBody)
                {
                    CelestialBody b      = pair.Key;
                    bool          hidden = hiddenBodies.ContainsKey(b) && hiddenBodies[b];
                    if (GUILayout.Button(b.name, headerButtonStyle, GUILayout.MaxWidth(GUI_WIDTH - 24.0f)))
                    {
                        hidden          = !hidden;
                        hiddenBodies[b] = hidden;
                    }

                    if (!hidden)
                    {
                        foreach (WaypointData wpd in pair.Value.OrderBy(wp => wp.waypoint.name + wp.waypoint.index))
                        {
                            WaypointLineGUI(wpd);
                        }
                    }
                }
            }
            GUILayout.EndScrollView();
            GUILayout.EndVertical();

            GUI.DragWindow();

            SetToolTip(0);
        }
Exemple #7
0
        void OnGUI()
        {
            // Build the cache of waypoint data
            if (Event.current.type == EventType.Layout)
            {
                WaypointData.CacheWaypointData();
            }

            if (!stylesSetup)
            {
                // Set up the label style
                labelStyle         = new GUIStyle(GUI.skin.label);
                labelStyle.padding = new RectOffset(0, 0, 0, 0);

                // Header buttons
                headerButtonStyle           = new GUIStyle(GUI.skin.button);
                headerButtonStyle.alignment = TextAnchor.MiddleLeft;
                headerButtonStyle.clipping  = TextClipping.Clip;

                // Headings
                headingStyle           = new GUIStyle(GUI.skin.label);
                headingStyle.fontStyle = FontStyle.Bold;

                // Tooltips
                tipStyle                  = new GUIStyle(GUI.skin.box);
                tipStyle.wordWrap         = true;
                tipStyle.stretchHeight    = true;
                tipStyle.normal.textColor = Color.white;

                stylesSetup = true;
            }

            GUI.depth = 0;

            if (showGUI && visible)
            {
                var ainfoV = Attribute.GetCustomAttribute(GetType().Assembly, typeof(AssemblyInformationalVersionAttribute)) as AssemblyInformationalVersionAttribute;
                Config.mainWindowPos = GUILayout.Window(
                    GetType().FullName.GetHashCode(),
                    Config.mainWindowPos,
                    WindowGUI,
                    "Waypoint Manager " + ainfoV.InformationalVersion);

                // Add the close icon
                if (GUI.Button(new Rect(Config.mainWindowPos.xMax - 18, Config.mainWindowPos.yMin + 2, 16, 16), Config.closeIcon, GUI.skin.label))
                {
                    showGUI = false;
                    HideSettings();
                }

                if (showSettings)
                {
                    // Default settings position
                    if (settingsPosition.xMin == settingsPosition.xMax)
                    {
                        settingsPosition = new Rect(Config.mainWindowPos.xMax + SETTINGS_WIDTH + 4 > Screen.width ?
                                                    Config.mainWindowPos.xMin - SETTINGS_WIDTH - 4: Config.mainWindowPos.xMax, Config.mainWindowPos.yMin, SETTINGS_WIDTH + 4, 1);
                    }

                    settingsPosition = GUILayout.Window(
                        GetType().FullName.GetHashCode() + 1,
                        settingsPosition,
                        SettingsGUI,
                        "Waypoint Manager Settings");

                    // Add the close icon
                    if (GUI.Button(new Rect(settingsPosition.xMax - 18, settingsPosition.yMin + 2, 16, 16), Config.closeIcon, GUI.skin.label))
                    {
                        HideSettings();
                    }
                }

                // Reset the position of the settings window
                if (!showSettings)
                {
                    settingsPosition.xMax = settingsPosition.xMin;
                }
            }

            // Display custom waypoint gui windows
            CustomWaypointGUI.OnGUI();

            // Draw any tooltips
            DrawToolTip();
        }
        protected void WaypointLineGUI(WaypointData wpd)
        {
            GUILayout.BeginHorizontal(GUILayout.Height(32));

            // Contract icon
            GUILayout.Label(ContractIcon(wpd), GUILayout.ExpandWidth(false), GUILayout.Height(38));
            GUILayout.Space(2);

            // Celestial body icon
            GUILayout.Label(CelestialBodyIcon(wpd.celestialBody.name), GUILayout.ExpandWidth(false));
            GUILayout.Space(2);

            GUILayout.BeginVertical();

            // Waypoint name
            string name = wpd.waypoint.name;

            if (wpd.waypoint.isClustered)
            {
                name += " " + StringUtilities.IntegerToGreek(wpd.waypoint.index);
            }
            GUILayout.Label(name, labelStyle, GUILayout.Height(16), GUILayout.ExpandWidth(false));

            // Waypoint distance
            GUILayout.Label("Distance: " + Util.PrintDistance(wpd), labelStyle, GUILayout.Height(16), GUILayout.ExpandWidth(false));

            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();

            if (CustomWaypoints.Instance.IsCustom(wpd.waypoint))
            {
                GUILayout.BeginVertical();
                GUILayout.Space(8);
                GUILayout.BeginHorizontal();

                if (GUILayout.Button(new GUIContent(Config.editWaypointIcon, "Edit Waypoint"), GUI.skin.label))
                {
                    CustomWaypointGUI.EditWaypoint(wpd.waypoint);
                }
                if (GUILayout.Button(new GUIContent(Config.deleteWaypointIcon, "Delete Waypoint"), GUI.skin.label))
                {
                    CustomWaypointGUI.DeleteWaypoint(wpd.waypoint);
                }

                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }

            // Active waypoint toggle
            GUILayout.BeginVertical();
            GUILayout.Space(8);
            bool isNavPoint = Util.IsNavPoint(wpd.waypoint);

            if (GUILayout.Toggle(isNavPoint, (string)null) != isNavPoint)
            {
                if (isNavPoint)
                {
                    FinePrint.WaypointManager.clearNavPoint();
                }
                else
                {
                    FinePrint.WaypointManager.setupNavPoint(wpd.waypoint);
                    FinePrint.WaypointManager.activateNavPoint();
                }
            }
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            GUILayout.Space(6);
        }