コード例 #1
0
ファイル: SwitchWindow.cs プロジェクト: pzgulyas/openrails-1
 protected internal override void Initialize()
 {
     base.Initialize();
     if (SwitchStates == null)
     {
         // TODO: This should happen on the loader thread.
         SwitchStates = SharedTextureManager.Get(Owner.Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Owner.Viewer.ContentPath, "SwitchStates.png"));
     }
 }
コード例 #2
0
 protected internal override void Initialize()
 {
     base.Initialize();
     if (CouplerTexture == null)
     {
         // TODO: This should happen on the loader thread.
         CouplerTexture = SharedTextureManager.Get(Owner.Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Owner.Viewer.ContentPath, "TrainOperationsCoupler.png"));
     }
 }
コード例 #3
0
ファイル: Shaders.cs プロジェクト: wacampbell/openrails
 public PopupWindowShader(Viewer viewer, GraphicsDevice graphicsDevice)
     : base(graphicsDevice, "PopupWindow")
 {
     world = Parameters["World"];
     worldViewProjection = Parameters["WorldViewProjection"];
     glassColor          = Parameters["GlassColor"];
     screenSize          = Parameters["ScreenSize"];
     screenTexture       = Parameters["ScreenTexture"];
     // TODO: This should happen on the loader thread.
     Parameters["WindowTexture"].SetValue(SharedTextureManager.Get(graphicsDevice, System.IO.Path.Combine(viewer.ContentPath, "Window.png")));
 }
コード例 #4
0
 public PrecipitationMaterial(Viewer viewer)
     : base(viewer, null)
 {
     // TODO: This should happen on the loader thread.
     RainTexture = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "Raindrop.png"));
     SnowTexture = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "Snowflake.png"));
     DynamicPrecipitationTexture[0]  = SnowTexture;
     DynamicPrecipitationTexture[11] = RainTexture;
     for (int i = 1; i <= 10; i++)
     {
         var path = "Raindrop" + i.ToString() + ".png";
         DynamicPrecipitationTexture[11 - i] = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, path));
     }
 }
コード例 #5
0
        public Texture2D LoadTexture(string name)
        {
            string path;

            if (MipMapScale == 2)
            {
                path = System.IO.Path.Combine(Viewer.ContentPath, "ETCS", "mipmap-2", name);
            }
            else
            {
                path = System.IO.Path.Combine(Viewer.ContentPath, "ETCS", name);
            }
            return(SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, path));
        }
コード例 #6
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);
        }
コード例 #7
0
ファイル: Sky.cs プロジェクト: strawberryfield/openrails
        public SkyMaterial(Viewer viewer)
            : base(viewer, null)
        {
            SkyShader = Viewer.MaterialManager.SkyShader;
            // TODO: This should happen on the loader thread.
            SkyTexture   = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "SkyDome1.png"));
            StarTextureN = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "Starmap_N.png"));
            StarTextureS = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "Starmap_S.png"));
            MoonTexture  = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "MoonMap.png"));
            MoonMask     = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "MoonMask.png"));
            CloudTexture = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "Clouds01.png"));

            ShaderPassesSky    = SkyShader.Techniques["Sky"].Passes.GetEnumerator();
            ShaderPassesMoon   = SkyShader.Techniques["Moon"].Passes.GetEnumerator();
            ShaderPassesClouds = SkyShader.Techniques["Clouds"].Passes.GetEnumerator();

            SkyShader.SkyMapTexture   = SkyTexture;
            SkyShader.StarMapTexture  = StarTextureN;
            SkyShader.MoonMapTexture  = MoonTexture;
            SkyShader.MoonMaskTexture = MoonMask;
            SkyShader.CloudMapTexture = CloudTexture;
        }
