Platforms to show: All Mac Windows Linux Cross-Platform
/Main/MBS Plugin Manager/MBS Plugin Manager
Required plugins for this example: MBS Util Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Main/MBS Plugin Manager/MBS Plugin Manager
This example is the version from Fri, 21th Nov 2019.
Project "MBS Plugin Manager.xojo_binary_project"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Sub Open()
me.ColumnType(0)=2
End EventHandler
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action()
Save
List.DeleteAllRows
RestoreDates
Quit
End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action()
List.DeleteAllRows
RestoreDates
Load
End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action()
dim i,c as integer
c=List.ListCount-1
for i=0 to c
List.CellCheck(i,0)=true
next
End EventHandler
End Control
Control PushButton4 Inherits PushButton
ControlInstance PushButton4 Inherits PushButton
EventHandler Sub Action()
dim i,c as integer
c=List.ListCount-1
for i=0 to c
List.CellCheck(i,0)=false
next
End EventHandler
End Control
EventHandler Sub Open()
#if DebugBuild
// ignore IDE
#else
TestForIDE
#endif
Load
End EventHandler
Function FindFile(name as string) As FolderItem
// Look for file in parent folders from executable on
dim parent as FolderItem = app.ExecutableFile.Parent
while parent<>Nil
dim file as FolderItem = parent.Child(name)
if file<>Nil and file.Exists then
Return file
end if
parent = parent.Parent
wend
End Function
Private Function GetName(f as folderitem, name as string, n as integer) As string
dim h,g as FolderItem
g=f.TrueChild(name)
if g<>Nil then
h=g.TrueItem(n)
if h<>nil then
Return h.Name
end if
end if
End Function
Protected Sub Load()
dim f as FolderItem
#if DebugBuild
f=FindFile("PluginsTest")
#else
f=FindFile("Plugins")
#endif
if f<>nil then
LoadDir f
end if
Title="MBS Plugin Manager: "+str(List.ListCount)+" plugin parts"
End Sub
Protected Sub LoadDir(f as folderitem)
dim i,c as integer
dim g as FolderItem
c=f.Count
for i=1 to c
g=f.TrueItem(i)
if g<>nil then
if g.Directory then
LoadDir g
elseif Right(g.Name,4)=".rbx" then
LoadRBXPlugin g
end if
end if
next
End Sub
Protected Sub LoadRBXPlugin(f as folderitem)
dim p as PluginPart
dim i,c as integer
dim id as integer
dim part,name as string
dim pl as Plugin
dim v as VirtualVolume
dim g,root,CarbonFolder,pluginroot,buildresources as FolderItem
const kenn = "MBS Real Studio"
if Left(f.Name,len(kenn))=kenn then
part=NthField(f.Name," ",4)
pl=new Plugin
pl.file=f
pl.filedate=f.ModificationDate
v=f.OpenAsVirtualVolume
if v<>Nil then
root=v.Root
// search first folder
i=1
pluginroot=root.TrueItem(1)
while pluginroot=nil or pluginroot.Directory=false
i=i+1
pluginroot=root.TrueItem(i)
wend
buildresources=pluginroot.TrueChild("Build Resources")
CarbonFolder=buildresources.TrueChild("Mac Carbon Mach-O Universal")
if CarbonFolder<>nil and CarbonFolder.Exists then
c=CarbonFolder.count
for i=1 to c
g=CarbonFolder.TrueItem(i)
id=i
name=g.Name
p=new PluginPart
p.file=f
p.id=id
p.name=name
p.buildresources=buildresources
p.StateBefore=true
p.WindowsName=GetName(buildresources,"Windows",i)
p.LinuxName=GetName(buildresources,"Linux X86",i)
p.MacCarbonMachOName=GetName(buildresources,"Mac Carbon Mach-O Universal",i)
p.MacCocoaName=GetName(buildresources,"Mac Cocoa",i)
List.AddRow name
List.CellTag(List.LastIndex,0)=p
List.CellCheck(List.LastIndex,0)=p.StateBefore
List.Cell(List.LastIndex,1)=part
next
end if
CarbonFolder=buildresources.TrueChild("Mac Carbon Disabled")
if CarbonFolder<>nil and CarbonFolder.Exists then
c=CarbonFolder.count
for i=1 to c
g=CarbonFolder.TrueItem(i)
id=i
name=g.Name
p=new PluginPart
p.file=f
p.id=id
p.name=name
p.StateBefore=false
p.buildresources=buildresources
p.WindowsName=GetName(buildresources,"Windows Disabled",i)
p.LinuxName=GetName(buildresources,"Linux X86 Disabled",i)
p.MacCarbonMachOName=GetName(buildresources,"Mac Carbon Mach-O Disabled",i)
p.MacCocoaName=GetName(buildresources,"Mac Cocoa Disabled",i)
List.AddRow name
List.CellTag(List.LastIndex,0)=p
List.CellCheck(List.LastIndex,0)=p.StateBefore
List.Cell(List.LastIndex,1)=part
next
end if
Plugins.Append pl
end if
end if
End Sub
Sub RestoreDates()
dim p as plugin
for each p in Plugins
p.RestoreDate
next
redim plugins(-1)
End Sub
Protected Sub Save()
dim i,c as integer
dim p as PluginPart
dim State as Boolean
c=List.ListCount-1
for i=c downto 0 // backwards so saveing RBX works
State=List.CellCheck(i,0)
p=List.CellTag(i,0)
if state<>p.StateBefore then
p.Save state
end if
next
End Sub
Protected Sub TestForIDE()
dim p as ProcessMBS
p=new ProcessMBS
p.GetFirstProcess
do
if p.MacCreator="RBv2" then
MsgBox "Please Quit RB first!"
quit
Return
end if
loop until not p.GetNextProcess
End Sub
Property plugins() As plugin
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu5 = ""
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu4 = ""
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = ""
End MenuBar
Class App Inherits Application
End Class
Class PluginPart
Sub Move(oldname as string, newname as string, filename as string)
dim e,d as FolderItem
dim f as FolderItem
dim g as FolderItem
dim b as BinaryStream
dim s as string
if filename<>"" then
e=buildresources.TrueChild(oldname)
d=buildresources.TrueChild(newname)
e.CreateAsFolder
d.CreateAsFolder
f=e.TrueChild(fileName)
g=d.TrueChild(fileName)
b=f.OpenAsBinaryFile(false)
s=B.Read(b.Length)
b.Close
f.Delete
b=g.CreateBinaryFile("text")
b.Write s
b.Close
'MsgBox f.NativePath+" to "+g.NativePath
end if
End Sub
Sub Save(state as boolean)
if buildresources<>nil then
if state then
// enable
Move "Linux X86 Disabled", "Linux X86", LinuxName
Move "Windows Disabled", "Windows", WindowsName
Move "Mac Cocoa Disabled", "Mac Cocoa", MacCocoaName
Move "Mac Carbon Disabled", "Mac Carbon Mach-O Universal", MacCarbonMachOName
else
// disable
Move "Linux X86","Linux X86 Disabled", LinuxName
Move "Windows","Windows Disabled", WindowsName
Move "Mac Cocoa","Mac Cocoa Disabled", MacCocoaName
Move "Mac Carbon Mach-O Universal","Mac Carbon Disabled", MacCarbonMachOName
end if
end if
End Sub
Property ID As integer
Property LinuxName As string
Property MacCarbonMachOName As string
Property MacCocoaName As string
Property StateBefore As boolean
Property WindowsName As string
Property buildresources As folderitem
Property file As folderitem
Property name As string
End Class
Class Plugin
Sub RestoreDate()
file.ModificationDate=filedate
End Sub
Property file As folderitem
Property filedate As date
End Class
End Project
See also:
The items on this page are in the following plugins: MBS Main Plugin.