; ColorNick V2.2
; © Scott Keiffer, 2000


on 1:LOAD:{
  if ($version < 5.7) {
    echo -a You must use mIRC v5.7 or higher for this addon to work.
    echo -a Please d/l mIRC 5.7 at www.mirc.com and try again
    /timer 1 3 unload -rs $script
    halt
  }
  else {
    echo ColorNick is Ready to go, Please remmeber to read the readme file for info.
    set %cnum? 0
    set %cnew 1
    set %cnewn 1
    set %cme? 0
    set %check 0
    set %colorme 4
    set %ctemp 0
    /ial on
    /timer3 0 4 colorize
    /who #
  }
}


menu channel,status,menubar {
  -
  <>------=Color Nick=-------<>
  .Color Nick Setup:cd1
  .-
  .Delete All Users:delall
  .Error Fix:if (%cnum? == 0) { halt } | dec %cnum? 1
}

menu nicklist {
<>------=Color Nick=-------<>
.add this nick:set %tcnick $$1 | nickadd
}

alias /cd1 splay sounds/start.wav | .timer -om 1 1 dialog -dm cdi1 cdi1
alias /cd2 splay sounds/start.wav | .timer -om 1 1 dialog -dm cdi2 cdi2

dialog cdi1 {
  title  "Nick color setup"
  size   244 236 277 278
  edit   "",1,11 31 109 20
  box    "Your Setup",2,0 12 271 53
  text   "Color:",3,130 36 29 15
  icon   4,160 36 17 15,system/pics/no.bmp,0
  button "Set",5,184 36 33 16
  button "Clear",6,226 36 33 16
  box    "Buddy Setup",7,0 74 271 175
  edit   "",8,11 193 109 20,autohs
  text   "Color:",9,130 198 29 15
  icon   10,160 197 17 15,system/pics/no.bmp,0
  button "Set",11,184 197 33 16
  button "Del",12,226 197 33 16
  button  "Ok",13,224 253 50 22,ok
  list  14,7 90 256 110
  button "Add/Edit",15,12 220 248 20
}


on 1:dialog:cdi1:init:0:{
  set %ctemp 0
  set %cnew 1
  set %cnewn 1
  set %me $me
  set %addnick 0  
  did -a cdi1 1 %me
  did -m cdi1 1
  if (%colorme == $colour(listbox text)) { did -g cdi1 4 system/pics/no.bmp }
  else { did -g cdi1 4 system/pics/ $+ %colorme $+ .bmp }
  colorinit
}

on 1:dialog:cdi1:sclick:5:{ set %cme? 1 | set %cnew 0 | /cd2 }

on 1:dialog:cdi1:sclick:11:{ 
  if (%cnew == 1) {
    set %cme? 0
  }
  /cd2
}

on 1:dialog:cdi1:sclick:14:{ 
  set %csel?  $did(14,1).sel
  set %atemp1 $did(14,1).sel
  did -o cdi1 8 1 %cidnt [ $+ [ %atemp1 ] ]
  did -g cdi1 10 system/pics/ $+ [ %color [ $+ [ $did(14,1).sel ] ] ] $+ .bmp
  set %cnewn 0
  set %cnew 0
  set %check 1

}


on 1:dialog:cdi1:sclick:15:{ 

  if (%check == 0) { echo -a 4 You have not set a color Please do so 7NOW4!!!! | halt }
  if ($did(cdi1,8).text == $null) { echo -a 4 You have not enter in a nick name Please do so 87NOW4!!!! | halt }
  if (%cnewn == 0) {
    set %cidnt [ $+ [ %csel? ] ] $did(cdi1,8).text
    did -o cdi1 14 %csel? %cnick [ $+ [ %csel? ] ]
  }
  else {
    set %cnick [ $+ [ %cnum? ] ] $did(cdi1,8).text
    set %cidnt [ $+ [ %cnum? ] ] $address($did(cdi1,8).text,3)
    did -a cdi1 14 %cnick [ $+ [ %cnum? ] ]
  }
  did -r cdi1 8
  did -g cdi1 10 system/pics/no.bmp  
  set %check 0
  set %cnew 1
  set %cnewn 1
  colorize
}

