dialog color {
  title "Color Config By ¤Fox_DeLiRiuM¤"
  size -1 -1 363 229
  option pixels
  tab "Salons", 1, 6 7 348 215
  check "Activer les couleurs sur les salons", 3, 16 35 211 20, tab 1 flat 
  combo 5, 64 61 120 100, tab 1 size drop
  combo 7, 64 94 120 100, tab 1 size drop
  check "Gras", 8, 211 62 57 20, tab 1 flat
  check "Souligné", 9, 211 92 100 20, tab 1 flat
  text "Pas de couleurs sur ", 10, 22 140 114 16, tab 1
  combo 11, 147 138 120 100, tab 1 size drop
  button "Ajouter", 12, 282 138 60 20, tab 1
  button "Modifier", 13, 282 161 60 20, tab 1
  button "Supprimer", 14, 282 184 60 20, tab 1
  tab "Query", 2
  check "Activer les couleurs en Privé", 15, 16 35 211 20, tab 2 flat
  combo 16, 64 61 120 100, tab 2 size drop
  combo 17, 64 94 120 100, tab 2 size drop
  check "Gras", 18, 211 62 57 20, tab 2 flat
  check "Souligné", 19, 211 92 100 20, tab 2 flat
  check "Symbole en début de texte", 20, 24 134 170 20, tab 2 flat
  edit $dt(query).symd, 21, 200 136 43 21, tab 2 center
  check "Symbole en fin de texte", 22, 24 162 157 20, tab 2 flat
  edit $dt(query).symf, 23, 200 160 43 21, tab 2 center
  text "Texte :", 4, 20 62 34 16
  text "Fond :", 6, 23 94 31 16
  button "F E R M E R", 24, 274 36 75 25, ok
}

on *:dialog:color:init:*:{
  did -a color 5,7,16,17 00 - Blanc
  did -a color 5,7,16,17 01 - Noir
  did -a color 5,7,16,17 02 - Bleu foncé
  did -a color 5,7,16,17 03 - Vert foncé
  did -a color 5,7,16,17 04 - Rouge
  did -a color 5,7,16,17 05 - Brun
  did -a color 5,7,16,17 06 - Violet
  did -a color 5,7,16,17 07 - Orange
  did -a color 5,7,16,17 08 - Jaune
  did -a color 5,7,16,17 09 - Vert clair
  did -a color 5,7,16,17 10 - Turquoise
  did -a color 5,7,16,17 11 - Bleu clair
  did -a color 5,7,16,17 12 - Bleu Ciel
  did -a color 5,7,16,17 13 - Rose
  did -a color 5,7,16,17 14 - Gris foncé
  did -a color 5,7,16,17 15 - Gris clair
  did -c color 5 $calc($dt(channel).texte +1)
  did -c color 7 $calc($dt(channel).fond +1)
  did -c color 16 $calc($dt(query).texte +1)
  did -c color 17 $calc($dt(query).fond +1)
  if ($dt(channel).color == on) { did -c color 3 }
  if ($dt(query).color == on) { did -c color 15 }
  if ($dt(channel).gras == $chr(2)) { did -c color 8 }
  if ($dt(query).gras == $chr(2)) { did -c color 18 }
  if ($dt(channel).soul == ) { did -c color 9 }
  if ($dt(query).soul == ) { did -c color 19 }
  if ($dt(query).syd == on) { did -c color 20 }
  else { did -b color 21 }
  if ($dt(query).syf == on) { did -c color 22 }
  else { did -b color 23 }
  mdxdll
  mdxicon rgb.ico 
  mdxbutton 12,13,14 clientedge 
  mdxbutton 24 border
  mdxfont 3,4,6,8,9,10,15,18,19,20,22
  upcomboc
  upcolor 
}
on *:dialog:color:sclick:* {
  if ($did == 3) {
    if ($dt(channel).color == on) { /writeini $fd channel color off | upcolor | halt }
    if ($dt(channel).color == off) { /writeini $fd channel color on | upcolor | halt }
  }
  if ($did == 5) { /writeini $fd channel texte $calc($did($dname,5) -1) }
  if ($did == 7) { /writeini $fd channel fond $calc($did($dname,7) -1) }
  if ($did == 8) {
    if ($dt(channel).gras == $chr(2)) { /remini $fd channel gras | halt }
    if ($dt(channel).gras != $chr(2)) { /writeini $fd channel gras $ $+ chr(2) | halt }
  }
  if ($did == 9) {
    if ($dt(channel).soul == $chr(31)) { /remini $fd channel soul | halt }
    if ($dt(channel).soul != $chr(31)) { /writeini $fd channel soul $ $+ chr(31) | halt }
  }
  if ($did == 12) {
    var %ajout = $$?"Quel salon à ajouter ?"
    if (%ajout == $null) { halt }
    if ($left(%ajout,1) != $chr(35)) { var %ajout = $chr(35) $+ %ajout }
    /writeini $fd channel nocolor $dt(channel).nocolor $+ , $+ %ajout 
    upcomboc
  }
  if ($did == 13) {
    var %replace = $$?"Remplacer $gettok($dt(channel).nocolor,$did(11).sel,44) par..... ?"
    if (%replace == $null) { halt }
    if ($left(%replace,1) != $chr(35)) { var %replace = $chr(35) $+ %replace }
    /writeini $fd channel nocolor $puttok($dt(channel).nocolor,%replace,$did(11).sel,44)
    upcomboc
  }
  if ($did == 14) {
    if ($did(11).sel == $null) { halt }
    var %liste = $dt(channel).nocolor
    if ($?!"Voulez vous supprimer $gettok($dt(channel).nocolor,$did(11).sel,44) ?" == $true) {
      if ($gettok(%liste,0,44) == 1) { remini $fd channel nocolor | upcomboc | halt }
      /writeini $fd channel nocolor $deltok(%liste,$did(11).sel,44)
      /upcomboc
    }
  }
  ;QUERY
  if ($did == 15) {
    if ($dt(query).color == on) { /writeini $fd query color off | upcolor | halt }
    if ($dt(query).color == off) { /writeini $fd query color on | upcolor | halt }
  }
  if ($did == 18) {
    if ($dt(query).gras == $chr(2)) { /remini $fd query gras | halt }
    if ($dt(query).gras != $chr(2)) { /writeini $fd query gras $ $+ chr(2) | halt }
  }
  if ($did == 16) { /writeini $fd query texte $calc($did($dname,16) -1) }
  if ($did == 17) { /writeini $fd query fond $calc($did($dname,17) -1) }
  if ($did == 19) {
    if ($dt(query).soul == $chr(31)) { /remini $fd query soul | halt }
    if ($dt(query).soul != $chr(31)) { /writeini $fd query soul $ $+ chr(31) | halt }
  }
  if ($did == 20) {
    if ($dt(query).syd == on) { /writeini $fd query syd off | did -b color 21 | halt }
    if ($dt(query).syd != on) { /writeini $fd query syd on | did -e color 21 | halt }
  }
  if ($did == 22) {
    if ($dt(query).syf == on) { /writeini $fd query syf off | did -b color 23 | halt }
    if ($dt(query).syf != on) { /writeini $fd query syf on | did -e color 23 | halt }
  }
}

