; Opens window for GIF images.
;
; Usage:
; //tenor loop $qt($mircdir\tenor.gif)
; //tenor $qt($mircdir\tenor2.gif)
;
; $tenor($qt($mircdir\scripts\tenor.gif))
; Returns <id> <frames>
;
alias tenor {
; Set Unique ID for GIF.
; ------------------------
var %id $rand(1,999999)
; Loop in Existing Window.
; ---------------------------------------
if (loop. isin $1) {
var %id $gettok($1,2,46)
var %loop $+(loop.,%id)
tokenize 32 $2-
}
; Check for existing GIF.
; ------------------------
if (loop == $1) {
; First Loop.
; -------------
tokenize 32 $2-
var %loop $+(loop.,%id)
}
; Check for GIF.
; ----------------
var %tenor.file $$1
if ($exists($1) == $false) {
echo -s > No such file: %tenor.file
return
}
; Set GIF properties.
; ---------------------
var %tenor.w $calc($pic($$1-).width +155)
var %tenor.h $calc($pic($$1-).height +155)
; Rescale GIF (if too small)
; ---------------------------
if (%tenor.w < 500) {
inc %tenor.w %tenor.w
inc %tenor.h %tenor.h
}
var %tenor.frames $calc($pic($$1-).frames -1)
var %tenor.win $+(@tenor,.,%id)
; Setup Window and Check for excessive frames.
; ----------------------------------------------
window -pk0 %tenor.win $iif($window(%tenor.win).x == $null,-1,$v1) $iif($window(%tenor.win).y == $null,-1,$v1) %tenor.w %tenor.h
if (%tenor.frames > 150) {
var %tenor.frames 150
}
titlebar %tenor.win ( $+ %tenor.frames Frames)
var %tenor.delay $pic($$1-).delay
; Draw GIF frames.
; ------------------
var %i 1
while (%i < %tenor.frames) {
inc %i
.timerTENOR. [ $+ [ %id ] ] [ $+ . ] [ $+ [ %i ] ] -m 1 $calc(%tenor.delay * %i) /drawpic -os %tenor.win 0 0 $calc(%tenor.w -20) $calc(%tenor.h -25) %i $$1-
}
if (%loop != $null) {
.timerTENOR. [ $+ [ %id ] ] -m 1 $calc(%tenor.delay * (%i +1)) /tenor %loop $1-
}
return %id %tenor.frames
}
on *:close:@: {
.timerTENOR. [ $+ [ $gettok($target,2,46) ] ] [ $+ * ] off
}