diff options
author | Daniel Santos (javamonger) <daniel.santos@pobox.com> | 2010-10-21 06:05:44 +0000 |
---|---|---|
committer | Daniel Santos (javamonger) <daniel.santos@pobox.com> | 2010-10-21 06:05:44 +0000 |
commit | 1457a9142f51bbc1657c70b74328dec6462ed2c2 (patch) | |
tree | c890ac61a1f2df8ec6d968c2b67112c8eff60cbd /games-strategy/moo2/files | |
parent | games-strategy/ moo2: New ebuild for bug #341859. (diff) | |
download | sunrise-1457a9142f51bbc1657c70b74328dec6462ed2c2.tar.gz sunrise-1457a9142f51bbc1657c70b74328dec6462ed2c2.tar.bz2 sunrise-1457a9142f51bbc1657c70b74328dec6462ed2c2.zip |
games-strategy/moo2: Added menu launcher, cleanup, formatting, comments and such.
svn path=/sunrise/; revision=11451
Diffstat (limited to 'games-strategy/moo2/files')
-rw-r--r-- | games-strategy/moo2/files/1.40.24/backup.sh | 81 | ||||
-rwxr-xr-x | games-strategy/moo2/files/1.40.24/moo2 | 63 | ||||
-rw-r--r-- | games-strategy/moo2/files/1.40.24/moo2rc | 16 | ||||
-rwxr-xr-x | games-strategy/moo2/files/1.40.24/utils.sh | 2 |
4 files changed, 140 insertions, 22 deletions
diff --git a/games-strategy/moo2/files/1.40.24/backup.sh b/games-strategy/moo2/files/1.40.24/backup.sh new file mode 100644 index 000000000..386f0f266 --- /dev/null +++ b/games-strategy/moo2/files/1.40.24/backup.sh @@ -0,0 +1,81 @@ +# backup.sh - Library of functions for backing up moo2 saved games +# Copyright (C) 2010 Daniel Santos <daniel.santos@pobox.com> +# $Header: $ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +#set -o functrace +shopt -s extdebug + +############################################################################# +# Function : backupInit +# Arguments : none +# Description : +############################################################################# +backupInit() { + cd "${moo2UserDir}" || die + + # Check for good config + test -z "${backupBaseDir}" && die "backupBaseDir not set in ${configFile}" + + # Get absolute path + backupDir="${PWD}/${backupBaseDir}" + + # Make sure backupDir is usable or can be created. + getOrCreateUsableDir "${backupDir}" +} + +setFileName() { + backupBaseName="$1" + backupFileName="${backupDir}/${backupBaseName}.tgz" +} + +getFileName() { + setFileName "$1" + typeset -i firstTime=1 + while true; do + # Name can't be empty + if [[ ${#backupBaseName} -eq 0 ]]; then + + # Don't complain because not supplied at command line + if [[ ${firstTime} -eq 0 ]]; then + echo "Name cannot be empty, try again." + fi + + # Make sure it doesn't already exist + elif [[ -e "${backupFileName}" ]]; then + echo "File '${backupFileName}' already exists. Please choose another." + + else + return + fi + + echo "Please enter a name for this saved set." + echo -e "Saved set name: \c " + read + echo + setFileName "${REPLY}" + firstTime=0 + done +} + +# Do backup +doBackup() { + backupInit + getFileName "$1" + pushd "${moo2UserDir}/MPS/ORION2" 1>/dev/null || die "Failed to enter directory MPS/ORION!" + echo "Backing up to '${backupFileName}'..." + tar czf "${backupFileName}" $(ls SR_R[0-9]* HOF.* LASTRACE.RAC MOX.SET SAVE[0-9]*.GAM 2>/dev/null) || die + echo "Done!" + popd 1>/dev/null +} diff --git a/games-strategy/moo2/files/1.40.24/moo2 b/games-strategy/moo2/files/1.40.24/moo2 index 8f4880d4d..d40c31a01 100755 --- a/games-strategy/moo2/files/1.40.24/moo2 +++ b/games-strategy/moo2/files/1.40.24/moo2 @@ -19,9 +19,12 @@ moo2Dir="__MOO2DIR__" +. "${moo2Dir}/utils.sh" +. "${moo2Dir}/backup.sh" moo2UserDir="${HOME}/.moo2" configFile="${moo2UserDir}/moo2rc" -. "${moo2Dir}/utils.sh" +postRunMsg="" +postRunCmd="" ############################################################################# # Function : getSeed @@ -72,6 +75,7 @@ userInstall() { ln -s "${moo2Dir}/cd" . || die cp "${moo2Dir}/moo2rc" . || die + # DOS text management is a pain local userMsg="@echo \ Since this is your first time running Master of Orion II, we need to do some \ user-level setup. Master of Orion II uses dosbox. See the Welcome box above for\ @@ -99,7 +103,7 @@ help with that." pushd "${src}" || die # Some files cannot be read only and must be copied - cp -L SOUND.LBX SR_R* *.INI "${dest}" + cp -L SOUND.LBX SR_R* *.INI "${dest}" || die # All the rest can be read-only symlinks for f in *; do @@ -120,29 +124,28 @@ help with that." } ############################################################################# -# Function : main +# Function : verifyEnv # Arguments : none -# Description : Main function +# Description : Performs sanity checks: +# * Initates user install if needed +# * Corrects moo2exe if lordbrazen patch not installed +# * Warns if CD is not present ############################################################################# -main() { - local postRunMsg="" - local postRunCmd="" - +verifyEnv() { # If this is the 1st time to run, do user setup if [ ! -e "${moo2UserDir}/MPS/ORION2/ORION2.EXE" ]; then userInstall fi . "${configFile}" - # If we have the unofficial patch specified in the config, but not installed, use the offical - # version + # If we have the unofficial patch specified in the config, but not + # installed, use the offical version if [ ! -e "${moo2UserDir}/MPS/ORION2/M2V140.EXE" ]; then moo2exe=ORION2.EXE fi # Make sure the CD is still in if [ ! -e "${moo2UserDir}/cd/ORION2.EXE" ]; then - # DOS text management is a pain postRunMsg="\ You're Moo2 CD does not appear to be mounted. You can either put it in, \ reinstall with the nocd USE option (while the CD in) or change the symlink \ @@ -155,7 +158,14 @@ ${moo2UserDir}/cd." warn ${postRunMsg} echo fi +} +############################################################################# +# Function : runGame +# Arguments : none +# Description : (Attempts to) run the game. Function will not return. +############################################################################# +runGame() { # Run the game exec dosbox -conf "${moo2UserDir}/dosboxrc" \ -c "mount c ${moo2UserDir}" \ @@ -167,6 +177,35 @@ ${moo2UserDir}/cd." -c "exit" || warn "dosbox exited with error" } -main +showUsage() { + echo "USAGE: $0 [backup|restore [file_name]]" + exit +} + +############################################################################# +# Function : main +# Arguments : none +# Description : Main function +############################################################################# +main() { + verifyEnv + + # I should probably just make a separate script for this, but screw it. + if [[ "$1" == "backup" ]]; then + shift + (($# <= 1)) || showUsage + doBackup "$@" + elif [[ "$1" == "restore" ]]; then + shift + (($# <= 1)) || showUsage + echo "Restore not yet supported, but your backups are in" \ + "${moo2UserDir}/${backupBaseDir}" + else + (($#)) && showUsage + runGame + fi +} + +main "$@" # vim:ts=4
\ No newline at end of file diff --git a/games-strategy/moo2/files/1.40.24/moo2rc b/games-strategy/moo2/files/1.40.24/moo2rc index db61bcc84..ba1f6bc60 100644 --- a/games-strategy/moo2/files/1.40.24/moo2rc +++ b/games-strategy/moo2/files/1.40.24/moo2rc @@ -1,14 +1,14 @@ -# Base directory to backup saved games to, relative to moo2UserDir (usually ~/.moo2) -backupDirBase="saved-game-backups" +# Base directory to backup saved games to, relative to ${moo2UserDir}. +backupBaseDir="saved-game-backups" -# Which executable to run. M2V140.EXE is the unofficial, hacked-up executable and ORION2.EXE is -# the official one -moo2exe=M2V140.EXE +# Which executable to run. M2V140.EXE is the unofficial, hacked-up executable +# and ORION2.EXE is the official one. #moo2exe=ORION2.EXE +moo2exe=M2V140.EXE -# The arguments to pass. Do not add /seed, as this is randomly generated for you each time. See -# http://lordbrazen.blogspot.com/2005/01/moo2v140-patch-faq.html for a full list of command-line -# options +# The arguments to pass. Do not add /seed, as this is randomly generated for +# you each time. For a list of command-line options, see +# http://lordbrazen.blogspot.com/2005/01/moo2v140-patch-faq.html. #moo2args="/picks=10 /hugestart /planets=3 /skipintro /monsters=3" moo2args="/picks=10" diff --git a/games-strategy/moo2/files/1.40.24/utils.sh b/games-strategy/moo2/files/1.40.24/utils.sh index 621a5b326..bc0b90747 100755 --- a/games-strategy/moo2/files/1.40.24/utils.sh +++ b/games-strategy/moo2/files/1.40.24/utils.sh @@ -1,5 +1,3 @@ -#!/bin/bash - # utils.sh - Library of general utility functions # Copyright (C) 2010 Daniel Santos <daniel.santos@pobox.com> # $Header: $ |