;----------------------------------------------------------------------------------------------------
;
;                      © ArcticFire Platinum Addons ©        
;        All Rights Reserved, All copyright acknowledged.
;                                                 
;           If you would like to use this addons in your 
;                script, all I ask for is FULL credit. 
;
;        With all of that out of the way, enjoy the addon!
;
;----------------------------------------------------------------------------------------------------


on *:UNLOAD: {
  if ($version <= 6.0) {
    halt 
  }
  else {
    echo -a 6Narkoman's Video Player 7удалён6.
    echo -a 6Спасибо за пользование этим плеером!
    echo -a 6By _TRANE_  Copyright 2007.
  }
}

alias mplay {
  if (!$isfile(%gpnt)) { set %gpnt $findfile($scriptdir,nhtml*.dll,1) | if (!%gpnt) { echo -a 6Error: nHTMLn.dll was not found. Please Re-Install Arctic Fire or download nHTMLn.dll and put it into the System folder for this to work. | halt } }
  if (%gpdir == $null) { setmplaydir }
  if ($left($1,1) == -) { var %s = $right($1,-1) | tokenize 32 $2- }
  if (!%s) || (%s == d) { dialog -md mplay mplay }
  if (%s == l) {
    if (!%gpdir) %gpdir = $mircdir | if ($right(%gpdir,1) == \) %gpdir = $left(%gpdir,-1) | did -r mplay 1 | did -a mplay 1 .. | .echo -q $finddir(%gpdir,*,0,1,did -a mplay 1 $iif(!%gpsp,$nopath($1-),$1-)) | did -a mplay 1 $str(-,20)
    var %i 1 | while ($gettok(asf;avi;mov;mpg;mpeg,%i,59)) { .echo -q $findfile(%gpdir,$+(*.,$ifmatch),0,1,did -a mplay 1 $iif(!%gpsp,$nopath($1-),$1-)) | inc %i } | did -o mplay 3 1 %gpdir | did -z mplay 1
  }
  if (%s == v) { 
    var %f " $+ $scriptdir $+ mplay.html $+ " |  write -c %f | write %f <EMBED WIDTH="100%" HEIGHT="100%" SRC= $+ $1- $+ > 
    if (!%gpsd) { var %w @mPlay | window -ak0p %w 0 0 402 353 | var %h = $window(%w).hwnd } 
    if (%gpsd) { dialog -s mplay $dialog(mplay).x $dialog(mplay).y 728 326 | dialog -t mplay Double Click for Full Screen Mode | var %h = $dll(%gpnt,find,mplayer!) }
    .echo -q $dll(%gpnt,attach,%h) | .echo -q $dll(%gpnt,navigate,$scriptdirmplay.html)
  }
}
dialog mplay {
  title "Narkoman's Video Player"
  size -1 -1 155 163
  option dbu
  icon C:\Program Files\Windows Media Player\mplayer2.exe
  list 1, 4 18 146 110,vsbar,hsbar
  edit "", 3, 4 4 104 11,autohs read
  check " Показывать путь к папке", 4, 8 130 80 10
  check " Watch Movie in Dialog", 5, 500 430 80 10
  box "mplayer!", 6, 155 4 210 155
  button "Выбрать папку", 7, 111 4 42 11
  box "", 8, 4 126 119 15
  button "Громкость", 9, 126 129 30 11
  button "Авторы", 10, 63 149 30 11
  button "Закрыть", 11, 103 149 30 11, ok
  button "Рестарт", 12, 22 149 30 11
  box "", 13, 62 145 32 16
  text "----------------------------------------------------------------------------------------------", 14, 7 141 142 4
}

on *:dialog:mplay:init:0:mplay -l | if (%gpsp) did -c mplay 4 | if (%gpsd) did -c mplay 5
on *:dialog:mplay:sclick:*:{
  if ($did == 4) { set %gpsp $did(4).state | mplay -l }
  if ($did == 5) { if ($did(5).state) set %gpsd 1 | else { unset %gpsd | dialog -s mplay -1 -1 310 326 } }
  if ($did == 7) { setmplaydir | mplay -l | halt }
  if ($did == 9) { volume }
  if ($did == 10) { afabout }
  if ($did == 12) { dialog -x mplay | mplay }
}

