zIRCk Final Project — File Browser

zIRCkFinalProjectv2.5 / zIRCkFinalProjectv2.5 / System / script8.mrc

script8.mrc — 14.07 KB — Download this file

[SCRIPT]
NAME=Sidepanel
VERSION=2.5

; ## on LOAD

on *:load: { if (!%h1) { set %h1 400 } }

; ## on NOTIFY

on *:notify: { 
  if ($rconf(Display,NotifyWin) = on) { $arise(zIRCk Script Notification,$nick $iif($notify($nick).note,$+($chr(40),$notify($nick).note,$chr(41))) is online on $scid($cid).network) }
  .timer -m 1 1 _updatenl 
}

; ## on UNOTIFY 

on *:unotify: { 
  if ($rconf(Display,NotifyWin) = on) { $arise(zIRCk Script Notification,$nick $iif($notify($nick).note,$+($chr(40),$notify($nick).note,$chr(41))) has went offline from $scid($cid).network) }
  .timer -m 1 1 _updatenl 
}

; ## Adding selected nickname to notify list

alias addnotify {
  if ($1) {
    var %x = $?!="Is there a note for $1 $+ ?"
    if (%x = $true) { notify $1 $$?="Enter a note for $1 $+ :" }
    else { notify $1 }
  }
  elseif (!$1) {
    var %n = $$?="Enter nickname:",%x = $?!="Is there a note for %n $+ ?"
    if (%x = $true) && (%n) { notify %n $$?="Enter a note for %n $+ :" }
    else { notify %n }
  }
  _updatenl
}

; ## Removing selected nickname from notify list

alias delnotify {
  if ($1) {
    notify -r $1
    .timer -m 1 1 _updatenl
  }
}

; ## Open/close sidepanel

alias sidepane { if (!%sp_w) { set %sp_w 174 } | $iif(!$dialog(sidepane),dialog -m sidepane sidepane,$iif($1 = -x,sidepane_close))) }
alias sidepane_close { hdock -udock sidepane close }

; ## Left or right dock popup 

alias sidepane_pop {
  popup New sp 16 16
  popup SetStyle sp bordericon bordertext
  popup SetMetrics sp iconpad 1 0 contentpad 0 0 spacing 1 0
  popup AddItem sp end + $+ $iif($rconf(Display,SPSide) = left,x) Left $cr sidepane_sw left
  popup AddItem sp end + $+ $iif($rconf(Display,SPSide) = right,x) Right $cr sidepane_sw right
  ;popup AddItem sp end +
  popup AddItem sp end + Width... $cr sp_width
  pop1 sp $mouse.dx $mouse.dy
}

; ## Notify popup

alias ndock.pop {
  var %n = sidepane
  popup New %n 16 16
  popup SetMetrics %n iconpad 1 0 contentpad 0 0 spacing 1 0
  popup AddItem %n end + Whois $cr nl.cmd whois
  popup AddItem %n end + Query $cr nl.cmd query
  popup AddItem %n end +> Notify list $cr nl
  popup AddItem %n end +
  popup AddItem %n end +> DCC $cr dcc
  popup AddItem %n end +> XDCC $cr xdcc
  %n = dcc
  popup New %n 16 16
  popup SetMetrics %n iconpad 1 0 contentpad 0 0 spacing 1 0
  popup AddItem %n end + Send $cr nl.cmd dccsend
  popup AddItem %n end + Chat $cr nl.cmd dccchat
  popup AddItem %n end + Allow $cr nl.cmd dccallow
  %n = xdcc
  popup New %n 16 16
  popup SetMetrics %n iconpad 1 0 contentpad 0 0 spacing 1 0
  popup AddItem %n end + Request pack $cr nl.cmd xdccr
  popup AddItem %n end + Request list $cr nl.cmd xdccl
  popup AddItem %n end + Remove from queue $cr nl.cmd xdccrq
  popup AddItem %n end + List queues $cr nl.cmd xdcclq
  %n = nl
  popup New %n 16 16
  popup SetMetrics %n iconpad 1 0 contentpad 0 0 spacing 1 0
  popup AddItem %n end + Add user $cr addnotify
  popup AddItem %n end + Remove user $cr $iif($gettok($gettok($did(sidepane,1,$gettok($did(sidepane,1,1), -1,32)), 7-, 32),1,32) != offline,delnotify $gettok($gettok($did(sidepane,1,$gettok($did(sidepane,1,1), -1,32)), 7-, 32),1,32),return)
  popup AddItem %n end + 
  popup AddItem %n end + Import notify list $cr import_notify
  pop1 sidepane $mouse.dx $mouse.dy
}

