GUI system


#1

Any one develop UI editor to get the UI or sence layout done?


#2

I’m thinking of editor for my hard coded routines in game cycle:

typedef struct
    {
    ScreenFieldValues typField;
    ScreenElementTypes typElement;
    pair< int, int> whElement;
    int sizeStretch;
    int deltaX;
    int deltaY;
} ScreenFieldType;
typedef pair< ScreenFieldType, ScreenFieldType > HV_Field;
...
map< string, HV_Field > ScreenModel::SetupGameOptions();

vector< pair< string, HV_Field > > ScreenInterface::SetupGameOptions(CCArray* rElements);

class GameOptions : public CCLayer
{
    public:
        vector< pair< string, HV_Field > > mPosMenuItems;
        CCArray* mMenuItems;

        virtual bool init();
        static cocos2d::CCScene* scene();

        void SetupScene();
        void SetTarget(CCObject* rElement, string rName);
        void menuBackCallback(CCObject* pSender);
        CREATE_FUNC(GameOptions );
};

void GameOptions ::SetupScene()
{
    int capacity = GameOptions ::GetScreenInterface()->CapacityOptions();
    mMenuItems  = CCArray::createWithCapacity(capacity);
    mPosMenuItems = MainMenu::GetScreenInterface()->SetupGameOptions(mMenuItems);
}

void GameOptions ::SetTarget(CCObject* rElement, string rName)
{
    if ...

    else if (rName == "BTN_MAIN_MENU")
        (static_cast(rElement))->setTarget(
                                    this,
                                    menu_selector(GameOptions::menuBackCallback)
                                                        );
}
bool GameOptions ::init()
{
    if ( !CCLayer::init() )
    {
         return false;
    }
    SetupScene();
    CCMenu *menu = CCMenu::create();
    vector< pair< string, HV_Field > >::iterator pos_iter = mPosMenuItems.begin();
    CCObject* element;

    CCARRAY_FOREACH(mMenuItems, element)
    {
        SetTarget(element, (*pos_iter).first);
        if (
                ((*pos_iter).second.first.typElement == SCET_BUTTON)
            ||
                ((*pos_iter).second.first.typElement == SCET_IF_BUTTON)
            ||
                ((*pos_iter).second.first.typElement == SCET_ONOFF_BUTTON)
           )
        {
            menu->addChild((static_cast(element)), 0);
            (static_cast(element))->setVisible(true);
        }
        else
        {
            this->addChild((static_cast(element)), 0);
        }
        pos_iter++;
    }

    menu->setPosition(ccp(float (0), float (0)));
    GameOptions ::GetScreenInterface()->SetupPositions(mMenuItems, mPosMenuItems, landscape);

    this->addChild(menu,2);
    return true;
}

So basicaly I could make an editor with tool for picking object types and area for drawing rectangles. Saving could create gameOptions.xml ready to parse ScreenModel::SetupGameOptions and coresponding ScreenInterface::SetupGameOptions and ScreenModel::CapacityGameOptions. For now my non-generioc methods looks like:

int ScreenInterface::CapacityGameOptions()
{
    return SCCP_GAME_OPTIONS;
}

vector< pair< string, HV_Field > > ScreenInterface::SetupGameOptions (CCArray* rElements)
{
    map< string, HV_Field > game_options;
    ScreenModel model(false);
    game_options = model.SetupGameOptions ();
    return ParseGenericScreen(rElements, game_options;
}

map< string, HV_Field > ScreenModel::SetupGameOptions ()
{
    map< string, HV_Field > game_options;
    ...
    buttons[0]      = {{pg_left, 0},{0, pg_left}};
    button_sizes[0] = {{area_height, area_height},{area_height, area_height}};

    game_options["BTN_GO_SPEED"]    = SetupScreenField(
                                                        SCFV_GO_SPEED,
                                                        SCET_BUTTON,
                                                        button_sizes[0],
                                                        0,
                                                        buttons[0]
                                                     );

#3

Have you check CocoStudio Project?

Here is the link:

http://www.cocos2d-x.org/projects/studio/wiki/CocoStudio


#4

CocoStudio is preparing its international version, I mean English version in about one month.


#5

So this is something like cocos builder for windows? Can’t wait to see english version :slight_smile:


#6

Are there any plans for a cross-platform version?


#7

Too much work. Maybe GNUstep can help, but I’m not sure that all required APIs implemented in it.