public void Draw(ref bool isGameViewFocused) { _gamePanel.IsGameViewActive = isGameViewFocused; ImGui.SetNextWindowPos(Vector2.Zero, Condition.Always, Vector2.Zero); ImGui.SetNextWindowSize(new Vector2(_gameWindow.ClientBounds.Width, _gameWindow.ClientBounds.Height), Condition.Always); ImGui.PushStyleVar(StyleVar.WindowRounding, 0); ImGui.BeginWindow("OpenSAGE Viewer", WindowFlags.MenuBar | WindowFlags.NoTitleBar); if (ImGui.BeginMenuBar()) { if (ImGui.BeginMenu("Installation")) { foreach (var installation in _installations) { if (ImGui.MenuItem(installation.Game.DisplayName, null, _selectedInstallation == installation, true)) { ChangeInstallation(installation); } } ImGui.EndMenu(); } ImGui.EndMenuBar(); } ImGui.BeginChild("sidebar", new Vector2(250, 0), true, 0); if (_launcherImage != null) { var availableSize = ImGui.GetContentRegionAvailable(); var launcherImageSize = SizeF.CalculateSizeFittingAspectRatio( new SizeF(_launcherImage.Width, _launcherImage.Height), new Size((int)availableSize.X, (int)availableSize.Y)); ImGui.Image( _imGuiRenderer.GetOrCreateImGuiBinding(_gameWindow.GraphicsDevice.ResourceFactory, _launcherImage), new Vector2(launcherImageSize.Width, launcherImageSize.Height), Vector2.Zero, Vector2.One, Vector4.One, Vector4.Zero); } ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", true, 0); for (var i = 0; i < _files.Count; i++) { var entry = _files[i]; if (!string.IsNullOrEmpty(searchText) && entry.FilePath.IndexOf(searchText, StringComparison.OrdinalIgnoreCase) < 0) { continue; } if (ImGui.Selectable(entry.FilePath, i == _currentFile)) { _currentFile = i; RemoveAndDispose(ref _contentView); _game.ContentManager.Unload(); _contentView = AddDisposable(new ContentView( new Views.AssetViewContext(_game, _gamePanel, _imGuiRenderer, entry))); } var shouldOpenSaveDialog = false; if (ImGui.BeginPopupContextItem("context" + i)) { _currentFile = i; if (ImGui.Selectable("Export...")) { shouldOpenSaveDialog = true; } ImGui.EndPopup(); } var exportId = "Export##ExportDialog" + i; if (shouldOpenSaveDialog) { ImGui.OpenPopup(exportId); } if (ImGui.BeginPopupModal(exportId, WindowFlags.AlwaysAutoResize)) { ImGuiUtility.InputText("File Path", _filePathBuffer, out var filePath); if (ImGui.Button("Save")) { using (var entryStream = entry.Open()) { using (var fileStream = File.OpenWrite(filePath)) { entryStream.CopyTo(fileStream); } } ImGui.CloseCurrentPopup(); } ImGui.SetItemDefaultFocus(); ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } ImGui.EndPopup(); } } ImGui.EndChild(); ImGui.EndChild(); ImGui.SameLine(); if (_contentView != null) { ImGui.BeginChild("content"); ImGui.Text(_contentView.DisplayName); ImGui.BeginChild("content view"); _contentView.Draw(ref isGameViewFocused); ImGui.EndChild(); ImGui.EndChild(); } ImGui.EndWindow(); ImGui.PopStyleVar(); }