A tool for deriving PKG packet encryption keys for ps4 written in c++
| 1 | // SPDX-FileCopyrightText: Copyright 2025 shadPKG |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "include/NavBar.h" |
| 5 | #include <assert.h> |
| 6 | #include "imgui.h" |
| 7 | #include "include/StyleManager.h" |
| 8 | |
| 9 | namespace ShadPKG::GUI { |
| 10 | |
| 11 | // ╔═══════════════════════════════════════════════════════════════════════════╗ |
| 12 | // ║ NavBar::Draw - Render the vertical navigation sidebar ║ |
| 13 | // ╚═══════════════════════════════════════════════════════════════════════════╝ |
| 14 | void NavBar::Draw(GUIContext &ctx) { |
| 15 | ImGui::PushStyleColor(ImGuiCol_ChildBg, Colors::NavBarBg); |
| 16 | ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 8)); |
| 17 | |
| 18 | ImGui::BeginChild("##navbar", ImVec2(Width, 0), false, |
| 19 | ImGuiWindowFlags_NoScrollbar); |
| 20 | |
| 21 | // Center content |
| 22 | float centerX = (Width - 40.0f) / 2.0f; |
| 23 | ImGui::SetCursorPosX(centerX); |
| 24 | |
| 25 | // Top section: Main navigation |
| 26 | GUIContext::View currentView = ctx.GetCurrentView(); |
| 27 | |
| 28 | ImGui::Spacing(); |
| 29 | ImGui::Spacing(); |
| 30 | |
| 31 | // Extract button |
| 32 | ImGui::SetCursorPosX(centerX); |
| 33 | if (DrawNavButton(ICON_FA_FILE_ZIPPER, "Extract PKG", |
| 34 | currentView == GUIContext::View::Extractor)) { |
| 35 | ctx.SetCurrentView(GUIContext::View::Extractor); |
| 36 | } |
| 37 | |
| 38 | ImGui::Spacing(); |
| 39 | ImGui::Spacing(); |
| 40 | |
| 41 | // Inspect button |
| 42 | ImGui::SetCursorPosX(centerX); |
| 43 | if (DrawNavButton(ICON_FA_MAGNIFYING_GLASS, "Inspect PKG", |
| 44 | currentView == GUIContext::View::Inspector)) { |
| 45 | ctx.SetCurrentView(GUIContext::View::Inspector); |
| 46 | } |
| 47 | |
| 48 | ImGui::Spacing(); |
| 49 | ImGui::Spacing(); |
| 50 | |
| 51 | // RIF button |
| 52 | ImGui::SetCursorPosX(centerX); |
| 53 | if (DrawNavButton(ICON_FA_KEY, "RIF Tools", |
| 54 | currentView == GUIContext::View::RIF)) { |
| 55 | ctx.SetCurrentView(GUIContext::View::RIF); |
| 56 | } |
| 57 | |
| 58 | ImGui::Spacing(); |
| 59 | ImGui::Spacing(); |
| 60 | |
| 61 | // Decompiler button |
| 62 | ImGui::SetCursorPosX(centerX); |
| 63 | if (DrawNavButton(ICON_FA_TERMINAL, "Decompiler", |
| 64 | currentView == GUIContext::View::Decompiler)) { |
| 65 | ctx.SetCurrentView(GUIContext::View::Decompiler); |
| 66 | } |
| 67 | |
| 68 | // Spacer to push settings to bottom |
| 69 | float availHeight = ImGui::GetContentRegionAvail().y; |
| 70 | ImGui::Dummy(ImVec2(0, availHeight - 60)); |
| 71 | |
| 72 | // Settings button (at bottom) |
| 73 | ImGui::SetCursorPosX(centerX); |
| 74 | if (DrawNavButton(ICON_FA_GEAR, "Settings", |
| 75 | currentView == GUIContext::View::Settings)) { |
| 76 | ctx.SetCurrentView(GUIContext::View::Settings); |
| 77 | } |
| 78 | |
| 79 | ImGui::EndChild(); |
| 80 | |
| 81 | ImGui::PopStyleVar(); |
| 82 | ImGui::PopStyleColor(); |
| 83 | } |
| 84 | |
| 85 | // ┌─────────────────────────────────────────────────────────────────────────┐ |
| 86 | // │ DrawNavButton: Render a single navigation button │ |
| 87 | // └─────────────────────────────────────────────────────────────────────────┘ |
| 88 | bool NavBar::DrawNavButton(const char *icon, const char *tooltip, |
| 89 | bool selected) { |
| 90 | ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 8.0f); |
| 91 | |
| 92 | // Different colors for selected state |
| 93 | if (selected) { |
| 94 | ImGui::PushStyleColor(ImGuiCol_Button, Colors::Primary); |
| 95 | ImGui::PushStyleColor(ImGuiCol_ButtonHovered, Colors::PrimaryHover); |
| 96 | ImGui::PushStyleColor(ImGuiCol_ButtonActive, Colors::PrimaryActive); |
| 97 | } else { |
| 98 | ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.15f, 0.15f, 0.15f, 1.0f)); |
| 99 | ImGui::PushStyleColor(ImGuiCol_ButtonHovered, |
| 100 | ImVec4(0.25f, 0.25f, 0.25f, 1.0f)); |
| 101 | ImGui::PushStyleColor(ImGuiCol_ButtonActive, Colors::PrimaryActive); |
| 102 | } |
| 103 | |
| 104 | ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 10)); |
| 105 | |
| 106 | bool clicked = ImGui::Button(icon, ImVec2(40, 40)); |
| 107 | |
| 108 | ImGui::PopStyleVar(2); |
| 109 | ImGui::PopStyleColor(3); |
| 110 | |
| 111 | if (ImGui::IsItemHovered()) { |
| 112 | ImGui::SetTooltip("%s", tooltip); |
| 113 | } |
| 114 | |
| 115 | return clicked; |
| 116 | } |
| 117 | |
| 118 | } // namespace ShadPKG::GUI |
| 119 |