mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Fixed up zoom.rc, renamed it to zoom.gib. Made alias with only one
argument print the contents of that alias. Added the sleep command, which works like wait but pauses for a certain number of seconds.
This commit is contained in:
parent
69894d96c4
commit
6d37a9e48a
3 changed files with 68 additions and 33 deletions
|
@ -23,74 +23,74 @@
|
|||
// Boston, MA 02111-1307, USA
|
||||
|
||||
set zoom_version {$Id$}
|
||||
set zoom_base_sensitivity 10
|
||||
set zoom_base_amp 1
|
||||
set zoom_base_fov 90
|
||||
set zoom_mult 1.25
|
||||
set zoom_zoomed 0
|
||||
|
||||
set zoom_mult_lower 1.25
|
||||
set zoom_mult_upper 90 // This is more or less the hard limit
|
||||
set zoom_mult_step .25;
|
||||
set zoom_mult_step .25
|
||||
|
||||
alias zoom_init { // Initialize basic options
|
||||
if #{$argn != 6} {
|
||||
echo "Usage: $0 base_sensitivity base_fov min_zoom max_zoom zoom_step";
|
||||
return;
|
||||
echo "Usage: $0 base_sensitivity base_fov min_zoom max_zoom zoom_step"
|
||||
return
|
||||
}
|
||||
set zoom_base_sensitivity $1;
|
||||
set zoom_base_amp $1
|
||||
set zoom_base_fov $2
|
||||
set zoom_mult_lower $3;
|
||||
set zoom_mult $3;
|
||||
set zoom_mult_upper $4;
|
||||
set zoom_mult_step $5;
|
||||
set zoom_mult_lower $3
|
||||
set zoom_mult $3
|
||||
set zoom_mult_upper $4
|
||||
set zoom_mult_step $5
|
||||
}
|
||||
|
||||
alias zoom_mult { // "Accessor" for zoom_mult
|
||||
if #{!$1} return; // Prevent division by zero
|
||||
set zoom_mult $1;
|
||||
if #{!$1} return // Prevent division by zero
|
||||
set zoom_mult $1
|
||||
}
|
||||
|
||||
alias zoom_adjust { // Adjust fov and sensitivity to match zoom factor
|
||||
if $zoom_zoomed {
|
||||
set fov #{$zoom_base_fov/$zoom_mult};
|
||||
set in_mouse_amp #{$zoom_base_sensitivity/$zoom_mult};
|
||||
return;
|
||||
set fov #{$zoom_base_fov/$zoom_mult}
|
||||
set in_mouse_amp #{$zoom_base_amp/$zoom_mult}
|
||||
return
|
||||
} else {
|
||||
set fov $zoom_base_fov;
|
||||
set in_mouse_amp $zoom_base_sensitivity;
|
||||
};
|
||||
set fov $zoom_base_fov
|
||||
set in_mouse_amp $zoom_base_amp
|
||||
}
|
||||
}
|
||||
|
||||
alias zoom_in { // Replaced ID zoom function
|
||||
set zoom_zoomed 1;
|
||||
zoom_adjust;
|
||||
set zoom_zoomed 1
|
||||
zoom_adjust
|
||||
}
|
||||
|
||||
alias zoom_out { // Replaced ID zoom function
|
||||
set zoom_zoomed 0;
|
||||
zoom_adjust;
|
||||
set zoom_zoomed 0
|
||||
zoom_adjust
|
||||
}
|
||||
|
||||
alias zoom_toggle {
|
||||
toggle zoom_zoomed;
|
||||
zoom_adjust;
|
||||
toggle zoom_zoomed
|
||||
zoom_adjust
|
||||
}
|
||||
|
||||
alias zoom_increase {
|
||||
if #{!$zoom_zoomed} return;
|
||||
zoom_mult #{$zoom_mult + $zoom_mult_step*$zoom_mult};
|
||||
if #{!$zoom_zoomed} return
|
||||
zoom_mult #{$zoom_mult + $zoom_mult_step*$zoom_mult} // Grow zoom exponentially
|
||||
if #{$zoom_mult>$zoom_mult_upper} {
|
||||
zoom_mult $zoom_mult_upper;
|
||||
};
|
||||
zoom_adjust;
|
||||
zoom_mult $zoom_mult_upper
|
||||
}
|
||||
zoom_adjust
|
||||
}
|
||||
|
||||
alias zoom_decrease {
|
||||
if #{!$zoom_zoomed} return;
|
||||
zoom_mult #{$zoom_mult/(1 + $zoom_mult_step)};
|
||||
if #{!$zoom_zoomed} return
|
||||
zoom_mult #{$zoom_mult/(1 + $zoom_mult_step)}
|
||||
if #{$zoom_mult < $zoom_mult_lower} {
|
||||
zoom_mult $zoom_mult_lower;
|
||||
};
|
||||
zoom_adjust;
|
||||
zoom_mult $zoom_mult_lower
|
||||
}
|
||||
zoom_adjust
|
||||
}
|
||||
|
|
@ -70,6 +70,10 @@ typedef struct cmd_buffer_s {
|
|||
unsigned int loop; // Buffer loops itself. If true, value signifies number of loops done so far
|
||||
qboolean embedded; // Buffer exists to evaluate embedded command
|
||||
|
||||
// Sleep data
|
||||
double timeleft;
|
||||
double lasttime;
|
||||
|
||||
// Execution position
|
||||
enum {
|
||||
cmd_ready, // Ready to read a command
|
||||
|
|
|
@ -451,9 +451,20 @@ Cbuf_ExecuteBuffer (cmd_buffer_t *buffer)
|
|||
cmd_buffer_t *temp = cmd_activebuffer; // save old context
|
||||
int ret;
|
||||
|
||||
|
||||
if (buffer->timeleft) {
|
||||
double newtime = Sys_DoubleTime ();
|
||||
buffer->timeleft -= newtime - buffer->lasttime;
|
||||
buffer->lasttime = newtime;
|
||||
if (buffer->timeleft < 0.0)
|
||||
buffer->timeleft = 0.0;
|
||||
}
|
||||
if (buffer->timeleft)
|
||||
return;
|
||||
cmd_activebuffer = buffer;
|
||||
buffer->wait = false;
|
||||
buffer->again = false;
|
||||
|
||||
while (1) {
|
||||
if (!strlen(buffer->buffer->str) && buffer->position == cmd_ready) {
|
||||
if (buffer->loop) {
|
||||
|
@ -1893,6 +1904,11 @@ Cmd_Alias_f (void)
|
|||
s = Cmd_Argv (1);
|
||||
// if the alias already exists, reuse it
|
||||
alias = (cmdalias_t *) Hash_Find (cmd_alias_hash, s);
|
||||
if (Cmd_Argc () == 2) {
|
||||
if (alias)
|
||||
Sys_Printf("alias \"%s\" {%s}\n", alias->name, alias->value);
|
||||
return;
|
||||
}
|
||||
if (alias) {
|
||||
free ((char *) alias->value);
|
||||
} else {
|
||||
|
@ -1964,6 +1980,20 @@ Cmd_Wait_f (void)
|
|||
cur->wait = true;
|
||||
}
|
||||
|
||||
/* Pauses execution for a certain number of seconds */
|
||||
void
|
||||
Cmd_Sleep_f (void)
|
||||
{
|
||||
if (Cmd_Argc() != 2) {
|
||||
Cmd_Error ("sleep: invalid number of arguments.\n");
|
||||
return;
|
||||
}
|
||||
cmd_activebuffer->timeleft = (double)atof(Cmd_Argv(1));
|
||||
cmd_activebuffer->lasttime = Sys_DoubleTime ();
|
||||
Cmd_Wait_f ();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Prints a list of available commands */
|
||||
void
|
||||
Cmd_CmdList_f (void)
|
||||
|
@ -2319,6 +2349,7 @@ Cmd_Init (void)
|
|||
"seperate each command with a semi-colon.");
|
||||
Cmd_AddCommand ("unalias", Cmd_UnAlias_f, "Remove the selected alias");
|
||||
Cmd_AddCommand ("wait", Cmd_Wait_f, "Wait a game tic");
|
||||
Cmd_AddCommand ("sleep", Cmd_Sleep_f, "Sleep for $1 seconds");
|
||||
Cmd_AddCommand ("cmdlist", Cmd_CmdList_f, "List all commands");
|
||||
Cmd_AddCommand ("help", Cmd_Help_f, "Display help for a command or "
|
||||
"variable");
|
||||
|
|
Loading…
Reference in a new issue