private void NewFileButton_Click(object sender, EventArgs e) { try { System.IO.File.Delete(Settings.Paths.Maps + "/New_map.xml"); } catch { } System.IO.File.Copy(Settings.Paths.EngineMaps + "/Default/New_map.xml", Settings.Paths.Maps + "/New_map.xml"); XmlDocument XML = new XmlDocument(); try { XML.Load(Settings.Paths.Maps + "/New_map.xml"); string Name = XML.DocumentElement.SelectSingleNode("Name").InnerText; MapNameTextBox.Text = Name; if ((Name != null) && !Maps.MapsList.ContainsKey(Name)) { Maps.MapsList.Add(Name, openFileDialog1.FileName); Maps.Free(); Maps.LoadMap(Name); } else { Maps.Free(); Maps.LoadMap(Name); } lightSettings.ListsRefresh(); } catch (Exception e1) { Log.WriteLineRed("Maps.LoadMapList() Exception."); Log.WriteLineRed("XmlFile: \"{0}\"", openFileDialog1.FileName); Log.WriteLineYellow("Maybe some XML file in Map directory is not a valid map."); Log.WriteLineYellow(e1.Message); } }
private void OpenFileButton_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; } XmlDocument XML = new XmlDocument(); try { XML.Load(openFileDialog1.FileName); string Name = XML.DocumentElement.SelectSingleNode("Name").InnerText; MapNameTextBox.Text = Name; if ((Name != null) && !Maps.MapsList.ContainsKey(Name)) { Maps.MapsList.Add(Name, openFileDialog1.FileName); Maps.Free(); Maps.LoadMap(Name); } else { Maps.Free(); Maps.LoadMap(Name); } lightSettings.ListsRefresh(); } catch (Exception e1) { Log.WriteLineRed("Maps.LoadMapList() Exception."); Log.WriteLineRed("XmlFile: \"{0}\"", openFileDialog1.FileName); Log.WriteLineYellow("Maybe some XML file in Map directory is not a valid map."); Log.WriteLineYellow(e1.Message); } //MessageBox.Show("Chosen file: " + openFileDialog1.FileName); }
private static void Main(string[] args) { Application.EnableVisualStyles(); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; //For fix parsing values like "0.5" and "0,5" Glfw.SetErrorCallback(OnError); if (!Glfw.Init()) { Log.WriteLineRed("ERROR: Could not initialize GLFW, shutting down."); Console.ReadKey(); Environment.Exit(1); } Engine.LoadConfig(); Engine.ApplyConfig(); while (Settings.Window.NeedReinitWindow) { ApplySettingsAndCreateWindow(); Engine.GetGLSettings(); Engine.LoadContentLists(); int FB_Width, FB_Height; Glfw.GetFramebufferSize(Window, out FB_Width, out FB_Height); FBO.Init(FB_Width, FB_Height); RescaleToWindowSize(); // This function call FBO.Init()!!! That's is needed! (mb GLFW bug...) Settings.Window.NeedReinitWindow = false; if (!ContextIsLoaded) { Engine.LoadEngineContent(); //Load Map if (args.Length > 0) { Maps.LoadMap(args[0]); } else { Maps.LoadMap("Materials_Test_Map"); //Sponza //SampleMap //Materials_Test_Map } ContextIsLoaded = true; } // On...DoSomething functions Glfw.SetCursorPosCallback(Window, OnMouseMove); Glfw.SetMouseButtonCallback(Window, OnMouseClick); Glfw.SetFramebufferSizeCallback(Window, OnFramebufferResize); Glfw.SetKeyCallback(Window, OnKeyPress); Glfw.SetWindowFocusCallback(Window, OnFocusChanged); Glfw.SetWindowPosCallback(Window, OnWindowPositionChange); Glfw.SetWindowSizeCallback(Window, OnWindowResize); #region Main Loop while (!(Glfw.WindowShouldClose(Window) || Settings.Window.NeedReinitWindow)) { OnUpdateFrame(); OnRenderFrame(); if (FPS.ShowFPS) { FPS.CalcFPS(); //FPS Counter, must be at the END of the Render LOOP! } Glfw.SwapBuffers(Window); // Swap the front and back buffer, displaying the scene Glfw.PollEvents(); // Poll GLFW window events } #endregion } Maps.Free(true); // Free all: Map -> Meshes, Shaders, Textures... FBO.Free(); FPS.Font_Free(); Engine.ClearLists(); try { Game.EditorMainForm.Close(); // Editor } catch { } Glfw.DestroyWindow(Window); Glfw.Terminate(); if (Settings.Debug.Enabled) { //Console.ReadKey(); string log = Log.GetLog(); if (log.Length > 256) { System.Windows.Forms.Clipboard.SetText(log); } } }