alias uninstall.ignore.manager {
  unset %ignore.*
  echo $colour(info2) -se *** Ignore manager successfully uninstalled
  unload -rs $scriptdir $+ ignore.mrc
}

alias -l ignore.settings {
  set %ignore.delay [ off ]
  set %ignore.delay.timer [ 60 ]
  set %ignore.switches.default [ 2 ]
  set %ignore.type.default [ 2 ]
  .ial on
}


alias show.ignoreList.dialog {
  if ($dialog(ignoreListDialog) == $null) { dialog -m ignoreListDialog ignoreListDialog |  if ( %cc181p == on ) { $tunder TDDialog $dialog(ignorelistdialog).hwnd > 2 } }
  else { dialog  -v ignoreListDialog }
}

alias ignore.manager {
  set %ignore.nick [ $1 ]
  if ($dialog(ignoreDialog) == $null) { 
  dialog -m ignoreDialog ignoreDialog | if ( %cc181p == on ) { $tunder TDDialog $dialog(ignoredialog).hwnd > 10 } }

}
else {
  dialog  -v ignoreDialog
  setIgnore
}

dialog ignoreDialog {
  title "Ignore for the Arcan]G[elo 2 "
  size -1 -1 290 140
  option dbu
  text "Tipi Mask :",722,10 10 30 10,left
  radio "",723,20 21 10 10, left
  edit "",724,35 20 130 10, autohs left
  radio "",725,20 31 10 10, left
  edit "",726,35 30 130 10, autohs left
  radio "",727,20 41 10 10, left
  edit "",728,35 40 130 10, autohs left
  radio "",729,20 51 10 10, left
  edit "",730,35 50 130 10, autohs left
  radio "",731,20 61 10 10, left
  edit "",732,35 60 130 10, autohs left
  radio "",733,20 71 10 10, left
  edit "",734,35 70 130 10, autohs left
  radio "",735,20 81 10 10, left
  edit "",736,35 80 130 10, autohs left
  radio "",737,20 91 10 10, left
  edit "",738,35 90 130 10, autohs left
  radio "",739,20 101 10 10, left
  edit "",740,35 100 130 10, autohs left

  text "Tipi ignore :",741,190 10 35 10,left
  check "",742,200 20 10 10
  check "",743,200 30 10 10
  check "",744,200 40 10 10
  check "",745,200 50 10 10
  check "",746,200 60 10 10
  check "",747,200 70 10 10
  text "Privati",1742,210 20 35 10
  text "Chan",1743,210 30 35 10
  text "Notices",1744,210 40 35 10
  text "Ctcps",1745,210 50 35 10
  text "Inviti",1746,210 60 35 10
  text "Control codes",1747,210 70 50 10

  text "Disattiva :",748,190 90 35 10,left
  edit "",749,200 100 15 10,left
  text "secondi",750,217 101 25 10,left
  check "",751,245 100 10 10
  text "Attiva",1751,255 100 30 10

  button "Ignora", 720, 25 125 30 12, ok
  button "Cancel", 721, 60 125 30 12, cancel
  button "Salva Impostaz.",752, 155 125 40 10
  button "Ripristina Imp. Default",753, 200 125 65 10
}

alias -l  setIgnore {
  var %ign.i = 1
  var %ignore.address.did = 724
  while (%ign.i <= 9) {
    did -ra ignoreDialog %ignore.address.did $address(%ignore.nick,%ign.i)
    inc %ign.i 1
    inc %ignore.address.did 2
  }
  did -c ignoreDialog $calc(721 + 2 * %ignore.type.default)
  unset %ignore.nick
  if (%ignore.delay == on) { did -c ignoreDialog 751 | did -rae ignoreDialog 749 %ignore.delay.timer }
  else { did -u ignoreDialog 751 | did -rab ignoreDialog 749 %ignore.delay.timer }

  %ign.i = 1
  while (%ign.i <= $numtok(%ignore.switches.default,44)) {
    did -c ignoreDialog $calc(741 + $gettok(%ignore.switches.default,%ign.i,44))
    inc %ign.i 1
  }
}


