private void DrawStatusPanel() { ImGui.BeginChild("statusbar", new Vector2(0, 30), true, 0); ImGui.Text($"{_bigArchive.FilePath} | Version: {_bigArchive.Version} | Size: {ImGuiUtility.GetFormatedSize(_bigArchive.Size)} | Files: {_bigArchive.Entries.Count}"); ImGui.SameLine(); if (_currentFileName != null) { ImGui.Text($"| Selected file: {_currentFileName}"); } ImGui.EndChild(); // end statusbar }
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(); }