Example #1
0
        ORTSActSoundSources ORTSActSoundSourceList; // Dictionary of activity sound sources

        public SoundProcess(Game game)
        {
            Game                   = game;
            Thread                 = new Thread(SoundThread);
            WatchdogToken          = new WatchdogToken(Thread);
            ORTSActSoundSourceList = new ORTSActSoundSources();
        }
Example #2
0
 public LoaderProcess(Game game)
 {
     Game          = game;
     Thread        = new Thread(LoaderThread);
     WatchdogToken = new WatchdogToken(Thread);
     WatchdogToken.SpecialDispensationFactor = 6;
     CancellationTokenSource = new Orts.Common.Threading.CancellationTokenSource(WatchdogToken.Ping);
 }
Example #3
0
        public static float[] ShadowMapLimit;  // diameter of shadow map far edge from camera

        internal RenderProcess(Game game)
        {
            this.game = game;
            gameForm  = (Form)Control.FromHandle(game.Window.Handle);

            watchdogToken = new WatchdogToken(System.Threading.Thread.CurrentThread);

            Profiler = new Profiler("Render");
            Profiler.SetThread();
            game.SetThreadLanguage();

            game.Window.Title     = "Open Rails";
            GraphicsDeviceManager = new GraphicsDeviceManager(game);

            var windowSizeParts = game.Settings.WindowSize.Split(new[] { 'x' }, 2);

            gameWindowSize = new System.Drawing.Size(Convert.ToInt32(windowSizeParts[0]), Convert.ToInt32(windowSizeParts[1]));

            FrameRate         = new SmoothedData();
            FrameTime         = new SmoothedDataWithPercentiles();
            PrimitiveCount    = new int[(int)RenderPrimitiveSequence.Sentinel];
            PrimitivePerFrame = new int[(int)RenderPrimitiveSequence.Sentinel];

            // Run the game initially at 10FPS fixed-time-step. Do not change this! It affects the loading performance.
            game.IsFixedTimeStep   = true;
            game.TargetElapsedTime = TimeSpan.FromMilliseconds(100);
            game.InactiveSleepTime = TimeSpan.FromMilliseconds(100);

            // Set up the rest of the graphics according to the settings.
            GraphicsDeviceManager.SynchronizeWithVerticalRetrace = game.Settings.VerticalSync;
            GraphicsDeviceManager.PreferredBackBufferFormat      = SurfaceFormat.Color;
            GraphicsDeviceManager.PreferredDepthStencilFormat    = DepthFormat.Depth24Stencil8;
            GraphicsDeviceManager.IsFullScreen             = true;
            GraphicsDeviceManager.PreferMultiSampling      = game.Settings.MultisamplingCount > 0;
            GraphicsDeviceManager.PreparingDeviceSettings += new EventHandler <PreparingDeviceSettingsEventArgs>(GDM_PreparingDeviceSettings);

            currentScreen    = Screen.PrimaryScreen;
            gameWindowOrigin = new System.Drawing.Point((currentScreen.WorkingArea.Right - gameWindowSize.Width) / 2, (currentScreen.WorkingArea.Bottom - gameWindowSize.Height) / 2);
            System.Drawing.Point tempGameWindowOrigin = gameWindowOrigin;
            SynchronizeGraphicsDeviceManager(game.Settings.FullScreen ?
                                             game.Settings.NativeFullscreenResolution ? ScreenMode.FullscreenNativeResolution : ScreenMode.FullscreenPresetResolution
                : ScreenMode.WindowedPresetResolution);

            //restore gameWindowOrigin which will be overriden when game started in Fullscreen ()
            gameWindowOrigin = tempGameWindowOrigin;

            RenderPrimitive.SetGraphicsDevice(game.GraphicsDevice);

            UserInput.Initialize(game);
            gameForm.LocationChanged += GameForm_LocationChanged;
        }
Example #4
0
 /// <summary>
 /// Unregisters a thread token from monitoring by the watchdog.
 /// </summary>
 /// <param name="token">The token representing the thread to stop monitoring.</param>
 public void Unregister(WatchdogToken token)
 {
     // We must do this elaborate routine because:
     //   a) We cannot modify Tokens in-place (due to potentially being read from other threads at the same time)
     //   b) We cannot just assign directly (due to potentially being written from other threads at the same time)
     while (true)
     {
         var tokens    = Tokens;
         var newTokens = new List <WatchdogToken>(tokens);
         newTokens.Remove(token);
         if (tokens == Interlocked.CompareExchange(ref Tokens, newTokens, tokens))
         {
             break;
         }
     }
 }
Example #5
0
 public UpdaterProcess(Game game)
 {
     Game          = game;
     Thread        = new Thread(UpdaterThread);
     WatchdogToken = new WatchdogToken(Thread);
 }
Example #6
0
 public UpdaterProcess(Game game)
 {
     this.game     = game;
     thread        = new Thread(UpdaterThread);
     watchdogToken = new WatchdogToken(thread);
 }