diff --git a/doc/config/zoom.gib b/doc/config/zoom.gib index a31c85c5f..1c34d6136 100644 --- a/doc/config/zoom.gib +++ b/doc/config/zoom.gib @@ -42,47 +42,58 @@ function "zoom.init" { // Initialize basic options set in_amp ${zoom.amp} } +zoom.init 1 90 1 90 1.15 + function "zoom.adjust" { // Adjust fov and sensitivity to match zoom factor if ${zoom.zoomed} { set fov (${zoom.fov}/${zoom.mult}) set in_amp (${zoom.amp}/${zoom.mult}) return } else { - set fov $zoom_base_fov - set in_amp $zoom_base_amp + set fov ${zoom.fov} + set in_amp ${zoom.amp} } } -alias zoom_in { // Replaced ID zoom function - set zoom_zoomed 1 - zoom_adjust +function "zoom.in" { // Replaced ID zoom function + zoom.zoomed = 1 + zoom.adjust } -alias zoom_out { // Replaced ID zoom function - set zoom_zoomed 0 - zoom_adjust +function "zoom.out" { // Replaced ID zoom function + zoom.zoomed = 0 + zoom.adjust } -alias zoom_toggle { - toggle zoom_zoomed - zoom_adjust +function "zoom.toggle" { + zoom.zoomed = (!${zoom.zoomed}) + zoom.adjust } -alias zoom_increase { - 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 +function "zoom.increase" { + ifnot ${zoom.zoomed} { + return } - zoom_adjust -} - -alias zoom_decrease { - if #{!$zoom_zoomed} return - zoom_mult #{$zoom_mult/(1 + $zoom_mult_step)} - if #{$zoom_mult < $zoom_mult_lower} { - zoom_mult $zoom_mult_lower + zoom.mult = (${zoom.mult.step}*${zoom.mult}) + if (${zoom.mult} > ${zoom.mult.upper}) { + zoom.mult = ${zoom.mult.upper} } - zoom_adjust + zoom.adjust } +function "zoom.decrease" { + ifnot ${zoom.zoomed} return + zoom.mult = (${zoom.mult}/(1 + ${zoom.mult.step})) + if (${zoom.mult} < ${zoom.mult.lower}) { + zoom.mult = ${zoom.mult.lower} + } + zoom.adjust +} + +export zoom.init +export zoom.increase +export zoom.decrease +export zoom.in +export zoom.out +export zoom.toggle + diff --git a/libs/util/gib_parse.c b/libs/util/gib_parse.c index 11cc74ded..d6ac5ecfe 100644 --- a/libs/util/gib_parse.c +++ b/libs/util/gib_parse.c @@ -205,9 +205,10 @@ GIB_Parse_Extract_Line (struct cbuf_s *cbuf) break; else if (dstr->str[i] == '/' && dstr->str[i+1] == '/') { char *n; - if ((n = strchr (dstr->str+i, '\n'))) - dstring_snip (dstr, i, n-dstr->str); - else { + if ((n = strchr (dstr->str+i, '\n'))) { + dstring_snip (dstr, i, n-dstr->str-i); + i--; + } else { dstring_snip (dstr, i, strlen(dstr->str+i)); break; } @@ -451,10 +452,18 @@ void GIB_Parse_Execute_Line (cbuf_t *cbuf) else if ((f = GIB_Function_Find (args->argv[0]->str))) GIB_Function_Execute (f); else if (args->argc == 3 && !strcmp (args->argv[1]->str, "=")) { - if (!GIB_Var_Get (cbuf, args->argv[0]->str) && GIB_Var_Get_R (gib_globals, args->argv[0]->str)) - GIB_Var_Set_R (gib_globals, args->argv[0]->str, args->argv[2]->str); + // First, determine global versus local + int glob = 0; + char *c = 0; + if ((c = strchr (args->argv[0]->str, '.'))) // Only check stem + *c = 0; + glob = (!GIB_Var_Get (cbuf, args->argv[0]->str) && GIB_Var_Get_R (gib_globals, args->argv[0]->str)); + if (c) + *c = '.'; + if (glob) + GIB_Var_Set_R (gib_globals, args->argv[0]->str, args->argv[2]->str); // Set the global else - GIB_Var_Set (cbuf, args->argv[0]->str, args->argv[2]->str); + GIB_Var_Set (cbuf, args->argv[0]->str, args->argv[2]->str); // Set the local } else Cmd_Command (cbuf->args); dstring_clearstr (cbuf->line);