; ## Notify list popup commands

alias nl.cmd {
  did -i sidepane 1 1 cb root
  var %s = $gettok($did(sidepane,1,$gettok(%tmp,3,32)),7,32),%c = 1
  while %c <= $scon(0) {
    if ($1 = whois) && ($scon(%c).server = %s) {
      did -i sidepane 1 1 cb root $gettok(%tmp,3,32) | scid $scon(%c).cid whois $gettok($gettok($did(sidepane,1,$gettok($did(sidepane,1,1), -1,32)), 7-, 32),1,32) $gettok($gettok($did(sidepane,1,$gettok($did(sidepane,1,1), -1,32)), 7-, 32),1,32) 
    }  
    if ($1 = query) && ($scon(%c).server = %s) {
      did -i sidepane 1 1 cb root $gettok(%tmp,3,32) | scid $scon(%c).cid query $gettok($gettok($did(sidepane,1,$gettok($did(sidepane,1,1), -1,32)), 7-, 32),1,32) 
    }
    if ($1 = dccsend) && ($scon(%c).server = %s) {
      did -i sidepane 1 1 cb root $gettok(%tmp,3,32) | scid $scon(%c).cid dcc send $gettok($gettok($did(sidepane,1,$gettok($did(sidepane,1,1),-1,32)),7-,32),1,32) $+(",$sfile(C:),") | .timer -m 1 1 load.sb | .timer -m 1 1 _update.dcc
    }
    if ($1 = dccchat) && ($scon(%c).server = %s) {
      did -i sidepane 1 1 cb root $gettok(%tmp,3,32) | scid $scon(%c).cid dcc chat $gettok($gettok($did(sidepane,1,$gettok($did(sidepane,1,1), -1,32)), 7-, 32),1,32) 
    }
    if ($1 = dccallow) && ($scon(%c).server = %s) {
      did -i sidepane 1 1 cb root $gettok(%tmp,3,32) | scid $scon(%c).cid dccallow $+(+,$gettok($gettok($did(sidepane,1,$gettok($did(sidepane,1,1), -1,32)), 7-, 32),1,32)) 
    }
    if ($1 = xdccr) && ($scon(%c).server = %s) {
      did -i sidepane 1 1 cb root $gettok(%tmp,3,32) | scid $scon(%c).cid msg $gettok($gettok($did(sidepane,1,$gettok($did(sidepane,1,1), -1,32)), 7-, 32),1,32) xdcc send $$?="Enter pack number:"
    }
    if ($1 = xdccl) && ($scon(%c).server = %s) {
      did -i sidepane 1 1 cb root $gettok(%tmp,3,32) | scid $scon(%c).cid msg $gettok($gettok($did(sidepane,1,$gettok($did(sidepane,1,1), -1,32)), 7-, 32),1,32) xdcc list
    }
    if ($1 = xdccrq) && ($scon(%c).server = %s) {
      did -i sidepane 1 1 cb root $gettok(%tmp,3,32) | scid $scon(%c).cid msg $gettok($gettok($did(sidepane,1,$gettok($did(sidepane,1,1), -1,32)), 7-, 32),1,32) xdcc remove $$?="Enter pack number:"
    }
    if ($1 = xdcclq) && ($scon(%c).server = %s) {
      did -i sidepane 1 1 cb root $gettok(%tmp,3,32) | scid $scon(%c).cid msg $gettok($gettok($did(sidepane,1,$gettok($did(sidepane,1,1), -1,32)), 7-, 32),1,32) xdcc queues
    }
    inc %c
  }
}

