public static void Main(string[] args) { string datadir = null; string[] openFiles = null; if (args.Length > 0) { if (!GameConfig.CheckFLDirectory(args[0])) { Console.Error.WriteLine("Error: {0} is not a valid data directory", args[0]); return; } datadir = args[0]; openFiles = args.Skip(1).ToArray(); } MainWindow mw = null; AppHandler.Run(() => { mw = new MainWindow(); mw.PreloadOpen = openFiles; mw.PreloadDataDir = datadir; mw.Run(); }, () => mw.Crashed()); }
public static bool Create(MainWindow mw, out ProjectileViewer viewer) { viewer = null; string folder; if ((folder = FileDialog.ChooseFolder()) != null) { if (!GameConfig.CheckFLDirectory(folder)) { return(false); } viewer = new ProjectileViewer(mw, folder); return(true); } return(false); }
protected override void Draw(double elapsed) { VertexBuffer.TotalDrawcalls = 0; EnableTextInput(); Viewport.Replace(0, 0, Width, Height); RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f); RenderState.ClearAll(); // if (world != null) { if (wireFrame) { RenderState.Wireframe = true; } world.Renderer.Draw(); RenderState.Wireframe = false; } // guiHelper.NewFrame(elapsed); ImGui.PushFont(ImGuiHelper.Noto); //Main Menu ImGui.BeginMainMenuBar(); if (ImGui.BeginMenu("File")) { if (Theme.IconMenuItem("Open", "open", Color4.White, true)) { var folder = FileDialog.ChooseFolder(); if (folder != null) { if (GameConfig.CheckFLDirectory(folder)) { openLoad = true; LoadData(folder); } else { //Error dialog } } } if (Theme.IconMenuItem("Quit", "quit", Color4.White, true)) { Exit(); } ImGui.EndMenu(); } if (world != null) { if (ImGui.MenuItem("Change System (F6)")) { sysIndex = sysIndexLoaded; openChangeSystem = true; } } if (ImGui.BeginMenu("View")) { if (ImGui.MenuItem("Debug Text", "", showDebug, true)) { showDebug = !showDebug; } if (ImGui.MenuItem("Wireframe", "", wireFrame, true)) { wireFrame = !wireFrame; } if (ImGui.MenuItem("Infocard", "", infocardOpen, true)) { infocardOpen = !infocardOpen; } if (ImGui.MenuItem("VSync", "", vSync, true)) { vSync = !vSync; SetVSync(vSync); } ImGui.EndMenu(); } var h = ImGui.GetWindowHeight(); ImGui.EndMainMenuBar(); //Other Windows if (world != null) { if (showDebug) { ImGui.SetNextWindowPos(new Vector2(0, h), ImGuiCond.Always, Vector2.Zero); ImGui.Begin("##debugWindow", ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoBringToFrontOnFocus); ImGui.Text(string.Format(DEBUG_TEXT, curSystem.Name, curSystem.Nickname, camera.Position.X, camera.Position.Y, camera.Position.Z, DebugDrawing.SizeSuffix(GC.GetTotalMemory(false)), (int)Math.Round(RenderFrequency), VertexBuffer.TotalDrawcalls, VertexBuffer.TotalBuffers)); ImGui.End(); } ImGui.SetNextWindowSize(new Vector2(100, 100), ImGuiCond.FirstUseEver); if (infocardOpen) { if (ImGui.Begin("Infocard", ref infocardOpen)) { var szX = Math.Max(20, ImGui.GetWindowWidth()); var szY = Math.Max(20, ImGui.GetWindowHeight()); if (icard == null) { icard = new InfocardControl(this, systemInfocard, szX); } icard.Draw(szX); } ImGui.End(); } } //dialogs must be children of window or ImGui default "Debug" window appears if (openChangeSystem) { ImGui.OpenPopup("Change System"); openChangeSystem = false; } bool popupopen = true; if (ImGui.BeginPopupModal("Change System", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize)) { ImGui.Combo("System", ref sysIndex, systems, systems.Length); if (ImGui.Button("Ok")) { if (sysIndex != sysIndexLoaded) { camera.UpdateProjection(); camera.Free = false; camera.Zoom = 5000; Resources.ClearTextures(); curSystem = GameData.GetSystem(systems[sysIndex]); systemInfocard = GameData.GetInfocard(curSystem.Infocard, fontMan); if (icard != null) { icard.SetInfocard(systemInfocard); } GameData.LoadAllSystem(curSystem); world.LoadSystem(curSystem, Resources); sysIndexLoaded = sysIndex; } ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } if (openLoad) { ImGui.OpenPopup("Loading"); openLoad = false; } popupopen = true; if (ImGui.BeginPopupModal("Loading", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize)) { if (world != null) { ImGui.CloseCurrentPopup(); } ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1)); ImGui.SameLine(); ImGui.Text("Loading"); ImGui.EndPopup(); } ImGui.PopFont(); guiHelper.Render(RenderState); }
protected override void Draw(double elapsed) { VertexBuffer.TotalDrawcalls = 0; EnableTextInput(); Viewport.Replace(0, 0, Width, Height); RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f); RenderState.ClearAll(); // if (cutscene != null) { cutscene.Draw(); } // guiHelper.NewFrame(elapsed); ImGui.PushFont(ImGuiHelper.Noto); bool openLoad = false; //Main Menu ImGui.BeginMainMenuBar(); if (ImGui.BeginMenu("File")) { if (Theme.IconMenuItem("Load Game Data", "open", Color4.White, true)) { var folder = FileDialog.ChooseFolder(); if (folder != null) { if (GameConfig.CheckFLDirectory(folder)) { openLoad = true; LoadData(folder); } else { //Error dialog } } } if (Theme.IconMenuItem("Open Thn", "open", Color4.White, GameData != null)) { var file = FileDialog.Open(); if (file != null) { var script = new ThnScript(file); var ctx = new ThnScriptContext(new[] { script }); cutscene = new Cutscene(ctx, GameData, new Viewport(0, 0, Width, Height), this); } } if (Theme.IconMenuItem("Quit", "quit", Color4.White, true)) { Exit(); } ImGui.EndMenu(); } var h = ImGui.GetWindowHeight(); ImGui.EndMainMenuBar(); bool popupopen = true; if (openLoad) { ImGui.OpenPopup("Loading"); openLoad = false; } popupopen = true; if (ImGui.BeginPopupModal("Loading", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize)) { if (loaded) { ImGui.CloseCurrentPopup(); } ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1)); ImGui.SameLine(); ImGui.Text("Loading"); ImGui.EndPopup(); } ImGui.PopFont(); guiHelper.Render(RenderState); }
protected override void Draw(double elapsed) { VertexBuffer.TotalDrawcalls = 0; EnableTextInput(); RenderContext.ReplaceViewport(0, 0, Width, Height); RenderContext.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f); RenderContext.ClearAll(); // if (world != null) { if (wireFrame) { RenderContext.Wireframe = true; } world.Renderer.Draw(); RenderContext.Wireframe = false; } // guiHelper.NewFrame(elapsed); ImGui.PushFont(ImGuiHelper.Noto); //Main Menu ImGui.BeginMainMenuBar(); if (ImGui.BeginMenu("File")) { if (Theme.IconMenuItem(Icons.Open, "Open", true)) { var folder = FileDialog.ChooseFolder(); if (folder != null) { if (GameConfig.CheckFLDirectory(folder)) { openLoad = true; LoadData(folder); } else { //Error dialog } } } if (Theme.IconMenuItem(Icons.Quit, "Quit", true)) { Exit(); } ImGui.EndMenu(); } if (world != null) { if (ImGui.MenuItem("Change System (F6)")) { sysIndex = sysIndexLoaded; openChangeSystem = true; } } if (ImGui.BeginMenu("View")) { if (ImGui.MenuItem("Debug Text", "", showDebug, true)) { showDebug = !showDebug; } if (ImGui.MenuItem("Wireframe", "", wireFrame, true)) { wireFrame = !wireFrame; } if (ImGui.MenuItem("Infocard", "", infocardOpen, true)) { infocardOpen = !infocardOpen; } if (ImGui.MenuItem("Universe Map", "", universeOpen, true)) { universeOpen = !universeOpen; } if (ImGui.MenuItem("Controls", "", controlsOpen, true)) { controlsOpen = !controlsOpen; } if (ImGui.MenuItem("VSync", "", vSync, true)) { vSync = !vSync; SetVSync(vSync); } ImGui.EndMenu(); } var h = ImGui.GetWindowHeight(); ImGui.EndMainMenuBar(); //Other Windows if (camera != null && controlsOpen) { if (ImGui.Begin("Controls", ref controlsOpen)) { ImGui.Text("WSAD - Movement"); ImGui.Text("Arrow Keys - Rotation"); ImGui.SliderFloat("Move Speed", ref camera.MoveSpeed, 1, 12000); if (ImGui.Button(LOWSPEED.ToString())) { camera.MoveSpeed = LOWSPEED; } ImGui.SameLine(); if (ImGui.Button(MEDSPEED.ToString())) { camera.MoveSpeed = MEDSPEED; } ImGui.SameLine(); if (ImGui.Button(HIGHSPEED.ToString())) { camera.MoveSpeed = HIGHSPEED; } ImGui.End(); } } if (world != null) { if (showDebug) { ImGui.SetNextWindowPos(new Vector2(0, h), ImGuiCond.Always, Vector2.Zero); ImGui.Begin("##debugWindow", ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoBringToFrontOnFocus); ImGui.Text(string.Format(DEBUG_TEXT, curSystem.Name, curSystem.Nickname, camera.Position.X, camera.Position.Y, camera.Position.Z, DebugDrawing.SizeSuffix(GC.GetTotalMemory(false)), (int)Math.Round(RenderFrequency), VertexBuffer.TotalDrawcalls, VertexBuffer.TotalBuffers)); ImGui.End(); } if (infocardOpen) { ImGui.SetNextWindowSize(new Vector2(300, 300), ImGuiCond.FirstUseEver); if (ImGui.Begin("Infocard", ref infocardOpen)) { var szX = Math.Max(20, ImGui.GetWindowWidth()); var szY = Math.Max(20, ImGui.GetWindowHeight()); if (icard == null) { icard = new InfocardControl(this, systemInfocard, szX); } icard.Draw(szX); ImGui.End(); } } if (universeOpen) { ImGui.SetNextWindowSize(new Vector2(300, 300), ImGuiCond.FirstUseEver); if (ImGui.Begin("Map", ref universeOpen)) { ImGui.BeginTabBar("##maptabs"); if (ImGui.BeginTabItem("Universe")) { var szX = Math.Max(20, ImGui.GetWindowWidth()); var szY = Math.Max(20, ImGui.GetWindowHeight() - 50); string result = UniverseMap.Draw(universeBackgroundRegistered, GameData, (int)szX, (int)szY, 20); if (result != null) { for (int i = 0; i < systems.Length; i++) { if (result.Equals(systems[i], StringComparison.OrdinalIgnoreCase)) { sysIndex = i; ChangeSystem(); break; } } } ImGui.EndTabItem(); } if (ImGui.BeginTabItem("System")) { var szX = Math.Max(20, ImGui.GetWindowWidth()); var szY = Math.Max(20, ImGui.GetWindowHeight() - 70); systemMap.Draw((int)szX, (int)szY, elapsed); ImGui.EndTabItem(); } ImGui.EndTabBar(); ImGui.End(); } } } //dialogs must be children of window or ImGui default "Debug" window appears if (openChangeSystem) { ImGui.OpenPopup("Change System"); openChangeSystem = false; } bool popupopen = true; if (ImGui.BeginPopupModal("Change System", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize)) { ImGui.Combo("System", ref sysIndex, systems, systems.Length); if (ImGui.Button("Ok")) { ChangeSystem(); ImGui.CloseCurrentPopup(); } ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } if (openLoad) { ImGui.OpenPopup("Loading"); openLoad = false; } popupopen = true; if (ImGui.BeginPopupModal("Loading", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize)) { if (world != null) { ImGui.CloseCurrentPopup(); } ImGuiExt.Spinner("##spinner", 10, 2, ImGui.GetColorU32(ImGuiCol.ButtonHovered, 1)); ImGui.SameLine(); ImGui.Text("Loading"); ImGui.EndPopup(); } ImGui.PopFont(); guiHelper.Render(RenderContext); }
protected override void Draw(double elapsed) { VertexBuffer.TotalDrawcalls = 0; EnableTextInput(); Viewport.Replace(0, 0, Width, Height); RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f); RenderState.ClearAll(); // if (cutscene != null) { cutscene.Draw(); } Typewriter.Render(); // guiHelper.NewFrame(elapsed); ImGui.PushFont(ImGuiHelper.Noto); bool openLoad = false; bool openMultiple = false; isMultipleOpen = false; //Main Menu ImGui.BeginMainMenuBar(); if (ImGui.BeginMenu("File")) { if (Theme.IconMenuItem("Load Game Data", "open", Color4.White, true)) { var folder = FileDialog.ChooseFolder(); if (folder != null) { if (GameConfig.CheckFLDirectory(folder)) { openLoad = true; LoadData(folder); } else { //Error dialog } } } if (Theme.IconMenuItem("Open Thn", "open", Color4.White, GameData != null)) { var file = FileDialog.Open(); if (file != null) { Open(file); } } if (Theme.IconMenuItem("Open Multiple", "open", Color4.White, GameData != null)) { openFiles = new List <string>(); openMultiple = true; } if (Theme.IconMenuItem("Quit", "quit", Color4.White, true)) { Exit(); } ImGui.EndMenu(); } if (ImGui.BeginMenu("View")) { ImGui.MenuItem("Decompiled", "", ref decompiledOpen); ImGui.EndMenu(); } if (toReload != null && ImGui.MenuItem("Reload (F5)")) { Reload(); } var h = ImGui.GetWindowHeight(); ImGui.EndMainMenuBar(); bool popupopen = true; if (openLoad) { ImGui.OpenPopup("Loading"); openLoad = false; } popupopen = true; if (ImGui.BeginPopupModal("Loading", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize)) { if (loaded) { ImGui.CloseCurrentPopup(); } ImGuiExt.Spinner("##spinner", 10, 2, ImGui.GetColorU32(ImGuiCol.ButtonHovered, 1)); ImGui.SameLine(); ImGui.Text("Loading"); ImGui.EndPopup(); } popupopen = true; if (openMultiple) { ImGui.OpenPopup("Open Multiple"); } if (ImGui.BeginPopupModal("Open Multiple", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize)) { isMultipleOpen = true; if (ImGui.Button("+")) { var file = FileDialog.Open(); if (file != null) { openFiles.Add(file); } } ImGui.BeginChild("##files", new Vector2(200, 200), true, ImGuiWindowFlags.HorizontalScrollbar); int j = 0; foreach (var f in openFiles) { ImGui.Selectable(ImGuiExt.IDWithExtra(f, j++)); } ImGui.EndChild(); if (ImGuiExt.Button("Open", openFiles.Count > 0)) { ImGui.CloseCurrentPopup(); Open(openFiles.ToArray()); } } if (decompiled != null) { if (decompiledOpen) { ImGui.SetNextWindowSize(new Vector2(300, 300), ImGuiCond.FirstUseEver); int j = 0; if (ImGui.Begin("Decompiled", ref decompiledOpen)) { ImGui.BeginTabBar("##tabs", ImGuiTabBarFlags.Reorderable); foreach (var file in decompiled) { var tab = ImGuiExt.IDWithExtra(file.Name, j++); if (ImGui.BeginTabItem(tab)) { if (ImGui.Button("Copy")) { SetClipboardText(file.Text); } ImGui.SetNextItemWidth(-1); var th = ImGui.GetWindowHeight() - 100; ImGui.PushFont(ImGuiHelper.SystemMonospace); ImGui.InputTextMultiline("##src", ref file.Text, uint.MaxValue, new Vector2(0, th), ImGuiInputTextFlags.ReadOnly); ImGui.PopFont(); ImGui.EndTabItem(); } } ImGui.EndTabBar(); } } } ImGui.PopFont(); guiHelper.Render(RenderState); }