Changed: bind to interact with vertical/horizontal scroll elements

--HG--
branch : lua
hg/atys
Inky 5 years ago
parent 9dec7f9dbe
commit a1492e70e0

@ -495,6 +495,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();
@ -4248,4 +4249,48 @@ int CLuaIHMRyzom::displayChatMessage(CLuaState &ls)
ci.DynamicChat[id].displayMessage(ucstring(msg), prop.getRGBA()); ci.DynamicChat[id].displayMessage(ucstring(msg), prop.getRGBA());
} }
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;
}

@ -271,6 +271,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