Esempio n. 1
0
UIButton* UI::addButton(int id, const char* strID, 
            uint32_t textureID_idle, uint32_t textureID_hover, uint32_t textureID_press,  
            const char* text, void (*callback)(UINode* Sender), UINode* parent)
{
    int x = luaGetNodePosX(strID);
    int y = luaGetNodePosY(strID);
    int width  = luaGetNodeWidth (strID);
    int height = luaGetNodeHeight(strID);
    UIButton* button = addButton(id, x, y, width, height, 
                        textureID_idle, textureID_hover, textureID_press,  
                        text, callback, parent);
    strcpy(button->strID, strID);
    return button;
}
Esempio n. 2
0
void UI::resize(int width, int height)
{
    mWindowWidth = width;
    mWindowHeight = height;
    lua_pushnumber(UILayout->L, width);
    lua_setglobal(UILayout->L, "window_width");
    lua_pushnumber(UILayout->L, height);
    lua_setglobal(UILayout->L, "window_height");
    for(int i=0; i<nodeList.size(); ++i)
    {
        if(strcmp(nodeList[i]->strID,"")==0) continue;
        nodeList[i]->setPos(luaGetNodePosX(nodeList[i]->strID), 
            luaGetNodePosY(nodeList[i]->strID));
        nodeList[i]->setSize(luaGetNodeWidth(nodeList[i]->strID), 
            luaGetNodeHeight(nodeList[i]->strID));
    }
}
Esempio n. 3
0
UIButton* UIImpl::addButton(int id, const char* strID,
                            void (*callback)(void* data), void* userData,
                            UINode* parent) {
    int x = luaGetNodePosX(strID);
    int y = luaGetNodePosY(strID);
    int width = luaGetNodeWidth(strID);
    int height = luaGetNodeHeight(strID);

    int textureID_idle =
        textureManager->loadTexture(luaGetTextureName(strID, "idle"), 4);
    int textureID_hover =
        textureManager->loadTexture(luaGetTextureName(strID, "hover"), 4);
    int textureID_press =
        textureManager->loadTexture(luaGetTextureName(strID, "press"), 4);

    std::string text = luaGetNodeText(strID);
    UIButtonImpl* button = dynamic_cast<UIButtonImpl*>(
        addButton(id, x, y, width, height, textureID_idle, textureID_hover,
                  textureID_press, text.c_str(), callback, userData, parent));

    strcpy(button->strID, strID);
    return button;
}