Peace & Protection 4.00 — File Browser

PeaceProtection4.00v4.0 / PeaceProtection4.00v4.0 / SCRIPT / THEMFILE.MRC

THEMFILE.MRC — 27.24 KB — Download this file

; #= P&P.temp -rs
; ########################################
; Peace & Protection
; Theme loading and saving and some editing
; ########################################

alias _themeunload {
  if ($dialog(themeload)) return
  if ($dialog(linesep)) return
  if ($dialog(ncedit)) return
  _unload themfile
}

dialog themepick {
  title "Theme"
  size -1 -1 290 213
  text "Saving Theme:", 201, 5 3 100 20
  text "Which elements do you wish to include?", 202, 17 20 200 20
  check "&mIRC colors", 1, 30 40 120 16
  check "&P&&P colors", 2, 30 58 120 16
  check "&Nicklist colors", 3, 30 76 120 16
  check "&Line seperator", 4, 30 94 120 16
  check "&Symbols / Brackets", 5, 30 112 120 16
  check "&Text scheme (not including text options)", 6, 30 130 220 16
  check "T&oolbar / Switchbar", 7, 160 40 120 16
  check "&Backgrounds", 8, 160 58 120 16
  check "&Window fonts", 9, 160 76 120 16
  check "M&essages", 10, 160 94 120 16
  check "E&vent sounds", 11, 160 112 120 16
  text "(associated sound/bmp files are included as well)", 40, 30 155 250 16, hide
  text "", 50, 1 1 1 1, hide result autohs
  button "OK", 101, 30 181 80 25, OK default
  button "Cancel", 102, 175 181 80 25, cancel
}
on *:DIALOG:themesave:sclick:101:{
  var %types,%num = 1
  :loop
  if ($did(%num).state) %types = %types $+ $mid(mpnlstobwev,%num,1)
  if (%num < 11) { inc %num | goto loop }
  did -o $dname 50 1 %types
}
on *:DIALOG:themesave:init:*:{
  _progress.1 Gathering theme data...
  _progress.2 0 Flushing mirc.ini...
  ; Grab backgrounds now since we can compare them anyways
  saveini
  flushini " $+ $mircini $+ "
  _progress.2 33 Grabbing backgrounds...
  unset %_bk.*
  var %type,%nosounds = 1,%none = 1,%num = 1
  :loop1
  %type = $gettok(toolbar switchbar toolbuttons status @mdi wchannel wquery wchat wfinger wmessage,%num,32)
  if ($readini -n $mircini background %type) { %_bk. [ $+ [ %type ] ] = $ifmatch | if (%num > 3) %none = 0 }
  if (%num < 10) { inc %num | goto loop1 }

  ; scan sounds
  _progress.2 66 Scanning sounds...
  window -hl @.sounds
  loadbuf @.sounds $_cfg(display.dat)
  %num = $read -s"-- sound" script\scheme.dat | %num = $readn + 1
  var %last = $read -s"-- message" script\scheme.dat | %last = $readn - 1
  :loop2 | if ($left($line(@.sounds,%num),1) !isin .-) %nosounds = 0 | elseif (%num < %last) { inc %num | goto loop2 }
  window -c @.sounds

  ; Check to disable any elements we aren't using
  _progress.2 100 Preparing dialog...
  if (($_texts.name == Default mIRC text) || ($exists($_cfg(text.dat)) == $false)) did -b $dname 6
  if ((%_bk.toolbar == $null) && (%_bk.switchbar == $null) && (%_bk.toolbuttons == $null)) did -b $dname 7
  if (%none) did -b $dname 8
  if (%nosounds) did -b $dname 11
  did -f $dname 1
  window -c @Progress
}
on *:DIALOG:themesave:sclick:*:{
  if (($did(7).state) || ($did(8).state) || ($did(11).state)) did -v $dname 40
  else did -h $dname 40
}

alias _theme {
  var %num,%error,%file,%data,%type,%info,%count,%section,%datadir,%size,%offset,%filename,%display,%nicklist,%line,%method,%font,%filetypes
  if ($1 == load) {
    if ($2 == $null) {
      window -hnl @.files
      %num = $findfile($mircdir,*.ppt,0,@.files)
      if (%num == 0) { window -c @.files | _error No theme files found!Place any themes in $mircdirthemes\ and try again. }
      if ($dialog(themeload)) { did -r themeload 30 | did -b themeload 1,2,3,4,5,6,7,8,9,10,11,201 | dialog -v themeload }
      else dialog -md themeload themeload
      %error = 0
      :loopF
      %file = $line(@.files,%num)
      %data = $read -nl1 %file
      if (*PnP theme file* !iswm %data) %error = 1 %file
      else {
        %data = $read -nl2 %file
        if ($gettok(%data,2,32) > $:bver) %error = 2 $ifmatch %file
        else did -a themeload 30 $read -nl3 %file $chr(160) ( $+ %file $+ )
      }
      if (%num > 1) { dec %num | goto loopF }
      window -c @.files

      if (1* iswm %error) $_doerror($gettok(%error,2-,32),Erroneous theme file!This is not a legitimate P&P theme, or the file is corrupted.)
      if (2* iswm %error) $_doerror($gettok(%error,3-,32),Unusable theme file!This theme is for P&P,$gettok(%error,2,32),.)
      return
    }
    if (-* iswm $2) { %type = $2 | %file = $3- }
    else { %type = -mpnlstobwev | %file = $2- }
    if ((%file == $null) || (%type == -)) return
    _progress.1 Loading theme...
    _progress.2 0 Preparing data...
    saveini
    flushini " $+ $mircini $+ "
    %info = $read -nl2 %file
    close -@ @.load @.display
    window -hl @.load
    filter -fwr 1- $+ $calc($gettok(%info,4,32) + 2) " $+ %file $+ " @.load *
    savebuf @.load $_temp(ts)
    %offset = $lof($_temp(ts))
    .remove $_temp(ts)
    dline @.load 1-3
    if ($remove(%type,p,l,s,v,e) != %type) {
      window -hl @.display
      loadbuf @.display $_cfg(display.dat)
    }
    %line = $gettok(%info,5,32) - 1
    _progress.2 25 Extracting files...
    if ($gettok($line(@.load,%line),1,32)) {
      %num = $ifmatch
      .mkdir themes
      %datadir = themes\ $+ $_merge($gettok($nopath(%file),1,46))
      .mkdir %datadir
      %datadir = %datadir $+ \
      :extract
      inc %line
      %size = $gettok($line(@.load,%line),1,32)
      %filename = %datadir $+ $nopath($gettok($line(@.load,%line),2-,32))
      .remove %filename
      _progress.2 25 Extracting ' $+ %filename $+ '...
      :exloop
      if (%size > 4096) {
        bread " $+ %file $+ " %offset 4096 &data
        bwrite " $+ %filename $+ " -1 4096 &data
        dec %size 4096
        inc %offset 4096
        goto exloop
      }
      bread " $+ %file $+ " %offset %size &data
      bwrite " $+ %filename $+ " -1 %size &data
      inc %offset %size
      if (%num > 1) { dec %num | goto extract }
    }
    _progress.2 50 Loading settings...
    if (b isin %type) remini " $+ $mircini $+ " background
    if (w isin %type) remini " $+ $mircini $+ " fonts
    :load
    %count = $gettok($line(@.load,1),1,32)
    if (%count !isnum) goto loaddone
    %section = $gettok($line(@.load,1),2,32)
    dline @.load 1
    if (%section !isin %type) goto skip
    _progress.2 50 Loading $gettok(mIRC colors.PnP colors.Nicklist colors.Line seperator.Symbols / brackets.Text scheme.Toolbar / switchbar.Backgrounds.Fonts.Messages.Event sounds,$pos(mpnlstobwev,%section,1),46) $+ ...
    goto L $+ %section
    :Lm
    %num = 1 | :loopLm
    colour $gettok(A.B.C.E.Editbox t.H.I.Info2.Inv.J.K.L.Listbox t.M.N.No.Not.Notif.O.Ow.P.Q.T.W.Wh,%num,46) $line(@.load,%num)
    if (%num < 25) { inc %num | goto loopLm }
    goto skip
    :Lp
    %display = 1
    %num = 1 | :loopLp
    rline @.display $calc(%num + 2) $line(@.load,%num)
    if (%num < 5) { inc %num | goto loopLp }
    goto skip
    :Ln | %nicklist = 1 | `set nickcol $line(@.load,1) | goto skip
    :Ll | %display = 1 | rline @.display 23 $line(@.load,1) | goto skip
    :Ls
    %display = 1
    %num = 1 | :loopLs
    rline @.display $calc(%num + 7) $line(@.load,%num)
    if (%num < 15) { inc %num | goto loopLs }
    goto skip
    :Lt
    savebuf 1- $+ %count @.load $_cfg(text.dat)
    if ($alias(text.dat)) .reload -a $_cfg(text.dat)
    else .load -a $_cfg(text.dat)
    _cfgw texts 1
    .enable #pp-texts
    goto skip
    :Lo
    %file = %datadir $+ $nopath($gettok($line(@.load,1),2-,32)) | if ($isfile(%file)) background -l " $+ %file $+ " | else background -lx
    %file = %datadir $+ $nopath($gettok($line(@.load,2),2-,32)) | if ($isfile(%file)) background -h " $+ %file $+ " | else background -hx
    %file = %datadir $+ $nopath($gettok($line(@.load,3),2-,32)) | if ($isfile(%file)) background -u " $+ %file $+ " | else background -ux
    goto skip
    :Lb
    %num = 1 | :loopLb
    %filename = $gettok($line(@.load,%num),2-,32)
    %data = 1- $+ $calc($numtok(%filename,44) - 1)
    %file = %datadir $+ $nopath($gettok(%filename,%data,44))
    %data = $gettok(%filename,$numtok(%filename,44),44)
    %method = $gettok(c f n r t p,$calc(%data + 1),32)
    %filename = %file $+ , $+ %data
    goto $gettok(Lbs Lbm Lbc Lbq Lbz Lbg Lbd,%num,32)
    :Lbs | if ($isfile(%file)) background -s $+ %method " $+ %file $+ " | else background -sx | goto nextLb
    :Lbm | if ($isfile(%file)) background -m $+ %method " $+ %file $+ " | else background -mx | goto nextLb
    :Lbc
    if ($chan(0)) {
      %line = $ifmatch
      :loopLbc
      if ($isfile(%file)) background -e $+ %method $chan(%line) " $+ %file $+ " | else background -ex $chan(%line)
      if (%line > 1) { dec %line | goto loopLbc }
    }
    else {
      if ($isfile(%file)) writeini " $+ $mircini $+ "  background wchannel %filename | else remini " $+ $mircini $+ "  background wchannel
    }
    goto nextLb
    :Lbq
    if ($query(0)) {
      %line = $ifmatch
      :loopLbq
      if ($isfile(%file)) background -e $+ %method $query(%line) " $+ %file $+ " | else background -ex $query(%line)
      if (%line > 1) { dec %line | goto loopLbq }
    }
    else {
      if ($isfile(%file)) writeini " $+ $mircini $+ "  background wquery %filename | else remini " $+ $mircini $+ "  background wquery
    }
    goto nextLb
    :Lbz
    if ($chat(0)) {
      %line = $ifmatch
      :loopLbz
      if ($isfile(%file)) background -e $+ %method = $+ $chat(%line) " $+ %file $+ " | else background -ex = $+ $chat(%line)
      if (%line > 1) { dec %line | goto loopLbz }
    }
    else {
      if ($isfile(%file)) writeini " $+ $mircini $+ "  background wchat %filename | else remini " $+ $mircini $+ "  background wchat
    }
    goto nextLb
    :Lbg
    if ($line(finger window,0)) {
      if ($isfile(%file)) background -g $+ %method " $+ %file $+ " | else background -gx
    }
    else {
      if ($isfile(%file)) writeini " $+ $mircini $+ "  background wfinger %filename | else remini " $+ $mircini $+ "  background wfinger
    }
    goto nextLb
    :Lbd
    if ($line(message window,0) != $null) {
      if ($isfile(%file)) background -d $+ %method " $+ %file $+ " | else background -dx
    }
    else {
      if ($isfile(%file)) writeini " $+ $mircini $+ "  background wmessage %filename | else remini " $+ $mircini $+ "  background wmessage
    }
    goto nextLb
    :nextLb
    if (%num < 7) { inc %num | goto loopLb }
    goto skip
    :Lw
    notify -h
    url hide
    %num = 1 | :loopLw
    %data = $gettok(fstatus fchannel fquery fmessage fdccs fdccg fnotify fwwwlist flist flinks ffinger fscripts,%num,32)
    %font = $gettok($line(@.load,%num),2-,32)
    if (%font != $null) {
      var %font. [ $+ [ %data ] ] = $calc(($gettok(%font,2,44) - 400) % 300) $gettok(%font,1,44) $iif($gettok(%font,2,44) > 700,bold)
      writeini " $+ $mircini $+ " fonts %data %font
    }
    else var %font. [ $+ [ %data ] ] = %font.fstatus
    if (%num < 12) { inc %num | goto loopLw }
    %num = 1
    :font1
    if ($chan(%num)) { font $ifmatch %font.fchannel | inc %num | goto font1 }
    %num = 1
    :font2
    if ($query(%num)) { font $ifmatch %font.fquery | inc %num | goto font2 }
    if ($line(finger window,0)) font -g %font.ffinger
    font -s %font.fstatus
    if ($exists($_cfg(window.ini))) {
      window -hl @.fontfix
      filter -fwx $_cfg(window.ini) @.fontfix font=*
      savebuf @.fontfix $_cfg(window.ini)
      window -c @.fontfix
    }
    goto skip
    :Lv
    %display = 1
    %num = 1 | :loopLv
    %file = $line(@.load,%num)
    if ($gettok(%file,1,32) isin .-) rline @.display $calc(%num + 24) %file
    else rline @.display $calc(%num + 24) %datadir $+ $nopath(%file)
    if (%num < 46) { inc %num | goto loopLv }
    goto skip
    :Le
    %display = 1
    %num = 1 | :loopLe
    rline @.display $calc(%num + 71) $line(@.load,%num)
    if (%num < 50) { inc %num | goto loopLe }
    goto skip
    :skip
    dline @.load 1- $+ %count
    goto load
    :loaddone
    _progress.2 75 Applying settings...
    if (%display) {
      savebuf @.display $_cfg(display.dat)
      _upd.markup
    }
    if (%nicklist) .nickcol
    close -@ @.load @.display
    _progress.2 100 Theme loaded!
    _themeunload
  }
  elseif ($1 == save) {
    %type = $dialog(themesave,themepick,-4)
    if (%type == $null) { _themeunload | return }
    %info = $_entry(0,$me,Name for your theme?(be descriptive- spaces, etc. are OK))
    %file = $_merge(%info)
    if (($bits == 16) || ($os == Win3.x)) %file = $left(%file,8)
    %file = $mircdirthemes\ $+ %file $+ .ppt
    %file = $$dir="Save theme file as...?" %file
    %file = $_add.ext(ppt,%file)
    if ($exists(%file)) _fileopt 0 %file
    close -@ @.save @.files
    window -hl @.save
    window -hl @.files
    aline @.save %info
    %display = $len(%type) + 4
    _progress.1 Saving theme...
    %section = 1
    :save
    if ($mid(%type,%section,1)) {
      aline @.save $ifmatch
      %line = $line(@.save,0)
      _progress.2 $int($calc(%section * 100 / %display)) Saving theme data...
      goto $mid(%type,%section,1)
    }
    _progress.2 $int($calc(%section * 100 / %display)) Listing sound / bmp files...
    aline @.save $line(@.files,0) files
    %offset = $line(@.save,0)
    %num = $line(@.files,0)
    if (%num) {
      :files1
      %filetypes = $addtok(%filetypes,$gettok($line(@.files,%num),$numtok($line(@.files,%num),46),46),47)
      aline @.save $lof($line(@.files,%num)) $line(@.files,%num)
      if (%num > 1) { dec %num | goto files1 }
    }
    inc %section
    _progress.2 $int($calc(%section * 100 / %display)) Saving data to theme file...
    if (%filetypes == $null) %filetypes = 0
    iline @.save 1 %type $:bver %filetypes $line(@.save,0) %offset
    iline @.save 1 ; PnP theme file - Do not modify
    savebuf @.save " $+ %file $+ "
    inc %section
    _progress.2 $int($calc(%section * 100 / %display)) Appending binary files...
    %num = $line(@.files,0)
    if (%num) {
      :files2
      .copy -a " $+ $line(@.files,%num) $+ " " $+ %file $+ "
      if (%num > 1) { dec %num | goto files2 }
    }
    _progress.2 100 Theme saved!
    unset %_bk.*
    close -@ @.save @.files
    _themeunload
    return
    :p | loadbuf 3-7 @.save $_cfg(display.dat) | %count = 5 | goto next
    :n | aline @.save %`nickcol | %count = 1 | goto next
    :l | aline @.save $read -nl23 $_cfg(display.dat) | %count = 1 | goto next
    :s | loadbuf 8-22 @.save $_cfg(display.dat) | %count = 15 | goto next
    :t
    filter -fw $_cfg(text.dat) @.save *
    %count = $filtered
    goto next
    :o |
    if ($exists(%_bk.toolbar)) aline @.files %_bk.toolbar
    if ($exists(%_bk.switchbar)) aline @.files %_bk.switchbar
    if ($exists(%_bk.toolbuttons)) aline @.files %_bk.toolbuttons
    aline @.save . %_bk.toolbar
    aline @.save . %_bk.switchbar
    aline @.save . %_bk.toolbuttons
    %count = 3
    goto next
    :b
    %num = 1 | :loopb
    %filename = %_bk. [ $+ [ $gettok(status @mdi wchannel wquery wchat wfinger wmessage,%num,32) ] ]
    aline @.save . %filename
    %data = 1- $+ $calc($numtok(%filename,44) - 1)
    %filename = $gettok(%filename,%data,44)
    if ($exists(%filename)) aline @.files %filename
    if (%num < 7) { inc %num | goto loopb }
    %count = 7
    goto next
    :w
    %num = 1 | :loopw
    aline @.save . $readini -n $mircini fonts $gettok(fstatus fchannel fquery fmessage fdccs fdccg fnotify fwwwlist flist flinks ffinger fscripts,%num,32)
    if (%num < 12) { inc %num | goto loopw }
    %count = 12
    goto next
    :e | loadbuf 72-121 @.save $_cfg(display.dat) | %count = 50 | goto next
    :v
    loadbuf 25-70 @.save $_cfg(display.dat)
    %count = 0
    %num = $line(@.save,0)
    :loopv
    %filename = $line(@.save,$calc(%num - %count))
    if ((%filename != .) && ($exists(%filename))) aline @.files %filename
    inc %count | if (%count < 46) goto loopv
    goto next
    :m
    %num = 1 | :loopm
    aline @.save $colour($gettok(A.B.C.E.Editbox t.H.I.Info2.Inv.J.K.L.Listbox t.M.N.No.Not.Notif.O.Ow.P.Q.T.W.Wh,%num,46))
    if (%num < 25) { inc %num | goto loopm }
    %count = 25
    goto next
    :next
    rline @.save %line %count $line(@.save,%line)
    inc %section
    goto save
  }
  elseif ($1) _recurse _theme load $1-
}

dialog themeload {
  title "P&P Themes"
  size -1 -1 400 364

  box "&Available themes:", 101, 10 10 380 150
  list 30, 20 30 360 140, sort

  box "Install theme:", 102, 10 170 380 150

  check "&mIRC colors", 1, 20 190 120 16, disable
  check "&P&&P colors", 2, 20 208 120 16, disable
  check "&Nicklist colors", 3, 20 226 120 16, disable
  check "&Line seperator", 4, 20 244 120 16, disable
  check "&Symbols / Brackets", 5, 20 262 120 16, disable
  check "&Text scheme", 6, 20 280 220 16, disable
  check "T&oolbar / Switchbar", 7, 150 190 120 16, disable
  check "&Backgrounds", 8, 150 208 120 16, disable
  check "&Window fonts", 9, 150 226 120 16, disable
  check "M&essages", 10, 150 244 120 16, disable
  check "E&vent sounds", 11, 150 262 120 16, disable

  button "&Install", 201, 260 284 120 25, default OK disable

  button "Cl&ose", 202, 110 330 80 25, cancel
  button "H&elp", 203, 210 330 80 25, disable
}
on *:DIALOG:themeload:sclick:30:{
  did -e $dname 201
  var %num = 1,%types = $read -nl2 $left($gettok($did(30,$did(30).sel),$numtok($did(30,$did(30).sel),40),40),-1)
  %types = $gettok(%types,1,32)
  :loop
  did $iif($mid(mpnlstobwev,%num,1) isin %types,-ec,-bu) $dname %num
  if (%num < 11) { inc %num | goto loop }
}
on *:DIALOG:themeload:sclick:201:{
  var %num = 1,%types = -
  :loop
  if ($did(%num).state) %types = %types $+ $mid(mpnlstobwev,%num,1)
  if (%num < 11) { inc %num | goto loop }
  _juryrig2 _theme load %types $left($gettok($did(30,$did(30).sel),$numtok($did(30,$did(30).sel),40),40),-1)
}
on *:DIALOG:themeload:sclick:202:.timer -o 1 0 _themeunload

