Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/PracticeMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "UI/QR.hpp"
#include "UI/SettingsMenu.hpp"
#include "UI/WarpMenu.h"
#include "UI/ImHelpers.hpp"
#include "imgui.h"
#include "os.h"
#include "prime/CGameState.hpp"
Expand Down Expand Up @@ -129,7 +130,7 @@ void PracticeMod::renderMenu() {
GUI::drawInventoryMenu();
GUI::drawSettingsMenu();
GUI::drawWarpMenu();
if (ImGui::TreeNode("v%s", MOD_VERSION)) {
if (ImHelpers::TreeNodeNavLeft("Version", "v%s", MOD_VERSION)) {
ImGui::Text("Links (QR codes):");
if (ImGui::TreeNode("Releases")) {
GUI::drawQRCode("https://github.com/MetroidPrimeModding/prime2-practice-mod/releases", 3.0f);
Expand Down
16 changes: 16 additions & 0 deletions src/UI/ImHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,21 @@ namespace ImHelpers {
ImGui::SetWindowPos(window->Name, windowPos);
}
}

static const ImGuiTreeNodeFlags NavLeftFlags = ImGuiTreeNodeFlags_OpenOnArrow
| ImGuiTreeNodeFlags_OpenOnDoubleClick
| ImGuiTreeNodeFlags_NavLeftJumpsBackHere;

bool TreeNodeNavLeft(const char *label) {
return ImGui::TreeNodeEx(label, NavLeftFlags);
}

bool TreeNodeNavLeft(const char *str_id, const char *fmt, ...) {
va_list args;
va_start(args, fmt);
bool is_open = ImGui::TreeNodeExV(str_id, NavLeftFlags, fmt, args);
va_end(args);
return is_open;
}
}

2 changes: 2 additions & 0 deletions src/UI/ImHelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@

namespace ImHelpers {
void ClampCurrentWindowToScreen();
bool TreeNodeNavLeft(const char *label);
bool TreeNodeNavLeft(const char *str_id, const char *fmt, ...);
}
2 changes: 1 addition & 1 deletion src/UI/SettingsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace GUI {
void drawHex32Editor(const char *title, s32 *value);

void drawSettingsMenu() {
if (ImGui::TreeNode("Settings")) {
if (ImHelpers::TreeNodeNavLeft("Settings")) {
if (ImGui::TreeNode("On-screen display")) {
BITFIELD_CHECKBOX("Show", SETTINGS.OSD_show);
BITFIELD_CHECKBOX("Pos", SETTINGS.OSD_showPos);
Expand Down
5 changes: 3 additions & 2 deletions src/UI/WarpMenu.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <imgui.h>
#include "WarpMenu.h"
#include "ImHelpers.hpp"

// clang-format off
const WarpArea AREAS_TEMPLE_GROUNDS[] = {
Expand Down Expand Up @@ -402,10 +403,10 @@ const WarpWorld WARP_WORLDS[] = {

namespace GUI {
void drawWarpMenu() {
if (ImGui::TreeNode("Warps")) {
if (ImHelpers::TreeNodeNavLeft("Warps")) {
// ImGui::Text("You can also warp by pressing 'x' on the map");
for (auto world : WARP_WORLDS) {
if (ImGui::TreeNode(world.name)) {
if (ImHelpers::TreeNodeNavLeft(world.name)) {
for (int i = 0; i < world.areaCount; i++) {
ImGuiTreeNodeFlags node_flags = ImGuiTreeNodeFlags_OpenOnArrow
| ImGuiTreeNodeFlags_OpenOnDoubleClick
Expand Down