Esempio n. 1
0
        public bool TryFitWindowedScreen(int width, int height)
        {
            int num     = (int)((float)Screen.currentResolution.width * 0.99f);
            int num2    = (int)((float)Screen.currentResolution.height * 0.94f);
            int width2  = Math.Min(width, num);
            int height2 = Math.Min(height, num2);

            if (width > num || height > num2)
            {
                DisplayResolutionManager.SetRawResolution(width2, height2, fullscreen: false);
                return(false);
            }
            return(true);
        }
        private IEnumerator resizeAfterDrag()
        {
            int waitFrames   = 20;
            int currentFrame = 0;

            while (currentFrame < waitFrames)
            {
                currentFrame++;
                yield return(null);
            }
            float currentAspectRatio = (float)width / (float)height;
            int   screenSize         = width * height;

            if (screenSize >= previousScreensize)
            {
                if (currentAspectRatio > desiredAspectRatio)
                {
                    height = (int)((float)width / desiredAspectRatio);
                }
                else
                {
                    width = (int)((float)height * desiredAspectRatio);
                }
                DisplayResolutionManager.SetRawResolution(width, height, fullscreen: false);
            }
            else
            {
                if (currentAspectRatio > desiredAspectRatio)
                {
                    width = (int)((float)height * desiredAspectRatio);
                }
                else
                {
                    height = (int)((float)width / desiredAspectRatio);
                }
                if (width <= 640 && height <= 480)
                {
                    height = 480;
                    width  = (int)((float)height * desiredAspectRatio);
                }
                DisplayResolutionManager.SetRawResolution(width, height, fullscreen: false);
            }
            isWindowResizing = true;
            yield return(waitForResize);

            isWindowResizing   = false;
            previousScreensize = width * height;
        }