Skip to content

Commit 111cf1a

Browse files
committed
make it possible to choose several index files
I also change the way make_index works: - if used from a self extracting archive, prefix all arguments with $GSH_MISSIONS/ - otherwise, use the actual files given from the command line I also print a warning when giving index files in "continue" mode, as those are not used.
1 parent 0802362 commit 111cf1a

File tree

6 files changed

+72
-13
lines changed

6 files changed

+72
-13
lines changed

i18n/en.po

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ msgstr "There are stopped jobs in your session.\n"
207207
" $ jobs\n"
208208
"Do you still want to quit? [y/n]"
209209

210+
#, sh-format
211+
msgid "Warning: command line arguments are ignored when continuing a game ($args)"
212+
msgstr "Warning: command line arguments are ignored when continuing a game ($args)"
213+
214+
#, sh-format
215+
msgid "Warning: language is ignored when continuing a game ($args)"
216+
msgstr "Warning: language is ignored when continuing a game ($args)"
217+
210218
msgid "Warning: the file 'treasure.sh' was sourced from a subshell.\n"
211219
"You should use the command\n"
212220
" $ gsh reset"

i18n/fr.po

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ msgstr "Il y a des processus stoppés dans votre session.\n"
212212
" $ jobs\n"
213213
"Êtes vous sûr de vouloir quitter ? [o/N]"
214214

215+
#, sh-format
216+
msgid "Warning: command line arguments are ignored when continuing a game ($args)"
217+
msgstr "Warning: les arguments sur la ligne de commande sont ignorés lorsqu'on reprend une partie ($args)"
218+
219+
#, sh-format
220+
msgid "Warning: language is ignored when continuing a game ($args)"
221+
msgstr "Warning: la langue est ignorée lorsqu'on reprend une partie ($args)"
222+
215223
msgid "Warning: the file 'treasure.sh' was sourced from a subshell.\n"
216224
"You should use the command\n"
217225
" $ gsh reset"

i18n/it.po

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,14 @@ msgstr "Ci sono dei processi fermati nella tua sessione.\n"
222222
"Vuoi uscire lo stesso? [s/n\n"
223223
"]"
224224

225+
#, sh-format
226+
msgid "Warning: command line arguments are ignored when continuing a game ($args)"
227+
msgstr ""
228+
229+
#, sh-format
230+
msgid "Warning: language is ignored when continuing a game ($args)"
231+
msgstr ""
232+
225233
msgid "Warning: the file 'treasure.sh' was sourced from a subshell.\n"
226234
"You should use the command\n"
227235
" $ gsh reset"

i18n/template.pot

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@ msgid "There are stopped jobs in your session.\n"
197197
"Do you still want to quit? [y/n]"
198198
msgstr ""
199199

200+
#, sh-format
201+
msgid "Warning: command line arguments are ignored when continuing a game ($args)"
202+
msgstr ""
203+
204+
#, sh-format
205+
msgid "Warning: language is ignored when continuing a game ($args)"
206+
msgstr ""
207+
200208
msgid "Warning: the file 'treasure.sh' was sourced from a subshell.\n"
201209
"You should use the command\n"
202210
" $ gsh reset"

scripts/make_index

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,17 @@ make_index() {
115115
return 0
116116
fi
117117

118-
if [ "$#" -eq 1 ] && [ -f "$GSH_MISSIONS/$1" ]
118+
# when used from a self extracting archive, all path are prefixed with the
119+
# mission directory
120+
if [ -n "$GSH_EXEC_FILE" ]
119121
then
120-
# with a single file argument, we assume it is an index file
121-
parse_index "$GSH_MISSIONS/$1" || exit 1
122-
return 0
122+
PREFIX="$GSH_MISSIONS/"
123123
fi
124124

125125
# otherwise, parse each mission / index file from the arguments
126-
# (Note, it should not be used from a GameShell instance, but only directly
127-
# from ``start.sh`` or from ``utils/archive.sh``
128126
while [ "$#" -gt 0 ]
129127
do
130-
MISSION_DIR=$(readlink-f "$1")
128+
MISSION_DIR=$(readlink-f "$PREFIX$1")
131129
if [ -e "$MISSION_DIR" ]
132130
then
133131
parse_mission "$MISSION_DIR" || exit 1

start.sh

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ display_help() {
3838

3939

4040
# list of index files (default: only index.txt)
41-
export GSH_INDEX_FILES=index.txt # DO NOT CHANGE OR REMOVE THIS LINE, it is used by utils/archive.sh
41+
export GSH_INDEX_FILES=index.txt
4242

4343
# possible values: index, simple (default), overwrite
4444
export GSH_SAVEFILE_MODE="simple"
@@ -102,6 +102,13 @@ do
102102
;;
103103
L)
104104
export LANGUAGE="$OPTARG" # only works on GNU systems
105+
if [ "$RESET" = FALSE ]
106+
then
107+
args="-L $OPTARG"
108+
echo "$(eval_gettext 'Warning: language is ignored when continuing a game ($args)')" >&2
109+
echo "$(gettext 'Press Enter to continue.')" >&2
110+
read -r _
111+
fi
105112
;;
106113
G)
107114
export GSH_NO_GETTEXT=1
@@ -249,18 +256,40 @@ init_gsh() {
249256
# - continue the previous game
250257
if [ -e "$GSH_CONFIG" ]
251258
then
252-
if [ -z "$RESET" ]
253-
then
259+
260+
while [ -z "$RESET" ]
261+
do
254262
local r
255263
printf "$(eval_gettext 'The directory $GSH_CONFIG contains meta-data from a previous game.
256264
Do you want to remove it and start a new game? [y/N]') "
257265
read -r r
258-
[ "$r" = "$(gettext "y")" ] || [ "$r" = "$(gettext "Y")" ] || return 1
266+
if [ "$r" = "$(gettext "y")" ] || [ "$r" = "$(gettext "Y")" ]
267+
then
268+
RESET=TRUE
269+
echo
270+
fi
271+
if [ -z "$r" ] || [ "$r" = "$(gettext "n")" ] || [ "$r" = "$(gettext "N")" ]
272+
then
273+
RESET=FALSE
274+
echo
275+
fi
276+
done
259277

260-
elif [ "$RESET" = "FALSE" ]
278+
else
279+
# if no data is found, we need to initialize a new game
280+
RESET=TRUE
281+
fi
282+
283+
if [ "$RESET" = FALSE ]
284+
then
285+
if [ "$#" -gt 0 ]
261286
then
262-
return 1
287+
args=$*
288+
echo "$(eval_gettext 'Warning: command line arguments are ignored when continuing a game ($args)')" >&2
289+
echo "$(gettext 'Press Enter to continue.')" >&2
290+
read -r _
263291
fi
292+
return 1
264293
fi
265294

266295
### if we're here, we need to reset a new game

0 commit comments

Comments
 (0)