summaryrefslogtreecommitdiff
path: root/games/falcons-eye/patches/patch-bf
blob: cdbfcb605b6ae246fb6bcf18336c189b28f1af18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
$NetBSD: patch-bf,v 1.1.1.1 2002/01/21 11:56:18 pooka Exp $

--- /dev/null	Sun Dec  2 19:51:52 2001
+++ src/fe-config.in	Wed Nov 28 12:19:38 2001
@@ -0,0 +1,463 @@
+#!/bin/ksh
+fe_prefix=XXXPREFIXXXX
+fe_config="${fe_prefix}/share/falcons-eye-dir/config/jtp_opts.txt"
+fe_output=""
+if [ ! -f "$fe_config" ]
+then
+	touch "$fe_config"
+	if [ $? -ne 0 ]
+	then
+		echo "Cannot find nor create $fe_config..."
+		exit 1
+	fi
+fi
+settings=$(grep '^[^%].*=' "$fe_config"|sed 's/=\(.*\)/="\1"/')
+orig_settings=$(echo "$settings"|sed 's/^/orig_/')
+variables="screen_xsize screen_ysize fullscreen play_music play_effects
+	linux_midi_player linux_mp3_player wall_style recenter_after_movement
+	one_command_per_click scroll_delay command_delay gamma_correction"
+eval "$settings"
+eval "$orig_settings"
+
+function __menu
+{
+	choices=$(echo "$2"|sed 's/\^/\
+/g')
+	max=$(echo "$choices"|wc -l)
+	title=$(echo "$1"|sed 's/_/ /g')
+	underline=$(echo "$title"|sed 's/./=/g')
+	ps=$(echo "$choices"|pr -n\	1|grep '	')
+	ps=$(echo -e "\n\n$title\n$underline\n\n$ps\n\nPlease choose> ")
+	input=""
+	while [ "$input" -lt 1 -o "$input" -gt "$max" ]
+	do
+		clear
+		read input?"$ps"
+		input=$(echo "$input"|cut -c 1)
+	done
+	choice=$(echo "$choices"|head -n +$input|tail -n 1|cut -d ' ' -f 1)
+	if [ "$choice" != "return" ]
+	then
+		${choice}_menu ${choice}
+		return 1
+	fi
+	return 0
+}
+
+function do_toggle
+{
+	toggle_value=$(eval echo \$$1)
+	if [ "$toggle_value" -eq 1 ]
+	then
+		eval $1=0
+	else
+		eval $1=1
+	fi
+}
+
+function read_value
+{
+	rmin="$1"
+	rps="$2"
+	rvalue=$(($min-1))
+	while [ "$rvalue" -lt "$rmin" ]
+	do
+		read rvalue?"$rps"
+		rvalue=$(echo "$rvalue"|sed 's/^\([0-9]*\).*/\1/')
+	done
+	return $rvalue
+}
+
+read_float_value_return=0
+function read_float_value
+{
+	rmin="$1"
+	rmax="$2"
+	rps="$3"
+	rvalue=$(echo "$rmin-1"|bc)
+	while [ "$(echo \"$rvalue<$rmin\"|bc)" -eq 1 -o \
+		"$(echo \"$rvalue>$rmax\"|bc)" -eq 1 ]
+	do
+		read rvalue?"$rps"
+	done
+	rvalue=$(echo "$rvalue"|sed 's/^\./0./')
+	read_float_value_return="$rvalue"
+}
+
+function find_line
+{
+	return $(grep -n "^$1=" "$fe_output"|head -1|cut -d : -f 1)
+}
+
+function find_commented_line
+{
+	return $(grep -n "^%$1=" "$fe_output"|head -1|cut -d : -f 1)
+}
+
+function edit_replace_line
+{
+	echo -e "$1\nd\ni\n$2\n.\nwq\n" | ed "$fe_output" >/dev/null 2>&1
+	return $?
+}
+
+function edit_insert_line
+{
+	echo -e "$1\ni\n$2\n.\nwq\n" | ed "$fe_output" >/dev/null 2>&1
+	return $?
+}
+
+function edit_append_line
+{
+	echo "$1" >>"$fe_output"
+	return $?
+}
+
+function save_changes
+{
+	retval=0
+	for var in $variables
+	do
+		value=$(eval echo \$$var)
+		if [ "$value" != "$(eval echo \$orig_$var)" ]
+		then
+			find_line "$var"
+			line=$?
+			if [ $line -gt 1 ]
+			then
+				edit_replace_line $line "$var=$value"
+				result=$?
+			else
+				find_commented_line "$var"
+				line=$?
+				if [ $line -gt 1 ]
+				then
+					edit_insert_line $line "$var=$value"
+					result=$?
+				else
+					edit_append_line "$var=$value"
+					result=$?
+				fi
+			fi
+			if [ $result -ne 0 ]
+			then
+				retval=$result
+			fi
+		fi
+	done
+	return $retval
+}
+
+function use_tmp_menu
+{
+	fe_output=$(mktemp /tmp/jtp_opts.txt.XXXXXX)
+	cp "$fe_config" "$fe_output"
+}
+
+function use_home_menu
+{
+	fe_output=$(mktemp $HOME/jtp_opts.txt.XXXXXX)
+	cp "$fe_config" "$fe_output"
+}
+
+function use_default_path_menu
+{
+	fe_output="$fe_config"
+}
+
+function save_changes_menu
+{
+	__menu "$1" "use_default_path : $fe_config^use_tmp : write config file to /tmp^use_home : write config file to $HOME"
+	save_changes
+	if [ $? -ne 0 ]
+	then
+		echo -e "Error writing ${fe_output}...\nPress enter...\n"
+		read pause
+	else
+		echo -e "Finished writing ${fe_output}...\n"
+		if [ "$fe_output" != "$fe_config" ]
+		then
+			echo "To use new config:"
+			echo "	cp ${fe_output} ${fe_config}"
+		fi
+		exit
+	fi
+}
+
+function quit_without_saving_menu
+{
+	exit
+}
+
+function have_settings_changed
+{
+	changed=0
+	for var in $variables
+	do
+		if [ "$(eval echo \$$var)" != "$(eval echo \$orig_$var)" ]
+		then
+			changed=1
+		fi
+	done
+	return $changed
+}
+
+function exit_menu
+{
+	have_settings_changed
+	if [ $? -eq 0 ]
+	then
+		exit
+	fi
+	__menu "$1" "save_changes^quit_without_saving"
+}
+
+function print_sound_warning
+{
+	if [ "$play_effects" -eq 1 ]
+	then
+		cat <<__EOF__
+
+You have sound effects turned on.  Falcon's Eye Nethack uses SDL to play
+sound effects, and SDL is configured to directly use /dev/audio.  The
+result is a conflict with external players that open /dev/audio.
+
+So you either can have musical scores played by mpg123 and timidity,
+or you can have sound effects.
+
+__EOF__
+	fi
+}
+
+function pick_player
+{
+	player_path="XXXPREFIXXXX/bin/$1"
+	"$1" >/dev/null 2>&1
+	if [ $? -ne 127 ]
+	then
+		player_path=$(which $1)
+	fi
+
+	looping=1
+	while [ "$looping" -eq 1 ]
+	do
+		print_sound_warning
+		echo "Example:"
+		echo "	$player_path $2 %s"
+		echo -n "Please enter command to play $3 files> "
+		read $4
+		player_value=$(echo $(eval echo \$$4)|cut -d ' ' -f 1)
+		if [ ! -x "$player_value" ]
+		then
+			if [ "$player_value" = "" ]
+			then
+				looping=0
+			else
+				echo "Error: cannot execute $player_value"
+			fi
+		else
+			looping=0
+		fi
+	done
+}
+
+function pick_mp3_player_menu
+{
+	pick_player mpg123 "-q" "MP3" "linux_mp3_player"
+}
+
+function manual_enter_midi_player_menu
+{
+	pick_player timidity "-idqq" "MIDI" "linux_midi_player"
+}
+
+function midiplay_menu
+{
+	midi_port=99
+	max=$(midiplay -l|tail -1|cut -d : -f 1)
+	while [ "$midi_port" -lt 0 -o "$midi_port" -gt "$max" ]
+	do
+		echo ""
+		echo "MIDI ports"
+		echo "=========="
+		echo ""
+		midiplay -l
+		echo ""
+		read midi_port?"Please pick MIDI port> "
+		midi_port=$(echo "$midi_port"|cut -c 1)
+	done
+	if [ "$midi_port" -gt 0 ]
+	then
+		linux_midi_player="/usr/bin/midiplay -d$midi_port %s"
+	else
+		linux_midi_player="/usr/bin/midiplay %s"
+	fi
+}
+
+function pick_midi_player_menu
+{
+	looping=1
+	while [ "$looping" -eq 1 ]
+	do
+		midiplay -l >/dev/null 2>&1
+		if [ $? -ne 127 ]
+		then
+			menu_string="midiplay^"
+		else
+			menu_string=""
+		fi
+		menu_string="${menu_string}manual_enter_midi_player : \"$linux_midi_player\"^return to previous menu"
+		__menu "$1" "$menu_string"
+		looping=$?
+	done
+}
+
+function pick_players_menu
+{
+	looping=1
+	while [ "$looping" -eq 1 ]
+	do
+		__menu "$1" "pick_midi_player : \"$linux_midi_player\"^pick_mp3_player : \"$linux_mp3_player\"^return to previous menu"
+		looping=$?
+	done
+}
+
+function music_menu
+{
+	do_toggle play_music
+}
+
+function sound_effects_menu
+{
+	do_toggle play_effects
+}
+
+function audio_settings_menu
+{
+	looping=1
+	while [ "$looping" -eq 1 ]
+	do
+		menu_string="sound_effects : $play_effects^music : $play_music"
+		menu_string=$(echo "$menu_string"|sed -e 's/: 1/: on/g' -e 's/: 0/: off/g')
+		if [ "$play_music" -eq 1 ]
+		then
+			menu_string="${menu_string}^pick_players"
+		fi
+
+		__menu "$1" "${menu_string}^return to previous menu"
+		looping=$?
+	done
+}
+
+function fullscreen_menu
+{
+	do_toggle fullscreen
+}
+
+function screen_xsize_menu
+{
+	read_value 800 "Please enter x size (minimum 800) -> "
+	screen_xsize=$?
+}
+
+function screen_ysize_menu
+{
+	read_value 600 "Please enter y size (minimum 600) -> "
+	screen_ysize=$?
+}
+
+function gamma_correction_menu
+{
+	read_float_value 0 2 "Please enter gamma correction (dark 0.0 - light 2.0) -> "
+	gamma_correction="$read_float_value_return"
+}
+
+function wall_style_full_menu
+{
+	wall_style="full"
+}
+
+function wall_style_half_height_menu
+{
+	wall_style="half_height"
+}
+
+function wall_style_transparent_menu
+{
+	wall_style="transparent"
+}
+
+function wall_style_menu
+{
+	__menu "$1" "wall_style_full^wall_style_half_height^wall_style_transparent"
+}
+
+function video_settings_menu
+{
+	looping=1
+	while [ "$looping" -eq 1 ]
+	do
+		menu_string="fullscreen : $fullscreen^screen_xsize : \"$screen_xsize\"^screen_ysize : \"$screen_ysize\"^wall_style : \"$wall_style\"^gamma_correction : \"$gamma_correction\"^return to previous menu"
+		menu_string=$(echo "$menu_string"|sed -e 's/: 1/: on/g' -e 's/: 0/: off/g')
+		__menu "$1" "$menu_string"
+		looping=$?
+	done
+}
+
+function recenter_after_movement_menu
+{
+	do_toggle recenter_after_movement
+}
+
+function one_command_per_click_menu
+{
+	do_toggle one_command_per_click
+}
+
+function scroll_delay_menu
+{
+	read_float_value 0 10 "Please enter scroll delay (0 - 10 seconds) -> "
+	scroll_delay="$read_float_value_return"
+}
+
+function command_delay_menu
+{
+	read_float_value 0 10 "Please enter command delay (0 - 10 seconds) -> "
+	command_delay="$read_float_value_return"
+}
+
+function interface_settings_menu
+{
+	looping=1
+	while [ "$looping" -eq 1 ]
+	do
+		menu_string="recenter_after_movement : $recenter_after_movement^one_command_per_click : $one_command_per_click^scroll_delay : \"$scroll_delay\"^command_delay : \"$command_delay\"^return to previous menu"
+		menu_string=$(echo "$menu_string"|sed -e 's/: 1/: on/g' -e 's/: 0/: off/g')
+		__menu "$1" "$menu_string"
+		looping=$?
+	done
+}
+
+function about_menu
+{
+	less -d <<__EOF__
+This script generates a configuration file for falcon's eye nethack.
+Some assumptions are made by this script, for example, that you are
+running NetBSD, and that you do not have multiple sound cards.
+__EOF__
+	main_menu
+}
+
+function view_config_file_menu
+{
+	less -d "$fe_config"
+}
+
+function main_menu
+{
+	__menu "main" "about^audio_settings^video_settings^interface_settings^view_config_file^exit"
+}
+
+while :
+do
+	main_menu
+done