VrS (Variant realities Script) — File Browser
VrSVariantrealitiesScriptv2.0 / VrSVariantrealitiesScriptv2.0 / VrS / System / Modules / vPopup / VPOPUP.MRC
VPOPUP.MRC — 23.68 KB — Download this file
;#[vHD@3.0 C!vPopup@2.0.0;2001.11.21;Variant<variant@variantrealities.com>]
;#[SD C!vGui@2.1.0]
;#[Incl ]
;#[VrS' Popup system]
;#[ ]
;#[ ]
;---------Main vPopup command----------
; Syntax: /vP.Open [Desktop] [NoMove] <X> <Y> <Popup filename or hash table name> <Process function and parameters>
;Main vP command to open up a popup from the specified popup file at X and Y coordinates.
alias vP.Open {
if ($1 == Desktop) { var %Desktop = Desktop | tokenize 32 $2- }
if ($1 == NoMove) { var %NoMove = NoMove | tokenize 32 $2- }
;if ($noext($3) != $3) { vP.Clear }
if ($window(@vGui.vPopup. [ $+ [ $noext($3) ] ] )) {
vP.CloseChildWindows $noext($3)
vGui.Close vPopup. [ $+ [ $noext($3) ] ]
}
if ($gettok($3,2,46) != $null) { vP.ReadFile $3 }
hadd vP. [ $+ [ $noext($3) ] ] Process $4-
vP.SetVars vP. [ $+ [ $noext($3) ] ]
if ($hget(vPopup.Theme) == $null) { vP.SetThemeVars }
vP.OpenMenu $1 $2 $noext($3) %Desktop %NoMove
}
;---------vPopup vGui processing----------
alias vGui.vPopup.Process {
;if ($1 != vGuiTimer) && ($2 !isin MouseMove MovedWin Animate) { vecho $1- }
if ($1-2 == Window Close) {
if ($numtok($3,46) == 1) {
if ($hget( vP. [ $+ [ $gettok($3,1,46) ] ] ,Process)) && ($window(@vGui.vPopup. [ $+ [ $3 ] ] )) { $hget( vP. [ $+ [ $gettok($3,1,46) ] ] ,Process) vPopup Close }
}
}
elseif (vP.* AnimStart iswm $1-2) {
var %Y = $calc($hget(vPopup.Theme,TitlebarHeight) + (($gettok($1,2,46) - 1) * $hget(vPopup.Theme,NormHeight)))
if ($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),4,32) != -) && ($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),4,32) != !Text) {
return $3 0 %Y MouseOver $gettok($1,2,46) $iif($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),2,32) == Child,HasChild)
}
}
elseif (vP.* Animate iswm $1-2) && ($window( @vGui.vPopup. [ $+ [ $3 ] ] )) {
vP.DrawItem -a $calc($4 - 1) $5-
;vGui.Update vPopup. [ $+ [ $3 ] ]
}
elseif (vP.* MouseOver iswm $1-2) {
var %Y = $calc($hget(vPopup.Theme,TitlebarHeight) + (($gettok($1,2,46) - 1) * $hget(vPopup.Theme,NormHeight)))
if (%vGui.vPopup. [ $+ [ $3 ] $+ .Child ] != $null) && (%vGui.vPopup. [ $+ [ $3 ] $+ .Child ] != $1) {
var %OldY = $calc($hget(vPopup.Theme,TitlebarHeight) + (($gettok( %vGui.vPopup. [ $+ [ $3 ] $+ .Child ] ,2,46) - 1) * $hget(vPopup.Theme,NormHeight)))
vP.DrawItem $3 0 %OldY Normal $gettok( %vGui.vPopup. [ $+ [ $3 ] $+ .Child ] ,2,46) $iif($gettok($hget( vP. [ $+ [ $3 ] ] , %vGui.vPopup. [ $+ [ $3 ] $+ .Child ] ),2,32) == Child,HasChild)
}
var %OldChild = %vGui.vPopup. [ $+ [ $3 ] $+ .Child ]
;vGui.Update vPopup. [ $+ [ $3 ] ]
if ($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),2,32) == Child) {
var %PopupX = $calc($window(@vGui.vPopup. [ $+ [ $3 ] ] ).x + $hget(vPopup.Theme,ChildX))
if ($window(@vGui.vPopup. [ $+ [ $3 ] ] ).mdi == $true) {
if ($calc(%PopupX + $hget(vPopup.Theme,NormWidth)) > $window(-3).dw) { %PopupX = $calc($window(@vGui.vPopup. [ $+ [ $3 ] ] ).x - $hget(vPopup.Theme,ChildX)) }
}
else {
if ($calc(%PopupX + $hget(vPopup.Theme,NormWidth)) > $window(-1).w) { %PopupX = $calc($window(@vGui.vPopup. [ $+ [ $3 ] ] ).x - $hget(vPopup.Theme,ChildX)) }
}
var %HashTableName = $3 $+ . $+ $vP.HashName($gettok($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),4-,32),1,58))
var %PopupY = $calc($window(@vGui.vPopup. [ $+ [ $3 ] ] ).y + %Y - $hget(vPopup.Theme,TitlebarHeight) + $hget(vPopup.Theme,ChildY))
var %ParentName = $gettok($3,1,46)
vP.SetVars vP. $+ %ParentName $calc($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),1,32) + 1) $gettok($hget( vP. [ $+ [ $3 ] ] ,$1),3,32) %HashTableName
if ($window(@vGui.vPopup. [ $+ [ %HashTableName ] ] ,0) < 1) {
.timervP. [ $+ [ $3 ] ] -m 1 100 vP.OpenMenu %PopupX %PopupY %HashTableName $iif($window(@vGui.vPopup. [ $+ [ $3 ] ] ).mdi == $false,Desktop)
}
set %vGui.vPopup. [ $+ [ $3 ] $+ .Child ] $1
}
else { unset %vGui.vPopup. [ $+ [ $3 ] $+ .Child ] }
if (%OldChild != $1) {
vP.CloseChildWindows $iif($numtok($3,46) > 1,$gettok($3,1- [ $+ [ $numtok($3,46) ] ] ,46),$3) %HashTableName
}
if (%HashTableName == $null) { !window -a @vGui.vPopup. [ $+ [ $3 ] ] }
}
elseif (vP.* MouseOut iswm $1-2) {
if ($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),4,32) == -) || ($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),4,32) == !Text) { return }
.timervP. [ $+ [ $3 ] ] off
if (%vGui.vPopup. [ $+ [ $3 ] $+ .Child ] != $1) || ($window(@vGui.vPopup. [ $+ [ $3 ] $+ . $+ * ] ,0) < 1) {
var %Y = $calc($hget(vPopup.Theme,TitlebarHeight) + (($gettok($1,2,46) - 1) * $hget(vPopup.Theme,NormHeight)))
vP.DrawItem $3 0 %Y Normal $gettok($1,2,46) $iif($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),2,32) == Child,HasChild)
;vGui.Update vPopup. [ $+ [ $3 ] ]
}
else {
var %Y = $calc($hget(vPopup.Theme,TitlebarHeight) + (($gettok($1,2,46) - 1) * $hget(vPopup.Theme,NormHeight)))
vP.DrawItem -a $calc($hget(vPopup.Theme,MouseOverNum) - 1) $3 0 %Y MouseOver $gettok($1,2,46) $iif($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),2,32) == Child,HasChild)
;vGui.Update vPopup. [ $+ [ $3 ] ]
}
}
elseif (vP.* MouseClicked iswm $1-2) {
vGui.AnimStop
if ($gettok($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),4-,32),2,58) == !vPCheckbox) {
set %vGui.vPopup. [ $+ [ $3 ] $+ .vPCheckbox. $+ [ $gettok($1,2,46) ] ] $iif(%vGui.vPopup. [ $+ [ $3 ] $+ .vPCheckbox. $+ [ $gettok($1,2,46) ] ] == Checked,Unchecked,Checked)
vP.DrawItem $3 0 %Y MouseOver $gettok($1,2,46) $iif($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),2,32) == Child,HasChild)
$hget( vP. [ $+ [ $gettok($3,1,46) ] ] ,Process) !Check $gettok($gettok($hget( vP. [ $+ [ $3 ] ] , $1 ] ] ),4-,32),3,58) %vGui.vPopup. [ $+ [ $3 ] $+ .vPCheckbox. $+ [ $gettok($1,2,46) ] ]
}
else {
if ($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),4,32) == -) || ($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),4,32) == !Text) || ($gettok($gettok($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),4-,32),1,58),1,32) == !Disabled) { return }
if ($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),2,32) != Child) {
var %Process = $hget( vP. [ $+ [ $gettok($3,1,46) ] ] ,Process)
var %Command = $gettok($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),4-,32),2-,58)
if ($left($gettok(%Command,1,32),1) == !) { %Command = $gettok(%Command,2-,58) }
vP.CloseChildWindows $gettok($3,1,46)
vGui.Close -q vPopup. [ $+ [ $gettok($3,1,46) ] ]
hfree -w vP. [ $+ [ $gettok($3,1,46) ] ]
%Process %Command
}
}
}
elseif (vP.* MouseDown iswm $1-2) {
if ($gettok($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),4-,32),2,58) == !vPCheckbox) {
set -u %vPMouseDown 1
var %Y = $calc($hget(vPopup.Theme,TitlebarHeight) + (($gettok($1,2,46) - 1) * $hget(vPopup.Theme,NormHeight)))
vP.DrawItem $3 0 %Y MouseOver $gettok($1,2,46) $iif($gettok($hget( vP. [ $+ [ $3 ] ] ,$1),2,32) == Child,HasChild)
unset %vPMouseDown
}
}
elseif ($1-2 == WINDOW InActive) {
if ($gettok($3,1,46)) && ($gettok($active,3,46) != $gettok($3,1,46)) || ($appactive == $false) {
vGui.Close -q vPopup. [ $+ [ $gettok($3,1,46) ] ]
vP.CloseChildWindows $gettok($3,1,46)
$hget( vP. [ $+ [ $gettok($3,1,46) ] ] ,Process) vPopup Close
;hfree -w vP. [ $+ [ $gettok($3,1,46) ] ]
}
}
}
alias vGui.vPopup.CheckObjects {
if ($2 >= $hget(vPopup.Theme,TitlebarHeight)) {
var %Y = $calc($2 - $hget(vPopup.Theme,TitlebarHeight))
var %Total = $hget( vP. [ $+ [ $3 ] ] ,vP.Total)
var %ItemNum = $int($calc(%Y / $hget(vPopup.Theme,NormHeight)))
var %X = $iif($hget(vPopup.Theme,vPIconX),$ifmatch,$hget(vPopup.Theme,IconX))
var %Y = $iif($hget(vPopup.Theme,vPIconY),$ifmatch,$hget(vPopup.Theme,IconY))
if ($calc(%ItemNum + 1) <= %Total) {
if ($gettok($hget( vP. [ $+ [ $3 ] ] ,vP. [ $+ [ $calc(%ItemNum + 1) ] ] ),2,58) != !Text) {
return animhotspot vP. [ $+ [ $calc(%ItemNum + 1) ] ] 0 $calc($hget(vPopup.Theme,TitlebarHeight) + (%ItemNum * $hget(vPopup.Theme,NormHeight))) $hget(vPopup.Theme,NormWidth) $hget(vPopup.Theme,NormHeight) $hget(vPopup.Theme,AnimStyle) $hget(vPopup.Theme,AnimSpeed) 1 $hget(vPopup.Theme,AnimTotal)
}
}
}
else {
if ($inrect($1,$2,0,0,$hget(vPopup.Theme,NormWidth),$hget(vPopup.Theme,TitlebarHeight)) == $true) && ($numtok($3,46) == 1) && (%vGui.vPopup. [ $+ [ $3 ] $+ ] .NoMove != 1) { return winmove vPWinMove 0 0 $hget(vPopup.Theme,NormWidth) $hget(vPopup.Theme,TitlebarHeight) }
}
}
on 1:close:@: {
if ($gettok($target,2,46) != vPopup) {
var %Total = $window( @vGui.vPopup.*,0)
var %Counter = 1
while (%Counter <= %Total) {
var %WinName = $window(@vGui.vPopup.*,1)
var %ProcessWinName = $gettok(%WinName,3-,46)
if ($2 != %ProcessWinName) {
vGui.Close -q vPopup. [ $+ [ %ProcessWinName ] ]
hfree -w vP. [ $+ [ %ProcessWinName ] ]
}
else { inc %Total | inc %Counter }
inc %Counter
}
}
}
alias showwins {
var %Counter = 1, %Total = $window(*,0)
while (%Counter <= %Total) {
vecho $window(*,%Counter)
inc %Counter
}
}
; Syntax: /vP.CloseChildWindows <Window to start with> [Window to skip]
alias vP.CloseChildWindows {
var %Total = $window( @vGui.vPopup. [ $+ [ $1 ] $+ .* ] ,0)
var %Counter = 1
while (%Counter <= %Total) {
var %WinName = $window(@vGui.vPopup. [ $+ [ $1 ] $+ ] .*,1)
var %ProcessWinName = $gettok(%WinName,3-,46)
if ($2 != %ProcessWinName) {
vGui.Close -q vPopup. [ $+ [ %ProcessWinName ] ]
hfree -w vP. [ $+ [ %ProcessWinName ] ]
}
else { inc %Total | inc %Counter }
inc %Counter
}
if ($numtok($1,46) == 1) && ($window(@vGui.vPopup. [ $+ [ $1 ] ] )) && ($2 != $null) { !window -a @vGui.vPopup. [ $+ [ $1 ] ] }
}
;---------vPopup window drawing commands----------
; Syntax: /vP.OpenMenu <X> <Y> <Name of vPopup table> [Desktop] [NoMove]
alias vP.OpenMenu {
var %Height = $calc(($hget( vP. [ $+ [ $3 ] ] ,vP.Total) * $hget(vPopup.Theme,NormHeight)) + $hget(vPopup.Theme,TitlebarHeight) + $hget(vPopup.Theme,BottomHeight))
var %Width = $hget(vPopup.Theme,NormWidth)
var %PopupX = $1, %PopupY = $2
if ($4 == Desktop) {
if ($calc(%PopupX + %Width) > $window(-1).w) { dec %PopupX %Width }
if ($calc(%PopupY + %Height) > $window(-1).h) { dec %PopupY %Height }
}
else {
if ($calc(%PopupX + %Width) > $window(-3).dw) { dec %PopupX %Width }
if ($calc(%PopupY + %Height) > $window(-3).dh) { dec %PopupY %Height }
}
vGui.Window -qhb [ $+ [ $iif($4 == Desktop,do) ] ] vPopup. [ $+ [ $3 ] ] %PopupX %PopupY %Width %Height
if (NoMove isin $4-5) { set %vGui.vPopup. [ $+ [ $3 ] $+ ] .NoMove 1 }
drawpic -ctn @vGui.vPopup. [ $+ [ $3 ] ] $rgb(255,0,255) 0 0 $vP.ThemeDir($hget(vPopup.Theme,TitleImg))
var %Y = $hget(vPopup.Theme,TitlebarHeight)
var %Counter = 1
while (%Counter <= $hget( vP. [ $+ [ $3 ] ] ,vP.Total)) {
if ($gettok($hget( vP. [ $+ [ $3 ] ] ,vP. [ $+ [ %Counter ] ] ),4,32) != -) {
vP.DrawItem $3 0 %Y Normal %Counter $iif($gettok($hget( vP. [ $+ [ $3 ] ] ,vP. [ $+ [ %Counter ] ] ),2,32) == Child,HasChild)
}
else { vP.DrawItem $3 0 %Y Divider %Counter }
inc %Y $hget(vPopup.Theme,NormHeight)
inc %Counter
}
drawpic -ctn @vGui.vPopup. [ $+ [ $3 ] ] $rgb(255,0,255) 0 %Y $vP.ThemeDir($hget(vPopup.Theme,BottomImg))
vGui.Update vPopup. [ $+ [ $3 ] ]
!window -a @vGui.vPopup. [ $+ [ $3 ] ]
}
; Syntax: /vP.DrawItem [-a Num] <vPopup Window> <X> <Y> <Mouseover/Normal/Divider> <Item number> [HasChild]
alias vP.DrawItem {
if ($left($1,1) == -) { var %Options = $1-2 | tokenize 32 $3- }
var %vPText = $gettok($gettok($hget( vP. [ $+ [ $1 ] ] , vP. [ $+ [ $5 ] ] ),4-,32),2,58)
var %ItemText = $gettok($gettok($hget( vP. [ $+ [ $1 ] ] , vP. [ $+ [ $5 ] ] ),4-,32),1,58)
var %X = $iif($hget(vPopup.Theme,vPIconX),$ifmatch,$hget(vPopup.Theme,IconX))
var %Y = $iif($hget(vPopup.Theme,vPIconY),$ifmatch,$hget(vPopup.Theme,IconY))
if ($4 == Mouseover) {
drawpic -ctn @vGui.vPopup. [ $+ [ $1 ] ] $rgb(255,0,255) $2 $3 0 $iif(%Options,$calc($gettok(%Options,2,32) * $hget(vPopup.Theme,NormHeight)),0) $hget(vPopup.Theme,NormWidth) $hget(vPopup.Theme,NormHeight) $vP.ThemeDir($hget(vPopup.Theme,MouseOverImg))
if ($gettok(%ItemText,1,32) == !Disabled) {
drawtext -rcn @vGui.vPopup. [ $+ [ $1 ] ] $rgb( [ $vGui.Setting(vGui,Hilight) ] ) " $+ $hget(vPopup.Theme,Font) $+ " $hget(vPopup.Theme,FontSize) $calc($2 + $hget(vPopup.Theme,TextX) + 1) $calc($3 + $hget(vPopup.Theme,TextY) + 1) $iif($6 == HasChild,$hget(vPopup.Theme,ClipWidth),$calc($hget(vPopup.Theme,NormWidth) - $hget(vPopup.Theme,TextX) - 4)) $hget(vPopup.Theme,NormHeight) $gettok(%ItemText,2-,32)
drawtext -rcn @vGui.vPopup. [ $+ [ $1 ] ] $rgb( [ $vGui.Setting(vGui,Shadow) ] ) " $+ $hget(vPopup.Theme,Font) $+ " $hget(vPopup.Theme,FontSize) $calc($2 + $hget(vPopup.Theme,TextX)) $calc($3 + $hget(vPopup.Theme,TextY)) $iif($6 == HasChild,$hget(vPopup.Theme,ClipWidth),$calc($hget(vPopup.Theme,NormWidth) - $hget(vPopup.Theme,TextX) - 4)) $hget(vPopup.Theme,NormHeight) $gettok(%ItemText,2-,32)
}
else { drawtext -rcn @vGui.vPopup. [ $+ [ $1 ] ] $rgb( [ $hget(vPopup.Theme,MouseOverColor) ] ) " $+ $hget(vPopup.Theme,Font) $+ " $hget(vPopup.Theme,FontSize) $calc($2 + $hget(vPopup.Theme,TextX)) $calc($3 + $hget(vPopup.Theme,TextY)) $iif($6 == HasChild,$hget(vPopup.Theme,ClipWidth),$calc($hget(vPopup.Theme,NormWidth) - $hget(vPopup.Theme,TextX) - 4)) $hget(vPopup.Theme,NormHeight) %ItemText }
if ($gettok($gettok($hget( vP. [ $+ [ $1 ] ] , vP. [ $+ [ $5 ] ] ),4-,32),2,58) == !vPCheckbox) {
vGui.Obj.Checkbox.Draw vPopup. [ $+ [ $1 ] ] $iif(%vPMouseDown,MouseDown,MouseOver) $calc($2 + %X)) $calc($3 + %Y) 15 15 vPCheckbox. $+ $gettok($hget( vP. [ $+ [ $1 ] ] , vP. [ $+ [ $5 ] ] ),1,32)
}
elseif ($gettok(%vPText,1,32) == !vPIcon) {
drawpic -ctn @vGui.vPopup. [ $+ [ $1 ] ] $rgb(255,0,255) $calc($2 + %X)) $calc($3 + %Y) $gettok(%vPText,2-3,32) 14 14 $vrsdir($gettok(%vPText,4-,32))
}
if ($6 == HasChild) { drawpic -ctn @vGui.vPopup. [ $+ [ $1 ] ] $rgb(255,0,255) $calc($2 + $hget(vPopup.Theme,IconX)) $calc($3 + $hget(vPopup.Theme,IconY)) $vP.ThemeDir($hget(vPopup.Theme,MouseOverChildImg)) }
}
elseif ($4 == Normal) {
drawpic -ctn @vGui.vPopup. [ $+ [ $1 ] ] $rgb(255,0,255) $2 $3 $vP.ThemeDir($hget(vPopup.Theme,NormImg))
if ($gettok(%ItemText,1,32) == !Disabled) {
drawtext -rcn @vGui.vPopup. [ $+ [ $1 ] ] $rgb( [ $vGui.Setting(vGui,Hilight) ] ) " $+ $hget(vPopup.Theme,Font) $+ " $hget(vPopup.Theme,FontSize) $calc($2 + $hget(vPopup.Theme,TextX) + 1) $calc($3 + $hget(vPopup.Theme,TextY) + 1) $iif($6 == HasChild,$hget(vPopup.Theme,ClipWidth),$calc($hget(vPopup.Theme,NormWidth) - $hget(vPopup.Theme,TextX) - 4)) $hget(vPopup.Theme,NormHeight) $gettok(%ItemText,2-,32)
drawtext -rcn @vGui.vPopup. [ $+ [ $1 ] ] $rgb( [ $vGui.Setting(vGui,Shadow) ] ) " $+ $hget(vPopup.Theme,Font) $+ " $hget(vPopup.Theme,FontSize) $calc($2 + $hget(vPopup.Theme,TextX)) $calc($3 + $hget(vPopup.Theme,TextY)) $iif($6 == HasChild,$hget(vPopup.Theme,ClipWidth),$calc($hget(vPopup.Theme,NormWidth) - $hget(vPopup.Theme,TextX) - 4)) $hget(vPopup.Theme,NormHeight) $gettok(%ItemText,2-,32)
}
else { drawtext -rcn @vGui.vPopup. [ $+ [ $1 ] ] $rgb( [ $hget(vPopup.Theme,NormColor) ] ) " $+ $hget(vPopup.Theme,Font) $+ " $hget(vPopup.Theme,FontSize) $calc($2 + $hget(vPopup.Theme,TextX)) $calc($3 + $hget(vPopup.Theme,TextY)) $iif($6 == HasChild,$hget(vPopup.Theme,ClipWidth),$calc($hget(vPopup.Theme,NormWidth) - $hget(vPopup.Theme,TextX) - 4)) $hget(vPopup.Theme,NormHeight) %ItemText }
if ($gettok($gettok($hget( vP. [ $+ [ $1 ] ] , vP. [ $+ [ $5 ] ] ),4-,32),2,58) == !vPCheckbox) {
vGui.Obj.Checkbox.Draw vPopup. [ $+ [ $1 ] ] Normal $calc($2 + %X)) $calc($3 + %Y) 15 15 vPCheckbox. $+ $gettok($hget( vP. [ $+ [ $1 ] ] , vP. [ $+ [ $5 ] ] ),1,32)
}
elseif ($gettok(%vPText,1,32) == !vPIcon) {
drawpic -ctn @vGui.vPopup. [ $+ [ $1 ] ] $rgb(255,0,255) $calc($2 + %X)) $calc($3 + %Y) $gettok(%vPText,2-3,32) 14 14 $vrsdir($gettok(%vPText,4-,32))
}
if ($6 == HasChild) { drawpic -ctn @vGui.vPopup. [ $+ [ $1 ] ] $rgb(255,0,255) $calc($2 + $hget(vPopup.Theme,IconX)) $calc($3 + $hget(vPopup.Theme,IconY)) $vP.ThemeDir($hget(vPopup.Theme,NormChildImg)) }
}
elseif ($4 == Divider) { drawpic -ctn @vGui.vPopup. [ $+ [ $1 ] ] $rgb(255,0,255) $2 $3 $vP.ThemeDir($hget(vPopup.Theme,DividerImg)) }
}
;---------vPopup file parsing----------
alias vP.SetThemeVars {
if ($hget(vPopup.Theme) != $null) { hfree vPopup.Theme }
hmake vPopup.Theme 10
hadd vPopup.Theme Font $vP.Setting(vPopup,Font)
hadd vPopup.Theme FontSize $vP.Setting(vPopup,FontSize)
hadd vPopup.Theme TextX $vP.Setting(vPopup,TextX)
hadd vPopup.Theme TextY $vP.Setting(vPopup,TextY)
hadd vPopup.Theme MouseOverColor $vP.Setting(vPopup,MouseOverColor)
hadd vPopup.Theme NormColor $vP.Setting(vPopup,NormColor)
hadd vPopup.Theme IconX $vP.Setting(vPopup,IconX)
hadd vPopup.Theme IconY $vP.Setting(vPopup,IconY)
hadd vPopup.Theme vPIconX $vP.Setting(vPopup,vPIconX)
hadd vPopup.Theme vPIconY $vP.Setting(vPopup,vPIconY)
hadd vPopup.Theme IconW $vP.Setting(vPopup,IconW)
hadd vPopup.Theme IconH $vP.Setting(vPopup,IconH)
hadd vPopup.Theme AnimStyle $iif($vP.Setting(vPopup,AnimStyle),$ifmatch,1)
hadd vPopup.Theme AnimSpeed $iif($vP.Setting(vPopup,AnimSpeed),$ifmatch,100)
hadd vPopup.Theme AnimTotal $iif($vP.Setting(vPopup,AnimTotal),$ifmatch,1)
hadd vPopup.Theme MouseOverNum $iif($vP.Setting(vPopup,MouseOverNum),$ifmatch,$hget(vPopup.Theme,AnimTotal))
hadd vPopup.Theme TitleImg $vP.Setting(vPopup,TitleImg)
hadd vPopup.Theme BottomImg $vP.Setting(vPopup,BottomImg)
hadd vPopup.Theme NormImg $vP.Setting(vPopup,NormImg)
hadd vPopup.Theme MouseOverImg $vP.Setting(vPopup,MouseOverImg)
hadd vPopup.Theme DividerImg $vP.Setting(vPopup,DividerImg)
hadd vPopup.Theme NormChildImg $vP.Setting(vPopup,NormChildImg)
hadd vPopup.Theme ChildX $vP.Setting(vPopup,ChildX)
hadd vPopup.Theme ChildY $vP.Setting(vPopup,ChildY)
hadd vPopup.Theme MouseOverChildImg $vP.Setting(vPopup,MouseOverChildImg)
hadd vPopup.Theme CheckImg $vP.Setting(vPopup,CheckImg)
hadd vPopup.Theme TitlebarHeight $pic($vP.ThemeDir(vp_title.png)).height
hadd vPopup.Theme BottomHeight $pic($vP.ThemeDir(vp_bot.png)).height
hadd vPopup.Theme NormHeight $pic($vP.ThemeDir(vp_norm.png)).height
hadd vPopup.Theme NormWidth $pic($vP.ThemeDir(vp_norm.png)).width
hadd vPopup.Theme ClipWidth $iif($vP.Setting(vPopup,ClipWidth),$ifmatch,$calc($hget(vPopup.Theme,NormWidth) - $hget(vPopup.Theme,TextX) - 4))
}
;vPopup cleanup alias - this removes all vPopup related hash tables
alias vP.Clear { hfree -w vP* | hunset vP.* | hunset vPS.* }
; Syntax: /vP.ReadFile <Popup filename>
alias vP.ReadFile {
if ($hget( vP. [ $+ [ $noext($1) ] ] ) != $null) { hfree -w vP. [ $+ [ $noext($1) ] ] }
hmake vP. [ $+ [ $noext($1) ] ] 50
hload -n vP. [ $+ [ $noext($1) ] ] $vP.Dir($1)
}
; Syntax: /vP.SetVars <Popup hash table> [Start line] [Start char] [Hash table name]
;The hash table is a list of all the items in the actual popup file that was read in by vP.ReadFile.
;Generally the hash table name is the filename without the extension, such as vpstatus.vpi becomes
;vpstatus as the hash table name.
alias vP.SetVars {
;Set starting line in hash table
var %vPS.Counter = $iif($2,$2,1)
;Set starting vPopup counter for the hash table for this menu
var %Counter = 1
;Determine child name and free/make table if necessary
if ($2 == $null) { var %ParentTable $1 }
else {
var %ParentTable vP. [ $+ [ $4 ] ]
if ($hget(%ParentTable) != $null) { hfree %ParentTable }
hmake %ParentTable 10
}
;Set current line of text we're parsing in the hash table
var %vPS.Line = $hget($1,%vPS.Counter)
while (%vPS.Line != $null) {
;Basically if we're in a child, and we come to an item that isn't in the child
;menu we're parsing, break out, we're done.
if ($3) && ($mid(%vPS.Line,$calc($3 - 1),1) != .) { break }
;Check if this line is starting a new child item, if not, then add it to this menu
if ($mid(%vPS.Line,$iif($3,$3,1),1) != .) {
;Set the text minus the . prefix
var %vPS.vPLine = $iif($3,$right(%vPS.Line, - [ $+ [ $calc($3 - 1) ] ] ),%vPS.Line)
;Determine whether this option leads to a child menu or not.
if (: isin %vPS.vPLine) || (%vPS.vPLine == -) { hvar vPS.vPChild NotChild }
else { hvar vPS.vPChild Child }
;If $ isin the popup title, evaluate if possible, and if $null, do not add item.
if ($chr(36) isin $gettok(%vPS.vPLine,1,58)) {
var %Process = $hget($1,Process)
var %Command = $gettok(%vPS.vPLine,1,58)
var %WinInfo = $ [ $+ [ $right($gettok($1,1,46),-1) ] $+ . $+ vSProcess( $+ [ $1 ] $+ ) ]
set -u %vP.ProcessParams $gettok(%Process,2-,32)
var %Text = $ [ $+ [ $gettok(%Process,1,32) ] $+ ] ( $iif($gettok(%Process,2-,32),$gettok(%Process,2-,32) %Command,%Command) )
if (%Text == $null) { goto end }
else { %vPS.vPLine = $puttok(%vPS.vPLine,%Text,1,58) }
}
if ($gettok(%vPS.vPLine,2,58) == !vPCheckbox) {
var %Process = $hget($1,Process)
var %Checkbox = $ [ $+ [ $gettok(%Process,1,32) ] $+ ] ( $iif($gettok(%Process,2-,32),$gettok(%Process,2-,32) !CheckInit $gettok(%vPS.vPLine,3-,58),!CheckInit $gettok(%vPS.vPLine,3-,58)) )
set %vGui.vPopup. [ $+ [ $gettok(%ParentTable,2-,46) ] $+ .vPCheckbox. $+ [ %Counter ] ] %Checkbox
}
;Determine starting character for the child menu (if any) for future reference.
hvar vPS.vPChildStartChar $iif($3,$calc($3 + 1),2)
;Add item to this menu, including the line number in the hash table (for future reference), whether
;its a child or not, the number of how deep the child menu will be in ...'s and the above "text minus the . prefix"
if ($gettok(%vPS.vPLine,2,58) == !DynList) {
%Counter = $ [ $+ [ $gettok(%vPS.vPLine,3,58) ] $+ ( [ %ParentTable ] , [ %Counter ] , [ $hvar(vPS.vPChild) ] , [ $hvar(vPS.vPChildStartChar) ] ) ]
}
else {
hadd %ParentTable vP. [ $+ [ %Counter ] ] %vPS.Counter $hvar(vPS.vPChild) $hvar(vPS.vPChildStartChar) %vPS.vPLine
;Increment counter for this menu.
inc %Counter
}
:end
}
;Increment hash table counter
inc %vPS.Counter
;Reset line we're parsing to the next line in the hash table and then proceed to beginning of WHILE loop.
%vPS.Line = $hget($1,%vPS.Counter)
}
hadd %ParentTable vP.Total $calc(%Counter - 1)
;Remove temporary hash table variables
hunset vPS.*
}
;---------Supplemental vPopup identifiers and commands----------
on *:signal:vTheme.Load: { vP.Set $theme.setting(vPopup) }
alias vP.Set {
if ($exists($vrsdir( Themes\ [ $+ [ $1 ] $+ ] \vpset.ini )) == $false) { var %Theme = vrsdefault }
else { var %Theme = $1 }
if ($hget(vPopup.Theme)) { hfree vPopup.Theme }
hdel -w Theme vPSetting.*
theme.write vPopup %Theme
}
alias vP.Dir { return $vrsdir( System\Core\Popups\ [ $+ [ $1- ] ] ) }
alias vP.ThemeDir {
if ($prop) { return $vrsdir( Themes\ [ $+ [ $theme.setting(vPopup) ] $+ \ $+ [ $1- ] ] ).n }
return $vrsdir( Themes\ [ $+ [ $theme.setting(vPopup) ] $+ \ $+ [ $1- ] ] )
}
alias vP.HashName { return $replace($1-,$chr(32),_,$chr(46),_) }
alias vP.Setting {
if ( $hget(Theme, vPSetting. [ $+ [ $1 ] $+ . $+ [ $2 ] ] ) != $null) { return $hget(Theme, vPSetting. [ $+ [ $1 ] $+ . $+ [ $2 ] ] ) }
if ($readini($vP.ThemeDir(vpset.ini).n,n,$1,$2) != $null) { hadd Theme vPSetting. [ $+ [ $1 ] $+ . $+ [ $2 ] ] $readini($vP.ThemeDir(vpset.ini).n,n,$1,$2) }
return $hget(Theme, vPSetting. [ $+ [ $1 ] $+ . $+ [ $2 ] ] )
}