before i started using Mediamonkey last week, i have organised my files with the mp3db from Kroll-Software (http://www.kroll-software.de/produkte/mp3db.asp).
This a very nice piece of Freeware and has a very good grouping function, which is done with drag and drop of the Tag-Fields. I have now tried to transfer this possibilty to Mediamonkey and this "FastNode-GUI" script is the result. As i am not as firm in programming as the guys from Kroll Software, i have just realised Dropdowns instead of DragnDrop .
Everything else is explained in the Script-Comments, three main points:
- You need Magic Nodes
- You have to set the options:
- And start using it
I am waiting for your comments!
AND: This thing would never be possible without the fantastic Magic Nodes-Script!!! Respect!!!!
Here is the code:
Code: Select all
'##################################################
'####### FastNode GUI for Magic Nodes #######
'####### by Begges 2006 #######
'####### search the Forum for my #######
'####### other scripts: #######
'####### - Simple Lyrics Panel #######
'####### - Eviltagger #######
'####### - VUPlayer #######
'##################################################
'
'
'This Script will give you a simple GUI for the Magic Nodes:
'look there:
'http://students.washington.edu/~shmerkin/magic_nodes/index.htm
'If you don't know MagicNodes by now, you have missed the best script for MM around
'
'This GUI is
'inspired by the Grouping function of this nice piece of freeware:
' mp3db by Kroll-Software (http://www.kroll-software.de/produkte/mp3db.asp)
'- very fast
'- very intuitiv
'- and very flexible grouping
'- but not as customizable as MM
'- and no Ipod-Support, thats why i have to switch to Mediamonkey
'
'
'##################################################
'####### How it works #######
'##################################################
' 1)Download the MagicNodes Script and add some Code to it (i have used V1.3b):
' As we need to call the MagicNode Functions "CreateNode" and "DeleteNode"
' we have to make them "callable", that means, not to work with their normal objects
' but with a String send form this GUI script.
' So i have added these two new functions on the bottom of the Magic Nodes Script
' and renamed MagicNodes.1.3b.vbs to MagicNodes.1.3b_GUI.vbs:
'#####################################
' Rename adopted MagicNodes.1.3b.vbs to MagicNodes.1.3b_GUI.vbs !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'#####################################
' ________________________________________________________________________________
' Sub CreateNodeExternalCall(usermask)
'
' Dim iniMask, i, wellFormedMask, singleLineMask
'
' If usermask = "" Then Exit Sub
'
' wellFormedMask = CheckMask(usermask)
' singleLineMask = Cond(InStr(usermask, vbCr) = 0, True, False)
'
' If wellFormedMask And singleLineMask Then
' For i = 1 To MasksInIniFile
' iniMask = getIniMask(i)
' If iniMask = "" Then
' SetIniMask i, usermask
' SetIniMask 0, usermask ' mask0 is used as a default/temporary mask
' ResetEditDeleteMenus
' Dim pn: pn = getQualifierValue(usermask, "child of", "MAGIC", True)
' If pn = "MAGIC" Then
' ResetCustomNodeRoot
' Else
' CreateCustomNode Eval("SDB.MainTree.Node_" & pn), 1, usermask, i
' End If
' expandCustomNode (i)
' Exit Sub
' End If
' Next
' Else
' SetIniMask 0, Cond(wellFormedMask, Left(usermask, InStr(usermask, vbCr)), usermask)
' SDB.MessageBox Cond(wellFormedMask, _
' "The mask you entered spans several lines. Masks must fit in one line in order to be valid.", _
' "The mask you entered is not valid. Please check GUI Options."), mtError, Array(mbOK)
' Exit Sub
' End If
'
' SDB.MessageBox "You have exceeded the allowed limit of Magic Nodes. You can increase this limit by modifying the constant" & _
' " masksInIniFile in the script source and restarting MediaMonkey.", mtError, Array(mbOK)
'
' End Sub
'
' _______________________________________________________________________________________
' Sub DeleteNodeExternalCall(NodeString)
' Dim i
' For i = 1 To MasksInIniFile
' If getIniMask(i) = NodeString Then
' SetIniMask i, ""
' SDB.objects("submnu_edit" & i).Visible = False
' SDB.objects("submnu_delete" & i).Visible = False
' If getQualifierValue(NodeString, "child of", "MAGIC", True) <> "MAGIC" Then
' ShowRestartMsg
' Else
' ResetCustomNodeRoot
' End If
' Exit Sub
' End If
' Next
' End Sub
' ___________________________________________________________________________________________
' 2) Put both scripts into the Auto-Folder (but MagicNodes only once!!! and with the name
' the sript references to later)
' 3) Start Mediamonkey and set the GUI Options in the Optionspanel, after this you have to restart
' 4) The Options Panel:
' - there are 10 customizable fields with "Active", "Name" and "Code"
' - and the Name field
' - and the numbers of DropDown-Controls used
' NodeName:
' - You can set the name for your FastNode here, e.g. "My SuperDatabase", etc.
' Number of DropDowns:
' - In the FastNodePanel there are DropDownFields, where you can select the Node Code
' for this position.
' - The number of Dropdowns-Elemenst is specified here
' Active:
' Check the box, if you want this specific CodePart to be shown in the DropDown-Elements
' Name:
' with this name will the specific codepart be shown in the DropDown-Elements
' Code:
' Here you set the Code part, which is later send to MagicNodes
' Please read the Magic Nodes Manual for further details
' The different codeparts will later be seperated with "\" and send to MagicNodes
' also you can enter more nodes in one Codefield:
' - <artist|trim:1>\<artist>
' 5) Select Elements in FastNode-Panel:
' - you can access the FastNode-Panel in the View-Menu if hidden
' - then set your filters with the DropDown-Elements
' - and hit ok, Magic Nodes will create the new Fastnode then
' - if the old FastNode is not deleted you can delete it manually in the MagicNodes-Menu
' (but i hope this will never happen, due to my perfect coding ;-))
' - if you select a Codeitem twice (e.g. in the first and the third DropDown) the second time it will
' be ignored (because this makes no sense, or?)
' - if you left it blank, it also will be ignored
' 6) Try it and love it/or not:
' This sounds a bit complexing now, but if you are familiar with MagicNodes this will be
' very easy. Just test it some minutes, and you will know how it works! I Love it!!
'##### HERE WE GO
Option Explicit
Dim GUIForm
Dim GUIMnu
Dim GUIOptions
Dim NodeLabel
Dim BtnOk
Dim FastNodeName
Dim DDsUsed
Dim Tags(9, 2)
Sub onStartUp()
GUIOptions = SDB.UI.AddOptionSheet("FastNode_GUI", Script.ScriptPath, "InitGUIOptions", "SaveGUIOptions", -1)
GetOptions
CreatePanel
CreateMenu
Script.RegisterEvent SDB, "OnShutdown", "SDBShutdown"
End Sub
Sub GetOptions()
Dim i
'Check if there were Strings in the Ini
If SDB.IniFile.StringValue("FastNode_GUI", "NodeName") = "" Then
SDB.MessageBox "Its the first time you use the FastNodeGUI. Set the options and restart, please", mtInformation, Array(mbOK)
FastNodeName = "FastNode"
DDsUsed = 3
Else
'Read the nodestrings from the ini to the Tag Array
For i = 1 To 10
Tags(i - 1, 0) = SDB.IniFile.StringValue("FastNode_GUI", "Code" & i & "_Active")
Tags(i - 1, 1) = SDB.IniFile.StringValue("FastNode_GUI", "Code" & i & "_Name")
Tags(i - 1, 2) = SDB.IniFile.StringValue("FastNode_GUI", "Code" & i & "_Code")
Next
FastNodeName = SDB.IniFile.StringValue("FastNode_GUI", "NodeName")
DDsUsed = SDB.IniFile.StringValue("FastNode_GUI", "DDsUsed")
End If
End Sub
Sub CreatePanel()
'Create the dockable panel
Dim i, j
Dim DD
Set GUIForm = SDB.objects(FastNodeName)
If GUIForm Is Nothing Then
'### Dockable Panel
Set GUIForm = SDB.UI.NewDockablePersistentPanel(FastNodeName)
'Get the last status from the ini-File
If SDB.IniFile.StringValue("FastNode_GUI", "DockedTo") <> "" Then
GUIForm.DockedTo = SDB.IniFile.StringValue("FastNode_GUI", "DockedTo")
Else
GUIForm.DockedTo = 1
End If
If SDB.IniFile.StringValue("FastNode_GUI", "Show") <> "" Then
GUIForm.Common.Visible = SDB.IniFile.StringValue("FastNode_GUI", "Show")
Else
GUIForm.Common.Visible = True
End If
GUIForm.caption = FastNodeName
GUIForm.Common.Height = 45
GUIForm.Common.Width = 250
'### OK Button
Dim BtnOk
Set BtnOk = SDB.UI.NewButton(GUIForm)
BtnOk.caption = "OK"
BtnOk.Common.Height = 19
BtnOk.Common.Width = 20
BtnOk.Common.Top = 5
BtnOk.Common.Left = GUIForm.Common.Width - (BtnOk.Common.Width + 6)
BtnOk.UseScript = Script.ScriptPath
BtnOk.OnClickFunc = "OKClick"
'### Dropdown-Elements
'Get Width and Rows, Maximum Elements are 10 (and i think this must be enough...) so 2 Rows with 5 DropDowns
Dim ControlWidth
Dim ControlCount
'Do we need the second row? Answer in DDsUsed!
If DDsUsed > 5 Then
ControlCount = 5
Else
ControlCount = DDsUsed
End If
ControlWidth = GUIForm.Common.Width - (BtnOk.Common.Width + 6) - ControlCount
For i = 0 To DDsUsed - 1
Set DD = SDB.UI.NewDropDown(GUIForm)
If i < 5 Then
'First Row
DD.Common.Width = ControlWidth / ControlCount
DD.Common.Left = i * ControlWidth / ControlCount + 2
DD.Common.Top = 4
Else
'Second Row, you see the difference...
DD.Common.Width = ControlWidth / ControlCount
DD.Common.Left = (i - 5) * ControlWidth / ControlCount + 2
DD.Common.Top = DD.Common.Height + 4
End If
DD.Style = 2
DD.Common.ControlName = "Node" & i
'Add the possible Tags
For j = 0 To UBound(Tags, 1)
If Tags(j, 0) = "True" Then
DD.AddItem (Tags(j, 1))
End If
Next
'Get the values of the last use from the ini
If SDB.IniFile.StringValue("FastNode_GUI", "Node" & i) <> "" Then
DD.ItemIndex = SDB.IniFile.StringValue("FastNode_GUI", "Node" & i)
Else
DD.ItemIndex = 1
End If
Set DD = Nothing
Next
'### Label for Stringstorage
'This label is not shown on the panel
'but its caption contains the magicnode-code (which is later transfered to the MagicNodesScript)
Dim NodeLabel
Set NodeLabel = SDB.UI.NewLabel(GUIForm)
'Get last node from the ini-File
NodeLabel.caption = SDB.IniFile.StringValue("FastNode_GUI", "TotalString")
NodeLabel.Common.ControlName = "TotalString"
NodeLabel.Common.Height = 2
NodeLabel.Common.Left = 2
NodeLabel.Common.Visible = False
SDB.objects("MN_GUI") = GUIForm
End If
End Sub
Sub CreateMenu()
'Add the GUI to the View-Menu
Set GUIMnu = SDB.UI.AddMenuItem(SDB.UI.Menu_View, 1, -1)
GUIMnu.caption = FastNodeName & "_GUI"
GUIMnu.Shortcut = "Ctrl+Alt+G"
GUIMnu.Checked = GUIForm.Common.Visible
Script.RegisterEvent GUIMnu, "OnClick", "ShowPanel"
End Sub
Sub ShowPanel(item)
GUIForm.Common.Visible = Not GUIForm.Common.Visible
GUIMnu.Checked = GUIForm.Common.Visible
End Sub
Sub OKClick(BtnOk)
GetOptions
'When OK is clicked, i establish a connection to the modified MagicNode-Script
'(modified with the callable functions, see above)
'make sure the filename will be correct!!
Script.Include ("auto\MagicNodes.1.3b_GUI.vbs")
'Delete our old node
DeleteNodeExternalCall (BtnOk.Common.Parent.Common.Childcontrol("TotalString").caption)
'Create the new node and store it in Label
BtnOk.Common.Parent.Common.Childcontrol("TotalString").caption = GetString(BtnOk)
'Create new node
CreateNodeExternalCall (BtnOk.Common.Parent.Common.Childcontrol("TotalString").caption)
End Sub
Function GetString(BtnOk)
Dim i
Dim j
Dim ParentForm
Dim Index
Dim DCounter
Dim DDIndex()
Set ParentForm = BtnOk.Common.Parent
GetString = FastNodeName
ReDim DDIndex(DDsUsed)
'Get all DropDown-Values
For i = 0 To DDsUsed - 1
Set Index = ParentForm.Common.Childcontrol("Node" & i)
DDIndex(i) = Index.ItemIndex
'And sort out double entries (this makes no sense, or):
DCounter = 0
For j = 0 To i
If DDIndex(i) = DDIndex(j) Then DCounter = DCounter + 1
Next
If DCounter <= 1 And DDIndex(i) >= 0 Then GetString = GetString & "\" & Tags(DDIndex(i), 2)
Next
Set ParentForm = Nothing
Set Index = Nothing
End Function
Sub SDBShutDown()
Dim i
'Save the actual Status of the GUI to the ini-File
SDB.IniFile.StringValue("FastNode_GUI", "Show") = GUIForm.Common.Visible
SDB.IniFile.StringValue("FastNode_GUI", "DockedTo") = GUIForm.DockedTo
SDB.IniFile.StringValue("FastNode_GUI", "TotalString") = GUIForm.Common.Childcontrol("TotalString").caption
'Clear all Nodes
For i = 0 To 9
SDB.IniFile.StringValue("FastNode_GUI", "Node" & i) = ""
Next
'Get all DropDown-Values
For i = 0 To DDsUsed - 1
SDB.IniFile.StringValue("FastNode_GUI", "Node" & i) = GUIForm.Common.Childcontrol("Node" & i).ItemIndex
Next
Script.UnregisterAllevents
Set GUIForm = Nothing
Set GUIMnu = Nothing
Set NodeLabel = Nothing
Set BtnOk = Nothing
End Sub
'Set the layout of the options panel
Sub InitGUIOptions(sheet)
Dim Label
Dim CB
Dim i
Dim EDName, EDCode
Set Label = SDB.UI.NewLabel(sheet)
Label.Common.SetRect 10, 10, 80, 20
Label.caption = "Configure available Fields (needs Restart to take effect):"
Label.AutoSize = True
Label.Alignment = 0
Set Label = Nothing
Set Label = SDB.UI.NewLabel(sheet)
Label.Common.SetRect 40, 25, 80, 20
Label.caption = "Active"
Label.AutoSize = True
Label.Alignment = 0
Set Label = Nothing
Set Label = SDB.UI.NewLabel(sheet)
Label.Common.SetRect 80, 25, 80, 20
Label.caption = "Name"
Label.AutoSize = True
Label.Alignment = 0
Set Label = Nothing
Set Label = SDB.UI.NewLabel(sheet)
Label.Common.SetRect 160, 25, 80, 20
Label.caption = "Code"
Label.AutoSize = True
Label.Alignment = 0
Set Label = Nothing
For i = 1 To 10
Set Label = SDB.UI.NewLabel(sheet)
Label.Common.SetRect 20, 15 + i * 25 + 2, 80, 20
Label.caption = i
Label.AutoSize = True
Label.Alignment = 1
Set Label = Nothing
Set CB = SDB.UI.NewCheckbox(sheet)
CB.Common.SetRect 50, 15 + i * 25, 80, 20
CB.Common.ControlName = "CB" & i
CB.caption = ""
If SDB.IniFile.StringValue("FastNode_GUI", "Code" & i & "_Active") <> "" Then
CB.Checked = SDB.IniFile.StringValue("FastNode_GUI", "Code" & i & "_Active")
Else
CB.Checked = False
End If
Set CB = Nothing
Set EDName = SDB.UI.NewEdit(sheet)
EDName.Common.SetRect 80, 15 + i * 25, 60, 20
EDName.Common.ControlName = "EDName" & i
If SDB.IniFile.StringValue("FastNode_GUI", "Code" & i & "_Name") <> "" Then
EDName.text = SDB.IniFile.StringValue("FastNode_GUI", "Code" & i & "_Name")
Else
EDName.text = "Name"
End If
Set EDName = Nothing
Set EDCode = SDB.UI.NewEdit(sheet)
EDCode.Common.SetRect 160, 15 + i * 25, 200, 20
EDCode.Common.ControlName = "EDCode" & i
If SDB.IniFile.StringValue("FastNode_GUI", "Code" & i & "_Code") <> "" Then
EDCode.text = SDB.IniFile.StringValue("FastNode_GUI", "Code" & i & "_Code")
Else
EDCode.text = "code, e.g. <artist>"
End If
Set EDCode = Nothing
Next
Set Label = SDB.UI.NewLabel(sheet)
Label.Common.SetRect 20, 295, 60, 20
Label.caption = "NodeName:"
Label.AutoSize = True
Label.Alignment = 0
Set Label = Nothing
Set EDName = SDB.UI.NewEdit(sheet)
EDName.Common.SetRect 90, 292, 90, 20
EDName.Common.ControlName = "NodeName"
If SDB.IniFile.StringValue("FastNode_GUI", "NodeName") <> "" Then
EDName.text = SDB.IniFile.StringValue("FastNode_GUI", "NodeName")
Else
EDName.text = "FastNode"
End If
Set EDName = Nothing
Set Label = SDB.UI.NewLabel(sheet)
Label.Common.SetRect 200, 295, 80, 20
Label.caption = "Number of DropDowns:"
Label.AutoSize = True
Label.Alignment = 0
Set Label = Nothing
Set EDName = SDB.UI.NewSpinEdit(sheet)
EDName.Common.SetRect 320, 292, 40, 20
EDName.Common.ControlName = "DDsUsed"
EDName.minvalue = 1
EDName.maxvalue = 10
If SDB.IniFile.StringValue("FastNode_GUI", "DDsUsed") <> "" Then
EDName.value = SDB.IniFile.StringValue("FastNode_GUI", "DDsUsed")
Else
EDName.value = 3
End If
Set EDName = Nothing
End Sub
Sub SaveGUIOptions(sheet)
Dim i
For i = 1 To 10
SDB.IniFile.StringValue("FastNode_GUI", "Code" & i & "_Active") = sheet.Common.Childcontrol("CB" & i).Checked
Next
For i = 1 To 10
SDB.IniFile.StringValue("FastNode_GUI", "Code" & i & "_Name") = sheet.Common.Childcontrol("EDName" & i).text
Next
For i = 1 To 10
SDB.IniFile.StringValue("FastNode_GUI", "Code" & i & "_Code") = sheet.Common.Childcontrol("EDCode" & i).text
Next
SDB.IniFile.StringValue("FastNode_GUI", "NodeName") = sheet.Common.Childcontrol("NodeName").text
SDB.IniFile.StringValue("FastNode_GUI", "DDsUsed") = sheet.Common.Childcontrol("DDsUSed").value
End Sub