on *:dialog:mplay:dclick:1:{
  var %t $$did(1).seltext | if (%t == ..) { set %gpdir $deltok(%gpdir,-1,92) | mplay -l | halt } | if ($isdir($iif(%gpsp,%t,$+(%gpdir,\,%t)))) { set %gpdir $iif(%gpsp,%t,$+(%gpdir,\,%t)) | mplay -l } 
  if ($isfile($iif(%gpsp,%t,$+(%gpdir,\,%t)))) mplay -v $+(",$iif(%gpsp,%t,$+(%gpdir,\,%t)),")
}

alias setmplaydir { set %gpdir $sdir="Укажите путь к папке с видео файлами" C: }


alias volume {
  if ($dialog(volcontrol) == $null) dialog -mdo volcontrol volcontrol
  else dialog -vo volcontrol
}

dialog volcontrol {
  title "            Громкость"
  size -1 -1 122 100
  option dbu

  box " Громкость ", 1, 2 2 28 96
  scroll "", 2, 10 12 10 66, range 65535 
  text "65535", 3, 8 80 15 8, center
  check "Выкл", 4, 4 88 23 8

  box " Звук ", 11, 32 2 28 96
  scroll "", 12, 40 12 10 66, range 65535 
  text "65535", 13, 38 80 15 8, center
  check "Выкл", 14, 34 88 23 8

  box " Миди ", 21, 62 2 28 96
  scroll "", 22, 70 12 10 66, range 65535 
  text "65536", 23, 68 80 15 8, center
  check "Выкл", 24, 64 88 23 8

  box " MP3", 31, 92 2 28 96
  scroll "", 32, 100 12 10 66, range 65535 
  text "65535", 33, 98 80 15 8, center
  check "Выкл", 34, 94 88 23 8

  button "Выход", 99, 44 104 36 14, Cancel
}

on *:dialog:volcontrol:init:0:{
  did -h volcontrol 99
  var %i = 0
  while ( %i < 4) {
    did -c volcontrol $calc(10 * %i + 2) $calc(65536 - $vol($vc.name(%i)))
    did -ra volcontrol $calc(10 * %i + 3) $vol($vc.name(%i))
    if ($vol($vc.name(%i)).mute) did -c volcontrol $calc(10 * %i + 4)
    inc %i
  }
}

on *:dialog:volcontrol:scroll:*:{
  did -ra volcontrol $calc($did + 1 ) $calc(65535 - $did($did).sel)
  vol - $+ $vc.abbr($int($calc($did / 10))) $calc(65535 - $did($did).sel)
  var %i = 0
  while ( %i < 4) {
    did -c volcontrol $calc(10 * %i + 2) $calc(65536 - $vol($vc.name(%i)))
    did -ra volcontrol $calc(10 * %i + 3) $vol($vc.name(%i))
    if ($vol($vc.name(%i)).mute) did -c volcontrol $calc(10 * %i + 4)
    else did -u volcontrol $calc(10 * %i + 4)
    inc %i
  }
}

on *:dialog:volcontrol:sclick:*:{
  if ($right($did,1) == 4) {
    if ($did($did).state == 1)   vol - $+ $vc.abbr($int($calc($did / 10))) $+ u1
    else vol - $+ $vc.abbr($int($calc($did / 10))) $+ u2
    var %i = 0
    while ( %i < 4) {
      did -c volcontrol $calc(10 * %i + 2) $calc(65536 - $vol($vc.name(%i)))
      did -ra volcontrol $calc(10 * %i + 3) $vol($vc.name(%i))
      if ($vol($vc.name(%i)).mute) did -c volcontrol $calc(10 * %i + 4)
      else did -u volcontrol $calc(10 * %i + 4)
      inc %i
    }
  }
}
alias -l vc.name {
  return $gettok(Master Wave MIDI MP3, $calc($$1 + 1 ),32)
}
alias -l vc.abbr {
  return $gettok(v w m p, $calc($$1 + 1 ),32)
}

