quakeforge/doc/config/gib/zoom.gib

107 lines
2.2 KiB
Text
Raw Normal View History

// zoom.gib
2002-04-29 01:41:07 +00:00
//
// zoom script for GIB in QuakeForge 0.5.3
2002-04-29 01:41:07 +00:00
//
// Copyright (C) 2002,2003 Brian Koropoff
2002-04-29 01:41:07 +00:00
//
// 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 2
// 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, write to:
//
// Free Software Foundation, Inc.
// 59 Temple Place - Suite 330
// Boston, MA 02111-1307, USA
//
// $Id$
2002-04-29 01:41:07 +00:00
domain zoom
global amp
global fov
global min
global max
global step
global mult
global zoomed
// clamp returns the second argument clamped
// between the first and second
function clamp {
if ($args[2] < $args[1]) {
return $args[1]
} else if ($args[2] > $args[3]) {
return $args[3]
} else return $args[2]
}
2002-04-29 01:41:07 +00:00
function zoom::init { // Initialize basic options
if (#args != 6) {
print "Usage: ", $args[0], " base_amp base_fov min_zoom max_zoom zoom_step\n"
return
2002-04-29 01:41:07 +00:00
}
amp = $args[1]
fov = $args[2]
min = $args[3]
max = $args[4]
step = $args[5]
mult = $min
zoomed = 0
set fov $fov
set in_amp $amp
2002-04-29 01:41:07 +00:00
}
// Default initial values
zoom::init 1 90 1.15 90 1.15
function zoom::adjust { // Adjust fov and sensitivity to match zoom factor
if $zoomed {
set fov ($fov/$mult)
set in_amp ($amp/$mult)
2002-04-29 01:41:07 +00:00
} else {
set fov $fov
set in_amp $amp
}
2002-04-29 01:41:07 +00:00
}
function zoom::in {
zoomed = 1
zoom::adjust
2002-04-29 01:41:07 +00:00
}
function zoom::out {
zoomed = 0
zoom::adjust
2002-04-29 01:41:07 +00:00
}
function zoom::toggle {
zoomed = (!$zoomed)
zoom::adjust
2002-04-29 01:41:07 +00:00
}
function zoom::increase {
if (!$zoomed) {
return
}
mult = `cap $min ($mult*$step) $max`
zoom::adjust
2002-04-29 01:41:07 +00:00
}
function zoom::decrease {
if (!$zoomed) {
return
}
mult = `cap $min ($mult/$step) $max`
zoom::adjust
2002-04-29 01:41:07 +00:00
}
function::export zoom::init zoom::increase zoom::decrease zoom::in zoom::out zoom::toggle