ON *:DIALOG:ignoreDialog:INIT:0:{ 
  setIgnore
  dll $mdx SetMircVersion $version
  dll $mdx MarkDialog $dname $dialog($dname).hwnd
  if (%unome == 2) {
    dll $mdx SetDialog $dname bgcolor $rgb(0,0,95)
    dll $mdx  SetColor 722,723,725,727,729,731,733,735,737,739,741,742,743,744,745,746,747,1742,1743,1744,1745,1746,1747,748,749,750,751,1751 background $dname bgcolor $rgb(0,0,95)
    dll $mdx  SetColor 722,723,725,727,729,731,733,735,737,739,741,742,743,744,745,746,747,1742,1743,1744,1745,1746,1747,748,749,750,751,1751 textbg $rgb(0,0,95)
    dll $mdx  SetColor 722,723,725,727,729,731,733,735,737,739,741,742,743,744,745,746,747,1742,1743,1744,1745,1746,1747,748,749,750,751,1751 background $rgb(0,0,95)
    dll $mdx  SetColor 722,723,725,727,729,731,733,735,737,739,741,742,743,744,745,746,747,1742,1743,1744,1745,1746,1747,748,749,750,751,1751,724,726,728,730,732,734,736,738,740 text $rgb(255,255,255)
    dll $mdx  SetColor $dname 724,726,728,730,732,734,736,738,740,749 background $rgb(0,0,0)
    dll $mdx  SetColor $dname 724,726,728,730,732,734,736,738,740,749 textbg $rgb(0,0,0)
    dll $mdx  SetColor 724,726,728,730,732,734,736,738,740,749 background $rgb(0,0,0)
    dll $mdx  SetColor 724,726,728,730,732,734,736,738,740,749 text $rgb(255,255,255)
    dll $mdx  SetColor $dname 720,721,752,753 background $rgb(0,0,95)
  }
  if (%unome == 1) {
    dll $mdx SetDialog $dname bgcolor $rgb(0,72,170)
    dll $mdx  SetColor 722,723,725,727,729,731,733,735,737,739,741,742,743,744,745,746,747,1742,1743,1744,1745,1746,1747,748,750,751,1751 background $dname bgcolor $rgb(0,72,170)
    dll $mdx  SetColor 722,723,725,727,729,731,733,735,737,739,741,742,743,744,745,746,747,1742,1743,1744,1745,1746,1747,748,750,751,1751 textbg $rgb(0,72,170)
    dll $mdx  SetColor 722,723,725,727,729,731,733,735,737,739,741,742,743,744,745,746,747,1742,1743,1744,1745,1746,1747,748,750,751,1751 background $rgb(0,72,170)
    dll $mdx  SetColor 722,723,725,727,729,731,733,735,737,739,741,742,743,744,745,746,747,1742,1743,1744,1745,1746,1747,748,749,750,751,1751,724,726,728,730,732,734,736,738,740 text $rgb(255,255,255)
    dll $mdx  SetColor $dname 724,726,728,730,732,734,736,738,740,749 background $rgb(0,0,0)
    dll $mdx  SetColor $dname 724,726,728,730,732,734,736,738,740,749 textbg $rgb(0,0,0)
    dll $mdx  SetColor 724,726,728,730,732,734,736,738,740,749 background $rgb(0,0,0)
    dll $mdx  SetColor 724,726,728,730,732,734,736,738,740,749 text $rgb(255,255,255)
    dll $mdx  SetColor $dname 720,721,752,753 background $rgb(0,72,170)
  }
}
ON *:DIALOG:ignoreDialog:SCLICK:751:{
  if ($did(751).state == 1) { did -e ignoreDialog 749 %ignore.delay.timer }
  if ($did(751).state == 0) { did -b ignoreDialog 749 %ignore.delay.timer }
}

;restore settings button
ON *:DIALOG:ignoreDialog:SCLICK:753:{ 
  ignore.settings  
  var %ign.i = 1
  var %ignore.address.did = 723
  while (%ign.i <= 9) {
    did -u ignoreDialog %ignore.address.did
    inc %ign.i 1
    inc %ignore.address.did 2
  }
  %ign.i = 1
  %ignore.address.did = 742
  while (%ign.i <= 6) {
    did -u ignoreDialog %ignore.address.did
    inc %ign.i 1
    inc %ignore.address.did 1
  }
  did -c ignoreDialog $calc(721 + 2 * %ignore.type.default)
  if (%ignore.delay == on) { did -c ignoreDialog 751 | did -rae ignoreDialog 749 %ignore.delay.timer }
  else { did -u ignoreDialog 751 | did -rab ignoreDialog 749 %ignore.delay.timer }

  %ign.i = 1
  while (%ign.i <= $numtok(%ignore.switches.default,44)) {
    did -c ignoreDialog $calc(741 + $gettok(%ignore.switches.default,%ign.i,44))
    inc %ign.i 1
  }
}

