protected override unsafe void DrawOverride(ref bool isGameViewFocused) { ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", ImGui.GetContentRegionAvail(), true); var clipperPtr = ImGuiNative.ImGuiListClipper_ImGuiListClipper(_items.Count, ImGui.GetTextLineHeightWithSpacing()); var clipper = new ImGuiListClipperPtr(clipperPtr); while (clipper.Step()) { for (var i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { var item = _items[i]; var name = GetObjectName(item); if (ImGui.Selectable(name, item == _currentItem)) { _currentItem = item; Context.SelectedObject = item; } ImGuiUtility.DisplayTooltipOnHover(name); } } clipper.Destroy(); ImGui.EndChild(); }
protected override void DrawOverride(ref bool isGameViewFocused) { ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("strings", Vector2.Zero, false); ImGui.Columns(2, "CSF", true); ImGui.Separator(); ImGui.Text("Name"); ImGui.NextColumn(); ImGui.Text("Value"); ImGui.NextColumn(); ImGui.Separator(); foreach (var label in _labels) { ImGui.Text(label); ImGui.NextColumn(); ImGui.Text(CleanText(label.Translate())); ImGui.NextColumn(); } ImGui.Columns(1, null, false); ImGui.EndChild(); }
protected override void DrawOverride(ref bool isGameViewFocused) { ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", Vector2.Zero, true); foreach (var item in _items) { if (ImGui.Selectable(item.Name, item.Asset == Context.SelectedObject)) { Context.SelectedObject = item.Asset; } ImGuiUtility.DisplayTooltipOnHover(item.Name); } ImGui.EndChild(); }
protected override void DrawOverride(ref bool isGameViewFocused) { ImGui.BeginChild("asset list sidebar", new Vector2(350, 0), true, 0); ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", Vector2.Zero, true); foreach (var item in _items) { if (ImGui.Selectable(item.Name, item == _currentItem)) { _currentItem = item; RemoveAndDispose(ref _currentAssetView); _currentAssetView = AddDisposable(item.CreateAssetView()); } ImGuiUtility.DisplayTooltipOnHover(item.Name); } ImGui.EndChild(); ImGui.EndChild(); ImGui.SameLine(); if (_currentItem != null) { ImGui.BeginChild("asset view"); _currentAssetView.Draw(); ImGui.EndChild(); } else { ImGui.Text("Select a previewable asset."); } }
private void DrawOpenFileDialog() { ImGuiUtility.InputText("File Path", _filePathBuffer, out var filePath); if (ImGui.Button("Open")) { filePath = ImGuiUtility.TrimToNullByte(filePath); OpenBigFile(filePath); ImGui.CloseCurrentPopup(); } ImGui.SetItemDefaultFocus(); ImGui.SameLine(); if (ImGui.Button("Cancel")) { ImGui.CloseCurrentPopup(); } }
private void DrawFilesList(Vector2 windowSize) { ImGui.BeginChild("sidebar", new Vector2(350, 0), true, 0); ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", Vector2.Zero, true); ImGui.Columns(2, "Files", false); ImGui.SetColumnWidth(0, 250); ImGui.Separator(); ImGui.Text("Name"); ImGui.NextColumn(); ImGui.Text("Size"); ImGui.NextColumn(); ImGui.Separator(); if (ImGui.IsKeyPressed(ImGui.GetKeyIndex(ImGuiKey.DownArrow)) && _currentFile != _files.Count - 1) { _currentFile++; _scrollY += ImGui.GetIO().DeltaTime * 1000.0f; ImGui.SetScrollY(_scrollY); } if (ImGui.IsKeyPressed(ImGui.GetKeyIndex(ImGuiKey.UpArrow)) && _currentFile != 0) { _currentFile--; _scrollY -= ImGui.GetIO().DeltaTime * 1000.0f; ImGui.SetScrollY(_scrollY); } if (ImGui.IsMouseClicked(0)) { _scrollY = ImGui.GetScrollY(); } for (var i = 0; i < _files.Count; i++) { var entry = _files[i]; if (ImGui.Selectable(entry.FullName, i == _currentFile, ImGuiSelectableFlags.SpanAllColumns) || i == _currentFile) { _currentFile = i; _currentFileName = entry.FullName; switch (Path.GetExtension(entry.FullName).ToLowerInvariant()) { case ".ini": case ".txt": case ".wnd": using (var stream = entry.Open()) using (var reader = new StreamReader(stream)) { _currentFileText = reader.ReadToEnd(); } break; default: _currentFileText = null; break; } } var shouldOpenSaveDialog = false; if (ImGui.BeginPopupContextItem("context" + i)) { _currentFile = i; _currentFileName = entry.FullName; if (ImGui.Selectable("Export...")) { shouldOpenSaveDialog = true; } ImGui.EndPopup(); } ImGui.NextColumn(); ImGui.Text(ImGuiUtility.GetFormatedSize(entry.Length)); ImGui.NextColumn(); if (shouldOpenSaveDialog) { var saveDialog = new SaveFileDialog("Export file"); saveDialog.DefaultFileName = entry.Name; saveDialog.Save(result => ExportFile(entry, result.FileName)); } } ImGui.Columns(1, null, false); ImGui.EndChild(); ImGui.EndChild(); }
private void DrawFilesList() { ImGui.BeginChild("sidebar", new Vector2(350, 0), true, 0); ImGui.PushItemWidth(-1); ImGuiUtility.InputText("##search", _searchTextBuffer, out var searchText); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", Vector2.Zero, true); ImGui.Columns(2, "Files", false); ImGui.SetColumnWidth(0, 250); ImGui.Separator(); ImGui.Text("Name"); ImGui.NextColumn(); ImGui.Text("Size"); ImGui.NextColumn(); ImGui.Separator(); for (var i = 0; i < _files.Count; i++) { var entry = _files[i]; if (ImGui.Selectable(entry.FullName, i == _currentFile, ImGuiSelectableFlags.SpanAllColumns)) { _currentFile = i; switch (Path.GetExtension(entry.FullName).ToLowerInvariant()) { case ".ini": case ".txt": case ".wnd": using (var stream = entry.Open()) using (var reader = new StreamReader(stream)) { _currentFileText = reader.ReadToEnd(); } break; default: _currentFileText = null; break; } } var shouldOpenSaveDialog = false; if (ImGui.BeginPopupContextItem("context" + i)) { _currentFile = i; if (ImGui.Selectable("Export...")) { shouldOpenSaveDialog = true; } ImGui.EndPopup(); } ImGui.NextColumn(); ImGui.Text(entry.Length.ToString()); ImGui.NextColumn(); var exportId = "Export##ExportDialog" + i; if (shouldOpenSaveDialog) { ImGui.OpenPopup(exportId); } bool contextMenuOpen = true; if (ImGui.BeginPopupModal(exportId, ref contextMenuOpen, ImGuiWindowFlags.AlwaysAutoResize)) { ImGuiUtility.InputText("File Path", _filePathBuffer, out var filePath); if (ImGui.Button("Save")) { filePath = ImGuiUtility.TrimToNullByte(filePath); 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.Columns(1, null, false); ImGui.EndChild(); ImGui.EndChild(); }
private void DrawMainUi(ref bool isGameViewFocused) { 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(); } if (ImGui.BeginMenu("Preferences")) { bool isVSyncEnabled = _isVSyncEnabled; if (ImGui.MenuItem("VSync", null, ref isVSyncEnabled, true)) { SetVSync(isVSyncEnabled); } ImGui.EndMenu(); } ImGui.EndMenuBar(); } ImGui.BeginChild("sidebar", new Vector2(250, 0), true, 0); if (_launcherImage != null) { var availableSize = ImGui.GetContentRegionAvail(); 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); UpdateSearch(searchText); ImGui.PopItemWidth(); ImGui.BeginChild("files list", Vector2.Zero, true); for (var i = 0; i < _files.Count; i++) { var entry = _files[i]; 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))); } ImGuiUtility.DisplayTooltipOnHover(entry.FilePath); } ImGui.EndChild(); ImGui.EndChild(); ImGui.SameLine(); if (_contentView != null) { ImGui.BeginChild("content"); ImGui.Text(_contentView.DisplayName); if (isGameViewFocused) { var message = "Press [ESC] to unfocus the 3D view."; ImGui.SameLine(ImGui.GetWindowWidth() - ImGui.CalcTextSize(message).X); ImGui.TextColored(new Vector4(1.0f, 0.0f, 0.0f, 1.0f), message); } ImGui.BeginChild("content view"); _contentView.Draw(ref isGameViewFocused); ImGui.EndChild(); ImGui.EndChild(); } }
private void DrawMainUi(ref bool isGameViewFocused) { 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(); } }