예제 #1
0
        public void PrepareFrame(Viewer viewer)
        {
            if (RenderSurfaceMaterial == null)
            {
                RenderSurfaceMaterial = new SpriteBatchMaterial(viewer, BlendState.Opaque);
            }

            if (viewer.Settings.UseMSTSEnv == false)
            {
                SolarDirection = viewer.World.Sky.solarDirection;
            }
            else
            {
                SolarDirection = viewer.World.MSTSSky.mstsskysolarDirection;
            }

            if (ShadowMapMaterial == null)
            {
                ShadowMapMaterial = (ShadowMapMaterial)viewer.MaterialManager.Load("ShadowMap");
            }
            if (SceneryShader == null)
            {
                SceneryShader = viewer.MaterialManager.SceneryShader;
            }
        }
예제 #2
0
        public WindowManager(Viewer viewer)
        {
            Viewer = viewer;
            WindowManagerMaterial   = new BasicBlendedMaterial(viewer, "WindowManager");
            PopupWindowMaterial     = (PopupWindowMaterial)Viewer.MaterialManager.Load("PopupWindow");
            SpriteBatchMaterial     = (SpriteBatchMaterial)Viewer.MaterialManager.Load("SpriteBatch");
            TextManager             = new WindowTextManager();
            TextFontDefault         = TextManager.GetScaled("Arial", 10, System.Drawing.FontStyle.Regular);
            TextFontDefaultOutlined = TextManager.GetScaled("Arial", 10, System.Drawing.FontStyle.Regular, 1);
            TextFontSmall           = TextManager.GetScaled("Arial", 8, System.Drawing.FontStyle.Regular);
            TextFontSmallOutlined   = TextManager.GetScaled("Arial", 8, System.Drawing.FontStyle.Regular, 1);

            SpriteBatch = new SpriteBatch(Viewer.GraphicsDevice);

            if (WhiteTexture == null)
            {
                WhiteTexture = new Texture2D(Viewer.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                WhiteTexture.SetData(new[] { Color.White });
            }
            if (FlushTexture == null)
            {
                FlushTexture = new Texture2D(Viewer.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                FlushTexture.SetData(new[] { Color.Transparent });
            }
            if (ScrollbarTexture == null)
            {
                // TODO: This should happen on the loader thread.
                ScrollbarTexture = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "WindowScrollbar.png"));
            }
            if (LabelShadowTexture == null)
            {
                // TODO: This should happen on the loader thread.
                LabelShadowTexture = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "WindowLabelShadow.png"));
            }
            if (NoticeTexture == null)
            {
                var size         = 256;
                var background   = new Color(Color.Black, 0.5f);
                var borderRadius = size / 7;
                var data         = new Color[size * size * 2];

                // Rounded corner background.
                for (var y = 0; y < size; y++)
                {
                    for (var x = 0; x < size; x++)
                    {
                        if ((x > borderRadius && x < size - borderRadius) || (y > borderRadius && y < size - borderRadius) ||
                            (Math.Sqrt((x - borderRadius) * (x - borderRadius) + (y - borderRadius) * (y - borderRadius)) < borderRadius) ||
                            (Math.Sqrt((x - size + borderRadius) * (x - size + borderRadius) + (y - borderRadius) * (y - borderRadius)) < borderRadius) ||
                            (Math.Sqrt((x - borderRadius) * (x - borderRadius) + (y - size + borderRadius) * (y - size + borderRadius)) < borderRadius) ||
                            (Math.Sqrt((x - size + borderRadius) * (x - size + borderRadius) + (y - size + borderRadius) * (y - size + borderRadius)) < borderRadius))
                        {
                            data[y * size + x] = background;
                        }
                    }
                }

                // Notice texture is just the rounded corner background.
                NoticeTexture = new Texture2D(Viewer.GraphicsDevice, size, size, false, SurfaceFormat.Color);
                NoticeTexture.SetData(data, 0, size * size);

                // Clone the background for pause texture (it has two states).
                Array.Copy(data, 0, data, size * size, size * size);

                // Play ">" symbol.
                for (var y = size / 7; y < size - size / 7; y++)
                {
                    for (var x = size / 7; x < size - size / 7 - 2 * Math.Abs(y - size / 2); x++)
                    {
                        data[y * size + x] = Color.White;
                    }
                }

                // Pause "||" symbol.
                for (var y = size + size / 7; y < 2 * size - size / 7; y++)
                {
                    for (var x = size * 2 / 7; x < size * 3 / 7; x++)
                    {
                        data[y * size + x] = Color.White;
                    }
                    for (var x = size * 4 / 7; x < size * 5 / 7; x++)
                    {
                        data[y * size + x] = Color.White;
                    }
                }

                PauseTexture = new Texture2D(Viewer.GraphicsDevice, size, size * 2, false, SurfaceFormat.Color);
                PauseTexture.SetData(data);
            }
        }