예제 #1
0
        public void UpdateSize(Vector2 _consoleSize, int fontSize)
        {
            SetFontSize(fontSize);
            if (_consoleSize.X <= 0 || _consoleSize.Y <= 0)
            {
                return;
            }
            if (_consoleSize.X > Console.LargestWindowWidth || _consoleSize.Y > Console.LargestWindowHeight)
            {
                return;
            }

            consoleSize = _consoleSize;
            sWidth      = consoleSize.X;
            sHeight     = consoleSize.Y;
            screen      = new Pixel[sWidth * sHeight];
            screenSize  = new ScreenSize()
            {
                Left = 0, Top = 0, Right = (ushort)sWidth, Bottom = (ushort)sHeight
            };
            handle = CreateFile("CONOUT$", 0x40000000, 2, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);

            try
            {
                Console.SetWindowSize(consoleSize.X, consoleSize.Y);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return;
        }
예제 #2
0
        public static void ChangeSize(ScreenSize size)
        {
            var form        = Application.OpenForms[0];
            var browserForm = (BrowserForm)form;

            browserForm.ChangeSize(size);
        }
예제 #3
0
        public void Init(Vector2 _consoleSize, int fontSize)
        {
            SetFontSize(fontSize);
            Console.OutputEncoding = System.Text.Encoding.UTF8;

            //Save console settings
            consoleSize = _consoleSize;

            //Apply scale for init
            Console.SetWindowSize(consoleSize.X, consoleSize.Y);
            sWidth  = consoleSize.X;
            sHeight = consoleSize.Y;

            objects = new List <Object>();

            //Setup screen buffer
            screen = new Pixel[sWidth * sHeight];

            screenSize = new ScreenSize()
            {
                Left = 0, Top = 0, Right = (ushort)sWidth, Bottom = (ushort)sHeight
            };
            handle = CreateFile("CONOUT$", 0x40000000, 2, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);

            initialized = true;
            return;
        }
예제 #4
0
        /// <summary>
        /// Draw 7-seg image
        /// </summary>
        /// <param name="dp"></param>
        /// <param name="format"></param>
        /// <remarks>
        /// Format:
        /// 0-9 ... draw number
        /// *   ... draw Dark 8
        /// .   ... draw Dot at last position
        /// ,   ... draw Dot at last position (dark)
        /// :   ... draw colon
        /// ;   ... draw colon(dark)
        /// !   ... draw half space
        /// _   ... draw space
        /// \b  ... back space (1/4)
        /// </remarks>
        public void Draw(DrawProperty dp, string format, ScreenPos pos, ScreenY height)
        {
            if (LoadStatus != 1)
            {
                return;
            }
            var x   = ScreenX.From(0);
            var sz0 = ScreenSize.From(Bitmaps['*'].SizeInPixels.Width, Bitmaps['*'].SizeInPixels.Height);
            var z   = height / sz0.Height;
            var sz  = sz0 * z;
            var sr  = ScreenRect.FromLTWH(0, 0, sz.Width, sz.Height);

            foreach (var c in format)
            {
                if (SpaceAdjust.TryGetValue(c, out var adjust))
                {
                    x += sz.Width * adjust;
                }
                var bmp = Bitmaps.GetValueOrDefault(c, null);
                if (bmp != null)
                {
                    dp.Graphics.DrawImage(bmp, _(sr + pos + x));
                }
                x += sz.Width;
            }
        }
예제 #5
0
        /// <summary>
        /// Initialize feature
        /// </summary>
        public override void OnInitialInstance()
        {
            base.OnInitialInstance();
            Pane.Target = Pane["ToolBox"];

            // Tool box background
            Parts.Add(Pane.Target, new PartsToolBox {
            }, LAYER.ToolButtonBox);

            var x       = ScreenX.From(0);
            var y       = ScreenY.From(48);
            var btnSize = ScreenSize.From(24, 24);
            var marginY = ScreenY.From(8);

            for (var i = 0; i < Buttons.Count; i++)
            {
                var btn = Buttons[i];
                btn.Name     = string.IsNullOrEmpty(btn.Name) ? btn.GetType().Name : btn.Name;
                btn.Size     = btnSize;
                btn.Location = CodePos <ScreenX, ScreenY> .From(x, y);

                var dmy = btn.Load(View);   // dmy = thread control
                Parts.Add(Pane.Target, btn, LAYER.ToolButtons);
                y += btnSize.Height + marginY;
            }
        }
예제 #6
0
    private static ScreenSize GetScreenSize()
    {
        if (screenSizeInitialised)
        {
            return(screenSize);
        }

        float shortSideDP = PixelToDp(GetShortSide());

        ScreenSize size;

        if (shortSideDP > 500)
        {
            size = DisplayMetricsUtil.ScreenSize.tablet;
        }
        else if (shortSideDP < 300)
        {
            size = DisplayMetricsUtil.ScreenSize.smartphoneSmall;
        }
        else
        {
            size = DisplayMetricsUtil.ScreenSize.smartphone;
        }

        screenSize            = size;
        screenSizeInitialised = true;
        return(size);
    }
        /// <summary>
        /// fetches a tilemap. this is simple; apparently only the screen size (shape) is a factor (not the tile size)
        /// </summary>
        public TileEntry[] FetchTilemap(int addr, ScreenSize size)
        {
            var blockDims = SizeInBlocksForBGSize(size);
            int blocksw   = blockDims.Width;
            int blocksh   = blockDims.Height;
            int width     = blockDims.Width * 32;
            int height    = blockDims.Height * 32;

            TileEntry[] buf = new TileEntry[width * height];

            for (int by = 0; by < blocksh; by++)
            {
                for (int bx = 0; bx < blocksw; bx++)
                {
                    for (int y = 0; y < 32; y++)
                    {
                        for (int x = 0; x < 32; x++)
                        {
                            int    idx   = (by * 32 + y) * width + bx * 32 + x;
                            ushort entry = *(ushort *)(vram + addr);
                            buf[idx].tilenum = (ushort)(entry & 0x3FF);
                            buf[idx].palette = (byte)((entry >> 10) & 7);
                            buf[idx].flags   = (TileEntryFlags)((entry >> 13) & 7);
                            buf[idx].address = addr;
                            addr            += 2;
                        }
                    }
                }
            }

            return(buf);
        }
        public void ChangeSize(ScreenSize size)
        {
            if (this.InvokeRequired)
            {
                // This is a worker thread so delegate the task.
                this.Invoke(new ChangeSizeDelegate(this.ChangeSize), size);
            }
            else
            {
                // This is the UI thread so perform the task.
                var height = 0;
                var width  = 0;
                switch (size)
                {
                case ScreenSize.L:
                    height = Screen.PrimaryScreen.WorkingArea.Height;
                    width  = Screen.PrimaryScreen.WorkingArea.Width;
                    break;

                case ScreenSize.M:
                    height = Convert.ToInt32(Screen.PrimaryScreen.WorkingArea.Height * 0.75);
                    width  = Convert.ToInt32(Screen.PrimaryScreen.WorkingArea.Width * 0.75);
                    break;

                case ScreenSize.S:
                    height = Convert.ToInt32(Screen.PrimaryScreen.WorkingArea.Height * 0.5);
                    width  = Convert.ToInt32(Screen.PrimaryScreen.WorkingArea.Width * 0.5);
                    break;
                }
                this.Height = height;
                this.Width  = width;
            }
        }
예제 #9
0
 protected Utility(IntPtr hwnd, ScreenSize size)
 {
     this.SC2hwnd = hwnd;
     this.mem     = new ReadWriteMemory(this.SC2hwnd);
     this.ChangeSize(size);
     this.debug = /*Debugger.IsAttached*/ false;
 }
예제 #10
0
        public void UpdateViewerSize()
        {
            if (_frmFullscreenRenderer != null)
            {
                return;
            }
            if (HideMenuStrip)
            {
                _menu.Visible = false;
            }

            ScreenSize screenSize = EmuApi.GetScreenSize(false);

            if (_resizeForm && _frm.WindowState != FormWindowState.Maximized)
            {
                _frm.Resize -= frmMain_Resize;
                Size newSize = new Size(screenSize.Width, screenSize.Height);
                _frm.ClientSize = new Size(newSize.Width, newSize.Height + (HideMenuStrip ? 0 : _panel.Top));
                _frm.Resize    += frmMain_Resize;
            }

            _renderer.Size = new Size(screenSize.Width, screenSize.Height);
            _renderer.Top  = (_panel.Height - _renderer.Height) / 2;
            _renderer.Left = (_panel.Width - _renderer.Width) / 2;
        }
예제 #11
0
        public override void Draw(DrawProperty dp)
        {
            if (Seg7?.IsLoaded == false)
            {
                return;
            }

            var pos = dp.PaneRect.RB - ScreenSize.From(420, 40);
            var now = Parent.Now;

            Seg7.Draw(dp, "****,!**,!**_**\b;\b**\b;\b**", pos, Height);
            if (now != DateTime.MinValue)
            {
                var timestr = $"{now.Year}.!{StrUtil.Right($"_{now.Month}", 2)}.!{StrUtil.Right($"_{now.Day}", 2)}_{StrUtil.Right($"_{now.Hour}", 2)}\b:\b{StrUtil.Right($"0{now.Minute}", 2)}\b:\b{StrUtil.Right($"0{now.Second}", 2)}";
                Seg7.Draw(dp, timestr, pos, Height);

                // Sim Time Caption
                dp.Graphics.DrawText($"Sim time :", pos.X - ScreenX.From(8), pos.Y + ScreenY.From(20), Colors.Cyan, new CanvasTextFormat
                {
                    FontFamily          = "Tahoma",
                    FontSize            = 11f,
                    FontWeight          = FontWeights.Normal,
                    HorizontalAlignment = CanvasHorizontalAlignment.Right,
                });
            }

            // Current Local Time
            dp.Graphics.DrawText($"Actual time : {DateTime.Now.ToString(TimeUtil.FormatYMDHMS)}", dp.PaneRect.R - ScreenX.From(64), pos.Y - ScreenY.From(24), Colors.DarkGray, new CanvasTextFormat
            {
                FontFamily          = "Tahoma",
                FontSize            = 11f,
                FontWeight          = FontWeights.Normal,
                HorizontalAlignment = CanvasHorizontalAlignment.Right,
            });
        }
예제 #12
0
        public void EngSetScreenSize(ScreenSize screenSize)
        {
            switch (screenSize)
            {
            case ScreenSize.SMALL:
                Width  = SCREEN_SIZE_SMALL_WIDTH;
                Height = SCREEN_SIZE_SMALL_HEIGHT;
                break;

            case ScreenSize.MEDIUM:
                Width  = SCREEN_SIZE_MEDIUM_WIDTH;
                Height = SCREEN_SIZE_MEDIUM_HEIGHT;
                break;

            case ScreenSize.LARGE:
                Width  = SCREEN_SIZE_LARGE_WIDTH;
                Height = SCREEN_SIZE_LARGE_HEIGHT;
                break;

            case ScreenSize.FULLSCREEN:
                this.FormBorderStyle = FormBorderStyle.None;
                this.WindowState     = FormWindowState.Maximized;
                break;

            default:
                Console.WriteLine("Default case");
                break;
            }


            CenterToScreen();
        }
예제 #13
0
    public void OnValueChangedScreen()
    {
        CurrentScreenSize = (ScreenSize)ScreenSizeSelector.GetComponent <Dropdown>().value;
        // change screen size code here
        switch ((int)CurrentScreenSize)
        {
        case 0:     //1024x768
            if (Screen.width != 1024 || Screen.height != 768)
            {
                Screen.SetResolution(1024, 768, false);
                Debug.Log("setting to 1024x768");
            }
            break;

        case 1:     //1280x800
            if (Screen.width != 1280 || Screen.height != 800)
            {
                Screen.SetResolution(1280, 800, false);
                Debug.Log("setting to 1280x800");
            }
            break;

        case 2:     //1280x960
            if (Screen.width != 1280 || Screen.height != 960)
            {
                Screen.SetResolution(1280, 960, false);
                Debug.Log("setting to 1280x960");
            }
            break;

        default:
            Debug.LogWarning("why am i here?");
            break;
        }
    }
예제 #14
0
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // TODO: Add your update logic here
            if (ScreenSize.Contains(player2.HitBox) && stopwatch.ElapsedMilliseconds < 1000)
            {
                player2.Speed = (int)ball.Speed.Y;
            }
            else if (stopwatch.ElapsedMilliseconds > 5000)
            {
                stopwatch.Reset();
            }

            player1.MoveUpDown(Keyboard.GetState().IsKeyDown(Keys.W), Keyboard.GetState().IsKeyDown(Keys.S),
                               GraphicsDevice.Viewport.Y, GraphicsDevice.Viewport.Height);
            player2.AutoMoveUpDown(GraphicsDevice.Viewport.Y, GraphicsDevice.Viewport.Height);
            ball.Move(ScreenSize);
            BallAndPaddleReaction(ball, player1, player2);

            CheckScore();
            ScoreKeeper.UpdateScore(player1.Score, player2.Score);

            base.Update(gameTime);
        }