;
; Modification of line separator
;
dialog linesep {
  title "Line Separator"
  size -1 -1 340 160

  radio "Color based:", 51, 3 5 100 16
  radio "Custom:", 52, 3 70 100 16

  icon 1, 20 25 15 15
  icon 2, 40 25 15 15
  icon 3, 60 25 15 15
  icon 4, 80 25 15 15
  icon 5, 100 25 15 15
  icon 6, 120 25 15 15
  icon 7, 140 25 15 15
  icon 8, 160 25 15 15
  icon 9, 180 25 15 15
  icon 10, 200 25 15 15
  icon 11, 20 45 15 15
  icon 12, 40 45 15 15
  icon 13, 60 45 15 15
  icon 14, 80 45 15 15
  icon 15, 100 45 15 15
  icon 16, 120 45 15 15
  icon 17, 140 45 15 15
  icon 18, 160 45 15 15
  icon 19, 180 45 15 15
  icon 20, 200 45 15 15

  text "Char:", 201, 220 26 38 20, right
  edit "", 54, 260 22 50 22
  text "Times:", 202, 220 49 38 20, right
  edit "", 55, 260 45 50 22
  edit "", 53, 20 90 315 22, autohs

  button "OK", 101, 20 125 80 25, OK default
  button "Cancel", 102, 130 125 80 25, cancel
  button "Help", 103, 240 125 80 25, disable
}
on *:DIALOG:linesep:init:*:{
  var %num = 1
  :loop
  did -g linesep %num script\ $+ %_color. [ $+ [ %num ] ] $+ .bmp
  if (%num < 20) { inc %num | goto loop }
}
alias _line {
  if ($dialog(linesep)) { dialog -v linesep | return }
  var %line = $read -ntl23 $_cfg(display.dat)
  _cs-prep
  if ($gettok(%line,1,32) == a) {
    var %col,%num = 1 | :loop1 | %col = $gettok(%line,$calc(3 + %num),32) | if (%col isnum) %_color. [ $+ [ %num ] ] = $calc(%col) | else %_color. [ $+ [ %num ] ] = 16 | if (%num < 20) { inc %num | goto loop1 }
    dialog -am linesep linesep
    did -c linesep 51
    did -a linesep 54 $gettok(%line,3,32)
    did -a linesep 55 $gettok(%line,2,32)
    did -a linesep 53 $:::
  }
  else {
    var %num = 1 | :loop2 | %_color. [ $+ [ %num ] ] = 16 | if (%num < 20) { inc %num | goto loop2 }
    dialog -am linesep linesep
    did -fc linesep 52
    did -a linesep 53 $gettok(%line,2-,32)
    %num = $len($strip($gettok(%line,2-,32)))
    if (%num > 200) %num = 200
    elseif (%num < 1) %num = 1
    did -a linesep 55 %num
    var %char = $right($left($strip($gettok(%line,2-,32)),2),1)
    if (%char == $null) %char = -
    did -a linesep 54 %char
  }
}
on *:DIALOG:linesep:sclick:101:{
  _cs-fin
  if ($did(52).state) var %line = b $did(53)
  else {
    var %line = a $iif($did(55) isnum 1-200,$did(55),20) $iif($did(54) == $null,-,$did(54)),%num = 1
    :loop
    if (%_color. [ $+ [ %num ] ] < 16) %line = %line %_color. [ $+ [ %num ] ]
    if (%num < 20) { inc %num | goto loop }
  }
  write -l23 $_cfg(display.dat) %line
  _upd.markup
  unset %_color.*
  .timer -o 1 0 _themeunload
}
on *:DIALOG:linesep:sclick:102:_cs-fin | unset %_color.* | .timer -o 1 0 _themeunload
on *:DIALOG:linesep:sclick:*:if ($did < 21) _cs-go 15 15 1

