public void OnClick()
		{
			MapIconSelector.Close();
			MapIconSelector.selectedSite = this;
			MapIconSelector.useLaunchSite = true;
			MapIconSelector.Open();
			NavGuidanceSystem.setTargetSite(this);
		}
        /// <summary>
        /// Called after Awake. used for setting up references between objects and initializing windows.
        /// </summary>
        public void Start()
        {
            Log.Warning("WindowManager Start");
            KerbalKonstructs.instance.WindowManager = this;

            GUI_Editor             = new EditorGUI();
            GUI_StaticsEditor      = new StaticsEditorGUI();
            GUI_NGS                = new NavGuidanceSystem();
            GUI_Downlink           = new DownlinkGUI();
            GUI_FlightManager      = new BaseBossFlight();
            GUI_FacilityManager    = new FacilityManager();
            GUI_LaunchSiteSelector = new LaunchSiteSelectorGUI();
            GUI_MapIconManager     = new MapIconManager();
            GUI_KSCManager         = new KSCManagerNGUI();
            GUI_AirRacingApp       = new AirRacing();
            GUI_BaseManager        = new BaseManager();
            GUI_Settings           = new KKSettingsNGUI();
            GUI_ModelInfo          = new ModelInfo();
        }
Example #3
0
        public void DrawLaunchsites()
        {
            displayingTooltip = false;
            body = PlanetariumCamera.fetch.target.GetReferenceBody();

            bool isOpen = false;

            // Then do launchsites
            for (int index = 0; index < lauchSites.Length; index++)
            {
                launchSite = lauchSites[index];
                // check if we should display the site or not this is the fastst check, so it shoud be first
                isOpen = launchSite.isOpen;

                if (!KerbalKonstructs.instance.mapShowHelipads && launchSite.sitecategory == LaunchSiteCategory.Helipad)
                {
                    continue;
                }
                if (!KerbalKonstructs.instance.mapShowOther && (launchSite.sitecategory == LaunchSiteCategory.Other))
                {
                    continue;
                }
                if (!KerbalKonstructs.instance.mapShowWaterLaunch && (launchSite.sitecategory == LaunchSiteCategory.Waterlaunch))
                {
                    continue;
                }
                if (!KerbalKonstructs.instance.mapShowRocketbases && launchSite.sitecategory == LaunchSiteCategory.RocketPad)
                {
                    continue;
                }
                if (!KerbalKonstructs.instance.mapShowRunways && launchSite.sitecategory == LaunchSiteCategory.Runway)
                {
                    continue;
                }

                if (MiscUtils.isCareerGame())
                {
                    if (!KerbalKonstructs.instance.mapShowOpen && isOpen)
                    {
                        continue;
                    }
                    if (!KerbalKonstructs.instance.mapShowClosed && !isOpen)
                    {
                        continue;
                    }
                    // don't show hidden bases when closed
                    if (launchSite.LaunchSiteIsHidden && !isOpen)
                    {
                        continue;
                    }
                }

                launchSitePosition = (Vector3)launchSite.body.GetWorldSurfacePosition(launchSite.refLat, launchSite.refLon, launchSite.refAlt) - MapView.MapCamera.GetComponent <Camera>().transform.position;

                if (mapHideIconsBehindBody && IsOccluded(launchSitePosition, body))
                {
                    continue;
                }

                lsPosition = MapView.MapCamera.GetComponent <Camera>().WorldToScreenPoint(ScaledSpace.LocalToScaledSpace(launchSitePosition));
                screenRect = new Rect((lsPosition.x - 8), (Screen.height - lsPosition.y) - 8, 16, 16);

                // Distance between camera and spawnpoint sort of
                float fPosZ = lsPosition.z;

                float fRadarRadius = 12800 / fPosZ;
                float fRadarOffset = fRadarRadius / 2;


                if (launchSite.icon != null)
                {
                    if (fRadarRadius > 15)
                    {
                        GUI.DrawTexture(screenRect, launchSite.icon, ScaleMode.ScaleToFit, true);
                    }
                }
                else
                {
                    if (fRadarRadius > 15)
                    {
                        switch (launchSite.sitecategory)
                        {
                        case LaunchSiteCategory.RocketPad:
                            GUI.DrawTexture(screenRect, UIMain.VABIcon, ScaleMode.ScaleToFit, true);
                            break;

                        case LaunchSiteCategory.Runway:
                            GUI.DrawTexture(screenRect, UIMain.runWayIcon, ScaleMode.ScaleToFit, true);
                            break;

                        case LaunchSiteCategory.Helipad:
                            GUI.DrawTexture(screenRect, UIMain.heliPadIcon, ScaleMode.ScaleToFit, true);
                            break;

                        case LaunchSiteCategory.Waterlaunch:
                            GUI.DrawTexture(screenRect, UIMain.waterLaunchIcon, ScaleMode.ScaleToFit, true);
                            break;

                        default:
                            GUI.DrawTexture(screenRect, UIMain.ANYIcon, ScaleMode.ScaleToFit, true);
                            break;
                        }
                    }
                }

                // Tooltip
                if (!displayingTooltip && screenRect.Contains(Event.current.mousePosition))
                {
                    //Only display one tooltip at a time
                    string sToolTip = "";
                    sToolTip = launchSite.LaunchSiteName;
                    if (launchSite.LaunchSiteName == "Runway")
                    {
                        sToolTip = "KSC Runway";
                    }
                    if (launchSite.LaunchSiteName == "LaunchPad")
                    {
                        sToolTip = "KSC LaunchPad";
                    }
                    DisplayMapIconToolTip(sToolTip, lsPosition);

                    // Select a base by clicking on the icon
                    if (Event.current.type == EventType.mouseDown && Event.current.button == 0)
                    {
                        MiscUtils.HUDMessage("Selected base is " + sToolTip + ".", 5f, 3);
                        BaseManager.setSelectedSite(launchSite);
                        selectedSite = launchSite;
                        NavGuidanceSystem.setTargetSite(selectedSite);
                        BaseManager.instance.Open();
                    }
                }
            }
        }