;save settings button
ON *:DIALOG:ignoreDialog:SCLICK:752:{
  var %ign.i = 1
  var %ignore.address.did = 723
  while (%ign.i <= 9) {
    if ($did(%ignore.address.did).state == 1) { set %ignore.type.default [ %ign.i ] } 
    inc %ign.i 1
    inc %ignore.address.did 2
  }
  %ign.i = 1
  %ignore.address.did = 742
  var %ignore.switches.save
  var %ignore.switches.abbr
  while (%ign.i <= 6) {
    if ($did(%ignore.address.did).state == 1) { 
      if (Privates isin $did(%ignore.address.did).text) { %ignore.switches.abbr = 1 }  
      if (Channel isin $did(%ignore.address.did).text) { %ignore.switches.abbr = 2 }  
      if (Notices isin $did(%ignore.address.did).text) { %ignore.switches.abbr = 3 }  
      if (Ctcps isin $did(%ignore.address.did).text) { %ignore.switches.abbr = 4 }  
      if (Invites isin $did(%ignore.address.did).text) { %ignore.switches.abbr = 5 }  
      if (Control isin $did(%ignore.address.did).text) { %ignore.switches.abbr = 6 }  
      %ignore.switches.save = %ignore.switches.save $+ $chr(44) $+ %ignore.switches.abbr
    }
    inc %ign.i 1
    inc %ignore.address.did 1
  }
  set %ignore.switches.default [ $right(%ignore.switches.save,$calc($len(%ignore.switches.save) - 1)) ]

  if ($did(751).state == 1) { set %ignore.delay [ on ] }
  else { set %ignore.delay [ off ] }
  if (($did(749).text != $null) && ($did(749).text isnum) && ($did(749).text >= 0)) { set %ignore.delay.timer [ $did(749).text ] }
  else { 
    if ($did(751).state == 1) { did -rae ignoreDialog 749 %ignore.delay.timer  }
    else { did -rab ignoreDialog 749 %ignore.delay.timer  }
  } 
}

;cancel button
ON *:DIALOG:ignoreDialog:SCLICK:721:close -x

;ignore button
ON *:DIALOG:ignoreDialog:SCLICK:720:{
  var %ign.i = 1
  var %ignore.address.did = 723
  var %ignore.mask
  while (%ign.i <= 9) {
    if ($did(%ignore.address.did).state == 1) { %ignore.mask = $did($calc(%ignore.address.did + 1)).text } 
    inc %ign.i 1
    inc %ignore.address.did 2
  }
  %ign.i = 1
  %ignore.address.did = 742
  var %ignore.switches
  var %ignore.switches.abbr
  while (%ign.i <= 6) {
    if ($did(%ignore.address.did).state == 1) { 
      if (Privates isin $did(%ignore.address.did).text) { %ignore.switches.abbr = p }  
      if (Channel isin $did(%ignore.address.did).text) { %ignore.switches.abbr = c }  
      if (Notices isin $did(%ignore.address.did).text) { %ignore.switches.abbr = n }  
      if (Ctcps isin $did(%ignore.address.did).text) { %ignore.switches.abbr = t }  
      if (Invites isin $did(%ignore.address.did).text) { %ignore.switches.abbr = i }  
      if (Control isin $did(%ignore.address.did).text) { %ignore.switches.abbr = k }  
      %ignore.switches = %ignore.switches $+ %ignore.switches.abbr
    }
    inc %ign.i 1
    inc %ignore.address.did 1
  }
  if ((%ignore.mask != $null) && (%ignore.switches)) { 
    if ($did(751).state == 1) { 
      ;scri pted by a_ d ude at w w w. ar mat han. c j b. n e t
      if (($did(749).text != $null) && ($did(749).text isnum) && ($did(749).text >= 0)) { ignore - $+ %ignore.switches $+ u $+ $did(749).text %ignore.mask }
      else { echo $colour(info)  -se 3* 7[3Ignora7]3: Ignore cancellato : errore nel timer }
    }
    else { ignore - $+ %ignore.switches %ignore.mask }
  }
  else { echo $colour(info)  -se 3* 7[3Ignora7]3: Ignore cancellato...Non hai selezionato alcun tipo di mask }
}