on *:dialog:color:edit:* {
  if ($did == 21) { 
    if ($did($dname,21) != $null) { /writeini $fd query symd $did($dname,21) }
  }
  if ($did == 23) { 
    if ($did($dname,23) != $null) { /writeini $fd query symd $did($dname,23) }
  }
}
alias upcolor {
  if ($dt(channel).color != on) { did -b color 5,7,8,9,11,12,13,14 | goto se }
  if ($dt(channel).color == on) { did -e color 5,7,8,9,11,12,13,14 | goto se }
  :se
  if ($dt(query).color != on) { did -b color 16,17,18,19,20,21,22,23 | halt }
  if ($dt(query).color == on) { did -e color 16,17,18,19,20,21,22,23 | halt }
}
alias upcomboc {
  did -r color 11
  var %liste = $dt(channel).nocolor , %loop = 1
  while (%loop <= $gettok(%liste,0,44)) {
    did -a color 11 $gettok(%liste,%loop,44)
    inc %loop
  }
  did -c color 11 1
}

on 1:input:#:{
  if (/ == $left($1,1)) || ($dt(channel).color != on) || ($active isin $dt(channel).nocolor) { goto end }
  if (!$server) { echo -a 4[Erreur] 3Tu n'es pas connecté :) | halt }
  if (! == $left($1,1)) || ($null == $left($1,1)) { goto end }
  if ( $asc($left($1,1)) isnum 48-57) { /var %tempcolor = 0 }
  if ($me isop #) { /echo -a 4< $+ @ $+ $nick $+ > $dt(channel).gras $+ $dt(channel).soul $+  $+ $dt(channel).texte $+ , $+ $dt(channel).fond $+ %tempcolor $+ $1- | .msg # $dt(channel).gras $+ $dt(channel).soul $+  $+ $dt(channel).texte $+ , $+ $dt(channel).fond $+ %tempcolor $+ $1- }
  elseif ($me isvo #) { /echo -a 3< $+ + $+ $nick $+ > $dt(channel).gras $+ $dt(channel).soul $+  $+ $dt(channel).texte $+ , $+ $dt(channel).fond $+ %tempcolor $+ $1- | .msg # $dt(channel).gras $+ $dt(channel).soul $+  $+ $dt(channel).texte $+ , $+ $dt(channel).fond $+ %tempcolor $+ $1- }
  else  { /echo -a 7< $+ $nick $+ > $dt(channel).gras $+ $dt(channel).soul $+  $+ $dt(channel).texte $+ , $+ $dt(channel).fond $+ %tempcolor $+ $1- | .msg # $dt(channel).gras $+ $dt(channel).soul $+  $+ $dt(channel).texte $+ , $+ $dt(channel).fond $+ %tempcolor $+ $1- }
  halt
  :end
}
on 1:input:?:{
  if (!$server) { echo -a 4[Erreur] 3Tu n'es pas connecté :) | halt }
  if ( $asc($left($1,1)) isnum 48-57) { /var %tempcolor = 0 }
  if (/ == $left($1,1)) || (! == $left($1,1)) || ($dt(query).color != on) { goto bas }
  if ($null == $left($1,1)) { goto bas }
  var %result = $1-
  if ($dt(query).syd == on) { var %result = $dt(query).symd $1- }
  if ($dt(query).syf == on) { var %result = %result $dt(query).symf }
  msg $active $dt(query).gras $+ $dt(query).soul $+  $+ $dt(query).texte $+ , $+ $dt(query).fond $+ %tempcolor $+ %result | halt
  :bas
}
alias mdxdll { /dll color/mdx.dll SetMircVersion $version | /dll color/mdx.dll MarkDialog $dname }
alias mdxicon { dll color/mdx.dll SetDialog $dname icon 0 color\ $+ $1- }
alias mdxbutton { dll color/mdx.dll SetBorderStyle $dname $1- }
alias mdxfont {   /dll color/mdx.dll SetFont $dname $1 +a 14 300 tahoma }
alias d { 
  if ($dialog($1)) { return }
  else { dialog -m $1 $1 }
}
alias fd { return color/delirium.ini }
alias dt {  
  if ($1 == channel) return $readini($fd,channel,$prop)
  if ($1 == query) return $readini($fd,query,$prop)
}

  