; ## Switching sides

alias sidepane_sw {
  if ($1 = left) { conf Display SPSide left | sidepane -x | sidepane }
  elseif ($1 = right) { conf Display SPSide right | sidepane -x | sidepane }
}

; ## Update the DCC list

alias _update.dcc {
  if ($dialog(sidepane)) {
    did -r sidepane 2
    did -a sidepane 2 +be 2 2 Sends $iif($send(0) > 0, ( $+ $ifmatch $+ ))
    did -i sidepane 2 1 cb root last last 1
    var %x = 1
    while %x <= $send(0) {
      did -a sidepane 2 2 2 $send(%x) : $nopath($send(%x).file)
      inc %x
    }
    did -i sidepane 2 1 cb root 
    did -a sidepane 2 +be 1 1 Gets $iif($get(0) > 0, ( $+ $ifmatch $+ ))
    did -i sidepane 2 1 cb root last last 1
    var %x = 1
    while %x <= $get(0) {
      did -a sidepane 2 1 1 $get(%x) : $nopath($get(%x).file)
      inc %x
    }
  }
}

; ## Returns current font size and type

alias _nfontsize { return $calc($right($gettok($readini(mirc.ini,fonts,fstatus),2,44),-1) +2) }
alias _nfonttype { return $gettok($readini(mirc.ini,fonts,fstatus),1,44) }

; ## Updating the notify list

alias _updatenl {
  if ($dialog(sidepane)) { 
    var %d = sidepane
    did -r %d 1
    var %s = 1
    while $scon(%s) {
      if ($scon(%s).server) { 
        did -i %d 1 1 cb root 
        did -a %d 1 +be 3 3 $scon(%s).server 
      }
      inc %s
    }
    did -i %d 1 1 cb root 
    did -a %d 1 +be 4 4 Offline
    var %x = 1
    while $scon(%x) {
      scon %x
      var %s = 1
      while $notify(%s) {
        if ($notify(%s).ison) { 
          did -i %d 1 1 cb root  
          did -i %d 1 1 cb root $didwm(%d,1,* $scon(%x).server $+ *) 
          did -a %d 1 1 1 $notify(%s) $chr(9) $+ Nick: $notify(%s) $crlf $+ Note: $iif($notify(%s).note,$notify(%s).note,n/a) 
          did -i %d 1 1 cb root 
          did -i %d 1 1 cb root $did(%d,1).lines 
          if ($didwm(%d,1,* $notify(%s) *)) { did -d %d 1 $ifmatch }
        }
        else { 
          did -i %d 1 1 cb root 
          did -i %d 1 1 cb root $did(%d,1).lines
          if (!$didwm(%d,1,* $notify(%s) *)) {
            did -i %d 1 1 cb root
            var %l = $did(%d,1).lines
            var %c = 2
            while %c <= %l {
              did -i %d 1 1 cb root %c
              if (!$didwm(%d,1,* $notify(%s) *)) { 
                inc %c 
              }
              else { 
                var %c = $calc(%l +1) 
              }
              if (%c = %l) { 
                did -i %d 1 1 cb root %l 
                did -a %d 1 +e 2 2 $notify(%s) $chr(9) $+ Nick: $notify(%s) $crlf $+ Note: $iif($notify(%s).note,$notify(%s).note,n/a) 
              }
            }          
          }
        }
        inc %s
      }
      inc %x
    }
    did -i %d 1 1 cb root
    var %l = $did(%d,1).lines
    while %l > 0 {
      did -i %d 1 1 cb root %l
      if (!$did(%d,1,2)) { did -i %d 1 1 cb root | did -d %d 1 %l }
      dec %l
    }
    if ($scon(0) <= 1) || ($scon(1).status = disconnected) || ($scon(1).status = connecting)  || ($scon(1).status = connected) {
      did -i %d 1 1 cb root
      var %l = $did(%d,1).lines
      if ($gettok($did(%d,1,%l),7-,32) != offline) { did -a %d 1 +be 4 4 Offline }
      did -i %d 1 1 cb root
    }
  }
}

