WorldsLinuxWrapper/launch.sh

202 lines
7.5 KiB
Bash
Raw Normal View History

2020-02-10 01:09:45 -05:00
#!/bin/bash
export TITLE="Worlds Linux"
2020-02-10 01:09:45 -05:00
export WORLDSDIR="$(dirname "$(readlink -f "$0")")"
export WINEPREFIX=$WORLDSDIR/prefix
export WORLDSINSTALL="$WINEPREFIX/drive_c/Program Files/Worlds/WorldsPlayer by Worlds.com"
2020-04-30 14:47:33 -04:00
export WINE="/usr/bin/wine"
2020-02-10 01:09:45 -05:00
mkdir -p $WORLDSDIR/backups $WORLDSDIR/themes
2020-04-28 19:23:34 -04:00
if [ -f "$WORLDSDIR/wrldslinux" ]; then
source "$WORLDSDIR/wrldslinux"
fi
cd "$WORLDSINSTALL"
2020-02-14 14:37:01 -05:00
2020-02-10 01:09:45 -05:00
main() {
2020-09-09 16:17:26 -04:00
if [[ -f "$WORLDSDIR/.update.sh" ]]; then
rm "$WORLDSDIR/.update.sh"
fi
2020-04-28 19:23:34 -04:00
sel=$(zenity \
--list \
--title="$TITLE" \
--window-icon="$WORLDSDIR/icon.png" \
--width=300 \
2020-09-09 16:17:26 -04:00
--height=360 \
2020-04-28 19:23:34 -04:00
--cancel-label='Quit' \
--radiolist \
--text 'WorldsPlayer Linux' \
--column '' \
--column 'Options' \
--hide-header \
TRUE 'Launch Worlds' \
FALSE 'Launch Worlds with Logger' \
2020-09-09 13:33:59 -04:00
FALSE 'Worlds Organizer' \
2020-04-28 19:23:34 -04:00
FALSE 'Open Worlds folder' \
FALSE 'Settings' \
FALSE 'Clear Cache' \
FALSE 'Force Kill' \
2020-09-09 16:17:26 -04:00
FALSE 'Update' \
2020-04-28 19:23:34 -04:00
FALSE 'Open Github page' 2>/dev/null)
case $sel in
2020-04-28 19:23:34 -04:00
'Launch Worlds')
launch ;;
'Launch Worlds with Logger')
launch && tail -F "$WORLDSINSTALL/Gamma.Log.open" | zenity --text-info --auto-scroll --height=480 --width=768 --title="$TITLE - Log" --window-icon="$WORLDSDIR/icon.png" --text="Gamma.Log.open" ;;
2020-09-09 13:33:59 -04:00
'Worlds Organizer')
if [[ ! -f "$WORLDSDIR/WorldsOrganizer.jar" ]]; then
zenity --info --text="The launcher will now download WorldsOrganizer using wget and run it." --width=280 --height=40 --title="$TITLE - WorldsOrganizer" --window-icon="$WORLDSDIR/icon.png"
2023-05-08 15:56:42 -04:00
wget -O"$WORLDSDIR/WorldsOrganizer.jar" "https://git.worlio.com/attachments/9c9bc3bf-c5c0-40bc-a26d-ce38556fe05d" | zenity --progress --no-cancel --title="$TITLE - Downloading WorldsOrganizer" --width=300 --height=50 --auto-close --auto-kill
2020-09-09 13:33:59 -04:00
fi
2021-03-02 02:03:26 -05:00
java -jar "$WORLDSDIR/WorldsOrganizer.jar" -i "$WORLDSINSTALL/gamma.avatars" -i "$WORLDSINSTALL/gamma.worldsmarks"
2020-09-09 13:33:59 -04:00
main ;;
2020-04-28 19:23:34 -04:00
'Open Worlds folder')
gio open "$WORLDSINSTALL" ;;
'Settings' )
2020-04-30 14:47:33 -04:00
settings
2020-04-28 19:23:34 -04:00
main ;;
'Clear Cache')
2020-04-30 14:47:33 -04:00
cache
2020-04-28 19:23:34 -04:00
main ;;
'Force Kill' )
2020-04-30 14:47:33 -04:00
killw
2020-04-28 19:23:34 -04:00
main ;;
2020-09-09 16:17:26 -04:00
'Update' )
update | zenity --progress --no-cancel --title="$TITLE - Updating" --width=300 --height=50 --auto-close --auto-kill;;
2020-04-28 19:23:34 -04:00
'Open Github page' )
2023-05-08 15:56:42 -04:00
xdg-open "https://git.worlio.com/Wirlaburla/WorldsLinuxWrapper"
2020-04-28 19:23:34 -04:00
main ;;
esac
}
launch () {
2020-09-09 13:33:59 -04:00
WORLDSNEW="WorldsPlayer.exe"
WORLDSOLD="run.exe"
WORLDSLEGACY="run.bat"
if [ -f "$WORLDSINSTALL/$WORLDSNEW" ]; then
$WINE "$WORLDSINSTALL/$WORLDSNEW"
elif [ -f "$WORLDSINSTALL/$WORLDSOLD" ]; then
$WINE "$WORLDSINSTALL/$WORLDSOLD"
else
$WINE cmd /c "$WORLDSINSTALL/$WORLDSLEGACY"
fi
if [ $? -ne 0 ]; then
launch
fi
}
2020-04-28 19:23:34 -04:00
settings () {
SETSEL=$(zenity --list --title="$TITLE - Settings" --text="Settings for Worlds Linux" --column='Option' --column='Value' --cancel-label="Back" --width=540 --height=360 --window-icon="$WORLDSDIR/icon.png" \
"Wine Location" "$WINE" \
"Prefix Location" "$WINEPREFIX" \
"Worlds Location" "$WORLDSINSTALL" \
"Edit worlds.ini" "" \
"Wine Configuration" "" \
2020-04-30 14:47:33 -04:00
"Winetricks" "" \
2020-04-28 19:23:34 -04:00
"Backup" "" \
"Restore" "" \
2>/dev/null)
case $SETSEL in
'Wine Location')
WINESEL=$(zenity --entry --title="$WTITLE - Wine Binary Location" --text="Path to wine binary" --entry-text="$WINE" --window-icon="$WORLDSDIR/icon.png")
if [[ ! $? -eq 1 ]]; then
export WINE=$WINESEL
fi
settings ;;
'Prefix Location')
PREFSEL=$(zenity --entry --title="$WTITLE - Wine Prefix Location" --text="Path to Wine Prefix." --entry-text="$WINEPREFIX" --window-icon="$WORLDSDIR/icon.png")
if [[ ! $? -eq 1 ]]; then
export WINEPREFIX=$PREFSEL
fi
settings ;;
'Worlds Location')
WORLDSEL=$(zenity --entry --title="$WTITLE - Worlds Location" --text="Path to Worlds Folder" --entry-text="$WORLDSINSTALL" --window-icon="$WORLDSDIR/icon.png")
if [[ ! $? -eq 1 ]]; then
export WORLDSINSTALL=$WORLDSEL
fi
settings ;;
'Edit worlds.ini')
xdg-open "$WORLDSINSTALL/worlds.ini"
settings ;;
'Wine Configuration')
"$WINE"cfg
settings ;;
2020-04-30 14:47:33 -04:00
'Winetricks')
winetricks
settings ;;
2020-04-28 19:23:34 -04:00
'Backup')
2020-04-30 14:47:33 -04:00
backup
2020-04-28 19:23:34 -04:00
settings ;;
'Restore')
2020-04-30 14:47:33 -04:00
restore
2020-04-28 19:23:34 -04:00
settings ;;
esac
echo "# Configuration for Worlds on Linux." > "$WORLDSDIR/wrldslinux"
echo "export WINE=\"$WINE\"" >> "$WORLDSDIR/wrldslinux"
echo "export WINEPREFIX=\"$WINEPREFIX\"" >> "$WORLDSDIR/wrldslinux"
echo "export WORLDSINSTALL=\"$WORLDSINSTALL\"" >> "$WORLDSDIR/wrldslinux"
2020-07-02 20:36:11 -04:00
echo "source \"$WORLDSDIR/wrldscmd\"" >> "$WORLDSDIR/wrldslinux"
}
backup () {
2020-04-28 19:23:34 -04:00
mkdir -p "$WORLDSDIR/backups"
bkup=$(zenity --file-selection --title="$TITLE - Backup" --text="Select Backup folder to backup to" --directory --filename="$WORLDSDIR/backups/" --save --confirm-overwrite --window-icon="$WORLDSDIR/icon.png")
if [[ ! $? -eq 1 ]]; then
cp -r "$WORLDSINSTALL/worlds.ini" "$bkup/worlds.ini"
cp -r "$WORLDSINSTALL/gamma.avatars" "$bkup/gamma.avatars"
cp -r "$WORLDSINSTALL/gamma.worldsmarks" "$bkup/gamma.worldsmarks"
if [[ $? -eq 1 ]]; then
zenity --error --text="Could not backup files." --width=240 --height=40 --title="$TITLE - Backup" --window-icon="$WORLDSDIR/icon.png"
else
zenity --info --text="Personal world files successfully backed up." --width=240 --height=40 --title="$TITLE - Backup" --window-icon="$WORLDSDIR/icon.png"
fi
fi
}
restore () {
2020-04-28 19:23:34 -04:00
mkdir -p "$WORLDSDIR/backups"
rbkup=$(zenity --file-selection --title="Select Backup folder to restore from" --directory --filename="$WORLDSDIR/backups/" --window-icon="$WORLDSDIR/icon.png")
if [[ ! $? -eq 1 ]]; then
cp -r "$rbkup/worlds.ini" "$WORLDSINSTALL/worlds.ini"
cp -r "$rbkup/gamma.avatars" "$WORLDSINSTALL/gamma.avatars"
cp -r "$rbkup/gamma.worldsmarks" "$WORLDSINSTALL/gamma.worldsmarks"
if [[ $? -eq 1 ]]; then
zenity --error --text="Could not restore files." --width=240 --height=40 --title="$TITLE - Restore" --window-icon="$WORLDSDIR/icon.png"
else
zenity --info --text="Personal world files successfully restored." --width=240 --height=40 --title="$TITLE - Restore" --window-icon="$WORLDSDIR/icon.png"
fi
fi
}
cache () {
2020-04-28 19:23:34 -04:00
CDSIZE=$(du -sh "$WORLDSINSTALL/cachedir" | cut -f1)
if [ -d "$WORLDSINSTALL/cachedir" ]; then
rm -rf "$WORLDSINSTALL/cachedir" | zenity --progress --no-buttons --text="Removing cachedir..." -title="$TITLE - Removing Cachedir" --window-icon="$WORLDSDIR/icon.png" --auto-close --auto-kill
if [ ! -d "$WORLDSINSTALL/cachedir" ]; then
zenity --info --text="$CDSIZE were successfully cleared." --width=240 --height=40 --title="$TITLE - Cachedir" --window-icon="$WORLDSDIR/icon.png"
else
zenity --error --text="Something went wrong." --width=240 --height=40 --title="$TITLE - Cachedir" --window-icon="$WORLDSDIR/icon.png"
fi
else
zenity --error --text="Cachedir doesn't exist! Was it already cleared?" --width=240 --height=40 --title="$TITLE - Cachedir" --window-icon="$WORLDSDIR/icon.png"
fi
}
2020-09-09 16:17:26 -04:00
update () {
2023-05-08 15:56:42 -04:00
NEWLAUNCHFILE="https://git.worlio.com/Wirlaburla/WorldsLinuxWrapper/raw/branch/master/launch.sh"
2020-09-09 16:17:26 -04:00
UPDATEFILE="$WORLDSDIR/.update.sh"
touch "$UPDATEFILE"
echo "wget -N -O\"$WORLDSDIR/launch.sh\" \"$NEWLAUNCHFILE\"" >> "$UPDATEFILE"
echo "chmod +x \"$WORLDSDIR/launch.sh\"" >> "$UPDATEFILE"
echo "\"$WORLDSDIR/launch.sh\"" >> "$UPDATEFILE"
chmod +x "$UPDATEFILE"
sh "$UPDATEFILE"
}
2020-04-28 19:23:34 -04:00
killw () {
killall WorldsPlayer.exe run.exe javaw.exe jrew.exe run.bat | zenity --progress --no-cancel --title="$TITLE - Killing Processes" --width=300 --height=50 --auto-close --auto-kill
2020-04-28 19:23:34 -04:00
zenity --error --text="Killed all possible running processes of Worlds." --width=240 --height=40 --title="$TITLE - Kill" --window-icon="$WORLDSDIR/icon.png"
2020-02-10 01:09:45 -05:00
}
main