Property editor for inventory

Hey Guys,
I am writing a RPG and now I am stuck with the Inventory. I want the inventory to be modified by the designer using the JMonkey SDK. I have an userdata, which stores all the items in the inventory. It includes one weapon slot, one armor slot and an array of items. Now i need a PropertyEditor for the inventory slots, but i don’t know, how to write it. Does anybody of you have any idea, how to do this? I hope i have described my problem clearly.
Turakar

That sounds like a good idea, you might need to do your own SDK plugin to handle your custom stuff although it’s possible there is already something in place to do it that I’m not aware of.

@normen is the expert in this area.

Okay, thanks for the fast reply. So I will wait for normen to answer me.

@Turakar23 said: Hey Guys, I am writing a RPG and now I am stuck with the Inventory. I want the inventory to be modified by the designer using the JMonkey SDK. I have an userdata, which stores all the items in the inventory. It includes one weapon slot, one armor slot and an array of items. Now i need a PropertyEditor for the inventory slots, but i don't know, how to write it. Does anybody of you have any idea, how to do this? I hope i have described my problem clearly. Turakar
The SDK has a built in user data editor that is using reflection. So basically if you have a classic java bean you should have a form to fill your fields. In the add User data dialog box choose "custom" for the user data type, you'll be asked for a type (must implement savable) and it you'll have a form that reflect your bean.

Yep, it can edit primitive values and Vector3f, i think. But my inventory userdata consists of an array of item-objects, which are not editable with the SDK. So I want to write my own property editor for them.
Turakar23

Bump
Or does anybody has an idea, how to change the class design of the inventory, to make it editable using the SDK?

@Turakar23 :
Now talking about extend the SDK, do you have any idea of Netbean Platform (NBP) architect. That’s what our JMP and SDK is built in.

and NetBeans Selection Management Tutorial I-Using a TopComponent’s Lookup

Ok, let’s assume you know that already.

Pure java way:
Option A:

  1. Create a TopComponent which have form to display your custom data. This call an Editor Component.
  2. Link that TopComponent to the SceneGraph selection, via a pre-made connections, called “lookup” and “service” . It’s as simple as 10 loc and an Annotation.
  3. Then when you select your Spatial’s Node, your data can be sent to your Editor Component by NBP hidden API and can be display.
  4. The opposite way is pretty much the same, you listen to your swing component (ex: JTextField) changes, wrap a change code in to an app.queue and then tell the Spatial to update its data in render thread (not in Swing EDT thread).

Option B:
For the step 3-4) [For those know NBP very clear, like the palm of your hand, This one other way]
You can also use a property sheet to display and change your data, in a hacky way. Remember that property sheet is a boring style of displaying data but it’s tranditional and have good integrated and supported features!
If you have a Node which just display the predefined Property as a normal Node, just let its have some more properties by:
Change to SpatialDataInspector in combination with BeanInspector
Ask the PropertyTopComponent for the PropertyPanel and change its layout, and such…
These two source code will help:
http://code.google.com/p/jmonkeyengine/source/browse/trunk/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/JmeNode.java?r=10473
http://code.google.com/p/jmonkeyengine/source/browse/trunk/sdk/jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/actions/UserDataDialog.java?r=10473

Groovy way:
I also come up with a solution which i fact i’m big fan of Unity. And the way they let user create custom Editor is great!

  • So I made a ScriptComponentModule,
  • Let this Module procedure as much ScriptBaseTopComponent as they want.
  • Those ScriptBaseTopComponent are build by a GroovyScript with swing builder and have groovy style EventListener ( ex: via Closure).
  • Interchange Action between Swing and the Render thread are wrap into app.queue or fully functions as a mini AppState. I use a lot of GPars power here!
  • Or it’s just a bunch of code without Interchange Action.
    If you are good with Unity, you can find this solution extremely familiar and friendly. But as for now (current solution) remember this ScriptComponentModule is very heavy weight and mix up M,V,C in one place. In the term of Scripting, or Groovy its self, no problem. But in Netbean architecture, it’s a dangerous violating.

Hope this help.

2 Likes

Thanks atomix.
Sorry, that I waited so long with my answer.
I will look at your ideas and try to implement one of them.