Merge with lua

--HG--
branch : yubo
hg/yubo
Inky 5 years ago
commit a7cdf29463

@ -497,6 +497,7 @@ void CLuaIHMRyzom::RegisterRyzomFunctions(NLGUI::CLuaState &ls)
ls.registerFunc("saveUserChannels", saveUserChannels); ls.registerFunc("saveUserChannels", saveUserChannels);
ls.registerFunc("readUserChannels", readUserChannels); ls.registerFunc("readUserChannels", readUserChannels);
ls.registerFunc("getMaxDynChan", getMaxDynChan); ls.registerFunc("getMaxDynChan", getMaxDynChan);
ls.registerFunc("scrollElement", scrollElement);
lua_State *L = ls.getStatePointer(); lua_State *L = ls.getStatePointer();
@ -4266,3 +4267,47 @@ int CLuaIHMRyzom::displayChatMessage(CLuaState &ls)
} }
return 1; return 1;
} }
// ***************************************************************************
int CLuaIHMRyzom::scrollElement(CLuaState &ls)
{
const char *funcName = "scrollElement";
// scrollElement(object, vertical, direction, offset_multiplier)
CLuaIHM::checkArgMin(ls, funcName, 3);
CLuaIHM::check(ls, ls.getTop() > 2, funcName);
CLuaIHM::check(ls, CLuaIHM::isUIOnStack(ls, 1), toString("%s requires a UI object in param 1", funcName));
CLuaIHM::check(ls, ls.type(2)==LUA_TBOOLEAN, toString("%s requires a boolean in param 2", funcName));
CLuaIHM::check(ls, ls.isInteger(3), toString("%s requires a number in param 3", funcName));
if (ls.getTop() > 3)
CLuaIHM::check(ls, ls.isInteger(4), toString("%s requires a number in param 4", funcName));
CInterfaceElement *pIE = CLuaIHM::getUIOnStack(ls, 1);
if (pIE)
{
// must be a scroll element
CCtrlScroll *pCS = dynamic_cast<CCtrlScroll*>(pIE);
if (pCS)
{
sint32 direction = 0;
sint32 multiplier = 16;
direction = (ls.toInteger(3) > 0) ? 1 : -1;
if (ls.getTop() > 3)
multiplier = (ls.toInteger(4) > 0) ? ls.toInteger(4) : 1;
const bool vertical = ls.toBoolean(2);
if (vertical)
pCS->moveTrackY(-(direction * multiplier));
else
pCS->moveTrackX(-(direction * multiplier));
return 0;
}
}
ls.pushNil();
return 1;
}

@ -273,6 +273,9 @@ private:
static bool isPlayerInPVPMode(); static bool isPlayerInPVPMode();
static bool isTargetInPVPMode(); static bool isTargetInPVPMode();
// vertical and horizontal scrolling
// do not require element to be focused
static int scrollElement(CLuaState &ls); // return none (nil if error)
public: public:

Loading…
Cancel
Save