public override bool Draw(float backgroundFadeAlpha)
        {
            foreach (var sectorNavigationMarksKvp in m_data.NavigationMarks)
            {
                foreach (var navigationMark in sectorNavigationMarksKvp.Value)
                {
                    navigationMark.Update(m_camera);
                }
            }

            m_solarMapRender.Draw(m_camera, m_data);

            MyHud.DrawOnlyMissionObjectives();

            MySolarSystemMapNavigationMark navigationMarkUnderMouse = GetNearestNavigationMarkUnderMouseCursor();

            if (navigationMarkUnderMouse != null)
            {
                var toolTipPosition = MyGuiManager.MouseCursorPosition + MyGuiConstants.TOOL_TIP_RELATIVE_DEFAULT_POSITION;
                m_toolTip.Draw(toolTipPosition);
            }

            base.Draw(backgroundFadeAlpha);

            return(true);
        }
Exemplo n.º 2
0
        public override void AddSolarMapMarks(MySolarSystemMapData data)
        {
            foreach (var objective in ActiveObjectives)
            {
                if (objective.Location != null && !MyGuiScreenGamePlay.Static.IsCurrentSector(objective.Location.Sector) && objective.ShowNavigationMark)
                {
                    var missionMark = new MySolarSystemMapNavigationMark(objective.Location.Sector, objective.NameTemp.ToString(), null, MyHudConstants.MISSION_MARKER_COLOR, TransparentGeometry.MyTransparentMaterialEnum.SolarMapNavigationMark)
                    {
                        VerticalLineColor = MyHudConstants.MISSION_MARKER_COLOR.ToVector4(), DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_white
                    };
                    data.NavigationMarks.Add(missionMark);
                }

                objective.AddSolarMapMarks(data);
            }

            if (Location != null && !MyGuiScreenGamePlay.Static.IsCurrentSector(Location.Sector) && ShowNavigationMark)
            {
                var missionMark = new MySolarSystemMapNavigationMark(Location.Sector, NameTemp.ToString(), null, MyHudConstants.ACTIVE_MISSION_SOLAR_MAP_COLOR, TransparentGeometry.MyTransparentMaterialEnum.SolarMapNavigationMark)
                {
                    VerticalLineColor = MyHudConstants.MISSION_MARKER_COLOR.ToVector4(), DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_white
                };
                data.NavigationMarks.Add(missionMark);
            }
        }
        private string GetSectorName(MySolarSystemMapNavigationMark navigationMark)
        {
            string sectorName = navigationMark.Name;

            if (String.IsNullOrWhiteSpace(sectorName))
            {
                sectorName = navigationMark.Text;
            }

            if (String.IsNullOrWhiteSpace(sectorName))
            {
                sectorName = navigationMark.Sector.ToString();
            }

            return(sectorName);
        }
        private void AddMarks()
        {
            foreach (var sector in SectorCache)
            {
                const int centerDist = 1;
                if (MyFakes.HIDE_CENTER_SECTOR_MARKS && Math.Abs(sector.Position.X) <= centerDist && Math.Abs(sector.Position.Y) <= centerDist && Math.Abs(sector.Position.Z) <= centerDist)
                {
                    continue;
                }

                var mark = new MySolarSystemMapNavigationMark(sector.Position, sector.SectorName,
                                                              null,
                                                              MyHudConstants.SOLAR_MAP_SIDE_MISSION_MARKER_COLOR,
                                                              TransparentGeometry.MyTransparentMaterialEnum.SolarMapSideMission)
                {
                    DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_white,
                };


                m_data.NavigationMarks.Add(mark);
            }
        }
        private MySolarSystemMapNavigationMark GetNearestNavigationMarkUnderMouseCursor()
        {
            MySolarSystemMapNavigationMark nearestNavigationMarkUnderMouse = null;
            float nearestDistanceFromCamera = float.MaxValue;

            foreach (var sectorNavigationMarksKvp in m_data.NavigationMarks)
            {
                foreach (var navigationMark in sectorNavigationMarksKvp.Value)
                {
                    if (navigationMark.IsMouseOver())
                    {
                        float distanceFromCamera = navigationMark.WorldPosition.Length();
                        if (distanceFromCamera < nearestDistanceFromCamera)
                        {
                            nearestDistanceFromCamera       = distanceFromCamera;
                            nearestNavigationMarkUnderMouse = navigationMark;
                        }
                    }
                }
            }

            return(nearestNavigationMarkUnderMouse);
        }
        public MyGuiScreenSolarSystemMap(MyGuiScreenBase parent, MyMwcSectorIdentifier currentSector)
            : base(new Vector2(0.5f, 0.5f), null, Vector2.One)
        {
            m_parent = parent;
            m_enableBackgroundFade = false;
            DrawMouseCursor        = true;
            m_currentSector        = currentSector;
            m_closeOnEsc           = true;

            Static = this;

            MySolarSystemGenerator generator = new MySolarSystemGenerator(UNIVERSE_SEED);

            generator.Generate(1024);

            m_data           = generator.SolarSystemData;
            m_solarMapRender = new MySolarMapRenderer();
            m_solarMapRender.PlayerSector = currentSector.Position;

            //MyMinerGame.SwitchPause();
            m_particlesEnabled = TransparentGeometry.Particles.MyParticlesManager.Enabled;
            TransparentGeometry.Particles.MyParticlesManager.Enabled = false;

            //AddCaption(MyTextsWrapperEnum.SolarSystemMap);

            MySolarSystemMapNavigationMark playerNavigationMark =
                new MySolarSystemMapNavigationMark(
                    currentSector.Position,
                    "",
                    null,
                    MyHudConstants.SOLAR_MAP_PLAYER_MARKER_COLOR,
                    MyTransparentMaterialEnum.SolarMapPlayer)
            {
                VerticalLineColor  = MyHudConstants.SOLAR_MAP_PLAYER_MARKER_COLOR.ToVector4(),
                DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_green,
                Offset             = new Vector3(0, 0.0f, 0),
                Text       = MyClientServer.LoggedPlayer.GetDisplayName().ToString(),
                Importance = 50
            };

            m_data.NavigationMarks.Add(playerNavigationMark);

            if (MyGuiScreenGamePlay.Static.IsEditorStoryActive() || MyGuiScreenGamePlay.Static.GetPreviousGameType() == MyGuiScreenGamePlayType.EDITOR_STORY)
            {
                // Loads all marks, we want it for editor
                LoadMarks(false);
            }
            else
            {
                // Load only active marks
                MyMissions.AddSolarMapMarks(m_data);
            }

            if (MyMissions.ActiveMission != null)
            {
                MyMissions.ActiveMission.AddSolarMapMarks(m_data);
            }

            m_travelButton = new MyGuiControlButton(this, new Vector2(0.0f, 0.40f),
                                                    new Vector2(650f / 1600f, 120f / 1200f),
                                                    MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                                                    MyGuiManager.GetTravelButtonTexture(),
                                                    MyGuiManager.GetTravelButtonTexture(),
                                                    MyGuiManager.GetTravelButtonTexture(),
                                                    MyTextsWrapperEnum.Travel,
                                                    MyGuiConstants.BACK_BUTTON_TEXT_COLOR,
                                                    MyGuiConstants.BACK_BUTTON_TEXT_SCALE,
                                                    MyGuiControlButtonTextAlignment.CENTERED,
                                                    OnTravelClick,
                                                    false,
                                                    MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                                                    true,
                                                    false);
            m_travelButton.TextOffset = new Vector2(0, -0.0030f);
            m_travelButton.Visible    = false;
            Controls.Add(m_travelButton);

            // target sector 0, 0, 0
            // distance is 1.7 sectors from camera
            Vector3 sector;

            var mostImportantMark = m_data.NavigationMarks.GetMostImportant();

            if (mostImportantMark != null)
            {
                sector = new Vector3(mostImportantMark.Sector.X, mostImportantMark.Sector.Y, mostImportantMark.Sector.Z);
            }
            else
            {
                sector = new Vector3(currentSector.Position.X, currentSector.Position.Y, currentSector.Position.Z);
            }

            sector.Y = 0;

            m_camera = new MySolarSystemMapCamera(sector * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS, 10000000.0f * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS);
            m_camera.MinDistanceToTarget = 1.7f * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS;
            m_camera.MaxDistanceToTarget = 1.2f * MySolarSystemUtils.MillionKmToSectors(MyBgrCubeConsts.NEPTUNE_POSITION.Length()) * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS;
            m_camera.MaxSector           = MySolarSystemUtils.MillionKmToSectors(MyBgrCubeConsts.NEPTUNE_POSITION.Length());

            MyGuiManager.FullscreenHudEnabled = true;
        }
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            base.HandleInput(input, receivedFocusInThisUpdate);

            if (MyGuiInput.ENABLE_DEVELOPER_KEYS)
            {
                if (input.IsNewKeyPress(Keys.C) && input.IsAnyCtrlKeyPressed())
                {
                    CopySector();
                }
                if (input.IsNewKeyPress(Keys.V) && input.IsAnyCtrlKeyPressed())
                {
                    PasteSector();
                }
            }


            if (MyFakes.DRAW_FACTION_AREAS_IN_SOLAR_MAP)
            {
                MySolarMapAreaInput.HandleInput(m_solarMapRender, input, receivedFocusInThisUpdate);
            }

            float   rollIndicator     = input.GetRoll();
            Vector2 rotationIndicator = Vector2.Zero;

            if (input.IsNewRightMousePressed() && MyVideoModeManager.IsHardwareCursorUsed())
            {
                m_oldRotationIndicator = input.GetRotation();
            }

            if (input.IsRightMousePressed())
            {
                if (MyVideoModeManager.IsHardwareCursorUsed())
                {
                    rotationIndicator      = m_oldRotationIndicator - input.GetRotation();
                    m_oldRotationIndicator = input.GetRotation();
                }
                else
                {
                    rotationIndicator = input.GetRotation();
                }
            }
            Vector3 moveIndicator = input.GetPositionDelta();

            if (input.IsKeyPress(Keys.Left))
            {
                moveIndicator.X = -1;
            }
            if (input.IsKeyPress(Keys.Right))
            {
                moveIndicator.X = 1;
            }
            if (input.IsKeyPress(Keys.Up))
            {
                moveIndicator.Z = -1;
            }
            if (input.IsKeyPress(Keys.Down))
            {
                moveIndicator.Z = 1;
            }

            m_camera.Zoom(input.DeltaMouseScrollWheelValue());

            m_camera.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, 1);


            bool sectorChanged = false;

            if (m_lastSector != m_camera.TargetSector)
            {
                sectorChanged = true;
                m_lastSector  = m_camera.TargetSector;
            }



            MySolarSystemMapNavigationMark navigationMarkUnderMouse = GetNearestNavigationMarkUnderMouseCursor();

            const float maxHeightForEnter = MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS * 16;

            if (sectorChanged) // we have moved camera so deselect sector
            {
                m_selectedSector = null;
            }


            // tool tips
            if (m_lastNavigationMarkUnderMouse != navigationMarkUnderMouse)
            {
                m_toolTip.ClearToolTips();
                if (navigationMarkUnderMouse != null)
                {
                    m_toolTip.AddToolTip(new StringBuilder(GetSectorName(navigationMarkUnderMouse)));
                    if (!String.IsNullOrEmpty(navigationMarkUnderMouse.Description))
                    {
                        m_toolTip.AddToolTip(new StringBuilder(navigationMarkUnderMouse.Description), Color.LightGray);
                    }
                    m_toolTip.AddToolTip(new StringBuilder(navigationMarkUnderMouse.Sector.ToString()), Color.LightGray);
                }
                m_lastNavigationMarkUnderMouse = navigationMarkUnderMouse;
            }



            if (navigationMarkUnderMouse != null)
            {
                MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorHandTexture());

                if (input.IsNewLeftMousePressed() && !m_travelButton.IsMouseOver())
                {
                    MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
                    if (m_selectedNavigationMark != null)
                    {
                        m_selectedNavigationMark.Highlight = false;
                    }

                    m_selectedNavigationMark           = navigationMarkUnderMouse;
                    m_selectedNavigationMark.Highlight = true;
                    sectorChanged          = true;
                    m_slectionLocked       = true;
                    m_travelButton.Visible = false;
                }
                if (input.IsNewLeftMouseDoubleClick())
                {
                    TravelToSector(navigationMarkUnderMouse.Sector, navigationMarkUnderMouse.MissionID);
                }
            }
            else if (m_camera.CameraDistance < maxHeightForEnter && !m_slectionLocked)
            {
                if (MyGuiScreenGamePlay.CanTravelToSector(m_camera.TargetSector))
                {
                    //MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorHandTexture());
                    if (m_selectedNavigationMark != null)
                    {
                        m_selectedNavigationMark.Highlight = false;
                    }

                    var navigationMarkUnderCamera = GetNavigationMarkUnderCamera();
                    if (navigationMarkUnderCamera != null && navigationMarkUnderCamera.Sector == m_camera.TargetSector)
                    {
                        m_selectedNavigationMark = navigationMarkUnderCamera;
                    }
                    else
                    {
                        m_selectedNavigationMark = new MySolarSystemMapNavigationMark(m_camera.TargetSector, "");
                        m_travelButton.Visible   = false;
                    }
                }
                else
                {
                    m_selectedNavigationMark = null;
                }
            }
            else if (input.IsNewLeftMousePressed())
            {
                if (m_selectedNavigationMark != null)
                {
                    m_selectedNavigationMark.Highlight = false;
                }
                if (!m_travelButton.IsMouseOver())
                {
                    m_selectedNavigationMark = null;
                }
                m_slectionLocked = false;
            }
            else if (sectorChanged && m_camera.CameraDistance > maxHeightForEnter && !m_slectionLocked)
            {
                m_selectedNavigationMark = null;
            }
            else
            {
                MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorArrowTexture());
            }



            if (m_selectedNavigationMark != null)
            {
                if (!m_travelButton.Visible)
                {
                    m_travelButton.Text.Clear();
                    string text = GetSectorName(m_selectedNavigationMark);
                    if (text.Length > 21)
                    {
                        text  = text.Substring(0, 20);
                        text += "…";
                    }
                    m_travelButton.Text.Append(MyTextsWrapper.GetFormatString(MyTextsWrapperEnum.TravelTo, text));
                    //                    float width = MyGuiManager.GetNormalizedSize( MyGuiManager.GetFontMinerWarsBlue(), m_travelButton.Text, 1).X + 0.05f;
                    //  m_travelButton.SetSize(new Vector2(width, MyGuiConstants.BACK_BUTTON_SIZE.Y));
                    m_travelButton.Visible = true;
                }
            }
            else
            {
                m_travelButton.Visible = false;
            }
        }
