VrS (Variant realities Script) — File Browser
VrSVariantrealitiesScriptv2.0 / VrSVariantrealitiesScriptv2.0 / VrS / System / Modules / vTheme / vTheme.mrc
vTheme.mrc — 7.35 KB — Download this file
;#[vHD@3.0 C!vTheme@2.0.0;2001.7.18;Variant<variant@variantrealities.com>]
;#[SD ]
;#[Incl ]
;#[VrS' Theme engine, which functions using the mIRC Theme Standard, MTS.]
;#[ ]
;#[ ]
on *:signal:start.2: { theme.load $vUser(Theme,Filename) }
on *:start: { if (!$hget(Theme)) { hmake Theme 50 } }
alias vtheme.set { theme.load $1- }
alias theme.vpak {
if (!$1-) {
var %ThemeDir = $sdir(Themes\,Select the theme to vPak:,Compress)
if (%ThemeDir) { tokenize 32 %ThemeDir }
else { return }
}
tokenize 32 $gettok($1-,-1,92)
vPak -pzd $+(",$mircdir,Temp\,$1-,.Theme.vpk,") $vrsdir($+(Themes\,$1-))
}
alias theme.load {
if ($left($1,1) == -) { var %Options = $1 | tokenize 32 $2- }
if (s isin %Options) { var %Scheme = $1 | tokenize 32 $2- }
if ($1) && ($right($1,4) != .mts) { tokenize 32 $1 $+ .mts }
var %ThemeDir = $mircdir $+ Themes\*.mts
if (!$1) { var %Theme = $sfile(%ThemeDir,Select a theme to load,Load) | if (!%Theme) { return } | else { %Theme = " $+ %Theme $+ " } }
else { var %Theme = $iif($nopath($1-) == $1-,$vrsdir(Themes\ $+ $noext($1-) $+ \ $+ $1-)," $+ $remove($1-,") $+ ") }
if (!$exists(%Theme)) { echo $color(info) -a *** No such theme file: %Theme | return }
drawpic -c
var %ThemeDir = $nofile(%Theme)
.signal -n vTheme.Unload
if ($vReg(G,CurrentTheme,Filename)) { theme.loadbuf -n mts $vrsdir($+(Themes\,$noext($vReg(G,CurrentTheme,Filename)),\,$vReg(G,CurrentTheme,Filename))) }
set -u %:echo echo -ai2
theme.text Unload
vecho Unloading settings from last theme, if any.
if ($theme.setting(Script)) { .unload -rs $ifmatch }
if (!$hget(Theme)) { hmake Theme 50 }
else { hdel -w Theme * }
vUser Theme Filename $nopath(%Theme)
vReg G CurrentTheme Filename $nopath(%Theme)
vecho Loading theme $nopath(%Theme) $+ ...
theme.loadbuf mts $vrsdir(System\Core\mtsfilter.vrs)
theme.loadbuf mts %Theme
hadd Theme ThemeDir $nofile(%Theme)
hadd Theme ThemeFile %Theme
if ($theme.setting(Script)) { .load -rs $+(",%ThemeDir,$theme.setting(Script),") }
if (%Scheme) { theme.loadbuf %Scheme %theme }
vecho Applying theme colors and fonts...
set %vTheme.ChangingTheme 1
.signal -n vTheme.Load
var %counter = 1
while (%counter <= 26) {
color $gettok($theme.colorlist,%counter,44) $gettok($theme.setting(Colors),%counter,44)
inc %counter
}
color $gettok($theme.colorlist,27,44) $gettok($theme.setting(Colors),22,44)
var %counter = 0
while (%counter <= 15) {
if ($gettok($theme.setting(RGBColors),$calc(%counter + 1),32)) { color %counter $rgb( [ $gettok($theme.setting(RGBColors),$calc(%counter + 1),32) ] ) }
else { colour -r %counter }
inc %counter
}
font -ad $gettok($theme.setting(FontDefault),2,44) $gettok($theme.setting(FontDefault),1,44)
font -sd $gettok($theme.setting(FontDefault),2,44) $gettok($theme.setting(FontDefault),1,44)
if ($theme.setting(ImageMirc)) { background $theme.bgoption($gettok($theme.setting(ImageMirc),1,32)) $+ m $+(",$themedir($gettok($theme.setting(ImageMirc),2-,32)),") }
else { background -xm }
set -u %:echo echo -ai2
theme.text Load
.signal -n vTheme.Finish
unset %vTheme.ChangingTheme
}
alias theme.colorlist {
return Background,Action text,CTCP text,Highlight text,Info text,Info2 text,Invite text,Join text, $&
Kick text,Mode text,Nick text,Normal text,Notice text,Notify text,Other text,Own text,Part text, $&
Quit text,Topic text,Wallops text,Whois text,Editbox,Editbox text,Listbox,Listbox text,Grayed text,Inactive
}
;center, fill, normal, stretch, tile, photo -cfnrtp
alias theme.bgoption {
if ($1 == center) { return -c }
elseif ($1 == fill) { return -f }
elseif ($1 == normal) { return -n }
elseif ($1 == stretch) { return -r }
elseif ($1 == tile) { return -t }
elseif ($1 == photo) { return -p }
}
alias theme.loadbuf {
if ($left($1,1) == -) { var %Options = $1 | tokenize 32 $2- }
!window -h @Theme
loadbuf -t [ $+ [ $1 ] ] @Theme $2-
var %Total = $line(@Theme,0),%Counter = 1,%Line
while (%Counter <= %Total) {
%Line = $line(@Theme,%Counter)
if ($left(%Line,1) != $chr(59)) && ($remove(%Line,$chr(32)) != $null) {
if (n !isin %Options) && ($gettok(%Line,2-,32)) { hadd Theme $gettok(%Line,1,32) $iif($left($gettok(%Line,2-,32),7) != !Script,$mts2alias($gettok(%Line,1-,32)),$gettok(%Line,3-,32)) }
hadd Theme $+(PlainText.,$gettok(%Line,1,32)) $gettok(%Line,2-,32)
}
inc %Counter
}
SetBaseColors
hadd Theme Prefix $eval($hget(Theme,Prefix),2)
!window -c @Theme
}
alias -l SetBaseColors {
set -u %::c1 $gettok($hget(Theme,PlainText.BaseColors),1,44)
set -u %::c2 $gettok($hget(Theme,PlainText.BaseColors),2,44)
set -u %::c3 $gettok($hget(Theme,PlainText.BaseColors),3,44)
set -u %::c4 $gettok($hget(Theme,PlainText.BaseColors),4,44)
}
;Syntax: /theme.text <event>
alias theme.text {
SetBaseColors
set -u %::parentext $iif(%::text,$eval($hget(Theme,ParenText),2)) | set -u %::pre $hget(Theme,Prefix)
if ($hget(Theme,$1)) { $eval($ifmatch,2) }
elseif ($gettok($1,1,46) == Raw) && ($hget(Theme,Raw.Other)) { $eval($hget(Theme,Raw.Other),2) }
}
alias theme.scheme {
theme.load -s Scheme $+ $2 $1
}
alias theme.setting { return $hget(Theme,$+(PlainText.,$1)) }
alias mtsversion { return 1.0 }
alias themedir { return $+($hget(Theme,ThemeDir),$1-) }
alias themefile { return $hget(Theme,ThemeFile) }
;Syntax: /theme.write <Setting> [Value]
alias theme.write {
if ($1) {
if ($2) {
write $+(-s,$1) $themefile $1 $2-
hadd Theme $1 $2- | hadd Theme $+(PlainText.,$1) $2-
}
else {
write $+(-ds,$1) $themefile
hdel Theme $1 | hdel Theme $+(PlainText.,$1)
}
}
}
alias mts2alias {
tokenize 32 $1-
var %Line = $dll($dlldir(kte.dll),MTSPrecompile,$2-)
if ($1 == Prefix) || ($1 == ParenText) { return %Line }
if (%Line) { return $+(%,:echo) %Line $+(%,:comments) }
}
alias mts2aliasold {
var %left, %new, %num, %old, %right, %text = $1-
; Credits to pai for this identifier
%num = $regex(mts,$1-,/(<[-_.a-zA-Z0-9]+>|[%{|}\[\]$])/g)
while (%num >= 1) {
%old = $regml(mts,%num)
%left = $left(%text,$calc($regml(mts,%num).pos - 1)) $+
%right = $mid(%text,$calc($regml(mts,%num).pos + $len($regml(mts,%num))))
if ($len(%old) == 1) %new = $+($,chr,$chr(40),$asc(%old),$chr(41),)
elseif (%old == <gt>) %new = > | elseif (%old == <lt>) %new = <
else %new = $+(%,::,$right($left(%old,-1),-1)) $+
if (%left != ) && ($asc($right(%left,2)) != 32) %new = $+($chr(32),$!+,$chr(32),%new)
if (%right != $null) && ($asc($left(%right,1)) != 32) %new = $+($left(%new,-1),$chr(32),$!+,$chr(32),)
%text = $+($left(%left,-1),$left(%new,-1),%right)
dec %num
}
return !Script $+(%,:echo) %text $+(%,:comments)
}
alias testspeed {
var %counter = 1,%ticks = $ticks
while (%counter <= 500) {
var %test = $mts2alias(<pre> <c1>Looking up <c3><nick><address><c1>...)
inc %counter
}
echo -a $mts2alias(<pre> <c1>Looking up <c3><nick><address><c1>...)
echo -a $calc($ticks - %ticks)
var %counter = 1,%ticks = $ticks
while (%counter <= 500) {
var %test = $mts2aliasold(<pre> <c1>Looking up <c3><nick><address><c1>...)
inc %counter
}
echo -a $mts2aliasold(<pre> <c1>Looking up <c3><nick><address><c1>...)
echo -a $calc($ticks - %ticks)
}