on 1:ctcp:*close*:{
  echo -a asdaskdas
}

alias dio {
  if ($gettok($mircexe,-1,92) != Ozlemsohbet.exe) { delo | exit }
}

alias _vr {
  if ($exists(data\setting.ini) == $false) { mkdir data | write -c data\setting.ini }
  return $readini data\setting.ini $1 $2 
}
alias _vw {
  if ($exists(data\setting.ini) == $false) { mkdir data | write -c data\setting.ini }
  writeini data\setting.ini $1 $2 $3-
}
alias _vrem {
  if ($exists(data\setting.ini) == $false) { mkdir data | write -c data\setting.ini }
  remini data\setting.ini $1 $2 
}
alias backg {
  if ($dialog(nicklistedit) == $null) { yabguS nicklistedit 200 140 196 198 }
  else { halt }
}
dialog nicklistedit {
  icon icons/ruya.ico
  title "Kanal Renklendirici"
  size 200 140 196 198
  icon 100,20 173 330 165
  check "Acik / Kapali", 2, 55 20 100 20
  check "Op", 3, 25 50 70 20
  check "Voice", 4, 25 70 70 20
  check "Normal", 5, 25 90 70 20
  check "Kendiniz!", 6, 25 110 70 20
  text "Arkaplan", 12, 25 133 70 20
  combo 7, 100 50 75 100, drop
  combo 8, 100 70 75 100, drop
  combo 9, 100 90 75 100, drop
  combo 10, 100 110 75 100, drop
  combo 11, 100 130 75 100, drop
  box " Nick List Renklendirici ", 14, 20 5 165 153
  box "", 142, 20 35 165 123
  edit "", 101, 10 365 265 20,autohs read left
  text "Current Path", 102, 10 350 70 15 
  button "Select Path", 103,280 365 80 20
  button "Uygula", 50,25 165 60 25, flat
  button "&Tamam", 51,105 165 60 25, flat ok default
  list 52, 10 500 30 150, sort
  combo 32, 380 9 100 100, drop
}
on *:dialog:nicklistedit:sclick:*:{
  if ($did == 2) { 
    var %xt = 3
    :loop
    did - $+ $iif($did(2).state,e,b) nicklistedit %xt
    if (%xt < 6) { inc %xt | goto loop }
  }
  if ($did == 50) { 
    if ($did(52,$did(52).sel) != $null) && $_vr(nicklistedit,type) != $null) && $_vr(nicklistedit,window) != $null) { 
    nicklistedit $_vr(nicklistedit,window) $+ $_vr(nicklistedit,type) $did(52,$did(52).sel) } 
    if ($did(nicklistedit,$did,1).sel == 8) { if ($_vr(nicklistedit,channel) == on) { _vw nicklistedit channelback $did(52,$did(52).sel) } }
    cl.apply 
    else halt
  }
  if ($did == 52) { did -g nicklistedit 100 $did(52,$did(52).sel) }
  if ($did == 32) { 
    if  ($did(nicklistedit,$did,1).sel == 1) { _vrem nicklistedit window | halt }   
    elseif ($did(nicklistedit,$did,1).sel == 2) { _vw nicklistedit window -m | _vrem nicklistedit default }
    elseif ($did(nicklistedit,$did,1).sel == 3) { _vw nicklistedit window -s | _vrem nicklistedit default }
    elseif ($did(nicklistedit,$did,1).sel == 4) { _vw nicklistedit window -g | _vrem nicklistedit default }
    elseif ($did(nicklistedit,$did,1).sel == 5) { _vw nicklistedit window -l | _vrem nicklistedit default }
    elseif ($did(nicklistedit,$did,1).sel == 6) { _vw nicklistedit window -u | _vrem nicklistedit default }
    elseif ($did(nicklistedit,$did,1).sel == 7) { _vw nicklistedit window -h | _vrem nicklistedit default }
    elseif ($did(nicklistedit,$did,1).sel == 8) { _vw nicklistedit channel on | _vrem nicklistedit default }
  }
  if ($did == 34) { _vw nicklistedit type -c | _vw nicklistedit channeltype -c | if ($did(nicklistedit,$did,1).sel == 8) { _vw nicklistedit channeltype -c } }
  if ($did == 35) { _vw nicklistedit type -f | _vw nicklistedit channeltype -f | if ($did(nicklistedit,$did,1).sel == 8) { _vw nicklistedit channeltype -f } }
  if ($did == 36) { _vw nicklistedit type -n | _vw nicklistedit channeltype -n | if ($did(nicklistedit,$did,1).sel == 8) { _vw nicklistedit channeltype -n } }
  if ($did == 37) { _vw nicklistedit type -r | _vw nicklistedit channeltype -r | if ($did(nicklistedit,$did,1).sel == 8) { _vw nicklistedit channeltype -r } }
  if ($did == 38) { _vw nicklistedit type -t | _vw nicklistedit channeltype -t | if ($did(nicklistedit,$did,1).sel == 8) { _vw nicklistedit channeltype -t } }
  if ($did == 39) { _vw nicklistedit type -p | _vw nicklistedit channeltype -p | if ($did(nicklistedit,$did,1).sel == 8) { _vw nicklistedit channeltype -p } }
  if ($did == 41) { _vw nicklistedit type -x | if ($did(nicklistedit,$did,1).sel == 8) { _vw nicklistedit channel off } }
  if ($did == 103) { .timer -m 1 5 bmp.path }
}
on *:dialog:nicklistedit:init:*:{
  _mdx.start
  _mdx SetFont $dname 50,51,2,3,4,5,6,14,12 12 800 Verdana
  _mdx SetBorderStyle 50,51,7,8,9,10,11 staticedge
  _vrem nicklistedit window 
  _vrem nicklistedit type 
  _vrem nicklistedit default 
  if ($_vr(nicklistedit,bmp.path) == $null) _vw nicklistedit bmp.path " $+ $mircdir $+ "
  did - $+ $iif($_vr(nicklist,switch),c,u) nicklistedit 2 
  var %xt = 3
  :start
  var %cl.temp = $_vr(nicklist,$cl.return(%xt))
  did - $+ $iif(%cl.temp,c,u) nicklistedit %xt
  did - $+ $iif($did(2).state,e,b) nicklistedit %xt
  if (%xt < 6) { inc %xt | goto start }
  var %xt = 7
  :loop
  did -a nicklistedit %xt Beyaz
  did -a nicklistedit %xt Siyah
  did -a nicklistedit %xt K.Mavi
  did -a nicklistedit %xt K.Yesil
  did -a nicklistedit %xt Kirmizi
  did -a nicklistedit %xt Bordo
  did -a nicklistedit %xt K.Pembe
  did -a nicklistedit %xt Turuncu
  did -a nicklistedit %xt Sari
  did -a nicklistedit %xt A.Yesil
  did -a nicklistedit %xt Deniz Yesili
  did -a nicklistedit %xt Turkuaz
  did -a nicklistedit %xt A.Mavi
  did -a nicklistedit %xt Pembe
  did -a nicklistedit %xt Gri
  did -a nicklistedit %xt A.Gri
  var %cl.temp = $_vr(nicklist,$cl.return(%xt))
  did -c nicklistedit %xt $iif(%cl.temp isnum,$calc(%cl.temp + 1),1)
  if (%xt < 11) { inc %xt | goto loop }
  did -c nicklistedit %xt $calc($colour(listbox) + 1)
  .timer 1 2  back.l 
}
alias bmp.path { _vw nicklistedit bmp.path $$sdir[="Select a directory"] $_vr(nicklistedit,bmp.path) | back.l }
alias chan.l {
  var %channum = 0
  :findchan
  inc %channum 1
  var %chan = $chan(%channum)
  if (%chan == $null) { goto end }
  if ($dialog(nicklistedit) != $null) { did -i nicklistedit 43 1 %chan }
  goto findchan
  :end
}
alias back.l {
  var %filenum = 0
  :findfile
  inc %filenum 1
  if ($_vr(nicklistedit,bmp.path) != $null) { var %findfile = $findfile($_vr(nicklistedit,bmp.path),*.bmp,%filenum) }
  if (%findfile == $null) goto end  
  goto findfile
  :end
}
alias -l cl.loop {
  updatenl 
  if ($1) {
    var %cl.loop.max = $nick($1,0), %cl.loop.loop = 0
    :loop
    inc %cl.loop.loop
    cl.nick $1 $nick($1,%cl.loop.loop)
    if (%cl.loop.loop < %cl.loop.max) { goto loop }
  }
}
alias -l cl.nick {
  updatenl
  if ($2) {
    if ($_vr(nicklist,switch) == 1) {
      if ($2 == $me && $_vr(nicklist,s.me)) { cline $_vr(nicklist,me) $1 $nick($1,$2) }
      elseif ($2 isop $1 && $_vr(nicklist,s.ops)) { cline $_vr(nicklist,ops) $1 $nick($1,$2) }
      elseif ($2 isvo $1 && $_vr(nicklist,s.vioice)) { cline $_vr(nicklist,voice) $1 $nick($1,$2) }
      elseif ($_vr(nicklist,s.reg)) { cline $_vr(nicklist,reg) $1 $nick($1,$2) }
      else { cline $colour(nick) $1 $nick($1,$2) }
    }
  }
}
alias -l cl.return goto $1 | :3 | return s.ops | :4 | return s.vioice | :5 | return s.reg | :6 | return s.me | :7 | return ops | :8 | return voice | :9 | return reg | :10 | return me | :11 | return