コード例 #8
0
ファイル: BasicShapes.cs プロジェクト: pzgulyas/openrails-1
        private static void LoadAndHighlightTexture(GraphicsDevice graphicsDevice, string contentPath, string textureName, string fileName, int offsetX, int offsetY)
        {
            string    fullFileName = System.IO.Path.Combine(contentPath, fileName + ".png");
            Texture2D tempTexture;

            try
            {
                tempTexture = SharedTextureManager.Get(graphicsDevice, fullFileName);
            }
            catch
            {
                tempTexture = textures["disc"];
            }
            textures[textureName]       = ColorScaledTexture(tempTexture, graphicsDevice, 0); // No scaling, but it is adding automipmap
            textureScales[textureName]  = textures[textureName].Width;
            textureOffsets[textureName] = new Vector2(offsetX, offsetY);

            string textureNameHighlight = textureName + "Highlight";

            textures[textureNameHighlight]       = ColorScaledTexture(tempTexture, graphicsDevice, 80);
            textureScales[textureNameHighlight]  = textures[textureNameHighlight].Width;
            textureOffsets[textureNameHighlight] = textureOffsets[textureName];
        }
コード例 #9
0
        public MSTSSkyMaterial(Viewer viewer)
            : base(viewer, null)
        {
            MSTSSkyShader = Viewer.MaterialManager.SkyShader;

            //// TODO: This should happen on the loader thread.
            if (viewer.ENVFile.SkyLayers != null)
            {
                var mstsskytexture = Viewer.ENVFile.SkyLayers.ToArray();
                int count          = Viewer.ENVFile.SkyLayers.Count;


                string[] mstsSkyTexture = new string[Viewer.ENVFile.SkyLayers.Count];

                for (int i = 0; i < Viewer.ENVFile.SkyLayers.Count; i++)
                {
                    mstsSkyTexture[i] = Viewer.Simulator.RoutePath + @"\envfiles\textures\" + mstsskytexture[i].TextureName.ToString();
                    MSTSSkyTexture.Add(Orts.Formats.Msts.AceFile.Texture2DFromFile(Viewer.RenderProcess.GraphicsDevice, mstsSkyTexture[i]));
                    if (i == 0)
                    {
                        MSTSDayTexture  = MSTSSkyTexture[i];
                        mstsskytexturex = mstsskytexture[i].TileX;
                        mstsskytexturey = mstsskytexture[i].TileY;
                    }
                    else if (mstsskytexture[i].Fadein_Begin_Time != null)
                    {
                        MSTSSkyStarTexture = MSTSSkyTexture[i];
                        mstsskytexturex    = mstsskytexture[i].TileX;
                        mstsskytexturey    = mstsskytexture[i].TileY;
                    }
                    else
                    {
                        MSTSSkyCloudTexture.Add(Orts.Formats.Msts.AceFile.Texture2DFromFile(Viewer.RenderProcess.GraphicsDevice, mstsSkyTexture[i]));
                        mstscloudtexturex = mstsskytexture[i].TileX;
                        mstscloudtexturey = mstsskytexture[i].TileY;
                    }
                }

                MSTSSkyConstants.mstsskyTileu   = mstsskytexturex;
                MSTSSkyConstants.mstsskyTilev   = mstsskytexturey;
                MSTSSkyConstants.mstscloudTileu = mstscloudtexturex;
                MSTSSkyConstants.mstscloudTilev = mstscloudtexturey;
            }
            else
            {
                MSTSSkyTexture.Add(SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "SkyDome1.png")));
                MSTSSkyStarTexture = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "Starmap_N.png"));
            }
            if (viewer.ENVFile.SkySatellite != null)
            {
                var mstsskysatellitetexture = Viewer.ENVFile.SkySatellite.ToArray();

                string mstsSkySunTexture  = Viewer.Simulator.RoutePath + @"\envfiles\textures\" + mstsskysatellitetexture[0].TextureName.ToString();
                string mstsSkyMoonTexture = Viewer.Simulator.RoutePath + @"\envfiles\textures\" + mstsskysatellitetexture[1].TextureName.ToString();

                MSTSSkySunTexture  = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, mstsSkySunTexture);
                MSTSSkyMoonTexture = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, mstsSkyMoonTexture);
            }
            else
            {
                MSTSSkyMoonTexture = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "MoonMap.png"));
            }

            MSTSSkyMoonMask = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "MoonMask.png")); //ToDo:  No MSTS equivalent - will need to be fixed in MSTSSky.cs
            //MSTSSkyCloudTexture[0] = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "Clouds01.png"));

            ShaderPassesSky  = MSTSSkyShader.Techniques["Sky"].Passes.GetEnumerator();
            ShaderPassesMoon = MSTSSkyShader.Techniques["Moon"].Passes.GetEnumerator();


            for (int i = 0; i < Viewer.ENVFile.SkyLayers.Count - 2; i++)
            {
                ShaderPassesClouds.Add(MSTSSkyShader.Techniques["Clouds"].Passes.GetEnumerator());
            }

            MSTSSkyShader.SkyMapTexture   = MSTSDayTexture;
            MSTSSkyShader.StarMapTexture  = MSTSSkyStarTexture;
            MSTSSkyShader.MoonMapTexture  = MSTSSkyMoonTexture;
            MSTSSkyShader.MoonMaskTexture = MSTSSkyMoonMask;
            MSTSSkyShader.CloudMapTexture = MSTSSkyCloudTexture[0];
        }
