alias SoundSystemSet { if (!$dialog(SoundSystemSet)) { dialog -m SoundSystemSet SoundSystemSet } | else halt }
dialog SoundSystemSet {
  title "=[ Sound System Setup ]="
  size -1 -1 250 255
  box "Configurazione Sound System:" 2,5 3 240 210
  button "Chiudi" 3, 105 220 80 20, cancel
  button "Procedi >>" 4, 20 220 80 20
  text "- Bisogna impostare la directory contenente gli mp3, affinché il player mp3 funzioni." 5, 20 25 190 40
  text "- Le funzioni del Sound System saranno disabilitate finché non si configura il campo sottostante." 6, 20 72 190 40
  text "Directory Mp3:" 7, 20 122 72 15
  edit "" 8, 95 118 100 20,autohs,multi
  button "Sfoglia!" 9, 198 118 42 20
  text "- Al termine della configurazione premere il bottone ''Procedi'' per poter usare le funzioni del Sound System." 13, 20 162 190 40
}
on *:dialog:SoundSystemSet:sclick:*:{
  if ($did = 3) { sclose }
  if ($did = 4) { sopen
    if (!%mp3dir) { errore La Directory Mp3 non è stata settata. | halt } 
    dialog -x SoundSystemSet | SoundSystem
  }
  if ($did = 9) { sopen | SetMp3Dir }
}
on *:dialog:SoundSystemSet:edit:8:{ set %mp3dir $did(SoundSystemSet,8).text }
on *:dialog:SoundSystemSet:init:0:{ if (%mp3dir) { did -a SoundSystemSet 8 %mp3dir } }
alias SetMp3Dir { set %mp3dir $$sdir="Seleziona la cartella dei tuoi mp3" | did -r SoundSystemSet 8 | did -a SoundSystemSet 8 %mp3dir }

alias SoundSystem {
  if (!%mp3dir) { SoundSystemSet | halt }
  if ($dialog(SoundSystemQ)) { halt }
  if (!$dialog(SoundSystem)) { dialog -m SoundSystem SoundSystem }
  if ($dialog(SoundSystem)) { halt }
}
dialog SoundSystem {
  title "Dreamer§ §cript =[ Lettore Mp3 ]="
  size -1 -1 199 147
  option dbu
  box "PlayList (Doppio Click sul file per eseguirlo):", 2, 7 1 190 50
  combo 3, 10 10 184 40
  box "Top Mp3 List:", 4, 7 52 45 60
  button "1", 5, 12 61 10 10
  button "2", 6, 24 61 10 10
  button "3", 7, 37 61 10 10
  button "4", 8, 12 74 10 10
  button "5", 9, 24 74 10 10
  button "6", 10, 37 74 10 10
  button "7", 11, 12 86 10 10
  button "8", 12, 24 86 10 10
  button "9", 13, 37 86 10 10
  button "Configura!", 14, 12 99 34 10
  box "Status:", 15, 55 52 142 60
  edit "", 16, 57 60 137 50, read multi autovs vsbar
  radio "Attiva Comunicatore Mp3", 17, 60 122 76 7
  radio "Disattiva Comunicatore Mp3", 18, 60 132 76 7
  box "Other:", 19, 57 113 82 31
  button "Setta dir mp3", 20, 142 115 54 10
  button "Genera Lista", 21, 142 125 54 10
  button "Chiudi Menu", 22, 142 135 54 10, cancel
  button "Ascolta un File...", 23, 1 115 54 10
  button "Conta i Files...", 24, 1 125 54 10
  button "SS Quick Menu", 25, 1 135 54 10
}
on *:dialog:SoundSystem:init:0:{
  qplaylistmp3.init
  if (%comunicaMp3 = ON) { did -c SoundSystem 17 }
  if (%ComunicaMp3 = OFF) { did -c SoundSystem 18 }
  did -a SoundSystem 16 Benvenuto in Sound System! $+ $crlf
  did -a SoundSystem 16 $crlf
  did -a SoundSystem 16 Directory Mp3: %mp3dir $+ $crlf
  did -a SoundSystem 16 $crlf
}

