public DispatcherLabel(WorldLocation position, Color color, string text, WindowTextFont font)
 {
     Position = position;
     Color    = color;
     Text     = text;
     Font     = font;
     TextSize = new Vector2(Font.MeasureString(text), Font.Height);
 }
Exemplo n.º 2
0
 public override void Initialize(WindowManager windowManager)
 {
     base.Initialize(windowManager);
     Font = windowManager.TextFontDefault;
     if (TrainDrivingWindow.FontToBold || MultiPlayerWindow.FontToBold || TrainDpuWindow.FontToBold)
     {
         Font = windowManager.TextFontDefaultBold;
     }
 }
Exemplo n.º 3
0
        internal override void ScreenChanged()
        {
            // SizeTo does not clamp the size so we should do it first; MoveTo clamps position.
            SizeTo(Owner.ScreenSize.X, Owner.ScreenSize.Y);
            MoveTo(0, 0);

            Font = Owner.TextManager.GetExact("Arial", (int)(Owner.ScreenSize.Y * NoticeTextSize), System.Drawing.FontStyle.Regular);

            base.ScreenChanged();
        }
Exemplo n.º 4
0
        public TrackMonitor(int width, int height, WindowManager owner)
            : base(0, 0, width, height)
        {
            if (SignalAspects == null)
            {
                // TODO: This should happen on the loader thread.
                SignalAspects = SharedTextureManager.Get(owner.Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(owner.Viewer.ContentPath, "SignalAspects.png"));
            }
            if (TrackMonitorImages == null)
            {
                // TODO: This should happen on the loader thread.
                TrackMonitorImages = SharedTextureManager.Get(owner.Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(owner.Viewer.ContentPath, "TrackMonitorImages.png"));
            }

            metric = owner.Viewer.MilepostUnitsMetric;

            Font = owner.TextFontSmall;

            ScaleDesign(ref additionalInfoHeight);
            ScaleDesign(ref mainOffset);
            ScaleDesign(ref textSpacing);

            ScaleDesign(ref trackRail1Offset);
            ScaleDesign(ref trackRail2Offset);
            ScaleDesign(ref trackRailWidth);

            ScaleDesign(ref textOffset);

            ScaleDesign(ref distanceTextOffset);
            ScaleDesign(ref trackOffset);
            ScaleDesign(ref speedTextOffset);

            ScaleDesign(ref eyePosition);
            ScaleDesign(ref trainPosition);
            ScaleDesign(ref otherTrainPosition);
            ScaleDesign(ref stationPosition);
            ScaleDesign(ref reversalPosition);
            ScaleDesign(ref waitingPointPosition);
            ScaleDesign(ref endAuthorityPosition);
            ScaleDesign(ref signalPosition);
            ScaleDesign(ref arrowPosition);
        }
Exemplo n.º 5
0
 public override void Initialize(WindowManager windowManager)
 {
     base.Initialize(windowManager);
     Font = windowManager.TextFontDefault;
     Reflow();
 }
Exemplo n.º 6
0
 public override void Initialize(WindowManager windowManager)
 {
     base.Initialize(windowManager);
     Font = windowManager.TextFontMonoSpacedBold;
 }
Exemplo n.º 7
0
        public WindowManager(Viewer viewer)
        {
            Viewer = viewer;
            WindowManagerMaterial   = new BasicBlendedMaterial(viewer, "WindowManager");
            PopupWindowMaterial     = (PopupWindowMaterial)Viewer.MaterialManager.Load("PopupWindow");
            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, 1, TextureUsage.None, SurfaceFormat.Color);
                WhiteTexture.SetData(new[] { Color.White });
            }
            if (FlushTexture == null)
            {
                FlushTexture = new Texture2D(Viewer.GraphicsDevice, 1, 1, 1, TextureUsage.None, SurfaceFormat.Color);
                FlushTexture.SetData(new[] { Color.TransparentBlack });
            }
            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, 1, TextureUsage.None, SurfaceFormat.Color);
                NoticeTexture.SetData(data, 0, size * size, SetDataOptions.Discard);

                // 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, 1, TextureUsage.None, SurfaceFormat.Color);
                PauseTexture.SetData(data);
            }
        }