コード例 #10
0
ファイル: Signals.cs プロジェクト: pzgulyas/openrails-1
 public SignalLightGlowMaterial(Viewer viewer)
     : base(viewer, null)
 {
     SceneryShader = Viewer.MaterialManager.SceneryShader;
     Texture       = SharedTextureManager.Get(Viewer.GraphicsDevice, Path.Combine(Viewer.ContentPath, "SignalLightGlow.png"));
 }
コード例 #11
0
 public LightGlowMaterial(Viewer viewer)
     : base(viewer, null)
 {
     // TODO: This should happen on the loader thread.
     LightGlowTexture = SharedTextureManager.Get(Viewer.RenderProcess.GraphicsDevice, System.IO.Path.Combine(Viewer.ContentPath, "Lightglow.png"));
 }
コード例 #12
0
        public WindowManager(Viewer viewer)
        {
            Viewer = viewer ?? throw new ArgumentNullException(nameof(viewer));

            WindowManagerMaterial      = new BasicBlendedMaterial(viewer, "WindowManager");
            PopupWindowMaterial        = (PopupWindowMaterial)Viewer.MaterialManager.Load("PopupWindow");
            TextManager                = new WindowTextManager();
            TextFontDefault            = TextManager.GetScaled("Arial", 10, System.Drawing.FontStyle.Regular);
            TextFontDefaultBold        = TextManager.GetScaled("Arial", 10, System.Drawing.FontStyle.Bold);
            TextFontDefaultOutlined    = TextManager.GetScaled("Arial", 10, System.Drawing.FontStyle.Regular, 1);
            TextFontMonoSpacedBold     = TextManager.GetScaled("Consolas", 11.29f, System.Drawing.FontStyle.Bold);
            TextFontMonoSpacedOutlined = TextManager.GetScaled("Consolas", 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.RenderProcess.GraphicsDevice);

            if (WhiteTexture == null)
            {
                WhiteTexture = new Texture2D(Viewer.RenderProcess.GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
                WhiteTexture.SetData(new[] { Color.White });
            }
            if (FlushTexture == null)
            {
                FlushTexture = new Texture2D(Viewer.RenderProcess.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   = 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.RenderProcess.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.RenderProcess.GraphicsDevice, size, size * 2, false, SurfaceFormat.Color);
                PauseTexture.SetData(data);
            }

            viewer.UserCommandController.AddEvent(CommonUserCommand.PointerPressed, MouseClickedEvent);
            viewer.UserCommandController.AddEvent(CommonUserCommand.PointerDown, MouseDownEvent);
            viewer.UserCommandController.AddEvent(CommonUserCommand.PointerReleased, MouseReleasedEvent);
            viewer.UserCommandController.AddEvent(CommonUserCommand.PointerDragged, MouseDraggingEvent);
            viewer.UserCommandController.AddEvent(CommonUserCommand.VerticalScrollChanged, WindowScrollEvent);
        }
コード例 #13
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);
            }
        }
コード例 #14
0
 protected virtual Texture2D GetTexture(Game game)
 {
     return(SharedTextureManager.Get(game.RenderProcess.GraphicsDevice, Path.Combine(game.ContentPath, "Loading.png")));
 }