/usr/games/freesci-setup is in freesci 0.6.4-7.2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/usr/bin/wish
#################################################################################
# #
# Freesci-setup, a GUI for FreeSci's configuration file #
# Copyright (C) 2001 Rune Orsval, fixed by Vyacheslav Dikonov #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of version 2 of the GNU General Public License as #
# published by the Free Software Foundation. #
# #
# 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, write to the Free Software #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #
# #
#################################################################################
set configfiles "~/.freesci/config.template /usr/share/freesci/config.template /usr/share/games/freesci/config.template"
wm title . "FreeSci configuration"
proc new_game {} {
global games configuration currentgame name
toplevel .newgame
label .newgame.label -text "New game name:"
entry .newgame.entry -textvariable name
frame .newgame.buttonframe
button .newgame.buttonframe.ok -text Ok -command {
set name [string map {\ _} $name]
if {$name != "" && [lsearch $games $name] == -1} {
lappend games $name
setdefault $name
set currentgame $name
}
set name [string map {_ \ } $name]
destroy .newgame
}
button .newgame.buttonframe.cancel -text Cancel -command {destroy .newgame}
pack .newgame.label .newgame.entry .newgame.buttonframe -padx 12 -pady 4
pack .newgame.buttonframe.ok .newgame.buttonframe.cancel -side left
grab set .newgame
focus .newgame.entry
bind .newgame <Return> {.newgame.buttonframe.ok invoke}
tkwait window .newgame
}
proc show_help {option} {
global template
toplevel .help
wm title .help "FreeSci configuration help - $option"
message .help.msg -aspect 400 -text $template($option,help)
pack .help.msg -padx 8 -pady 2
button .help.ok -text "Ok" -command {destroy .help}
pack .help.ok -pady 4
grab .help
tkwait window .help
}
proc show_about {} {
toplevel .about
wm title . "About FreeSci configuration"
message .about.msg -aspect 400 -text "FreeSCI-Setup - a graphical configuration tool for FreeSci written by Rune Orsval.\n\nThis program is distributed under GNU General Public license version 2"
pack .about.msg -padx 8 -pady 2
button .about.ok -text "Ok" -command {destroy .about}
pack .about.ok -pady 4
grab .about
tkwait window .about
}
proc saveit {} {
global env games options template configuration
set f [open $env(HOME)/.freesci/config w]
foreach game $games {
if [string compare "$game" "Global"] {
set printgame 1
} else {
set printgame 0
}
foreach option $options {
if $configuration($game,$option,selected) {
if $printgame {
puts $f ""
puts $f "\[$game\]"
set printgame 0
}
if {$configuration($game,$option,value) != ""} {
puts $f "$option=$configuration($game,$option,value)"
}
}
}
}
close $f
}
# Read config.template #
set options ""
set area all
set f ""
foreach filename $configfiles {
if [file exists $filename] {
set f [open $filename r]
break
}
}
if {$f == ""} {
puts "Can't find config.template"
exit 1
}
while {![eof $f]} {
gets $f line
if [string match {\[*\]} $line] {
scan $line {[%[^]]]} area
} elseif [string match {\{*} $line] {
set help ""
if [string match {\{*\}} $line] {
append template($option,help) [string trim $line {\{\}}]
} else {
set line [string trimleft $line {\{}]
while {![string match {*\}} $line]} {
append template($option,help) $line " "
gets $f line
}
append template($option,help) [string trimright $line {\}}]
}
} else {
set indx [string first {=} $line]
set option [string range $line 0 [expr $indx-1]]
set option [string trim $option]
set options [concat $options $option]
set template($option,values) ""
set template($option,help) ""
set template($option,area) $area
set line [string range $line [expr $indx+1] end]
if ![string compare [string trim $line] <text>] {
set template($option,values) {}
set template($option,type) text
} else {
while {[string length $line]} {
set indx [string first {|} $line]
if {$indx<0} {
set indx [string length $line]
}
set value [string trim [string range $line 0 [expr $indx-1]]]
set line [string range $line [expr $indx+1] end]
lappend template($option,values) $value
set template($option,type) option
}
}
}
}
close $f
proc setdefault {game} {
global template options configuration
foreach option $options {
set configuration($game,$option,selected) 0
switch $template($option,type) {
option {
# puts $template($option,values)
set configuration($game,$option,value) [lindex $template($option,values) 0]
}
text {
set configuration($game,$option,value) ""
}
}
}
}
# Read ~/.freesci/config #
set path $env(HOME)/.freesci
if ![file isdirectory $path] {
file mkdir $path
}
if [file exists $path/config] {
set f [open $path/config r]
set game Global
set games $game
setdefault $game
while {![eof $f]} {
gets $f line
if [string match {*=*} $line] {
scan $line {%[^=]=%[^=]} a b
set option [string trim $a]
set configuration($game,$option,selected) 1
set configuration($game,$option,value) [string trim $b]
} elseif [string match {\[*\]} $line] {
scan $line {[%[^]]]} game
lappend games $game
setdefault $game
}
}
close $f
} else {
set game Global
set games $game
setdefault $game
}
menu .m -tearoff 0
menu .m.file -tearoff 1
.m add cascade -label "File" -menu .m.file
.m.file add command -label "Save" -accelerator "(C-x C-s)" -command {saveit}
bind . <Control-x><Control-s> {saveit}
.m.file add command -label "New game" -command {new_game}
.m.file add command -label "Quit" -command {exit} -accelerator "(C-x C-c)"
bind . <Control-x><Control-c> exit
menu .m.help -tearoff 1
.m add cascade -label "Help" -menu .m.help
.m.help add command -label "About" -command {show_about}
.m.help add separator
foreach option $options {
if [string length $template($option,help)] {
.m.help add command -label [string totitle [string map {_ \ } $option]] -command "show_help $option"
}
}
. configure -menu .m
set currentgame Global
while {1} {
frame .main
pack .main
frame .main.games
pack .main.games -padx 4 -pady 4 -anchor w -in .main
label .main.games.gamelabel -text "Choose game or global settings:"
pack .main.games.gamelabel -side top -anchor w -in .main.games
set incol 3
foreach i $games {
if "$incol == 3" {
frame .main.games.fr$i
pack .main.games.fr$i -side left -anchor n -pady 2 -in .main.games
set currentframe .main.games.fr$i
set incol 1
} else {
set incol [expr $incol + 1]
}
radiobutton .main.games.rb$i -text [string map {_ " "} $i ] -variable currentgame -value $i
pack .main.games.rb$i -in $currentframe -anchor w
}
frame .main.options -relief groove -borderwidth 4
pack .main.options -padx 4 -pady 4 -in .main
frame .main.options.optionlabelframe
pack .main.options.optionlabelframe -side top -anchor w -in .main.options
label .main.options.varoptionlabel -text [string map {_ \ } $currentgame]
label .main.options.optionlabel -text options:
pack .main.options.varoptionlabel .main.options.optionlabel -side left -in .main.options.optionlabelframe
set incol 16
set c 0
set r 0
foreach i $options {
if [string compare Global $currentgame]||![string compare all $template($i,area)] {
if "$incol == 16" {
set c [expr $c + 1]
frame .main.options.cf$c
pack .main.options.cf$c -side left -anchor n -padx 4 -pady 2 -in .main.options
set currentframe .main.options.cf$c
set incol 1
} else {
set incol [expr $incol + 1]
}
set r [expr $r + 1]
frame $currentframe.fr$r
pack $currentframe.fr$r -in $currentframe -fill x
checkbutton $currentframe.cb$r -text [string totitle [string map {_ \ } $i]] -variable configuration($currentgame,$i,selected)
pack $currentframe.cb$r -in $currentframe.fr$r -side left
if [string compare $template($i,type) text] {
eval tk_optionMenu $currentframe.op$r configuration($currentgame,$i,value) $template($i,values)
pack $currentframe.op$r -in $currentframe.fr$r -side right
} else {
entry $currentframe.op$r -textvariable configuration($currentgame,$i,value)
pack $currentframe.op$r -in $currentframe.fr$r -side right -pady 4
}
}
}
tkwait variable currentgame
destroy .main
}
tkwait window .
exit
|