示例#1
0
文件: Viewport.cs 项目: djlw78/Mosa
 //-------------------------------------------------------------------
 public void PreserveAspectRatio(double alignx,
                                 double aligny,
                                 EAspectRatio aspect)
 {
     m_align_x = alignx;
     m_align_y = aligny;
     m_aspect  = aspect;
     Update();
 }
示例#2
0
        private void OnResolutionChange()
        {
            EAspectRatio easpectRatio = GraphicsConfigManager.GetAspectRatio();

            if (easpectRatio == EAspectRatio.None)
            {
                easpectRatio = EAspectRatio._4_3;
            }
            m_background.mainTexture = ((easpectRatio != EAspectRatio._4_3) ? m_backgroundTexture169 : m_backgroundTexture43);
            m_background.MakePixelPerfect();
        }
示例#3
0
        public static EAspectRatio GetAspectRatio(Resolution p_resolution)
        {
            Single num = p_resolution.width / (Single)p_resolution.height;

            if (num >= 1.2375f && num <= 1.2625f)
            {
                return(EAspectRatio.None);
            }
            if (num >= 1.32f && num <= 1.34666669f)
            {
                return(EAspectRatio._4_3);
            }
            if (num >= 1.76f && num <= 1.79555559f)
            {
                return(EAspectRatio._16_9);
            }
            if (num >= 1.584f && num <= 1.616f)
            {
                return(EAspectRatio._16_10);
            }
            EAspectRatio result = EAspectRatio.None;
            Single       num2   = Single.MaxValue;
            Single       num3   = Math.Abs(1.33333337f - num);

            if (num2 > num3)
            {
                num2   = num3;
                result = EAspectRatio._4_3;
            }
            num3 = Math.Abs(1.77777779f - num);
            if (num2 > num3)
            {
                num2   = num3;
                result = EAspectRatio._16_9;
            }
            num3 = Math.Abs(1.6f - num);
            if (num2 > num3)
            {
                result = EAspectRatio._16_10;
            }
            return(result);
        }
示例#4
0
        private void OnResolutionChange()
        {
            EAspectRatio easpectRatio = GraphicsConfigManager.GetAspectRatio();

            if (easpectRatio == EAspectRatio.None)
            {
                easpectRatio = EAspectRatio._4_3;
            }
            Texture mainTexture = (easpectRatio != EAspectRatio._4_3) ? m_backgroundTexture169 : m_backgroundTexture43;

            if (LegacyLogic.Instance.ModController.InModMode)
            {
                ModController.ModInfo currentMod = LegacyLogic.Instance.ModController.CurrentMod;
                if (!String.IsNullOrEmpty(currentMod.TitleImage))
                {
                    String path = Path.Combine(currentMod.ImageFolder, currentMod.TitleImage);
                    if (File.Exists(path))
                    {
                        if (m_createdBackground == null)
                        {
                            m_createdBackground           = new Texture2D(1, 1, TextureFormat.ARGB32, false);
                            m_createdBackground.hideFlags = HideFlags.DontSave;
                        }
                        Byte[] data = File.ReadAllBytes(path);
                        if (m_createdBackground.LoadImage(data))
                        {
                            mainTexture = m_createdBackground;
                        }
                    }
                }
            }
            m_background.mainTexture = mainTexture;
            if (easpectRatio == EAspectRatio._4_3)
            {
                m_background.transform.localScale = new Vector3(2048f, 1536f, 1f);
            }
            else
            {
                m_background.transform.localScale = new Vector3(2732f, 1536f, 1f);
            }
        }
示例#5
0
 //-------------------------------------------------------------------
 public Viewport()
 {
     m_world_x1 = (0.0);
     m_world_y1 = (0.0);
     m_world_x2 = (1.0);
     m_world_y2 = (1.0);
     m_device_x1 = (0.0);
     m_device_y1 = (0.0);
     m_device_x2 = (1.0);
     m_device_y2 = (1.0);
     m_aspect = EAspectRatio.Stretch;
     m_is_valid = (true);
     m_align_x = (0.5);
     m_align_y = (0.5);
     m_wx1 = (0.0);
     m_wy1 = (0.0);
     m_wx2 = (1.0);
     m_wy2 = (1.0);
     m_dx1 = (0.0);
     m_dy1 = (0.0);
     m_kx = (1.0);
     m_ky = (1.0);
 }