Exemplo n.º 8
0
        public override void AddSolarMapMarks(MySolarSystemMapData data)
        {
            foreach (var objective in ActiveObjectives)
            {
                if (objective.Location != null && !MyGuiScreenGamePlay.Static.IsCurrentSector(objective.Location.Sector) && objective.ShowNavigationMark)
                {
                    var missionMark = new MySolarSystemMapNavigationMark(objective.Location.Sector, objective.NameTemp.ToString(), null, MyHudConstants.MISSION_MARKER_COLOR, TransparentGeometry.MyTransparentMaterialEnum.SolarMapNavigationMark) { VerticalLineColor = MyHudConstants.MISSION_MARKER_COLOR.ToVector4(), DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_white };
                    data.NavigationMarks.Add(missionMark);
                }

                objective.AddSolarMapMarks(data);
            }

            if (Location != null && !MyGuiScreenGamePlay.Static.IsCurrentSector(Location.Sector) && ShowNavigationMark)
            {
                var missionMark = new MySolarSystemMapNavigationMark(Location.Sector, NameTemp.ToString(), null, MyHudConstants.ACTIVE_MISSION_SOLAR_MAP_COLOR, TransparentGeometry.MyTransparentMaterialEnum.SolarMapNavigationMark) { VerticalLineColor = MyHudConstants.MISSION_MARKER_COLOR.ToVector4(), DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_white };
                data.NavigationMarks.Add(missionMark);
            }
        }
        private string GetSectorName(MySolarSystemMapNavigationMark navigationMark)
        {
            string sectorName = navigationMark.Name;

            if (String.IsNullOrWhiteSpace(sectorName))
                sectorName = navigationMark.Text;

            if (String.IsNullOrWhiteSpace(sectorName))
                sectorName = navigationMark.Sector.ToString();

            return sectorName;
        }
        public MyGuiScreenSolarSystemMap(MyGuiScreenBase parent, MyMwcSectorIdentifier currentSector)
            : base(new Vector2(0.5f, 0.5f), null, Vector2.One)
        {
            m_parent = parent;
            m_enableBackgroundFade = false;
            DrawMouseCursor = true;
            m_currentSector = currentSector;
            m_closeOnEsc = true;

            Static = this;

            MySolarSystemGenerator generator = new MySolarSystemGenerator(UNIVERSE_SEED);
            generator.Generate(1024);

            m_data = generator.SolarSystemData;
            m_solarMapRender = new MySolarMapRenderer();
            m_solarMapRender.PlayerSector = currentSector.Position;

            //MyMinerGame.SwitchPause();
            m_particlesEnabled = TransparentGeometry.Particles.MyParticlesManager.Enabled;
            TransparentGeometry.Particles.MyParticlesManager.Enabled = false;

            //AddCaption(MyTextsWrapperEnum.SolarSystemMap);

            MySolarSystemMapNavigationMark playerNavigationMark =
                new MySolarSystemMapNavigationMark(
                    currentSector.Position,
                    "",
                    null,
                    MyHudConstants.SOLAR_MAP_PLAYER_MARKER_COLOR,
                    MyTransparentMaterialEnum.SolarMapPlayer)
                    {
                        VerticalLineColor = MyHudConstants.SOLAR_MAP_PLAYER_MARKER_COLOR.ToVector4(),
                        DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_green,
                        Offset = new Vector3(0, 0.0f, 0),
                        Text = MyClientServer.LoggedPlayer.GetDisplayName().ToString(),
                        Importance = 50
                    };
            m_data.NavigationMarks.Add(playerNavigationMark);

            if (MyGuiScreenGamePlay.Static.IsEditorStoryActive() || MyGuiScreenGamePlay.Static.GetPreviousGameType() == MyGuiScreenGamePlayType.EDITOR_STORY)
            {
                // Loads all marks, we want it for editor
                LoadMarks(false);
            }
            else
            {
                // Load only active marks
                MyMissions.AddSolarMapMarks(m_data);
            }

            if (MyMissions.ActiveMission != null)
            {
                MyMissions.ActiveMission.AddSolarMapMarks(m_data);
            }

            m_travelButton = new MyGuiControlButton(this, new Vector2(0.0f, 0.40f),
                new Vector2(650f / 1600f, 120f / 1200f),
                MyGuiConstants.BUTTON_BACKGROUND_COLOR,
                MyGuiManager.GetTravelButtonTexture(),
                MyGuiManager.GetTravelButtonTexture(),
                MyGuiManager.GetTravelButtonTexture(),
                MyTextsWrapperEnum.Travel,
                MyGuiConstants.BACK_BUTTON_TEXT_COLOR,
                MyGuiConstants.BACK_BUTTON_TEXT_SCALE,
                MyGuiControlButtonTextAlignment.CENTERED,
                OnTravelClick,
                false,
                MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER,
                true,
                false);
            m_travelButton.TextOffset = new Vector2(0, -0.0030f);
            m_travelButton.Visible = false;
            Controls.Add(m_travelButton);

            // target sector 0, 0, 0
            // distance is 1.7 sectors from camera
            Vector3 sector;

            var mostImportantMark = m_data.NavigationMarks.GetMostImportant();
            if (mostImportantMark != null) {
                sector = new Vector3(mostImportantMark.Sector.X, mostImportantMark.Sector.Y, mostImportantMark.Sector.Z);
            } else {
                sector = new Vector3(currentSector.Position.X, currentSector.Position.Y, currentSector.Position.Z);
            }

            sector.Y = 0;

            m_camera = new MySolarSystemMapCamera(sector * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS, 10000000.0f * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS);
            m_camera.MinDistanceToTarget = 1.7f * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS;
            m_camera.MaxDistanceToTarget = 1.2f * MySolarSystemUtils.MillionKmToSectors(MyBgrCubeConsts.NEPTUNE_POSITION.Length()) * MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS;
            m_camera.MaxSector = MySolarSystemUtils.MillionKmToSectors(MyBgrCubeConsts.NEPTUNE_POSITION.Length());

            MyGuiManager.FullscreenHudEnabled = true;
        }
        public override void HandleInput(MyGuiInput input, bool receivedFocusInThisUpdate)
        {
            base.HandleInput(input, receivedFocusInThisUpdate);

            if (MyGuiInput.ENABLE_DEVELOPER_KEYS)
            {
                if (input.IsNewKeyPress(Keys.C) && input.IsAnyCtrlKeyPressed())
                {
                    CopySector();
                }
                if (input.IsNewKeyPress(Keys.V) && input.IsAnyCtrlKeyPressed())
                {
                    PasteSector();
                }
            }


            if (MyFakes.DRAW_FACTION_AREAS_IN_SOLAR_MAP)
            {
                MySolarMapAreaInput.HandleInput(m_solarMapRender, input, receivedFocusInThisUpdate);
            }

            float rollIndicator = input.GetRoll();
            Vector2 rotationIndicator = Vector2.Zero;
            if (input.IsNewRightMousePressed() && MyVideoModeManager.IsHardwareCursorUsed())
            {
                m_oldRotationIndicator = input.GetRotation();
            }

            if (input.IsRightMousePressed())
            {

                if (MyVideoModeManager.IsHardwareCursorUsed())
                {
                    rotationIndicator = m_oldRotationIndicator - input.GetRotation();
                    m_oldRotationIndicator = input.GetRotation();
                }
                else
                    rotationIndicator = input.GetRotation();
            }
            Vector3 moveIndicator = input.GetPositionDelta();
            if (input.IsKeyPress(Keys.Left))
                moveIndicator.X = -1;
            if (input.IsKeyPress(Keys.Right))
                moveIndicator.X = 1;
            if (input.IsKeyPress(Keys.Up))
                moveIndicator.Z = -1;
            if (input.IsKeyPress(Keys.Down))
                moveIndicator.Z = 1;

            m_camera.Zoom(input.DeltaMouseScrollWheelValue());

            m_camera.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, 1);


            bool sectorChanged = false;
            if (m_lastSector != m_camera.TargetSector)
            {
                sectorChanged = true;
                m_lastSector = m_camera.TargetSector;
            }



            MySolarSystemMapNavigationMark navigationMarkUnderMouse = GetNearestNavigationMarkUnderMouseCursor();

            const float maxHeightForEnter = MySolarSystemMapCamera.SECTOR_SIZE_GAMEUNITS * 16;

            if (sectorChanged) // we have moved camera so deselect sector
            {
                m_selectedSector = null;
            }


            // tool tips
            if (m_lastNavigationMarkUnderMouse != navigationMarkUnderMouse)
            {
                m_toolTip.ClearToolTips();
                if (navigationMarkUnderMouse != null)
                {
                    m_toolTip.AddToolTip(new StringBuilder(GetSectorName(navigationMarkUnderMouse)));
                    if (!String.IsNullOrEmpty(navigationMarkUnderMouse.Description))
                    {
                        m_toolTip.AddToolTip(new StringBuilder(navigationMarkUnderMouse.Description), Color.LightGray);
                    }
                    m_toolTip.AddToolTip(new StringBuilder(navigationMarkUnderMouse.Sector.ToString()), Color.LightGray);
                }
                m_lastNavigationMarkUnderMouse = navigationMarkUnderMouse;
            }



            if (navigationMarkUnderMouse != null)
            {
                MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorHandTexture());

                if (input.IsNewLeftMousePressed() && !m_travelButton.IsMouseOver())
                {
                    MyAudio.AddCue2D(MySoundCuesEnum.GuiMouseClick);
                    if (m_selectedNavigationMark != null)
                        m_selectedNavigationMark.Highlight = false;

                    m_selectedNavigationMark = navigationMarkUnderMouse;
                    m_selectedNavigationMark.Highlight = true;
                    sectorChanged = true;
                    m_slectionLocked = true;
                    m_travelButton.Visible = false;
                }
                if (input.IsNewLeftMouseDoubleClick())
                {
                    TravelToSector(navigationMarkUnderMouse.Sector, navigationMarkUnderMouse.MissionID);
                }
            }
            else if (m_camera.CameraDistance < maxHeightForEnter && !m_slectionLocked)
            {
                if (MyGuiScreenGamePlay.CanTravelToSector(m_camera.TargetSector))
                {
                    //MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorHandTexture());
                    if (m_selectedNavigationMark != null)
                        m_selectedNavigationMark.Highlight = false;

                    var navigationMarkUnderCamera = GetNavigationMarkUnderCamera();
                    if (navigationMarkUnderCamera != null && navigationMarkUnderCamera.Sector == m_camera.TargetSector)
                    {
                        m_selectedNavigationMark = navigationMarkUnderCamera;
                    }
                    else
                    {
                        m_selectedNavigationMark = new MySolarSystemMapNavigationMark(m_camera.TargetSector, "");
                        m_travelButton.Visible = false;
                    }
                }
                else
                {
                    m_selectedNavigationMark = null;
                }
            }
            else if (input.IsNewLeftMousePressed())
            {
                if (m_selectedNavigationMark != null)
                    m_selectedNavigationMark.Highlight = false;
                if (!m_travelButton.IsMouseOver())
                {
                    m_selectedNavigationMark = null;
                }
                m_slectionLocked = false;
            }
            else if (sectorChanged && m_camera.CameraDistance > maxHeightForEnter && !m_slectionLocked)
            {
                m_selectedNavigationMark = null;
            }
            else
            {
                MyGuiManager.SetMouseCursorTexture(MyGuiManager.GetMouseCursorArrowTexture());
            }



            if (m_selectedNavigationMark != null)
            {
                if (!m_travelButton.Visible)
                {
                    m_travelButton.Text.Clear();
                    string text = GetSectorName(m_selectedNavigationMark);
                    if (text.Length > 21)
                    {
                        text = text.Substring(0, 20);
                        text += "…";
                    }
                    m_travelButton.Text.Append(MyTextsWrapper.GetFormatString(MyTextsWrapperEnum.TravelTo, text));
                    //                    float width = MyGuiManager.GetNormalizedSize( MyGuiManager.GetFontMinerWarsBlue(), m_travelButton.Text, 1).X + 0.05f;
                    //  m_travelButton.SetSize(new Vector2(width, MyGuiConstants.BACK_BUTTON_SIZE.Y));
                    m_travelButton.Visible = true;
                }
            }
            else
            {
                m_travelButton.Visible = false;
            }

        }
        private void AddMarks()
        {
            foreach (var sector in SectorCache)
            {
                const int centerDist = 1;
                if (MyFakes.HIDE_CENTER_SECTOR_MARKS && Math.Abs(sector.Position.X) <= centerDist && Math.Abs(sector.Position.Y) <= centerDist && Math.Abs(sector.Position.Z) <= centerDist)
                {
                    continue;
                }

                var mark = new MySolarSystemMapNavigationMark(sector.Position, sector.SectorName,
                            null,
                            MyHudConstants.SOLAR_MAP_SIDE_MISSION_MARKER_COLOR,
                            TransparentGeometry.MyTransparentMaterialEnum.SolarMapSideMission)
                            {
                                DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_white,
                            };


                m_data.NavigationMarks.Add(mark);
            }
        }
