示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            //ddraw = new WindowedDirectDraw(this);
            //drawer = new QuarterViewDrawer( World.world, ddraw,
            //	new Rectangle( this.scrollPos, ClientSize ) );
            //drawer.OnUpdated += new EventHandler(onDrawerUpdated);

            weatherOverlay = NullWeatherOverlay.theInstance;
            // TODO
            // TEST: TODO
            //			weatherOverlay = new WeatherOverlayImpl( new WeatherOverlaySpriteSet(
            //				"{9B411B87-07F4-451b-93D0-2922EE62461B}",8,new Size(64,128)));
        }
示例#2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="disposing"></param>
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             if (this.weatherOverlay != null)
             {
                 this.weatherOverlay.Dispose();
                 this.weatherOverlay = null;
             }
         }
         this.disposed = true;
     }
 }
示例#3
0
        private void Go()
        {
            splashscreen = new Splash();
            splashscreen.Show();
            splashscreen.BringToFront();
            splashscreen.Refresh();
            Core.Init(null, null, null, new ProgressHandler(UpdateMessage), true);
            world = new WorldDefinition(new Distance(150, 150, 7), 3);
            WorldDefinition.World = world;
            mainWindowMDI         = new MainWindow();
            timer = new System.Windows.Forms.Timer();
            Events.KeyboardDown    += new EventHandler <KeyboardEventArgs>(this.KeyDown);
            Events.MouseButtonDown +=
                new EventHandler <MouseButtonEventArgs>(this.MouseButtonDown);
            Events.MouseButtonUp +=
                new EventHandler <MouseButtonEventArgs>(this.MouseButtonUp);
            Events.Quit          += new EventHandler <QuitEventArgs>(this.Quit);
            Events.Tick          += new EventHandler <TickEventArgs>(this.Tick);
            Events.VideoResize   += new EventHandler <SdlDotNet.Graphics.VideoResizeEventArgs>(this.Resize);
            Events.MusicFinished +=
                new EventHandler <MusicFinishedEventArgs>(this.MusicFinished);
            Events.MouseMotion     += new EventHandler <MouseMotionEventArgs>(this.MouseMotion);
            dragStartMousePosition  = new Point(0, 0);
            dragStartScrollPosition = new Point(0, 0);
            ScrollPosition          = new Point(0, 0);
            this.width  = Properties.Settings.Default.RenderWindowWidth;
            this.height = Properties.Settings.Default.RenderWindowHeight;

            try
            {
                SdlDotNet.Graphics.Video.WindowIcon();
                SdlDotNet.Graphics.Video.WindowCaption = Translation.GetString("MAIN_WINDOW_TITLE");
                SdlDotNet.Graphics.Video.Initialize();
                splashscreen.BringToFront();
            }
            catch
            {
                MessageBox.Show(Translation.GetString("SDL_NOT_FOUND"));
                return;
            }

            Mixer.Initialize();

            SdlMixer.MusicFinishedDelegate musicStopped = new SdlMixer.MusicFinishedDelegate(MusicHasStopped);
            SdlMixer.Mix_HookMusicFinished(musicStopped);


            screen = SdlDotNet.Graphics.Video.SetVideoMode(width, height, currentBpp, true);
            screen.SourceColorKey = Color.Magenta;
            IntPtr videoInfoPointer = Sdl.SDL_GetVideoInfo();

            if (videoInfoPointer != IntPtr.Zero)
            {
                videoInfo   = (Sdl.SDL_VideoInfo)Marshal.PtrToStructure(videoInfoPointer, typeof(Sdl.SDL_VideoInfo));
                pixelFormat = (Sdl.SDL_PixelFormat)Marshal.PtrToStructure(videoInfo.vfmt, typeof(Sdl.SDL_PixelFormat));
            }
            splashscreen.status.AppendText("FreeTrain SDL Starting...");
            splashscreen.status.AppendText("\n");
            splashscreen.Refresh();

            FinalDraw();

            splashscreen.status.AppendText("Loading plugins...");
            splashscreen.status.AppendText("\n");
            splashscreen.Refresh();
            FinalDraw();


            weatherOverlay = NullWeatherOverlay.theInstance;
            FinalDraw();
            qView = new QuarterViewDrawer(world, new Rectangle(0, 0, world.Size.x * 32 - 16, (world.Size.y - 2 * world.Size.z - 1) * 8));
            qView.OffscreenBuffer = new Surface(world.Size.x * 32 - 16, (world.Size.y - 2 * world.Size.z - 1) * 8, screen.CreateCompatibleSurface().Pixels);
            qView.OffscreenBuffer.SourceColorKey = Color.Magenta;
            qView.RecreateDrawBuffer(new Size(width, height), true);
            splashscreen.status.AppendText("Creating Map...");
            splashscreen.status.AppendText("\n");
            splashscreen.Refresh();
            FinalDraw();

            qView.Draw(new Rectangle(0, 0, world.Size.x * 32 - 16, (world.Size.y - 2 * world.Size.z - 1) * 8), null);
            timer.Tick    += new EventHandler(TimerTick);
            timer.Interval = 33;
            timer.Enabled  = true;
            timer.Start();

            mainWindowMDI.Show();
            splashscreen.BringToFront();
            splashscreen.Close();

            Events.Run();
        }