mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-25 16:26:18 +00:00
Added: Add lua function to have an icon at left of menu option
This commit is contained in:
parent
db718f9a40
commit
18b024f0c7
2 changed files with 46 additions and 2 deletions
|
@ -191,6 +191,7 @@ namespace NLGUI
|
||||||
int luaGetLineFromId(CLuaState &ls);
|
int luaGetLineFromId(CLuaState &ls);
|
||||||
int luaIsSeparator(CLuaState &ls);
|
int luaIsSeparator(CLuaState &ls);
|
||||||
int luaAddLine(CLuaState &ls);
|
int luaAddLine(CLuaState &ls);
|
||||||
|
int luaAddIconLine(CLuaState &ls);
|
||||||
int luaAddLineAtIndex(CLuaState &ls);
|
int luaAddLineAtIndex(CLuaState &ls);
|
||||||
int luaAddSeparator(CLuaState &ls);
|
int luaAddSeparator(CLuaState &ls);
|
||||||
int luaAddSeparatorAtIndex(CLuaState &ls);
|
int luaAddSeparatorAtIndex(CLuaState &ls);
|
||||||
|
@ -210,6 +211,7 @@ namespace NLGUI
|
||||||
REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu);
|
REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu);
|
||||||
REFLECT_LUA_METHOD("isSeparator", luaIsSeparator);
|
REFLECT_LUA_METHOD("isSeparator", luaIsSeparator);
|
||||||
REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id
|
REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id
|
||||||
|
REFLECT_LUA_METHOD("addIconLine", luaAddIconLine); // name, ah, ah_params, id, texture
|
||||||
REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id
|
REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id
|
||||||
REFLECT_LUA_METHOD("addSeparator", luaAddSeparator);
|
REFLECT_LUA_METHOD("addSeparator", luaAddSeparator);
|
||||||
REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex);
|
REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex);
|
||||||
|
@ -278,6 +280,7 @@ namespace NLGUI
|
||||||
*/
|
*/
|
||||||
CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const;
|
CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const;
|
||||||
void initOptions(CInterfaceGroup *parent);
|
void initOptions(CInterfaceGroup *parent);
|
||||||
|
CViewBitmap *createIcon(CInterfaceElement *parentPos, const std::string &texture);
|
||||||
CViewBitmap *createCheckBox(bool checked);
|
CViewBitmap *createCheckBox(bool checked);
|
||||||
CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center);
|
CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center);
|
||||||
};
|
};
|
||||||
|
|
|
@ -381,6 +381,22 @@ namespace NLGUI
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
CViewBitmap *CGroupSubMenu::createIcon(CInterfaceElement *parentPos, const string &texture)
|
||||||
|
{
|
||||||
|
// Add an icon to the line
|
||||||
|
CViewBitmap *pVB = new CViewBitmap(CViewBase::TCtorParam());
|
||||||
|
pVB->setSerializable( false );
|
||||||
|
pVB->setParent (this);
|
||||||
|
pVB->setParentPos (parentPos);
|
||||||
|
pVB->setParentPosRef (Hotspot_ML);
|
||||||
|
pVB->setPosRef (Hotspot_MR);
|
||||||
|
pVB->setTexture(texture);
|
||||||
|
pVB->setModulateGlobalColor(false);
|
||||||
|
pVB->setX (-2);
|
||||||
|
addView (pVB);
|
||||||
|
return pVB;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
CViewBitmap *CGroupSubMenu::createCheckBox(bool checked)
|
CViewBitmap *CGroupSubMenu::createCheckBox(bool checked)
|
||||||
|
@ -1226,13 +1242,22 @@ namespace NLGUI
|
||||||
pV->setCheckBox(checkBox);
|
pV->setCheckBox(checkBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CViewBitmap *icon = NULL;
|
||||||
|
if (!texture.empty())
|
||||||
|
{
|
||||||
|
if (_GroupList->getNumChildren() == 1)
|
||||||
|
pV->setX(20);
|
||||||
|
icon = createIcon(pV, texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
tmp.ViewText = pV;
|
tmp.ViewText = pV;
|
||||||
tmp.Separator = NULL;
|
tmp.Separator = NULL;
|
||||||
tmp.AHName = ah;
|
tmp.AHName = ah;
|
||||||
tmp.AHParams = params;
|
tmp.AHParams = params;
|
||||||
tmp.Cond = cond;
|
tmp.Cond = cond;
|
||||||
tmp.CheckBox = checkBox;
|
tmp.CheckBox = checkBox;
|
||||||
tmp.RightArrow = NULL;
|
tmp.RightArrow = icon;
|
||||||
if (id.empty())
|
if (id.empty())
|
||||||
tmp.Id = NLMISC::toString (_Lines.size());
|
tmp.Id = NLMISC::toString (_Lines.size());
|
||||||
else
|
else
|
||||||
|
@ -1772,7 +1797,23 @@ namespace NLGUI
|
||||||
addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4));
|
addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
int CGroupSubMenu::luaAddIconLine(CLuaState &ls)
|
||||||
|
{
|
||||||
|
const char *funcName = "addIconLine";
|
||||||
|
CLuaIHM::checkArgCount(ls, funcName, 5);
|
||||||
|
CLuaIHM::checkArgTypeUCString(ls, funcName, 1);
|
||||||
|
CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING);
|
||||||
|
CLuaIHM::checkArgType(ls, funcName, 3, LUA_TSTRING);
|
||||||
|
CLuaIHM::checkArgType(ls, funcName, 4, LUA_TSTRING);
|
||||||
|
CLuaIHM::checkArgType(ls, funcName, 5, LUA_TSTRING);
|
||||||
|
ucstring arg1;
|
||||||
|
nlverify(CLuaIHM::getUCStringOnStack(ls, 1, arg1));
|
||||||
|
addLine(arg1, ls.toString(2), ls.toString(3), ls.toString(4), string(), ls.toString(5));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
int CGroupSubMenu::luaAddLineAtIndex(CLuaState &ls)
|
int CGroupSubMenu::luaAddLineAtIndex(CLuaState &ls)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue