2002-08-23 21:18:00 +00:00
|
|
|
// zoom.gib
|
2002-04-29 01:41:07 +00:00
|
|
|
//
|
2003-01-31 00:12:04 +00:00
|
|
|
// zoom script for GIB in QuakeForge 0.5.3
|
2002-04-29 01:41:07 +00:00
|
|
|
//
|
2003-01-31 00:12:04 +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
|
2002-08-14 05:28:07 +00:00
|
|
|
//
|
|
|
|
// $Id$
|
2002-04-29 01:41:07 +00:00
|
|
|
|
2003-01-31 00:12:04 +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
|
|
|
|
2002-11-11 01:57:34 +00:00
|
|
|
function zoom::init { // Initialize basic options
|
2003-01-31 00:12:04 +00:00
|
|
|
if (#args != 6) {
|
|
|
|
print "Usage: ", $args[0], " base_amp base_fov min_zoom max_zoom zoom_step\n"
|
2002-05-11 06:09:50 +00:00
|
|
|
return
|
2002-04-29 01:41:07 +00:00
|
|
|
}
|
2003-01-31 00:12:04 +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
|
|
|
}
|
|
|
|
|
2002-08-23 21:18:00 +00:00
|
|
|
// Default initial values
|
2003-01-31 00:12:04 +00:00
|
|
|
zoom::init 1 90 1.15 90 1.15
|
2002-08-22 20:50:12 +00:00
|
|
|
|
2002-11-11 01:57:34 +00:00
|
|
|
function zoom::adjust { // Adjust fov and sensitivity to match zoom factor
|
2003-01-31 00:12:04 +00:00
|
|
|
if $zoomed {
|
|
|
|
set fov ($fov/$mult)
|
|
|
|
set in_amp ($amp/$mult)
|
2002-04-29 01:41:07 +00:00
|
|
|
} else {
|
2003-01-31 00:12:04 +00:00
|
|
|
set fov $fov
|
|
|
|
set in_amp $amp
|
2002-05-11 06:09:50 +00:00
|
|
|
}
|
2002-04-29 01:41:07 +00:00
|
|
|
}
|
|
|
|
|
2002-11-11 01:57:34 +00:00
|
|
|
function zoom::in {
|
2003-01-31 00:12:04 +00:00
|
|
|
zoomed = 1
|
2002-11-11 01:57:34 +00:00
|
|
|
zoom::adjust
|
2002-04-29 01:41:07 +00:00
|
|
|
}
|
|
|
|
|
2002-11-11 01:57:34 +00:00
|
|
|
function zoom::out {
|
2003-01-31 00:12:04 +00:00
|
|
|
zoomed = 0
|
2002-11-11 01:57:34 +00:00
|
|
|
zoom::adjust
|
2002-04-29 01:41:07 +00:00
|
|
|
}
|
|
|
|
|
2002-11-11 01:57:34 +00:00
|
|
|
function zoom::toggle {
|
2003-01-31 00:12:04 +00:00
|
|
|
zoomed = (!$zoomed)
|
2002-11-11 01:57:34 +00:00
|
|
|
zoom::adjust
|
2002-04-29 01:41:07 +00:00
|
|
|
}
|
|
|
|
|
2002-11-11 01:57:34 +00:00
|
|
|
function zoom::increase {
|
2003-01-31 00:12:04 +00:00
|
|
|
if (!$zoomed) {
|
2002-08-22 20:50:12 +00:00
|
|
|
return
|
2002-05-11 06:09:50 +00:00
|
|
|
}
|
2003-01-31 00:12:04 +00:00
|
|
|
mult = `cap $min ($mult*$step) $max`
|
2002-11-11 01:57:34 +00:00
|
|
|
zoom::adjust
|
2002-04-29 01:41:07 +00:00
|
|
|
}
|
|
|
|
|
2002-11-11 01:57:34 +00:00
|
|
|
function zoom::decrease {
|
2003-01-31 00:12:04 +00:00
|
|
|
if (!$zoomed) {
|
|
|
|
return
|
2002-05-11 06:09:50 +00:00
|
|
|
}
|
2003-01-31 00:12:04 +00:00
|
|
|
mult = `cap $min ($mult/$step) $max`
|
2002-11-11 01:57:34 +00:00
|
|
|
zoom::adjust
|
2002-04-29 01:41:07 +00:00
|
|
|
}
|
|
|
|
|
2002-11-11 01:57:34 +00:00
|
|
|
function::export zoom::init zoom::increase zoom::decrease zoom::in zoom::out zoom::toggle
|