1 -- In this file we define functions that serves for interaction windows
4 ------------------------------------------------------------------------------------------------------------
5 -- create the game namespace without reseting if already created in an other file.
10 ------------------------------------------------------------------------------------------------------------
11 -- called when server send an invitaion we receive a text id containing the string to display (invitor name)
12 function game
:onTeamInvation(textID
)
14 local ui
= getUI('ui:interface:join_team_proposal');
15 ui
.content
.inside
.invitor_name
.textid
= textID
;
22 ------------------------------------------------------------------------------------------------------------
24 function game
:teamInvitationAccept()
26 local ui
= getUI('ui:interface:join_team_proposal');
28 sendMsgToServer('TEAM:JOIN');
31 ------------------------------------------------------------------------------------------------------------
33 function game
:teamInvitationRefuse()
35 local ui
= getUI('ui:interface:join_team_proposal');
37 sendMsgToServer('TEAM:JOIN_PROPOSAL_DECLINE');
40 ------------------------------------------------------------------------------------------------------------
42 function game
:switchChatTab(dbEntry
)
43 local db
= 'UI:SAVE:ISENABLED:' .. dbEntry
;
44 local val
= getDbProp(db
);
53 ------------------------------------------------------------------------------------------------------------
55 function game
:updateEmoteMenu(prop
, tooltip
, tooltip_pushed
, name
, param
)
58 local text
= i18n
.get('uiTalkMemMsg0' .. i
);
59 local key
= runExpr( "getKey('talk_message','0" .. i
.. "',1)" );
61 if (key
~= nil and key
~= '') then
62 key
= ' @{T25}@{2F2F}(' .. key
.. ')';
63 text
= concatUCString(text
, key
);
66 -- if we don't do the full getUI, it doesn't work (don't understand why)
67 local uiQC
= getUI("ui:interface:user_chat_emote_menu:quick_chat:" .. "qc" .. i
);
68 uiQC
.uc_hardtext_format
= text
;
73 ------------------------------------------------------------------------------------------------------------
75 if (ui_free_chat_h
== nil) then
79 if (ui_free_chat_w
== nil) then
83 ------------------------------------------------------------------------------------------------------------
85 function game
:closeTellHeader(uiID
)
86 local ui
= getUI('ui:interface:' .. uiID
);
89 ui_free_chat_h
[uiID
] = ui
.h
;
90 ui_free_chat_w
[uiID
] = ui
.w
;
98 ------------------------------------------------------------------------------------------------------------
100 function game
:openTellHeader(uiID
)
101 local ui
= getUI('ui:interface:' .. uiID
);
104 -- set size from saved values
105 if (ui_free_chat_h
[uiID
] ~= nil) then
106 ui
.h
= ui_free_chat_h
[uiID
];
109 if (ui_free_chat_w
[uiID
] ~= nil) then
110 ui
.w
= ui_free_chat_w
[uiID
];
113 -- set Header Color to normal values (when a tell is closed and the telled player say someone, header change to "UI:SAVE:WIN:COLORS:INFOS")
114 ui
:setHeaderColor('UI:SAVE:WIN:COLORS:COM');
118 --/////////////////////////
119 --// TARGET WINDOW SETUP //
120 --/////////////////////////
122 -- local functions for tests
123 local function levelToForceRegion(level
)
126 elseif level
>= 250 then
129 return math
.floor(level
/ 50) + 2
133 local function levelToLevelForce(level
)
134 return math
.floor(math
.fmod(level
, 50) * 5 / 50) + 1
139 -- tmp var for tests in local mode
140 local twPlayerLevel
= 10
141 local twTargetLevel
= 19
142 local twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
143 local twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
144 local twTargetPlayer
= false
145 local twPlayerInPVPMode
= false
146 local twTargetInPVPMode
= false
149 -----------------------------------
150 local function twGetPlayerLevel()
151 if config
.Local
== 1 then
154 return getPlayerLevel()
158 -----------------------------------
159 local function twGetTargetLevel()
160 if config
.Local
== 1 then
163 return getTargetLevel()
167 -----------------------------------
168 local function twGetTargetForceRegion()
169 if config
.Local
== 1 then
170 return twTargetForceRegion
172 return getTargetForceRegion()
176 -----------------------------------
177 local function twGetTargetLevelForce()
178 if config
.Local
== 1 then
179 return twTargetLevelForce
181 return getTargetLevelForce()
185 -----------------------------------
186 local function twIsTargetPlayer()
187 if config
.Local
== 1 then
188 return twTargetPlayer
190 return isTargetPlayer()
194 -----------------------------------
195 local function twIsPlayerInPVPMode()
196 if config
.Local
== 1 then
197 return twPlayerInPVPMode
199 return isPlayerInPVPMode()
203 -----------------------------------
204 local function twIsTargetInPVPMode()
205 if config
.Local
== 1 then
206 return twTargetInPVPMode
208 return isTargetInPVPMode()
212 ----------------------
213 -- MISC local tests function
217 twTargetPlayer
= false
218 game
:updateTargetConsiderUI()
220 -- selection, not impossible
222 twTargetPlayer
= false
225 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
226 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
227 game
:updateTargetConsiderUI()
229 -- selection, not impossible (limit)
231 twTargetPlayer
= false
234 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
235 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
236 game
:updateTargetConsiderUI()
238 -- selection, impossible
240 twTargetPlayer
= false
243 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
244 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
245 game
:updateTargetConsiderUI()
249 -- selection, not impossible, named
251 twTargetPlayer
= false
254 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
255 twTargetLevelForce
= 6
256 game
:updateTargetConsiderUI()
258 -- selection, not impossible (limit), named
260 twTargetPlayer
= false
263 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
264 twTargetLevelForce
= 6
265 game
:updateTargetConsiderUI()
267 -- selection, impossible, named
269 twTargetPlayer
= false
272 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
273 twTargetLevelForce
= 6
274 game
:updateTargetConsiderUI()
278 -- selection, not impossible, boss
280 twTargetPlayer
= false
283 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
284 twTargetLevelForce
= 7
285 game
:updateTargetConsiderUI()
287 -- selection, not impossible (limit), boss
289 twTargetPlayer
= false
292 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
293 twTargetLevelForce
= 7
294 game
:updateTargetConsiderUI()
296 -- selection, impossible, boss
298 twTargetPlayer
= false
301 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
302 twTargetLevelForce
= 7
303 game
:updateTargetConsiderUI()
307 -- selection, not impossible, boss
309 twTargetPlayer
= false
312 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
313 twTargetLevelForce
= 8
314 game
:updateTargetConsiderUI()
316 -- selection, not impossible (limit), boss
318 twTargetPlayer
= false
321 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
322 twTargetLevelForce
= 8
323 game
:updateTargetConsiderUI()
325 -- selection, impossible, boss
327 twTargetPlayer
= false
330 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
331 twTargetLevelForce
= 8
332 game
:updateTargetConsiderUI()
335 ------ PLAYER SELECTION
336 ------ 2 players, no pvp
338 twTargetPlayer
= true
339 twPlayerInPVPMode
= false
340 twTargetInPVPMode
= false
344 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
345 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
346 game
:updateTargetConsiderUI()
350 twTargetPlayer
= true
351 twPlayerInPVPMode
= true
352 twTargetInPVPMode
= true
356 twTargetForceRegion
= levelToForceRegion(twTargetLevel
)
357 twTargetLevelForce
= levelToLevelForce(twTargetLevel
)
358 game
:updateTargetConsiderUI()
362 ------ 2 players, pvp
365 function twGroup(groupSize
)
367 if gm
< groupSize
then
368 setDbProp("SERVER:GROUP:" .. tostring(gm
) .. ":PRESENT", 1)
370 setDbProp("SERVER:GROUP:" .. tostring(gm
) .. ":PRESENT", 0)
375 ------------------------------------------------------------------------------------------------------------
377 function game
:closeWebIGBrowserHeader()
378 local ui
= getUI('ui:interface:webig');
381 ui_webig_browser_h
= ui
.h
;
382 ui_webig_browser_w
= ui
.w
;
384 -- reduce window size
390 ------------------------------------------------------------------------------------------------------------
392 function game
:openWebIGBrowserHeader()
393 local ui
= getUI('ui:interface:webig');
396 -- set size from saved values
397 if (ui_webig_browser_h
~= nil) then
398 ui
.h
= ui_webig_browser_h
;
401 if (ui_webig_browser_w
~= nil) then
402 ui
.w
= ui_webig_browser_w
;
405 ------------------------------------------------------------------------------------------------------------
407 ------------------------------------------------------------------------------------------------------------
408 --#############################
409 --###### Syphox's modlib ######
410 --#############################
411 if (package_path_native
== nil) then
412 package_path_native
= package
.path
;
414 package
.path
= package
.path
.. ';./user/syui/?.lua';
417 function isModuleAvailable(name
)
418 if(package
.loaded
[name
])then
421 for _
, searcher
in ipairs(package
.searchers
or package
.loaders
) do
422 local loader
= searcher(name
)
423 if(type(loader
) == 'function')then
424 package
.preload
[name
] = loader
432 if(isModuleAvailable("syui"))then
433 sy_ui
= require("syui")
436 function game
:showTargetPercent()
437 if(not sy_ui
.exist())then return end
439 sy_ui
.showTargetPercent()
442 function game
:newConsider()
443 if(not sy_ui
.exist())then return end
447 function game
:updateFPS()
448 if(not sy_ui
.exist())then return end
452 function game
:sysinfo(txt
, mtd
)
453 if(not sy_ui
.exist())then return end
454 sy_ui
.sysinfo(txt
, mtd
)
457 function game
:updateMemberCount()
458 if(not sy_ui
.exist())then return end
459 sy_ui
.updateMemberCount()
462 function game
:updateGLinvB()
463 if(not sy_ui
.exist())then return end
467 function game
:teamInviteFromGuild(uiID
)
468 if(not sy_ui
.exist())then return end
469 sy_ui
.teamInviteFromGuild(uiID
)
472 function game
:invToGuild(ply
)
473 if(not sy_ui
.exist())then return end
474 sy_ui
.invToGuild(ply
)
477 function game
:updateFLinvB(uiID
)
478 if(not sy_ui
.exist())then return end
479 sy_ui
.updateFLinvB(uiID
)
482 function game
:teamInvite(uiID
)
483 if(not sy_ui
.exist())then return end
484 sy_ui
.teamInvite(uiID
)
487 --#############################
488 --######## modlib end #########
489 --#############################
491 ------------------------------------------------------------------------------------------------------------
492 -- This function is called when a new target is selected, it should update the 'consider' widget
493 -- Level of the creature
494 -- Is its level known (not too high ...)
495 -- Boss/Mini-bosses/Names colored ring
496 function game
:updateTargetConsiderUI()
497 --debugInfo("Updating consider widget")
500 local targetWindow
= getUI("ui:interface:target")
502 local wgTargetSlotForce
= targetWindow
:find("slot_force")
503 local wgTargetLevel
= targetWindow
:find("target_level")
504 local wgImpossible
= targetWindow
:find("impossible")
505 local wgSlotRing
= targetWindow
:find("slot_ring")
506 local wgToolTip
= targetWindow
:find("target_tooltip")
507 local wgPvPTag
= targetWindow
:find("pvp_tags")
508 local wgHeader
= targetWindow
:find("header_opened")
510 wgTargetSlotForce
.active
= true
511 wgImpossible
.active
= true
514 if twGetTargetLevel() == -1 then
515 wgTargetSlotForce
.active
= false
516 wgTargetLevel
.active
= false
517 wgImpossible
.active
= false
518 wgSlotRing
.active
= false
519 if (isTargetUser() and twIsPlayerInPVPMode()) then
520 wgToolTip
.tooltip
= ""
521 wgPvPTag
.active
= true
524 wgPvPTag
.active
= false
526 wgToolTip
.tooltip
= i18n
.get("uittConsiderTargetNoSelection")
531 local pvpMode
= false
532 wgPvPTag
.active
= false
535 -- if the selection is a player, then both the local & targeted player must be in PVP mode for the level to be displayed
536 if (twIsTargetPlayer()) then
537 -- don't display anything ...
538 wgTargetSlotForce
.active
= false
539 wgTargetLevel
.active
= false
540 wgImpossible
.active
= false
541 wgSlotRing
.active
= false
542 wgToolTip
.tooltip
= ""
543 if twIsTargetInPVPMode() then
544 debugInfo("target in pvp")
545 wgPvPTag
.active
= true
546 wgHeader
.h
= 34; -- 56
551 -- load default code if syphox.lua is not available
552 if(not sy_ui
.exist())then
553 -- depending on the number of people in the group, set the max diff for visibility between player level
554 -- & creature level (x 10 per member)
555 local maxDiffLevel
= 10
557 -- exception there : when "pvping", don't relate the levelof the target to the level of the group, but to thelocal
560 if getDbProp("SERVER:GROUP:" .. tostring(gm
) .. ":PRESENT") ~= 0 then
561 maxDiffLevel
= maxDiffLevel
+ 10
566 debugInfo("Max diff level= " .. tostring(maxDiffLevel
))
568 local impossible
= (twGetTargetLevel() - twGetPlayerLevel() > maxDiffLevel
)
570 wgSlotRing
.active
= false
573 -- targeted object is too hard too beat, display a skull
574 wgTargetLevel
.active
= false
575 wgTargetLevelText
.active
= wgTargetLevel
.active
576 wgTargetLevelText
.hardtext
= ""
578 wgImpossible
.color
= "255 50 50 255"
580 -- player can see the level of the targeted creature
581 wgTargetLevel
.active
= true
582 wgTargetLevelText
.active
= wgTargetLevel
.active
584 wgTargetLevel
.hardtext
= tostring(twGetTargetLevel())
585 wgImpossible
.color
= "255 255 255 255"
586 wgTargetLevel
.color
= getDefine("region_force_" .. tostring(levelToForceRegion(twGetTargetLevel())))
587 wgTargetLevelText
.color
= wgTargetLevel
.color
588 wgTargetLevelText
.hardtext
= "LVL"
591 -- based on the 'level force', set a colored ring around the level
592 local levelForce
= twGetTargetLevelForce()
593 wgTargetSlotForce
.color
= getDefine("region_force_" .. tostring(levelToForceRegion(twGetTargetLevel())))
595 wgImpossible
.texture
= getDefine("force_level_" .. tostring(levelForce
))
596 wgImpossible
.active
= true
597 if levelForce
< 6 then
598 wgToolTip
.tooltip
= i18n
.get("uittConsiderTargetLevel")
599 elseif levelForce
== 6 then
601 wgImpossible
.color
= "117 132 126 255"
602 wgSlotRing
.color
= "117 132 126 255"
603 wgTargetSlotForce
.color
= "117 132 126 255"
604 wgSlotRing
.texture
= "consider_ring.tga"
605 wgToolTip
.tooltip
= i18n
.get("uittConsiderNamedOrMiniBoss")
606 elseif levelForce
== 7 then
608 wgImpossible
.color
= "156 98 65 255"
609 wgSlotRing
.color
= "156 98 65 255"
610 wgTargetSlotForce
.color
= "156 98 65 255"
611 wgSlotRing
.texture
= "consider_ring.tga"
612 wgToolTip
.tooltip
= i18n
.get("uittConsiderNamedOrMiniBoss")
613 elseif levelForce
== 8 then
615 wgImpossible
.color
= "213 212 9 255"
616 wgSlotRing
.texture
= "consider_ring.tga"
617 wgSlotRing
.color
= "213 212 9 255"
618 if isTargetNPC() then
619 wgTargetSlotForce
.color
= "255 255 255 255"
620 wgToolTip
.tooltip
= i18n
.get("uittConsiderBossNpc")
622 wgTargetSlotForce
.color
= "213 212 9 255"
623 wgToolTip
.tooltip
= i18n
.get("uittConsiderBoss")
628 wgToolTip
.tooltip
= concatUCString(wgToolTip
.tooltip
, ucstring("\n"), i18n
.get("uittConsiderUnknownLevel"))