FIFE forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

FIFE 0.4.0 has been released on 15th of January, 2017!

Author Topic: Contextual Menu -> Object managing ?  (Read 2679 times)

November

  • Developer
  • Newbie
  • *
  • Posts: 36
    • View Profile
Contextual Menu -> Object managing ?
« on: January 23, 2008, 06:00:16 am »

In a recent diff Sleek implemented an Instance Menu, which is a good start because it will raise questions about the game engine itself. This Instance Menu is not dynamically defined for now.

But ultimately, this Menu (I'd call it Contextual Menu) should get informations from the object the cursor clicked on to know what ContextActions it has, or what ContextButtons it must show when right clicked.
This require game engine to have an object manager, which would manage all game objects, load objects properties and return them to any script requesting them, but also modify them. Objects could be map instances, but in cases like items, there will be an object without an associated map instance, until the item is released by it's container (character or object).

I've wandered in the engine code to see whether such object managing was implemented, but since i'm not a master of C++ so I can't really tell.
« Last Edit: January 23, 2008, 06:03:26 am by November »
Logged

Sleek

  • Developer
  • Jr. Member
  • *
  • Posts: 57
    • View Profile
Re: Contextual Menu -> Object managing ?
« Reply #1 on: January 23, 2008, 07:45:16 am »

Hi,

Thank you for posting this thread. I've been really eager to push our progress ahead although a number of basic functionalities still need improving. In one way this lets us discover more weak areas in our engine.

The create_instancemenu or ContextMenu currently receives a list of instances available in that particular layer coordinate. I agree with you that we need to elaborate a bit on what context an instance can provide. Perhaps this can be done by creating a grouping structure in the map format :
Code: [Select]
<contextgroup id="walkable">
  <contextgroup id="bot">
    <i name="Cyborg1" />
  </contextgroup>
  <contextgroup id="human">
    <o id="Peasant" />
  </contextgroup>
</contextgroup>

<contextgroup id="openable">
  <contextgroup id="door">
    <o id="Mahogany_door" />
  </contextgroup>
</contextgroup>

Putting this info in metadata tags could be easier though.

We can also do this script-wise.. but iterating through all the objects/instances matched with conditional tests sounds like repetitive in  the case of multiple mod implementation.

Do you suggest that we have an 'ObjectManager' for retrieving these properties ? The way I would do it is just by adding a contexts list under instance, so all we need to do is

Code: [Select]
if ( instance.hasContext( "talker" ) ):
   instancemenu.addTalkButton(  )
elif ( instance.hasContext( "item" ) ):
   instancemenu.addPickupButton(  )

Also FYI, items and tiles are also instances in our map format. I am not sure what you mean by objects being associated with map instance. Maybe you mean game characters <->items association : inventory handling ?
Logged

November

  • Developer
  • Newbie
  • *
  • Posts: 36
    • View Profile
Re: Contextual Menu -> Object managing ?
« Reply #2 on: January 23, 2008, 01:53:48 pm »

Hi,

Thank you for answering to this thread :)

First, a little disclaimer : i'm not a member of the project and therefore my vision on certain aspects of the engine may be wrong/biased. Just correct me if I make a big mistake.



My view of how the system should handle instances and objects :
Instances are the graphic onmap representation of a game object. But they are not the objects themselves. You could have objects that don't have a onmap representation (=an instance), either because they are not on any map, or because they are carried by an object (character or container) which is on a map, and therefore are won't be rendered : no need of instances.
There will also be instances without attached objects : walls, floor tiles.

Example : You can have a character object "Hunter", that is not on any map : it won't have any instance. But, when you make this object "Hunter" enter a map, engine will create the instance from the object.

Another example : Player opens the inventory interface. Iventory Interface requests the item objects carried by the player (with a request ressembling to the following code). These objects doesn't have any instances, since they are not rendered on the map.


Objects will be a lot more than simple map instances. Will be stored into the objects all of its properties necessary to the ruleset (like the damage of a weapon, or the default dialog file of a character), but also necessary to the engine and client (like the icon of a weapon, or the sound which is played when it's used)

The problem is that actually all game information is stored in the map files. It's understandable since FIFE has developped itself around the very important step of development which is definition of the map format. But now we must take into account that not all the game data will be stored in the map.

Objects should be declared in the map file they are instancied, but defined (-> their properties be set) in another file.
It would be easy to just fill the "talkable" and "pickable" properties (with 1 or 0) (and along with other properties) of objects in this file.

The interface script would look like this :

Code: [Select]
object = instance.getObject()
if (object) :
   if ( object.get( "talkable" )):
      instancemenu.addTalkButton(  )
   elif ( object.get( "pickable" )):
      instancemenu.addPickupButton(  )
« Last Edit: January 25, 2008, 05:12:52 pm by November »
Logged