Exemplo n.º 13
0
        public static void AddSolarMapMarks(MySolarSystemMapData data)
        {
            foreach (var mission in m_missions.Values.OfType<MyMission>())
            {
                if (mission.Location != null && !MyGuiScreenGamePlay.Static.IsCurrentSector(mission.Location.Sector) && mission.ShowNavigationMark)
                {
                    if (!mission.Flags.HasFlag(MyMissionFlags.HiddenInSolarMap) && mission.IsAvailable())
                    {
                        bool isStory = mission.Flags.HasFlag(MyMissionFlags.Story);

                        var missionMark = new MySolarSystemMapNavigationMark(
                            mission.Location.Sector,
                            MyTextsWrapper.Get(mission.Name).ToString(),
                            mission.ID,
                            /*isStory ? MyHudConstants.SOLAR_MAP_STORY_MISSION_MARKER_COLOR : */MyHudConstants.SOLAR_MAP_SIDE_MISSION_MARKER_COLOR,
                            isStory ? TransparentGeometry.MyTransparentMaterialEnum.SolarMapStoryMission : TransparentGeometry.MyTransparentMaterialEnum.SolarMapSideMission)
                            {
                                //Description = mission.DescriptionTemp.ToString(),
                                DirectionalTexture = mission.Flags.HasFlag(MyMissionFlags.Story) ? MyHudTexturesEnum.DirectionIndicator_blue : MyHudTexturesEnum.DirectionIndicator_white,
                                IsBlinking = isStory,
                                Text = isStory ? MyTextsWrapper.Get(MyTextsWrapperEnum.NewMission).ToString() : null,
                                TextSize = isStory ? 0.9f : 0.7f,
                                Font = isStory ? MyGuiManager.GetFontMinerWarsBlue() : MyGuiManager.GetFontMinerWarsWhite(),
                                Importance = isStory ? 100 : 1
                            };
                        missionMark.VerticalLineColor = missionMark.Color.ToVector4();

                        data.NavigationMarks.Add(missionMark);
                    }
                    else
                    {
                        bool any = false;
                        foreach (MyMissionBase value in m_missions.Values)
                        {
                            MyMission m = value as MyMission;
                            if (m != null)
                            {
                                if (m.Location.Sector == mission.Location.Sector && m.IsAvailable())
                                {
                                    any = true;
                                    break;
                                }
                            }
                        }
                        if (!any && mission.IsCompleted() && !data.NavigationMarks.Contains(mission.Location.Sector))
                        {
                            var missionMark = new MySolarSystemMapNavigationMark(
                                mission.Location.Sector,
                                MyTextsWrapper.Get(mission.Name).ToString(),
                                null,
                                Color.Gray,
                                TransparentGeometry.MyTransparentMaterialEnum.SolarMapSideMission)
                                                  {
                                                      //Description = mission.DescriptionTemp.ToString(),
                                                      DirectionalTexture = MyHudTexturesEnum.DirectionIndicator_white,
                                                      Text = "Completed",
                                                      TextSize = 0.6f,
                                                  };
                            missionMark.VerticalLineColor = missionMark.Color.ToVector4();
                            data.NavigationMarks.Add(missionMark);
                        }
                    }
                }
            }
        }
