idTech4.idSystem.Initialize C# (CSharp) Method

Initialize() protected method

protected Initialize ( ) : void
return void
		protected override void Initialize()
		{
			// TODO
			//try
			{
				InitConsole();

				// clear warning buffer
				idConsole.ClearWarnings(string.Format("{0} initialization", idE.GameName));

				ParseCommandLine(_rawCommandLineArguments);

				idE.CmdSystem.Init();
				idE.CvarSystem.Init();

				// start file logging right away, before early console or whatever
				StartupVariable("win_outputDebugString", false);

				// register all static CVars
				idE.CvarSystem.RegisterStatics();

				// print engine version
				idConsole.WriteLine(idE.Version);

				// initialize key input/binding, done early so bind command exists
				idE.Input.Init();

				// init the console so we can take prints
				idE.Console.Init();

				// get architecture info
				Sys_Init();

				// initialize networking
				// TODO: Sys_InitNetworking();

				// override cvars from command line
				StartupVariable(null, false);

				// initialize processor specific SIMD implementation
				// TODO: InitSIMD();

				// init commands
				InitCommands();

				idE.FileSystem.Init();
				idE.DeclManager.Init();

				bool sysDetect = idE.FileSystem.FileExists(idE.ConfigSpecification, "fs_savepath") == false;

				if(sysDetect == true)
				{
					Stream s = idE.FileSystem.OpenFileWrite(idE.ConfigSpecification);

					if(s != null)
					{
						s.Dispose();
						s = null;
					}
				}

				if(sysDetect == true)
				{
					SetMachineSpec();
					Cmd_ExecMachineSpec(this, new CommandEventArgs(new idCmdArgs()));
				}

				// exec the startup scripts
				idE.CmdSystem.BufferCommandText(Execute.Append, "exec editor.cfg");
				idE.CmdSystem.BufferCommandText(Execute.Append, "exec default.cfg");

				// skip the config file if "safe" is on the command line
				/* TODO: if ( !SafeMode() ) {*/
				idE.CmdSystem.BufferCommandText(Execute.Append, string.Format("exec {0}", idE.ConfigFile));
				/*}*/

				idE.CmdSystem.BufferCommandText(Execute.Append, "exec autoexec.cfg");

				// reload the language dictionary now that we've loaded config files
				idE.CmdSystem.BufferCommandText(Execute.Append, "reloadLanguage");

				// run cfg execution
				idE.CmdSystem.ExecuteCommandBuffer();

				// re-override anything from the config files with command line args
				StartupVariable(null, false);

				// initialize the renderSystem data structures
				idE.RenderSystem.Init();
				
				// initialize string database right off so we can use it for loading messages
				InitLanguageDict();

				PrintLoadingMessage(idE.Language.Get("#str_04344"));

				// load the font, etc
				idE.Console.LoadGraphics();

				// init journalling, etc
				idE.EventLoop.Init();

				PrintLoadingMessage(idE.Language.Get("#str_04345"));

				// if any archived cvars are modified after this, we will trigger a writing of the config file
				idE.CvarSystem.ModifiedFlags |= CvarFlags.Archive;

				// init the user command input code
				idE.UserCommandGenerator.Init();

				PrintLoadingMessage(idE.Language.Get("#str_04346"));

				// start the sound system, but don't do any hardware operations yet
				idE.SoundSystem.Init();

				PrintLoadingMessage(idE.Language.Get("#str_04347"));

				// init async network
				idE.AsyncNetwork.Init();

				if(idE.CvarSystem.GetInteger("net_serverDedicated") == 1)
				{
					throw new NotImplementedException("we don't do dedicated");

					/*idAsyncNetwork::server.InitPort();*/
					idE.CvarSystem.SetBool("s_noSound", true);
				}
				else
				{
					// init OpenGL, which will open a window and connect sound and input hardware
					PrintLoadingMessage(idE.Language.Get("#str_04348"));
					InitRenderSystem();
				}

				base.Initialize();
			}
			/*catch(Exception x)
			{
				Error("Error during initialization");

				idConsole.WriteLine(x.ToString());
			}*/
		}