dialog slap {
title "flupScript Slap Manager - uitgebreid door Bullseye"
size -1 -1 290 158
option dbu
list 1, 0 16 217 129, size
button "Random Slap", 2, 1 145 37 12
button "Selected Slap", 3, 59 145 37 12
button "Delete Slap", 4, 180 145 37 12
button "Add Slap", 5, 120 145 37 12
combo 8, 223 16 60 140, size vsbar drop
list 7, 223 27 60 117, size
text "flupScript Slap Manager - uitgebreid door Bullseye", 6, 7 3 140 8
edit "", 9, 222 3 61 10, read
}
on *:dialog:slap:*:*:{
if (!$istok(mouse edit,$devent,32) && $did != 3 && $active != @slap.preview && $window(@slap.preview)) { window -c $ifmatch }
if ($devent == init) {
did -r slap 1
loadbuf -o slap 1 slaps.txt
did -r slap 9
did -a slap 9 Total Slaps: $lines(slaps.txt)
set %schan $chan(0)
while (%schan > 0) {
did -a slap 8 $chan( $+ %schan $+ )
dec %schan
}
}
if ($devent == sclick) {
if ($did == 1) {
if ($did(1).seltext) {
preview
}
}
if ($did == 8) {
var %schans $did(8)
did -r slap 7
var %snicks $nick($did(8),0)
while (%snicks > 0) {
did -a slap 7 $nick($did(8), %snicks)
dec %snicks
}
}
if ($did == 5) {
write slaps.txt $?="Slap to add"
did -r slap 1
loadbuf -o slap 1 slaps.txt
did -r slap 9
did -a slap 9 Total Quotes: $lines(slaps.txt)
}
if ($did == 4) {
write -dl $+ $did(1).sel slaps.txt
did -r slap 1
loadbuf -o slap 1 slaps.txt
did -r slap 9
did -a slap 9 Total Quotes: $lines(slaps.txt)
}
if ($did == 3) {
var %ik = $did(8).text
var %nick = $did(7).seltext
var %msg = msg $did(8)
var %act = describe $did(8)
$read(slaps.txt,t, $did(1).sel)
}
if ($did == 2) {
var %ik = $did(8).text
var %nick = $did(7).seltext
var %msg = msg $did(8)
var %act = describe $did(8)
$read(slaps.txt,t)
}
}
}
menu channel {
.Slap Manager:dialog -m slap slap
}
alias -l preview {
var %font = $window(Status Window).font,%size = $window(Status Window).fontsize,%x = $calc($dialog(slap).x +1),%y = $calc($dialog(slap).y + 346),%text = $read(slaps.txt, $did(1).seltext),%w = $iif($calc($window(-1).w - %x) < 602,$calc($v1 - 4),$v2),%text.w = $width($burcwrap(%text,%font,%size,$calc(%w -4),1,1),%font,%size,0,1),%w = $calc(%text.w + 6),%lines = $burcwrap(%text,%font,%size,%w,1,0),%line.h = $height(%text,%font,%size),%text.h = $calc(%lines * %line.h),%h = $iif($calc($window(-1).h - %y) < $calc(%text.h + 6),$calc($v1 -2),$v2)
if ($window(@slap.preview)) {
var %wnd = $ifmatch
window -f %wnd %x %y %w %h
}
else {
window -pdk0fhB +dL @slap.preview %x %y %w %h
}
window -o @slap.preview
drawrect -rf @slap.preview 15794175 1 0 0 %w %h
;15794175
drawrect -r @slap.preview 0 1 0 0 %w %h
var %q = 1
while (%q <= %lines) {
var %drawtext = $burcwrap(%text,%font,%size,$calc(%w -4),1,%q)
drawtext -bpr @slap.preview $color($color(action)) 15794175 %font %size 4 $calc((%q -1) * %line.h +2) %drawtext
inc %q
}
}
menu @slap.preview {
fix position:preview
}
on *:appactive:{
if (!$appactive && $window(@slap.preview)) { window -c @slap.preview }
}
alias -l burcwrap {
var %text = $1, %c $chr(44)
tokenize 44 $+($2,%c,$3,%c,$4,%c,$iif($0 == 5,1 $+ %c),$$5,%c,$6)
if ($istok(1.0,$5,46) == $true) {
return $wrap(%text,$1,$2,$3,$4,$5)
}
var %regex = /(\d{0,2})/g, %regex2 /\d{0,2},(\d{1,2})/g, %b = 1,
var %str, %cc1, %cc2
while (%b < $($ $+ $0,2)) {
%str = %str $+ $wrap(%text,$1,$2,$3,$4,%b)
inc %b
}
if ($regex(%str,%regex)) %cc1 = $regml($regml(0))
if ($regex(%str,%regex2) > 0) %cc2 = $regml($regml(0))
if (%cc1 $+ %cc2) var %cc = $+(,%cc1,$iif(%cc2,$chr(44) $+ %cc2))
return $iif(2 \\ $count(%str,) ,) $+ $iif(2 \\ $count(%str,),) $+ $&
$iif(2 \\ $count(%str,),) $+ $iif(%cc,%cc) $+ $wrap(%text,$1,$2,$3,$4,$5)
}