I’ve been lately looking at the AngelScript’s manual and found out how to use the Objects and Handles. Then i implented GUI System that is pretty easy. When i get the Element system done then these combined they are really powerful as you have all image events automatically because of the Element system so you dont have to worry about animations nor loading different images.
Anyways here is commented example script:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | /* This AngelScript file is for XML definied Button that automatically places itself into game using the info provided on XML file. To create script for that button we simply create script with same filename as provided in XML file. In example this file is Equip.as. */ //All variables declared outside of scope are globals. int x = 0; int y = 0; //Lets declare global X and Y for our Equip inventory window. //In AngelScript we have types called Objects and Handles just think them similar as pointers //but instead of * you use @ IWindow@ handle; //Here is the predefined onClick() global behavior for button. void onClick() { if(handle is null) { //We check if the window is NULL aka does not exist. /* We create Window. Don`t worry about the Equip.backgrnd thingy, when i get element system complete you can simply type Equip and you get all states automatically. Like Hover image, Pressed Image etc.. if definied. */ @handle = addWindow("Equip.backgrnd",x,y,x,y,""); handle.setEvent(1,"void equipClose()"); //We register Close event for the Window we just created. //The event ID`s will be all Constanted. So don`t worry. } else { //If window exist and you press the button. handle.close(); //We close the window. } } //onHover event, won`t mess with it now. But could be useful for popups, tooltips etc.. void onHover() { } //Now here is our registered event for the Window. It`s actually normal function. void equipClose() { x = handle.getX(); y = handle.getY(); //We store the X and Y when the window is closed, so it will open up in same place again. @handle = null; //And then kill the window handle. } /* That`s it. The scripting implentations are still far for done and i may include Vector2d type for x and y. */ |
Result:

Fully draggable Window which is customized with Maple Story element.
2 Comments
Test
Blah