1 #ifndef LUA_IHM_RYZOM_H
2 #define LUA_IHM_RYZOM_H
4 #include "nel/gui/lua_ihm.h"
11 static void RegisterRyzomFunctions( CLuaState
&ls
);
14 static void createLuaEnumTable(CLuaState
&ls
, const std::string
&str
);
16 static int luaClientCfgIndex(CLuaState
&ls
);
17 static int luaClientCfgNewIndex(CLuaState
&ls
);
19 // CInterfaceElement management on stack, stored by a CRefPtr.
24 static int getUI(CLuaState
&ls
); // params: "ui:interface:...". return: CInterfaceElement* (nil if error), an additionnal boolean parameter
25 // LUA exported Functions with standard lua (because use ui object, use variable param number, or return dynamic-typed object)
26 static int getUICaller(CLuaState
&ls
); // params: none. return: CInterfaceElement* (nil if error)
27 // can specify verbose display when the element is note found (default is true)
28 static int createGroupInstance(CLuaState
&ls
); // params : param 1 = template name,
29 // param 2 = id of parent where the instance will be inserted
30 // param 3 = table with ("template_param", "template_param_value") key/value pairs
31 // such as { id="foo", x="10" } etc. -> returns a new instance of the template, or nil on fail
32 static int createRootGroupInstance(CLuaState
&ls
); // params : param 1 = template name,
33 // param 2 = id of parent where the instance will be inserted
34 // param 3 = table with ("template_param", "template_param_value") key/value pairs
35 // such as { id="foo", x="10" } etc. -> returns a new instance of the template, or nil on fail
36 static int createUIElement(CLuaState
&ls
); // params : param 1 = template name,
37 // param 2 = id of parent where the instance will be inserted
38 // param 3 = table with ("template_param", "template_param_value") key/value pairs
39 // such as { id="foo", x="10" } etc. -> returns a new instance of the template, or nil on fail
41 static int displayBubble(CLuaState
&ls
); // params : param 1 = bot id
43 // param 3 = table with all strings and urls
44 // {"main text"="http:///", "text option 1"="http:///", "text option 2"="http:///") etc...
45 static int getIndexInDB(CLuaState
&ls
); // params: CDBCtrlSheet*.... return: index, or 0 if error
46 static int formatUI(CLuaState
&ls
); // params: "expr", param1, param2.... return: string with # and % parsed
47 static int formatDB(CLuaState
&ls
); // params: param1, param2.... return: string with @ and , added
48 static int launchContextMenuInGame(CLuaState
&ls
); // params : menu name
49 static int parseInterfaceFromString(CLuaState
&ls
); // params : intreface script
50 static int updateAllLocalisedElements(CLuaState
&ls
);
51 static int isShiftDown(CLuaState
&ls
);
52 static int isCtrlDown(CLuaState
&ls
);
53 static int getTimestampHuman(CLuaState
&ls
);
54 static int breakPoint(CLuaState
&ls
);
55 static int i18n(CLuaState
&ls
); // retrieve an unicode string from CI18N
56 static int setTextFormatTaged(CLuaState
&ls
); // set a text that may contains Tag Format infos
57 static int validMessageBox(CLuaState
&ls
); // ok/cancel type message box (can't get it to work through luabind)
58 static int initEmotesMenu(CLuaState
&ls
);
59 static int hideAllWindows(CLuaState
&ls
);
60 static int hideAllNonSavableWindows(CLuaState
&ls
);
61 static int getDesktopIndex(CLuaState
&ls
);
62 static int setLuaBreakPoint(CLuaState
&ls
); // set a breakpoint in lua external debugger (file, line)
63 static int getMainPageURL(CLuaState
&ls
);
64 static int setNewsAtProgress(CLuaState
&ls
);
65 static int getCharSlot(CLuaState
&ls
);
66 static int displaySystemInfo(CLuaState
&ls
);
67 static int displayChatMessage(CLuaState
&ls
);
68 static int setWeatherValue(CLuaState
&ls
); // first value is a boolean to say automatic, second value ranges from of to 1 and gives the weather
69 static int getWeatherValue(CLuaState
&ls
); // get current real weather value (blend between server driven value & predicted value). Manual weather value is ignored
70 static int getRyzomTime(CLuaState
&ls
); // get day and hour in ryzom time
71 static int getContinentSheet(CLuaState
&ls
);
72 static int disableContextHelpForControl(CLuaState
&ls
); // params: CCtrlBase*. return: none
73 static int disableContextHelp(CLuaState
&ls
);
74 static int getServerSeason(CLuaState
&ls
); // get the last season sent by the server
75 // 0->auto, computed locally from the current day (or not received from server yet)
76 // 1->server force spring
80 static int computeCurrSeason(CLuaState
&ls
); // compute current displayed season (1->spring, etc .)
81 static int getAutoSeason(CLuaState
&ls
); // compute automatic season that would be at this time (1->spring, etc .)
84 static int enableModalWindow(CLuaState
&ls
);
85 static int getPlayerPos(CLuaState
&ls
);
86 static int getPlayerFront(CLuaState
&ls
);
87 static int getPlayerDirection(CLuaState
&ls
);
88 static int getPlayerGender(CLuaState
&ls
);
89 static int getPlayerName(CLuaState
&ls
);
90 static int getPlayerTitleRaw(CLuaState
&ls
);
91 static int getPlayerTitle(CLuaState
&ls
);
92 static int getPlayerTag(CLuaState
&ls
);
93 static int getPlayerMode(CLuaState
&ls
);
94 static int getTargetPos(CLuaState
&ls
);
95 static int getTargetFront(CLuaState
&ls
);
96 static int getTargetDirection(CLuaState
&ls
);
97 static int getTargetGender(CLuaState
&ls
);
98 static int getTargetName(CLuaState
&ls
);
99 static int getTargetTitleRaw(CLuaState
&ls
);
100 static int getTargetTitle(CLuaState
&ls
);
101 static int getTargetTag(CLuaState
&ls
);
102 static int getTargetMode(CLuaState
&ls
);
103 static int moveToTarget(CLuaState
&ls
);
104 static int addSearchPathUser(CLuaState
&ls
);
105 static int getClientCfgVar(CLuaState
&ls
);
106 static int isPlayerFreeTrial(CLuaState
&ls
);
107 static int isPlayerNewbie(CLuaState
&ls
);
108 static int isInRingMode(CLuaState
&ls
);
109 static int getUserRace(CLuaState
&ls
);
110 static int getSheet2idx(CLuaState
&ls
);
111 static int getTargetSlot(CLuaState
&ls
);
112 static int setTargetAsInterlocutor(CLuaState
&ls
);
113 static int unsetTargetAsInterlocutor(CLuaState
&ls
);
114 static int getSlotDataSetId(CLuaState
&ls
);
116 static int getMaxDynChan(CLuaState
&ls
);
117 static int readUserChannels(CLuaState
&ls
);
118 static int saveUserChannels(CLuaState
&ls
); // { name = "pass" }
120 // LUA functions exported for Dev only (debug)
121 static int dumpUI(CLuaState
&ls
); // params: CInterfaceElement*.... return: none
122 static int setKeyboardContext(CLuaState
&ls
);
124 static int setRpItems(CLuaState
&ls
);
126 static int getCompleteIslands(CLuaState
&ls
);
127 static int getIslandId(CLuaState
&ls
);//TEMP
129 static int addShape(CLuaState
&ls
);
130 static int moveShape(CLuaState
&ls
);
131 static int rotateShape(CLuaState
&ls
);
132 static int getShapePos(CLuaState
&ls
);
133 static int getShapeScale(CLuaState
&ls
);
134 static int getShapeRot(CLuaState
&ls
);
135 static int getShapeColPos(CLuaState
&ls
);
136 static int getShapeColScale(CLuaState
&ls
);
137 static int getShapeColOrient(CLuaState
&ls
);
138 static int deleteShape(CLuaState
&ls
);
140 ///////////////////////////// Standard Lua stuff ends here //////////////////////////////////////////////
142 static sint32
getDbProp(const std::string
&dbProp
); // return 0 if not found.
143 static sint64
getDbProp64(const std::string
&dbProp
); // return 0 if not found.
144 static void setDbProp(const std::string
&dbProp
, sint32 value
); // Nb: the db prop is not created if not present.
145 static void setDbProp64(const std::string
&dbProp
, sint64 value
); // Nb: the db prop is not created if not present.
146 static void addDbProp(const std::string
&dbProp
, sint32 value
); // Nb: the db prop is created if not present.
147 static void delDbProp(const std::string
&dbProp
);
148 static void setDbRGBA(const std::string
&dbProp
, const NLMISC::CRGBA
&color
); // the db prop is created if not present
149 static std::string
getDbRGBA(const std::string
&dbProp
); // empty string if not found
152 // Print a message in the log.
153 // Lua messages must be enabled (with ClientCfg.DisplayLuaDebugInfo = 1)
154 // Additionnally, if ClientCfg.LuaDebugInfoGotoButtonEnabled is set, then
155 // a button will be created near the line to allow to goto the lua line that issued the message
156 // by using an external editor
157 static void debugInfo(const std::string
&dbg
);
158 // Print a message in the log
159 // No 'goto file' button is created
160 // Lua messages must be enabled (with ClientCfg.DisplayLuaDebugInfo = 1)
162 static void dumpCallStack(int startStackLevel
= 0);
164 /** execute function that is currently on the stack, possibly outputing error messages to the log
165 * \return true if execution succeeded
167 static bool executeFunctionOnStack(CLuaState
&ls
, int numArgs
, int numRet
);
170 static void rawDebugInfo(const std::string
&dbg
);
171 // Dump callstack in the console
172 // Additionnally, if ClientCfg.LuaDebugInfoGotoButtonEnabled is set, then
173 // buttons will be created in front of each line to allow to go to the lua line that issued the message
174 // by using an external editor
176 static void getCallStackAsString(int startStackLevel
, std::string
&result
);
177 static std::string
getDefine(const std::string
&def
);
178 #ifdef RYZOM_LUA_UCSTRING
179 static void setContextHelpText(const ucstring
&text
);
181 static void setContextHelpText(const std::string
&text
);
185 #ifdef RYZOM_LUA_UCSTRING
186 static void messageBox(const ucstring
&text
);
187 static void messageBox(const ucstring
&text
, const std::string
&masterGroup
);
188 static void messageBox(const ucstring
&text
, const std::string
&masterGroup
, int caseMode
);
190 static void messageBox(const std::string
&text
);
191 static void messageBox(const std::string
&text
, const std::string
&masterGroup
);
192 static void messageBox(const std::string
&text
, const std::string
&masterGroup
, int caseMode
);
193 #ifdef RYZOM_LUA_UCSTRING
194 static void messageBoxWithHelp(const ucstring
&text
);
195 static void messageBoxWithHelp(const ucstring
&text
, const std::string
&masterGroup
);
196 static void messageBoxWithHelp(const ucstring
&text
, const std::string
&masterGroup
, int caseMode
);
198 static void messageBoxWithHelp(const std::string
&text
);
199 static void messageBoxWithHelp(const std::string
&text
, const std::string
&masterGroup
);
200 static void messageBoxWithHelp(const std::string
&text
, const std::string
&masterGroup
, int caseMode
);
202 #ifdef RYZOM_LUA_UCSTRING
203 static ucstring
replacePvpEffectParam(const ucstring
&str
, sint32 parameter
); // TODO: UTF-8 Lua
205 static std::string
replacePvpEffectParam(const std::string
&str
, sint32 parameter
); // TODO: UTF-8 Lua
207 static sint32
secondsSince1970ToHour(sint32 seconds
);
208 #ifdef RYZOM_BG_DOWNLOADER
209 static void pauseBGDownloader();
210 static void unpauseBGDownloader();
211 static void requestBGDownloaderPriority(uint priority
);
212 static sint
getBGDownloaderPriority();
214 static void loadBackground(const std::string
&bg
);
215 #ifdef RYZOM_LUA_UCSTRING
216 static ucstring
getPatchLastErrorMessage();
218 static std::string
getPatchLastErrorMessage();
220 static bool isInGame();
221 static uint32
getPlayerSelectedSlot();
222 static bool isPlayerSlotNewbieLand(uint32 slot
); // test if one of the player slot is a newbieland one, if not so, client must be patched in order to continue
225 static ucstring
getSheetLocalizedName(const std::string
&sheet
);
226 static ucstring
getSheetLocalizedDesc(const std::string
&sheet
);
227 static sint32
getSkillIdFromName(const std::string
&def
);
228 #ifdef RYZOM_LUA_UCSTRING
229 static ucstring
getSkillLocalizedName(sint32 skillId
);
231 static std::string
getSkillLocalizedName(sint32 skillId
);
233 static sint32
getMaxSkillValue(sint32 skillId
);
234 static sint32
getBaseSkillValueMaxChildren(sint32 skillId
);
235 static sint32
getMagicResistChance(bool elementalSpell
, sint32 casterSpellLvl
, sint32 victimResistLvl
);
236 static sint32
getDodgeParryChance(sint32 attLvl
, sint32 defLvl
);
237 static void browseNpcWebPage(const std::string
&htmlId
, const std::string
&url
, bool addParameters
, double timeout
);
238 static void clearHtmlUndoRedo(const std::string
&htmlId
);
239 #ifdef RYZOM_LUA_UCSTRING
240 static ucstring
getDynString(sint32 dynStringId
);
242 static std::string
getDynString(sint32 dynStringId
);
244 static bool isDynStringAvailable(sint32 dynStringId
);
245 static bool isFullyPatched();
246 static std::string
getSheetType(const std::string
&sheet
);
247 static std::string
getSheetShape(const std::string
&sheet
);
248 static float getCharacterSheetScale(const std::string
&sheet
);
249 static std::string
getSheetFamily(const std::string
&sheet
);
250 static std::string
getSheetName(uint32 sheetId
);
251 static sint32
getFameIndex(const std::string
&factionName
);
252 static std::string
getFameName(sint32 fameIndex
);
253 static sint32
getFameDBIndex(sint32 fameIndex
); // convert from the fame index
254 static sint32
getFirstTribeFameIndex(); // fame index of the 1st tribe
255 static sint32
getNbTribeFameIndex(); // number of tribe fame index (which are contiguous)
256 static std::string
getClientCfg(const std::string
&varName
);
257 static void sendMsgToServer(const std::string
&msgName
);
258 static void sendMsgToServerPvpTag(bool pvpTag
);
259 static void sendMsgToServerAutoPact(bool bval
);
260 static void sendMsgToServerUseItem(sint32 slot
);
261 static bool isGuildQuitAvailable();
262 static void sortGuildMembers();
263 static sint32
getNbGuildMembers();
264 static std::string
getGuildMemberName(sint32 nMemberId
);
265 static std::string
getGuildMemberGrade(sint32 nMemberId
);
266 static bool isR2Player(const std::string
&sheet
);
267 static std::string
getR2PlayerRace(const std::string
&sheet
);
268 static bool isR2PlayerMale(const std::string
&sheet
);
270 // TODO nico : using the reflection system on sheets would allow to export them to lua without these functions ...
271 static std::string
getCharacterSheetSkel(const std::string
&sheet
, bool isMale
);
272 static sint32
getSheetId(const std::string
&itemName
);
273 static sint
getCharacterSheetRegionForce(const std::string
&sheet
);
274 static sint
getCharacterSheetRegionLevel(const std::string
&sheet
);
275 static float setChar3dDBfromVPX(const std::string
&branch
, const std::string
&people
, const std::string
&vpa
, const std::string
&vpb
, const std::string
&vpc
);
276 static void setChar3dDBfromServerDB(const std::string
&branch
);
277 static float getRefHeightScale(const std::string
&people
, const std::string
&vpa
);
278 static std::string
getRegionByAlias(uint32 alias
);
279 static float getGroundZ(float x
, float y
);
280 static int getGroundAtMouse(CLuaState
&ls
);
281 static int moveCam(CLuaState
&ls
);
282 static int setCamMode(CLuaState
&ls
);
283 static int getMousePos(CLuaState
&ls
);
284 static int getMouseDown(CLuaState
&ls
);
285 static int getMouseMiddleDown(CLuaState
&ls
);
286 static int getMouseRightDown(CLuaState
&ls
);
287 static int getShapeIdAt(CLuaState
&ls
);
288 static int setupShape(CLuaState
&ls
);
289 static void setMouseCursor(const std::string
&texture
);
291 static int removeLandMarks(CLuaState
&ls
);
292 static int addLandMark(CLuaState
&ls
);
293 static int updateUserLandMarks(CLuaState
&ls
);
294 static int addRespawnPoint(CLuaState
&ls
);
295 static int delArkPoints(CLuaState
&ls
);
296 static int setArkPowoOptions(CLuaState
&ls
);
297 static int getActualMapZoom(CLuaState
&ls
);
298 static int setActualMapZoom(CLuaState
&ls
);
301 // open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly
302 // else, current command of the chat window will be replaced with tell 'player'
303 #ifdef RYZOM_LUA_UCSTRING
304 static void tell(const ucstring
&player
, const ucstring
&msg
);
306 static void tell(const std::string
&player
, const std::string
&msg
);
308 static bool isRingAccessPointInReach();
309 static void updateTooltipCoords();
310 // test if the ctrl key is down (NB nico : I didn't add other key,
311 // because it would be too easy to write a key recorder ...)
312 static bool isCtrlKeyDown();
313 #ifdef RYZOM_LUA_UCSTRING
314 static std::string
encodeURLUnicodeParam(const ucstring
&text
);
316 static std::string
encodeURLUnicodeParam(const std::string
&text
);
318 static std::string
encodeURLParam(const std::string
&text
);
320 static std::string
encodeToHexa(const std::string
&text
);
321 static std::string
decodeFromHexa(const std::string
&text
);
323 static sint32
getPlayerLevel(); // get max level among player skills (magi, combat, crafting ,foraging)
324 static std::string
getPlayerVpaHex();
325 static std::string
getPlayerVpbHex();
326 static std::string
getPlayerVpcHex();
327 static uint64
getPlayerVpa();
328 static uint64
getPlayerVpb();
329 static uint64
getPlayerVpc();
330 static sint32
getTargetLevel(); // get current, precise level of the selected target, or -1 if there's no such selected target
331 static sint32
getTargetForceRegion(); // get 'force region' for current target, or -1 if there's no selected target
332 static sint32
getTargetLevelForce(); // get 'level force' for current target, or -1 if there's no selected target
333 #ifdef RYZOM_LUA_UCSTRING
334 static ucstring
getTargetSheet(); // get the name of the target sheet (like 'zoha2old.creature')
336 static std::string
getTargetSheet(); // get the name of the target sheet (like 'zoha2old.creature')
338 static std::string
getTargetVpaHex();
339 static std::string
getTargetVpbHex();
340 static std::string
getTargetVpcHex();
341 static void updateVpa();
342 static uint64
getTargetVpa();
343 static uint64
getTargetVpb();
344 static uint64
getTargetVpc();
345 static bool isTargetNPC(); // return 'true' if the target is an npc
346 static bool isTargetPlayer(); // return 'true' if the target is a player
347 static bool isTargetUser(); // return 'true' if the target is the user
348 static bool isPlayerInPVPMode();
349 static bool isTargetInPVPMode();
351 // vertical and horizontal scrolling
352 // do not require element to be focused
353 static int scrollElement(CLuaState
&ls
); // return none (nil if error)
357 // Create a special tag that will add a 'goto' button for the given file and line
358 // The tag should be appended in front of a string to use with 'rawDebugInfo'.
359 // when the final string will be printed, a button will be created in front of it
360 // Requires that 'ClientCfg.LuaDebugInfoGotoButtonEnabled' is set to 1, else
361 // a, empty tag is returned
362 static std::string
createGotoFileButtonTag(const char *fileName
, uint line
);