Exemplo n.º 1
0
        protected override void Load()
        {
            Thread.CurrentThread.Name = "FreelancerGame UIThread";
            //Move to stop _TSGetMainThread error on OSX
            MinimumWindowSize = new Point(640, 480);
            SetVSync(Config.Settings.VSync);
            Config.Settings.RenderContext = RenderContext;
            new IdentityCamera(this);
            uithread       = Thread.CurrentThread.ManagedThreadId;
            useintromovies = _cfg.IntroMovies;
            FLLog.Info("Platform", Platform.RunningOS.ToString() + (IntPtr.Size == 4 ? " 32-bit" : " 64-bit"));
            FLLog.Info("Available Threads", Environment.ProcessorCount.ToString());
            //Cache
            ResourceManager = new GameResourceManager(this);
            //Init Audio
            FLLog.Info("Audio", "Initialising Audio");
            Audio = new AudioManager(this);
            Audio.WaitReady();
            Audio.MasterVolume = _cfg.Settings.MasterVolume;
            Audio.Music.Volume = _cfg.Settings.MusicVolume;
            //Load data
            FLLog.Info("Game", "Loading game data");
            GameData    = new GameDataManager(_cfg.FreelancerPath, ResourceManager);
            IntroMovies = GameData.GetIntroMovies();
            MpvOverride = _cfg.MpvOverride;
            Saves       = new SaveGameFolder();
            var    saveLoadTask         = Task.Run(() => Saves.Load(GetSaveFolder()));
            Thread GameDataLoaderThread = new Thread(() =>
            {
                GameData.LoadData(this, () =>
                {
                    Sound = new SoundManager(GameData, Audio, this);
                    Services.Add(Sound);
                    InisLoaded = true;
                });
                FLLog.Info("Game", "Finished loading game data");
                saveLoadTask.Wait();
                Saves.Infocards     = GameData.Ini.Infocards;
                InitialLoadComplete = true;
            });

            GameDataLoaderThread.Name = "GamedataLoader";
            GameDataLoaderThread.Start();
            //
            Fonts      = new FontManager();
            Billboards = new Billboards();
            Nebulae    = new NebulaVertices();
            RenderContext.PushViewport(0, 0, Width, Height);
            Screenshots = new ScreenshotManager(this);
            Typewriter  = new Typewriter(this);

            Services.Add(Billboards);
            Services.Add(Nebulae);
            Services.Add(ResourceManager);
            Services.Add(Config);
            Services.Add(Fonts);
            Services.Add(GameData);
            Services.Add(Sound);
            Services.Add(Typewriter);
            Debug = new DebugView(this);
            if (useintromovies && IntroMovies.Count > 0)
            {
                ChangeState(new IntroMovie(this, 0));
            }
            else
            {
                ChangeState(new LoadingDataState(this));
            }
        }