Skip to content

Commit 61999f6

Browse files
Adding open folder button for mods. (#458)
* Adding open folde buttonr for mods. * Updating && symbol and switching to osShellExecute * Removing windows.h import * Spurios addition --------- Co-authored-by: Karjala22 <78927981+Karjala22@users.noreply.github.com>
1 parent 81aab6b commit 61999f6

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

TheForceEngine/TFE_FrontEndUI/modLoader.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ namespace TFE_FrontEndUI
7070

7171
static ViewMode s_viewMode = VIEW_IMAGES;
7272

73+
char programDirModDir[TFE_MAX_PATH];
7374
static char s_modFilter[256] = { 0 };
7475
static char s_prevModFilter[256] = { 0 };
7576
static size_t s_filterLen = 0;
@@ -90,7 +91,8 @@ namespace TFE_FrontEndUI
9091

9192
void modLoader_read()
9293
{
93-
if (s_modsRead) { return; }
94+
// Reuse the cached mods unless no mods have been read yet.
95+
if (s_modsRead && s_mods.size() > 0) { return; }
9496
s_modsRead = true;
9597

9698
s_mods.clear();
@@ -118,7 +120,6 @@ namespace TFE_FrontEndUI
118120
sprintf(programDataModDir, "%sMods/", programData);
119121
TFE_Paths::fixupPathAsDirectory(programDataModDir);
120122

121-
char programDirModDir[TFE_MAX_PATH];
122123
sprintf(programDirModDir, "%sMods/", programDir);
123124
TFE_Paths::fixupPathAsDirectory(programDirModDir);
124125

@@ -142,6 +143,7 @@ namespace TFE_FrontEndUI
142143

143144
if (!modPathCount)
144145
{
146+
s_modsRead = false;
145147
return;
146148
}
147149

@@ -444,6 +446,24 @@ namespace TFE_FrontEndUI
444446
}
445447
filterMods(s_viewMode != VIEW_FILE_LIST);
446448
}
449+
450+
ImGui::SameLine(510.0f * uiScale);
451+
if (ImGui::Button("Refresh Mod Listing"))
452+
{
453+
s_modsRead = false;
454+
modLoader_read();
455+
}
456+
457+
#ifdef _WIN32
458+
ImGui::SameLine(730.0f * uiScale);
459+
if (ImGui::Button("Open Mod Folder"))
460+
{
461+
if (!TFE_System::osShellExecute(programDirModDir, NULL, NULL, false))
462+
{
463+
TFE_System::logWrite(LOG_ERROR, "ModLoader", "Failed to open the directory: '%s'", programDirModDir);
464+
}
465+
}
466+
#endif
447467

448468
ImGui::Separator();
449469

0 commit comments

Comments
 (0)