alias afabout { dialog -m afabout afabout }
dialog afabout {
  title "Narkoman's Video Player"
  size -1 -1 100 115
  option dbu

  button "OK",2, 150 150 20 20, ok
  link "www.first-net.narod.ru", 3, 20 95 60 13, center
  text "N",4, 3 1 5 7, center
  text "A",5, 13 1 5 7, center
  text "R",6, 23 1 5 7, center 
  text "K",7, 33 1 5 7, center
  text "O",8, 43 1 5 7, center
  text "O",9, 53 1 5 7, center
  text "S",10, 63 1 5 7, center
  text "C",11, 73 1 5 7, center
  text "R",12, 83 1 5 7, center
  text "I",13, 93 1 5 7, center
  text "P",14, 3 107 5 7, center
  text "T",15, 13 107 5 7, center
  text "B",16, 23 107 5 7, center 
  text "Y",17, 33 107 5 7, center
  text "_",18, 43 107 5 7, center
  text "T",19, 53 107 5 7, center
  text "R",20, 63 107 5 7, center
  text "A",21, 73 107 5 7, center
  text "N",22, 83 107 5 7, center
  text "E",23, 93 107 5 7, center
  box "",24, 3 6 94 100
  box "",25, 19 10 61 40
  text "TRIKS 2007",46, 31 21 39 8
  text "All Rights Reserved",47, 26 33 50 8
  text "©",48, 22 14 5 6
  text "©",49, 73 14 5 6
  text "©",50, 22 41 5 6
  text "©",51, 73 41 5 6
  text "----------------------",52, 27 27 45 4
  text "This Has Been A Product",53, 19 53 64 8
  text "of The One And Only",54, 23 60 57 8
  text " ArcticFire Platinum",55, 25 67 46 8
  link "Credits",56, 40 74 45 10
  text "For More Great Addons,",57, 21 81 60 8
  text "Сайт Narkoman's Script:",58, 21 88 60 8
}
on *:dialog:afabout:*:*:{
  if ($devent == init) {
    did -b afabout 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23
    ppblink
  }
  if ($devent == sclick) {
    if ($did == 3) { run http://first-net.narod.ru/narkoo.mht }
    if ($did == 56) { dialog -mo afmplaycredits afmplaycredits }
  }
}
alias ppblinkvar {
  if ($dialog(afabout) == $null) { return }
  .did -e afabout $1
  .timerppblinkrem $+ $1 1 1 ppblinkrem $1
}
alias ppblinkrem {
  if ($dialog(afabout) == $null) { return }
  .did -b afabout $1
}
alias ppblink {
  if ($dialog(afabout) == $null) { return }
  .timerppblink1 1 1 /ppblinkvar 4,14
  .timerppblink2 1 2 /ppblinkvar 5,15
  .timerppblink3 1 3 /ppblinkvar 6,16
  .timerppblink4 1 4 /ppblinkvar 7,17
  .timerppblink5 1 5 /ppblinkvar 8,18
  .timerppblink6 1 6 /ppblinkvar 9,19
  .timerppblink7 1 7 /ppblinkvar 10,20
  .timerppblink8 1 8 /ppblinkvar 11,21
  .timerppblink9 1 9 /ppblinkvar 12,22
  .timerppblink10 1 10 /ppblinkvar 13,23
  .timerppblink12 1 12 /ppblinkvar 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23
  .timerppblink14 1 14 /ppblink
}

dialog afmplaycredits {
  title " -= Credits =-"
  size -1 -1 68 145
  option dbu

  button "Close",1, 20 130 26 12, ok
  text "The Following Sources Must Be Given Credit For Their Part In This Addon:",2, 4 2 62 20, center
  text "-------------------------------",3, 3 21 62 4
  link "Prometheus",4, 19 28 30 8
  text "For the coding. The original creator of this dialog. It was outdated and wasn't compatible with todays movie standards, so I rebuilt it.",5, 3 35 62 39, center
  link "Dan",6, 27 78 30 8
  text "Unofficial nHTMLn.dll file.",7, 3 85 62 7, center
  link "mircscripts.org",8, 16 96 36 8
  text "The helpful people in the web board who helped me out with any problems.",9, 3 103 63 27, center
  text "-------------------------------",10, 3 123 62 4
}

on *:dialog:afmplaycredits:sclick:*:{
  if ($did == 6) { run http://first-net.narod.ru/narkoo.mht }
  if ($did == 8) { run http://www.mircscripts.org }
}

menu menubar {
  Видео Плеер:mplay
}