dialog ignoreListDialog {
  title "Ignore list"
  size -1 -1 270 130
  option dbu
  list 761,10 5 140 100
  text "Applica ignore di tipo:",765,200 5 70 10,left
  check "",766,210 15 10 10
  check "",767,210 25 10 10
  check "",768,210 35 10 10
  check "",769,210 45 10 10
  check "",770,210 55 10 10
  check "",771,210 65 10 10
  check "",772,11 100 10 10

  text "Privati",1766,220 15 35 10
  text "Chan",1767,220 25 35 10
  text "Notices",1768,220 35 35 10
  text "Ctcps",1769,220 45 35 10
  text "Inviti",1770,220 55 35 10
  text "Control codes",1771,220 65 50 10
  text "Ignore abilitato",1772,21 100 70 10

  button "rimuovi",762,160 75 30 10
  button "pulisci tutto",763,160 90 30 10
  button "aggiorna",764,160 10 30 10
  button "ok", 760, 120 115 30 12, ok
}


alias -l  setIgnoreList {
  %ignore.number = $ignore(0)
  if (%ignore.number != 0) {
    var %ign.i = 1
    while (%ign.i <= %ignore.number) {
      did -a ignoreListDialog 761 $ignore(%ign.i)
      inc %ign.i 1
    }
    ;did -f ignoreListDialog $did(761,1)
    set.ignore.types  1
  }
  else {
    var %message = La lista di ignore è vuota
    did -a ignoreListDialog 761 %message
  }
  if ($ignore == $true) { did -c ignoreListDialog 772 }
  else { did -u ignoreListDialog 772  }
}

;show the switches
alias -l  set.ignore.types {
  var %ign.j = 766
  while (%ign.j <= 771) {
    did -u ignoreListDialog %ign.j
    inc %ign.j 1
  }      
  %ign.j = 1 
  var %types.max = $numtok($ignore($1).type,44)
  while (%ign.j <= %types.max) {
    if (private isin $gettok($ignore($1).type,%ign.j,44)) { did -c ignoreListDialog 766 }  
    if (channel isin $gettok($ignore($1).type,%ign.j,44)) { did -c ignoreListDialog 767 }  
    if (notice isin $gettok($ignore($1).type,%ign.j,44)) { did -c ignoreListDialog 768 }  
    if (ctcp isin $gettok($ignore($1).type,%ign.j,44)) { did -c ignoreListDialog 769 }  
    if (invite isin $gettok($ignore($1).type,%ign.j,44)) { did -c ignoreListDialog 770 }  
    if (codes isin $gettok($ignore($1).type,%ign.j,44)) { did -c ignoreListDialog 771 }  
    inc %ign.j 1
  }
}

ON *:DIALOG:ignoreListDialog:INIT:0:{
  setIgnoreList
  dll $mdx SetMircVersion $version
  dll $mdx MarkDialog $dname $dialog($dname).hwnd
  if (%unome == 1) {
    dll $mdx SetDialog $dname bgcolor $rgb(0,72,170)
    dll $mdx  SetColor 761 background $dname bgcolor $rgb(0,0,0)
    dll $mdx  SetColor 761 textbg $rgb(0,0,0)
    dll $mdx  SetColor 761 background $rgb(0,0,0)
    dll $mdx  SetColor 765,766,767,768,769,770,771,772,1766,1767,1768,1769,1770,1771,1772 background $dname bgcolor $rgb(0,72,170)
    dll $mdx  SetColor 765,766,767,768,769,770,771,772,1766,1767,1768,1769,1770,1771,1772 textbg $rgb(0,72,170)
    dll $mdx  SetColor 765,766,767,768,769,770,771,772,1766,1767,1768,1769,1770,1771,1772 background $rgb(0,72,170)
    dll $mdx  SetColor 761,765,766,767,768,769,770,771,772,1766,1767,1768,1769,1770,1771,1772 text $rgb(255,255,255)
    dll $mdx  SetColor $dname 762,763,764,760 background $rgb(0,72,170)
  }
  if (%unome == 2) {
    dll $mdx SetDialog $dname bgcolor $rgb(0,0,95)
    dll $mdx  SetColor 761 background $dname bgcolor $rgb(0,0,0)
    dll $mdx  SetColor 761 textbg $rgb(0,0,0)
    dll $mdx  SetColor 761 background $rgb(0,0,0)
    dll $mdx  SetColor 765,766,767,768,769,770,771,772,1766,1767,1768,1769,1770,1771,1772 background $dname bgcolor $rgb(0,0,95)
    dll $mdx  SetColor 765,766,767,768,769,770,771,772,1766,1767,1768,1769,1770,1771,1772 textbg $rgb(0,0,95)
    dll $mdx  SetColor 765,766,767,768,769,770,771,772,1766,1767,1768,1769,1770,1771,1772 background $rgb(0,0,95)
    dll $mdx  SetColor 761,765,766,767,768,769,770,771,772,1766,1767,1768,1769,1770,1771,1772 text $rgb(255,255,255)
    dll $mdx  SetColor $dname 762,763,764,760 background $rgb(0,0,95)
  }
}
ON *:DIALOG:ignoreListDialog:SCLICK:761:set.ignore.types $did(761).sel

