How to create a PlugIn for Deled
Posted: Wed Aug 01, 2007 8:16 pm
- Compile as Shared Dll
- Copy the Dll in the Deled 'PlugIn' folder.
- Run Deled
- Control if PlugIn is ok --> Go to Menu PlugIn --> PlugIn information.
- Add an objet in a new scene
- Run PlugIn and see.
Deledis a 3D editor.
Download the Dll :
http://herved25.free.fr/sources/TestPlugIn.zip
- Copy the Dll in the Deled 'PlugIn' folder.
- Run Deled
- Control if PlugIn is ok --> Go to Menu PlugIn --> PlugIn information.
- Add an objet in a new scene
- Run PlugIn and see.
Deledis a 3D editor.
Code: Select all
;Comtois le 03/08/07
;PureBasic 4.10 beta 2
;This chapter lists all methods that should be exported through a DeleD plugin DLL file.
Enumeration
#Panel
#Button
#TreePrimitive
#TreeMaterial
#TreeLight
EndEnumeration
Enumeration
#PR_GETMEM
#PR_GETDATA
#PR_SETDATA
EndEnumeration
Structure TCallBackRecord
RequestID.l ;reason for executing callback (0,1 or 2)
*RequestXML ;XML Data send by the plugin To DeleD
*ResponseXML ;XML data send by DeleD to the plugin
ResponseSize.l ;size of the response XML data in bytes
EndStructure
Global PluginName.s
Global PluginDescription.s
Global PluginDeleDVersion.s
Global PluginVersion.s
Global PluginAuthor.s
Global PluginEmail.s
Prototype TCallBackProc(*ACallBackRecord.TCallBackRecord)
Global DeledCallBack.TCallBackProc
ProcedureDLL PluginName()
;This function returns a pointer To a character string
;containing the name of the plugin As being displayed
;in the Plugin menu With DeleD. Typically,
;this character string is between 10 And 20 characters in size.
PluginName = "PlugIn PureBasic"
ProcedureReturn @PluginName
EndProcedure
ProcedureDLL PluginDescription()
;This function returns a pointer To a character string
;containing the description of the plugin.
;This description is displayed in the Plugin window within DeleD.
PluginDescription = "Description"
ProcedureReturn @PluginDescription
EndProcedure
ProcedureDLL PluginDeleDVersion()
;This function returns a pointer To a character string
;showing the minimal version of DeleD needed To execute this plugin.
;DeleD uses this version number To determine If the plugin can be run And thus,
;If it should be listed in the Plugin menu.
PluginDeleDVersion = "1.7"
ProcedureReturn @PluginDeleDVersion
EndProcedure
ProcedureDLL PluginVersion()
;This function returns a pointer To a character string
;showing the current version of the plugin itself.
PluginVersion = "1.0 beta 1"
ProcedureReturn @PluginVersion
EndProcedure
ProcedureDLL PluginAuthor()
;This function returns a pointer To a character string
;showing the name of the author of the plugin.
PluginAuthor = "Comtois"
ProcedureReturn @PluginAuthor
EndProcedure
ProcedureDLL PluginEmail()
;This function returns a pointer To a character string
;showing the emailaddress of the author of the plugin.
PluginEmail = "Comtois@Truc.fr"
ProcedureReturn @PluginEmail
EndProcedure
ProcedureDLL PluginSetCallback(aCallBackProc.TCallBackProc)
;At startup, DeleD initializes all available plugins And calls
;the PluginSetCallback routine automatically For each plugin.
;This Procedure saves a pointer To DeleD's callback routine
;(As provided in the TCallBack parameter) into a parameter local To the plugin.
;The plugin then uses that local parameter To issue a callback To DeleD.
DeledCallBack = aCallBackProc
EndProcedure
Procedure AddNode(Tree,*Node, Position)
name$ = GetXMLNodeName(*Node)
If ExamineXMLAttributes(*Node)
While NextXMLAttribute(*Node)
name$ + " "+XMLAttributeName(*node)+"="+ XMLAttributeValue(*node) + " "
Wend
EndIf
AddGadgetItem (Tree, -1, name$, 0, position)
For child = 1 To XMLChildCount(*Node)
*child = ChildXMLNode(*Node, child)
AddNode(Tree,*child, position+1)
Next
EndProcedure
Procedure MaCallBack(Tree.l,Type.s)
Protected MaVariable.TCallBackRecord
MaVariable\RequestID = #PR_GETMEM
Texte$= "<request>"
Texte$ + "<" + type + " subset="+Chr(34)+"all"+Chr(34)
Texte$ + "retrieveID=" + Chr(34) + "false" + Chr(34)
Texte$ + "/>"
Texte$ + "</request>"
MaVariable\RequestXML = @Texte$
DeledCallBack(@MaVariable)
MaVariable\ResponseXML=AllocateMemory(MaVariable\ResponseSize)
MaVariable\RequestID = #PR_GETDATA
DeledCallBack(@MaVariable)
CatchXML(Tree, MaVariable\ResponseXML, MaVariable\ResponseSize)
status = XMLStatus(TRee)
If status = 4 ; (Normalement il faut tester 0)
AddNode(Tree,MainXMLNode(Tree), 0)
EndIf
FreeMemory(MaVariable\ResponseXML)
EndProcedure
ProcedureDLL PluginExecute(); stdcall;
;This Procedure is executed when the user executes a plugin
;from the Plugin menu within DeleD.
;
Protected MaVariable.TCallBackRecord
If OpenWindow(0, 0, 0, 600, 400, "PlugIn PureBasic", #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
PanelGadget(#Panel,5,5,595,350)
AddGadgetItem(#Panel, -1, "primitives")
TreeGadget(#TreePrimitive, 0, 0, 590, 325)
AddGadgetItem(#Panel, -1, "materials")
TreeGadget(#TreeMaterial, 0, 0, 590, 325)
AddGadgetItem(#Panel, -1, "lights")
TreeGadget(#TreeLight, 0, 0, 590, 325)
CloseGadgetList()
ButtonGadget(#Button, 10, 370, 200, 20, "Quit")
CloseGadgetList()
MaCallBack(#TreePrimitive,"primitives")
MaCallBack(#TreeMaterial,"materials")
MaCallBack(#TreeLight,"lights")
Repeat
event = WindowEvent()
Select event
Case 0
Delay(10)
Case #PB_Event_Gadget
Select EventGadget()
Case #Button
Quit = 1
EndSelect
EndSelect
Until quit
CloseWindow(0)
For i = #Panel To #TreeLight
FreeGadget(i)
Next i
EndIf
EndProcedure
http://herved25.free.fr/sources/TestPlugIn.zip