Code Itself wrote not me. Translated it with bb standard utility + little has ed. example:
Function AddRes(FileName$)
Local XML:sdXMLnode = sdReadXML(FileName)
Local c:sdXMLnode = xml.firstchild
While c <> Null
If Lower(c.tag) = "resources" Then
' Print sdXMLAttrValueStr$(c, "id")
ResAddScope(c, Lower(sdXMLAttrValueStr$(c, "id")))
End If
c = sdXMLNextNode(c)
Wend
End Function
Function ResAddScope( pNode:sdXMLNode, Scope$)
Local c:sdXMLnode = pNode.firstchild
Local DefPath:String
Local idprefix:String
While c <> Null
Local id:String = sdXMLAttrValueStr(c, "id")
Local path:String = sdXMLAttrValueStr(c, "path")
Select Lower(c.tag)
Case "setdefaults"
Local _path:String = sdXMLAttrValueStr(c, "path", "#NONE#")
If _path <> "#NONE#" Then DefPath = _path
Local _idprefix:String = sdXMLAttrValueStr(c, "idprefix", "#NONE#")
If _idprefix <> "#NONE#" Then idprefix = _idprefix
Case "image"
Local MidHandle$ = sdXMLAttrValueStr(c, "midhandle", "0")
ResManager.ResLoadImage( DefPath + Path, idprefix + id, Scope, Int(MidHandle))
Case "imagefont"
ResManager.ResLoadImageFont( DefPath + Path, idprefix + id, Scope)
End Select
c = sdXMLNextNode(c)
Wend
End Function
xml file
<?xml version="1.0"?>
<ResourceManifest>
<Resources id="Init">
<SetDefaults path="media/fonts/" idprefix="FONT_"/>
<ImageFont id="MAIN" path="Font" />
<SetDefaults path="media/images/" idprefix="IMAGE_" />
<Image id="BUTTON1_DOWN" path="button1_down.png" />
<Image id="BUTTON1_OVER" path="button1_over.png" />
<Image id="BUTTON1_NORMAL" path="button1.png" />
</Resources>
</ResourceManifest>
|