2016-05-06 10:56:20 +00:00
|
|
|
-- In this file we define functions that serves for info player windows
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
-- create the game namespace without reseting if already created in an other file.
|
|
|
|
if (game==nil) then
|
|
|
|
game= {};
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- Index of the mission slected during the last session (read from the config file)
|
|
|
|
game.PrevSessionMission = - 1
|
|
|
|
|
|
|
|
|
|
|
|
-- flag set to true when the in game db has been initialized
|
|
|
|
game.InGameDbInitialized = false
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
-- MAGIC DAMAGE PROTECTIONS
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
-- From DB, compute the Total Max Magic Absorption, and store in local DB
|
|
|
|
function game:computeMagicProtectTotalAbsorb()
|
|
|
|
|
|
|
|
-- *** pre compute the table of DB props (if not done)
|
|
|
|
if (self.JewelDBs == nil) then
|
|
|
|
local defList= {
|
|
|
|
'headdress',
|
|
|
|
'earl',
|
|
|
|
'earr',
|
|
|
|
'necklace',
|
|
|
|
'wristl',
|
|
|
|
'wristr',
|
|
|
|
'fingerl',
|
|
|
|
'fingerr',
|
|
|
|
'anklel',
|
|
|
|
'ankler',
|
|
|
|
};
|
|
|
|
|
|
|
|
self.JewelDBs= {};
|
|
|
|
for k,v in pairs(defList) do
|
|
|
|
self.JewelDBs[k]= getDefine(v) .. ':INDEX_IN_BAG';
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- *** for each jewel, add the magic protection
|
|
|
|
local protectFactor= getDbProp(formatUI('%player_protect_absorbfactor'));
|
|
|
|
local totalProtect= 0;
|
|
|
|
for k,dbJewel in pairs(self.JewelDBs) do
|
|
|
|
-- if the index in bag is not null (ie something present)
|
|
|
|
local indexInBag= getDbProp(dbJewel);
|
|
|
|
if (indexInBag>0) then
|
|
|
|
-- real index in bag is -1
|
|
|
|
indexInBag= indexInBag-1;
|
|
|
|
-- check the sheetId is correct
|
|
|
|
local dbSheet= formatUI('%bag:#1:SHEET', indexInBag);
|
|
|
|
if (getDbProp(dbSheet)~=0) then
|
|
|
|
local protect= getDbProp(formatUI('%bag:#1:QUALITY', indexInBag));
|
|
|
|
-- mul by factor, and add to total protection
|
|
|
|
protect= math.floor(protect * protectFactor / 100);
|
|
|
|
totalProtect= totalProtect + protect;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- *** additionaly, must add the max skill of player (mul by factor)
|
|
|
|
local protect= 0;
|
|
|
|
protect= math.max(protect, getBaseSkillValueMaxChildren(getSkillIdFromName('SF')) );
|
|
|
|
protect= math.max(protect, getBaseSkillValueMaxChildren(getSkillIdFromName('SM')) );
|
|
|
|
protect= math.max(protect, getBaseSkillValueMaxChildren(getSkillIdFromName('SC')) );
|
|
|
|
protect= math.max(protect, getBaseSkillValueMaxChildren(getSkillIdFromName('SH')) );
|
|
|
|
protect= math.floor(protect * protectFactor / 100);
|
|
|
|
totalProtect= totalProtect + protect;
|
|
|
|
|
|
|
|
|
|
|
|
-- *** store result
|
|
|
|
setDbProp('UI:VARIABLES:TOTAL_MAGIC_ABSORB', totalProtect);
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
-- From given DBs, compute the 'Magic protection' tooltip to display
|
|
|
|
function game:tooltipMagicProtect(dbVal, ttFormat)
|
|
|
|
local fmt= i18n.get(ttFormat);
|
|
|
|
|
|
|
|
-- get the current and max value. minimize the value displayed
|
|
|
|
local val= getDbProp(dbVal);
|
|
|
|
local vMax= getDbProp(formatUI('%player_protect_maxratio'));
|
|
|
|
val= math.min(val, vMax);
|
|
|
|
|
|
|
|
-- replace value
|
|
|
|
fmt= findReplaceAll(fmt, "%v", tostring(val) );
|
|
|
|
|
|
|
|
-- replace max text
|
|
|
|
if (val>=vMax) then
|
|
|
|
fmt= findReplaceAll(fmt, "%max", i18n.get('uittProtect_MaxReached') );
|
|
|
|
else
|
|
|
|
fmt= findReplaceAll(fmt, "%max", "" );
|
|
|
|
end
|
|
|
|
|
|
|
|
-- set the tooltip in InterfaceManager
|
|
|
|
setContextHelpText(fmt);
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:displayMagicProtect(dbVal)
|
|
|
|
-- get values. minimize the value displayed
|
|
|
|
local val= getDbProp(dbVal);
|
|
|
|
local vMax= getDbProp(formatUI('%player_protect_maxratio'));
|
|
|
|
val= math.min(val, vMax);
|
|
|
|
|
|
|
|
-- get the ui text
|
|
|
|
local ui= getUICaller();
|
|
|
|
local uiText= ui.val;
|
|
|
|
|
|
|
|
-- set the text (percentage)
|
|
|
|
uiText.uc_hardtext= tostring(val) .. "%";
|
|
|
|
|
|
|
|
-- set color and global color according to maximum reached or not
|
|
|
|
if(val >= vMax) then
|
|
|
|
uiText.color= '255 240 130 255';
|
|
|
|
uiText.global_color= false;
|
|
|
|
else
|
|
|
|
uiText.color= '255 255 255 255';
|
|
|
|
uiText.global_color= true;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
-- MAGIC RESISTANCES
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
-- Compute the current Base Resist (nb maybe negative)
|
|
|
|
function game:getMagicResistBaseLevel()
|
|
|
|
-- its just the max beetween SF, SM and SH/2
|
|
|
|
local vSF= getBaseSkillValueMaxChildren(getSkillIdFromName('SF'));
|
|
|
|
local vSM= getBaseSkillValueMaxChildren(getSkillIdFromName('SM'));
|
|
|
|
local vSH= getBaseSkillValueMaxChildren(getSkillIdFromName('SH'));
|
|
|
|
local val= math.max(vSF, vSM);
|
|
|
|
val= math.max(val, math.floor(vSH/2));
|
|
|
|
-- Yoyo: -25 is an EGS variable. Hardcoded for now
|
|
|
|
val= val-25;
|
|
|
|
return val;
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
-- Compute the current Max Resist
|
|
|
|
function game:getMagicResistMaxLevel()
|
2016-10-14 16:29:29 +00:00
|
|
|
local mlvl= 25 + self:getMagicResistBaseLevel() + getDbProp(formatUI('%player_resist_maxratio'));
|
2016-05-06 10:56:20 +00:00
|
|
|
return math.max(0,mlvl);
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
-- From given DBs, compute the 'Magic Resistance' tooltip to display
|
|
|
|
function game:tooltipMagicResist(dbVal, ttFormat)
|
|
|
|
local fmt= i18n.get(ttFormat);
|
|
|
|
|
|
|
|
-- get the current and max value. minimize the value displayed
|
|
|
|
local val= getDbProp(dbVal);
|
|
|
|
local vMax= self:getMagicResistMaxLevel();
|
|
|
|
val= math.min(val, vMax);
|
|
|
|
|
|
|
|
-- replace value
|
|
|
|
fmt= findReplaceAll(fmt, "%v", tostring(val) );
|
|
|
|
|
|
|
|
-- replace max text
|
|
|
|
if (val>=vMax) then
|
|
|
|
fmt= findReplaceAll(fmt, "%max", i18n.get('uittResist_MaxReached') );
|
|
|
|
else
|
|
|
|
fmt= findReplaceAll(fmt, "%max", "" );
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Print Chances to resist agst Elemental spells
|
|
|
|
local casterSpellLvl= self:getMagicResistBaseLevel(); -- choose the skill base level for reference, +25
|
|
|
|
casterSpellLvl= casterSpellLvl+25;
|
|
|
|
casterSpellLvl= math.max(casterSpellLvl, 0);
|
|
|
|
fmt= findReplaceAll(fmt, "%eml", tostring(casterSpellLvl));
|
|
|
|
fmt= findReplaceAll(fmt, "%emr", tostring(getMagicResistChance(true, casterSpellLvl, val)));
|
|
|
|
|
|
|
|
-- Print Chances to resist against Afflliction spells
|
|
|
|
fmt= findReplaceAll(fmt, "%aml", tostring(casterSpellLvl));
|
|
|
|
fmt= findReplaceAll(fmt, "%amr", tostring(getMagicResistChance(false, casterSpellLvl, val)));
|
|
|
|
|
|
|
|
|
|
|
|
-- set the tooltip in InterfaceManager
|
|
|
|
setContextHelpText(fmt);
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:displayMagicResist(dbVal)
|
|
|
|
-- get values. minimize the value displayed
|
|
|
|
local val= getDbProp(dbVal);
|
|
|
|
local vMax= self:getMagicResistMaxLevel();
|
|
|
|
val= math.min(val, vMax);
|
|
|
|
|
|
|
|
-- get the ui text
|
|
|
|
local ui= getUICaller();
|
|
|
|
local uiText= ui.val;
|
|
|
|
|
|
|
|
-- set the text (final value)
|
|
|
|
uiText.uc_hardtext= tostring(val);
|
|
|
|
|
|
|
|
-- set color and global color according to maximum reached or not
|
|
|
|
if(val >= vMax) then
|
|
|
|
uiText.color= '255 240 130 255';
|
|
|
|
uiText.global_color= false;
|
|
|
|
else
|
|
|
|
uiText.color= '255 255 255 255';
|
|
|
|
uiText.global_color= true;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
-- NPC WEB BROWSER
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:initNpcWebPageData()
|
|
|
|
if(self.NpcWebPage==nil) then
|
|
|
|
self.NpcWebPage= {};
|
|
|
|
self.NpcWebPage.UrlTextId= 0;
|
|
|
|
self.NpcWebPage.BrowseDone= false;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- TMP TMP for test
|
|
|
|
NicoMagicURL = ""
|
|
|
|
--function nicoTest()
|
|
|
|
-- runCommand("db", "LOCAL:TARGET:CONTEXT_MENU:WEB_PAGE_URL", 45678)
|
|
|
|
-- end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:onDrawNpcWebPage()
|
|
|
|
|
|
|
|
self:initNpcWebPageData();
|
|
|
|
|
|
|
|
-- if the browse has already been done
|
|
|
|
if(self.NpcWebPage.BrowseDone) then
|
|
|
|
return;
|
|
|
|
end
|
|
|
|
|
|
|
|
-- browse when the url string id is ready
|
|
|
|
if(self.NpcWebPage.UrlTextId ~=0) then
|
|
|
|
local available
|
|
|
|
if config.Local == 1 then
|
|
|
|
available = (NicoMagicURL ~= "")
|
2017-03-24 14:12:18 +00:00
|
|
|
else
|
|
|
|
available = isDynStringAvailable(self.NpcWebPage.UrlTextId)
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
2017-03-24 14:12:18 +00:00
|
|
|
if(available) then
|
2016-05-06 10:56:20 +00:00
|
|
|
local ucUrl
|
|
|
|
if config.Local == 1 then
|
2017-03-24 14:12:18 +00:00
|
|
|
ucUrl = ucstring(NicoMagicURL) -- for test in local mode
|
2016-05-06 10:56:20 +00:00
|
|
|
else
|
|
|
|
ucUrl = getDynString(self.NpcWebPage.UrlTextId);
|
|
|
|
end
|
|
|
|
-- browse
|
|
|
|
local uiStr= getUIId(getUICaller());
|
2017-03-24 14:12:18 +00:00
|
|
|
-- if the url
|
2016-05-06 10:56:20 +00:00
|
|
|
local utf8Url = ucUrl:toUtf8()
|
2017-03-24 14:12:18 +00:00
|
|
|
local isRing = string.find(utf8Url, "ring_access_point=1") ~= nil
|
2016-05-06 10:56:20 +00:00
|
|
|
if isRing then
|
|
|
|
getUI("ui:interface:npc_web_browser").active = false
|
|
|
|
runAH(nil, "context_ring_sessions", "")
|
|
|
|
return
|
|
|
|
else
|
2017-03-24 14:12:18 +00:00
|
|
|
local hideWindow = string.find(utf8Url, "_hideWindow=1") ~= nil
|
2016-05-06 10:56:20 +00:00
|
|
|
if hideWindow then
|
|
|
|
getUI("ui:interface:npc_web_browser").active = false
|
|
|
|
end
|
|
|
|
self.NpcWebPage.BrowseDone= true;
|
|
|
|
browseNpcWebPage(uiStr, utf8Url, true, 10); -- 'true' is for 'add parameters' here. 10 is standard timeout
|
|
|
|
end
|
|
|
|
-- clear undo/redo, to cannot undo to the "please wait" page :)
|
|
|
|
clearHtmlUndoRedo(uiStr);
|
|
|
|
-- if this is a ring window, then only the refresh button to access to filter will be available
|
|
|
|
local isRing = string.find(utf8Url, "ring_access_point=1") ~= nil
|
|
|
|
local browser = getUI("ui:interface:npc_web_browser")
|
|
|
|
browser:find("browse_redo").active = true
|
|
|
|
browser:find("browse_undo").active = true
|
|
|
|
browser:find("browse_refresh").active = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:initNpcWebPage()
|
|
|
|
local ui= getUICaller();
|
|
|
|
if(ui~=nil) then
|
|
|
|
setOnDraw(ui, "game:onDrawNpcWebPage()");
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:startNpcWebPage()
|
|
|
|
self:initNpcWebPageData();
|
|
|
|
|
|
|
|
-- set the new page to explore.
|
|
|
|
-- NB: must backup the Database, because don't want that the page change when clicking an other NPC
|
|
|
|
self.NpcWebPage.UrlTextId= getDbProp('LOCAL:TARGET:CONTEXT_MENU:WEB_PAGE_URL');
|
|
|
|
self.NpcWebPage.BrowseDone= false;
|
|
|
|
|
|
|
|
-- reset the page (empty url) and undo / redo
|
|
|
|
runAH(nil, "browse", "name=ui:interface:npc_web_browser:content:html|url=release_wk.html|localize=1");
|
|
|
|
clearHtmlUndoRedo("ui:interface:npc_web_browser:content:html");
|
|
|
|
local ui= getUI("ui:interface:npc_web_browser");
|
|
|
|
if(ui~=nil) then
|
|
|
|
ui.active= true;
|
|
|
|
end
|
|
|
|
ui:find("browse_redo").active = false
|
|
|
|
ui:find("browse_undo").active = false
|
|
|
|
ui:find("browse_refresh").active = false
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
--
|
2016-05-06 10:56:20 +00:00
|
|
|
function game:closeNpcWebBrowserHeader()
|
|
|
|
local ui = getUI('ui:interface:npc_web_browser');
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
-- save size
|
|
|
|
ui_npc_web_browser_h = ui.h;
|
|
|
|
ui_npc_web_browser_w = ui.w;
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
-- reduce window size
|
|
|
|
ui.pop_min_h = 32;
|
|
|
|
ui.h = 0;
|
|
|
|
ui.w = 150;
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
--
|
2016-05-06 10:56:20 +00:00
|
|
|
function game:openNpcWebBrowserHeader()
|
|
|
|
local ui = getUI('ui:interface:npc_web_browser');
|
|
|
|
ui.pop_min_h = 96;
|
|
|
|
|
|
|
|
-- set size from saved values
|
|
|
|
if (ui_npc_web_browser_h ~= nil) then
|
|
|
|
ui.h = ui_npc_web_browser_h;
|
|
|
|
end
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
if (ui_npc_web_browser_w ~= nil) then
|
|
|
|
ui.w = ui_npc_web_browser_w;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
-- FAME
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:initFamePos()
|
|
|
|
local ui = getUICaller();
|
|
|
|
|
|
|
|
-- assign good bar with good text
|
|
|
|
|
|
|
|
local uiList = { 'fyros', 'matis', 'tryker', 'zorai', 'kami', 'karavan' };
|
|
|
|
|
|
|
|
for k,v in pairs(uiList) do
|
|
|
|
-- get ui text
|
|
|
|
local uiTextRef = getUI(getUIId(ui) .. ':' .. v);
|
|
|
|
local fameIdx = getFameDBIndex(getFameIndex(v));
|
|
|
|
-- put bar in front of it
|
|
|
|
if (fameIdx >= 0) and (fameIdx <= 5) then
|
|
|
|
local uiBar = getUI(getUIId(ui) .. ':fb' .. fameIdx);
|
|
|
|
uiBar.y = uiTextRef.y - uiTextRef.h / 2 + uiBar.h / 2;
|
|
|
|
else
|
|
|
|
debugInfo('Error init fame bar pos for ' .. v);
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:initFameTribe()
|
|
|
|
local ui = getUICaller();
|
|
|
|
|
|
|
|
local firstIdx = getFirstTribeFameIndex();
|
|
|
|
local firstDBIdx = getFameDBIndex(firstIdx);
|
|
|
|
local nbFame = getNbTribeFameIndex();
|
|
|
|
|
|
|
|
for c = 1,nbFame do
|
|
|
|
local lineIdx = getFameDBIndex(firstIdx+c-1) - firstDBIdx;
|
|
|
|
local uiLine = getUI(getUIId(ui) .. ':list:line' .. lineIdx);
|
|
|
|
uiLine.t.hardtext = 'uiFame_' .. getFameName(firstIdx+c-1);
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:updateFameBar(path)
|
|
|
|
local thresholdKOS = getDbProp('SERVER:FAME:THRESHOLD_KOS');
|
|
|
|
local thresholdTrade = getDbProp('SERVER:FAME:THRESHOLD_TRADE');
|
|
|
|
local fameValue = getDbProp(path .. ':VALUE');
|
|
|
|
local fameMax = getDbProp(path .. ':THRESHOLD');
|
|
|
|
|
|
|
|
if (thresholdKOS < -100) then thresholdKOS = -100; end
|
|
|
|
if (thresholdKOS > 100) then thresholdKOS = 100; end
|
|
|
|
if (thresholdTrade < -100) then thresholdTrade = -100; end
|
|
|
|
if (thresholdTrade > 100) then thresholdTrade = 100; end
|
|
|
|
if (fameValue < -100) then fameValue = -100; end
|
|
|
|
if (fameValue > 100) then fameValue = 100; end
|
|
|
|
if (fameMax < -100) then fameMax = -100; end
|
|
|
|
if (fameMax > 100) then fameMax = 100; end
|
|
|
|
|
|
|
|
if (thresholdKOS > thresholdTrade) then thresholdKOS = thresholdTrade; end
|
|
|
|
if (fameValue > fameMax) then fameValue = fameMax; end
|
|
|
|
|
|
|
|
local ui = getUICaller();
|
|
|
|
local uiPart0 = ui.p0;
|
|
|
|
local uiPart1 = ui.p1;
|
|
|
|
local uiPart2 = ui.p2;
|
|
|
|
local uiPart3 = ui.p3;
|
|
|
|
local uiPart4 = ui.p4;
|
|
|
|
local uiBar3d = ui.bar3d;
|
|
|
|
-- part 4 is there to fill in the hole
|
|
|
|
|
|
|
|
local barW = ui.w - 4;
|
|
|
|
local barX = 2;
|
|
|
|
|
|
|
|
local bar3dStart= barX + barW/2;
|
|
|
|
local bar3dLimit= bar3dStart;
|
|
|
|
|
|
|
|
-- init part 0 of the bar
|
|
|
|
uiPart0.x = barX;
|
|
|
|
ui.ttp0.x = barX;
|
|
|
|
ui.ttp0.w = barW * (thresholdKOS + 100) / 200;
|
|
|
|
if (fameValue >= -100) and (fameValue <= thresholdKOS) then
|
|
|
|
uiPart0.color = '80 0 0 255';
|
|
|
|
uiPart0.w = barW * (fameValue + 100) / 200;
|
|
|
|
|
|
|
|
uiPart4.color = '255 0 0 255';
|
|
|
|
uiPart4.x = uiPart0.x + uiPart0.w;
|
|
|
|
uiPart4.w = barW * (thresholdKOS - fameValue) / 200;
|
|
|
|
|
|
|
|
bar3dLimit= uiPart4.x;
|
|
|
|
else
|
|
|
|
uiPart0.color= '80 0 0 255';
|
|
|
|
uiPart0.w = barW * (thresholdKOS + 100) / 200;
|
|
|
|
end
|
|
|
|
|
|
|
|
-- init part 1 of the bar
|
|
|
|
local part1X= barX + barW * (thresholdKOS + 100) / 200;
|
|
|
|
local part1TotalW= barW * (thresholdTrade - thresholdKOS) / 200;
|
|
|
|
uiPart1.x = part1X;
|
|
|
|
ui.ttp1.x = part1X;
|
|
|
|
ui.ttp1.w = part1TotalW;
|
|
|
|
if (fameValue >= thresholdKOS) and (fameValue <= thresholdTrade) then
|
|
|
|
uiPart1.color = '80 40 0 255';
|
|
|
|
uiPart1.w = barW * (fameValue - thresholdKOS) / 200;
|
|
|
|
|
|
|
|
uiPart4.color = '255 127 0 255';
|
|
|
|
uiPart4.x = uiPart1.x + uiPart1.w;
|
|
|
|
uiPart4.w = barW * (thresholdTrade - fameValue) / 200;
|
|
|
|
|
|
|
|
bar3dLimit= uiPart4.x;
|
|
|
|
else
|
|
|
|
if (fameValue < thresholdKOS) then
|
|
|
|
uiPart1.color = '255 127 0 255';
|
|
|
|
else
|
|
|
|
uiPart1.color = '80 40 0 255';
|
|
|
|
end
|
|
|
|
uiPart1.w = part1TotalW;
|
|
|
|
end
|
|
|
|
|
|
|
|
-- init part 2 of the bar
|
|
|
|
local part2X= barX + barW * (thresholdTrade + 100) / 200;
|
|
|
|
local part2TotalW= barW * (0 - thresholdTrade) / 200;
|
|
|
|
uiPart2.x = part2X;
|
|
|
|
ui.ttp2.x = part2X;
|
|
|
|
ui.ttp2.w = part2TotalW;
|
|
|
|
if (fameValue >= thresholdTrade) and (fameValue <= 0) then
|
|
|
|
uiPart2.color = '80 80 0 255';
|
|
|
|
uiPart2.w = barW * (fameValue - thresholdTrade) / 200;
|
|
|
|
|
|
|
|
uiPart4.color = '255 255 0 255';
|
|
|
|
uiPart4.x = uiPart2.x + uiPart2.w;
|
|
|
|
uiPart4.w = barW * (0 - fameValue) / 200;
|
|
|
|
|
|
|
|
bar3dLimit= uiPart4.x;
|
|
|
|
else
|
|
|
|
if (fameValue < thresholdTrade) then
|
|
|
|
uiPart2.color = '255 255 0 255';
|
|
|
|
else
|
|
|
|
uiPart2.color = '80 80 0 255';
|
|
|
|
end
|
|
|
|
uiPart2.w = part2TotalW;
|
|
|
|
end
|
|
|
|
|
|
|
|
-- init part 3 of the bar
|
|
|
|
local part3X= barX + barW * (0 + 100) / 200;
|
|
|
|
local part3TotalW= barW * (100 - 0) / 200;
|
|
|
|
uiPart3.x = part3X;
|
|
|
|
ui.ttp3.x = part3X;
|
|
|
|
ui.ttp3.w = part3TotalW;
|
|
|
|
if (fameValue >= 0) and (fameValue <= 100) then
|
|
|
|
uiPart3.color = '0 255 0 255';
|
|
|
|
uiPart3.w = barW * (fameValue - 0) / 200;
|
|
|
|
|
|
|
|
uiPart4.color = '0 80 0 255';
|
|
|
|
uiPart4.x = uiPart3.x + uiPart3.w;
|
|
|
|
uiPart4.w = barW * (100 - fameValue) / 200;
|
|
|
|
|
|
|
|
bar3dLimit= uiPart4.x;
|
|
|
|
else
|
|
|
|
uiPart3.color = '0 80 0 255';
|
|
|
|
uiPart3.w = part3TotalW;
|
|
|
|
end
|
|
|
|
|
|
|
|
-- init max limit
|
|
|
|
local uiMaxLimit = ui.m;
|
|
|
|
uiMaxLimit.x = barX + barW * (fameMax + 100) / 200;
|
|
|
|
|
|
|
|
-- init bar3d
|
2017-03-24 14:12:18 +00:00
|
|
|
if (bar3dStart < bar3dLimit) then
|
2016-05-06 10:56:20 +00:00
|
|
|
uiBar3d.x= bar3dStart;
|
|
|
|
uiBar3d.w= bar3dLimit-bar3dStart;
|
|
|
|
else
|
|
|
|
uiBar3d.x= bar3dLimit;
|
|
|
|
uiBar3d.w= bar3dStart - bar3dLimit;
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:updateFameBarTT(path)
|
|
|
|
local fameMax = getDbProp(path .. ':THRESHOLD');
|
|
|
|
|
|
|
|
local text = i18n.get('uittFameMaxPossible');
|
2017-03-24 14:12:18 +00:00
|
|
|
text = findReplaceAll(text, '%famemax', tostring(fameMax));
|
2016-05-06 10:56:20 +00:00
|
|
|
setContextHelpText(text);
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:getPvpEffects()
|
|
|
|
local uiGroup= getUICaller();
|
|
|
|
local n = 59-1;
|
|
|
|
local i;
|
|
|
|
local hasBonus = false;
|
|
|
|
local hasMalus = false;
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
local text = ''
|
|
|
|
local textBonus = '';
|
|
|
|
local textMalus = '';
|
|
|
|
local fmt;
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
-- check every malus and bonus
|
|
|
|
for i=0, n do
|
|
|
|
local path = formatUI('SERVER:PVP_EFFECTS:#1', i);
|
|
|
|
local id = getDbProp(path .. ':ID');
|
|
|
|
if (id ~= 0) then
|
|
|
|
local isBonus = getDbProp(path .. ':ISBONUS');
|
|
|
|
local param = getDbProp(path .. ':PARAM');
|
|
|
|
if (isBonus == 1) then
|
|
|
|
hasBonus = true;
|
|
|
|
fmt = i18n.get('uiPvPEffect_' .. getRegionByAlias(id) .. '_Bonus');
|
|
|
|
fmt = replacePvpEffectParam(fmt, param);
|
|
|
|
if (textBonus ~= '') then
|
|
|
|
textBonus = concatUCString(textBonus, '\n\n');
|
|
|
|
end
|
|
|
|
textBonus = concatUCString(textBonus, fmt);
|
|
|
|
else
|
|
|
|
hasMalus = true;
|
|
|
|
fmt = i18n.get('uiPvPEffect_' .. getRegionByAlias(id) .. '_Malus');
|
|
|
|
fmt = replacePvpEffectParam(fmt, param);
|
|
|
|
if (textMalus ~= '') then
|
|
|
|
textMalus = concatUCString(textMalus, '\n\n');
|
|
|
|
end
|
|
|
|
textMalus = concatUCString(textMalus, fmt);
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if (hasBonus) then
|
|
|
|
uiGroup.pvpEffectsBonusMalusInfo.uc_hardtext_format = i18n.get('uiPvpEffectBonus');
|
|
|
|
uiGroup.pvpEffectsBonusMalus.uc_hardtext_format = textBonus;
|
|
|
|
elseif (hasMalus) then
|
|
|
|
uiGroup.pvpEffectsBonusMalusInfo.uc_hardtext_format = i18n.get('uiPvpEffectMalus');
|
|
|
|
uiGroup.pvpEffectsBonusMalus.uc_hardtext_format = textMalus;
|
|
|
|
else
|
|
|
|
uiGroup.pvpEffectsBonusMalusInfo.uc_hardtext_format = '';
|
|
|
|
uiGroup.pvpEffectsBonusMalus.uc_hardtext_format = '';
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:getFactionName(id)
|
2016-05-06 10:56:20 +00:00
|
|
|
if (id == self.TPVPClan.Kami) then
|
|
|
|
return i18n.get('uiFameKami');
|
|
|
|
elseif (id == self.TPVPClan.Karavan) then
|
|
|
|
return i18n.get('uiFameKaravan');
|
|
|
|
elseif (id == self.TPVPClan.Fyros) then
|
|
|
|
return i18n.get('uiFameFyros');
|
|
|
|
elseif (id == self.TPVPClan.Matis) then
|
|
|
|
return i18n.get('uiFameMatis');
|
|
|
|
elseif (id == self.TPVPClan.Tryker) then
|
|
|
|
return i18n.get('uiFameTryker');
|
|
|
|
elseif (id == self.TPVPClan.Zorai) then
|
|
|
|
return i18n.get('uiFameZorai');
|
|
|
|
else
|
|
|
|
return i18n.get('Unknown');
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:getAllegiancePoints()
|
|
|
|
local path = 'SERVER:PVP_EFFECTS:PVP_FACTION_POINTS';
|
|
|
|
local civ = getDbProp(path .. ':CIV');
|
|
|
|
local civPoints = getDbProp(path .. ':CIV_POINTS');
|
|
|
|
local cult = getDbProp(path .. ':CULT');
|
|
|
|
local cultPoints = getDbProp(path .. ':CULT_POINTS');
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
local text;
|
|
|
|
local uiGroup= getUICaller();
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
-- civ allegiance
|
|
|
|
if (civ == self.TPVPClan.None or civ == self.TPVPClan.Neutral) then
|
|
|
|
text = i18n.get('uiPvpFameNoCivAllegiance');
|
|
|
|
else
|
|
|
|
text = i18n.get('uiPvpFameAllegiancePoints');
|
|
|
|
text = findReplaceAll(text, '%faction', self:getFactionName(civ));
|
|
|
|
text = findReplaceAll(text, '%points', tostring(civPoints));
|
2017-03-24 14:12:18 +00:00
|
|
|
end
|
2016-05-06 10:56:20 +00:00
|
|
|
uiGroup.civ_allegiance_pts.uc_hardtext_format = text;
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
-- cult allegiance
|
|
|
|
if (cult == self.TPVPClan.None or cult == self.TPVPClan.Neutral) then
|
|
|
|
text = i18n.get('uiPvpFameNoCultAllegiance');
|
|
|
|
else
|
|
|
|
text = i18n.get('uiPvpFameAllegiancePoints');
|
|
|
|
text = findReplaceAll(text, '%faction', self:getFactionName(cult));
|
|
|
|
text = findReplaceAll(text, '%points', tostring(cultPoints));
|
|
|
|
end
|
|
|
|
uiGroup.cult_allegiance_pts.uc_hardtext_format = text;
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:updateAllegiance(path, uiText)
|
|
|
|
local alleg = getDbProp(path);
|
|
|
|
|
|
|
|
local text = i18n.get('uiFameAllegiance' .. tostring(alleg) );
|
|
|
|
getUICaller()[uiText].uc_hardtext= text;
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:fameAllegianceTooltipCiv()
|
|
|
|
local enum= getDbProp('SERVER:FAME:CIV_ALLEGIANCE');
|
|
|
|
-- set the tooltip in InterfaceManager
|
|
|
|
setContextHelpText( i18n.get('uittFameAllegianceCiv' .. tostring(enum)) );
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:fameAllegianceTooltipCult()
|
|
|
|
local enum= getDbProp('SERVER:FAME:CULT_ALLEGIANCE');
|
|
|
|
-- set the tooltip in InterfaceManager
|
|
|
|
setContextHelpText( i18n.get('uittFameAllegianceCult' .. tostring(enum)) );
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:fameAllegianceTooltipCivGuild()
|
|
|
|
local enum= getDbProp('SERVER:GUILD:FAME:CIV_ALLEGIANCE');
|
|
|
|
-- set the tooltip in InterfaceManager
|
|
|
|
setContextHelpText( i18n.get('uittFameAllegianceCivGuild' .. tostring(enum)) );
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:fameAllegianceTooltipCultGuild()
|
|
|
|
local enum= getDbProp('SERVER:GUILD:FAME:CULT_ALLEGIANCE');
|
|
|
|
-- set the tooltip in InterfaceManager
|
|
|
|
setContextHelpText( i18n.get('uittFameAllegianceCultGuild' .. tostring(enum)) );
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
--
|
2016-05-06 10:56:20 +00:00
|
|
|
function game:tooltipDeltaValue(base, max)
|
|
|
|
-- Calculate delta
|
|
|
|
local val = max - base;
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
local text;
|
|
|
|
if (val == 0) then
|
|
|
|
text = concatUCString('@{FFFF}', tostring(max));
|
|
|
|
else
|
|
|
|
if (val > 0) then
|
|
|
|
-- bonus
|
|
|
|
text = concatUCString('@{FFFF}', tostring(max));
|
|
|
|
text = concatUCString(text, ' (');
|
|
|
|
text = concatUCString(text, tostring(base));
|
|
|
|
text = concatUCString(text, '@{0F0F}');
|
|
|
|
text = concatUCString(text, ' + ');
|
|
|
|
text = concatUCString(text, tostring(val));
|
|
|
|
text = concatUCString(text, '@{FFFF}');
|
|
|
|
text = concatUCString(text, ')');
|
|
|
|
else
|
|
|
|
-- malus
|
|
|
|
text = concatUCString('@{FFFF}', tostring(max));
|
|
|
|
text = concatUCString(text, ' (');
|
|
|
|
text = concatUCString(text, tostring(base));
|
|
|
|
text = concatUCString(text, '@{E42F}');
|
|
|
|
text = concatUCString(text, ' - ');
|
|
|
|
text = concatUCString(text, tostring(math.abs(val)));
|
|
|
|
text = concatUCString(text, '@{FFFF}');
|
|
|
|
text = concatUCString(text, ')');
|
|
|
|
end
|
|
|
|
end
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
return text;
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
--
|
2016-05-06 10:56:20 +00:00
|
|
|
function game:tooltipScore(dbBase, dbMax, ttFormat)
|
|
|
|
-- Get DB values
|
|
|
|
local base = getDbProp(dbBase);
|
|
|
|
local max = getDbProp(dbMax);
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
-- Tooltip text
|
|
|
|
local fmt = i18n.get(ttFormat);
|
|
|
|
local text = self:tooltipDeltaValue(base, max);
|
|
|
|
fmt = findReplaceAll(fmt, "%n", text );
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
-- Set tooltip
|
|
|
|
setContextHelpText(fmt);
|
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
--
|
2016-05-06 10:56:20 +00:00
|
|
|
function game:tooltipScoreEP(dbBase, dbMax, ttFormat, dbLvl, dbMod)
|
|
|
|
-- Defender level
|
|
|
|
local defLvl= getDbProp(formatUI(dbLvl));
|
|
|
|
defLvl = math.max(0, defLvl);
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
-- Attacker level
|
|
|
|
local attLvl = getBaseSkillValueMaxChildren(getSkillIdFromName('SF'));
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
-- Get DB values
|
|
|
|
local base = getDbProp(dbBase);
|
|
|
|
local max = getDbProp(dbMax);
|
|
|
|
local chance = getDodgeParryChance(attLvl, defLvl);
|
|
|
|
local mod = getDbProp(dbMod);
|
|
|
|
local maxChance = chance + mod;
|
|
|
|
|
|
|
|
-- Tooltip text
|
|
|
|
local fmt = i18n.get(ttFormat);
|
|
|
|
local text = self:tooltipDeltaValue(base, max);
|
|
|
|
local textChance = self:tooltipDeltaValue(chance, maxChance);
|
|
|
|
fmt = findReplaceAll(fmt, "%n", text );
|
|
|
|
fmt = findReplaceAll(fmt, "%l", tostring(attLvl));
|
|
|
|
fmt = findReplaceAll(fmt, "%p", textChance);
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
-- Set tooltip
|
|
|
|
setContextHelpText(fmt);
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
|
|
---------------------------------- RING STATS ---------------------------------------------------
|
|
|
|
-------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2017-03-24 14:12:18 +00:00
|
|
|
RingPlayerInfo =
|
2016-05-06 10:56:20 +00:00
|
|
|
{
|
|
|
|
WaitingInfo = false,
|
|
|
|
LastRefreshTime = 0,
|
|
|
|
InfoReceived = false,
|
|
|
|
PendingRefresh = false,
|
|
|
|
WaitingPeriod = 15,
|
|
|
|
RefreshPeriod = 10,
|
|
|
|
MinRefreshPeriod = 4,
|
|
|
|
LastRefreshQuerryTime = 0,
|
|
|
|
}
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
function RingPlayerInfo:getWindow()
|
|
|
|
local ui = getUI("ui:interface:info_player_skills")
|
|
|
|
assert(ui)
|
|
|
|
return ui
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
function RingPlayerInfo:initRingStatPlayer()
|
|
|
|
|
2017-03-24 14:12:18 +00:00
|
|
|
setOnDraw(self:getWindow(), "RingPlayerInfo:onRingRatingPlayerDraw()")
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
function RingPlayerInfo:onRingRatingPlayerDraw()
|
|
|
|
|
|
|
|
local timeInSec = nltime.getLocalTime() / 1000
|
|
|
|
if self.WaitingInfo then
|
2017-03-24 14:12:18 +00:00
|
|
|
if timeInSec - self.LastRefreshTime > self.WaitingPeriod then
|
2016-05-06 10:56:20 +00:00
|
|
|
self.WaitingInfo = false
|
|
|
|
self.LastRefreshTime = nltime.getLocalTime() / 1000
|
2017-03-24 14:12:18 +00:00
|
|
|
else
|
2016-05-06 10:56:20 +00:00
|
|
|
if not self.InfoReceived then
|
|
|
|
--debugInfo("No received info")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
2017-03-24 14:12:18 +00:00
|
|
|
if timeInSec - self.LastRefreshTime > self.RefreshPeriod then
|
2016-05-06 10:56:20 +00:00
|
|
|
self:refresh()
|
|
|
|
else
|
|
|
|
--debugInfo("pas de refresh")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
self:updatePendingRefresh()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
function RingPlayerInfo:updatePendingRefresh()
|
|
|
|
|
|
|
|
if self.PendingRefresh then
|
|
|
|
local currTime = nltime.getLocalTime() / 1000
|
2017-03-24 14:12:18 +00:00
|
|
|
if currTime - self.LastRefreshQuerryTime > self.MinRefreshPeriod and game.getRingStats then
|
2016-05-06 10:56:20 +00:00
|
|
|
self.LastRefreshQuerryTime = currTime
|
|
|
|
self.PendingRefresh = false
|
|
|
|
game.getRingStats()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
function RingPlayerInfo:onRingStatsPlayerReceving(ringPoints)
|
|
|
|
|
|
|
|
self.WaitingInfo = false
|
|
|
|
self.LastRefreshTime = nltime.getLocalTime() / 1000
|
|
|
|
self.InfoReceived = true
|
|
|
|
|
|
|
|
self:fill(ringPoints)
|
|
|
|
end
|
|
|
|
|
|
|
|
function RingPlayerInfo:fill(ringPoints)
|
|
|
|
|
|
|
|
self.InfoReceived = false
|
|
|
|
|
|
|
|
local ui = self:getWindow()
|
|
|
|
|
|
|
|
-- author Rating
|
|
|
|
-- local authorRR = ui:find("author_ring_rating")
|
|
|
|
-- local jaugeUI = authorRR:find("jauge_bar")
|
|
|
|
-- local levelUI = authorRR:find("level_rating")
|
|
|
|
-- local tooltipUI = authorRR:find("tt")
|
|
|
|
-- local level, progress = self:getLevelRatingAndImprovementRate(ringPoints.AuthorRating)
|
|
|
|
-- jaugeUI.w = progress*156
|
|
|
|
-- local texturename = ""
|
|
|
|
-- if level~=0 then texturename = "r2ed_ring_rating_" .. level .. ".tga" end
|
|
|
|
-- levelUI.texture = texturename
|
|
|
|
-- tooltipUI.tooltip = self:tooltipRingRating(level, progress, "uiR2EDAuthorRingRatingTooltip")
|
|
|
|
|
|
|
|
-- AM Rating
|
|
|
|
-- local AMRR = ui:find("am_ring_rating")
|
|
|
|
-- jaugeUI = AMRR:find("jauge_bar")
|
|
|
|
-- levelUI = AMRR:find("level_rating")
|
|
|
|
-- tooltipUI = AMRR:find("tt")
|
|
|
|
-- level, progress = self:getLevelRatingAndImprovementRate(ringPoints.AMRating)
|
|
|
|
-- jaugeUI.w = progress*156
|
|
|
|
-- texturename = ""
|
|
|
|
-- if level~=0 then texturename = "r2ed_ring_rating_" .. level .. ".tga" end
|
|
|
|
-- levelUI.texture = texturename
|
|
|
|
-- tooltipUI.tooltip = self:tooltipRingRating(level, progress, "uiR2EDAMRingRatingTooltip")
|
|
|
|
|
|
|
|
-- masterless Rating
|
|
|
|
-- local masterlessRR = ui:find("masterless_ring_rating")
|
|
|
|
-- jaugeUI = masterlessRR:find("jauge_bar")
|
|
|
|
-- levelUI = masterlessRR:find("level_rating")
|
|
|
|
-- tooltipUI = masterlessRR:find("tt")
|
|
|
|
-- level, progress = self:getLevelRatingAndImprovementRate(ringPoints.MasterlessRating)
|
|
|
|
-- jaugeUI.w = progress*156
|
|
|
|
-- texturename = ""
|
|
|
|
-- if level~=0 then texturename = "r2ed_ring_rating_" .. level .. ".tga" end
|
|
|
|
-- levelUI.texture = texturename
|
|
|
|
-- tooltipUI.tooltip = self:tooltipRingRating(level, progress, "uiR2EDMasterlessRingRatingTooltip")
|
|
|
|
|
|
|
|
-- ecosystem Points
|
|
|
|
local ecosystems = {"Basic", "Desert", "Subtropic", "Forest", "Jungle", "PrimeRoot"}
|
|
|
|
for k, eco in pairs(ecosystems) do
|
|
|
|
local ecoVal = tostring(ringPoints[eco.."RingPoints"])
|
|
|
|
local ecoValMax = tostring(ringPoints["Max" .. eco.."RingPoints"])
|
|
|
|
local ecoUI = ui:find(string.lower(eco))
|
|
|
|
local maxUI = ecoUI:find("max")
|
|
|
|
local valUI = ecoUI:find("val")
|
|
|
|
tooltipUI = ecoUI:find("tt")
|
|
|
|
maxUI.hardtext = ecoValMax
|
|
|
|
valUI.hardtext = ecoVal
|
|
|
|
tooltipUI.tooltip = self:tooltipEcosystemPoints(ecoVal, ecoValMax, "uiR2ED" .. eco .. "PointsTooltip")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
function RingPlayerInfo:refresh()
|
|
|
|
|
2017-03-24 14:12:18 +00:00
|
|
|
self.PendingRefresh = true
|
2016-05-06 10:56:20 +00:00
|
|
|
self.LastRefreshTime = nltime.getLocalTime() / 1000
|
|
|
|
self.WaitingInfo = true
|
2017-03-24 14:12:18 +00:00
|
|
|
end
|
2016-05-06 10:56:20 +00:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
function RingPlayerInfo:tooltipEcosystemPoints(rp, maxRp, ttFormat)
|
|
|
|
|
|
|
|
-- Tooltip text
|
|
|
|
local fmt = i18n.get(ttFormat);
|
|
|
|
fmt = findReplaceAll(fmt, "%n", rp );
|
|
|
|
fmt = findReplaceAll(fmt, "%p", maxRp );
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
-- Set tooltip
|
|
|
|
return fmt;
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function RingPlayerInfo:updateRRPSLevel(dbVal, tooltip)
|
|
|
|
|
|
|
|
|
|
|
|
-- get values. minimize the value displayed
|
|
|
|
local val= getDbProp(dbVal);
|
|
|
|
|
|
|
|
-- get the ui text
|
|
|
|
local ui= getUICaller();
|
|
|
|
local uiText= ui.val;
|
|
|
|
|
2017-03-24 14:12:18 +00:00
|
|
|
-- set the text
|
|
|
|
uiText.uc_hardtext= tostring(val)
|
2016-05-06 10:56:20 +00:00
|
|
|
|
|
|
|
self:tooltipRRPs(dbVal, tooltip)
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
function RingPlayerInfo:tooltipRRPs(dbBase, ttFormat)
|
|
|
|
|
|
|
|
local val = getDbProp(dbBase);
|
|
|
|
|
|
|
|
-- Tooltip text
|
|
|
|
local fmt = i18n.get(ttFormat);
|
|
|
|
local text = tostring(val)
|
|
|
|
fmt = findReplaceAll(fmt, "%n", text );
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
-- Set tooltip
|
|
|
|
setContextHelpText(fmt);
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
function RingPlayerInfo:tooltipRingRating(level, progress, ttFormat)
|
|
|
|
|
|
|
|
-- Tooltip text
|
|
|
|
local fmt = i18n.get(ttFormat);
|
|
|
|
progress = math.floor(progress*100)
|
|
|
|
fmt = findReplaceAll(fmt, "%n", tostring(level));
|
|
|
|
fmt = findReplaceAll(fmt, "%p", tostring(progress));
|
|
|
|
-- Set tooltip
|
|
|
|
return fmt;
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
function RingPlayerInfo:getLevelRatingAndImprovementRate(val)
|
|
|
|
|
|
|
|
val = val / 100
|
|
|
|
local level = 0
|
|
|
|
local maxRatingInLevel = 0
|
|
|
|
local minRatingInLevel = 0
|
|
|
|
|
|
|
|
for i=0,9 do
|
|
|
|
level = i
|
|
|
|
minRatingInLevel = maxRatingInLevel
|
|
|
|
maxRatingInLevel = maxRatingInLevel + math.pow(4, i+1)
|
|
|
|
if maxRatingInLevel>val then break end
|
|
|
|
end
|
|
|
|
|
|
|
|
local progress = (val-minRatingInLevel)/(maxRatingInLevel-minRatingInLevel)
|
|
|
|
|
|
|
|
return level, progress
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
--
|
|
|
|
function game:updateOrganization(path, uiOrgText, uiStatusText, uiPointsText)
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
local org = getDbProp(path.."1:VALUE")
|
|
|
|
getUICaller()[uiOrgText].uc_hardtext = i18n.get('uiOrganization_' .. org)
|
|
|
|
|
|
|
|
local status = getDbProp(path.."2:VALUE")
|
|
|
|
getUICaller()[uiStatusText].uc_hardtext= status
|
|
|
|
|
|
|
|
local points = getDbProp(path.."3:VALUE")
|
|
|
|
getUICaller()[uiPointsText].uc_hardtext= points
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:organizationTooltip()
|
|
|
|
-- set the tooltip in InterfaceManager
|
|
|
|
setContextHelpText( i18n.get('uittOrganization') );
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:popMissionList()
|
|
|
|
local menu = getUI("ui:interface:mission_cb_menu")
|
2016-05-06 10:56:20 +00:00
|
|
|
enableModalWindow(getUICaller(), "ui:interface:mission_cb_menu")
|
2017-03-24 14:12:18 +00:00
|
|
|
self:updateMissionMenuSize()
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:getGroupMissionFirstIndex()
|
|
|
|
return tonumber(getDefine("ipj_nb_mission"))
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:getMissionDbPath(missionIndex)
|
|
|
|
local numMissions = game:getGroupMissionFirstIndex()
|
|
|
|
if missionIndex >= numMissions then -- group mission ?
|
|
|
|
return "SERVER:GROUP:MISSIONS:" .. tostring(missionIndex - numMissions)
|
|
|
|
else
|
|
|
|
return "SERVER:MISSIONS:" .. tostring(missionIndex)
|
2017-03-24 14:12:18 +00:00
|
|
|
end
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:getCurrMissionIndex()
|
|
|
|
local result = getDbProp("UI:SAVE:MISSION_SELECTED")
|
2016-05-06 10:56:20 +00:00
|
|
|
return result
|
|
|
|
end
|
|
|
|
|
|
|
|
function game:getCurrGroupMissionIndex()
|
|
|
|
return getDbProp("UI:SAVE:MISSION_SELECTED") - tonumber(getDefine("ipj_nb_mission"))
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:updateCurrMissionComboBox()
|
|
|
|
local numMissions = tonumber(getDefine("ipj_nb_mission"))
|
|
|
|
local missionFound = false
|
2017-03-24 14:12:18 +00:00
|
|
|
local cb = getUI("ui:interface:info_player_journal:content:mission_combo")
|
|
|
|
local missionList = getUI("ui:interface:info_player_journal:content:mission_list")
|
2016-05-06 10:56:20 +00:00
|
|
|
for i = 0, numMissions - 1 do
|
2017-03-24 14:12:18 +00:00
|
|
|
if getDbProp("SERVER:MISSIONS:" .. i .. ":TITLE") ~= 0
|
2016-05-06 10:56:20 +00:00
|
|
|
or getDbProp("SERVER:GROUP:MISSIONS:" .. i .. ":TITLE") ~= 0 then
|
|
|
|
missionFound = true
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if not missionFound then
|
|
|
|
cb.arrow.active = false
|
|
|
|
cb.mission_ico.active = false
|
|
|
|
cb.mission_title.active = false
|
|
|
|
cb.select.active = false
|
|
|
|
cb.no_selected_mission.active = false
|
|
|
|
cb.no_available_mission.active = true
|
|
|
|
missionList.no_selected_mission.active = false
|
|
|
|
missionList.no_available_mission.active = true
|
|
|
|
return
|
|
|
|
end
|
|
|
|
cb.no_available_mission.active = false
|
|
|
|
missionList.no_available_mission.active = false
|
|
|
|
cb.arrow.active = true
|
|
|
|
cb.select.active = true
|
2017-03-24 14:12:18 +00:00
|
|
|
local currMission = self:getCurrMissionIndex()
|
2016-05-06 10:56:20 +00:00
|
|
|
|
2017-03-24 14:12:18 +00:00
|
|
|
local dbPath = self:getMissionDbPath(currMission)
|
|
|
|
--
|
|
|
|
local selected = (currMission ~= -1)
|
2016-05-06 10:56:20 +00:00
|
|
|
if selected then
|
|
|
|
cb.mission_title.textid_dblink = dbPath .. ":TITLE"
|
|
|
|
selected = (tile ~= 0)
|
2017-03-24 14:12:18 +00:00
|
|
|
end
|
2016-05-06 10:56:20 +00:00
|
|
|
cb.mission_ico.active = selected
|
|
|
|
cb.mission_title.active = selected
|
|
|
|
cb.no_selected_mission.active = not selected
|
|
|
|
missionList.no_selected_mission.active = not selected
|
2017-03-24 14:12:18 +00:00
|
|
|
if selected then
|
2016-05-06 10:56:20 +00:00
|
|
|
if getDbProp(dbPath .. ":FINISHED") == 0 then
|
|
|
|
cb.mission_ico.texture = runExpr("getMissionSmallIcon(" .. tostring(getDbProp(dbPath .. ":ICON") .. ")"))
|
|
|
|
elseif getDbProp(dbPath .. ":FINISHED") == 1 then
|
|
|
|
cb.mission_ico.texture = "Small_Task_Done.tga"
|
|
|
|
else
|
|
|
|
cb.mission_ico.texture = "Small_Task_Failed.tga"
|
|
|
|
end
|
2017-03-24 14:12:18 +00:00
|
|
|
end
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:onMissionSelected(index)
|
2016-05-06 10:56:20 +00:00
|
|
|
disableModalWindow()
|
|
|
|
self:updateCurrMissionComboBox()
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:onGroupMissionSelected(index)
|
2016-05-06 10:56:20 +00:00
|
|
|
disableModalWindow()
|
|
|
|
self:updateCurrMissionComboBox()
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:onMissionDBIndexChanged()
|
|
|
|
local missionIndex = self:getCurrMissionIndex()
|
|
|
|
if missionIndex < 0 then return end
|
|
|
|
-- if selection was made from the list, update the other list
|
|
|
|
if missionIndex >= self:getGroupMissionFirstIndex() then
|
|
|
|
local groupMissionIndex = missionIndex - self:getGroupMissionFirstIndex()
|
2017-03-24 14:12:18 +00:00
|
|
|
getUI("ui:interface:info_player_journal:content:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true
|
2016-05-06 10:56:20 +00:00
|
|
|
getUI("ui:interface:mission_cb_menu:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true
|
|
|
|
else
|
2017-03-24 14:12:18 +00:00
|
|
|
getUI("ui:interface:info_player_journal:content:mission_list:b_title" .. tostring(missionIndex)).pushed = true
|
2016-05-06 10:56:20 +00:00
|
|
|
getUI("ui:interface:mission_cb_menu:mission_list:b_title" .. tostring(missionIndex)).pushed = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:onMissionTitleChanged(index)
|
2016-05-06 10:56:20 +00:00
|
|
|
-- if title is not nil then a new mission has been added -> if db initilization is over, then selected this new mission
|
2017-03-24 14:12:18 +00:00
|
|
|
if getDbProp(self:getMissionDbPath(index) .. ":TITLE") ~= 0 then
|
|
|
|
if game.InGameDbInitialized or config.Local then
|
2016-05-06 10:56:20 +00:00
|
|
|
self:setCurrentMission(index)
|
|
|
|
end
|
2017-03-24 14:12:18 +00:00
|
|
|
else
|
2016-05-06 10:56:20 +00:00
|
|
|
self:updateCurrMissionComboBox()
|
|
|
|
self:updateMissionMenuSize()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:onGroupMissionTitleChanged(index)
|
|
|
|
if getDbProp(self:getMissionDbPath(index + 15) .. ":TITLE") ~= 0 then
|
|
|
|
if game.InGameDbInitialized or config.Local then
|
2016-05-06 10:56:20 +00:00
|
|
|
self:setCurrentMission(index + 15)
|
|
|
|
end
|
2017-03-24 14:12:18 +00:00
|
|
|
else
|
2016-05-06 10:56:20 +00:00
|
|
|
self:updateCurrMissionComboBox()
|
|
|
|
self:updateMissionMenuSize()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:updateMissionMenuSize()
|
|
|
|
local parentCB = getUI("ui:interface:info_player_journal:content:mission_combo")
|
|
|
|
local menu = getUI("ui:interface:mission_cb_menu")
|
2017-03-24 14:12:18 +00:00
|
|
|
if not menu.active then return end
|
2016-05-06 10:56:20 +00:00
|
|
|
local maxNumMissions = 2 * self:getGroupMissionFirstIndex()
|
2017-03-24 14:12:18 +00:00
|
|
|
local missionCount = 0
|
2016-05-06 10:56:20 +00:00
|
|
|
for k = 0, maxNumMissions - 1 do
|
|
|
|
if getDbProp(self:getMissionDbPath(k) .. ":TITLE") ~= 0 then
|
2017-03-24 14:12:18 +00:00
|
|
|
missionCount = missionCount + 1
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
2017-03-24 14:12:18 +00:00
|
|
|
end
|
2016-05-06 10:56:20 +00:00
|
|
|
menu.h = 8 + missionCount * 18
|
|
|
|
menu.y = 0
|
|
|
|
menu:updateCoords()
|
|
|
|
local y = parentCB.y_real - menu.h_real - 1
|
|
|
|
if y < 0 then
|
|
|
|
y = parentCB.y_real + parentCB.h_real + 1
|
2017-03-24 14:12:18 +00:00
|
|
|
end
|
2016-05-06 10:56:20 +00:00
|
|
|
local scrW
|
|
|
|
local scrH
|
|
|
|
scrW, scrH = getWindowSize()
|
|
|
|
if y + menu.h > scrH then
|
|
|
|
y = scrH - menu.h
|
|
|
|
end
|
|
|
|
menu.w = parentCB.w_real
|
|
|
|
menu.y = y
|
2017-03-24 14:12:18 +00:00
|
|
|
menu.x = parentCB.x_real
|
2016-05-06 10:56:20 +00:00
|
|
|
menu.h = 8 + missionCount * 18
|
|
|
|
menu:invalidateCoords()
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
--function game:updateMissionDescCloseButton(index)
|
|
|
|
-- local dbPath = self:getMissionDbPath(index)
|
2017-03-24 14:12:18 +00:00
|
|
|
-- if index == self:getCurrMissionIndex() then
|
2016-05-06 10:56:20 +00:00
|
|
|
-- local closeText = getUI("ui:interface:info_player_journal:content:desc:close")
|
|
|
|
-- local button = getUI("ui:interface:info_player_journal:content:desc:uppart:over_icon")
|
|
|
|
-- local finished = getDbProp(dbPath .. ":FINISHED")
|
|
|
|
-- if finished == 0 then
|
|
|
|
-- closeText.hardtext = 'uittMissionAbandon'
|
|
|
|
-- button.texture = "blank2.tga"
|
|
|
|
-- else
|
|
|
|
-- closeText.hardtext = 'uittMissionFinished'
|
|
|
|
-- if finished == 1 then
|
|
|
|
-- button.texture = "ICO_Task_Done.tga"
|
|
|
|
-- else
|
|
|
|
-- button.texture = "ICO_Task_Failed.tga"
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
--end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:onMissionFinished(index)
|
|
|
|
self:updateCurrMissionComboBox()
|
2016-05-06 10:56:20 +00:00
|
|
|
--self:updateMissionDescCloseButton(index)
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:onGroupMissionFinished(index)
|
2016-05-06 10:56:20 +00:00
|
|
|
self:updateCurrMissionComboBox()
|
|
|
|
--self:updateMissionDescCloseButton(index + game:getGroupMissionFirstIndex())
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:expandMissionList()
|
|
|
|
local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo")
|
2016-05-06 10:56:20 +00:00
|
|
|
missionCB.active = not missionCB.active
|
|
|
|
self:updateMissionWindowLayout()
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:updateMissionWindowLayout()
|
2016-05-06 10:56:20 +00:00
|
|
|
if not isInRingMode() then
|
|
|
|
local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo")
|
2017-03-24 14:12:18 +00:00
|
|
|
local missionList = getUI("ui:interface:info_player_journal:content:mission_list")
|
2016-05-06 10:56:20 +00:00
|
|
|
local fake = getUI("ui:interface:info_player_journal:content:fake")
|
|
|
|
local sepBis = getUI("ui:interface:info_player_journal:content:separator_bis")
|
|
|
|
local desc = getUI("ui:interface:info_player_journal:content:desc")
|
|
|
|
local expanded
|
|
|
|
local popMinH
|
|
|
|
local win = getUI("ui:interface:info_player_journal")
|
|
|
|
|
2017-03-24 14:12:18 +00:00
|
|
|
if missionCB.active then
|
|
|
|
sepBis.active = false
|
2016-05-06 10:56:20 +00:00
|
|
|
missionList.active = false
|
|
|
|
fake.sizeref=""
|
|
|
|
fake.y = -32
|
|
|
|
fake.h = 0
|
2017-03-24 14:12:18 +00:00
|
|
|
expanded = 0
|
2016-05-06 10:56:20 +00:00
|
|
|
desc.max_sizeref ="wh"
|
|
|
|
desc.max_h= -42
|
|
|
|
win.pop_min_h = 152 - win.content_y_offset
|
2017-03-24 14:12:18 +00:00
|
|
|
else
|
|
|
|
sepBis.active = true
|
2016-05-06 10:56:20 +00:00
|
|
|
missionList.active = true
|
|
|
|
fake.sizeref="wh5"
|
|
|
|
fake.y = -8
|
|
|
|
fake.h = -42
|
|
|
|
expanded = 1
|
|
|
|
desc.max_sizeref ="wh5"
|
|
|
|
desc.max_h=16
|
|
|
|
win.pop_min_h = 152 - win.content_y_offset
|
2017-03-24 14:12:18 +00:00
|
|
|
end
|
2016-05-06 10:56:20 +00:00
|
|
|
|
2017-03-24 14:12:18 +00:00
|
|
|
local fixedEntry = getUI("ui:interface:info_player_journal:content:mission_fixed_entry")
|
2016-05-06 10:56:20 +00:00
|
|
|
fixedEntry:updateCoords()
|
|
|
|
desc.max_h = desc.max_h - fixedEntry.h
|
|
|
|
|
|
|
|
setDbProp("UI:SAVE:EXPAND_MISSION_LIST", expanded)
|
2017-03-24 14:12:18 +00:00
|
|
|
getUI("ui:interface:info_player_journal"):invalidateCoords()
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:onMissionJournalOpened()
|
2016-05-06 10:56:20 +00:00
|
|
|
local missionDesc = getUI("ui:interface:info_player_journal:content:desc")
|
2017-03-24 14:12:18 +00:00
|
|
|
missionDesc.active = getDbProp("UI:SAVE:MISSION_SELECTED") ~= -1
|
2016-05-06 10:56:20 +00:00
|
|
|
|
2017-03-24 14:12:18 +00:00
|
|
|
local expandList = getDbProp("UI:SAVE:EXPAND_MISSION_LIST")
|
2016-05-06 10:56:20 +00:00
|
|
|
self:updateMissionJournalMode()
|
|
|
|
|
|
|
|
if not isInRingMode() then
|
|
|
|
local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo")
|
|
|
|
if expandList == 1 then
|
|
|
|
missionCB.active = false
|
|
|
|
else
|
|
|
|
missionCB.active = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
self:updateMissionJournalHeader()
|
|
|
|
self:updateMissionWindowLayout()
|
2017-03-24 14:12:18 +00:00
|
|
|
self:updateMissionJournalFixedEntry()
|
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:updateMissionJournalHeader()
|
|
|
|
local win = getUI("ui:interface:info_player_journal")
|
|
|
|
local headerActive = getDbProp("UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE") ~= 0
|
|
|
|
win.header_active = headerActive
|
2017-03-24 14:12:18 +00:00
|
|
|
win.right_button_enabled = headerActive
|
2016-05-06 10:56:20 +00:00
|
|
|
if headerActive then
|
2017-03-24 14:12:18 +00:00
|
|
|
win.uc_title_opened = i18n.get("uiJournalTitle")
|
2016-05-06 10:56:20 +00:00
|
|
|
win.content_y_offset = 0
|
|
|
|
else
|
2017-03-24 14:12:18 +00:00
|
|
|
win.uc_title_opened = ucstring("")
|
2016-05-06 10:56:20 +00:00
|
|
|
win.content_y_offset = win.header_opened.h_real + 3
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:updateMissionJournalFixedEntry()
|
|
|
|
-- update fixed entry text
|
2017-03-24 14:12:18 +00:00
|
|
|
|
|
|
|
local fixedEntryRing = getUI("ui:interface:info_player_journal:no_available_missions:main:mission_fixed_entry")
|
2016-05-06 10:56:20 +00:00
|
|
|
local fixedEntryMain = getUI("ui:interface:info_player_journal:content:mission_fixed_entry")
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
fixedEntryRing.active = game.InGameDbInitialized and isInRingMode()
|
2017-03-24 14:12:18 +00:00
|
|
|
fixedEntryMain.active = game.InGameDbInitialized and not isInRingMode()
|
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
local id = "uiFixedMissionEntry"
|
|
|
|
if isPlayerNewbie() then
|
|
|
|
id = id .."_Newbie"
|
|
|
|
if isInRingMode() then
|
|
|
|
id = id .. "_R2"
|
|
|
|
end
|
|
|
|
if isPlayerFreeTrial() then
|
|
|
|
id = id .. "_Trial"
|
2017-03-24 14:12:18 +00:00
|
|
|
end
|
2016-05-06 10:56:20 +00:00
|
|
|
else
|
2017-03-24 14:12:18 +00:00
|
|
|
if isInRingMode() then
|
|
|
|
id = id .. "_R2"
|
|
|
|
else
|
2016-05-06 10:56:20 +00:00
|
|
|
id = id .. "_Mainland_" .. getUserRace()
|
|
|
|
end
|
2017-03-24 14:12:18 +00:00
|
|
|
end
|
2016-05-06 10:56:20 +00:00
|
|
|
fixedEntryMain.uc_hardtext = i18n.get(id)
|
|
|
|
fixedEntryRing.uc_hardtext = i18n.get(id)
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
self:updateMissionWindowLayout()
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:setCurrentMission(index)
|
2016-05-06 10:56:20 +00:00
|
|
|
mw = getMissionWindow()
|
|
|
|
mw.active = game.InGameDbInitialized
|
|
|
|
if index < self:getGroupMissionFirstIndex() then
|
|
|
|
runAH(nil, "proc", "mission_proc_title|" .. tostring(index))
|
|
|
|
else
|
|
|
|
runAH(nil, "proc", "group_mission_proc_title|" .. tostring(index - self:getGroupMissionFirstIndex()))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:onMissionComboWheelUp()
|
2016-05-06 10:56:20 +00:00
|
|
|
local currMissionIndex = self:getCurrMissionIndex()
|
|
|
|
while currMissionIndex > 0 do
|
|
|
|
currMissionIndex = currMissionIndex - 1
|
|
|
|
if getDbProp(self:getMissionDbPath(currMissionIndex) .. ":TITLE") ~= 0 then
|
|
|
|
self:setCurrentMission(currMissionIndex)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:onMissionComboWheelDown()
|
2016-05-06 10:56:20 +00:00
|
|
|
local currMissionIndex = self:getCurrMissionIndex()
|
|
|
|
local maxNumMission = 2 * self:getGroupMissionFirstIndex()
|
|
|
|
while currMissionIndex < (maxNumMission - 1) do
|
|
|
|
currMissionIndex = currMissionIndex + 1
|
|
|
|
if getDbProp(self:getMissionDbPath(currMissionIndex) .. ":TITLE") ~= 0 then
|
|
|
|
self:setCurrentMission(currMissionIndex)
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:toggleMissionJournalCaption()
|
|
|
|
local dbPath = "UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE"
|
2016-05-06 10:56:20 +00:00
|
|
|
setDbProp(dbPath, 1 - getDbProp(dbPath))
|
2017-03-24 14:12:18 +00:00
|
|
|
local win = getUI("ui:interface:info_player_journal")
|
2016-05-06 10:56:20 +00:00
|
|
|
self:updateMissionJournalHeader()
|
|
|
|
self:updateMissionWindowLayout()
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
-- handler called by C++ to tell that the main loop is about to begin
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:onMainLoopBegin()
|
|
|
|
game.InGameDbInitialized = false
|
2016-05-06 10:56:20 +00:00
|
|
|
game.PrevSessionMission = getDbProp("UI:VARIABLES:MISSION_SELECTED_PREV_SESSION")
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
debugInfo("onMainLoopBegin()")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
-- handler called by C++ to tell that all initial value have been set in the db
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:onInGameDbInitialized()
|
2016-05-06 10:56:20 +00:00
|
|
|
game.InGameDbInitialized = true
|
2017-03-24 14:12:18 +00:00
|
|
|
-- if the journal is opened, force an update for the fixed entry text
|
2016-05-06 10:56:20 +00:00
|
|
|
-- (says if we're in start island, paying account ...) need DB flags like
|
|
|
|
-- IS_NEWBIE & IS_TRIAL to be received
|
2017-03-24 14:12:18 +00:00
|
|
|
game:updateMissionJournalFixedEntry()
|
|
|
|
-- If a mission was previously selected, restore it
|
2016-05-06 10:56:20 +00:00
|
|
|
if game.PrevSessionMission ~= -1 then
|
2017-03-24 14:12:18 +00:00
|
|
|
self:setCurrentMission(game.PrevSessionMission)
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
game:setInfoPlayerCharacterRace()
|
|
|
|
end
|
|
|
|
|
|
|
|
function game:onWebIgReady()
|
|
|
|
-- Call init webig
|
|
|
|
getUI("ui:interface:web_transactions:content:html"):browse("home")
|
|
|
|
getUI("ui:interface:webig:content:html"):browse("home")
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
-- handler called by C++ at the start of a far TP (log to char selection or far tp)
|
|
|
|
function game:onFarTpStart()
|
|
|
|
debugInfo("game:onFarTpStart()")
|
|
|
|
--game:deinitWebIgApps()
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
-- handler called by C++ after characer reselection or the end of a far TP
|
|
|
|
function game:onFarTpEnd()
|
|
|
|
debugInfo("game:onFarTpEnd()")
|
|
|
|
--game:preInitWebIgApps()
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
-- handler called by C++ at the end of the main loop
|
|
|
|
function game:onMainLoopEnd()
|
|
|
|
game.InGameDbInitialized = false
|
|
|
|
game:updateMissionJournalFixedEntry()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
-- ring journal on / off
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:setMissionJournalRingMode(isRing)
|
2016-05-06 10:56:20 +00:00
|
|
|
local journal = getUI("ui:interface:info_player_journal")
|
|
|
|
if isRing then
|
|
|
|
journal.content.expand_mission_list.active = false
|
|
|
|
journal.content.mission_combo.active = false
|
|
|
|
journal.content.active = true
|
|
|
|
journal.content.mission_list.active = false
|
|
|
|
journal.content.sv.active = false
|
|
|
|
journal.content.fake.active = false
|
|
|
|
journal.content.separator.active = false
|
|
|
|
journal.content.separator_bis.active = false
|
|
|
|
journal.content.desc.active = false
|
|
|
|
journal.content.sv_desc.active = false
|
|
|
|
journal.no_available_missions.active = true
|
|
|
|
else
|
|
|
|
journal.content.expand_mission_list.active = true
|
2017-03-24 14:12:18 +00:00
|
|
|
journal.no_available_missions.active = false;
|
2016-05-06 10:56:20 +00:00
|
|
|
journal.content.active = true;
|
|
|
|
--journal.content.mission_list.active = true;
|
|
|
|
journal.content.sv.active = true;
|
|
|
|
journal.content.fake.active = true;
|
|
|
|
journal.content.separator.active = true;
|
|
|
|
journal.content.desc.active = getDbProp("UI:SAVE:MISSION_SELECTED") ~= -1;
|
|
|
|
journal.content.sv_desc.active = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
-- update mission journal depending on wether we're in the ring or not
|
|
|
|
function game:updateMissionJournalMode()
|
2017-03-24 14:12:18 +00:00
|
|
|
--local isRing = r2~=nil and r2.Mode~=nil and r2.Mode=='r2ed_anim_test'
|
|
|
|
game:setMissionJournalRingMode(isInRingMode())
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local remainingMissionTextIDs = {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getMissionWindow()
|
|
|
|
return getUI("ui:interface:info_player_journal")
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
-- This is called when a new step is added to the current mission. If so, make sure that the step
|
|
|
|
-- is visible in the listbox
|
|
|
|
function game:onNewMissionStepAdded(stepIndex)
|
|
|
|
local missionWnd = getMissionWindow()
|
|
|
|
local missionIndex = getDbProp("UI:SAVE:MISSION_SELECTED")
|
|
|
|
local dbPath
|
|
|
|
|
|
|
|
if missionIndex < 0 then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- debugInfo("New Step")
|
2017-03-24 14:12:18 +00:00
|
|
|
if missionIndex < 15 then
|
2016-05-06 10:56:20 +00:00
|
|
|
dbPath = "SERVER:MISSIONS:" .. tostring(missionIndex) .. ":GOALS:" .. tostring(stepIndex) .. ":TEXT"
|
2017-03-24 14:12:18 +00:00
|
|
|
else
|
2016-05-06 10:56:20 +00:00
|
|
|
dbPath = "SERVER:GROUP:MISSIONS:" .. tostring(missionIndex - 15) .. ":GOALS:" .. tostring(stepIndex) .. ":TEXT"
|
2017-03-24 14:12:18 +00:00
|
|
|
end
|
2016-05-06 10:56:20 +00:00
|
|
|
local stringID = getDbProp(dbPath)
|
|
|
|
if stringID ~= 0 then
|
|
|
|
-- debugInfo(tostring(stringID))
|
|
|
|
table.insert(remainingMissionTextIDs, stringID)
|
2017-03-24 14:12:18 +00:00
|
|
|
setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility0()")
|
|
|
|
else
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function game:ensureLastMissionStepVisibility0()
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
local missing = false
|
|
|
|
for k, v in pairs(remainingMissionTextIDs) do
|
|
|
|
if not isDynStringAvailable(v) then
|
|
|
|
missing = true
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
local missionWnd = getMissionWindow()
|
2017-03-24 14:12:18 +00:00
|
|
|
if not missing then
|
2016-05-06 10:56:20 +00:00
|
|
|
remainingMissionTextIDs = {}
|
2017-03-24 14:12:18 +00:00
|
|
|
-- delay real update to newt frame
|
|
|
|
setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility1()")
|
2016-05-06 10:56:20 +00:00
|
|
|
else
|
2017-03-24 14:12:18 +00:00
|
|
|
-- for debug : dump the list of remaining "dyn string"
|
2016-05-06 10:56:20 +00:00
|
|
|
--local stringList = "{"
|
|
|
|
--for k, v in remainingMissionTextIDs do
|
2017-03-24 14:12:18 +00:00
|
|
|
-- if not isDynStringAvailable(v) then
|
2016-05-06 10:56:20 +00:00
|
|
|
-- stringList = stringList .. " " .. tostring(v)
|
|
|
|
-- end
|
|
|
|
--end
|
2017-03-24 14:12:18 +00:00
|
|
|
--stringList = stringList .. "}"
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-03-24 14:12:18 +00:00
|
|
|
function game:ensureLastMissionStepVisibility1()
|
2016-05-06 10:56:20 +00:00
|
|
|
local missionWnd = getMissionWindow()
|
2017-03-24 14:12:18 +00:00
|
|
|
local scrollBar = missionWnd:find("sv_desc")
|
|
|
|
--scrollBar.trackPos = 20000 -- move upward
|
2016-05-06 10:56:20 +00:00
|
|
|
--scrollBar:updateCoords()
|
2017-03-24 14:12:18 +00:00
|
|
|
--setOnDraw(missionWnd, "")
|
|
|
|
local descWnd = missionWnd:find("desc")
|
2016-05-06 10:56:20 +00:00
|
|
|
local maxNumSteps = getDefine("ipj_nb_goal")
|
|
|
|
local topStep
|
2017-03-24 14:12:18 +00:00
|
|
|
for stepIndex = 0, maxNumSteps -1 do
|
2016-05-06 10:56:20 +00:00
|
|
|
local currStep = descWnd["step" .. tostring(stepIndex)]
|
|
|
|
if currStep.active then
|
|
|
|
topStep = currStep
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- debugInfo("Found step : " .. topStep.hardtext)
|
2017-03-24 14:12:18 +00:00
|
|
|
if topStep == nil then
|
2016-05-06 10:56:20 +00:00
|
|
|
return
|
2017-03-24 14:12:18 +00:00
|
|
|
end
|
2016-05-06 10:56:20 +00:00
|
|
|
|
|
|
|
scrollBar:ensureVisible(topStep, "M", "M")
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
--local wantedY = topStep.h_real / 2 - (descWnd.y_real - topStep.y_real)
|
2017-03-24 14:12:18 +00:00
|
|
|
--local wantedY = descWnd.y_real + descWnd.h_real - topStep.y_real
|
|
|
|
--local offsetY = wantedY - descWnd.max_h_real / 2
|
|
|
|
--if offsetY < 0 then offsetY = 0 end
|
2016-05-06 10:56:20 +00:00
|
|
|
--descWnd.ofsy = offsetY
|
|
|
|
--descWnd:invalidateCoords()
|
|
|
|
--descWnd:updateCoords()
|
|
|
|
|
2017-03-24 14:12:18 +00:00
|
|
|
setOnDraw(missionWnd, "")
|
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
-- This handler is triggered when a new mission has been added. In this case, we select the mission automatically
|
|
|
|
function game:onNewMissionAdded(missionIndex)
|
|
|
|
debugInfo("Mission " .. missionIndex .. " has been added")
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
-- RPJOBS
|
|
|
|
|
|
|
|
function game:addRpJob(jobtype, id, value, rpjobs)
|
|
|
|
local base_path = "ui:interface:info_player_skills:content:rpjobs:rpjob_"..jobtype.."_"..id..":rpjob_"..jobtype.."_infos_"..id
|
|
|
|
|
|
|
|
local group = getUI("ui:interface:info_player_skills:content:rpjobs:rpjob_"..jobtype.."_"..id)
|
|
|
|
|
|
|
|
if (value == nil) then
|
|
|
|
group.active = false
|
|
|
|
else
|
|
|
|
local name = "rpjob_" .. string.format("%03d", value)
|
|
|
|
local sitem = name..".sitem"
|
|
|
|
if (rpjobs[sitem] == nil) then
|
|
|
|
group.active = false
|
|
|
|
else
|
|
|
|
group.active = true
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
local echelon_value = rpjobs[sitem][1]
|
|
|
|
local quantity = rpjobs[sitem][2]
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
local maxlevel = (echelon_value*6)-30
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
if (quantity > maxlevel) then
|
|
|
|
quantity = maxlevel
|
|
|
|
end
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
local base = getUI(base_path..":t")
|
|
|
|
base.hardtext = i18n.get(name):toUtf8()
|
|
|
|
local ui = getUI(base_path..":icon")
|
|
|
|
ui.texture = name..".tga"
|
|
|
|
local echelon = getUI(base_path..":echelon_value")
|
|
|
|
echelon.hardtext = tostring(echelon_value/10)
|
|
|
|
local bar = getUI(base_path..":bar3d:level")
|
|
|
|
local t = getUI(base_path..":bar3d:t")
|
|
|
|
if (echelon_value >= 60) then
|
|
|
|
bar.color = "255 0 0 255"
|
|
|
|
bar.w = "368"
|
|
|
|
t.hardtext = i18n.get("uiRpjobMaxLevel"):toUtf8()
|
|
|
|
t.color = "255 255 0 255"
|
|
|
|
else
|
|
|
|
bar.color = tostring(math.floor((105*quantity)/maxlevel)).." "..tostring(100+math.floor((155*quantity)/maxlevel)).." "..tostring(math.floor((105*quantity)/maxlevel)).." 255"
|
|
|
|
bar.w = tostring((368*quantity)/maxlevel)
|
|
|
|
t.hardtext = tostring(quantity).." / "..tostring(maxlevel)
|
|
|
|
t.color = tostring(255*math.floor(3*(maxlevel-quantity)/maxlevel)).." "..tostring(255*math.floor(3*(maxlevel-quantity)/maxlevel)).." "..tostring(255*math.floor(3*(maxlevel-quantity)/maxlevel)).." 255"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function game:getRPJobs()
|
|
|
|
rpjobs_advanced = {}
|
|
|
|
rpjobs_elementary = {}
|
|
|
|
rpjobs_roleplay = {}
|
|
|
|
rpjobs = {}
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
for i = 0, 499, 1 do
|
|
|
|
local sheet = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":SHEET")
|
|
|
|
if (sheet ~= 0) then
|
|
|
|
local name = getSheetName(sheet)
|
|
|
|
if (string.sub(name, 0, 6) == "rpjob_") then
|
|
|
|
local quality = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":QUALITY")
|
|
|
|
local quantity = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":QUANTITY")
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
if (name == "rpjob_advanced.sitem") then
|
|
|
|
table.insert(rpjobs_advanced, quality)
|
|
|
|
else
|
|
|
|
if (name == "rpjob_elementary.sitem") then
|
|
|
|
table.insert(rpjobs_elementary, quality)
|
|
|
|
else
|
|
|
|
if (name == "rpjob_roleplay.sitem") then
|
|
|
|
table.insert(rpjobs_roleplay, quality)
|
|
|
|
else
|
|
|
|
if rpjobs[name] == nil then
|
|
|
|
rpjobs[name] = {quality, quantity}
|
|
|
|
else
|
|
|
|
if rpjobs[name][1] < quality then
|
|
|
|
rpjobs[name] = {quality, quantity}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-03-24 14:12:18 +00:00
|
|
|
|
2016-05-06 10:56:20 +00:00
|
|
|
for id=1,2,1 do
|
|
|
|
game:addRpJob("advanced", id, rpjobs_advanced[id], rpjobs)
|
|
|
|
end
|
|
|
|
|
|
|
|
for id=1,3,1 do
|
|
|
|
game:addRpJob("elementary", id, rpjobs_elementary[id], rpjobs)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------------------------------------
|
|
|
|
function game:setInfoPlayerCharacterRace()
|
|
|
|
getUI("ui:interface:info_player_skills:content:basics_skills:character_race_name").uc_hardtext = i18n.get("io"..getUserRace())
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- --------------------------------------------------------------------------------------------------------------
|
|
|
|
-- game.preInitTimer = 0
|
|
|
|
-- function game:preInitWebIgAppsLoop()
|
|
|
|
-- if game.preInitTimer == nil then game.preInitTimer = 0 end
|
|
|
|
|
|
|
|
-- game.preInitTimer = game.preInitTimer - 1
|
|
|
|
-- if (not game.preWebIgAppsInitialized) and game.preInitTimer < 0 then
|
|
|
|
-- debugInfo("initWebIgAppsLoop(): calling app_ig_preinit.php")
|
|
|
|
-- getUI("ui:interface:web_transactions:content:html"):browse("http://atys.ryzom.com/start/app_ig_preinit.php")
|
|
|
|
-- game.preInitTimer = getDbProp("UI:SAVE:WEBIG_RETRY_DELAY")
|
|
|
|
-- end
|
|
|
|
|
|
|
|
-- if game.preWebIgAppsInitialized then
|
|
|
|
-- debugInfo("preInitWebIgAppsLoop(): Calling removeOnDbChange()")
|
|
|
|
-- removeOnDbChange(getUI("ui:interface"), "@UI:VARIABLES:CURRENT_SERVER_TICK")
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
|
|
|
|
-- --------------------------------------------------------------------------------------------------------------
|
|
|
|
-- function game:preInitWebIgApps()
|
|
|
|
-- debugInfo("game:preInitWebIgApps()")
|
|
|
|
-- addOnDbChange(getUI("ui:interface"), "@UI:VARIABLES:CURRENT_SERVER_TICK", "game:preInitWebIgAppsLoop()")
|
|
|
|
-- end
|
|
|
|
|
|
|
|
-- --------------------------------------------------------------------------------------------------------------
|
|
|
|
-- game.postInitTimer = 0
|
|
|
|
-- function game:postInitWebIgAppsLoop()
|
|
|
|
-- if game.postInitTimer == nil then game.postInitTimer = 0 end
|
|
|
|
|
|
|
|
-- game.postInitTimer = game.postInitTimer - 1
|
|
|
|
-- if game.postInitTimer < 0 then
|
|
|
|
-- debugInfo("initWebIgAppsLoop(): calling app_ig_postinit.php")
|
|
|
|
-- getUI("ui:interface:web_transactions:content:html"):browse("http://atys.ryzom.com/start/app_ig_postinit.php")
|
|
|
|
-- game.postInitTimer = getDbProp("UI:SAVE:WEBIG_RETRY_DELAY")
|
|
|
|
-- end
|
|
|
|
|
|
|
|
-- if game.postWebIgAppsInitialized then
|
|
|
|
-- debugInfo("postInitWebIgAppsLoop(): Calling removeOnDbChange()")
|
|
|
|
-- removeOnDbChange(getUI("ui:interface:milko_pad"), "@UI:VARIABLES:CURRENT_SERVER_TICK")
|
|
|
|
-- end
|
|
|
|
-- end
|
|
|
|
|
|
|
|
-- --------------------------------------------------------------------------------------------------------------
|
|
|
|
-- function game:postInitWebIgApps()
|
|
|
|
-- debugInfo("game:postInitWebIgApps()")
|
|
|
|
-- addOnDbChange(getUI("ui:interface:milko_pad"), "@UI:VARIABLES:CURRENT_SERVER_TICK", "game:postInitWebIgAppsLoop()")
|
|
|
|
-- end
|
|
|
|
|
|
|
|
-- --------------------------------------------------------------------------------------------------------------
|
|
|
|
-- function game:deinitWebIgApps()
|
|
|
|
-- debugInfo("game:deinitWebIgApps()")
|
|
|
|
-- game.preWebIgAppsInitialized = nil
|
|
|
|
-- game.postWebIgAppsInitialized = nil
|
|
|
|
-- titleSetted = nil
|
|
|
|
-- end
|