Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Improve message boxes related to installing mods
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoticgd committed Aug 24, 2023
1 parent d237467 commit 633fdc0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions libra/mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ RA_Result RA_install_mods(RA_Mod* mods, u32 mod_count, RA_TableOfContents* toc,
return RA_FAILURE(result->message);
}

// If one of the mods doesn't exist, bail out. This prevents the user from
// being spammed with dialog boxes when they delete all their mods, and
// click 'Install Mods' without first clicking 'Refresh'.
for(u32 i = 0; i < mod_count; i++) {
if(mods[i].enabled) {
char mod_path[RA_MAX_PATH];
if(snprintf(mod_path, sizeof(mod_path), "%s/mods/%s", game_dir, mods[i].file_name) < 0) {
return RA_FAILURE("path too long");
}
if(!RA_file_exists(mod_path)) {
return RA_FAILURE("mod '%s' doesn't exist", mods[i].file_name);
}
}
}

RA_LoadedMod* loaded_mods = RA_malloc(mod_count * sizeof(RA_LoadedMod));
u32 loaded_mod_count = 0;
u32 success_count = 0;
Expand Down
4 changes: 4 additions & 0 deletions modmanager.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ static void install_mods() {

if(fail_count == 0) {
RA_message_box(GUI_MESSAGE_BOX_INFO, "Success", "Installed %u mod%s successfully.", success_count, success_count == 1 ? "" : "s");
} else {
RA_message_box(GUI_MESSAGE_BOX_INFO, "Error", "%u mod%s were installed successfully, %u mod%s failed to install.",
success_count, success_count == 1 ? "" : "s",
fail_count, fail_count == 1 ? "" : "s");
}

RA_free(out_data);
Expand Down

0 comments on commit 633fdc0

Please sign in to comment.