; ## Change sidepane width

alias sp_width {
  if (!$1) {
    var %x = $input(Enter the new size of the sidepane $+($chr(40),165 is the default,$chr(41)),ei,Enter new width)
    if (%x isnum) {
      %sp_w = %x 
    }
  }
  hosdock DockSize sidepane %sp_w
  .signal hosdock DOCKRESIZE 
  did -h sidepane 5,6
  mdx MoveControl sidepane 1 $iif($rconf(Display,SPSide) = right,4,2) 32 $calc(%sp_w -6) $calc($gettok($did(sidepane,3),3,32) -32)
  mdx MoveControl sidepane 2 $iif($rconf(Display,SPSide) = right,4,2) $calc($gettok($did(sidepane,3),4,32) +2) $calc(%sp_w -6) 9999
  mdx MoveControl sidepane 5 $iif($rconf(Display,SPSide) = right,4,2) 0 $calc(%sp_w -6) 26
  mdx MoveControl sidepane 6 $iif($rconf(Display,SPSide) = right,4,2) 6 $calc(%sp_w -12) 16
  mdx MoveControl sidepane 7 $calc(%sp_w -18) 2 8 22
  did -v sidepane 5,6
  did -ra sidepane 7 4
}

; ## Sidepanel dialog table/events

dialog sidepane {
  title ""
  size -1 -1 %sp_w 9999
  option dbu
  list 1, 2 16 $calc(%sp_w -6) $calc(%h1 /2 -18) , size
  list 2, 2 $calc(%h1 /2 +1) $calc(%sp_w -6) 99999, size
  button "Button", 3, 3 $calc(%h1 /2 -2) 9999 2
  ; box "", 4, 2 -3 84 18
  text "", 5, 2 0 84 13, center
  text "Sidepanel", 6, 2 3 80 8, center
  button "4", 7, 78 1 4 11
}

