;##########################################################
;## Scripts Manager ##
;##########################################################
;Main dialog
dialog sm {
title "Scripts Management"
size -1 -1 454 271
option pixels
list 1, 16 24 176 112, sort size hsbar vsbar
list 2, 264 24 176 112, sort size hsbar vsbar
box "Loaded Scripts", 3, 8 8 192 133
box "Unloaded Scripts", 4, 256 8 192 133
button "<", 5, 208 24 38 24
button "<<", 6, 208 56 38 24
button ">>", 7, 208 80 38 24
button ">", 8, 208 112 38 24
button "Ok", 9, 374 244 73 23, ok cancel
box "Messages", 10, 8 188 192 41
edit "Created By Crossfire39", 11, 16 203 172 21, read
combo 17, 262 175 176 28, drop
link "Get Latest Version And Support", 18, 8 240 171 16
box "Directories", 19, 255 160 192 40
box "Sub-Directories", 20, 255 200 192 40
combo 24, 262 215 176 28, drop
button "Reload", 12, 16 147 55 21
button "Reload All", 13, 80 147 55 21
button "View", 27, 143 147 55 21
button "View", 28, 386 143 55 21
menu "File", 14
item "Add Directory", 15, 14
item "Exit", 16, 14, cancel
menu "Tools", 21
item "Script Viewer", 26, 21
menu "Help", 25
item "Instructions", 22, 25
item "Credits", 23, 25
}
;Credits dialog
dialog sm_credits {
title "Script Management Credits"
size -1 -1 165 65
option pixels
box "Credits", 1, 4 1 157 36
text "Crossfire39", 2, 14 14 137 17, center
button "Back", 3, 88 40 70 20, ok
}
dialog sm_help {
title "Instructions"
size -1 -1 311 283
option pixels
box "Instructions", 1, 6 1 299 249
button "Back", 2, 184 257 72 20, ok cancel
link "Support Forum", 6, 16 259 80 16
text " When you begin this script, any current scripts you have loaded will appear in the left hand list. From here you can unload any of them by using > to unload them one by one or >> to unload all your scripts at once.", 3, 12 17 284 56
text " When you wish to add more scripts go to File --> Add Directory and browse to the directory containing your scripts and open it. Any unloaded scripts in that directory will be shown in the right list. If you wish to navigate to any subdirectories use the lower drop down meny. To load scripts use < to load them one by one, or << to load them all at once. You cannot load mirc system files.", 4, 12 74 284 95
text " Any errors that occur will be displayed in the messages box. These messages may not be visible if loading all scripts at once. ", 5, 12 168 284 56
text " The reload buttons are there for reloading scripts without having to run intialization commands again.", 7, 12 211 284 30
}
dialog sm_view {
title "Script Preview"
size -1 -1 470 374
option pixels
button "Back", 1, 365 340 88 28, ok
box "Preview", 2, 8 1 458 289
edit "", 3, 16 17 438 266, read multi hsbar vsbar
edit "", 4, 224 305 229 21, read
box "Messages", 5, 216 290 249 41
box "Scripts", 6, 8 290 179 66
combo 7, 15 306 166 20, drop
button "View", 8, 108 331 70 22
menu "File", 9
item "View File", 10, 9
item "Exit", 11, 9, cancel
menu "Help", 12
item "Instructions", 13, 12
item "Credits", 14, 12
}
dialog sm_view_help {
title "Script Preview"
size -1 -1 291 209
option pixels
button "Back", 2, 216 184 67 21, ok
link "Support Forums", 3, 16 184 110 16
box "Instructions", 1, 4 1 282 176
text " There are two ways to access this feature. The first is by selecting a loaded or unloaded scripts and clicking the corresponding view button, or in the main screen go to Tools > Script Viewer. This small program will allow you to view the contents of a script up to 500 lines. Sometimes there may be content that does not get displayed do to program limitations. You can select other loaded scripts by using the drop down menu below, or you can go to File > View File in the Viewer and select a file. The directory will automatically get added in the main screen. ", 4, 11 16 265 155
}
;Allows there to be a link to access the dialog
menu * {
Script Management:/dialog -mr sm sm
}
;Initiated when script starts. Fills values
on 1:dialog:sm:init:0:{
/Title
/var %x = 1
while ( %x <= $script(0)) {
/did -az sm 1 $nopath($script( %x ))
/inc %x
}
}
;Load script
on 1:dialog:sm:sclick:5:{
if ( $did(sm,2).seltext == $null ) { /did -ra sm 11 Select a script to load! | /halt }
/LoadScript $did(sm,2).sel $+($iif($did(sm,24).seltext != $null,$did(sm,24).seltext $+ \,$did(sm,17).seltext),$did(sm,2).seltext)
/did -ra sm 11 Loaded Script!
}
;Loads all scripts
on 1:dialog:sm:sclick:6:{
var %x = $did(sm,2).lines
if ( %x == 0 ) { /did -ra sm 11 No scripts to load! | /halt }
while ( %x > 0 ) {
/LoadScript %x $+($iif($did(sm,24).seltext != $null,$did(sm,24).seltext $+ \,$did(sm,17).seltext),$did(sm,2,%x)))
/did -ra sm 11 $str(||,%x)
/dec %x
}
/did -ra sm 11 Loaded scripts!
}
;Unloads all scripts
on 1:dialog:sm:sclick:7:{
var %x = $did(sm,1).lines
if ( %x == 0) { /did -ra sm 11 No Scripts to unload! }
while ( %x > 0 ) {
/UnloadScript %x $did(sm,1,%x)
/did -ra sm 11 $str(||,%x)
/dec %x
}
/did -ra sm 11 Unloaded scripts!
}
;Unload Script
on 1:dialog:sm:sclick:8:{
if ( $did(sm,1).seltext == $null ) { /did -ra sm 11 Select a script to unload! | /halt }
/UnloadScript $did(sm,1).sel $did(sm,1).seltext
/did -ra sm 11 Unloaded script!
}
;Reloads one script
on 1:dialog:sm:sclick:12:{
if ( $did(sm,1).seltext == $null ) { /did -ra sm 11 Select a script to reload! | /halt }
if ( $script($did(sm,1).seltext) == $script ) { /did -ra sm 11 Cannot reload this script! | /halt }
.reload -rs $qt($script($did(sm,1).seltext))
/did -ra sm 11 Reloaded script!
}
;Reloads all scripts
on 1:dialog:sm:sclick:13:{
if ( $did(sm,1).lines == 0 ) { /did -ra sm 11 No scripts to reload! | /halt }
var %x = $did(sm,1).lines
while ( %x > 0 ) {
if ( $script($did(sm,1,%x)) != $script ) {
.reload -rs $qt($script($did(sm,1,%x)))
/did -ra sm 11 $str(|||,%x)
}
/dec %x
}
/did -ra sm 11 Reloaded scripts!
}
;Adds a new directory.
on 1:dialog:sm:menu:15:{
/var %x = $sdir($mircdir, Select a directory to load)
/UpdateUnloadList %x
if ( !$didwm(sm,17,%x)) { /did -ac sm 17 %x }
/UpdateSubDirectories %x
}
;Drop down list. Changes info in list box every time something is selected
on 1:dialog:sm:sclick:17:{
/UpdateUnloadList $did(sm,17).seltext
/UpdateSubDirectories $did(sm,17).seltext
}
;Opens the swiftirc forums
on 1:dialog:sm_help:sclick:6:{ run http://forum.swiftirc.net/viewtopic.php?p=61133 }
;Opens the swiftirc forums
on 1:dialog:sm:sclick:18:{ run http://forum.swiftirc.net/viewtopic.php?p=61133 }
;Occurs when you select a subdirectory
on 1:dialog:sm:sclick:24:{ /UpdateUnloadList $did(sm,24).seltext }
;Opens the help menu
on 1:dialog:sm:menu:22:{ /dialog -m sm_help sm_help }
;Opens Credits (Please keep intact)
on 1:dialog:sm:menu:23:{ /dialog -mr sm_credits sm_credits }
;Opens Viewer From Menu
on 1:dialog:sm:menu:26:{ /dialog -m sm_view sm_view }
on 1:dialog:sm_view:init:0:{
/var %x = 1
while ( %x <= $script(0) ) {
/did -ac sm_view 7 $nopath($script(%x))
/inc %x
}
}
;Opens up a loaded script in the viewer
on 1:dialog:sm:sclick:27:{
/var %path = $did(sm,1).seltext
if ( %path == $null ) { /did -ar sm 11 No script selected | /halt }
/dialog -m sm_view sm_view
/LoadPreview $script(%path)
/did -c sm_view 7 $didwm(sm_view,7,%path)
}
;Opens up a script in the viewer
on 1:dialog:sm:sclick:28:{
/var %path = $did(sm,2).seltext
if ( %path == $null ) { /did -ar sm 11 No script selected | /halt }
/dialog -m sm_view sm_view
/LoadPreview $+($iif($did(sm,24).seltext != $null,$did(sm,24).seltext $+ \,$did(sm,17).seltext),%path)
/did -c sm_view 7 $didwm(sm_view,7,%path)
}
;View a new script in viewer
on 1:dialog:sm_view:sclick:8:{
if ( $did(sm_view,7).seltext == $dialog(sm_view).title ) { /did -ra sm_view 4 Already viewing script! | /halt }
/LoadPreview $script($did(sm_view,7).seltext)
}
on 1:dialog:sm_view:menu:10:{
/var %file = $sfile(*.ini;*.mrc,Select a file to view)
/LoadPreview %file
/did -a sm 17 $nofile(%file)
}
;Opens Credits (Please keep intact)
on 1:dialog:sm_view:menu:14:{ /dialog -mr sm_credits sm_credits }
;Viewer instructions
on 1:dialog:sm_view:menu:13:{ /dialog -mr sm_view_help sm_view_help }
;Opens the swiftirc forums
on 1:dialog:sm_view_help:sclick:3:{ run http://forum.swiftirc.net/viewtopic.php?p=61133 }
;##########################################################
;## Alias ##
;##########################################################
;Alias that updates list of subdirectories
alias -l UpdateSubDirectories {
/did -r sm 24
/var %y = $finddir($1-,*,0)
%y = $iif(%y > 10,10,%y)
while ( %y > 0 ) {
/did -a sm 24 $finddir($1-,*,%y)
/dec %y
}
}
;Alias that updates unloaded scripts list
alias -l UpdateUnloadList {
/did -r sm 2
/var %y = 1
while ( %y <= $findfile($1-,*.ini;*.mrc,0,0)) {
;Shows the scripts only if they are not already running
if ( !$script( $findfile($1-,*.ini;*.mrc,%y,0)) ) {
/did -a sm 2 $nopath($findfile($1-,*.ini;*.mrc,%y,0))
}
/inc %y
}
}
;Alias used to load scripts
alias -l LoadScript {
if ( $mircdir == $did(sm,17).seltext || $mircdir == $did(sm,24).seltext) {
if ( ($nopath($2-) == aliases.ini) || ($nopath($2-) == mirc.ini) || ($nopath($2-) == popups.ini) || ($nopath($2-) == perform.ini) || ($nopath($2-) == remote.ini) || ($nopath($2-) == servers.ini) ) { /did -ar sm 11 Mirc file, unable to load | /halt }
}
/did -az sm 1 $nopath($2-)
.load -rs $qt($2-)
/did -d sm 2 $1
/Title
}
;Alias used to unload scripts
alias -l UnloadScript {
if ( $2- != $nopath($script)) {
if ( ($nofile($script($2-)) == $did(sm,17).seltext) || ($nofile($script($2-)) == $+($did(sm,24).seltext,\) )) { /did -a sm 2 $2- }
.unload -rs $qt($2-)
/did -d sm 1 $1
/Title
}
else { /did -ar sm 11 Cannot remove this script! }
}
;Alias to keep track of scripts loaded
alias -l Title {
/dialog -t sm Script Managment - $script(0) Loaded Scripts
}
alias -l LoadPreview {
/did -r sm_view 3
var %y = 1
var %x = $lines($1-)
if (%x >= 500 ) { /did -ra sm_view 4 Full script cannot be displayed }
%x = $iif(%x > 500,500,%x)
while ( %y <= %x) { /did -i sm_view 3 %y $read($1-, nt, %y) | /inc %y }
/did -ar sm_view 4 Script loaded successfully.
/dialog -t sm_view $nopath($1-)
}