alias PlayBrano {
  if ($1-) { sopen | run -n $1-
    if ($dialog(SoundSystem)) {
      did -a SoundSystem 16 $crlf
      did -a SoundSystem 16 Stai ascoltando: $nopath($1-) $+ $crlf
      did -a SoundSystem 16 Dimensioni: $bytes($file($1-).size,m) Mb $+ $crlf
    }
    if (%ComunicaMp3 = ON) && ($server) && ($chan(0) > 0) { ame 9A10s9C8¤9L10T9a 8º9,2·®©®·8º4 $remove($nopath($1-),.mp3) 8º9,2·®©®·8º }
  }
  if (!$1-) && ($dialog(SoundSystem)) { sopen | did -a SoundSystem 16 $crlf | did -a SoundSystem 16 Nessun Brano è associato! $+ $crlf }
}

on *:dialog:SoundSystem:sclick:*:{
  if ($did = 5) { PlayBrano %Brano1 }
  if ($did = 6) { PlayBrano %Brano2 }
  if ($did = 7) { PlayBrano %Brano3 }
  if ($did = 8) { PlayBrano %Brano4 }
  if ($did = 9) { PlayBrano %Brano5 }
  if ($did = 10) { PlayBrano %Brano6 }
  if ($did = 11) { PlayBrano %Brano7 }
  if ($did = 12) { PlayBrano %Brano8 }
  if ($did = 13) { PlayBrano %Brano9 }
  if ($did = 14) { sopen | conftop } 
  if ($did = 17) { set %comunicamp3 ON | son } 
  if ($did = 18) { set %comunicamp3 OFF | soff }
  if ($did = 20) { sopen | dialog -x SoundSystem | SoundSystemSet } 
  if ($did = 21) { sopen | mp3list } 
  if ($did = 22) { sclose } 
  if ($did = 23) { mp3play }
  if ($did = 24) { sopen | mp3count }
  if ($did = 25) { sopen | dialog -x SoundSystem | SoundSystemQ }
}
on *:dialog:SoundSystem:dclick:*:{ if ($did = 3) { PlayBrano %mp3dir $+ $did(3,$did(3).sel) } }

alias qplaylistmp3.init {
  set %filenum 1
  set %findfile $findfile(%mp3dir,*.mp3,%filenum,1)
  if (!%findfile) { goto done }
  else {
    did -o SoundSystem 3 %filenum $nopath(%findfile)
    goto findfile
    :findfile
    inc %filenum
    set %findfile $findfile(%mp3dir,*.mp3,%filenum,1)
    if (!%findfile) { goto done }
    else {
      did -o SoundSystem 3 %filenum $nopath(%findfile)
      goto findfile
      :done
      unset %filenum %findfile
    }
  }
}

alias SoundSystemQ { if (!$dialog(SoundSystemQ)) { dialog -m SoundSystemQ SoundSystemQ } | else halt }
dialog SoundSystemQ {
  title "Dreamer§ §cript =[ Menu Lettore Mp3 Quick ]="
  size 270 9 207 12
  option dbu
  button "1", 1, 1 1 10 10
  button "2", 2, 13 1 10 10
  button "3", 3, 24 1 10 10
  button "4", 4, 36 1 10 10
  button "5", 5, 47 1 10 10
  button "6", 6, 59 1 10 10
  button "7", 7, 70 1 10 10
  button "8", 8, 81 1 10 10
  button "9", 9, 93 1 10 10
  button "Ascolta un File...", 10, 104 1 50 10
  button "SS Normal Menu", 11, 156 1 50 10
  button "Chiudi", 12, 250 250 40 10, cancel
}

on *:dialog:SoundSystemQ:sclick:*:{
  if ($did = 1) { PlayBrano %Brano1 }
  if ($did = 2) { PlayBrano %Brano2 }
  if ($did = 3) { PlayBrano %Brano3 }
  if ($did = 4) { PlayBrano %Brano4 }
  if ($did = 5) { PlayBrano %Brano5 }
  if ($did = 6) { PlayBrano %Brano6 }
  if ($did = 7) { PlayBrano %Brano7 }
  if ($did = 8) { PlayBrano %Brano8 }
  if ($did = 9) { PlayBrano %Brano9 }
  if ($did = 10) { Mp3Play }
  if ($did = 11) { sopen | dialog -x SoundSystemQ | SoundSystem }
}