Exemplo n.º 14
0
        public void AddTemplateGroups(MySolarSystemMapData data)
        {
            return; // Template groups in solar map are disabled
            if (SolarMapData.TemplateGroups == null) return;

            Random rnd = new Random(0);
            foreach (var g in SolarMapData.TemplateGroups)
            {
                for (int i = 0; i < g.Count; i++)
                {
                    var pos = GetRandomPosition(rnd);
                    Vector3 offset;
                    MyMwcVector3Int sector = MySolarSystemUtils.KmToSectors(pos, out offset);

                    var mark = new MySolarSystemMapNavigationMark(sector, "", null, Color.White, TransparentGeometry.MyTransparentMaterialEnum.SolarMapOutpost);
                    mark.Importance = g.Importance;
                    mark.DrawVerticalLine = false;
                    data.NavigationMarks.Add(mark);
                    data.ImportantObjects.Add(new MyImportantSolarObject() { NavigationMark = mark, TemplateGroup = g.TemplateGroup });
                    //entities.Add(new MySolarSystemMapEntity(sector, offset, 0, "", MySolarSystemEntityEnum.OutpostIcon));
                }
            }
        }
Exemplo n.º 15
0
        void AddNavigationMark(MySolarSystemMapNavigationMark navigationMark)
        {
            if (navigationMark.Visible)
            {
                Vector4 color = navigationMark.IsMouseOver() || navigationMark.Highlight ?
                                    navigationMark.Color.ToVector4() * 1.5f:
                                    navigationMark.Color.ToVector4();

                if (navigationMark.DrawVerticalLine)
                {
                    AddVerticalMarker(navigationMark.WorldPosition, navigationMark.VerticalLineColor);
                }


                bool showIcon = true;
                if (navigationMark.IsBlinking)
                {
                    if (MyMinerGame.TotalTimeInMilliseconds % 800 < 80 || (MyMinerGame.TotalTimeInMilliseconds % 800 > 160 && MyMinerGame.TotalTimeInMilliseconds % 800 < 160 + 80))
                    {
                        showIcon = false;
                    }
                }

                if (showIcon)
                {
                    AddIcon(navigationMark.WorldPosition, MySolarSystemMapNavigationMark.RADIUS, navigationMark.Texture, color, navigationMark.Name, navigationMark.Text, navigationMark.TextSize, navigationMark.Highlight || navigationMark.IsMouseOver(), navigationMark.Offset, navigationMark.Font, navigationMark.Importance);
                }
            
                if (navigationMark.DrawVerticalLine)
                {
                    AddDirectionNavigator(navigationMark.DirectionalTexture, navigationMark.WorldPosition, navigationMark.Name, color);
                }
            }
        }