示例#6
0
文件: Viewport.cs 项目: djlw78/Mosa
 //-------------------------------------------------------------------
 public Viewport()
 {
     m_world_x1  = (0.0);
     m_world_y1  = (0.0);
     m_world_x2  = (1.0);
     m_world_y2  = (1.0);
     m_device_x1 = (0.0);
     m_device_y1 = (0.0);
     m_device_x2 = (1.0);
     m_device_y2 = (1.0);
     m_aspect    = EAspectRatio.Stretch;
     m_is_valid  = (true);
     m_align_x   = (0.5);
     m_align_y   = (0.5);
     m_wx1       = (0.0);
     m_wy1       = (0.0);
     m_wx2       = (1.0);
     m_wy2       = (1.0);
     m_dx1       = (0.0);
     m_dy1       = (0.0);
     m_kx        = (1.0);
     m_ky        = (1.0);
 }
示例#7
0
 //-------------------------------------------------------------------
 public void PreserveAspectRatio(double alignx, 
                            double aligny, 
                            EAspectRatio aspect)
 {
     m_align_x = alignx;
     m_align_y = aligny;
     m_aspect  = aspect;
     Update();
 }
示例#8
0
        public static Boolean IsResolutionSupported(Resolution p_resolution)
        {
            EAspectRatio aspectRatio = GetAspectRatio(p_resolution);

            return(aspectRatio != EAspectRatio.None);
        }
