[Idea] Menu Builder Extension

Justin

  • *
  • Posts: 4716
With the support for extensions, I was hoping to create a WYSIWYG menu builder for the RPG Kit (well, it wouldn't necessarily be limited to that Kit, of course). Before extensions, I was limited to Design Mode and Custom Blocks in terms of user friendliness, so a WYSIWYG editor would be a big step up.

So the WYSIWYG editor sounds great and all, but I'm not sure how to save the data so that it can be read during the games runtime. In the previous incarnation of the menu builder, every menu and menu component had its own behavior. With this method, there was a great number of behaviors needed for every scene, so I ended up adding all the behaviors to the scene at runtime -- something I consider hackish, and I'd rather not resort to that again.

The bottom line is, I'd like as seamless an integration as possible. Open extension, edit menus, (close extension?), test game. Is such integration even possible at this point?

« Last Edit: May 31, 2011, 01:48:17 pm by Justin »
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Jon

  • *
  • Posts: 17524
It's possible to add generic data files that can be bundled with the game, provided that you know what to do with them after the game begins. What's your proposal on that front?

Justin

  • *
  • Posts: 4716
In that case, it seems like it would be a simple matter of creating a single behavior to read the data and create menus based on that data. All that would be left would be to add that behavior to every scene which has the menus. Unless behaviors can be added through extensions, which would eliminate even that step.

Is generic data limited only to text? Can images also be bundled with the game?
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Jon

  • *
  • Posts: 17524
You would be able to bundle in anything that Flash accepts, including images, sounds, text/XML and binary data. For testing/dev purposes, you can probably get away with hardcoding it until this support is in (it will take a while but isn't terribly hard to do, and you could even take a crack and I can tell you where to look)

Justin

  • *
  • Posts: 4716
Alright, I've got the SDK, and the sample extension is up and running. How do I go about bundling data with the game, and how can that data be accessed via behaviors?
For Live Support: Join our discord server and ping me @justin.
I'm most often available between 10am and 10pm Japan time. (GMT+9)

Jon

  • *
  • Posts: 17524
You need to develop a part of StencylWorks to support that, but I can describe roughly how you'd do that.

The best file to look at would be FlashFileGenerator.java. This file generates an Actionscript class on the fly that lists out all the game's assets (scenes, resources) for both game previewing and SWF publication. The relevant methods to look at are createMyAssetsFile and createRemote

You would need to do several things to add support for a game.

1) Add an extension hook to FlashFileGenerator:createRemote that will call onBuildGame and onPreviewGame that will call the extension when a game is built or previewed.

public String onPreviewGame()
public String onBuildGame()

2) Then, your extension will pass back a String with the data to inject. It will also need to copy the data file(s) to the right location during the call. You can tell what those locations are from the source.

Once that is done, then your data files will get packaged into the game. To access then from the game, you can get the Assets class, which is a singleton and then grab your data directly. (e.g. Assets.get().classMemberName)

You'll want to look at some of our file locating classes on the engine side to see how to process the data. You can find examples in Assets.as and the io package.

Since I see this becoming a fairly common thing to do for extensions, I invite ideas from you about how to make this easier for the end users and extensions authors to achieve.

Hope this helps!