Game engine lib and editor

Posted by luke on Game Development See other posts from Game Development or by luke
Published on 2012-06-27T11:32:57Z Indexed on 2012/06/27 15:27 UTC
Read the original article Hit count: 203

Filed under:
|

I would like to know the best way/best practice to handle the following situation. Suppose the project you are working on is split in two sub-projects:

  1. game engine lib
  2. editor gui.

Now, you have a method bool Method( const MethodParams &params ) that will be called during game-level initialization. So it is a method belonging to the game engine lib. Now, the parameters of this method, passed as a reference the structure MethodParams can be decided via the editor, in the level design phase. Suppose the structure is the following:

enum Enum1
{
    E1_VAL1,
    E1_VAL2,
};
enum Enum2
{
    E2_VAL1,
    E2_VAL2,
    E2_VAL3,
};

struct MethodParams
{
    float   value;
    Enum1   e1;
    Enum2   e2;
    // some other member
}

The editor should present a dialog that will let the user set the MethodParams struct. A text control for the field value. Furthermore, the editor needs to let the user set the fields e1 and e2 using, for example, two combo boxes (a combo box is a window control that has a list of choices). Obviously, every enum should be mapped to a string, so the user can make an informed selection (i have used E1_VAL1 etc.., but normally the enum would be more meaningful). One could even want to map every enum to a string more informative (E1_VAL1 to "Image union algorithm", E1_VAL2 to "Image intersection algorithm" and so on...).

The editor will include all the relevant game egine lib files (.h etc...), but this mapping is not automatic and i am confused on how to handle it in a way that, if in future i add E1_VAL3 and E1_VAL4, the code change will be minimal.

© Game Development or respective owner

Related posts about engine

Related posts about editors