;delete button
ON *:DIALOG:ignoreListDialog:SCLICK:762:{
  var %no.ignore = La lista ignore è vuota
  if (($did(761).sel != $null) && (%no.ignore !isin $did(761,$did(761).sel))) { 
    var %selected.item = $did(761).sel
    ignore -r $did(761,%selected.item)
    did -d ignoreListDialog 761 $did(761).sel 
    var %ign.j = 766
    while (%ign.j <= 771) {
      did -u ignoreListDialog %ign.j
      inc %ign.j 1
    }     
  }
  else { echo $colour(info)  -se 3* 7[3Ignora7]3: no entry selected }
}


;"delete all" button
ON *:DIALOG:ignoreListDialog:SCLICK:763:{
  var %no.ignore = La lista ignore è vuota
  var %ignore.number = $ignore(0)
  if  ((%ignore.number != 0) && (%no.ignore !isin $did(761,$did(761).sel))) {
    var %ign.i = 1
    while (%ign.i <= $ignore(0)) {
      did -d ignoreListDialog 761 1
      inc %ign.i 1
    }
    ignore -r
    did -a ignoreListDialog 761 La lista ignore è vuota
  }
  else { did -ra ignoreListDialog 761 La lista ignore è vuota }
  var %ign.j = 766
  while (%ign.j <= 771) {
    did -u ignoreListDialog %ign.j
    inc %ign.j 1
  }     
}


;"update" button
ON *:DIALOG:ignoreListDialog:SCLICK:764:{
  var %no.ignore = Ignore list is empty
  if (($did(761).sel != $null) && (%no.ignore !isin $did(761,$did(761).sel))) { 
    var %update.switches
    var %switch.selected = 0
    if ($did(766).state == 1) { %update.switches = %update.switches $+ p | inc %switch.selected 1 }
    if ($did(767).state == 1) { %update.switches = %update.switches $+ c | inc %switch.selected 1 }
    if ($did(768).state == 1) { %update.switches = %update.switches $+ n | inc %switch.selected 1 }
    if ($did(769).state == 1) { %update.switches = %update.switches $+ t | inc %switch.selected 1 }
    if ($did(770).state == 1) { %update.switches = %update.switches $+ i | inc %switch.selected 1 }
    if ($did(771).state == 1) { %update.switches = %update.switches $+ k | inc %switch.selected 1 }
    if (%switch.selected >= 1) { 
      var %selected.item = $did(761).sel
      .ignore -r $did(761,%selected.item)
      ignore - $+ %update.switches $did(761,%selected.item)
      did -c ignoreListDialog 772
    }    
    else { echo $colour(info)  -at 3* 7[3Ignora7]3: Non posso aggiornare se non scegli il tipo di ignore -.- }
  }
  else { echo $colour(info)  -at 3* 7[3Ignora7]3: Scegli l'utente da ignorare prima -.- }
}

;ok button
ON *:DIALOG:ignoreListDialog:SCLICK:760:{
  if ($did(772).state == 1) { 
    .ignore on 
    if ($ignore(0) != 0) { echo $colour(info)  -at 3* 7[3Ignora7]3: Ignore disattivato }
  }
  else { 
    .ignore off 
    if ($ignore(0) != 0) { echo $colour(info)  -at 3* 7[3Ignora7]3: Ignore disattivo }
  }
}
