-
Notifications
You must be signed in to change notification settings - Fork 6
/
roguepc-xterm
executable file
·165 lines (143 loc) · 4.88 KB
/
roguepc-xterm
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
#!/bin/bash
#
# roguepc-xterm - XTerm customization for roguepc
#
# Copyright (C) 2015 Rodrigo Silva (MestreLion) <[email protected]>
#
# 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. See <http://www.gnu.org/licenses/gpl.html>
#
# Launches the game in a new, customized xterm window
# default options
fullscreen=0
fontsize=24
columns=80
linechars=0
border=0
fg=gray
bg=black
term=xterm-256color
title='Rogue PC'
fontname='Perfect DOS VGA 437 Unicode'
here=$(dirname "$(readlink -f "$0")")
rogueargs=()
gamecmd=
for cmd in "$here"/src/rogue{-sdl,-ascii,}; do
if [[ -x "$cmd" ]]; then gamecmd=$cmd; break; fi
done
usage() {
echo "Launch Rogue PC in a new, customized Xterm window"
echo "Usage: ${0##.*/} [-h]" \
"[-f|--full[-]screen]" \
"[-l|--line-chars]" \
"[-b|--border]" \
"[-r|--rogue CMD|PATH]" \
"[-fs|--font-size SIZE]" \
"[--] [roguepc args]"
exit
}
# Pre-parse for `help`
for arg in "$@"; do [[ "$arg" == "-h" || "$arg" == "--help" ]] && usage ; done
while (( $# )); do
case "$1" in
-f|--full-screen|--fullscreen) fullscreen=1;;
-l|--line-chars ) linechars=1;;
-b|--border ) border=1;;
-r|--rogue ) shift; gamecmd=$1;;
--rogue=* ) gamecmd=${1#*=};;
# -c |--columns ) shift ; columns="$1";;
# --columns=* ) columns="${1#*=}";;
-fs|--font-size ) shift ; fontsize="$1";;
--font-size=*) fontsize="${1#*=}";;
--) shift; rogueargs+=( "$@" ); break;;
-*) echo "invalid option: $1" >&2; exit 1;;
*) rogueargs+=( "$1" );;
esac
shift
done
rogueargs+=("$@")
if [[ -z "$gamecmd" ]]; then
echo "No game found, use ${0##.*/} --rogue to set the executable" >&2
exit 1
fi
# XTerm options
# -uc
# Makes the cursor underlined instead of a box.
#
# Just like DOS :)
# -bc
# Turn on text cursor blinking.
#
# Annoying, but faithful to original
# -b 0
# Specifies the size of the inner border
#
# No border by default, just like DOSBox ;)
# +bdc
# Display characters with bold attribute as color rather than bold.
#
# Not really needed, as bold is not used under 256 color mode set by `-tn`.
# +fbx
# Assume that the normal and bold fonts have VT100 line-drawing characters.
#
# This improves the resolution and disable color AA of line and box drawing
# chars such as U+2592 "▒", used in Rogue for passages, mazes, curtain and zoom
# animations. It enhances their visual display and also make sure they nicely
# connect vertically and horizontaly regadless of the True Type font size.
# On the other hand, this is an enchancement not in original Rogue, so it's
# disabled by default.
# -fa 'Perfect DOS VGA 437 Unicode'
# Specifies the pattern for the font selected from the FreeType library.
#
# Selecting the custom DOS 437 font with IBM VGA glyphs.
# -geometry 80x25
# Specifies the preferred size and position of the VT102 window.
#
# Rogue default size is 80x25, and it also has a 40x25 mode. Currently columns
# are a compile-time option, so for now it's set to 80.
# -fs 24
# Sets the pointsize for fonts selected from the FreeType library
#
# Current custom font requires a multiple of 3 for best results, 12 for 1:1
# matching. 24 satisfies both and is large enough to look great while still
# fitting a 1280x800 screen. 30 is the largest good-looking size to fit a
# Full HD 1920x1080 monitor
# -title 'Rogue PC'
# Specifies the window title string, (...) the default is the command line
# specified after the -e option, if any.
#
# "Rogue PC" is better than "rogue", "roguepc" or "xterm"
# -tn 'xterm-256color'
# Specifies the name of the terminal type to be set in the TERM environment
# variable. (...) This terminal type must exist in the terminal database.
# (...) If the terminal type is not found, xterm uses the built-in list
# “xterm”, “vt102”, etc.
#
# Enable 256 colors.
# -fg gray
# Specifies the color to use for displaying text
#
# xterm default usually is white
# -bg black
# Specifies the color to use for the background of the window
#
# xterm default usually is already black
xtargs=(-uc -bc +bdc -title "$title" -tn "$term" -fg "$fg" -bg "$bg"
-fa "$fontname")
if ((fullscreen)); then xtargs+=(-fullscreen); fi
if ((linechars)); then xtargs+=(+fbx); fi
if !((border)); then xtargs+=(-b 0); fi
xtargs+=(-fs "$fontsize")
xtargs+=(-geometry "$columns"x25)
cd -- "$(dirname "$(readlink -f "$gamecmd")")" &&
xterm "${xtargs[@]}" -e "$gamecmd" "${rogueargs[@]}"