bmp2html — File Browser

bmp2htmlv2002.05.01 / bmp2htmlv2002.05.01 / bmp2html.mrc

bmp2html.mrc — 14.46 KB — Download this file

alias bmp2htmlversion var %v = 2002.05.01 | if ($1) return %v | return bmp2html [[ $+ %v $+ ]]
on *:load:bmp2html.init
alias bmp2html.init {
  if ($version < 5.81) {
    e You need mIRC v5.81 or higher. Get it from  $+ $colour(highlight) $+ www.mirc.co.uk
    if ($?!="You need mIRC32 v5.81 to use bmp2html.") .timer 1 0 run http://www.mirc.com/
    .unload -rs " $+ $script $+ "
    return
  }
  var %this = $script, %x = $script(0)
  while (%x) {
    var %that = $script(%x)
    if ($shortfn(%this) == $shortfn(%that)) && (%this != %that) .unload -rs " $+ %that $+ "
    dec %x
  }
  if (* !iswm %bmp2html.bg) {
    %bmp2html.in = $scriptdir $+ example1.bmp
    %bmp2html.out = $scriptdir $+ example1bmp.html
    %bmp2html.usefile = 0
    %bmp2html.word = $abc(97,122)
    %bmp2html.random = 1
    %bmp2html.file = $findfile($mircdir,versions.txt,1)
    setdefaults
  }
  e $bmp2htmlversion loaded. Type /bmp2html
  aboutbmp2html
}
alias -l setdefaults {
  %bmp2html.font = Lucida Console
  %bmp2html.size = 10px
  %bmp2html.width = 0px
  %bmp2html.height = 6px
  %bmp2html.bg = #000000
}
alias bmp2html {
  $nodl
  var %dlls = nhtmln.dll bmp2html.dll, %dll = 2, %file
  while (%dll) {
    %file = $gettok(%dlls,%dll,32)
    if ($isfile(%bmp2html. [ $+ [ %file ] ] ) != $true) {
      %bmp2html. [ $+ [ %file ] ] = $findfile($scriptdir,%file,1)
      if (* !iswm %bmp2html. [ $+ [ %file ] ] ) %bmp2html. [ $+ [ %file ] ] = $findfile($mircdir,%file,1)
      if (* !iswm %bmp2html. [ $+ [ %file ] ] ) {
        e File missing: " $+ $scriptdir $+ %file $+ "  Type /downloadbmp2html to fix.
        return
      }
    }
    dec %dll
  }
  var %d = $dialog(bmp2html)
  if ($isfile($1-)) {
    if (%d) did -o %d 1 $1-
    %bmp2html.in = $1-
  }
  if (%d) dialog -ev %d
  else {
    dialog -m bmp2html bmp2html
    if (* * !iswm %bmp2html.xy) %bmp2html.xy = -1 -1
    dialog -s bmp2html %bmp2html.xy -1 -1
  }
}
dialog bmp2html {
  title "bmp2html"
  size -1 -1 279 206
  option dbu
  text "Bmp  (Input)", 401, 6 8 39 9, center
  edit "", 1, 47 6 101 12, autohs
  button "Pick...", 201, 151 6 28 12
  text "Html  (Output)", 402, 6 23 39 9, center
  edit "", 2, 47 21 101 12, autohs
  button "Default", 202, 151 21 28 12
  box "Picture info", 101, 204 42 68 29
  text "", 403, 208 51 60 8
  text "", 404, 208 60 60 8, right
  box "", 102, 204 67 68 71
  icon 100, 208 74 60 60
  box "Html Setup", 103, 6 42 189 159
  text "<Span Style=''", 405, 13 56 38 8, right
  text "Font-Family:", 9, 54 56 33 8, right
  edit "", 3, 89 54 63 12, autohs
  button "Pick...", 203, 155 54 26 12
  text ";", 406, 183 56 5 8
  text "Font-Size:", 407, 59 71 28 8, right
  edit "", 4, 89 69 20 12, autohs
  text ";", 10, 111 71 5 8
  text "Letter-Spacing:", 411, 47 86 40 8, right
  edit "", 8, 89 84 20 12, autohs
  text ";", 11, 111 86 5 8
  text "Line-Height:", 408, 55 101 32 8, right
  edit "", 5, 89 99 20 12, autohs
  text ";", 12, 111 101 5 8
  text "Background-Color:", 14, 39 116 48 8, right
  edit "", 13, 89 114 34 12, autohs
  text ";''>", 409, 125 116 11 8
  button "Set defaults", 15, 146 114 40 12
  edit "", 6, 55 141 131 12, autohs
  button "a-z", 204, 55 155 19 12
  button "A-Z", 205, 76 155 19 12
  button "All chars", 206, 97 155 30 12
  check "Randomize Letters", 303, 131 156 57 10
  radio "Use a word:", 301, 13 142 41 10
  radio "Use a file:", 302, 13 182 36 10
  edit "", 7, 55 181 102 12, autohs
  button "Pick...", 207, 160 181 26 12
  button "Convert", 209, 207 146 30 12, default ok
  button "Cancel", 210, 239 146 30 12, cancel
  button "Check for updates", 208, 209 6 60 12
  text "bmp2html.mrc by ^Andy", 997, 205 167 66 8, center
  text "bmp2html.dll by nacitar", 998, 205 179 66 8, center
  text "nHTMLn.dll by Necroman", 999, 205 191 66 8, center
}
alias -l init {
  if (%bmp2html.in) did -o bmp2html 1 1 $ifmatch
  if (%bmp2html.out) did -o bmp2html 2 1 $ifmatch
  did -o bmp2html 3 1 %bmp2html.font
  did -o bmp2html 4 1 %bmp2html.size
  did -o bmp2html 8 1 %bmp2html.width
  did -o bmp2html 5 1 %bmp2html.height
  did -o bmp2html 13 1 %bmp2html.bg
  did -o bmp2html 6 1 %bmp2html.word
  if (%bmp2html.file) did -o bmp2html 7 1 $ifmatch
  did -c bmp2html $iif(%bmp2html.usefile,302,301)
  if (%bmp2html.random) did -c bmp2html 303
  check
}
alias -l save {
  var %d = $$dialog(bmp2html), %x
  %bmp2html.in = $did(%d,1)
  %bmp2html.out = $did(%d,2)
  %bmp2html.font = $did(%d,3)
  %x = $did(%d,4) | if (%x isnum) %x = %x $+ px | %bmp2html.size = %x
  %x = $did(%d,8) | if (%x isnum) %x = %x $+ px | %bmp2html.width = %x
  %x = $did(%d,5) | if (%x isnum) %x = %x $+ px | %bmp2html.height = %x
  %bmp2html.bg = $did(%d,13)
  %bmp2html.word = $remove($did(%d,6),$chr(32))
  %bmp2html.file = $did(%d,7)
  %bmp2html.random = $did(%d,303).state
  %bmp2html.usefile = $did(%d,302).state
}
on *:dialog:bmp2html:init,sclick,edit:*:{
  if ($devent == init) init
  elseif ($did == 201) .timer -o 1 0 setin
  elseif ($did == 203) .timer -o 1 0 setfont
  elseif ($did == 204) did -o bmp2html 6 1 $abc(97,122)
  elseif ($did == 205) did -o bmp2html 6 1 $abc(65,90)
  elseif ($did == 206) did -o bmp2html 6 1 $abc(33,255)
  elseif ($did == 207) .timer -o 1 0 setfile
  elseif ($did == 208) aboutbmp2html
  elseif ($did == 209) {
    if ($check) {
      save
      var %input = $longfn(%bmp2html.in) $+ ? $+ $longfn(%bmp2html.out) $+ $cr $+ %bmp2html.font $+ $cr $+ %bmp2html.size $+ $cr $+ %bmp2html.width $+ $cr $+ %bmp2html.height $+ $cr $+ %bmp2html.bg $+ $cr $+ $iif(%bmp2html.usefile,3,$iif(%bmp2html.random,2,1)) $+ $cr $+ $iif(%bmp2html.usefile,%bmp2html.file,%bmp2html.word)
      var %output = $dll(%bmp2html.bmp2html.dll,bmp2html,%input)
      if (S_OK isin %output) bmp2html.preview
      else return $?!="ERROR: %output $+ "
    }
    halt
  }
  elseif ($did == 210) {
    %bmp2html.xy = $dialog($dname).x $dialog($dname).y
    save
  }
  elseif ($did == 15) {
    save
    setdefaults
    init
  }
  if ($istok(1 2 6 7 13 301 302 202 204 205 206,$did,32)) check $iif($istok(1 202,$did,32),1)
}
alias -l abc {
  var %x = $1, %c
  while (%x <= $2) {
    if (%x != 33) %c = %c $+ $chr(%x)
    else %c = %c $chr(%x)
    inc %x
  }
  return $remove(%c,$chr(173))
}
alias -l getfile {
  .timer -o 1 0 if ($dialog(bmp2html)) dialog -ev bmp2html
  return $sfile($1,$2-)
}
alias -l setin {
  var %d = $$dialog(bmp2html), %f = $did(%d,1), %m = $mircdir $+ $nofile(%f), %s = $shortfn($iif($isdir(%m),%m,$nofile(%f))) $+ *.bmp
  if ($getfile(%s,select a .bmp)) did -o %d 1 1 $ifmatch
  check 1
}
alias -l setfont {
  .timer -o 1 0 if ($dialog(bmp2html)) dialog -ev bmp2html
  var %d = $$dialog(bmp2html)
  close -@ @bmp2html
  window -Bhpn +df @bmp2html $round($calc(-170+$window(-3).w /2),0) $round($calc(-170+$window(-3).h /2),0) 0 0 " $+ $gettok($did(%d,3),1,44) $+ " 0
  window -a @bmp2html -1 -1 0 0
  font
  if ($dialog(bmp2html)) did -o %d 3 1 $window(@bmp2html).font
  close -@ @bmp2html
}
alias -l setfile {
  var %d = $$dialog(bmp2html), %f = $did(%d,7), %m = $mircdir $+ $nofile(%f), %s = $shortfn($iif($isdir(%m),%m,$nofile(%f)))
  if ($getfile(%s,select a file to get letters from)) did -o %d 7 1 $ifmatch
  check
}
alias -l e echo $colour(info) Ă— $1-
alias -l title {
  dialog -t bmp2html bmp2html - $iif($1,set,ready) $1-
  did $iif($1,-b,-e) bmp2html 209
}
alias -l dfont return Lucida Console, Keyboard Font, Courier New
alias -l checkout {
  var %f = $did(bmp2html,2), %np = $nopath(%f), %nf = $nofile(%f), %ns = $remove(%f,$chr(32))
  if (%nf) && ($isdir(%nf) != $true) || ((*?.htm !iswm %ns) && (*?.html !iswm %ns)) || ($remove(%np,/,:,*,?,",<,>,|) != %np) title html (output)
  else return 1
}
alias -l checkin {
  var %f = $did(bmp2html,1)
  if ($isfile(%f)) && (*.bmp iswm %f) {
    var %w = $pic(%f).width, %h = $pic(%f).height, %p = %w * %h
    if ($1) did -o bmp2html 2 1 $nofile($did(bmp2html,1)) $+ $remove($nopath($did(bmp2html,1)),.) $+ .html
    if ($shortfn($gettok($did(bmp2html,100),2,32)) != $shortfn(%f)) {
      did -g bmp2html 100 $shortfn(%f)
      did -v bmp2html 100
    }
    did -o bmp2html 403 1 Size: %w Ă— %h
    did -o bmp2html 404 1 ( $+ %p pixels)
    return 1
  }
  else {
    did -h bmp2html 100
    did -g bmp2html 100 $shortfn($mircexe)
  }
  did -r bmp2html 2,403,404
  title bmp (input)
}
alias -l checkword {
  if ($did(bmp2html,302).state) return 1
  if (* !iswm $remove($did(bmp2html,6),$chr(32))) title word to get letters from
  else return 1
}
alias -l checkfile {
  if ($did(bmp2html,301).state) return 1
  if ($lines($did(bmp2html,7)) !isnum 1-) title file to get letters from
  else return 1
}
alias -l check {
  if ($checkin($1)) && ($checkout) && ($checkword) && ($checkfile) {
    did -e bmp2html 209
    title
    return 1
  }
}
alias bmp2html.preview {
  if ($dialog(bmp2htmlpreview)) {
    did -o bmp2htmlpreview 1 1 bmp2html.preview.display
    dialog -ev bmp2htmlpreview
  }
  else {
    dialog -m bmp2htmlpreview bmp2htmlpreview
    if (* * !iswm %bmp2html.xy.preview) %bmp2html.xy.preview = -1 -1
    dialog -s bmp2htmlpreview %bmp2html.xy.preview -1 -1
  }
  var %x = $dll(%bmp2html.nhtmln.dll,attach,$dll(%bmp2html.nhtmln.dll,find,bmp2html.preview.display)) $dll(%bmp2html.nhtmln.dll,navigate,$longfn(%bmp2html.out))
  did -o bmp2htmlpreview 1 1
}
dialog bmp2htmlpreview {
  title "bmp2html preview"
  size -1 -1 244 172
  option dbu
  button "Close", 2, 212 3 30 12, ok
  button "", 5, 0 0 0 0, cancel hide
  text "bmp2html.preview.display", 1, 2 18 240 152, center
  button "Open directory", 3, 54 3 50 12
  button "Open in browser", 4, 2 3 50 12
}
on *:dialog:bmp2htmlpreview:sclick:*:{
  if ($did == 3) run " $+ $nofile($longfn(%bmp2html.out)) $+ "
  elseif ($did == 4) run " $+ %bmp2html.out $+ "
  elseif ($did isin 25) %bmp2html.xy.preview = $dialog($dname).x $dialog($dname).y
}
alias aboutbmp2html {
  if ($dialog(aboutbmp2html)) {
    dialog -ev aboutbmp2html
    return
  }
  dialog -m aboutbmp2html aboutbmp2html
}
dialog aboutbmp2html {
  title "About bmp2html"
  size -1 -1 151 58
  option dbu
  button "Close", 98, 116 43 32 12, ok cancel
  text "bmp2html", 1, 3 4 75 8, center
  edit "", 2, 3 15 75 12, read center
  button "Check for a newer version", 3, 3 29 75 12
  button "Install the newest version", 4, 3 43 75 12
  text "bmp2html.mrc by ^Andy", 5, 82 4 66 8, center
  text "bmp2html.dll by nacitar", 6, 82 16 66 8, center
  text "nHTMLn.dll by Necroman", 7, 82 28 66 8, center
  button "Website", 99, 82 43 32 12
}
on *:dialog:aboutbmp2html:init,sclick:*:{
  if ($devent == init) {
    did -o aboutbmp2html 1 1 $bmp2htmlversion
    checkv
  }
  if ($did == 3) checkv
  if ($did == 4) downloadbmp2html
  if ($did == 99) run http://pages.cthome.net/pdufilie/
}
alias -l de {
  if ($dialog(aboutbmp2html)) did -o aboutbmp2html 2 1 $gettok($1-,1,124)
  elseif ($deltok($1-,1,124)) e $ifmatch
}
alias -l checkv {
  $nodl
  de
  if ($sock(bmp2htmlversion).name) return
  de Checking...
  sockopen bmp2htmlversion pages.cthome.net 80
}
on *:sockopen:bmp2htmlversion:{
  if ($sockerr) {
    de Connection error $sockerr
    return
  }
  sockwrite -n $sockname GET /pdufilie/versions.txt HTTP/1.0
  sockwrite -n $sockname Accept: */*
  sockwrite -n $sockname Host: pages.cthome.net
  sockwrite -n $sockname
}
on *:sockread:bmp2htmlversion:{
  if ($sockerr) {
    de Error $sockerr
    return
  }
  var %d, %v, %m = $bmp2htmlversion(1)
  :x
  sockread %d
  if ($sockbr) {
    if (bmp2html * iswm %d) {
      %v = $gettok(%d,2,32)
      %d = $gettok(%d,3,32)
      if (%m != %v) {
        if (%d > $version) {
          de Newest requires mIRC %d
          return
        }
        de New: [ $+ %v $+ ]|New version of bmp2html found! (You have version %m $+ ; version %v is the newest)
      }
      else de No new version
    }
    goto x
  }
}
alias downloadbmp2html {
  $nodl
  de Downloading...
  dlwin
  sockopen downloadbmp2html pages.cthome.net 80
}
alias -l nodl if ($sock(downloadbmp2html).name) || ($timer(installbmp2html)) return return
alias -l exe return " $+ $scriptdir $+ bmp2html.exe"
on *:sockopen:d*bmp2html:{
  if ($sockerr) {
    de Connection error $sockerr |Connection error ( $+ $sockerr $+ ) when downloading bmp2html
    return
  }
  write -c $exe
  %bmp2htmldlb = 0
  %bmp2htmldl = 1
  sockwrite -n $sockname GET /pdufilie/irc/bmp2html.exe HTTP/1.0
  sockwrite -n $sockname Accept: */*
  sockwrite -n $sockname Host: pages.cthome.net
  sockwrite -n $sockname
}
on *:sockread:d*bmp2html:{
  if ($sockerr) {
    de Error $sockerr |Error $sockerr when downloading bmp2html
    return
  }
  while (%bmp2htmldlb !isnum 1-) {
    var %d
    sockread %d
    if ($sockbr) {
      if (Content-Length: * iswm %d) %bmp2htmldl = $gettok(%d,2,32)
      elseif (%d) { }
      else {
        %bmp2htmldlb = $rand(1,16777215)
        break
      }
    }
  }
  :b
  sockread 4096 &d
  if ($sockbr) {
    dlwin
    bwrite $exe -1 -1 &d
    goto b
  }
}
alias -l dlwin {
  var %@ = @Downloading bmp2html
  if (* !iswm $window(%@)) window -BhaCdfopk +Ldf %@ -1 -1 176 24
  drawrect -frn %@ 0 0 0 0 176 24
  drawrect -rn %@ $calc(+%bmp2htmldlb) 0 0 0 176 24
  drawrect -frn %@ 7368816 0 1 1 $calc(+$calc(174*$sock(downloadbmp2html).rcvd /%bmp2htmldl)) 22
  drawtext -rn %@ 12632256 Fixedsys 15 8 4 Downloading bmp2html
  drawpic %@
}
alias -l movedlwin {
  if ($window(@Downloading bmp2html)) {
    window @Downloading bmp2html $calc($mouse.dx -$1) $calc($mouse.dy -$2)
    if ($mouse.key & 1) .timerbmp2htmldlwin -o 1 0 movedlwin $1-
  }
}
menu @Downloading bmp2html {
  sclick:movedlwin $calc($mouse.dx -$window(@Downloading bmp2html).x) $calc($mouse.dy -$window(@Downloading bmp2html).y)
  &Cancel:{
    close -@ @Downloading bmp2html
    sockclose downloadbmp2html
  }
}
on *:close:@Downloading bmp2html:sockclose downloadbmp2html
on *:sockclose:d*bmp2html:install
alias -l install {
  close -@ @Downloading bmp2html
  if ($isfile($exe)) {
    de Installing...
    .timerbmp2htmlerror -o 1 0 e Error occured while downloading bmp2html.
    .dll -u nhtmln.dll
    run $exe
    .timerbmp2htmlerror off
    _load 0
  }
}
alias -l _load {
  if ($isfile($exe) != $true) || ($1 > 20) {
    if ($dialog(aboutbmp2html)) dialog -c aboutbmp2html
    if ($dialog(bmp2html)) dialog -c bmp2html
    if ($dialog(bmp2htmlpreview)) dialog -c bmp2htmlpreview
    .timer -o 1 0 bmp2html.init
    .reload -rs " $+ $script $+ "
  }
  else .timerbmp2html -om 1 200 _load $calc(1+$1)
}