예제 #15
0
        public static ScreenSize GetRatio()
        {
            float      ratio = (float)Screen.width / (float)Screen.height;
            ScreenSize size  = ScreenSize.SIZE_5TO4;

            if (Mathf.Abs(ratio - 16f / 9f) < 0.01f)
            {
                size = ScreenSize.SIZE_16TO9;
            }
            else if (Mathf.Abs(ratio - 16f / 10f) < 0.01f)
            {
                size = ScreenSize.SIZE_16TO10;
            }
            else if (Mathf.Abs(ratio - 3f / 2f) < 0.01f)
            {
                size = ScreenSize.SIZE_3TO2;
            }
            else if (Mathf.Abs(ratio - 4f / 3f) < 0.01f)
            {
                size = ScreenSize.SIZE_4TO3;
            }
            else if (Mathf.Abs(ratio - 5f / 4f) < 0.01f)
            {
                size = ScreenSize.SIZE_5TO4;
            }

            return(size);
        }
예제 #16
0
        /// <summary>
        /// Sets the screen's size
        /// </summary>
        public ScreenImplementation()
        {
            var displayMetrics = Resources.System.DisplayMetrics;
            var height         = displayMetrics.HeightPixels / displayMetrics.Density;
            var width          = displayMetrics.WidthPixels / displayMetrics.Density;

            Size = new ScreenSize(true, width, height);
        }