on 1:dialog:cdi1:sclick:6:{
  did -g cdi1 4 system/pics/no.bmp
  set %dispc1
  set %colorme $colour(listbox text)
  colorize
}

on 1:dialog:cdi1:sclick:12:{ 
  :start 
  set %check 0
  set %cnew 1
  set %cnewn 1
  set %addnick 0
  did -g cdi1 10 system/pics/no.bmp
  did -r cdi1 8
  set %ctnum $did(14,1).sel
  goto decolor

  :decolor
  set %itemp %cidnt [ $+ [ %ctnum ] ]
  set %chtemp $ial(%itemp,1).nick
  if (%chtemp != $null) {
    cline -l $colour(listbox text) $active %chtemp
  }  
  unset %itemp %chtemp
  goto timer 

  :timer   
  did -d cdi1 14 %ctnum

  :loop
  inc %ctnum
  if (%ctnum > %cnum?) {
    unset  %color [ $+ [ %cnum? ] ]
    unset %cnick [ $+ [ %cnum? ] ]
    unset %cidnt [ $+ [ %cnum? ] ]
    dec %cnum? 1
    halt 
  }
  else {
    set %ctnum2 %ctnum
    set %cntemp %cnick [ $+ [ %ctnum ] ]
    set %citemp %cidnt [ $+ [ %ctnum ] ]
    set %cctemp %color [ $+ [ %ctnum ] ]
    dec %ctnum2 1
    set  %cnick [ $+ [ %ctnum2 ] ] %cntemp
    set %color [ $+ [ %ctnum2 ] ] %cctemp
    set %cidnt [ $+ [ %ctnum2 ] ] %citemp 
    goto loop
  }  
}


on 1:dialog:cdi1:sclick:13: {
  set %ctemp 0
  set %cnew 1
  echo -a 4Names and colors 7stored 4Colors have taken effect!! 
}




dialog cdi2 {
  title  "Color Select"
  size   300 300 187 126
  icon   1,15 14 17 15,system\pics\0.bmp,0
  icon   2,58 15 17 15,system\pics\1.bmp,0
  icon   3,104 15 17 15,system\pics\2.bmp,0
  icon   4,152 14 17 15,system\pics\3.bmp,0
  icon   5,15 45 17 15,system\pics\4.bmp,0
  icon   6,58 45 17 15,system\pics\5.bmp,0
  icon   7,104 45 17 15,system\pics\6.bmp,0
  icon   8,152 45 17 15,system\pics\7.bmp,0
  icon   9,15 75 17 15,system\pics\8.bmp,0
  icon   10,58 75 17 15,system\pics\9.bmp,0
  icon   11,104 75 17 15,system\pics\10.bmp,0
  icon   12,152 75 17 15,system\pics\11.bmp,0
  icon   13,15 105 17 15,system\pics\12.bmp,0
  icon   14,58 105 17 15,system\pics\13.bmp,0
  icon   15,104 105 17 15,system\pics\14.bmp,0
  icon   16,152 105 17 15,system\pics\15.bmp,0
  button "Command",17,82 140 15 22,ok
}


alias setcolor {
  if (%cnew == 1) { 
    inc %cnum? 1
    set %cnew 0
  }
  if (%cme? == 1) { 
    set %cwin? 4  
    set %colorme %cpick
  }
  else { 
    set %cwin? 10

    if (%cnewn == 0) {
      set %color $+ %csel? %cpick
    }
    else {
      set %color $+ %cnum? %cpick
    }
  }
  if (%addnick == 1) { dialog -x cdi2 cdi2  | colorize | halt }
  did -g cdi1 %cwin? system/pics/ $+ %cpick $+ .bmp
  set %check 1
  dialog -x cdi2 cdi2
}


