· 9 years ago · Dec 03, 2016, 04:38 AM
1; --- upp 2
2; --- file themes
3; --- type module
4; --- info description=enable theme support|version=1.0.0.3|rank=7|libraries=theme|modules=control,themes_dlg,importer2|hidden=0
5
6
7; --- load dependencies
8
9on *:load:{
10 fixdatas
11 rebuilddata
12 setgroups
13 setfonts
14 loadmodule themes_dlg,importer2
15}
16on *:signal:rebuild:{
17 ; $?1 = afterupdate|outdated
18 rebuilddata $1
19 if ($1 == outdated) { cttall }
20}
21alias -l rebuilddata {
22 ; $?1 = afterupdate|outdated
23 .timerthemeload -io 1 0 checknothemeunload $1
24}
25alias checknothemeunload {
26 ; $?1 = afterupdate|outdated
27 if ($ismodule(nothemes)) {
28 dbout unloading nothemes from themes
29 .unload -rs $quo($module2file(nothemes))
30 }
31 if ($1 == afterupdate) {
32 .loadtheme $deftheme
33 }
34 else {
35 loadtheme $deftheme
36 }
37}
38alias cttall {
39 ; !$1-
40 dbout updated version detected, updating custom themes...
41 var %dir = $+($mircdir,system\themes\)
42 $null($findfile(%dir,*.upp,0,0,ctt_check $1-))
43}
44alias -l ctt_check {
45 ; $1- = filename
46 if (($isfile($1-)) && (!$isdefaulttheme($1-))) {
47 $converttheme($1-)
48 }
49}
50alias setfonts {
51 setfont channel fchannel
52 setfont query fquery
53 setfont status fstatus
54}
55alias -l setfont {
56 ; $1 = friendlyname, $2 = mircininame
57 var %font = $readini($mircini,n,fonts,$2)
58 $inf(font,$1,$gettok(%font,1,44)).set
59 $inf(font,$+($1,.,size),$iif(($gettok(%font,2,44) isnum),$fontsize($v1).towindows)).set
60}
61alias deftheme {
62 if ($istheme($inf(theme,lasttheme))) { return $inf(theme,lasttheme) }
63 return $const(default,theme)
64}
65
66
67; --- unload clean
68
69on *:unload:{
70 closedialogs themes
71 unloadlib theme
72 unloadmodule themes_dlg
73 .timerthemeload -io 1 0 loadmodule nothemes
74}
75
76
77; --- groups
78
79on *:signal:setgroups:{
80 setgroups
81}
82alias -l setgroups {
83 setthemeprefixgroups
84 setthemeprefixnicklistgroups
85 setgroup themes_echodcctransfers $inf(theme,echodccs)
86 setgroup themes_nomircdccs $inf(theme,nomircdccs)
87 setgroup themes_hiding $inf(themehiding,on)
88}
89alias -l setthemeprefixgroups {
90 if ($inf(prefix,on)) {
91 if ($inf(theme,msgnickcolors)) {
92 setgroup themes_prefix 0
93 setgroup themes_prefix_color 1
94 }
95 else {
96 setgroup themes_prefix 1
97 setgroup themes_prefix_color 0
98 }
99 }
100 else {
101 setgroup themes_prefix 0
102 setgroup themes_prefix_color 0
103 }
104}
105alias -l setthemeprefixnicklistgroups {
106 if ($inf(prefix,nicklist)) {
107 setgroup themes_prefix_nicklist 1
108 setgroup themes_prefix_custom 0
109 }
110 else {
111 setgroup themes_prefix_nicklist 0
112 setgroup themes_prefix_custom 1
113 }
114}
115
116
117; --- register toggles
118
119on *:signal:set.prefix.on:{ setthemeprefixgroups }
120on *:signal:set.prefix.nicklist:{ setthemeprefixnicklistgroups }
121on *:signal:set.theme.msgnickcolors:{ setthemeprefixgroups }
122on *:signal:set.theme.echodccs:{ setgroup themes_echodcctransfers $1 }
123on *:signal:set.theme.nomircdccs:{ setgroup themes_nomircdccs $1 }
124on *:signal:set.themehiding.on:{ setgroup themes_hiding $1 }
125
126
127; --- feedback signals
128
129on *:signal:makechn:{
130 $$1- themehiding -1 themehiding on theme engine event hiding
131}
132
133
134; --- hashcache
135
136on *:signal:hashcache:{
137 fixdatas
138}
139alias -l fixdatas {
140 fixdata txt prefix q
141 fixdata txt prefix a
142 fixdata txt prefix o
143 fixdata txt prefix h
144 fixdata txt prefix v
145 fixdata reg theme noclones
146 fixdata reg theme notice.activeonly
147 fixdata reg theme notice.notinactive
148 fixdata reg theme notice.channelonly
149 fixdata reg theme opsnotice.channelonly
150 fixdata reg themehiding join
151 fixdata reg themehiding part
152 fixdata reg themehiding quit
153}
154
155
156; --- on start
157
158on *:start:{
159 savetheme
160}
161alias -l savetheme {
162 if (($islib(theme)) && ($istheme($theme.name))) {
163 $inf(theme,lasttheme,$theme.name).set
164 }
165}
166
167
168; --- channel status nick prefixes
169
170#themes_prefix_color off
171
172alias prefnonick {
173 ; $1 = nick, $2 = chan
174 if ($prefix2mode($left($nick($2,$1).pnick,1))) {
175 return $+($chr(3),$nick($2,$1).color,$v1)
176 }
177 return $+($chr(3),$nick($2,$1).color)
178}
179
180#themes_prefix_color end
181#themes_prefix on
182
183alias prefnonick {
184 ; $1 = nick, $2 = chan
185 if ($prefix2mode($left($nick($2,$1).pnick,1))) {
186 return $v1
187 }
188}
189
190#themes_prefix end
191#themes_prefix_nicklist on
192
193alias prefix2mode {
194 if ($1 isin $prefix) {
195 return $1
196 }
197}
198
199#themes_prefix_nicklist end
200#themes_prefix_custom off
201
202alias prefix2mode {
203 if ($pos(-+%@!&*.~,$1) isnum 1-) { return $data(txt,prefix,$mid(vvhoaaqqq,$v1,1)) }
204}
205
206#themes_prefix_custom end
207
208
209; --- themed aliases
210
211alias prefnonick { }
212alias avnick { return $prefnick($nick,$chan) }
213alias c { return $+ $data(txt,color,$1) }
214alias say_noenc { if (($active == status window) || ($left($active,1) == @)) { return } | !.msg $active $1- | echo $color(own) -aqtm $mytext($prefnick($me,$active),$1-) }
215alias describe_noenc { !.describe $1- | if (!$show) { return } | if ($window($1)) { echo $color(action) -tm $1 $myaction($prefnick($me,$1),$2-) } | elseif ($left($1,1) !== $chr(61)) { echo $color(action) -atm -> * $+ $1 $+ * $2- } }
216alias msg_noenc { !.msg $1- | if (!$show) { return } | if ($window($1)) { echo $color(own) -tm $1 $mytext($prefnick($me,$1),$2-) } | elseif ($left($1,1) !== $chr(61)) { echo $color(own) -atm -> * $+ $1 $+ * $2- } | checklistsignal $1- }
217
218
219; --- themed events
220
221on &^*:text:*:#:{
222 whilefix
223 tokenize 32 $fill($1-)
224 if ($msgstamp > 0) { echo $color(text) -mlbf $chan $asctime($msgstamp,$timestampfmt) $nb $1- }
225 else { echo $color(text) -tmlbf $chan $nb $1- }
226 halt
227}
228on ^*:text:*:?:{
229 whilefix
230 tokenize 32 $fill($1-)
231 if ($msgstamp > 0) { echo $color(text) -mlbf $nick $asctime($msgstamp,$timestampfmt) $nbc $1- }
232 else { echo $color(text) -tmlbf $nick $nbc $1- }
233 halt
234}
235on ^*:action:*:#:{
236 whilefix
237 if ($str($chr(32),2) isin $rawmsg) {
238 $null($regex(cact,$rawmsg,$+($chr(1),ACTION\s(.+),$chr(1),$)))
239 tokenize 32 $fillonly($regml(cact,1))
240 }
241 if ($msgstamp > 0) { echo $color(action) -mlbf $chan $asctime($msgstamp,$timestampfmt) $chanaction($1-) }
242 else { echo $color(action) -tmlbf $chan $chanaction($1-) }
243 halt
244}
245on ^*:action:*:?:{
246 whilefix
247 if ($str($chr(32),2) isin $rawmsg) {
248 $null($regex(pact,$rawmsg,$+($chr(1),ACTION\s(.+),$chr(1),$)))
249 tokenize 32 $fillonly($regml(pact,1))
250 }
251 if ($msgstamp > 0) { echo $color(action) -mlbf $nick $asctime($msgstamp,$timestampfmt) $privaction($1-) }
252 else { echo $color(action) -tmlbf $nick $privaction($1-) }
253 halt
254}
255on ^*:chat:action *:{
256 if ($str($chr(32),2) isin $rawmsg) {
257 $null($regex(dact,$rawmsg,$+($chr(1),ACTION\s(.+),$chr(1),$)))
258 tokenize 32 $fillonly($regml(dact,1))
259 }
260 else {
261 tokenize 32 $gettok($2-,1-,1)
262 }
263 echo $color(action) -tmlbf =$nick $chataction($1-)
264 halt
265}
266on ^*:chat:*:{ tokenize 32 $fillchat($1-) | echo $color(text) -tmlbf =$nick $nbc $1- | halt }
267on me:^*:join:#:{ whilefix | echo $chan $rc(onjoin,self) | halt }
268
269#themes_hiding off
270
271on !^*:join:#:{
272 whilefix
273 $checkforfloods
274 if ((!$data(reg,themehiding,join)) || (!$chn(themehiding).getsafe)) {
275 echo $color(join) -t $chan $chanjoin $clonechk $userstatsinfoline($nick,$wildsite)
276 }
277 halt
278}
279on !^*:part:#:{
280 whilefix
281 if ((!$data(reg,themehiding,part)) || (!$chn(themehiding).getsafe)) {
282 if ($fill($1-) !== $null) { tokenize 32 $+($v1,$chr(15)) }
283 else { tokenize 32 }
284 echo $color(part) -t $chan $chanpart($1-)
285 }
286 halt
287}
288on ^*:quit:{
289 whilefix
290 if ($fill($1-) !== $null) { tokenize 32 $+($v1,$chr(15)) }
291 else { tokenize 32 }
292 if (!$data(reg,themehiding,quit)) { themeechoquits $1- | halt }
293 var %c,%o = $comchan($nick,0)
294 if ($query($nick)) { .signal echo -t $v1 $tag $cborder($nick) has quit irc $iif(($1- !== $null),$cbrack($v1)) }
295 while (%o) {
296 whilefix
297 %c = $comchan($nick,%o)
298 if (!$chns($cid,%c,themehiding).getsafe) { echo $color(quit) -t %c $chanquit($prefnick($nick,%c),$1-) }
299 dec %o
300 }
301 halt
302}
303
304#themes_hiding end
305
306on !^*:join:#:{
307 whilefix
308 $checkforfloods
309 echo $color(join) -t $chan $chanjoin $clonechk $userstatsinfoline($nick,$wildsite)
310 halt
311}
312on !^*:part:#:{
313 whilefix
314 if ($fill($1-) !== $null) { tokenize 32 $+($v1,$chr(15)) }
315 else { tokenize 32 }
316 echo $color(part) -t $chan $chanpart($1-)
317 halt
318}
319on ^*:quit:{
320 whilefix
321 if ($fill($1-) !== $null) { tokenize 32 $+($v1,$chr(15)) }
322 else { tokenize 32 }
323 themeechoquits $1-
324 halt
325}
326
327alias -l themeechoquits {
328 var %c,%o = $comchan($nick,0)
329 if ($query($nick)) { .signal echo -t $v1 $tag $cborder($nick) has quit irc $iif(($1- !== $null),$cbrack($v1)) }
330 while (%o) {
331 whilefix
332 %c = $comchan($nick,%o)
333 echo $color(quit) -t %c $chanquit($prefnick($nick,%c),$1-)
334 dec %o
335 }
336}
337alias -l clonechk {
338 if ($data(reg,theme,noclones)) { return }
339 tokenize 32 $ialchan($wildsite,$chan,0)
340 if ($1 <= 1) { return }
341 var %t,%m,%k,%o = $1 | while (%o) {
342 whilefix
343 if ($ialchan($wildsite,$chan,%o).nick !== $nick) {
344 %t = $prefnick($v1,$chan) $+ &
345 inc %m $calc(1 + $len(%t))
346 if (%m > 600) { %k = %k ... | break }
347 %k = %k %t
348 }
349 dec %o
350 }
351 return $channelclone($1,$gettok(%k,1-,38))
352}
353alias -l userstatsinfoline {
354 ; $1 = nick, $2 = wildsite
355 if ($data(reg,userstats,on)) {
356 var %msg
357 if (($data(reg,userstats,showlines)) && ($dat(user,$+($getnet,.,$1)).exists)) { %msg = $sv(lines,$dat(user,$+($getnet,.,$1)).linesspoken) }
358 if ($data(reg,userstats,showclass)) { %msg = %msg $sv(class,$remtok($hget(wild,$2),$1,1,32)) }
359 return %msg
360 }
361}
362alias -l sv { if ($2) { return $1 $+ : $+ $border($2-) } }
363
364on !^*:nick:{
365 whilefix
366 var %o = $comchan($newnick,0) | while (%o) {
367 whilefix
368 tokenize 32 $comchan($newnick,%o) $prefnonick($newnick,$comchan($newnick,%o))
369 echo $color(nick) -t $1 $channickchange($+($2,$nick,),$+($2,$newnick,))
370 dec %o
371 }
372 halt
373}
374on ^*:nick:{ whilefix | allecho $color(nick) -t $mynickchange | halt }
375alias -l allecho {
376 var %o = $chan(0)
377 while (%o) { whilefix | echo $1-2 $chan(%o) $3- | dec %o }
378 echo $1-2 $+ s $3-
379 if (($cid == $activecid) && ($active !ischan) && ($active !== status window)) {
380 echo $1-2 $+ a $3-
381 }
382}
383on ^*:usermode:{ whilefix | acecho $mymodechange($1-) | halt }
384on ^*:rawmode:#:{ whilefix | echo $color(mode) -t $chan $chanmodechange($avnick,$1,$2-) | halt }
385on &^*:invite:#:{
386 whilefix
387 if ($cid !== $activecid) { echo $color(invite) -atm $privinvite($+($shortservname,$nick),$1-) }
388 else { echo $color(invite) -atm $privinvite($nick,$1-) }
389 halt
390}
391on ^*:topic:#:{ whilefix | tokenize 32 $fill($1-) | echo $color(topic) -t $chan $chantopic($avnick,$+($chr(15),$1-,$chr(15))) | halt }
392on ^*:kick:#:{
393 whilefix
394 if ($fill($1-) !== $null) { tokenize 32 $+($v1,$chr(15)) }
395 else { tokenize 32 }
396 if ($knick == $me) {
397 echo $color(kick) -t $chan $activechankickme($1-)
398 if (($cid !== $activecid) || ($chan !== $active)) { asecho $chankickme($1-) }
399 }
400 else { echo $color(kick) -t $chan $chankick($avnick,$prefnick($knick,$chan),$1-) }
401 halt
402}
403on ^*:notice:*:#:{
404 whilefix
405 tokenize 32 $fill($1-)
406 if ((($chan !== $active) || ($activecid !== $cid)) && (!$data(reg,theme,notice.channelonly)) && (($target !== $+(@,$chan)) || (!$data(reg,theme,opsnotice.channelonly)))) {
407 if ($cid !== $activecid) { echo $color(notice) -atm $channotice($+($shortservname,$avnick),$1-) }
408 else { echo $color(notice) -atm $channotice($avnick,$1-) }
409 }
410 echo $color(notice) -tm $chan $channotice($avnick,$1-)
411 halt
412}
413on &^*:notice:*:?:{
414 whilefix
415 tokenize 32 $fill($1-)
416 if (!$data(reg,theme,notice.activeonly)) {
417 var %o = $comchan($nick,0) | while (%o) {
418 whilefix
419 echo $color(notice) -tm $comchan($nick,%o) $privnotice($prefnick($nick,$comchan($nick,%o)),$1-)
420 dec %o
421 }
422 }
423 if (($nick !ison $active) || ($activecid !== $cid) || ($data(reg,theme,notice.activeonly))) {
424 if ($data(reg,theme,notice.notinactive)) { echo $color(notice) -stm $privnotice($nick,$1-) }
425 elseif ($cid !== $activecid) { echo $color(notice) -atm $privnotice($+($shortservname,$nick),$1-) }
426 elseif ($nick ison $active) { echo $color(notice) -atm $privnotice($prefnick($nick,$active),$1-) }
427 else { echo $color(notice) -atm $privnotice($nick,$1-) }
428 }
429 halt
430}
431ctcp &^*:xdcc *:?:{ whilefix | if ((!$inf(xdcc,on)) || (!$inf(xdcc,hidectcp))) { privctcpecho $1- } | halt }
432alias -l privctcpecho {
433 ; $1- = ctcp
434 if ($gettok($fill($1-),1-,1) !== motfv) { tokenize 32 $v1 }
435 else { tokenize 32 VERSION }
436 if ($inf(theme,ctcp.instatus)) { echo $color(ctcp) -stm $privctcp($nick,$1,$2-) }
437 elseif ($cid !== $activecid) { echo $color(ctcp) -atm $privctcp($+($shortservname,$nick),$1,$2-) }
438 else { echo $color(ctcp) -atm $privctcp($nick,$1,$2-) }
439}
440ctcp &^*:page *:?:{ whilefix | if (!$inf(pager,enabled)) { privctcpecho $1- } | halt }
441ctcp &^*:ping *:?:{ whilefix | if ($inf(ignore,ping) == all) { halt } | privctcpecho $1- }
442ctcp &^*:dcc *:?:{ whilefix }
443ctcp &^*:version:*:{ whilefix | halt }
444ctcp &^*:*:?:{ whilefix | privctcpecho $1- | halt }
445ctcp ^*:*:#:{
446 whilefix
447 if ($gettok($fill($1-),1-,1) !== motfv) { tokenize 32 $v1 }
448 else { tokenize 32 VERSION }
449 if ($inf(theme,ctcp.instatus)) { echo $color(ctcp) -stm $chanctcp($avnick,$1,$2-) }
450 else {
451 echo $color(ctcp) -tm $chan $chanctcp($avnick,$1,$2-)
452 if ($cid !== $activecid) { echo $color(ctcp) -atm $chanctcp($+($shortservname,$avnick),$1,$2-) }
453 elseif ($chan !== $active) { echo $color(ctcp) -atm $chanctcp($avnick,$1,$2-) }
454 }
455 halt
456}
457on &*:ctcpreply:*:{
458 whilefix
459 tokenize 32 $gettok($fill($1-),1-,1)
460 if ($cid !== $activecid) { echo $color(ctcp) -atm $privctcpreply($+($shortservname,$nick),$1,$2-) }
461 else { echo $color(ctcp) -atm $privctcpreply($nick,$1,$2-) }
462 halt
463}
464on ^*:snotice:*:{
465 whilefix
466 if ($notarealservernotice) {
467 tokenize 32 $fill($1-)
468 if ($cid !== $activecid) { echo $color(notice) -atm $privnotice($+($shortservname,$gettok($nick,1,46)),$1-) }
469 else { echo $color(notice) -atm $privnotice($gettok($nick,1,46),$1-) }
470 halt
471 }
472}
473on *:input:status window:{ whilefix }
474on *:input:@:{ whilefix }
475on &*:input:*:{
476 whilefix
477 if ($1- == $null) { if (!$inpaste) { return } | tokenize 32 $chr(160) }
478 if (($left($1,1) !== /) || ($inpaste) || ($mouse.key & 2)) { haltdef | say $1- }
479 elseif (($1 == /me) && ($2- !== $null)) { haltdef | describe $target $2- }
480}
481on *:disconnect:{ whilefix | if ($timeonline) { disconnectlogo } }
482alias -l disconnectlogo {
483 if ($cid == $activecid) { aecho $logo }
484 else {
485 secho $logo
486 if ($inf(theme,ondisconnect)) {
487 aecho $csv($rc(onconnect,disconnected),$servname)
488 }
489 }
490}
491
492
493; --- dcc transfer notification
494
495#themes_echodcctransfers on
496
497on *:signal:filercvd:{
498 ; $1 = nick, $!2 = ip, $3 = cps, $4 = secs, $5 = size, $6- = filename
499 aecho successfully received $cborder($nopath($6-)) $cbrack($size($5)) from $1 at $cborder($size($3) $+ /s) $csv(in,$hourtime($4)) $safeid(openlastreceivedmessage)
500}
501on *:signal:getfail:{
502 ; $1 = nick, $!2 = ip, $3 = pct, $4 = secs, $5 = size, $6- = filename
503 error failed to receive $cborder($nopath($6-)) $brack($size($5)) from $1 at $cborder($3 $+ $chr(37)) $csv(after,$hourtime($4))
504}
505on *:signal:filesent:{
506 ; $1 = nick, $!2 = ip, $3 = cps, $4 = secs, $5 = size, $!6 = wid, $7 = exists, $8- = filename
507 $iif(($7),secho,aecho) successfully sent $cborder($nopath($8-)) $brack($size($5)) to $1 at $cborder($size($3) $+ /s) $csv(in,$hourtime($4))
508}
509on *:signal:sendfail:{
510 ; $1 = nick, $!2 = ip, $3 = pct, $4 = secs, $5 = size, $!6 = wid, $7 = exists, $!8 = bytessent, $9- = filename
511 $iif(($7),statuserror,error) failed to send $cborder($nopath($9-)) $brack($size($5)) to $1 at $cborder($3 $+ $chr(37)) $csv(after,$hourtime($4))
512}
513
514#themes_echodcctransfers end
515
516
517; --- no mirc dcc transfer echo messages
518
519#themes_nomircdccs off
520
521on ^*:filercvd:*:{
522 whilefix
523 haltdef
524}
525on ^*:getfail:*:{
526 whilefix
527 haltdef
528}
529on ^*:filesent:*:{
530 whilefix
531 haltdef
532}
533on ^*:sendfail:*:{
534 whilefix
535 haltdef
536}
537
538#themes_nomircdccs end
539
540
541; --- global theme aliases
542
543alias themefile { return $+($themedir,$1-,.upp) }
544alias istheme { if ($1- !== $null) { return $isfile($themefile($v1)) } }
545alias themedir { return $path(directories,themes) }
546alias themepicdir { return $path(directories,themepics) }
547alias namedtheme { if ($left($theme.name,8) !== default_) { return $theme.name } }
548alias themednotifylistprops { return background,textcolor,textbg,caption,position }
549alias themedcontrolpanelprops { return background,textcolor,textbg,caption,position,flags,headerdims,iconview,icp }
550alias themedbackgrounds { return main,status,channel,query,menubar,menubuttons,switchbar,treebar }
551
552
553; --- drag and drop support
554
555alias themesend {
556 tokenize 32 $1-
557 if ($left($1,1) == $chr(35)) { loadtheme $2- }
558 else { $dccc(send $1 n/a $2-) }
559}
560
561
562; --- loading themes
563
564alias loadtheme {
565 ; $1- = themename|themefile
566 tokenize 32 $1-
567 if ($istheme($1-)) { tokenize 32 $themefile($1-) }
568 if ((!$isfile($1-)) && (!$islib(theme))) {
569 dbout cannot load theme $1-
570 tokenize 32 $themefile($const(default,theme))
571 }
572 if ($isfile($1-)) {
573 tokenize 32 $realfn($1-)
574 pretheme $1-
575 if ((!$istheme($noext($nopath($1-)))) || ($crc($1-) !== $crc($themefile($noext($nopath($1-)))))) { .copy -o $quo($1-) $quo($themedir) }
576 var %a = $iif((!$show),.) $+ continuethemeload
577 .timerloadingtheme -io 1 0 %a $uneval($1-)
578 }
579 elseif (!$isid) { error no such theme $quo($1-) }
580}
581alias -l pretheme {
582 mkemptydir $themepicdir
583 $null($unzip($1-,$themepicdir))
584}
585alias continuethemeload {
586 ; $1- = themefile
587 var %file = $+($themepicdir,theme.txt)
588 var %themename = $noext($nopath($1-))
589 if ($isfile(%file)) {
590 $overwritethemename(%themename)
591 .copy -o $quo(%file) $quo($+($mircdir,system\aliases\,theme.txt))
592 if (!$isfile($+($mircdir,system\aliases\,theme.txt))) {
593 error failed to copy themefile $quo(%file) to $quo($+($mircdir,system\aliases\,theme.txt))
594 }
595 else {
596 $iif((!$show),.) $+ applytheme
597 }
598 }
599 else {
600 error invalid themefile found, cannot load theme $quo(%themename)
601 }
602}
603alias -l overwritethemename {
604 ; $1 = themename
605 var %file = $+($themepicdir,theme.txt)
606 $null($read(%file,ns,theme.name))
607 if ($readn) {
608 write -l $+ $v1 $quo(%file) theme.name $evbrack(return,$noevalsafe($1))
609 }
610}
611alias isdefaulttheme {
612 ; $1 = themename|themefile
613 return $istok($const(list,themes),$noext($nopath($1-)),44)
614}
615alias applytheme {
616 if ($1- !== -n) {
617 tokenize 32 -n
618 if ($islib(theme)) { .reload -a $quo($v1) }
619 else { .timer -io 1 1 applytheme -n | loadlib theme | return }
620 }
621 elseif (!$islib(theme)) { error could not load theme file $quo($lib2file(theme)) | return }
622 setthemecolors $1
623 setthemefonts $1
624 setthemescriptcolors
625 setthemestamp
626 setthemeprefix
627 setthemecontrolpanel
628 setthemenotifylist
629 setthemecontrolpanelicons
630 setthemenotifylisticons
631 setthemecnicks
632 if ($show) { clearany }
633 setthemebackgrounds
634 saveini
635 var %a = $iif((!$show),.) $+ themeecho
636 .timerthemeecho -io 1 0 %a
637}
638alias themeecho {
639 savetheme
640 if ($show) { aecho $bracket(loaded theme,$theme.name) $csv(by,$theme.author) }
641 .signal theme_loaded $theme.name
642}
643on *:signal:theme_loaded:{
644 writeini -n $quo($mircini) colors n0 $+(mIRC Classic,$chr(44),$themed_events)
645 writeini -n $quo($mircini) palettes n0 $themed_colors
646 flushini $quo($mircini)
647 .color -l
648 setfonts
649}
650alias themed_events {
651 ; !$1-
652 var %k = background,action,ctcp,highlight,info,info2,invite,join,kick,mode,nick,normal,notice,notify,other,own,part,quit,topic,wallops,whois,editbox,editbox text,listbox,listbox text,gray,title,inactive,treebar,treebar text
653 var %r,%i = 1,%o = $numtok(%k,44) | while (%i <= %o) {
654 %r = $instok(%r,$color($gettok(%k,%i,44)),0,44)
655 inc %i
656 }
657 return %r
658}
659alias themed_colors {
660 ; !$1-
661 var %r,%i = 0,%o = 15 | while (%i <= %o) {
662 %r = $instok(%r,$color(%i),0,44)
663 inc %i
664 }
665 return %r
666}
667alias deletetheme {
668 ; $1- = themename|themefile
669 if ($istheme($1-)) { tokenize 32 $themefile($1-) }
670 var %themename = $noext($nopath($1-))
671 if ($isfile($1-)) {
672 if (!$isdefaulttheme($1-)) {
673 if ($innput(deletetheme,%themename)) { ifsremove $1- }
674 else { halt }
675 }
676 else { halt $innput(error,you cannot delete default themes $crlf $+ using this dialog. $crlf $crlf $+ the default themes are: $crlf $+ $replace($const(list,themes),$chr(44),$crlf)) }
677 }
678 else { halt $innput(error,no such theme $quo(%themename)) }
679}
680
681
682; --- loading themes - backgrounds
683
684alias setthemebackgrounds {
685 .signal theme.background $themedbackgrounds
686}
687on *:signal:theme.background:{
688 ; $1 = backgrounds
689 var %background,%i = 1,%o = $numtok($1,44) | while (%i <= %o) {
690 %background = $safeid($+(background.,$gettok($1,%i,44)))
691 if (%background !== $null) {
692 if ($deltok($1,1- $+ %i,44) !== $null) { .signal $signal $v1 }
693 _background $gettok($1,%i,44) %background
694 return
695 }
696 inc %i
697 }
698}
699
700
701; --- loading themes - fonts
702
703alias -l setthemefonts {
704 if ($theme.fontchannel) { .signal $1 theme.font -c $v1 }
705 if ($theme.fontstatus) { .signal $1 theme.font -s $v1 }
706 if ($theme.fontquery) { .signal $1 theme.font -q $v1 }
707}
708on *:signal:theme.font:{ if ($1-) { _font $v1 } }
709
710
711; --- loading themes - cnicks
712
713alias -l setthemecnicks {
714 var %n = $1
715 if ($safeid(theme.msgnickcolors) !== $null) { $inf(theme,msgnickcolors,$v1).set }
716 tokenize 32 $str($chr(32) $+ -r,$cnick(0))
717 .signal %n theme.cnick $*
718 if ($safeid(theme.cnicks)) { .signal %n theme.cnick $numtok($theme.cnicks,44) }
719}
720on *:signal:theme.cnick:{
721 if ($1 == -r) { .cnick -r 1 }
722 elseif ($1 isnum 1-) {
723 .cnick $gettok($theme.cnicks,$v1,44)
724 .signal $signal $calc($v1 -1)
725 }
726}
727
728
729; --- loading themes - colors
730
731alias -l setthemecolors {
732 .color -s mirc classic
733 var %n = $1
734 tokenize 44 $+($theme.events,$chr(44),$theme.colors)
735 .signal %n theme.color $*
736}
737on *:signal:theme.color:{ .color $1- }
738
739
740; --- loading themes - scriptcolors
741
742alias -l setthemescriptcolors {
743 if ($safeid(theme.color1) !== $null) { $inf(color,1,$v1).set }
744 if ($safeid(theme.color2) !== $null) { $inf(color,2,$v1).set }
745}
746
747
748; --- loading themes - timestamp
749
750alias -l setthemestamp {
751 $inf(timestamp,on,$iif(($safeid(theme.timestamp)),1,0)).set
752 var %timestampfmt = $safeid(theme.timestampfmt)
753 $inf(timestamp,timestamp,$iif((%timestampfmt === $ts(2)),2,$iif((%timestampfmt === $ts(1)),1,%timestampfmt))).set
754 settimestamp
755}
756
757
758; --- loading themes - prefixes
759
760alias -l setthemeprefix {
761 var %k = on.nicklist.v.h.o.a.q,%o = $numtok(%k,46) | while (%o) {
762 setprefixsetting $gettok(%k,%o,46)
763 dec %o
764 }
765}
766alias -l setprefixsetting {
767 ; $1 = prefixtype
768 if ($safeid($+(prefix_,$1)) !== $null) { $inf(prefix,$1,$v1).set }
769}
770
771
772; --- loading themes - controlpanel/notifylist settings
773
774alias -l setthemecontrolpanel {
775 var %k = $themedcontrolpanelprops,%o = $numtok(%k,44) | while (%o) {
776 setcontrolpanelsetting $gettok(%k,%o,44)
777 dec %o
778 }
779}
780alias -l setthemenotifylist {
781 var %k = $themednotifylistprops,%o = $numtok(%k,44) | while (%o) {
782 setnotifylistsetting $gettok(%k,%o,44)
783 dec %o
784 }
785}
786alias -l setnotifylistsetting {
787 ; $1 = setting
788 if ($safeid($+($1,.notifylist)) !== $null) { $dyn(dlg,notify,$1 $v1).set }
789}
790alias -l setcontrolpanelsetting {
791 ; $1 = setting
792 if ($safeid($+($1,.controlpanel)) !== $null) { $dyn(dlg,control,$1 $v1).set }
793}
794alias -l setthemecontrolpanelicons {
795 var %icons = $safeid(theme.controlpanelicons),%cpitem,%o = $dat(cpitem).num | while (%o) {
796 %cpitem = $dat(cpitem,%o).itemat
797 if ($istok(%icons,%cpitem,44)) {
798 $dat(cpitem,%cpitem,$defaultthemedicon(%cpitem)).iconset
799 }
800 elseif ($dat(cpitem,%cpitem).icon == $defaultthemedicon(%cpitem)) {
801 $dat(cpitem,%cpitem,$defaultunthemedicon(%cpitem)).iconset
802 }
803 dec %o
804 }
805}
806alias -l setthemenotifylisticons {
807 var %icon,%icons = $safeid(theme.notifylisticons),%notifyicons = online,offline
808 var %o = $numtok(%notifyicons,44) | while (%o) {
809 %icon = $gettok(%notifyicons,%o,44)
810 if ($istok(%icons,%icon,44)) {
811 $inf(notify,$+(icon.,%icon),$defaultthemedicon(%icon)).set
812 }
813 elseif ($inf(notify,$+(icon.,%icon)) == $defaultthemedicon(%icon)) {
814 $inf(notify,$+(icon.,%icon),$defaultnotifyicon(%icon)).set
815 }
816 dec %o
817 }
818}
819
820
821; --- table themes
822
823dialog themes {
824 title "theme manager"
825 size -1 -1 290 220
826 option dbu
827 tab "load theme", 1, 8 4 274 192
828 box "available themes", 2, 16 24 94 166, tab 1
829 list 3, 24 36 78 134, tab 1 sort size
830 button "&load", 4, 24 172 37 12, tab 1
831 button "&delete", 77, 64 172 37 12, tab 1
832 box "theme details", 5, 116 24 158 166, tab 1
833 text "name", 6, 124 37 33 8, tab 1 right
834 edit "", 7, 160 36 106 10, tab 1 read autohs
835 text "author", 8, 124 49 33 8, tab 1 right
836 edit "", 9, 160 48 106 10, tab 1 read autohs
837 text "created", 101, 124 61 33 8, tab 1 right
838 edit "", 102, 160 60 106 10, tab 1 read autohs
839 text "description", 16, 124 72 33 8, tab 1 right
840 edit "", 17, 124 80 142 42, tab 1 read multi autovs
841 button "&preview...", 83, 228 124 37 12, tab 1
842 text "included settings:", 66, 124 132 45 8, tab 1
843 check "", 10, 128 144 8 8, disable tab 1
844 text "timestamp", 69, 136 144 37 8, tab 1
845 check "", 14, 196 144 8 8, disable tab 1
846 text "controlpanel layout", 72, 204 144 57 8, tab 1
847 check "", 11, 128 152 8 8, disable tab 1
848 text "nick prefixes", 70, 136 152 37 8, tab 1
849 check "", 15, 196 152 8 8, disable tab 1
850 text "notifylist layout", 73, 204 152 57 8, tab 1
851 check "", 12, 128 160 8 8, disable tab 1
852 text "script colors", 71, 136 160 37 8, tab 1
853 check "", 13, 196 160 8 8, disable tab 1
854 text "nicklist colors", 74, 204 160 57 8, tab 1
855 text "fonts used", 67, 124 177 33 8, tab 1 right
856 edit "", 68, 160 176 106 10, tab 1 read
857 tab "settings", 18
858 box "font settings", 19, 16 24 258 50, tab 18
859 text "channel font", 20, 24 35 33 8, tab 18 right
860 edit "", 21, 60 34 54 10, tab 18 autohs
861 text "size", 22, 124 35 13 8, tab 18 right
862 edit "", 23, 140 34 26 10, tab 18 autohs
863 icon 34, 172 34 95 11, system\pics\pixel.bmp, 0, tab 18 noborder
864 text "chat font", 24, 24 47 33 8, tab 18 right
865 edit "", 25, 60 46 54 10, tab 18 autohs
866 text "size", 26, 124 47 13 8, tab 18 right
867 edit "", 27, 140 46 26 10, tab 18 autohs
868 icon 32, 172 46 95 11, system\pics\pixel.bmp, 0, tab 18 noborder
869 text "status font", 28, 24 59 33 8, tab 18 right
870 edit "", 29, 60 58 54 10, tab 18 autohs
871 text "size", 30, 124 59 13 8, tab 18 right
872 edit "", 31, 140 58 26 10, tab 18 autohs
873 icon 33, 172 58 95 11, system\pics\pixel.bmp, 0, tab 18 noborder
874 box "channel status nickprefixes", 45, 16 76 82 114, group tab 18
875 check "enable", 47, 24 88 34 8, tab 18
876 radio "use default prefixes", 98, 32 101 62 8, disable tab 18
877 radio "use custom:", 99, 32 113 50 8, disable tab 18
878 text "+q", 78, 24 128 21 8, disable tab 18 right
879 edit "", 79, 48 128 42 10, disable tab 18 autohs
880 text "+a", 62, 24 139 21 8, disable tab 18 right
881 edit "", 63, 48 139 42 10, disable tab 18 autohs
882 text "+o", 48, 24 150 21 8, disable tab 18 right
883 edit "", 49, 48 150 42 10, disable tab 18 autohs
884 text "+h", 50, 24 161 21 8, disable tab 18 right
885 edit "", 51, 48 161 42 10, disable tab 18 autohs
886 text "+v", 53, 24 172 21 8, disable tab 18 right
887 edit "", 54, 48 172 42 10, disable tab 18 autohs
888 box "nick colors", 81, 104 76 170 30, tab 18
889 check "color nicks in messages like nicks on the nicklist", 82, 112 88 130 8, tab 18
890 box "notes on creating themes", 46, 104 108 170 82, tab 18
891 text "to adjust color settings, inactive this dialog and hit alt+k", 37, 112 120 145 8, tab 18
892 text "to adjust nicklist colors, inactive this dialog, hit alt+b and see the 'nick' tab", 38, 112 136 157 16, tab 18
893 text "settings on this tab might be overwritten when you (re)load a theme. to safeguard your changes, click the 'theme builder' button to create a theme based on your current settings and theme.", 39, 112 160 157 28, tab 18
894 tab "behaviour", 52
895 box "disconnect", 55, 16 24 258 26, tab 52
896 check "show 'disconnected from...' message on disconnect from a non-active server", 36, 24 36 202 8, tab 52
897 box "ctcps", 61, 16 52 258 26, tab 52
898 check "show ctcps in the status window (default: show ctcps in the active window)", 59, 24 64 198 8, tab 52
899 box "dcc", 64, 16 80 126 34, tab 52
900 check "hide upp dcc transfer echo messages", 65, 24 92 106 8, tab 52
901 check "hide mirc dcc transfer echo messages", 100, 24 100 102 8, tab 52
902 box "join", 75, 148 80 126 34, tab 52
903 check "do not show clones in join message", 76, 156 92 102 8, tab 52
904 box "notices", 60, 16 116 258 50, tab 52
905 check "show private notices in active window only (default: show in active and in all common channels)", 56, 24 128 242 8, tab 52
906 check "do not show private notices in active window", 80, 24 136 122 8, tab 52
907 check "show channel notices in the target channel only (default: show in target and active window)", 57, 24 144 238 8, tab 52
908 check "show ops notices in the target channel only (default: show in target and active window)", 58, 24 152 226 8, tab 52
909 text "note: contrary to the previous tab, settings on this and the next tab cannot be themed, as they affect what to show and where, rather than how to show it.", 103, 20 172 249 16, tab 52
910 tab "event hiding", 84
911 box "settings", 85, 16 24 142 166, tab 84
912 check "hide the following events:", 86, 24 36 78 8, tab 84
913 check "join", 87, 32 48 26 8, disable tab 84
914 check "part", 88, 32 56 26 8, disable tab 84
915 check "quit", 89, 32 64 26 8, disable tab 84
916 text "on these channels:", 90, 32 80 53 8, disable tab 84
917 radio "all", 91, 32 92 19 8, disable tab 84
918 radio "all except", 92, 56 92 34 8, disable tab 84
919 radio "only", 93, 96 92 26 8, disable tab 84
920 combo 94, 32 104 84 74, disable tab 84 size
921 button "add", 95, 120 104 29 12, disable tab 84
922 button "remove", 96, 120 164 29 12, disable tab 84
923 text "network.channel", 97, 56 178 45 8, disable tab 84
924 button "&theme builder...", 35, 16 204 49 12, multi
925 text "current theme", 40, 72 200 77 8, center
926 button "&ok", 42, 156 204 37 12, default ok
927 button "&cancel", 43, 200 204 37 12, cancel
928 button "&apply", 44, 244 204 37 12
929 text "", 41, 72 208 77 8, center
930}
931
932
933; --- popup themes
934
935#themes_popup on
936
937menu menubar,status {
938 themes
939 .load theme
940 ..$submenu($thememenu($1))
941 .create theme... { dopen maketheme }
942 .settings... { dopen themes }
943 .-
944 .unload this module { unloadthemeengine }
945}
946alias -l thememenu {
947 if (($1 == begin) || ($1 == end)) { return - }
948 if ($noext($nopath($findfile($themedir,*.upp,$1,0)))) {
949 tokenize 32 $v1
950 var %i = $uneval($1-)
951 if ($1- == $theme.name) { return $style(1) %i :loadtheme %i }
952 return %i :loadtheme %i
953 }
954}
955alias -l unloadthemeengine { unloadmoduletree themes }
956
957
958#themes_popup end