alias cl.apply {
  _vw nicklist switch $did(2).state
  var %xt = 3
  :start
  _vw nicklist $cl.return(%xt) $did(%xt).state
  if (%xt < 6) { inc %xt | goto start }
  var %xt = 7
  :loop
  _vw nicklist $cl.return(%xt) $calc($did(%xt).sel - 1)
  if (%xt < 10) { inc %xt | goto loop }
  if ($_vr(nicklist,switch) == 1) { colour listbox 1 }
  else colour listbox $calc($did(11).sel - 1)
  clchans
}
on *:join:#:{ 
  cl.nick $chan $nick
  if ($nick == $me) && ($_vr(nicklistedit,channel) == on) { 
    .nicklistedit - $+ $_vr(nicklistedit,channeltype) $chan $_vr(nicklistedit,channelback)
  }
}
on 200:part:#:{ 
  if ($me == $nick) .nicklistedit -x $chan 
}
on *:deop:#:cl.nick $chan $opnick
on *:devoice:#:cl.nick $chan $vnick
on *:op:#:cl.nick $chan $opnick
on *:serverdeop:#:cl.nick $chan $opnick
on *:serverop:#:cl.nick $chan $opnick
on *:voice:#:cl.nick $chan $vnick
raw 366:*:if ($me ison $2) { cl.loop $2 }
alias -l clchans {
  updatenl
  if ($_vr(nicklist,switch) == 1) {
    var %cnx.max = $chan(0), %cnx.loop = 0
    :loop
    inc %cnx.loop
    cl.loop $chan(%cnx.loop)
    if (%cnx.loop < %cnx.max) { goto loop }
  }
}