on 1:dialog:cdi2:sclick:1: { set %cpick 0 | setcolor }
on 1:dialog:cdi2:sclick:2: { set %cpick 1 | setcolor }
on 1:dialog:cdi2:sclick:3: { set %cpick 2 | setcolor }
on 1:dialog:cdi2:sclick:4: { set %cpick 3 | setcolor }
on 1:dialog:cdi2:sclick:5: { set %cpick 4 | setcolor }
on 1:dialog:cdi2:sclick:6: { set %cpick 5 | setcolor }
on 1:dialog:cdi2:sclick:7: { set %cpick 6 | setcolor }
on 1:dialog:cdi2:sclick:8: { set %cpick 7 | setcolor }
on 1:dialog:cdi2:sclick:9: { set %cpick 8 | setcolor }
on 1:dialog:cdi2:sclick:10: { set %cpick 9 | setcolor }
on 1:dialog:cdi2:sclick:11: { set %cpick 10 | setcolor }
on 1:dialog:cdi2:sclick:12: { set %cpick 11 | setcolor }
on 1:dialog:cdi2:sclick:13: { set %cpick 12 | setcolor }
on 1:dialog:cdi2:sclick:14: { set %cpick 13 | setcolor }
on 1:dialog:cdi2:sclick:15: { set %cpick 14 | setcolor }
on 1:dialog:cdi2:sclick:16: { set %cpick 15 | setcolor }

alias colorize {
  set %me $me
  set %sctemp 0
  set %qtemp 0
  set %qnum? $query(0)
  if ($active == Status Window) { halt }
  if ($active == $chat(1)) { halt }
  if ($active == $chat(2)) { halt }
  if ($active == $chat(3)) { halt }
  if ($active == $chat(4)) { halt }
  if ($active == $chat(5)) { halt }
  if ($active == $send(1)) { halt }
  if ($active == $send(2)) { halt }
  if ($active == $send(3)) { halt }
  if ($active == $get(1)) { halt }
  if ($active == $get(2)) { halt }
  if ($active == $get(3)) { halt }
  goto qloop

  :qloop
  inc %qtemp
  if (%qtemp > %qnum?) { goto 1 }
  if ($active ==  $query( [ %qtemp ] )) { halt }
  goto qloop

  :1
  cline %colorme $active %me

  :loop
  inc %sctemp
  unset %itemp %ctemp
  if (%sctemp > %cnum?) { halt | set %sctemp 0 }
  if (%cnum? == 0) { halt | set %sctemp 0 }
  else { 
    set %itemp %cidnt [ $+ [ %sctemp ] ]
    set %chtemp $ial(%itemp,1).nick
    if (%chtemp != $null) {
      cline -l %color [ $+ [ %sctemp ] ] $active %chtemp
    }  
  }
  goto loop
}

on 1:CONNECT:/timer3 0 4 colorize
on 1:JOIN:#:set %chan $chan | who $chan | colorize



alias nickadd {
  set %cme? 0
  set %cnew 0
  set %cnewn 1
  set %addnick 1
  /idntset
  echo -a 4Please select a 7color4.
  halt
}

alias colorinit {
  :loop
  inc %ctemp
  if (%ctemp > %cnum?) { halt }
  if (%cnum? == 0) { halt }
  else {
    set %itemp %cidnt [ $+ [ %ctemp ] ]
    if ($ial(%itemp,1).nick == $null) {
      set %chtemp %cnick [ $+ [ %ctemp ] ]
    }
    else {
      set %chtemp $ial(%itemp,1).nick
    }
    did -a cdi1 14 %chtemp
  }
  goto loop
}

alias delall {
  set %cntemp 0

  :decolorloop
  inc %cntemp
  unset %itemp %chtemp
  if (%cntemp > %cnum?) { goto end }
  if (%cnum? == 0) { halt }
  else {
    set %itemp %cidnt [ $+ [ %cntemp ] ]
    set %chtemp $ial(%itemp,1).nick
    if (%chtemp != $null) { 
      cline -l $colour(listbox text) $active %chtemp
    }
    unset %cidnt [ $+ [ %cntemp ] ] %cnick [ $+ [ %cntemp ] ] %color [ $+ [ %cntemp ] ]
  }
  goto decolorloop

  :end
  set %cnum? 0

}

alias idntset {
  inc %cnum? 1
  set %cnick $+ %cnum? %tcnick
  set %try 0  
  :loop
  inc %try
  if (%try > 3) { echo -a The user could not be added, try again later | dec %cnum? 1 | halt }
  else {
    set %cidnt $+ %cnum? $address(%tcnick,3)
  }  
  if (%cidnt [ $+ [ %cnum? ] ] != $null) { echo -a This User has been added | goto end }
  goto loop  
  :end
  /cd2
}

