fix: importing now resets mods

This commit is contained in:
v4n
2025-01-15 20:15:59 +02:00
parent 0806594289
commit 0c00d7fc82
2 changed files with 24 additions and 10 deletions
+11 -2
View File
@@ -14,6 +14,7 @@
- [Resetting all installed mods](#resetting-all-installed-mods)
- [Database location and details](#database-location-and-details)
- [Contributing](#contributing)
- [Planned features](#planned-features)
Helldivers 2 Mod Manager CLI is a command line interface for managing Helldivers 2 mods. Since there is no mod manager GUI for Helldivers 2 on Linux yet, this small script aims to provide a simple way to manage mods on Linux.
@@ -86,9 +87,11 @@ You can use the short form of the commands to save some time. The shortcuts are:
You can export all installed mods to a zip file and import mods from the same file. This can be useful for sharing mods with others or for backing up your mods. The zip file will be saved in the current directory.
This will serve as either a backup or a way to have multiple mod setups.
```bash
h2mm export mods.zip
h2mm import mods.zip
h2mm export modpack1.zip
h2mm import modpack2.zip
```
### Resetting all installed mods
@@ -106,3 +109,9 @@ The database is stored in the `Helldivers 2` install directory, under the `data`
## Contributing
Feel free to contribute to this project by creating a pull request or opening an issue.
## Planned features
- [ ] Enable/disable mods
- [ ] Easier way to change mod presets
- [ ] Change to `.tar.xz` for exporting and importing
+13 -8
View File
@@ -7,7 +7,7 @@ GREEN='\033[0;32m'
ORANGE='\033[0;33m'
NC='\033[0m'
H2PATH="${HOME}/.config/h2path"
H2PATH="${HOME}/.config/h2mm/h2path"
MODS_DIR=""
DB_FILE=""
@@ -25,8 +25,6 @@ function find_game_directory() {
local search_dir="${HOME}"
local target_dir="Steam/steamapps/common/Helldivers\ 2/data"
echo "--- /// HELLDIVERS 2 MOD MANAGER /// ---" >&2
# check if path is saved
if [[ -f "$H2PATH" ]]; then
saved_dir=$(cat "$H2PATH")
@@ -53,6 +51,7 @@ function find_game_directory() {
fi
fi
mkdir -p "$(dirname "$H2PATH")"
echo "$game_dir" > "$H2PATH"
if [[ $? -eq 0 ]]; then
@@ -78,14 +77,12 @@ function initialize_directories() {
exit 1
fi
fi
echo "--- /// MAIN /// ---" >&2
}
# --- Help Functions ---
function display_help() {
echo "Helldivers 2 Mod Manager v0.1.4"
echo "Helldivers 2 Mod Manager v0.1.5"
echo "Usage: h2mm [command] [options]"
echo "Commands:"
echo " install Install a mod with files (short form: h2mm i)."
@@ -169,6 +166,9 @@ function mod_reset() {
rm -f "$DB_FILE"
rm -f "$H2PATH"
echo "Mods and database file deleted."
else
echo "Reset cancelled." >&2
exit 1
fi
}
@@ -313,6 +313,7 @@ function mod_list() {
return
fi
echo "Installed mods:" >&2
awk -F, '{ if (length($3) > 150) $3 = substr($3, 1, 147) "..."; printf "%2s. %s (%s)\n", $1, $2, $3 }' "$DB_FILE"
}
@@ -462,6 +463,12 @@ function mod_import() {
exit 1
fi
echo -e "Importing mods will ${RED}reset${NC} your mods." >&2
mod_reset
if [[ $? -eq 1 ]]; then
exit 1
fi
OUT_DIR=$(mktemp -d)
unzip -qq "$1" -d "$OUT_DIR"
@@ -523,8 +530,6 @@ function main() {
display_help
;;
esac
echo "--- /// END /// ---"
}
main "$@"