示例#9
0
    // Update is called once per frame
    void Update()
    {
        if (Camera.main.aspect >= 2.3f) // 21:9 and up
        {
            CurrentAspectRatio = EAspectRatio.a21_9;
        }
        else if (Camera.main.aspect >= 1.7f) // 16:9
        {
            CurrentAspectRatio = EAspectRatio.a16_9;
        }
        else if (Camera.main.aspect >= 1.6f) // 16:10
        {
            CurrentAspectRatio = EAspectRatio.a16_10;
        }
        else if (Camera.main.aspect >= 1.5f) // 3:2
        {
            CurrentAspectRatio = EAspectRatio.a3_2;
        }
        else if (Camera.main.aspect >= 1.3f) // 4:3
        {
            CurrentAspectRatio = EAspectRatio.a4_3;
        }
        else // 5:4
        {
            CurrentAspectRatio = EAspectRatio.a5_4;
        }

        if (SceneManager.GetActiveScene().name == "Game" || SceneManager.GetActiveScene().name.Contains("Credits"))
        {
            switch (CurrentAspectRatio)
            {
            case EAspectRatio.a21_9:
                Elevator.instance.BackgroundRenderer.gameObject.transform.localScale = RetroBackgroundScale;
                Shop.instance.BackgroundRenderer.gameObject.transform.localScale     = RetroBackgroundScale;
                Mirror.instance.BackgroundRenderer.gameObject.transform.localScale   = RetroBackgroundScale;
                if (Camera.main.orthographicSize != 5.4f)
                {
                    Camera.main.orthographicSize = 5.4f;
                }
                break;

            case EAspectRatio.a16_9:
                Elevator.instance.BackgroundRenderer.gameObject.transform.localScale = Vector3.one;
                Shop.instance.BackgroundRenderer.gameObject.transform.localScale     = Vector3.one;
                Mirror.instance.BackgroundRenderer.gameObject.transform.localScale   = Vector3.one;
                if (Camera.main.orthographicSize != 5.4f)
                {
                    Camera.main.orthographicSize = 5.4f;
                }
                break;

            case EAspectRatio.a16_10:
                Elevator.instance.BackgroundRenderer.gameObject.transform.localScale = UltraRetroBackgroundScale;
                Shop.instance.BackgroundRenderer.gameObject.transform.localScale     = UltraRetroBackgroundScale;
                Mirror.instance.BackgroundRenderer.gameObject.transform.localScale   = UltraRetroBackgroundScale;
                if (Camera.main.orthographicSize != 6.0f)
                {
                    Camera.main.orthographicSize = 6.0f;
                }
                break;

            case EAspectRatio.a3_2:
                Elevator.instance.BackgroundRenderer.gameObject.transform.localScale = UltraRetroBackgroundScale;
                Shop.instance.BackgroundRenderer.gameObject.transform.localScale     = UltraRetroBackgroundScale;
                Mirror.instance.BackgroundRenderer.gameObject.transform.localScale   = UltraRetroBackgroundScale;
                if (Camera.main.orthographicSize != 6.4f)
                {
                    Camera.main.orthographicSize = 6.4f;
                }
                break;

            case EAspectRatio.a4_3:
                Elevator.instance.BackgroundRenderer.gameObject.transform.localScale = UltraRetroBackgroundScale;
                Shop.instance.BackgroundRenderer.gameObject.transform.localScale     = UltraRetroBackgroundScale;
                Mirror.instance.BackgroundRenderer.gameObject.transform.localScale   = UltraRetroBackgroundScale;
                if (Camera.main.orthographicSize != 7.0f)
                {
                    Camera.main.orthographicSize = 7.0f;
                }
                break;

            case EAspectRatio.a5_4:
                Elevator.instance.BackgroundRenderer.gameObject.transform.localScale = RetroBackgroundScale;
                Shop.instance.BackgroundRenderer.gameObject.transform.localScale     = RetroBackgroundScale;
                Mirror.instance.BackgroundRenderer.gameObject.transform.localScale   = RetroBackgroundScale;
                if (Camera.main.orthographicSize != 7.6f)
                {
                    Camera.main.orthographicSize = 7.6f;
                }
                break;
            }
        }
        else/* if (SceneManager.GetActiveScene().name.Contains("Comic"))*/
        {
            switch (CurrentAspectRatio)
            {
            case EAspectRatio.a21_9:
                if (Camera.main.orthographicSize != 6.5f)
                {
                    Camera.main.orthographicSize = 6.5f;
                }
                if (SceneManager.GetActiveScene().name.Contains("PostGame"))
                {
                    if (MortimerPostGame.instance != null)
                    {
                        MortimerPostGame.instance.BackgroundRenderer.gameObject.transform.localScale = UltraWideMortimerBackgroundScale;
                    }
                }
                break;

            case EAspectRatio.a16_9:
                if (Camera.main.orthographicSize != 6.5f)
                {
                    Camera.main.orthographicSize = 6.5f;
                }
                if (SceneManager.GetActiveScene().name.Contains("PostGame"))
                {
                    if (MortimerPostGame.instance != null)
                    {
                        MortimerPostGame.instance.BackgroundRenderer.gameObject.transform.localScale = RegularMortimerBackgroundScale;
                    }
                }
                break;

            case EAspectRatio.a16_10:
                if (Camera.main.orthographicSize != 6.5f)
                {
                    Camera.main.orthographicSize = 6.5f;
                }
                if (SceneManager.GetActiveScene().name.Contains("PostGame"))
                {
                    if (MortimerPostGame.instance != null)
                    {
                        MortimerPostGame.instance.BackgroundRenderer.gameObject.transform.localScale = NotUltraWideMortimerBackgroundScale;
                    }
                }
                break;

            case EAspectRatio.a3_2:
                if (Camera.main.orthographicSize != 6.5f)
                {
                    Camera.main.orthographicSize = 6.5f;
                }
                if (SceneManager.GetActiveScene().name.Contains("PostGame"))
                {
                    if (MortimerPostGame.instance != null)
                    {
                        MortimerPostGame.instance.BackgroundRenderer.gameObject.transform.localScale = NotUltraWideMortimerBackgroundScale;
                    }
                }
                break;

            case EAspectRatio.a4_3:
                if (Camera.main.orthographicSize != 7.2f)
                {
                    Camera.main.orthographicSize = 7.2f;
                }
                if (SceneManager.GetActiveScene().name.Contains("PostGame"))
                {
                    if (MortimerPostGame.instance != null)
                    {
                        MortimerPostGame.instance.BackgroundRenderer.gameObject.transform.localScale = NotUltraWideMortimerBackgroundScale;
                    }
                }
                break;

            case EAspectRatio.a5_4:
                if (Camera.main.orthographicSize != 7.6f)
                {
                    Camera.main.orthographicSize = 7.6f;
                }
                if (SceneManager.GetActiveScene().name.Contains("PostGame"))
                {
                    if (MortimerPostGame.instance != null)
                    {
                        MortimerPostGame.instance.BackgroundRenderer.gameObject.transform.localScale = NotUltraWideMortimerBackgroundScale;
                    }
                }
                break;
            }
        }


        //if(GameMode == EGameMode.DEMO && SaveManager.instance != null && SaveManager.instance.GetCurrentPlayerState().GetCurrentDayNumberNotIndexThisHasOneAddedToIt() >= 8)
        //{
        //    Debug.Log("Quit lol");
        //    Application.Quit();
        //}
    }