on *:dialog:sidepane:init:0: {
  $iif(!%sp_w,set %sp_w 174)
  mdx MarkDialog $dname
  mdx SetFont $dname 6 -11 700 Tahoma
  mdx SetFont $dname 7 -11 400 Webdings
  mdx SetControlMDX $dname 1,2 Treeview haslines hasbuttons linesatroot showsel nohscroll > $views 
  mdx SetControlMDX $dname 3 Divider > $ctl
  mdx SetControlMDX $dname 7 Text center > $ctl
  mdx SetColor $dname 5,6,7 background $rgb(154,154,154)
  mdx SetColor $dname 5,6,7 textbg $rgb(154,154,154)
  mdx SetColor $dname 6,7 text $rgb(255,255,255)

  if ($rconf(Display,SPSide) = left) {
    ;mdx MoveControl $dname 1 2 32 168 $calc(%h1 -36)
    ;mdx MoveControl $dname 2 2 $calc(%h1 +1 *2) $calc(84 *2) $calc(9999 /2)
    ;mdx MoveControl $dname 3  1 $calc(%h1 -2) $calc(81 *2) 4
    ;mdx MoveControl $dname 5 2 1 168 26
    ;mdx MoveControl $dname 6 50 6 80 16
    ;mdx MoveControl $dname 7 152 2 14 22
    did -h sidepane 5,6
    mdx MoveControl sidepane 1 $iif($rconf(Display,SPSide) = right,4,2) 32 $calc(%sp_w -6) $calc($gettok($did(sidepane,3),3,32) -32)
    mdx MoveControl sidepane 2 $iif($rconf(Display,SPSide) = right,4,2) $calc($gettok($did(sidepane,3),4,32) +2) $calc(%sp_w -6) 9999
    mdx MoveControl sidepane 5 $iif($rconf(Display,SPSide) = right,4,2) 0 $calc(%sp_w -6) 26
    mdx MoveControl sidepane 6 $iif($rconf(Display,SPSide) = right,4,2) 6 $calc(%sp_w -12) 16
    mdx MoveControl sidepane 7 $calc(%sp_w -18) 2 8 22
    did -v sidepane 5,6
    did -ra sidepane 7 4  
  }

  mdx SetBorderStyle $dname 1,2,5 staticedge
  did -i $dname 1,2 1 iconsize normal small
  did -i $dname 1 1 seticon normal 18, $+ $icl
  did -i $dname 1 1 seticon normal 19, $+ $icl
  did -i $dname 1 1 seticon normal 0, $+ $icl
  did -i $dname 1 1 seticon normal 1, $+ $icl
  did -i $dname 2 1 seticon normal 6, $+ $shortfn($scriptdirIcons\Switchbar.icl)
  did -i $dname 2 1 seticon normal 5, $+ $shortfn($scriptdirIcons\Switchbar.icl)
  did -i $dname 1,2 1 tooltip 1 setdefault Click to select
  did -i $dname 1,2 1 setitemheight 17

  did -i sidepane 1,2 1 setcolor bkg $color($color(background))
  did -i sidepane 1,2 1 setcolor text $color($color(normal text))
  mdx SetColor sidepane 1,2 textbg $color($color(background))
  mdx SetFont sidepane 1,2 $_nfontsize 400 $_nfonttype
  did -a $dname 3 restrict top 26
  _updatenl
  _update.dcc
  $iif($dialog(sidepane),hdock -udock sidepane)
  hdock -dock $dialog(sidepane) $iif($rconf(Display,SPSide),$ifmatch,right) %sp_w
  sp_width !
}

on *:dialog:sidepane:sclick:2: {
  tokenize 32 $did($dname,2,1)
  if $4 = 2 && $5 {
    window -a "Send $remove($branch(sidepane,2),:) $+ "
  }
  elseif $4 = 3 && $5 {
    window -a "Get $remove($branch(sidepane,2),:) $+ "
  }
}

on *:dialog:sidepane:sclick:1: { 
  set %tmp $did(1,1)
  set %action $gettok(%tmp,2,32)
  if (%action = SELECT) {
    set %root $gettok(%tmp, 4-, 32)
    set %item $gettok(%tmp, -1, 32)
    did -i $dname 1 1 cb root %root up
  }
  if ($gettok(%tmp,1,32) = rclick) {
    ndock.pop
  }
}

on *:dialog:sidepane:sclick:2: {
  set %tmp $did(sidepane,2,1)
  if ($gettok(%tmp,1,32) = rclick) {
    ndock_servpop
  }
  elseif ($gettok(%tmp,1,32) = sclick && $did($dname,2).sel) {
    var %sel = $scon($calc($did($dname,2).sel -1))
    scid %sel window -a "Status Window"
  }
}

on *:dialog:sidepane:sclick:3: {
  if ($gettok($did($dname,3),3,32) < 27) {
    mdx MoveControl sidepane 3 * 26 * *
  }
  if ($gettok($did($dname,3),1,32) = move) {
    mdx MoveControl sidepane 1 $iif($rconf(Display,SPSide) = right,4,2) 32 $calc(%sp_w -6) $calc($gettok($did($dname,3),3,32) -32) 
    mdx MoveControl sidepane 2 $iif($rconf(Display,SPSide) = right,4,2) $calc($gettok($did($dname,3),4,32) +2) $calc(%sp_w -6) 9999
    set %h1 $gettok($did($dname,3),4,32)
  }
}

on *:dialog:sidepane:sclick:7: { 
  mdx SetBorderStyle sidepane 7 staticedge
  .timer -m 1 100 mdx SetBorderStyle sidepane 7
  sidepane_pop
  did -f sidepane 7
}