alias ConfTop { if (!$dialog(ConfTop)) { dialog -m ConfTop ConfTop } }
dialog ConfTop {
  title "Top Mp3 List Setup"
  size -1 -1 167 139
  option dbu
  text "Brano 1:", 1, 5 10 22 7
  text "Brano 2:", 2, 5 22 22 7
  text "Brano 3:", 3, 5 35 22 7
  text "Brano 4:", 4, 5 47 22 7
  text "Brano 5:", 5, 5 60 22 7
  text "Brano 6:", 6, 5 72 22 7
  text "Brano 7:", 7, 5 85 22 7
  text "Brano 8:", 8, 5 97 22 7
  text "Brano 9:", 9, 5 110 22 7
  edit "", 10, 27 7 87 11, read multi autohs
  edit "", 11, 27 20 87 11, read multi autohs
  edit "", 12, 27 32 87 11, read multi autohs
  edit "", 13, 27 45 87 11, read multi autohs
  edit "", 14, 27 57 87 11, read multi autohs
  edit "", 15, 27 70 87 11, read multi autohs
  edit "", 16, 27 82 87 11, read multi autohs
  edit "", 17, 27 95 87 11, read multi autohs
  edit "", 18, 27 107 87 11, read multi autohs
  button "Cerca", 19, 117 7 22 10
  button "Cerca", 20, 117 20 22 10
  button "Cerca", 21, 117 32 22 10
  button "Cerca", 22, 117 45 22 10
  button "Cerca", 23, 117 57 22 10
  button "Cerca", 24, 117 70 22 10
  button "Cerca", 25, 117 82 22 10
  button "Cerca", 26, 117 95 22 10
  button "Cerca", 27, 117 107 22 10
  button "Chiudi Menu", 28, 57 122 55 12, cancel
  button "Delete!", 29, 141 7 22 10
  button "Delete!", 30, 141 20 22 10
  button "Delete!", 31, 141 32 22 10
  button "Delete!", 32, 141 45 22 10
  button "Delete!", 33, 141 57 22 10
  button "Delete!", 34, 141 70 22 10
  button "Delete!", 35, 141 82 22 10
  button "Delete!", 36, 141 95 22 10
  button "Delete!", 37, 141 107 22 10
}
on *:dialog:ConfTop:sclick:*:{
  if ($did = 19) { sopen | SetBrano 1 }
  if ($did = 20) { sopen | SetBrano 2 }
  if ($did = 21) { sopen | SetBrano 3 }
  if ($did = 22) { sopen | SetBrano 4 }
  if ($did = 23) { sopen | SetBrano 5 }
  if ($did = 24) { sopen | SetBrano 6 }
  if ($did = 25) { sopen | SetBrano 7 }
  if ($did = 26) { sopen | SetBrano 8 }
  if ($did = 27) { sopen | SetBrano 9 }
  if ($did = 28) { sclose }
  if ($did = 29) { sopen | unset %Brano1 | did -r conftop 10 }
  if ($did = 30) { sopen | unset %Brano2 | did -r conftop 11 }
  if ($did = 31) { sopen | unset %Brano3 | did -r conftop 12 }
  if ($did = 32) { sopen | unset %Brano4 | did -r conftop 13 }
  if ($did = 33) { sopen | unset %Brano5 | did -r conftop 14 }
  if ($did = 34) { sopen | unset %Brano6 | did -r conftop 15 }
  if ($did = 35) { sopen | unset %Brano7 | did -r conftop 16 }
  if ($did = 36) { sopen | unset %Brano8 | did -r conftop 17 }
  if ($did = 37) { sopen | unset %Brano9 | did -r conftop 18 }
}
on *:dialog:ConfTop:init:0:{
  did -a conftop 10 $nopath(%Brano1)
  did -a conftop 11 $nopath(%Brano2)
  did -a conftop 12 $nopath(%Brano3)
  did -a conftop 13 $nopath(%Brano4)
  did -a conftop 14 $nopath(%Brano5)
  did -a conftop 15 $nopath(%Brano6)
  did -a conftop 16 $nopath(%Brano7)
  did -a conftop 17 $nopath(%Brano8)
  did -a conftop 18 $nopath(%Brano9)
}
alias SetBrano { if ($1 isnum 1-9) { set %Brano $+ $1 $$dir="Seleziona il $1 $+ ° Brano:" [ %mp3dir $+ *.m?? ] | dialog -x ConfTop | ConfTop } }
