[Library] GXML

Note: You can find an easier to read .galaxy version of this documentation in the download package

//--------------------------------------------------------------------------------------------------//Library:GXMLDocumentation,Forthelazy-byFuzzYD//--------------------------------------------------------------------------------------------------//Description//GXMLLibrarybyFuzzYD.609@SEA//HostedbySC2Mapster//Ifyouhavequestions,suggestionsorfindbugs,feelfreetomailmeatguan.chuan.siong@gmail.com//Version:B02//Requires:QuickLib-A02orlater//--------------------------------------------------------------------------------------------------//Changelog-B02//--------------------------------------------------------------------------------------------------//-Portedto.galaxy//--------------------------------------------------------------------------------------------------//Introduction//--------------------------------------------------------------------------------------------------//GXMLisascriptingtoolbasedonclassicXMLsyntax.Itiscodedentirelywithcustomscriptin//Galaxy.ItspurposeistoquickcreationofdialogsanddialogitemswithXMLcode.Thislibrary//isnotintendedforGUIusersasGUIalreadycontainsmanyofthefunctionsrequiredforcreating//dialogs.//--------------------------------------------------------------------------------------------------//Motivation//--------------------------------------------------------------------------------------------------//Ipersonallyusedialogsalot,AlmostallmyscriptingisdonewithdialogsandIfounditwas//reallymundanehavingtocreatedialogsandsettheirpropertieswithamultitudeoffunctions//eachtime.Sometimes,Iwouldonlyneedtosetdialogpositions,sometimesonlysize,orimages.//Itdidn't seem very efficient to have to have one function for every purpose. I wanted a function//thatallowsmethefreedomtospecifywhateverpropertiesIwant,inwhateversequenceIchoose.//ThusIwasinspiredtowriteGXML.//--------------------------------------------------------------------------------------------------//Installation//--------------------------------------------------------------------------------------------------//1)Openyoureditorandopentheimportmenu(F9).//2a)Rightclicktheimport(Ctrl+I)interfaceandGXML.galaxy.//2b)Optionalstep-Move(Ctrl+M)GXML.galaxytoTriggerLib.//3)Openthetriggereditor(F6),Createanewcustomscript(Ctrl+Alt+T).//4)Insertthefollowingline,withoutparanthesis,andyou're good to go!//'include "TriggerLibs/GXML"'//Note:Thispathwilldifferdependingonyouractionsduringstep2b//5)Settheoptionalinitializerfunctionto'InitGXML'.Thiswillinitializethevariablesneeded//forittofunctioncorrectly.//--------------------------------------------------------------------------------------------------//Features//--------------------------------------------------------------------------------------------------//-9supporteddialogtypes(SeeSupporteddialogtypesbelow)//-Parameterinputfreedom.Setwhateverpropertiesyouwant,whereveryouwant.//-Parametersthathavenoeffectontheselecteddialog/dialogitemareignored.//-Errordetection:GXMLwilloutputerrorsifitdetectsparametersthataremissing,exclusive//todifferentdialogitems//-EasilysetthetargetdialogfordialogitemcreationgwithSetDialog(intd);//--------------------------------------------------------------------------------------------------//Knowncaveats//--------------------------------------------------------------------------------------------------//-Tipswith'</n>'withinthemarecurrentlybroken.Hopetofixthisinafutureupdate.//--------------------------------------------------------------------------------------------------//Supporteddialogtypes//--------------------------------------------------------------------------------------------------//Dialog//-Dialog//Dialogcontrols//-Button//-Checkbox//-Editbox//-Images//-Labels//-Listbox//-Progressbar//-Pulldownmenu//-Slider//--------------------------------------------------------------------------------------------------//Unsupporteddialogtypes//--------------------------------------------------------------------------------------------------//Thefollowingdialogtypesareunsupportedforreasonsstatedbelow.//-f=flash(Blizzardonly)//-a=achievement(Can't get it working)//-p=panel(Can't get it working)//--------------------------------------------------------------------------------------------------//Unsupportedfunctions//--------------------------------------------------------------------------------------------------//Therearecurrentlynoplanstosupportthefollowingfunctionsastheyaretoosituational//-Setdialogimagetype:Thedefaultisnormalimagetype//-Renderpriority:Believedtoberarelyusedinbasicimplementations//-Textstyles:Toomanydifferentstyles//-Textwriteout:Situational//--------------------------------------------------------------------------------------------------//Acceptedidentifier//--------------------------------------------------------------------------------------------------//Identifiertaginputs//ImportantNote:Thesemustbedeclaredimmediatelyafterfirst"<"inyourGXMLstring//*d=dialog//Dialogcontrols//*b=button//*c=checkbox//*e=editbox//*i=image//*l=label//*lb=listbox//*pb=progressbar//*pd=pulldown//*s=slider//--------------------------------------------------------------------------------------------------//Acceptedparameters//--------------------------------------------------------------------------------------------------//Compulsoryinputs//*w=width(Int)//*h=height(Int)//Optionalinputs(Alldialog/dialogitemtypes)//*c=color(Hexcolor,Example:FF0000)//*a=anchor(0//*8,Toplefttobottomright,rowbyrow)//*x=xoffset(Int,usedwithanchors)//*y=yoffset(Int,usedwithanchors)//*f=fade(Fixed,%)//*tip='YourTip'dialogitemtooltip(String)//*txt=textdisplay(concealedfromuser,declaredinbetween<...>and</...>)//Imagedialogitemsonly//*r=rotation(Int)//ImageandButtondialogitemsonly//*img=dialogitemimage(String)//Image,Button,Progressbarandslideronly//*min=minimumdialogvalue(Fixed)//*max=maximumdialogvalue(Fixed)//*val=currentdialogvalue(Fixed)//BooleanInputs(Noargumentsrequired)//+check=Forcheckbox,initialcheckstate//+tiled=Forimage/button,definesifimageistiled//+hide=Fordialog,nottobeconfusedwithvisible,hidesdialogbackground//+full=Fordialog/dialogitem,forcesdialog/dialogitemtobefullscreen/fulldialog//+off=Initiallydisabledialog/dialogitem//--------------------------------------------------------------------------------------------------//Howtouse//--------------------------------------------------------------------------------------------------//Optionalsettings://GXMLhasaconstant'c_DefaultFullDialog'whichissettofalse.Youmaysetthistotruewith//anytexteditorbeforeimportingGXMLintoyourmap.Bysettingthistotrue,GXMLwillforce//alldialogsanddialogitemsthataremissingthecompulsorywidthandheightparametersto//'+full'////TheGXMLfunctiontakesonthefollowingform//*intGXML(stringGXMLString);//Alternatively,thefollowingfunctionperformsthesameaction(It's quicker)//*intqd(stringGXMLString);//NoticethatthereturntypeforGXMLisint.Thisintisactuallyanidentifiertothedialogor//dialogitemthatitcreates.Ifyoustorethisvalueintoanarray,youcaneasilycallbackyour//createddialog/dialogitemformodificationlater!////UsingGXML//1)Openyourtriggereditor(F6)andaddanewcustomscript(Ctrl+Alt+T)//2)Settheoptionalinitializerfunctiontoafunctionofyourchoice//3)Declareyourinitializerfunction,Examplebelow////voidInitHelloWorld(){////GXMLCall//}////4)InsertaGXMLCallwithastringinthefollowingformat,withoutanyapostrophes('):////GXML("<'id' 'param1' 'param2' 'param3' ... 'paramN'>'Insert text here'</'id'>");////Theonlyexceptiontothisruleistheinsertionofatipparameterwhichmustbedoneas//follows:////'tip='Thisisatip''////Noticethatallparametersandid's are always separated by a space, similar to whart you see//inXML.////Thefulllistofacceptedidentifiersandparameterscanbeseeninthetwoblockspreceding//theHowtousesection.Forexamplesofusage,takealookbelow.Alternatively,youmayimport//"GXMLDoc.galaxy"intoyourmapandincludeitincustomscripttoseehowitworks.//TheExampleinitializerfunctionisGXML_Example.Thiswillneedtobesetasthecustomscript//InitializerwhereyouincludeGXMLDoc.