Exemplo n.º 16
0
        public void Generate(int sectorCacheCapacity)
        {
            m_data = new MySolarSystemMapData(sectorCacheCapacity);
            
            // Sun
            AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.SUN_RADIUS, MyTextsWrapper.Get(MyTextsWrapperEnum.Sun).ToString(), MySolarSystemEntityEnum.Sun, Color.White);

            // Orbits (just orbit lines)
            AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.MERCURY_POSITION.Length(), "Mercury orbit", MySolarSystemEntityEnum.Orbit, Color.White);
            AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.VENUS_POSITION.Length(), "Venus orbit", MySolarSystemEntityEnum.Orbit, Color.White);
            AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.EARTH_POSITION.Length(), "Earth orbit", MySolarSystemEntityEnum.Orbit, Color.White);
            AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.MARS_POSITION.Length(), "Mars orbit", MySolarSystemEntityEnum.Orbit, Color.White);
            AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.JUPITER_POSITION.Length(), "Jupiter orbit", MySolarSystemEntityEnum.Orbit, Color.White);
            AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.SATURN_POSITION.Length(), "Saturn orbit", MySolarSystemEntityEnum.Orbit, Color.White);
            AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.URANUS_POSITION.Length(), "Uranus orbit", MySolarSystemEntityEnum.Orbit, Color.White);
            AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.NEPTUNE_POSITION.Length(), "Neptune orbit", MySolarSystemEntityEnum.Orbit, Color.White);

            foreach (var a in MySolarSystemConstants.Areas)
            {
                a.Value.AddUniverseEntities(m_data);
                m_data.Areas.Add(a.Key);
            }

            if (MyFakes.ENABLE_RANDOM_STATIONS_IN_SOLAR_SYSTEM && 
                MyMissions.ActiveMission == null && 
                MyMissions.GetAvailableMissions().Count == 0)
            {
                foreach (var a in MyFactions.FactionAreas)
                {
                    if (a.Key == CommonLIB.AppCode.ObjectBuilders.MyMwcObjectBuilder_FactionEnum.CSR)
                        continue;
                    foreach (var circle in a.Value)
                    {
                        Random r = new Random(circle.Position.GetHashCode() ^ circle.Radius.GetHashCode());

                        var radius = circle.Radius / 100000000;

                        float count = MathHelper.Pi * radius * radius;
                        count = MathHelper.Clamp(count, 0, 10);
                        if (count < 1)
                        {
                            count = r.Next(0, 2);
                        }
                        for (int i = 0; i < count; i++)
                        {
                            float dist = rnd.Float() * circle.Radius;
                            float angle = (float)(rnd.NextDouble() * 2 * MathHelper.Pi);
                            float x = (float)Math.Sin(angle) * dist;
                            float z = (float)Math.Cos(angle) * dist;

                            var pos = circle.GetCenter() + new Vector3(x, 0, z);
                            //pos = circle.GetCenter();

                            Vector3 offset;
                            MyMwcVector3Int sector = MySolarSystemUtils.KmToSectors(pos, out offset);
                            var mark = new MySolarSystemMapNavigationMark(sector, "", null, Color.White, MyTransparentMaterialEnum.SolarMapOutpost);
                            mark.Importance = rnd.Next(2, 5) / 4.0f;
                            mark.DrawVerticalLine = false;
                            m_data.NavigationMarks.Add(mark);
                            m_data.ImportantObjects.Add(new MyImportantSolarObject() { NavigationMark = mark, TemplateGroup = MyTemplateGroupEnum.RandomStations });
                        }
                    }
                }
            }
            
            // Filip resize solar map
            const float factionMapScale = 1.75f;

            // Faction map - size of map is same as saturn orbit
            AddEntity(m_data, Vector3.Zero, MyBgrCubeConsts.SATURN_POSITION.Length() / factionMapScale, "Faction map", MySolarSystemEntityEnum.FactionMap, Color.White);

            AddEntity(m_data, new Vector3(-352, 0, -40), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionRussian).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.IndianRed, MyTransparentMaterialEnum.FactionRussia);
            AddEntity(m_data, new Vector3(-432, 0, -628), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionRussian).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.IndianRed, MyTransparentMaterialEnum.FactionRussia);
            AddEntity(m_data, new Vector3(0, 0, 300), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionChineseShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.Brown, MyTransparentMaterialEnum.FactionChina);
            AddEntity(m_data, new Vector3(-150, 0, 95), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionJapan).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.DeepSkyBlue, MyTransparentMaterialEnum.FactionJapan);
            AddEntity(m_data, new Vector3(300, 0, 108), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionFreeAsia).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.HotPink, MyTransparentMaterialEnum.FactionFreeAsia);
            AddEntity(m_data, new Vector3(300, 0, -40), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionSaudiShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.Gold, MyTransparentMaterialEnum.FactionSaudi);
            AddEntity(m_data, new Vector3(220, 0, -180), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionEuroamericanShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.CornflowerBlue, MyTransparentMaterialEnum.FactionEAC);
            //AddEntity(m_data, new Vector3(65, 0, -135), 0, "CSR", MySolarSystemEntityEnum.FactionInfo, Color.DarkKhaki, MyTransparentMaterialEnum.FactionCSR);
            AddEntity(m_data, new Vector3(37, 0, -160), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionIndia).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.SandyBrown, MyTransparentMaterialEnum.FactionIndia);
            AddEntity(m_data, new Vector3(-30, 0, -160), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionChurchShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.Yellow, MyTransparentMaterialEnum.FactionChurch);
            AddEntity(m_data, new Vector3(-85, 0, -150), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionOmnicorpShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.LightGreen, MyTransparentMaterialEnum.FactionOmnicorp);
            AddEntity(m_data, new Vector3(-108, 0, -358), 0, MyTextsWrapper.Get(MyTextsWrapperEnum.FactionFourthReichShort).ToString(), MySolarSystemEntityEnum.FactionInfo, Color.LightSteelBlue, MyTransparentMaterialEnum.FactionFourthReich);

            // Some navigation marks for testing            
            //AddNavigationMark(m_data, new MyMwcVector3Int(1000000, 0, 1000000), "Mark1");
            //AddNavigationMark(m_data, new MyMwcVector3Int(3000000, 0, -1500000), "Mark2");
        }