;
; Nicklist color editor
;
dialog ncedit {
  title "Nicklist Colors"
  size -1 -1 328 285

  check "&Color users in nicklist:", 1, 5 10 130 16
  check "C&olor nicknames in channel text:", 2, 135 10 200 16

  icon 111, 100 50 15 15
  icon 112, 145 50 15 15
  icon 113, 190 50 15 15

  icon 121, 100 68 15 15
  icon 122, 145 68 15 15
  icon 123, 190 68 15 15

  icon 131, 100 86 15 15
  icon 132, 145 86 15 15
  icon 133, 190 86 15 15

  icon 141, 100 104 15 15
  icon 142, 145 104 15 15
  icon 143, 190 104 15 15

  icon 151, 100 122 15 15
  icon 152, 145 122 15 15
  icon 153, 190 122 15 15

  icon 161, 100 140 15 15
  icon 162, 145 140 15 15
  icon 163, 190 140 15 15

  icon 171, 100 158 15 15
  icon 172, 145 158 15 15
  icon 173, 190 158 15 15

  icon 181, 100 176 15 15
  icon 182, 145 176 15 15
  icon 183, 190 176 15 15

  text "Normal", 201, 5 53 85 20, right
  text "Notify / Userlist", 202, 5 71 85 20, right
  text "Failed notify", 203, 5 89 85 20, right
  text "Blacklist / Ignore", 204, 5 107 85 20, right
  text "IRCop", 205, 5 125 85 20, right
  text "Yourself", 206, 5 143 85 20, right
  text "Lagged", 207, 5 161 85 20, right
  text "Being pinged", 208, 5 179 85 20, right

  text "Reg.", 209, 97 33 30 16
  text "Voice", 210, 140 33 30 16
  text "Op", 211, 190 33 30 16

  button "Copy &down", 11, 235 49 80 25
  button "Copy &right", 13, 235 84 80 25
  button "Cl&ear", 12, 235 119 80 25

  button "Default &1", 14, 9 215 80 25
  button "Default &2", 15, 122 215 80 25
  button "Default &3", 16, 235 215 80 25

  text "Use lagged color", 20, 235 154 80 16
  text "if lagged:", 21, 235 171 43 16
  edit "", 22, 282 167 35 22
  text "seconds or more", 23, 235 188 80 16

  button "OK", 17, 9 250 80 25, OK default
  button "Cancel", 18, 122 250 80 25, cancel
  button "&Help", 19, 235 250 80 25, disable
}
alias _ncedit {
  if ($dialog(ncedit)) { dialog -v ncedit | return }
  _cs-prep
  _ncset %`nickcol
  dialog -am ncedit ncedit
  if ($_cfgi(nickcol)) did -c ncedit 1
  if (%`themecol) did -c ncedit 2
}
alias -l _ncupd {
  var %x = 1,%y = 1
  :loop
  did -g ncedit 1 $+ %y $+ %x script\ $+ %_color.1 [ $+ [ %y ] $+ [ %x ] ] $+ .bmp
  if (%x < 3) { inc %x | goto loop }
  if (%y < 8) { %x = 1 | inc %y | goto loop }
}
alias -l _ncset {
  var %x = 1,%y = 1
  :loop
  %_color.1 [ $+ [ %y ] $+ [ %x ] ] = $calc($gettok($gettok($1-,%y,32),%x,45))
  if (%x < 3) { inc %x | goto loop }
  if (%y < 8) { %x = 1 | inc %y | goto loop }
}
on *:DIALOG:ncedit:init:*:_ncupd | did -a $dname 22 $iif(%`lagtime isnum,%`lagtime,30)
on *:DIALOG:ncedit:sclick:11:{
  var %y = 2
  :loop
  %_color.1 [ $+ [ %y ] $+ 1 ] = %_color.111
  %_color.1 [ $+ [ %y ] $+ 2 ] = %_color.112
  %_color.1 [ $+ [ %y ] $+ 3 ] = %_color.113
  if (%y < 8) { inc %y | goto loop }
  _ncupd
}
on *:DIALOG:ncedit:sclick:13:{
  var %col,%y = 1
  :loop
  %col = %_color.1 [ $+ [ %y ] $+ 1 ]
  %_color.1 [ $+ [ %y ] $+ 2 ] = %col
  %_color.1 [ $+ [ %y ] $+ 3 ] = %col
  if (%y < 8) { inc %y | goto loop }
  _ncupd
}
on *:DIALOG:ncedit:sclick:12:var %col = $colour(listbox text) | %col = %col $+ - $+ %col $+ - $+ %col $+  | _ncset $_p2s($str(%col,8)) | _ncupd
on *:DIALOG:ncedit:sclick:14:_ncset 1-1-14 2-2-12 10-10-10 10-10-10 7-7-7 2-2-12 5-5-4 6-6-13 | _ncupd
on *:DIALOG:ncedit:sclick:15:_ncset 1-1-1 12-12-12 10-10-10 14-14-14 13-13-13 5-5-5 4-4-4 3-3-3 | _ncupd
on *:DIALOG:ncedit:sclick:16:_ncset 2-2-12 6-6-13 5-5-4 5-5-4 10-10-10 1-1-14 7-7-7 3-3-3 | _ncupd
on *:DIALOG:ncedit:sclick:17:{
  _cs-fin
  var %new,%done,%bit,%x = 1,%y = 1
  :loop
  %new = %_color.1 [ $+ [ %y ] $+ [ %x ] ]
  %bit = %bit $+ - $+ $_cprep(%new)
  if (%x < 3) { inc %x | goto loop }
  %done = %done $right(%bit,-1)
  if (%y < 8) { %x = 1 | var %bit | inc %y | goto loop }
  `set nickcol %done
  `set themecol $did(2).state
  if ($did(1).state) { _cfgw nickcol 1 | .nickcol on }
  else { _cfgw nickcol 0 | .nickcol off }
  unset %_color.*
  `set lagtime $did(22)
  .timer -o 1 0 _themeunload
}
on *:DIALOG:ncedit:sclick:18:_cs-fin | unset %_color.* | .timer -o 1 0 _themeunload
on *:DIALOG:ncedit:sclick:*:if ($did > 100) _cs-go 15 15 0

;
; Font control dialog
;

dialog fontfix {
  title "Font Control"
  size -1 -1 270 175
  text "P&&P can change the fonts of other window types to match your current status window font. Select the window types to update and press Update to do so.", 1, 10 15 270 60
  check "&Channels", 10, 10 70 110 16
  check "&Queries / Chats", 11, 10 90 110 16
  check "&DCC Send / Get", 12, 10 110 110 16
  check "&Notify / URL List", 13, 125 70 120 16
  check "&Other mIRC Windows", 14, 125 90 120 16
  check "&P&&P Windows", 15, 125 110 120 16
  button "&Update", 101, 30 140 80 25, OK default
  button "Cancel", 102, 145 140 80 25, cancel
}
on *:DIALOG:fontfix:init:*:did -c $dname 10,11
on *:DIALOG:fontfix:sclick:101:{
  ; Grab font
  window -h @.fontgrab
  var %error,%num,%data,%font2,%font1 = $window(@.fontgrab).fontsize $window(@.fontgrab).font $iif($window(@.fontgrab).fontbold,bold)
  %font2 = $window(@.fontgrab).font $+ , $+ $calc($iif($window(@.fontgrab).fontbold,700,400) + $window(@.fontgrab).fontsize)
  window -c @.fontgrab
  saveini
  flushini " $+ $mircini $+ "
  if ($did(10).state) {
    %num = 1
    :loop1
    if ($chan(%num)) { font $ifmatch %font1 | inc %num | goto loop1 }
    writeini " $+ $mircini $+ " fonts fchannel %font2
    %num = $read -tns[fonts] $mircini
    %num = $readn + 1
    :loop2
    %data = $read -tnl [ $+ [ %num ] ] $mircini
    if ([* !iswm %data) {
      if ($_ischan($right($gettok(%data,1,61),-1))) write -dl [ $+ [ %num ] ] " $+ $mircini $+ "
      else inc %num
      goto loop2
    }
  }
  if ($did(11).state) {
    %num = 1
    :loop3
    if ($query(%num)) { font $ifmatch %font1 | inc %num | goto loop3 }
    if (($chat(0)) || ($fserv(0))) %error = 1
    writeini " $+ $mircini $+ " fonts fquery %font2
    writeini " $+ $mircini $+ " fonts fmessage %font2
  }
  if ($did(12).state) {
    writeini " $+ $mircini $+ " fonts fdccs %font2
    writeini " $+ $mircini $+ " fonts fdccg %font2
    if (($send(0)) || ($get(0))) %error = 1
  }
  if ($did(13).state) {
    notify -h
    url hide
    writeini " $+ $mircini $+ " fonts fnotify %font2
    writeini " $+ $mircini $+ " fonts fwwwlist %font2
  }
  if ($did(14).state) {
    writeini " $+ $mircini $+ " fonts flist %font2
    writeini " $+ $mircini $+ " fonts flinks %font2
    writeini " $+ $mircini $+ " fonts ffinger %font2
    if ($line(finger window,0)) font -g %font1
  }
  if (($did(15).state) && ($exists($_cfg(window.ini)))) {
    window -hl @.fontfix
    filter -fwx $_cfg(window.ini) @.fontfix font=*
    savebuf @.fontfix $_cfg(window.ini)
    window -c @.fontfix
  }
  if (%error) _error Warning- Could not change open DCCsAny open DCC windows will not be updated until reopened
}
alias _fontfix $dialog(fontfix,fontfix,-4) | _themeunload