예제 #17
0
 private static AButton[] GetButtons(ContentManager content, GraphicsDeviceManager graphics)
 {
     return(new AButton[]
     {
         new ActionButton(content, 620, 320, 260, 50, new[] { VideoMenu.Fullscreen + ScreenSize.IsFullScreen() }, () =>
         {
             ScreenSize.ChangeSize(graphics);     //TODO reload game HUD
         }, default, new List <Screen> {
예제 #18
0
        public void SetScale(double scale)
        {
            VideoConfig.VideoScale = scale;
            ApplyVideoConfig();
            ScreenSize size = SnesApi.GetScreenSize(false);

            _renderControl.Size = new Size(size.Width, size.Height);
        }
 public static SmartClicker GetInstance(IntPtr hwnd, ScreenSize size)
 {
     if ((hwnd == IntPtr.Zero) || !Utility.supported.Contains(size))
     {
         return(null);
     }
     return(instance ?? new SmartClicker(hwnd, size));
 }
예제 #20
0
		public static Dimensions SizeInTilesForBGSize(ScreenSize size)
		{
			if (size == ScreenSize.Hacky_1x1) return new Dimensions(1, 1);
			var ret = SizeInBlocksForBGSize(size);
			ret.Width *= 32;
			ret.Height *= 32;
			return ret;
		}
예제 #21
0
        /// <summary>
        /// title bar design
        /// </summary>
        /// <param name="dp"></param>
        /// <param name="sr">log panel drawing area</param>
        /// <returns></returns>
        protected virtual ScreenY drawTitleBar(DrawProperty dp, ScreenRect sr)
        {
            var _bd         = new CanvasSolidColorBrush(dp.Canvas, Color.FromArgb(64, 0, 0, 0));
            var titleHeight = 8;
            var w3          = sr.Width / 4;
            var pst         = new ScreenPos[] { ScreenPos.From(sr.LT.X, sr.LT.Y + titleHeight + 16), ScreenPos.From(sr.LT.X, sr.LT.Y), ScreenPos.From(sr.RB.X, sr.LT.Y), };
            var psb         = new ScreenPos[] { ScreenPos.From(sr.RB.X, sr.LT.Y + titleHeight), ScreenPos.From(sr.RB.X - w3, sr.LT.Y + titleHeight + 2), ScreenPos.From(sr.RB.X - w3 * 2, sr.LT.Y + titleHeight + 8), ScreenPos.From(sr.RB.X - w3 * 3, sr.LT.Y + titleHeight + 16), ScreenPos.From(sr.LT.X, sr.LT.Y + titleHeight + 16), };
            var ps          = pst.Union(psb).ToList();
            var path        = new CanvasPathBuilder(dp.Canvas);

            path.BeginFigure(ps[0]);
            for (var i = 1; i < ps.Count; i++)
            {
                path.AddLine(ps[i]);
            }
            path.EndFigure(CanvasFigureLoop.Closed);
            var geo = CanvasGeometry.CreatePath(path);

            dp.Graphics.FillGeometry(geo, _bd);

            // edge highlight
            for (var i = 1; i < pst.Length; i++)
            {
                dp.Graphics.DrawLine(pst[i - 1], pst[i], Color.FromArgb(96, 255, 255, 255));
            }
            // edge shadow
            for (var i = 1; i < psb.Length; i++)
            {
                dp.Graphics.DrawLine(psb[i - 1], psb[i], Color.FromArgb(96, 0, 0, 0));
            }

            // title bar design
            var btr = sr.Clone();

            btr.RB = ScreenPos.From(btr.LT.X + ScreenX.From(24), btr.LT.Y + ScreenY.From(12));
            btr    = btr + ScreenPos.From(4, 4);
            var imgttl = Assets.Image("LogPanelTitileDesign");

            if (imgttl != null)
            {
                dp.Graphics.DrawImage(imgttl, btr.LT + ScreenSize.From(-3, -14));
            }
            btr = btr + ScreenX.From(50);

            // title filter buttons
            var btn1 = Assets.Image("btnLogPanel");
            var btn0 = Assets.Image("btnLogPanelOff");

            if (btn1 != null && btn0 != null)
            {
                var ctfb = new CanvasTextFormat
                {
                    FontFamily = "Arial",
                    FontSize   = 10.0f,
                    FontWeight = FontWeights.Normal,
                    FontStyle  = FontStyle.Italic,
                };
                foreach ((var lv, var caption) in new (LLV, string)[] { (LLV.ERR, "e"), (LLV.WAR, "w"), (LLV.INF, "i"), (LLV.DEV, "d") })
예제 #22
0
        /// <summary>
        /// Use this to setup the screen, this will disable the console.
        /// </summary>
        /// <param name="aSize">The dezired screen resolution</param>
        /// <param name="aBpp">The dezired Bytes per pixel</param>
        public void SetMode(ScreenSize aSize, Bpp aBpp)
        {
            //Get screen size
            switch (aSize)
            {
            case ScreenSize.Size320X200:
                ScreenWidth  = 320;
                ScreenHeight = 200;
                break;

            case ScreenSize.Size640X400:
                ScreenWidth  = 640;
                ScreenHeight = 400;
                break;

            case ScreenSize.Size640X480:
                ScreenWidth  = 640;
                ScreenHeight = 480;
                break;

            case ScreenSize.Size800X600:
                ScreenWidth  = 800;
                ScreenHeight = 600;
                break;

            case ScreenSize.Size1024X768:
                ScreenWidth  = 1024;
                ScreenHeight = 768;
                break;

            case ScreenSize.Size1280X1024:
                ScreenWidth  = 1280;
                ScreenHeight = 1024;
                break;
            }
            //Get bpp
            switch (aBpp)
            {
            case Bpp.Bpp15:
                ScreenBpp = 15;
                break;

            case Bpp.Bpp16:
                ScreenBpp = 16;
                break;

            case Bpp.Bpp24:
                ScreenBpp = 24;
                break;

            case Bpp.Bpp32:
                ScreenBpp = 32;
                break;
            }
            //set the screen
            _vbe.vbe_set((ushort)ScreenWidth, (ushort)ScreenHeight, (ushort)ScreenBpp);
        }
예제 #23
0
        public Form1()
        {
            InitializeComponent();

            ScreenSizeInCanvas          = ScreenSize.ApplyAspect(CanvasSize);
            label2.Text                 = string.Format("Your screen resolution: {0}x{1}", ScreenSize.Width, ScreenSize.Height);
            this.pictureBox1.MouseDown += (s, e) =>
            {
                isl   = true;
                start = e.Location;
                this.pictureBox1.Cursor = Cursors.Cross;
            };
            this.pictureBox1.MouseMove += (s, e) =>
            {
                if (isl)
                {
                    start_x += e.X - start.X;
                    start_y += e.Y - start.Y;
                    start    = e.Location;
                    draw_result();
                }
            };
            this.pictureBox1.MouseUp += (s, e) =>
            {
                isl   = false;
                start = e.Location;
                this.pictureBox1.Cursor = Cursors.Arrow;
                draw_result();
            };

            this.button4.MouseDown += (s, e) =>
            {
                m_MouseDownInEyedropper = true;
                this.Cursor             = m_eyeDropperCursor;

                m_ScreenImage = Utility.CaptureScreen();

                m_cursorLocation        = Utility.GetCursorPostionOnScreen();
                this.domColor.BackColor = m_ScreenImage.GetPixel(m_cursorLocation.X, m_cursorLocation.Y);
            };
            this.button4.MouseMove += (s, e) =>
            {
                if (m_MouseDownInEyedropper)
                {
                    m_cursorLocation        = Utility.GetCursorPostionOnScreen();
                    this.domColor.BackColor = m_ScreenImage.GetPixel(m_cursorLocation.X, m_cursorLocation.Y);
                    draw_result();
                }
            };
            this.button4.MouseUp += (s, e) =>
            {
                m_MouseDownInEyedropper = false;
                m_ScreenImage.Dispose();
                this.Cursor = Cursors.Default;
                draw_result();
            };
        }
예제 #24
0
        public void Move(IDrawArea pane, ScreenSize offset)
        {
            var s0 = GetScreenPos(pane, PositionBackup);
            var s1 = s0 + offset;
            var l1 = LayoutPos.From(pane, s1);
            var cl = CoderX(l1.X, l1.Y);
            var ca = CoderY(l1.X, l1.Y);

            Location = CodePos <Distance, Angle> .From(cl, ca);
        }
예제 #25
0
 public static Dimensions SizeInBlocksForBGSize(ScreenSize size)
 {
     return(size switch
     {
         ScreenSize.AAAA_32x32 => new Dimensions(1, 1),
         ScreenSize.ABAB_64x32 => new Dimensions(2, 1),
         ScreenSize.AABB_32x64 => new Dimensions(1, 2),
         ScreenSize.ABCD_64x64 => new Dimensions(2, 2),
         _ => throw new Exception()
     });
예제 #26
0
		public static Dimensions SizeInBlocksForBGSize(ScreenSize size)
		{
			switch (size)
			{
				case ScreenSize.AAAA_32x32: return new Dimensions(1, 1);
				case ScreenSize.ABAB_64x32: return new Dimensions(2, 1);
				case ScreenSize.AABB_32x64: return new Dimensions(1, 2);
				case ScreenSize.ABCD_64x64: return new Dimensions(2, 2);
				default: throw new Exception();
			}
		}
        public static SmartClicker GetInstance(IntPtr hwnd)
        {
            WC.GetClientRect(hwnd, out ClientRect);
            if (!WC.IsFullScreen(hwnd))
            {
                return(null);
            }
            ScreenSize size = (ScreenSize)Enum.Parse(typeof(ScreenSize), string.Concat(new object[] { "Size", ClientRect.Width, "x", ClientRect.Height }));

            return(GetInstance(hwnd, size));
        }
예제 #28
0
        public override Dictionary <string, string> GetAdditionalProperties()
        {
            Dictionary <string, string> additionalProperties = new Dictionary <string, string>();

            additionalProperties.Add("Screen size", ScreenSize.ToString());
            additionalProperties.Add("Processor", Processor);
            additionalProperties.Add("RAM", RAM.ToString());
            additionalProperties.Add("Battery capacity", BatteryCapacity.ToString());

            return(additionalProperties);
        }
        public async Task <IHttpActionResult> SetScreenResolution(ScreenSize screenSize)
        {
            if (screenSize == null)
            {
                return(new StatusCodeResult(HttpStatusCode.BadRequest, Request));
            }

            await MyConfig.SetScreenResolution(screenSize.Width, screenSize.Height);

            return(Ok());
        }
예제 #30
0
        private void UpdateScale()
        {
            Size       dimensions = pnlRenderer.ClientSize;
            ScreenSize size       = EmuApi.GetScreenSize(true, EmuApi.ConsoleId.HistoryViewer);

            double verticalScale   = (double)dimensions.Height / size.Height;
            double horizontalScale = (double)dimensions.Width / size.Width;
            double scale           = Math.Min(verticalScale, horizontalScale);

            EmuApi.SetVideoScale(scale, EmuApi.ConsoleId.HistoryViewer);
        }
예제 #31
0
        private void SetScale(int scale)
        {
            ScreenSize size    = EmuApi.GetScreenSize(true, EmuApi.ConsoleId.HistoryViewer);
            Size       newSize = new Size(size.Width * scale, size.Height * scale);

            if (this.WindowState != FormWindowState.Maximized)
            {
                Size sizeGap = newSize - ctrlRenderer.Size;
                this.ClientSize += sizeGap;
            }
            ctrlRenderer.Size = newSize;
        }
예제 #32
0
        public static Dimensions SizeInTilesForBGSize(ScreenSize size)
        {
            if (size == ScreenSize.Hacky_1x1)
            {
                return(new Dimensions(1, 1));
            }
            var ret = SizeInBlocksForBGSize(size);

            ret.Width  *= 32;
            ret.Height *= 32;
            return(ret);
        }
예제 #33
0
    public void ResetGame()
    {
        if (board != null) {
            for (int i = 0; i < rounds; ++i) {
                for (int f = 0; f < 2; ++f) {
                    Destroy (board [i] [f].fieldAction);
                    Destroy (board [i] [f].fieldElement);
                }
            }
        }

        screen = new ScreenSize (interfaceScript.canvas.pixelRect);

        rounds = boardSize;
        round = 0;
        scoreP1 = 0;
        scoreP2 = 0;

        interfaceScript.round.text = "1";
        interfaceScript.scoreP1.text = "0";
        interfaceScript.scoreP2.text = "0";

        board = new List<Board[]>();

        float fieldSize = screen.width / boardSize;
        float fieldBorder = Mathf.Clamp(fieldSize / 10.0f, 0.0f, screen.height / 25.0f);
        float fieldSizeWithoutBorder = fieldSize - fieldBorder;
        float halfWidth = screen.width / 2.0f;

        for (int i = 0; i < rounds; ++i) {
            board.Add (new Board[2]);

            for (int f = 0; f < 2; ++f) {
                board [i] [f].action = 0;

                board [i] [f].fieldElement = Instantiate(fieldElement) as GameObject;
                board [i] [f].fieldElement.transform.SetParent(GameObject.Find ("Board").transform, false);
                board [i] [f].fieldElement.name = "FieldElement_" + i + "_" + f;
            }

            RectTransform curBoard1 = board [i] [0].fieldElement.GetComponent<RectTransform> ();
            RectTransform curBoard2 = board [i] [1].fieldElement.GetComponent<RectTransform> ();

            curBoard1.sizeDelta = new Vector2 (fieldSizeWithoutBorder, Mathf.Clamp(fieldSizeWithoutBorder, 50.0f, 125.0f));
            curBoard2.sizeDelta = new Vector2 (fieldSizeWithoutBorder, Mathf.Clamp(fieldSizeWithoutBorder, 50.0f, 125.0f));
            curBoard1.anchoredPosition = new Vector2 (fieldSize * i - (halfWidth - fieldSize / 2.0f), curBoard1.rect.height / 2.0f + fieldBorder / 2.0f);
            curBoard2.anchoredPosition = new Vector2 (fieldSize * i - (halfWidth - fieldSize / 2.0f), -(curBoard2.rect.height / 2.0f + fieldBorder / 2.0f));
        }

        gameRunning = true;
        interfaceScript.restart.gameObject.SetActive (false);
    }
예제 #34
0
파일: VBEScreen.cs 프로젝트: Orvid/Cosmos
 /// <summary>
 /// Use this to setup the screen, this will disable the console.
 /// </summary>
 /// <param name="aSize">The dezired screen resolution</param>
 /// <param name="aBpp">The dezired Bytes per pixel</param>
 public void SetMode(ScreenSize aSize, Bpp aBpp)
 {
     //Get screen size
     switch (aSize)
     {
         case ScreenSize.Size320x200:
             ScreenWidth = 320;
             ScreenHeight = 200;
             break;
         case ScreenSize.Size640x400:
             ScreenWidth = 640;
             ScreenHeight = 400;
             break;
         case ScreenSize.Size640x480:
             ScreenWidth = 640;
             ScreenHeight = 480;
             break;
         case ScreenSize.Size800x600:
             ScreenWidth = 800;
             ScreenHeight = 600;
             break;
         case ScreenSize.Size1024x768:
             ScreenWidth = 1024;
             ScreenHeight = 768;
             break;
         case ScreenSize.Size1280x1024:
             ScreenWidth = 1280;
             ScreenHeight = 1024;
             break;
     }
     //Get bpp
     switch (aBpp)
     {
         case Bpp.Bpp15:
             ScreenBpp = 15;
             break;
         case Bpp.Bpp16:
             ScreenBpp = 16;
             break;
         case Bpp.Bpp24:
             ScreenBpp = 24;
             break;
         case Bpp.Bpp32:
             ScreenBpp = 32;
             break;
     }
     //set the screen
    _vbe.vbe_set((ushort)ScreenWidth, (ushort)ScreenHeight, (ushort)ScreenBpp);
 }
예제 #35
0
        public static void SetGraphicsMode(ScreenSize screenSize, ColorDepth colorDepth)
        {
            HALVGAScreen.ScreenSize ScrSize = HALVGAScreen.ScreenSize.Size320x200;
            HALVGAScreen.ColorDepth ClrDepth = HALVGAScreen.ColorDepth.BitDepth8;

            switch (screenSize)
            {
                case ScreenSize.Size320x200:
                    ScrSize = HALVGAScreen.ScreenSize.Size320x200;
                    break;
                case ScreenSize.Size640x480:
                    ScrSize = HALVGAScreen.ScreenSize.Size640x480;
                    break;
                case ScreenSize.Size720x480:
                    ScrSize = HALVGAScreen.ScreenSize.Size720x480;
                    break;
                default:
                    throw new Exception("This situation is not implemented!");
            }

            switch (colorDepth)
            {
                case ColorDepth.BitDepth2:
                    ClrDepth = HALVGAScreen.ColorDepth.BitDepth2;
                    break;
                case ColorDepth.BitDepth4:
                    ClrDepth = HALVGAScreen.ColorDepth.BitDepth4;
                    break;
                case ColorDepth.BitDepth8:
                    ClrDepth = HALVGAScreen.ColorDepth.BitDepth8;
                    break;
                case ColorDepth.BitDepth16:
                    ClrDepth = HALVGAScreen.ColorDepth.BitDepth16;
                    break;
                default:
                    throw new Exception("This situation is not implemented!");
            }

            mScreen.SetGraphicsMode(ScrSize, ClrDepth);
        }
예제 #36
0
        public MFTestResults LargeBitmapTest()
        {

            MFTestResults result = MFTestResults.Fail;

            ScreenSize[] pairs = new ScreenSize[] { 
                                                    new ScreenSize( 160, 120 ), // QQVGA
                                                    new ScreenSize( 240, 160 ), // HQVGA
                                                    new ScreenSize( 320, 240 ), // QVGA
                                                    new ScreenSize( 480, 320 ), // HVGA
                                                    new ScreenSize( 640, 240 ), // HVGA
                                                    new ScreenSize( 864, 480 ), // FWVGA
                                                    new ScreenSize( 640, 480 ), // VGA 
                                                    new ScreenSize( 800, 480 ), // WVGA
                                                    new ScreenSize( 848, 480 ), // WVGA
                                                    new ScreenSize( 854, 480 ), // WVGA
                                                    //new ScreenSize( 1024, 768 ), // XVGA
                                                    //new ScreenSize( 1152, 864 ), // XVGA+
                                                    //new ScreenSize( 1280, 1024 ), // SXGA
                                                    //new ScreenSize( 1400, 1050 ), // SXGA+
                                                    //new ScreenSize( 1600, 1200 ), // UXGA
                                                  };
            Bitmap bmp = null;
            try
            {

                foreach (ScreenSize p in pairs)
                {
                    try
                    {
                        // the CLR's limit of allocation in the managed heap is sizeof(CLR_RT_HeapBlock) * (2^16) = 768432 bytes. 
                        // To that one needs to subtract the size of an heap cluster (sizeof(CLR_RT_heapCluster)) and 
                        // round to the number of heap blocks in the remaining amount, since the CLR allocated in heap blocks units. 
                        // Thus some allocation (e.g. 800x600) must go in the unmanaged SimpleHeap if supported.

                        bmp = new Bitmap(p.width, p.height);
                    }
                    catch (OutOfMemoryException)
                    {
                        //SimpleHeap has no legitimate API to distinguish between no implementation
                        //or implemented but out-of-memory condition occurred. If OOM is thrown, assume
                        //it is because no SimpleHeap was provided.
                        // On the emulator though, we know it is implemented
                        if (Microsoft.SPOT.Hardware.SystemInfo.SystemID.SKU == 3)
                        {
                            return MFTestResults.Fail;
                        }
                    }

                    bmp.DrawLine(Color.White, 5, 0, 0, bmp.Width, bmp.Height);
                    bmp.DrawEllipse(Color.White, 4, 50, 50, 40, 11, Color.White, 0, 0, Color.Black, bmp.Width, bmp.Height, 5);

                    window.StretchImage(0, 0, bmp, width, height, 0xFF);
                    window.Flush();

                    bmp.Dispose(); bmp = null; // this is particlarly needed for the allocation in the non-managed heap   
                }

                result = MFTestResults.Pass;
            }
            finally
            {
                if (bmp != null)
                {
                    bmp.Dispose();
                }
                Debug.GC(true);
                System.Threading.Thread.Sleep(500);
            }

            return result;
        }
예제 #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FilmFormat"/> class.
 /// </summary>
 /// <param name='name'>
 /// Name.
 /// </param>
 /// <param name='filmWidth'>
 /// Film width in inches.
 /// </param>
 /// <param name='filmHeight'>
 /// Film height in inches.
 /// </param>
 /// <param name='aspectRatio'>
 /// Aspect ratio.
 /// </param>
 /// <param name='screenSizes'>
 /// ScreenSizes.
 /// </param>
 public FilmFormat(string name, float filmWidth, float filmHeight, float aspectRatio, ScreenSize[] screenSizes)
 {
     this.name = name;
     this.filmWidth = filmWidth;
     this.filmHeight = filmHeight;
     this.aspectRatio = aspectRatio;
     this.screenSizes = screenSizes;
 }
예제 #38
0
 public static void SetScreenSize(int index)
 {
     currentScreenSizeMode = (ScreenSize)Enum.ToObject(typeof(ScreenSize), index);
     game.setScreenSize(index);
     HUD.UpdateScale();
     Vignette.Load();
 }
예제 #39
0
        /// <summary>
        /// fetches a tilemap. this is simple; apparently only the screen size (shape) is a factor (not the tile size)
        /// </summary>
        public TileEntry[] FetchTilemap(int addr, ScreenSize size)
        {
            var blockDims = SizeInBlocksForBGSize(size);
            int blocksw = blockDims.Width;
            int blocksh = blockDims.Height;
            int width = blockDims.Width * 32;
            int height = blockDims.Height * 32;
            TileEntry[] buf = new TileEntry[width*height];

            for (int by = 0; by < blocksh; by++)
            {
                for (int bx = 0; bx < blocksw; bx++)
                {
                    for (int y = 0; y < 32; y++)
                    {
                        for (int x = 0; x < 32; x++)
                        {
                            int idx = (by * 32 + y) * width + bx * 32 + x;
                            ushort entry = *(ushort*)(vram + addr);
                            buf[idx].tilenum = (ushort)(entry & 0x3FF);
                            buf[idx].palette = (byte)((entry >> 10) & 7);
                            buf[idx].flags = (TileEntryFlags)((entry >> 13) & 7);
                            buf[idx].address = addr;
                            addr += 2;
                        }
                    }
                }
            }

            return buf;
        }
예제 #40
0
파일: VGAScreen.cs 프로젝트: rebizu/Cosmos
        public void SetGraphicsMode(ScreenSize aSize, ColorDepth aDepth)
        {
            switch (aSize)
            { 
                case ScreenSize.Size320x200:
                    if (aDepth == ColorDepth.BitDepth8)
                    {
                        WriteVGARegisters(g_320x200x8);

                        PixelWidth = 320;
                        PixelHeight = 200;
                        Colors = 256;
                        SetPixel = new SetPixelDelegate(SetPixel320x200x8);
                        GetPixel = new GetPixelDelegate(GetPixel320x200x8);
                    }
                    else if (aDepth == ColorDepth.BitDepth4)
                    {
                        WriteVGARegisters(g_320x200x4);

                        PixelWidth = 320;
                        PixelHeight = 200;
                        Colors = 16;
                        //SetPixel = new SetPixelDelegate(SetPixel320x200x4);
                        //GetPixel = new GetPixelDelegate(GetPixel320x200x4);
                    }
                    else throw new Exception("Unsupported color depth passed for specified screen size");
                    break;
                case ScreenSize.Size640x480:
                    if (aDepth == ColorDepth.BitDepth2)
                    {
                        WriteVGARegisters(g_640x480x2);

                        PixelWidth = 640;
                        PixelHeight = 480;
                        Colors = 4;
                        //SetPixel = new SetPixelDelegate(SetPixel640x480x2);
                        //GetPixel = new GetPixelDelegate(GetPixel640x480x2);
                    }
                    else if (aDepth == ColorDepth.BitDepth4)
                    {
                        WriteVGARegisters(g_640x480x4);

                        PixelWidth = 640;
                        PixelHeight = 480;
                        Colors = 16;
                        SetPixel = new SetPixelDelegate(SetPixel640x480x4);
                        GetPixel = new GetPixelDelegate(GetPixel640x480x4);
                    }
                    else throw new Exception("Unsupported color depth passed for specified screen size");
                    break;
                case ScreenSize.Size720x480:
                    if (aDepth == ColorDepth.BitDepth4)
                    {
                        WriteVGARegisters(g_720x480x4);

                        PixelWidth = 720;
                        PixelHeight = 480;
                        Colors = 16;
                        SetPixel = new SetPixelDelegate(SetPixel720x480x4);
                        GetPixel = new GetPixelDelegate(GetPixel720x480x4);
                    }
                    else throw new Exception("Unsupported color depth passed for specified screen size");
                    break;
                default:
                    throw new Exception("Unknown screen size");
            }
        }
예제 #41
0
        /// <summary>
        /// returns a tilemap which might be resized into 8x8 physical tiles if the 16x16 logical tilesize is specified
        /// </summary>
        //TileEntry[] AdaptTilemap(TileEntry[] map8x8, int tilesWide, int tilesTall, int tilesize)
        //{
        //  if (tilesize == 8) return map8x8;
        //  int numTiles = tilesWide * tilesTall;
        //  var ret = new TileEntry[numTiles * 4];
        //  for(int y=0;y<tilesTall;y++)
        //  {
        //    for (int x = 0; x < tilesWide; x++)
        //    {
        //      int si = tilesWide * y + x;
        //      int di = tilesHigh
        //      for (int tx = 0; tx < 2; tx++)
        //      {
        //        for (int ty = 0; ty < 2; ty++)
        //        {
        //        }
        //      }
        //    }
        //  }
        //}
        /// <summary>
        /// decodes a BG. youll still need to paletteize and colorize it.
        /// someone else has to take care of calculating the starting color from the mode and layer number.
        /// </summary>
        public void DecodeBG(int* screen, int stride, TileEntry[] map, int tiledataBaseAddr, ScreenSize size, int bpp, int tilesize, int paletteStart)
        {
            int ncolors = 1 << bpp;

            int[] tileBuf = new int[16*16];
            var dims = SizeInTilesForBGSize(size);
            int count8x8 = tilesize / 8;
            int tileSizeBytes = 8 * bpp;
            int baseTileNum = tiledataBaseAddr / tileSizeBytes;
            int[] tileCache = _tileCache[bpp];
            int tileCacheMask = tileCache.Length - 1;

            int screenWidth = dims.Width * count8x8 * 8;

            for (int mty = 0; mty < dims.Height; mty++)
            {
                for (int mtx = 0; mtx < dims.Width; mtx++)
                {
                    for (int tx = 0; tx < count8x8; tx++)
                    {
                        for (int ty = 0; ty < count8x8; ty++)
                        {
                            int mapIndex = mty * dims.Width + mtx;
                            var te = map[mapIndex];
                            int tileNum = te.tilenum + tx + ty * 16 + baseTileNum;
                            int srcOfs = tileNum * 64;
                            for (int i = 0, y = 0; y < 8; y++)
                            {
                                for (int x = 0; x < 8; x++, i++)
                                {
                                    int px = x;
                                    int py = y;
                                    if ((te.flags & TileEntryFlags.Horz) != 0) px = 7 - x;
                                    if ((te.flags & TileEntryFlags.Vert) != 0) py = 7 - y;
                                    int dstX = (mtx * count8x8 + tx) * 8 + px;
                                    int dstY = (mty * count8x8 + ty) * 8 + py;
                                    int dstOfs = dstY * stride + dstX;
                                    int color = tileCache[srcOfs & tileCacheMask];
                                    srcOfs++;
                                    if (color == 0 && usingUserBackColor)
                                    { }
                                    else
                                    {
                                        color += te.palette * ncolors;
                                        color += paletteStart;
                                    }
                                    screen[dstOfs] = color;
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #42
0
 public static void SetScreenSize(ScreenSize size)
 {
     currentScreenSizeMode = size;
     game.setScreenSize((int)size);
     HUD.UpdateScale();
     Vignette.Load();
 }
예제 #43
0
		/// <summary>
		/// returns a tilemap which might be resized into 8x8 physical tiles if the 16x16 logical tilesize is specified
		/// </summary>
		//TileEntry[] AdaptTilemap(TileEntry[] map8x8, int tilesWide, int tilesTall, int tilesize)
		//{
		//  if (tilesize == 8) return map8x8;
		//  int numTiles = tilesWide * tilesTall;
		//  var ret = new TileEntry[numTiles * 4];
		//  for(int y=0;y<tilesTall;y++)
		//  {
		//    for (int x = 0; x < tilesWide; x++)
		//    {
		//      int si = tilesWide * y + x;
		//      int di = tilesHigh 
		//      for (int tx = 0; tx < 2; tx++)
		//      {
		//        for (int ty = 0; ty < 2; ty++)
		//        {
		//        }
		//      }
		//    }
		//  }
		//}

		/// <summary>
		/// decodes a BG. youll still need to paletteize and colorize it.
		/// someone else has to take care of calculating the starting color from the mode and layer number.
		/// </summary>
		public void DecodeBG(int* screen, int stride, TileEntry[] map, int tiledataBaseAddr, ScreenSize size, int bpp, int tilesize, int paletteStart)
		{
			//emergency backstop. this can only happen if we're displaying an unavailable BG or other similar such value
			if (bpp == 0) return;

			int ncolors = 1 << bpp;

			int[] tileBuf = new int[16*16];
			var dims = SizeInTilesForBGSize(size);
			int count8x8 = tilesize / 8;
			int tileSizeBytes = 8 * bpp;
			int baseTileNum = tiledataBaseAddr / tileSizeBytes;
			int[] tileCache = _tileCache[bpp];
			int tileCacheMask = tileCache.Length - 1;

			int screenWidth = dims.Width * count8x8 * 8;

			for (int mty = 0; mty < dims.Height; mty++)
			{
				for (int mtx = 0; mtx < dims.Width; mtx++)
				{
					for (int tx = 0; tx < count8x8; tx++)
					{
						for (int ty = 0; ty < count8x8; ty++)
						{
							int mapIndex = mty * dims.Width + mtx;
							var te = map[mapIndex];
							
							//apply metatile flipping
							int tnx = tx, tny = ty;
							if (tilesize == 16)
							{
								if ((te.flags & TileEntryFlags.Horz) != 0) tnx = 1 - tnx;
								if ((te.flags & TileEntryFlags.Vert) != 0) tny = 1 - tny;
							}

							int tileNum = te.tilenum + tnx + tny * 16 + baseTileNum;
							int srcOfs = tileNum * 64;
							for (int i = 0, y = 0; y < 8; y++)
							{
								for (int x = 0; x < 8; x++, i++)
								{
									int px = x;
									int py = y;
									if ((te.flags & TileEntryFlags.Horz) != 0) px = 7 - x;
									if ((te.flags & TileEntryFlags.Vert) != 0) py = 7 - y;
									int dstX = (mtx * count8x8 + tx) * 8 + px;
									int dstY = (mty * count8x8 + ty) * 8 + py;
									int dstOfs = dstY * stride + dstX;
									int color = tileCache[srcOfs & tileCacheMask];
									srcOfs++;
									if (color == 0 && usingUserBackColor)
									{ }
									else
									{
										color += te.palette * ncolors;
										color += paletteStart;
									}
									screen[dstOfs] = color;
								}
							}
						}
					}
				}
			}
		}
    private void UpdateScreenSize()
    {
        ScreenSize newScreenSize = null;
        int screenSize = Mathf.Min(Screen.height, Screen.width);
        foreach (ScreenSize scrn in ScreenSizes.Reverse())
        {
            if (screenSize >= scrn.MinimumResolution)
            {
                newScreenSize = scrn;
                break;
            }
        }

        if (newScreenSize != null)
        {
            CurrentScreenSize = newScreenSize;
        }
    }
 public virtual void Start()
 {
     UpdateScreenSize();
     CurrentScreenWidth = Screen.width;
     if (CurrentScreenSize == null)
     {
         CurrentScreenSize = ScreenSizes[0];
     }
 }