Ejemplo n.º 1
0
        private void LoadDemo()
        {
            AssetManager   asman = AssetManager.GetSingleton();
            TunableManager tm    = TunableManager.GetSingleton();

            tm.ReloadValues();
            try
            {
                demoWrapper.Demo.Load(asman, syncSystem);
            }
            catch (Exception exception)
            {
                Logger.LogError(Logger.ErrorState.Critical, "Caught exception when creating Demo instance " + exception.Message);
                return;
            }
            loadCompleted = true;
        }
Ejemplo n.º 2
0
        protected override void OnLoad(EventArgs e)
        {
            PauseSyncButton = new Button(Key.Space);
            PrevSceneButton = new Button(Key.F3);
            NextSceneButton = new Button(Key.F4);

            ReloadDemoButton = new Button(Key.F5);
            RestartDemoOrRetreatSceneButton = new Button(Key.F6);
            AdvanceSceneButton = new Button(Key.F7);
            InputEnabledButton = new Button(Key.F8);

            CameraModeButton      = new Button(Key.F9);
            CameraSpeedDownButton = new Button(Key.F10);
            CameraSpeedUpButton   = new Button(Key.F11);
            PrintFrameButton      = new Button(Key.F12);

            tunableManager = TunableManager.GetSingleton();
            syncSystem     = SyncSystem.GetSingleton();
            renderer       = Renderer.GetSingleton();

            string dataFolder = "data";

            AssetManager.WorkingDir = dataFolder;
            AssetManager assetManager = AssetManager.GetSingleton();

            Logger.LogPhase("Asset manager is created");
            assetManager.LoadAll();
            assetManager.printLoadedAssets();
            Logger.LogPhase("Assets have been loaded");

            tunableManager.ReloadValues();
            Logger.LogPhase("Config file have been loaded");

            demoWrapper = new DemoWrapper();
            demoWrapper.Create();
            demoSettings = demoWrapper.Demo.GetDemoSettings();

            // Audio ....................................

            Logger.LogPhase("Initializing audio system");

            if (demoSettings.AudioEngineSetting == DemoSettings.AudioEngine.System)
            {
                audioSystem = new SystemAudio();
            }
            if (demoSettings.AudioEngineSetting == DemoSettings.AudioEngine.Dummy)
            {
                if (demoSettings.AudioEnabled == true)
                {
                    Logger.LogError(Logger.ErrorState.User, "Initialized dummy audio when Audio is enabled.");
                }
                audioSystem = new DummyAudioSystem();
            }
            bool audioInitOk = audioSystem.Initialize();

            if (!audioInitOk)
            {
                Logger.LogError(Logger.ErrorState.Critical, "Audio system failed to initialize.");
                return;
            }
            Logger.LogPhase("Audio has been initialized");
            demoWrapper.SetAudioSystem(audioSystem);


            // Sync.............................

            if (demoSettings.SyncEnabled)
            {
                syncSystem.Start(demoSettings.SyncFilePrefix);
            }
            else
            {
                syncSystem.StartManual();
            }

            // Rendering .................
            Size windowSize = new Size((int)demoSettings.Resolution.X, (int)demoSettings.Resolution.Y);

            base.Size = windowSize;
            if (demoSettings.Fullscreen)
            {
                base.WindowState = WindowState.Fullscreen;
            }
            renderer.ResizeScreen((int)demoSettings.Resolution.X, (int)demoSettings.Resolution.Y);


            CursorVisible = false;
            testScene     = new TestScene();
            testScene.Load(assetManager);

            loadingScene = new LoadingScene();
            loadingScene.Load(assetManager);

            applicationTime = new Stopwatch();

            LoadDemo();
            Logger.LogPhase("OnLoad complete");
            loadCompleted = true;
            running       = true;
            applicationTime.Start();
        }