Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / interface_v3 / lua_ihm_ryzom.h
blob501f5301f6f2e190ceebadc0c42f1003a3cafecc
1 #ifndef LUA_IHM_RYZOM_H
2 #define LUA_IHM_RYZOM_H
4 #include "nel/gui/lua_ihm.h"
6 using namespace NLGUI;
8 class CLuaIHMRyzom
10 public:
11 static void RegisterRyzomFunctions( CLuaState &ls );
13 private:
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.
20 public:
22 private:
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
42 // param 2 = text
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 breakPoint(CLuaState &ls);
52 static int i18n(CLuaState &ls); // retrieve an unicode string from CI18N
53 static int setTextFormatTaged(CLuaState &ls); // set a text that may contains Tag Format infos
54 static int validMessageBox(CLuaState &ls); // ok/cancel type message box (can't get it to work through luabind)
55 static int initEmotesMenu(CLuaState &ls);
56 static int hideAllWindows(CLuaState &ls);
57 static int hideAllNonSavableWindows(CLuaState &ls);
58 static int getDesktopIndex(CLuaState &ls);
59 static int setLuaBreakPoint(CLuaState &ls); // set a breakpoint in lua external debugger (file, line)
60 static int getMainPageURL(CLuaState &ls);
61 static int getCharSlot(CLuaState &ls);
62 static int displaySystemInfo(CLuaState &ls);
63 static int displayChatMessage(CLuaState &ls);
64 static int setWeatherValue(CLuaState &ls); // first value is a boolean to say automatic, second value ranges from of to 1 and gives the weather
65 static int getWeatherValue(CLuaState &ls); // get current real weather value (blend between server driven value & predicted value). Manual weather value is ignored
66 static int disableContextHelpForControl(CLuaState &ls); // params: CCtrlBase*. return: none
67 static int disableContextHelp(CLuaState &ls);
68 static int getServerSeason(CLuaState &ls); // get the last season sent by the server
69 // 0->auto, computed locally from the current day (or not received from server yet)
70 // 1->server force spring
71 // 2->' ' ' summer
72 // 3->' ' ' autumn
73 // 4->' ' ' winter
74 static int computeCurrSeason(CLuaState &ls); // compute current displayed season (1->spring, etc .)
75 static int getAutoSeason(CLuaState &ls); // compute automatic season that would be at this time (1->spring, etc .)
78 static int enableModalWindow(CLuaState &ls);
79 static int getPlayerPos(CLuaState &ls);
80 static int getPlayerFront(CLuaState &ls);
81 static int getPlayerDirection(CLuaState &ls);
82 static int getPlayerGender(CLuaState &ls);
83 static int getPlayerName(CLuaState &ls);
84 static int getPlayerTitleRaw(CLuaState &ls);
85 static int getPlayerTitle(CLuaState &ls);
86 static int getTargetPos(CLuaState &ls);
87 static int getTargetFront(CLuaState &ls);
88 static int getTargetDirection(CLuaState &ls);
89 static int getTargetGender(CLuaState &ls);
90 static int getTargetName(CLuaState &ls);
91 static int getTargetTitleRaw(CLuaState &ls);
92 static int getTargetTitle(CLuaState &ls);
93 static int addSearchPathUser(CLuaState &ls);
94 static int getClientCfgVar(CLuaState &ls);
95 static int isPlayerFreeTrial(CLuaState &ls);
96 static int isPlayerNewbie(CLuaState &ls);
97 static int isInRingMode(CLuaState &ls);
98 static int getUserRace(CLuaState &ls);
99 static int getSheet2idx(CLuaState &ls);
100 static int getTargetSlot(CLuaState &ls);
101 static int setTargetAsInterlocutor(CLuaState &ls);
102 static int unsetTargetAsInterlocutor(CLuaState &ls);
103 static int getSlotDataSetId(CLuaState &ls);
105 static int getMaxDynChan(CLuaState &ls);
106 static int readUserChannels(CLuaState &ls);
107 static int saveUserChannels(CLuaState &ls); // { name = "pass" }
109 // LUA functions exported for Dev only (debug)
110 static int dumpUI(CLuaState &ls); // params: CInterfaceElement*.... return: none
111 static int setKeyboardContext(CLuaState &ls);
113 static int getCompleteIslands(CLuaState &ls);
114 static int getIslandId(CLuaState &ls);//TEMP
116 static int addShape(CLuaState &ls);
117 static int moveShape(CLuaState &ls);
118 static int rotateShape(CLuaState &ls);
119 static int getShapePos(CLuaState &ls);
120 static int getShapeScale(CLuaState &ls);
121 static int getShapeRot(CLuaState &ls);
122 static int getShapeColPos(CLuaState &ls);
123 static int getShapeColScale(CLuaState &ls);
124 static int getShapeColOrient(CLuaState &ls);
125 static int deleteShape(CLuaState &ls);
127 ///////////////////////////// Standard Lua stuff ends here //////////////////////////////////////////////
129 static sint32 getDbProp(const std::string &dbProp); // return 0 if not found.
130 static sint64 getDbProp64(const std::string &dbProp); // return 0 if not found.
131 static void setDbProp(const std::string &dbProp, sint32 value); // Nb: the db prop is not created if not present.
132 static void setDbProp64(const std::string &dbProp, sint64 value); // Nb: the db prop is not created if not present.
133 static void addDbProp(const std::string &dbProp, sint32 value); // Nb: the db prop is created if not present.
134 static void delDbProp(const std::string &dbProp);
135 static void setDbRGBA(const std::string &dbProp, const NLMISC::CRGBA &color); // the db prop is created if not present
136 static std::string getDbRGBA(const std::string &dbProp); // empty string if not found
138 public:
139 // Print a message in the log.
140 // Lua messages must be enabled (with ClientCfg.DisplayLuaDebugInfo = 1)
141 // Additionnally, if ClientCfg.LuaDebugInfoGotoButtonEnabled is set, then
142 // a button will be created near the line to allow to goto the lua line that issued the message
143 // by using an external editor
144 static void debugInfo(const std::string &dbg);
145 // Print a message in the log
146 // No 'goto file' button is created
147 // Lua messages must be enabled (with ClientCfg.DisplayLuaDebugInfo = 1)
149 static void dumpCallStack(int startStackLevel = 0);
151 /** execute function that is currently on the stack, possibly outputing error messages to the log
152 * \return true if execution succeeded
154 static bool executeFunctionOnStack(CLuaState &ls, int numArgs, int numRet);
156 private:
157 static void rawDebugInfo(const std::string &dbg);
158 // Dump callstack in the console
159 // Additionnally, if ClientCfg.LuaDebugInfoGotoButtonEnabled is set, then
160 // buttons will be created in front of each line to allow to go to the lua line that issued the message
161 // by using an external editor
163 static void getCallStackAsString(int startStackLevel, std::string &result);
164 static std::string getDefine(const std::string &def);
165 #ifdef RYZOM_LUA_UCSTRING
166 static void setContextHelpText(const ucstring &text);
167 #else
168 static void setContextHelpText(const std::string &text);
169 #endif
172 #ifdef RYZOM_LUA_UCSTRING
173 static void messageBox(const ucstring &text);
174 static void messageBox(const ucstring &text, const std::string &masterGroup);
175 static void messageBox(const ucstring &text, const std::string &masterGroup, int caseMode);
176 #endif
177 static void messageBox(const std::string &text);
178 static void messageBox(const std::string &text, const std::string &masterGroup);
179 static void messageBox(const std::string &text, const std::string &masterGroup, int caseMode);
180 #ifdef RYZOM_LUA_UCSTRING
181 static void messageBoxWithHelp(const ucstring &text);
182 static void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup);
183 static void messageBoxWithHelp(const ucstring &text, const std::string &masterGroup, int caseMode);
184 #endif
185 static void messageBoxWithHelp(const std::string &text);
186 static void messageBoxWithHelp(const std::string &text, const std::string &masterGroup);
187 static void messageBoxWithHelp(const std::string &text, const std::string &masterGroup, int caseMode);
189 #ifdef RYZOM_LUA_UCSTRING
190 static ucstring replacePvpEffectParam(const ucstring &str, sint32 parameter); // TODO: UTF-8 Lua
191 #else
192 static std::string replacePvpEffectParam(const std::string &str, sint32 parameter); // TODO: UTF-8 Lua
193 #endif
194 static sint32 secondsSince1970ToHour(sint32 seconds);
195 #ifdef RYZOM_BG_DOWNLOADER
196 static void pauseBGDownloader();
197 static void unpauseBGDownloader();
198 static void requestBGDownloaderPriority(uint priority);
199 static sint getBGDownloaderPriority();
200 #endif
201 static void loadBackground(const std::string &bg);
202 #ifdef RYZOM_LUA_UCSTRING
203 static ucstring getPatchLastErrorMessage();
204 #else
205 static std::string getPatchLastErrorMessage();
206 #endif
207 static bool isInGame();
208 static uint32 getPlayerSelectedSlot();
209 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
211 // GameInfo
212 static ucstring getSheetLocalizedName(const std::string &sheet);
213 static ucstring getSheetLocalizedDesc(const std::string &sheet);
214 static sint32 getSkillIdFromName(const std::string &def);
215 #ifdef RYZOM_LUA_UCSTRING
216 static ucstring getSkillLocalizedName(sint32 skillId);
217 #else
218 static std::string getSkillLocalizedName(sint32 skillId);
219 #endif
220 static sint32 getMaxSkillValue(sint32 skillId);
221 static sint32 getBaseSkillValueMaxChildren(sint32 skillId);
222 static sint32 getMagicResistChance(bool elementalSpell, sint32 casterSpellLvl, sint32 victimResistLvl);
223 static sint32 getDodgeParryChance(sint32 attLvl, sint32 defLvl);
224 static void browseNpcWebPage(const std::string &htmlId, const std::string &url, bool addParameters, double timeout);
225 static void clearHtmlUndoRedo(const std::string &htmlId);
226 #ifdef RYZOM_LUA_UCSTRING
227 static ucstring getDynString(sint32 dynStringId);
228 #else
229 static std::string getDynString(sint32 dynStringId);
230 #endif
231 static bool isDynStringAvailable(sint32 dynStringId);
232 static bool isFullyPatched();
233 static std::string getSheetType(const std::string &sheet);
234 static std::string getSheetFamily(const std::string &sheet);
235 static std::string getSheetName(uint32 sheetId);
236 static sint32 getFameIndex(const std::string &factionName);
237 static std::string getFameName(sint32 fameIndex);
238 static sint32 getFameDBIndex(sint32 fameIndex); // convert from the fame index
239 static sint32 getFirstTribeFameIndex(); // fame index of the 1st tribe
240 static sint32 getNbTribeFameIndex(); // number of tribe fame index (which are contiguous)
241 static std::string getClientCfg(const std::string &varName);
242 static void sendMsgToServer(const std::string &msgName);
243 static void sendMsgToServerPvpTag(bool pvpTag);
244 static void sendMsgToServerAutoPact(bool bval);
245 static void sendMsgToServerUseItem(sint32 slot);
246 static bool isGuildQuitAvailable();
247 static void sortGuildMembers();
248 static sint32 getNbGuildMembers();
249 static std::string getGuildMemberName(sint32 nMemberId);
250 static std::string getGuildMemberGrade(sint32 nMemberId);
251 static bool isR2Player(const std::string &sheet);
252 static std::string getR2PlayerRace(const std::string &sheet);
253 static bool isR2PlayerMale(const std::string &sheet);
254 // sheet access
255 // TODO nico : using the reflection system on sheets would allow to export them to lua without these functions ...
256 static std::string getCharacterSheetSkel(const std::string &sheet, bool isMale);
257 static sint32 getSheetId(const std::string &itemName);
258 static sint getCharacterSheetRegionForce(const std::string &sheet);
259 static sint getCharacterSheetRegionLevel(const std::string &sheet);
260 static std::string getRegionByAlias(uint32 alias);
261 static float getGroundZ(float x, float y);
262 static int getGroundAtMouse(CLuaState &ls);
263 static int getMousePos(CLuaState &ls);
264 static int getMouseDown(CLuaState &ls);
265 static int getMouseMiddleDown(CLuaState &ls);
266 static int getMouseRightDown(CLuaState &ls);
267 static int getShapeIdAt(CLuaState &ls);
268 static int setupShape(CLuaState &ls);
269 static void setMouseCursor(const std::string &texture);
271 static int removeLandMarks(CLuaState &ls);
272 static int addLandMark(CLuaState &ls);
273 static int updateUserLandMarks(CLuaState &ls);
274 static int addRespawnPoint(CLuaState &ls);
275 static int delArkPoints(CLuaState &ls);
276 static int setArkPowoOptions(CLuaState &ls);
279 // open the window to do a tell to 'player', if 'msg' is not empty, then the message will be sent immediatly
280 // else, current command of the chat window will be replaced with tell 'player'
281 #ifdef RYZOM_LUA_UCSTRING
282 static void tell(const ucstring &player, const ucstring &msg);
283 #else
284 static void tell(const std::string &player, const std::string &msg);
285 #endif
286 static bool isRingAccessPointInReach();
287 static void updateTooltipCoords();
288 // test if the ctrl key is down (NB nico : I didn't add other key,
289 // because it would be too easy to write a key recorder ...)
290 static bool isCtrlKeyDown();
291 #ifdef RYZOM_LUA_UCSTRING
292 static std::string encodeURLUnicodeParam(const ucstring &text);
293 #else
294 static std::string encodeURLUnicodeParam(const std::string &text);
295 #endif
297 static sint32 getPlayerLevel(); // get max level among player skills (magi, combat, crafting ,foraging)
298 static sint64 getPlayerVpa();
299 static sint64 getPlayerVpb();
300 static sint64 getPlayerVpc();
301 static sint32 getTargetLevel(); // get current, precise level of the selected target, or -1 if there's no such selected target
302 static sint32 getTargetForceRegion(); // get 'force region' for current target, or -1 if there's no selected target
303 static sint32 getTargetLevelForce(); // get 'level force' for current target, or -1 if there's no selected target
304 #ifdef RYZOM_LUA_UCSTRING
305 static ucstring getTargetSheet(); // get the name of the target sheet (like 'zoha2old.creature')
306 #else
307 static std::string getTargetSheet(); // get the name of the target sheet (like 'zoha2old.creature')
308 #endif
309 static sint64 getTargetVpa();
310 static sint64 getTargetVpb();
311 static sint64 getTargetVpc();
312 static bool isTargetNPC(); // return 'true' if the target is an npc
313 static bool isTargetPlayer(); // return 'true' if the target is a player
314 static bool isTargetUser(); // return 'true' if the target is the user
315 static bool isPlayerInPVPMode();
316 static bool isTargetInPVPMode();
318 // vertical and horizontal scrolling
319 // do not require element to be focused
320 static int scrollElement(CLuaState &ls); // return none (nil if error)
322 public:
324 // Create a special tag that will add a 'goto' button for the given file and line
325 // The tag should be appended in front of a string to use with 'rawDebugInfo'.
326 // when the final string will be printed, a button will be created in front of it
327 // Requires that 'ClientCfg.LuaDebugInfoGotoButtonEnabled' is set to 1, else
328 // a, empty tag is returned
329 static std::string createGotoFileButtonTag(const char *fileName, uint line);
332 #endif