;;;;Buzz-Zyrus SoulFly Multi-Gamer by d33j4y™  ©2010 EvolutionScriptz d0t c0m;;;;
;;;;;;;;;;;;Evolution Scriptz Website http://www.evolutionscriptz.com;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;Buzzen Nicklist coded by err0r;;;;;;;;;;;;;;;;;;;;;;;;;

alias activatenl { $iif($group(#nicklist) == on,stopnl,startnl) }

alias startnl {
  enable #nicklist
  if ($chr(35) isin $active) {
    buzzdock $active
    buzzref $active
  }
}


alias stopnl {
  disable #nicklist
  var %a = 1
  while $scon(%a) {
    var %b = $ifmatch, %c = 1
    scid %b
    while $chan(%c) {
      if ($dialog(nick $+ $chan(%c))) { /dialog -x nick $+ $chan(%c)).hwnd }
      if ($dialog(buzznick $+ $chan(%c))) { /dialog -x buzznick $+ $chan(%c)).hwnd }
      inc %c
    }
    inc %a
  }
  scid -r
}

ON *:SIGNAL:nicklist_resize: {
  if ($4 == 1) && ($dialog($1)) { 
    dialog -s $1 0 0 $2 $3 | dll $mdx.nl MoveControl $1 2 0 0 $2 23 | dll $mdx.nl MoveControl $1 1 0 24 $2 $calc($3 -25)
  }
}
alias nickdll.nl { return $shortfn(dlls\nicklist.dll) }
alias mdx.nl { return $shortfn(dlls\mdx.dll) }
alias views.nl { return $shortfn(dlls\views.mdx) }
alias iconsnl { return $shortfn(imgs\icons\ $+ $1 $+ .ico) }
alias issuperownernl return  $iif($left($nick($1,$2).pnick,1) == ',$true,$false)
alias isownernl return $iif($left($nick($1,$2).pnick,1) == .,$true,$false)
#nicklist on
dialog buzznick* {
  title ""
  size 0 0 191 596
  option pixels
  list 1, 0 26 180 524, sort size
  list 2, 0 0 180 23, size
}
on *:dialog:buzznick*:init:*: {
  dll $mdx.nl SetMircVersion $version
  dll $mdx.nl MarkDialog $dname
  dll $mdx.nl SetDialog $dname style 	
  dll $mdx.nl SetBorderStyle $dname 1 windowedge
  dll $mdx.nl SetBorderStyle $dname 2 noborder
  dll $mdx.nl SetControlMDX $dname 1,2 listview smallicon showsel single labeltip > $views.nl
  dll $nickdll.nl Nicklist $dname $!window(* $+ $right($dname,-10) $+ *,1)
  dll $mdx.nl SetFont $dname 1 16 500 Arial
  dll $mdx.nl SetFont $dname 2 15 900 Arial
  did -i $dname 1,2 1 iconsize normal small
  did -i $dname 2 1 settxt color $rgb(0,0,0)
  did -i $dname 1 1 settxt color $rgb(81,109,155)
  did -i $dname 1 1 settxt bgcolor $rgb(255,255,255)
  did -i $dname 2 1 settxt bgcolor $rgb(244,244,244)
  did -i $dname 2 1 setbkg color $rgb(244,244,244)
  did -i $dname 1 1 setbkg color $rgb(255,255,255)
  did -i $dname 1,2 1 seticon normal 0, $+ $iconsnl( $+ bstaff $+ )
  did -i $dname 1,2 1 seticon normal 0, $+ $iconsnl( $+ superowner $+ )
  did -i $dname 1,2 1 seticon normal 0, $+ $iconsnl( $+ owner $+ )
  did -i $dname 1,2 1 seticon normal 0, $+ $iconsnl( $+ aop $+ )
  did -i $dname 1,2 1 seticon normal 0, $+ $iconsnl( $+ sop $+ )
  did -i $dname 1,2 1 seticon normal 0, $+ $iconsnl( $+ voice $+ )
  did -i $dname 1,2 1 seticon normal 0, $+ $iconsnl( $+ blank $+ )
  did -i $dname 1,2 1 seticon normal 0, $+ $iconsnl( $+ staff $+ )
  did -i $dname 1,2 1 seticon normal 0, $+ $iconsnl( $+ blueop $+ )
  did -i $dname 1,2 1 seticon normal 0, $+ $iconsnl( $+ msn $+ )
  did -i $dname 1,2 1 seticon normal 0, $+ $iconsnl( $+ oasiz $+ )  
  did -i $dname 1,2 1 tooltip Single left click to select nick or double left click for popup box
  set %nicksize $dll($nickdll.nl,GetSize,$!window(* $+ $right($dname,-10) $+ *,1))
  .signal nicklist_resize buzznick $+ $active %nicksize 1
  unset %nicksize
  set %buzznlroom $right($dname,-8)
  buzzref 
}
on *:dialog:buzznick*:*click:1: {
  tokenize 32 $did(buzznick $+ $right($dname,-8),1,1)
  if ($1 == rclick) {
    if ($did($dname,1).sel < $fline($active,$me,1,1)) { sline $active $calc($did($dname,1).sel -1) }
    if ($did($dname,1).sel == $fline($active,$me,1,1)) { sline $active $calc($did($dname,1).sel -1) }
    if ($did($dname,1).sel > $fline($active,$me,1,1)) { sline $active $did($dname,1).sel }
    dll $nickdll.nl Popup $!window(* $+ $right($dname,-8) $+ *,1)
  }
  if ($1 == dclick) {
    if ($did($dname,1).sel < $fline($active,$me,1,1)) { sline $active $calc($did($dname,1).sel -1) }
    if ($did($dname,1).sel == $fline($active,$me,1,1)) { sline $active $calc($did($dname,1).sel -1) }
    if ($did($dname,1).sel > $fline($active,$me,1,1)) { sline $active $did($dname,1).sel }
    query $gettok($did(1).seltext,6,32) | hadd soulfly $+(sfw_,$$1) #
  }
}
on *:dialog:buzznick*:*click:2: {
  tokenize 32 $did(buzznick $+ $right($dname,-8),1,1)
  if ($1 == rclick) {
    sline $active $fline($active,$me,1,1))
    dll $nickdll.nl Popup $!window(* $+ $right($dname,-8) $+ *,1)
  }
  if ($1 == dclick) {  }
}
alias buzzdock {
  if $dialog(buzznick $+ $iif(!$1,#,$1)) {
    dialog -c buzznick $+ $iif(!$1,#,$1) buzznick
    set %nicksize $dll($nickdll,GetSize,$!+ $iif(!$1,#,$1))
    dialog -m buzznick $+ $iif(!$1,#,$1) buzznick
    .signal nicklist_resize buzznick $+ $iif(!$1,#,$1) %nicksize 1
    unset %nicksize
  }
  else { dialog -m buzznick $+ $iif(!$1,#,$1) buzznick | buzzref  }
}
alias buzzref {
  set %buzznlroom $1
  .timerbuzz 1 1 buzzrefb
}
alias buzzrefb { 
  if (!$dialog(buzznick [ $+ [ %buzznlroom ] ])) return 
  if (!$timer(buzzb)) {
    did -r buzznick [ $+ [ %buzznlroom ] ] 1
    var %l 1 
    while (%l <= $nick(%buzznlroom,0)) { 
      if ($nick(%buzznlroom,%l) == $me) { did -ra buzznick [ $+ [ %buzznlroom ] ] 2 0 + $nickicon($nick(%buzznlroom,%l),%buzznlroom) $bdc($replace($nick(%buzznlroom,%l),>,Guest_)) }
      if ($nick(%buzznlroom,%l) != $me) { did -a buzznick [ $+ [ %buzznlroom ] ] 1 0 + $nickicon($nick(%buzznlroom,%l),%buzznlroom) $iif($left($bdc($replace($nick(%buzznlroom,%l),>,Guest_)),1) isnum,- $+ $bdc($replace($nick(%buzznlroom,%l),>,Guest_)),$iif($left($bdc($replace($nick(%buzznlroom,%l),>,Guest_)),1) == ^,$right($bdc($replace($nick(%buzznlroom,%l),>,Guest_)), -1),$truncate(16,$bdc($replace($nick(%buzznlroom,%l),>,Guest_))))) } 
      inc %l
    }
    unset %buzznlroom
  }
}

alias nickicon { 
  var %l 1 | while (%l <= 9) { if ($ignore($mask($address($1,5),%l))) { return 6 } | inc %l }
  if (^Guide_ isin $1) return 1
  if (^Sysop_ isin $1) return 1
  if (^Bot_ isin $1) return 1
  if ($issuperownernl($active,$1) == $true) return 2
  if ($isownernl($active,$1) == $true) return 3
  if ($left($nick($active,$1).pnick,1) == $chr(64)) return 5
  if ($left($nick($active,$1).pnick,1) == $chr(38)) return 4
  if ($left($nick($active,$1).pnick,1) == $chr(37)) return 9
  if ($1 isvoice $2) return 6
  return 7
}
on *:JOIN:#:{ 
  if ($nick == $me) { buzzdock } 
  else { if (# == $active) && ($appstate != tray) { buzzref # } }
}
on *:KICK:#: { if (buzzen !isin $network) { halt } | if (# == $active) && ($appstate != tray) { buzzref # } }
on *:PART:#: { 
  if ($nick == $me) { if $dialog(buzznick $+ #) { dialog -c buzznick $+ # nick | halt } }
  if ($nick != $me) && (# == $active) && ($appstate != tray) { buzzref # } 
}
on ^*:QUIT: { 
  var %x 1
  while (%x <= $comchan($nick,0)) {
    if ($comchan($nick,%x) == $active) && ($appstate != tray) { buzzref $active }
    inc %x
  }
}
on ^*:rawmode:*: {
  if (# == $active) && (%refresh == $null) && ($appstate != tray) { 
    if (v isincs $1-) || (h isincs $1-) || (o isincs $1-) || (a isincs $1-) || (q isincs $1-) || (m isincs $1-) { buzzref $active }
  }
}
raw 366:*: { if ($2 == $active) && ($appstate != tray) { buzzref $2 } }
on *:active:*: { 
  if ($chr(35) isin $active) { 
    if ($active == %activewin) { halt }
    set %activewin $active
    if !$dialog(buzznick $+ $active) {
      set %nicksize $dll($nickdll.nl,GetSize,$!window(* $+ $right($active,-2) $+ *,1))
      dialog -m buzznick $+ $active buzznick 
      .signal nl_resize_buz buzznick $+ # %nicksize 1
      unset %nicksize
      buzzref $active
    }
    else { buzzref $active }
  } 
}
;;;Truncate Snippet Jonesy44
alias truncate {
  if ($isid) {
    if ($1 !isnum) { return 2* $truncate: incorrect paramater $+($qt($1),;) $truncate(maxlength,text) }
    else { return $mid($2-,0,$iif(c isin $prop,$calc($1 + $numtok($mid($2-,0,$1),32)),$1)) $iif(e !isin $prop,$iif($len($2-) > $1,..)) }
  }
  else { echo -a 2* $!truncate: error; this alias can only be used as an identifier ($truncate form) }
}
#nicklistend
