private void MainForm_Load(object sender, EventArgs e) { //NeoAxis initialization if (!WinFormsAppWorld.Init(new ExampleEngineApp(EngineApp.ApplicationTypes.Simulation), this, "user:Logs/WinFormsAppExample.log", true, null, null, null, null)) { Close(); return; } UpdateVolume(); renderTargetUserControl1.AutomaticUpdateFPS = 60; renderTargetUserControl1.KeyDown += renderTargetUserControl1_KeyDown; renderTargetUserControl1.KeyUp += renderTargetUserControl1_KeyUp; renderTargetUserControl1.MouseDown += renderTargetUserControl1_MouseDown; renderTargetUserControl1.MouseUp += renderTargetUserControl1_MouseUp; renderTargetUserControl1.MouseMove += renderTargetUserControl1_MouseMove; renderTargetUserControl1.Tick += renderTargetUserControl1_Tick; renderTargetUserControl1.Render += renderTargetUserControl1_Render; renderTargetUserControl1.RenderUI += renderTargetUserControl1_RenderUI; const string startMapName = "Maps\\MainMenu\\Map.map"; //generate map list { string[] mapList = VirtualDirectory.GetFiles("", "*.map", SearchOption.AllDirectories); foreach (string mapName in mapList) { comboBoxMaps.Items.Add(mapName); if (mapName == startMapName) { comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1; } } } //load map WinFormsAppWorld.MapLoad(startMapName, true); //set camera position if (Map.Instance != null) { MapCamera mapCamera = FindFirstMapCamera(); if (mapCamera != null) { freeCameraPosition = mapCamera.Position; freeCameraDirection = SphereDir.FromVector(mapCamera.Rotation.GetForward()); } else { freeCameraPosition = Map.Instance.EditorCameraPosition; freeCameraDirection = Map.Instance.EditorCameraDirection; } } }
private void MainForm_Load(object sender, EventArgs e) { //NeoAxis initialization if (!WinFormsAppWorld.Init(this, "user:Logs/WinFormsAppExample.log")) { Close(); return; } UpdateVolume(); //load map WinFormsAppWorld.MapLoad("Maps\\WindowsAppExample\\Map.map", true); renderTargetUserControl1.AutomaticUpdateFPS = 60; renderTargetUserControl1.Render += renderTargetUserControl1_Render; renderTargetUserControl1.RenderUI += renderTargetUserControl1_RenderUI; }
private void MainForm_Load(object sender, EventArgs e) { //NeoAxis initialization EngineApp.ConfigName = "user:Configs/DedicatedServer.config"; EngineApp.ReplaceRenderingSystemComponentName = "RenderingSystem_NULL"; EngineApp.ReplaceSoundSystemComponentName = "SoundSystem_NULL"; if (!WinFormsAppWorld.Init(new WinFormsAppEngineApp(EngineApp.ApplicationTypes.Simulation), this, "user:Logs/DedicatedServer.log", true, null, null, null, null)) { Close(); return; } WinFormsAppEngineApp.Instance.AutomaticTicks = false; Engine.Log.Handlers.InfoHandler += delegate(string text, ref bool dumpToLogFile) { Log("Log: " + text); }; Engine.Log.Handlers.ErrorHandler += delegate(string text, ref bool handled, ref bool dumpToLogFile) { handled = true; timer1.Stop(); MessageBox.Show(text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); timer1.Start(); }; Engine.Log.Handlers.FatalHandler += delegate(string text, string createdLogFilePath, ref bool handled) { handled = true; timer1.Stop(); MessageBox.Show(text, "Fatal", MessageBoxButtons.OK, MessageBoxIcon.Warning); }; //register config fields of this class EngineApp.Instance.Config.RegisterClassParameters(GetType()); //generate map list { string[] mapList = VirtualDirectory.GetFiles("", "*.map", SearchOption.AllDirectories); foreach (string mapName in mapList) { //check for network support if (VirtualFile.Exists(string.Format("{0}\\NoNetworkSupport.txt", Path.GetDirectoryName(mapName)))) { continue; } comboBoxMaps.Items.Add(mapName); if (mapName == lastMapName) { comboBoxMaps.SelectedIndex = comboBoxMaps.Items.Count - 1; } } comboBoxMaps.SelectedIndexChanged += comboBoxMaps_SelectedIndexChanged; } checkBoxLoadMapAtStartup.Checked = loadMapAtStartup; checkBoxAllowCustomClientCommands.Checked = allowCustomClientCommands; //load map at startup if (loadMapAtStartup && comboBoxMaps.SelectedItem != null) { Create(); string mapName = comboBoxMaps.SelectedItem as string; if (!MapLoad(mapName)) { return; } } }