diff --git a/data/kh/kh_interfaces/game_config.xml b/data/kh/kh_interfaces/game_config.xml index c417e3aa..55849ef8 100644 --- a/data/kh/kh_interfaces/game_config.xml +++ b/data/kh/kh_interfaces/game_config.xml @@ -2672,9 +2672,9 @@ + posref="TM TL" + x="0" + y="-35" /> + + @@ -199,7 +199,7 @@ x="-15" y="10" posref="BM BM" - text_y="-0" + text_y="0" onclick_l="proc" params_l="active_hardware_cursor" hardtext="uiYes" /> @@ -208,7 +208,7 @@ y="0" posparent="active_ok" posref="BR BL" - text_y="-0" + text_y="0" onclick_l="proc" params_l="close_hardware_cursor" hardtext="uiNo" /> @@ -316,7 +316,7 @@ x="0" y="6" posref="BM BM" - text_y="-0" + text_y="0" onclick_l="proc" params_l="universe_chanel_warning_close" hardtext="uittOK" /> @@ -425,7 +425,7 @@ x="0" y="6" posref="BM BM" - text_y="-0" + text_y="0" onclick_l="proc" params_l="death_warning_close" hardtext="uittOK" /> @@ -532,7 +532,7 @@ x="0" y="6" posref="BM BM" - text_y="-0" + text_y="0" onclick_l="proc" params_l="night_warning_close" hardtext="uittOK" /> @@ -865,7 +865,7 @@ + value="https://app.khaganat.net/ams/" /> self.WaitingPeriod then + if timeInSec - self.LastRefreshTime > self.WaitingPeriod then self.WaitingInfo = false self.LastRefreshTime = nltime.getLocalTime() / 1000 - else + else if not self.InfoReceived then --debugInfo("No received info") end end else - if timeInSec - self.LastRefreshTime > self.RefreshPeriod then + if timeInSec - self.LastRefreshTime > self.RefreshPeriod then self:refresh() else --debugInfo("pas de refresh") @@ -844,7 +844,7 @@ function RingPlayerInfo:updatePendingRefresh() if self.PendingRefresh then local currTime = nltime.getLocalTime() / 1000 - if currTime - self.LastRefreshQuerryTime > self.MinRefreshPeriod and game.getRingStats then + if currTime - self.LastRefreshQuerryTime > self.MinRefreshPeriod and game.getRingStats then self.LastRefreshQuerryTime = currTime self.PendingRefresh = false game.getRingStats() @@ -924,10 +924,10 @@ end -- function RingPlayerInfo:refresh() - self.PendingRefresh = true + self.PendingRefresh = true self.LastRefreshTime = nltime.getLocalTime() / 1000 self.WaitingInfo = true -end +end -------------------------------------------------------------------------------------------------------------- -- @@ -937,7 +937,7 @@ function RingPlayerInfo:tooltipEcosystemPoints(rp, maxRp, ttFormat) local fmt = i18n.get(ttFormat); fmt = findReplaceAll(fmt, "%n", rp ); fmt = findReplaceAll(fmt, "%p", maxRp ); - + -- Set tooltip return fmt; end @@ -954,8 +954,8 @@ function RingPlayerInfo:updateRRPSLevel(dbVal, tooltip) local ui= getUICaller(); local uiText= ui.val; - -- set the text - uiText.uc_hardtext= tostring(val) + -- set the text + uiText.uc_hardtext= tostring(val) self:tooltipRRPs(dbVal, tooltip) end @@ -970,7 +970,7 @@ function RingPlayerInfo:tooltipRRPs(dbBase, ttFormat) local fmt = i18n.get(ttFormat); local text = tostring(val) fmt = findReplaceAll(fmt, "%n", text ); - + -- Set tooltip setContextHelpText(fmt); end @@ -1013,7 +1013,7 @@ end -------------------------------------------------------------------------------------------------------------- -- function game:updateOrganization(path, uiOrgText, uiStatusText, uiPointsText) - + local org = getDbProp(path.."1:VALUE") getUICaller()[uiOrgText].uc_hardtext = i18n.get('uiOrganization_' .. org) @@ -1022,7 +1022,7 @@ function game:updateOrganization(path, uiOrgText, uiStatusText, uiPointsText) local points = getDbProp(path.."3:VALUE") getUICaller()[uiPointsText].uc_hardtext= points - + end ------------------------------------------------------------------------------------------------------------ @@ -1033,10 +1033,10 @@ end -------------------------------------------------------------------------------------------------------------- -function game:popMissionList() - local menu = getUI("ui:interface:mission_cb_menu") +function game:popMissionList() + local menu = getUI("ui:interface:mission_cb_menu") enableModalWindow(getUICaller(), "ui:interface:mission_cb_menu") - self:updateMissionMenuSize() + self:updateMissionMenuSize() end @@ -1053,12 +1053,12 @@ function game:getMissionDbPath(missionIndex) return "SERVER:GROUP:MISSIONS:" .. tostring(missionIndex - numMissions) else return "SERVER:MISSIONS:" .. tostring(missionIndex) - end + end end -------------------------------------------------------------------------------------------------------------- -function game:getCurrMissionIndex() - local result = getDbProp("UI:SAVE:MISSION_SELECTED") +function game:getCurrMissionIndex() + local result = getDbProp("UI:SAVE:MISSION_SELECTED") return result end @@ -1071,10 +1071,10 @@ end function game:updateCurrMissionComboBox() local numMissions = tonumber(getDefine("ipj_nb_mission")) local missionFound = false - local cb = getUI("ui:interface:info_player_journal:content:mission_combo") - local missionList = getUI("ui:interface:info_player_journal:content:mission_list") + local cb = getUI("ui:interface:info_player_journal:content:mission_combo") + local missionList = getUI("ui:interface:info_player_journal:content:mission_list") for i = 0, numMissions - 1 do - if getDbProp("SERVER:MISSIONS:" .. i .. ":TITLE") ~= 0 + if getDbProp("SERVER:MISSIONS:" .. i .. ":TITLE") ~= 0 or getDbProp("SERVER:GROUP:MISSIONS:" .. i .. ":TITLE") ~= 0 then missionFound = true break @@ -1095,20 +1095,20 @@ function game:updateCurrMissionComboBox() missionList.no_available_mission.active = false cb.arrow.active = true cb.select.active = true - local currMission = self:getCurrMissionIndex() + local currMission = self:getCurrMissionIndex() - local dbPath = self:getMissionDbPath(currMission) - -- - local selected = (currMission ~= -1) + local dbPath = self:getMissionDbPath(currMission) + -- + local selected = (currMission ~= -1) if selected then cb.mission_title.textid_dblink = dbPath .. ":TITLE" selected = (tile ~= 0) - end + end cb.mission_ico.active = selected cb.mission_title.active = selected cb.no_selected_mission.active = not selected missionList.no_selected_mission.active = not selected - if selected then + if selected then if getDbProp(dbPath .. ":FINISHED") == 0 then cb.mission_ico.texture = runExpr("getMissionSmallIcon(" .. tostring(getDbProp(dbPath .. ":ICON") .. ")")) elseif getDbProp(dbPath .. ":FINISHED") == 1 then @@ -1116,17 +1116,17 @@ function game:updateCurrMissionComboBox() else cb.mission_ico.texture = "Small_Task_Failed.tga" end - end + end end -------------------------------------------------------------------------------------------------------------- -function game:onMissionSelected(index) +function game:onMissionSelected(index) disableModalWindow() self:updateCurrMissionComboBox() end -------------------------------------------------------------------------------------------------------------- -function game:onGroupMissionSelected(index) +function game:onGroupMissionSelected(index) disableModalWindow() self:updateCurrMissionComboBox() end @@ -1138,33 +1138,33 @@ function game:onMissionDBIndexChanged() -- if selection was made from the list, update the other list if missionIndex >= self:getGroupMissionFirstIndex() then local groupMissionIndex = missionIndex - self:getGroupMissionFirstIndex() - getUI("ui:interface:info_player_journal:content:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true + getUI("ui:interface:info_player_journal:content:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true getUI("ui:interface:mission_cb_menu:mission_list:b_group_title" .. tostring(groupMissionIndex)).pushed = true else - getUI("ui:interface:info_player_journal:content:mission_list:b_title" .. tostring(missionIndex)).pushed = true + getUI("ui:interface:info_player_journal:content:mission_list:b_title" .. tostring(missionIndex)).pushed = true getUI("ui:interface:mission_cb_menu:mission_list:b_title" .. tostring(missionIndex)).pushed = true end end -------------------------------------------------------------------------------------------------------------- -function game:onMissionTitleChanged(index) +function game:onMissionTitleChanged(index) -- if title is not nil then a new mission has been added -> if db initilization is over, then selected this new mission - if getDbProp(self:getMissionDbPath(index) .. ":TITLE") ~= 0 then - if game.InGameDbInitialized or config.Local then + if getDbProp(self:getMissionDbPath(index) .. ":TITLE") ~= 0 then + if game.InGameDbInitialized or config.Local then self:setCurrentMission(index) end - else + else self:updateCurrMissionComboBox() self:updateMissionMenuSize() end end -------------------------------------------------------------------------------------------------------------- -function game:onGroupMissionTitleChanged(index) - if getDbProp(self:getMissionDbPath(index + 15) .. ":TITLE") ~= 0 then - if game.InGameDbInitialized or config.Local then +function game:onGroupMissionTitleChanged(index) + if getDbProp(self:getMissionDbPath(index + 15) .. ":TITLE") ~= 0 then + if game.InGameDbInitialized or config.Local then self:setCurrentMission(index + 15) end - else + else self:updateCurrMissionComboBox() self:updateMissionMenuSize() end @@ -1174,21 +1174,21 @@ end function game:updateMissionMenuSize() local parentCB = getUI("ui:interface:info_player_journal:content:mission_combo") local menu = getUI("ui:interface:mission_cb_menu") - if not menu.active then return end + if not menu.active then return end local maxNumMissions = 2 * self:getGroupMissionFirstIndex() - local missionCount = 0 + local missionCount = 0 for k = 0, maxNumMissions - 1 do if getDbProp(self:getMissionDbPath(k) .. ":TITLE") ~= 0 then - missionCount = missionCount + 1 + missionCount = missionCount + 1 end - end + end 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 - end + end local scrW local scrH scrW, scrH = getWindowSize() @@ -1197,7 +1197,7 @@ function game:updateMissionMenuSize() end menu.w = parentCB.w_real menu.y = y - menu.x = parentCB.x_real + menu.x = parentCB.x_real menu.h = 8 + missionCount * 18 menu:invalidateCoords() end @@ -1205,7 +1205,7 @@ end -------------------------------------------------------------------------------------------------------------- --function game:updateMissionDescCloseButton(index) -- local dbPath = self:getMissionDbPath(index) --- if index == self:getCurrMissionIndex() then +-- if index == self:getCurrMissionIndex() then -- 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") @@ -1224,29 +1224,29 @@ end --end -------------------------------------------------------------------------------------------------------------- -function game:onMissionFinished(index) - self:updateCurrMissionComboBox() +function game:onMissionFinished(index) + self:updateCurrMissionComboBox() --self:updateMissionDescCloseButton(index) end -------------------------------------------------------------------------------------------------------------- -function game:onGroupMissionFinished(index) +function game:onGroupMissionFinished(index) self:updateCurrMissionComboBox() --self:updateMissionDescCloseButton(index + game:getGroupMissionFirstIndex()) end -------------------------------------------------------------------------------------------------------------- -function game:expandMissionList() - local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo") +function game:expandMissionList() + local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo") missionCB.active = not missionCB.active self:updateMissionWindowLayout() end -------------------------------------------------------------------------------------------------------------- -function game:updateMissionWindowLayout() +function game:updateMissionWindowLayout() if not isInRingMode() then local missionCB = getUI("ui:interface:info_player_journal:content:mission_combo") - local missionList = getUI("ui:interface:info_player_journal:content:mission_list") + local missionList = getUI("ui:interface:info_player_journal:content:mission_list") 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") @@ -1254,18 +1254,18 @@ function game:updateMissionWindowLayout() local popMinH local win = getUI("ui:interface:info_player_journal") - if missionCB.active then - sepBis.active = false + if missionCB.active then + sepBis.active = false missionList.active = false fake.sizeref="" fake.y = -32 fake.h = 0 - expanded = 0 + expanded = 0 desc.max_sizeref ="wh" desc.max_h= -42 win.pop_min_h = 152 - win.content_y_offset - else - sepBis.active = true + else + sepBis.active = true missionList.active = true fake.sizeref="wh5" fake.y = -8 @@ -1274,23 +1274,23 @@ function game:updateMissionWindowLayout() desc.max_sizeref ="wh5" desc.max_h=16 win.pop_min_h = 152 - win.content_y_offset - end + end - local fixedEntry = getUI("ui:interface:info_player_journal:content:mission_fixed_entry") + local fixedEntry = getUI("ui:interface:info_player_journal:content:mission_fixed_entry") fixedEntry:updateCoords() desc.max_h = desc.max_h - fixedEntry.h setDbProp("UI:SAVE:EXPAND_MISSION_LIST", expanded) - getUI("ui:interface:info_player_journal"):invalidateCoords() + getUI("ui:interface:info_player_journal"):invalidateCoords() end end -------------------------------------------------------------------------------------------------------------- -function game:onMissionJournalOpened() +function game:onMissionJournalOpened() local missionDesc = getUI("ui:interface:info_player_journal:content:desc") - missionDesc.active = getDbProp("UI:SAVE:MISSION_SELECTED") ~= -1 + missionDesc.active = getDbProp("UI:SAVE:MISSION_SELECTED") ~= -1 - local expandList = getDbProp("UI:SAVE:EXPAND_MISSION_LIST") + local expandList = getDbProp("UI:SAVE:EXPAND_MISSION_LIST") self:updateMissionJournalMode() if not isInRingMode() then @@ -1304,9 +1304,9 @@ function game:onMissionJournalOpened() self:updateMissionJournalHeader() self:updateMissionWindowLayout() - self:updateMissionJournalFixedEntry() + self:updateMissionJournalFixedEntry() + - end @@ -1315,12 +1315,12 @@ 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 - win.right_button_enabled = headerActive + win.right_button_enabled = headerActive if headerActive then - win.uc_title_opened = i18n.get("uiJournalTitle") + win.uc_title_opened = i18n.get("uiJournalTitle") win.content_y_offset = 0 else - win.uc_title_opened = ucstring("") + win.uc_title_opened = ucstring("") win.content_y_offset = win.header_opened.h_real + 3 end end @@ -1329,13 +1329,13 @@ end -------------------------------------------------------------------------------------------------------------- function game:updateMissionJournalFixedEntry() -- update fixed entry text - - local fixedEntryRing = getUI("ui:interface:info_player_journal:no_available_missions:main:mission_fixed_entry") + + local fixedEntryRing = getUI("ui:interface:info_player_journal:no_available_missions:main:mission_fixed_entry") local fixedEntryMain = getUI("ui:interface:info_player_journal:content:mission_fixed_entry") - + fixedEntryRing.active = game.InGameDbInitialized and isInRingMode() - fixedEntryMain.active = game.InGameDbInitialized and not isInRingMode() - + fixedEntryMain.active = game.InGameDbInitialized and not isInRingMode() + local id = "uiFixedMissionEntry" @@ -1346,22 +1346,22 @@ function game:updateMissionJournalFixedEntry() end if isPlayerFreeTrial() then id = id .. "_Trial" - end + end else - if isInRingMode() then - id = id .. "_R2" - else + if isInRingMode() then + id = id .. "_R2" + else id = id .. "_Mainland_" .. getUserRace() end - end + end fixedEntryMain.uc_hardtext = i18n.get(id) fixedEntryRing.uc_hardtext = i18n.get(id) - + self:updateMissionWindowLayout() end -------------------------------------------------------------------------------------------------------------- -function game:setCurrentMission(index) +function game:setCurrentMission(index) mw = getMissionWindow() mw.active = game.InGameDbInitialized if index < self:getGroupMissionFirstIndex() then @@ -1372,7 +1372,7 @@ function game:setCurrentMission(index) end -------------------------------------------------------------------------------------------------------------- -function game:onMissionComboWheelUp() +function game:onMissionComboWheelUp() local currMissionIndex = self:getCurrMissionIndex() while currMissionIndex > 0 do currMissionIndex = currMissionIndex - 1 @@ -1384,7 +1384,7 @@ function game:onMissionComboWheelUp() end -------------------------------------------------------------------------------------------------------------- -function game:onMissionComboWheelDown() +function game:onMissionComboWheelDown() local currMissionIndex = self:getCurrMissionIndex() local maxNumMission = 2 * self:getGroupMissionFirstIndex() while currMissionIndex < (maxNumMission - 1) do @@ -1399,37 +1399,37 @@ end -------------------------------------------------------------------------------------------------------------- -function game:toggleMissionJournalCaption() - local dbPath = "UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE" +function game:toggleMissionJournalCaption() + local dbPath = "UI:SAVE:MISSION_JOURNAL_HEADER_ACTIVE" setDbProp(dbPath, 1 - getDbProp(dbPath)) - local win = getUI("ui:interface:info_player_journal") + local win = getUI("ui:interface:info_player_journal") self:updateMissionJournalHeader() self:updateMissionWindowLayout() end -------------------------------------------------------------------------------------------------------------- -- handler called by C++ to tell that the main loop is about to begin -function game:onMainLoopBegin() - game.InGameDbInitialized = false +function game:onMainLoopBegin() + game.InGameDbInitialized = false game.PrevSessionMission = getDbProp("UI:VARIABLES:MISSION_SELECTED_PREV_SESSION") - + debugInfo("onMainLoopBegin()") end -------------------------------------------------------------------------------------------------------------- -- handler called by C++ to tell that all initial value have been set in the db -function game:onInGameDbInitialized() +function game:onInGameDbInitialized() game.InGameDbInitialized = true - -- if the journal is opened, force an update for the fixed entry text + -- if the journal is opened, force an update for the fixed entry text -- (says if we're in start island, paying account ...) need DB flags like -- IS_NEWBIE & IS_TRIAL to be received - game:updateMissionJournalFixedEntry() - -- If a mission was previously selected, restore it + game:updateMissionJournalFixedEntry() + -- If a mission was previously selected, restore it if game.PrevSessionMission ~= -1 then - self:setCurrentMission(game.PrevSessionMission) + self:setCurrentMission(game.PrevSessionMission) end - + game:setInfoPlayerCharacterRace() end @@ -1437,7 +1437,7 @@ function game:onWebIgReady() -- Call init webig getUI("ui:interface:web_transactions:content:html"):browse("home") getUI("ui:interface:webig:content:html"):browse("home") - + end -------------------------------------------------------------------------------------------------------------- @@ -1464,7 +1464,7 @@ end -------------------------------------------------------------------------------------------------------------- -- ring journal on / off -function game:setMissionJournalRingMode(isRing) +function game:setMissionJournalRingMode(isRing) local journal = getUI("ui:interface:info_player_journal") if isRing then journal.content.expand_mission_list.active = false @@ -1480,7 +1480,7 @@ function game:setMissionJournalRingMode(isRing) journal.no_available_missions.active = true else journal.content.expand_mission_list.active = true - journal.no_available_missions.active = false; + journal.no_available_missions.active = false; journal.content.active = true; --journal.content.mission_list.active = true; journal.content.sv.active = true; @@ -1494,8 +1494,8 @@ end -------------------------------------------------------------------------------------------------------------- -- update mission journal depending on wether we're in the ring or not function game:updateMissionJournalMode() - --local isRing = r2~=nil and r2.Mode~=nil and r2.Mode=='r2ed_anim_test' - game:setMissionJournalRingMode(isInRingMode()) + --local isRing = r2~=nil and r2.Mode~=nil and r2.Mode=='r2ed_anim_test' + game:setMissionJournalRingMode(isInRingMode()) end @@ -1521,22 +1521,22 @@ function game:onNewMissionStepAdded(stepIndex) end -- debugInfo("New Step") - if missionIndex < 15 then + if missionIndex < 15 then dbPath = "SERVER:MISSIONS:" .. tostring(missionIndex) .. ":GOALS:" .. tostring(stepIndex) .. ":TEXT" - else + else dbPath = "SERVER:GROUP:MISSIONS:" .. tostring(missionIndex - 15) .. ":GOALS:" .. tostring(stepIndex) .. ":TEXT" - end + end local stringID = getDbProp(dbPath) if stringID ~= 0 then -- debugInfo(tostring(stringID)) table.insert(remainingMissionTextIDs, stringID) - setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility0()") - else + setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility0()") + else end end function game:ensureLastMissionStepVisibility0() - + local missing = false for k, v in pairs(remainingMissionTextIDs) do if not isDynStringAvailable(v) then @@ -1545,54 +1545,54 @@ function game:ensureLastMissionStepVisibility0() end end local missionWnd = getMissionWindow() - if not missing then + if not missing then remainingMissionTextIDs = {} - -- delay real update to newt frame - setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility1()") + -- delay real update to newt frame + setOnDraw(missionWnd, "game:ensureLastMissionStepVisibility1()") else - -- for debug : dump the list of remaining "dyn string" + -- for debug : dump the list of remaining "dyn string" --local stringList = "{" --for k, v in remainingMissionTextIDs do - -- if not isDynStringAvailable(v) then + -- if not isDynStringAvailable(v) then -- stringList = stringList .. " " .. tostring(v) -- end --end - --stringList = stringList .. "}" + --stringList = stringList .. "}" end end -function game:ensureLastMissionStepVisibility1() +function game:ensureLastMissionStepVisibility1() local missionWnd = getMissionWindow() - local scrollBar = missionWnd:find("sv_desc") - --scrollBar.trackPos = 20000 -- move upward + local scrollBar = missionWnd:find("sv_desc") + --scrollBar.trackPos = 20000 -- move upward --scrollBar:updateCoords() - --setOnDraw(missionWnd, "") - local descWnd = missionWnd:find("desc") + --setOnDraw(missionWnd, "") + local descWnd = missionWnd:find("desc") local maxNumSteps = getDefine("ipj_nb_goal") local topStep - for stepIndex = 0, maxNumSteps -1 do + for stepIndex = 0, maxNumSteps -1 do local currStep = descWnd["step" .. tostring(stepIndex)] if currStep.active then topStep = currStep end end -- debugInfo("Found step : " .. topStep.hardtext) - if topStep == nil then + if topStep == nil then return - end + end scrollBar:ensureVisible(topStep, "M", "M") - + --local wantedY = topStep.h_real / 2 - (descWnd.y_real - topStep.y_real) - --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 + --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 --descWnd.ofsy = offsetY --descWnd:invalidateCoords() --descWnd:updateCoords() - setOnDraw(missionWnd, "") - + setOnDraw(missionWnd, "") + end -------------------------------------------------------------------------------------------------------------- @@ -1618,16 +1618,16 @@ function game:addRpJob(jobtype, id, value, rpjobs) group.active = false else group.active = true - + local echelon_value = rpjobs[sitem][1] local quantity = rpjobs[sitem][2] - + local maxlevel = (echelon_value*6)-30 - + if (quantity > maxlevel) then quantity = maxlevel end - + local base = getUI(base_path..":t") base.hardtext = i18n.get(name):toUtf8() local ui = getUI(base_path..":icon") @@ -1657,7 +1657,7 @@ function game:getRPJobs() rpjobs_elementary = {} rpjobs_roleplay = {} rpjobs = {} - + for i = 0, 499, 1 do local sheet = getDbProp("SERVER:INVENTORY:BAG:"..tostring(i)..":SHEET") if (sheet ~= 0) then @@ -1665,7 +1665,7 @@ function game:getRPJobs() 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") - + if (name == "rpjob_advanced.sitem") then table.insert(rpjobs_advanced, quality) else @@ -1688,7 +1688,7 @@ function game:getRPJobs() end end end - + for id=1,2,1 do game:addRpJob("advanced", id, rpjobs_advanced[id], rpjobs) end diff --git a/data/kh/kh_interfaces/info_player.xml b/data/kh/kh_interfaces/info_player.xml index f26f4bb7..b4c8cea9 100644 --- a/data/kh/kh_interfaces/info_player.xml +++ b/data/kh/kh_interfaces/info_player.xml @@ -1467,7 +1467,7 @@ @@ -246,7 +246,7 @@ posref="MM MM" posparent="slot_force" x="0" - y="-2" + y="0" color="255 255 255 255" fontsize="10" shadow="true" @@ -364,7 +364,7 @@ id="b_life" posref="TL TL" x="0" - y="-2" + y="0" texture="slot_jauge.tga" inherit_gc_alpha="false" /> @@ -1078,7 +1077,7 @@ tooltip_parent="win" /> - @@ -1136,7 +1124,7 @@ target="tab1:active" /> + target="tab6:active" /> @@ -1148,9 +1136,6 @@ target="tab4:active" /> - - - + case_mode="%case_normal" /> - + @@ -3060,13 +3031,6 @@ --> - - - - - - @@ -3127,7 +3091,7 @@ + + + + + + + diff --git a/data/kh/kh_interfaces/phrase.xml b/data/kh/kh_interfaces/phrase.xml index 7c1fb260..af9b515b 100644 --- a/data/kh/kh_interfaces/phrase.xml +++ b/data/kh/kh_interfaces/phrase.xml @@ -420,7 +420,7 @@ diff --git a/data/kh/kh_interfaces/player.lua b/data/kh/kh_interfaces/player.lua index 3e105361..bcae610c 100644 --- a/data/kh/kh_interfaces/player.lua +++ b/data/kh/kh_interfaces/player.lua @@ -1,963 +1,964 @@ --- In this file we define functions that serves for player windows - -function getDbPropU(dbEntry) - value = getDbProp(dbEntry) - if (value < 0) then - value = 4294967296+value - end - return value -end - -if string.find(_VERSION, "Lua 5.0") then - function math.fmod(a, b) - return math.mod(a, b) - end -end - ------------------------------------------------------------------------------------------------------------- --- create the game namespace without reseting if already created in an other file. -if (game==nil) then - game= {}; -end - -if (game.PVP == nil) then - game.PVP = {}; - game.PVP.tagStartTimer = 0; - game.PVP.flagStartTimer = 0; - game.PVP.tagTimerStarted = false; - game.PVP.flagTimerStarted = false; -end - -if (game.BonusMalus == nil) then - game.BonusMalus = {}; - game.BonusMalus.DeathPenaltyBefore = -1; - game.BonusMalus.DeathPenaltyAfter = -1; - game.BonusMalus.XPCatSlotBefore = -1; - game.BonusMalus.XPCatSlotAfter = -1; - game.BonusMalus.RingXPCatSlotBefore = -1; - game.BonusMalus.RingXPCatSlotAfter = -1; - game.BonusMalus.OutpostSlotBefore = -1; - game.BonusMalus.OutpostSlotAfter = -1; - game.BonusMalus.BonusAHList= {}; - game.BonusMalus.MalusAHList= {}; -end - - ------------------------------------------------------------------------------------------------------------- --- Update player bars in function of what we wants to display (we can hide each one of the 3 bars : sap,stamina and focus) -function game:updatePlayerBars() - - local dispChaScore3 = getDbProp('UI:SAVE:PLAYER:DISP_ChaScore3'); - local dispChaScore2 = getDbProp('UI:SAVE:PLAYER:DISP_ChaScore2'); - local dispChaScore4 = getDbProp('UI:SAVE:PLAYER:DISP_ChaScore4'); - - local ui = getUI('ui:interface:player:content'); - - -- active ui in function of what is displayed - - ui.b_ChaScore3.active = (dispChaScore3 == 1); - ui.jChaScore3.active = (dispChaScore3 == 1); - - ui.b_ChaScore2.active = (dispChaScore2 == 1); - ui.jChaScore2.active = (dispChaScore2 == 1); - - ui.b_ChaScore4.active = (dispChaScore4 == 1); - ui.jChaScore4.active = (dispChaScore4 == 1); - - -- choose good y-position - - local totalBarDisp = dispChaScore3 + dispChaScore2 + dispChaScore4; - if (totalBarDisp == 3) then - - ui.b_ChaScore3.y = -20; - ui.b_ChaScore2.y = -35; - ui.b_ChaScore4.y = -50; - ui.current_action.y = -65; - - elseif (totalBarDisp == 2) then - - if (dispChaScore3 == 0) then - ui.b_ChaScore2.y = -20; - ui.b_ChaScore4.y = -35; - end - - if (dispChaScore2 == 0) then - ui.b_ChaScore3.y = -20; - ui.b_ChaScore4.y = -35; - end - - if (dispChaScore4 == 0) then - ui.b_ChaScore3.y = -20; - ui.b_ChaScore2.y = -35; - end - - ui.current_action.y = -50; - - elseif (totalBarDisp == 1) then - - ui.b_ChaScore2.y = -20; - ui.b_ChaScore4.y = -20; - ui.b_ChaScore2.y = -20; - - ui.current_action.y = -35; - - else - ui.current_action.y = -20; - end - - -end - - ------------------------------------------------------------------------------------------------------------- --- convert a boolean to a number 0 or 1 -function booleanToNumber(thebool) - if(thebool) then - return 1; - else - return 0; - end -end - ------------------------------------------------------------------------------------------------------------- --- Update player pvp tag -function game:pvpTagUpdateDisplay() - local currentServerTick = getDbPropU('UI:VARIABLES:CURRENT_SERVER_TICK'); - local pvpServerTagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:ACTIVATION_TIME'); - local pvpServerFlagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:FLAG_PVP_TIME_LEFT'); - local uiPlayer= getUI('ui:interface:player:header_opened'); - - -- get the current state - local pvpServerFlag= pvpServerFlagTimer > currentServerTick; - local pvpLocalTag= (getDbProp('UI:TEMP:PVP_FACTION:TAG_PVP') == 1); - local pvpServerTag= (getDbProp('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:TAG_PVP') == 1); - local pvpServerActivateTimerOn= pvpServerTagTimer > currentServerTick; - - -- deduce the display state according to the current state - local GREEN= 0; - local ORANGE= 1; - local RED= 2; - local buttonMode= GREEN; - local buttonPushed= false; - local buttonTimer= false; - -- if the flag is activated, then must display PVP flag button and timer - if (pvpServerFlag) then - -- ** RED MODE - buttonMode= RED; - buttonPushed= false; - buttonTimer= true; - -- else must display correct mode according to the TAG state - else - -- There are 8 possibilities according to the combination of the 3 flags - -- Here: TL= pvpLocalTag, TS= pvpServerTag, AS= pvpServerActivateTimerOn) - -- TL TS AS - -- ** GREEN MODE ** - -- 0 0 0 -> Standard disabled PVP - -- 1 0 0 -> The user pressed the button but still no response from server - -- 1 1 1 -> The user pressed the button and got response from server. => GREEN icon with timer - -- 0 1 1 -> The user canceled the activation (server not acked yet the cancel). => default display - -- ** ORANGE MODE ** - -- 1 1 0 -> Standard enabled PVP - -- 0 1 0 -> The user pressed the button but still no response from server - -- 0 0 1 -> The user pressed the button and got response from server. => ORANGE icon with timer - -- 1 0 1 -> The user canceled the activation (server not acked yet the cancel). => default display - - -- From this table, we can deduce the following rules - - -- buttonMode is GREEN when TS==AS - if( pvpServerTag == pvpServerActivateTimerOn ) then - buttonMode= GREEN; - else - buttonMode= ORANGE; - end - - -- the button is pushed if (there is a timer and TL==TS), or (no timer and TL!=TS) - if( pvpServerActivateTimerOn == (pvpLocalTag == pvpServerTag) ) then - buttonPushed= true; - else - buttonPushed= false; - end - - -- display a timer only if the timer is activated and server and local tag are equals - if( pvpServerActivateTimerOn and pvpLocalTag == pvpServerTag ) then - buttonTimer= true; - else - buttonTimer= false; - end - - end - - -- setup the local display - setDbProp("UI:TEMP:PVP_FACTION:DSP_MODE", buttonMode); - setDbProp("UI:TEMP:PVP_FACTION:DSP_PUSHED", booleanToNumber(buttonPushed)); - setDbProp("UI:TEMP:PVP_FACTION:DSP_TIMER", booleanToNumber(buttonTimer)); - - -- setup the timer bar - if(buttonTimer) then - local uiBar = uiPlayer.pvp_timer; - local uiBarBg = uiPlayer.pvp_timer_bg; - -- Flag Bar? - if(buttonMode==RED) then - -- display a reverse timer - uiBar.w = uiBarBg.w * (pvpServerFlagTimer - currentServerTick) / (pvpServerFlagTimer - game.PVP.flagStartTimer); - else - -- display a forward timer - uiBar.w = uiBarBg.w * (currentServerTick - game.PVP.tagStartTimer) / (pvpServerTagTimer - game.PVP.tagStartTimer); - end - end - - -- force update of the tooltip for any button (by disabling then reenabling) - disableContextHelpForControl(uiPlayer.pvp_tag_button_0); - disableContextHelpForControl(uiPlayer.pvp_tag_button_1); - disableContextHelpForControl(uiPlayer.pvp_tag_button_2); -end - ------------------------------------------------------------------------------------------------------------- --- Update player pvp tag -function game:pvpTag() - local buttonStat = getDbProp('UI:TEMP:PVP_FACTION:TAG_PVP'); - if (buttonStat == 0) then - setDbProp('UI:TEMP:PVP_FACTION:TAG_PVP',1); - else - setDbProp('UI:TEMP:PVP_FACTION:TAG_PVP',0); - end - sendMsgToServerPvpTag(buttonStat == 0); - - -- update display - self:pvpTagUpdateDisplay(); -end - ------------------------------------------------------------------------------------------------------------- --- Update button due to server validation -function game:updatePvpTag() - -- force copy to temp of Server tag - local pvpServerTag= (getDbProp('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:TAG_PVP') == 1); - setDbProp('UI:TEMP:PVP_FACTION:TAG_PVP', booleanToNumber(pvpServerTag)); - - -- launch timer DB if necessary - local currentServerTick = getDbPropU('UI:VARIABLES:CURRENT_SERVER_TICK'); - local pvpServerTagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:ACTIVATION_TIME'); - local pvpServerFlagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:FLAG_PVP_TIME_LEFT'); - - if(pvpServerTagTimer > currentServerTick) or (pvpServerFlagTimer > currentServerTick) then - local ui = getUI('ui:interface:player'); - addOnDbChange(ui,'@UI:VARIABLES:CURRENT_SERVER_TICK', 'game:updatePvpTimer()'); - - if(pvpServerTagTimer > currentServerTick and game.PVP.tagTimerStarted == false) then - game.PVP.tagStartTimer = currentServerTick; - game.PVP.tagTimerStarted = true; - end - if(pvpServerFlagTimer > currentServerTick and game.PVP.flagTimerStarted == false) then - game.PVP.flagStartTimer = currentServerTick; - game.PVP.flagTimerStarted = true; - end - end - - -- update display (after start timer reseted) - self:pvpTagUpdateDisplay(); -end - ------------------------------------------------------------------------------------------------------------- --- -function game:updatePvpTimer() - - -- update display - self:pvpTagUpdateDisplay(); - - -- try to stop - local currentServerTick = getDbPropU('UI:VARIABLES:CURRENT_SERVER_TICK'); - local pvpServerTagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:ACTIVATION_TIME'); - local pvpServerFlagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:FLAG_PVP_TIME_LEFT'); - - -- Manage Tag Timer display - if(pvpServerTagTimer <= currentServerTick) then - game.PVP.tagTimerStarted = false; - end - - -- Manage Flag Timer display - if(pvpServerFlagTimer <= currentServerTick) then - game.PVP.flagTimerStarted = false; - end - - -- if both off, stop the db update - if(game.PVP.tagTimerStarted == false) and (game.PVP.flagTimerStarted == false) then - removeOnDbChange(getUI('ui:interface:player'),'@UI:VARIABLES:CURRENT_SERVER_TICK'); - end -end - ------------------------------------------------------------------------------------------------------------- --- -function game:formatTime(temps) - - local hours = math.floor(temps/(10*60*60)); - local minutes = math.floor((temps - (hours*10*60*60)) / (10*60)); - local seconds = math.floor((temps - (hours*10*60*60) - (minutes*10*60)) / 10); - - local fmt = i18n.get('uittPvPTime'); - fmt = findReplaceAll(fmt, '%h', tostring(hours)); - fmt = findReplaceAll(fmt, '%m', tostring(minutes)); - fmt = findReplaceAll(fmt, '%s', tostring(seconds)); - return fmt; -end - ------------------------------------------------------------------------------------------------------------- --- -function game:playerTTPvp() - - -- The tooltip to display depends on the current display state - local buttonMode= getDbProp("UI:TEMP:PVP_FACTION:DSP_MODE"); - local buttonPushed= (getDbProp("UI:TEMP:PVP_FACTION:DSP_PUSHED")==1); - local buttonTimer= (getDbProp("UI:TEMP:PVP_FACTION:DSP_TIMER")==1); - local text; - - -- Flag mode? - if(buttonMode==2) then - local pvpServerFlagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:FLAG_PVP_TIME_LEFT'); - local currentServerTick = getDbPropU('UI:VARIABLES:CURRENT_SERVER_TICK'); - local tempsString = game:formatTime( pvpServerFlagTimer - currentServerTick ); - text = i18n.get('uittPvPModeFlag'); - text = findReplaceAll(text, '%temps', tempsString); - -- Tag mode - else - -- base text - if(buttonMode==0 and not(buttonPushed)) then - text = i18n.get('uittPvPModeTagOff'); - elseif(buttonMode==0 and buttonPushed) then - text = i18n.get('uittPvPModeTagOffChange'); - elseif(buttonMode==1 and not(buttonPushed)) then - text = i18n.get('uittPvPModeTagOn'); - elseif(buttonMode==1 and buttonPushed) then - text = i18n.get('uittPvPModeTagOnChange'); - else - text = ucstring(); - end - -- timer - if(buttonTimer) then - local pvpServerTagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:ACTIVATION_TIME'); - local currentServerTick = getDbPropU('UI:VARIABLES:CURRENT_SERVER_TICK'); - local tempsString = game:formatTime( pvpServerTagTimer - currentServerTick ); - local timeFmt= i18n.get('uittPvPTagTimer'); - timeFmt= findReplaceAll(timeFmt, '%temps', tempsString); - text= concatUCString(text, timeFmt); - end - end - - -- set the text - setContextHelpText(text); -end - - - --- *************************************************************************** --- *************************************************************************** --- BONUS MALUS --- *************************************************************************** --- *************************************************************************** - - ------------------------------------------------------------------------------------------------------------- -function game:bonusMalusActiveText(ui, slot, state) - local uiTextGroup= ui["text" .. tostring(slot) ]; - if(uiTextGroup) then - uiTextGroup.active= state; - end -end - ------------------------------------------------------------------------------------------------------------- -function game:bonusMalusSetText(ui, slot, fmt) - local uiTextGroup= ui["text" .. tostring(slot) ]; - if(uiTextGroup) then - uiTextGroup.shade0.uc_hardtext_format= fmt; - uiTextGroup.shade1.uc_hardtext_format= fmt; - uiTextGroup.shade2.uc_hardtext_format= fmt; - uiTextGroup.shade3.uc_hardtext_format= fmt; - uiTextGroup.text.uc_hardtext_format= fmt; - uiTextGroup.text2.uc_hardtext_format= fmt; - end -end - ------------------------------------------------------------------------------------------------------------- --- From given DB vals, compute the 'Xp Bonus' text info -function game:updateXpCatQuantity(textSlot, ui) - -- get the ui text to fill - if(ui==nil) then - ui= getUICaller(); - end - - -- format the text - local fmt= "x@{FF6F}" .. tostring( getDbProp("SERVER:CHARACTER_INFO:XP_CATALYSER:Count") ); - - self:bonusMalusSetText(ui, textSlot, fmt); -end - - ------------------------------------------------------------------------------------------------------------- --- From given DB vals, compute the 'Ring Xp Bonus' text info -function game:updateRingXpCatQuantity(textSlot, ui) - -- get the ui text to fill - if(ui==nil) then - ui= getUICaller(); - end - - -- format the text - local fmt= "x@{FF6F}" .. tostring( getDbProp("SERVER:CHARACTER_INFO:RING_XP_CATALYSER:Count") ); - - self:bonusMalusSetText(ui, textSlot, fmt); -end - - ------------------------------------------------------------------------------------------------------------- -function game:outpostUpdatePVPTimer(textSlot, ui) - -- get the ui text to fill - if(ui==nil) then - ui= getUICaller(); - end - - -- Get the timer of interest (priority to player leaving the zone) - local endTimer= 0; - local endOfPvpTimer= getDbPropU('SERVER:CHARACTER_INFO:PVP_OUTPOST:FLAG_PVP_TIME_END'); - if( endOfPvpTimer>0 ) then - endTimer= endOfPvpTimer; - else - local endOfRound= getDbProp('SERVER:CHARACTER_INFO:PVP_OUTPOST:ROUND_END_DATE'); - if( endOfRound>0 ) then - endTimer= endOfRound; - end - end - - -- Use a text with a timer? - if( endTimer>0 ) then - -- compute the time that lefts in sec (suppose a smooth server tick is 1 ms) - local curTick= getDbPropU('UI:VARIABLES:CURRENT_SERVER_TICK'); - local timeSec= (endTimer- curTick)/10; - -- replace in str - local text= "@{FF6F}" .. runFct('secondsToTimeStringShort', timeSec); - self:bonusMalusSetText(ui, textSlot, text); - -- else Default display - else - self:bonusMalusSetText(ui, textSlot, "@{FF6F}on"); - end - -end - - ------------------------------------------------------------------------------------------------------------- -function game:deathPenaltyUpdateXPMalus() -end - - ------------------------------------------------------------------------------------------------------------- --- called when someone click on a bonus malus icon. redirect to correct action handler if any -function game:onLeftClickBonus() - local ui= getUICaller(); - local id= getIndexInDB(ui); - local ah= self.BonusMalus.BonusAHList[id]; - if(ui and ah) then - runAH(ui, ah, ""); - end -end - -function game:onLeftClickMalus() - local ui= getUICaller(); - local id= getIndexInDB(ui); - local ah= self.BonusMalus.MalusAHList[id]; - if(ui and ah) then - runAH(ui, ah, ""); - end -end - ------------------------------------------------------------------------------------------------------------- --- update if needed the ActionHandler and text update from DB -function game:updateBonusMalusTextSetup() - local numLocalBonusMalus= getDefine("num_local_bonus_malus"); - local uiBonus= getUI('ui:interface:bonus_malus:header_opened:bonus'); - local uiMalus= getUI('ui:interface:bonus_malus:header_opened:malus'); - local dbXpCat= "@SERVER:CHARACTER_INFO:XP_CATALYSER:Count"; - local dbRingXpCat= "@SERVER:CHARACTER_INFO:RING_XP_CATALYSER:Count"; - local dbOutpost= "@SERVER:CHARACTER_INFO:PVP_OUTPOST, @UI:VARIABLES:CURRENT_SERVER_TICK"; - local dbDeathPenalty= "@SERVER:USER:DEATH_XP_MALUS"; - - - -- reset cache - self.BonusMalus.DeathPenaltyBefore= self.BonusMalus.DeathPenaltyAfter; - self.BonusMalus.XPCatSlotBefore= self.BonusMalus.XPCatSlotAfter; - self.BonusMalus.RingXPCatSlotBefore= self.BonusMalus.RingXPCatSlotAfter; - self.BonusMalus.OutpostSlotBefore= self.BonusMalus.OutpostSlotAfter; - - - -- *** remove and hide any preceding - for i= 0,numLocalBonusMalus-1 do - -- reset AH - self.BonusMalus.BonusAHList[i]= nil; - self.BonusMalus.MalusAHList[i]= nil; - -- hide text view - self:bonusMalusActiveText(uiBonus, i, false); - -- reset special tooltip - setDbProp( formatUI('UI:VARIABLES:BONUS:#1:SPECIAL_TOOLTIP', i), game.TBonusMalusSpecialTT.None); - end - removeOnDbChange(uiBonus, dbXpCat); - removeOnDbChange(uiBonus, dbRingXpCat); - removeOnDbChange(uiBonus, dbOutpost); - - - -- *** set new XPCat setup - local slot= self.BonusMalus.XPCatSlotAfter; - if(slot~=-1) then - -- set AH to use for this slot - self.BonusMalus.BonusAHList[slot]= "xp_catalyser_stop_use"; - -- add DB change, and call now! else not updated - addOnDbChange(uiBonus, dbXpCat, formatUI("game:updateXpCatQuantity(#1, nil)", slot) ); - self:updateXpCatQuantity(slot, uiBonus); - -- show text - self:bonusMalusActiveText(uiBonus, slot, true); - -- set special tooltip (id==1 for xpcat) - setDbProp( formatUI('UI:VARIABLES:BONUS:#1:SPECIAL_TOOLTIP', slot), game.TBonusMalusSpecialTT.XpCatalyser); - end - - -- *** set new RingXPCat setup - local slot= self.BonusMalus.RingXPCatSlotAfter; - if(slot~=-1) then - -- set AH to use for this slot - self.BonusMalus.BonusAHList[slot]= "ring_xp_catalyser_stop_use"; - -- add DB change, and call now! else not updated - addOnDbChange(uiBonus, dbRingXpCat, formatUI("game:updateRingXpCatQuantity(#1, nil)", slot) ); - self:updateRingXpCatQuantity(slot, uiBonus); - -- show text - self:bonusMalusActiveText(uiBonus, slot, true); - -- set special tooltip (id==1 for ringxpcat) - setDbProp( formatUI('UI:VARIABLES:BONUS:#1:SPECIAL_TOOLTIP', slot), game.TBonusMalusSpecialTT.XpCatalyser); - end - - - -- *** set new Outpost setup - local slot= self.BonusMalus.OutpostSlotAfter; - if(slot~=-1) then - -- no AH - -- add DB change, and call now! else not updated - addOnDbChange(uiBonus, dbOutpost, formatUI("game:outpostUpdatePVPTimer(#1, nil)", slot) ); - self:outpostUpdatePVPTimer(slot, uiBonus); - -- show text - self:bonusMalusActiveText(uiBonus, slot, true); - -- don't set the tooltip here, because redone after return - end - - - -- *** set new DeathPenalty setup - local slot= self.BonusMalus.DeathPenaltyAfter; - if(slot~=-1) then - -- no AH - -- add DB change, and call now! else not updated - addOnDbChange(uiMalus, dbDeathPenalty, formatUI("game:deathPenaltyUpdateXPMalus(#1, nil)", slot) ); - self:deathPenaltyUpdateXPMalus(slot, uiMalus); - -- show text - self:bonusMalusActiveText(uiMalus, slot, true); - -- set special tooltip (id==1 for death penalty) - setDbProp( formatUI('UI:VARIABLES:MALUS:#1:SPECIAL_TOOLTIP', slot), game.TBonusMalusSpecialTT.DeathPenalty); - end - -end - ------------------------------------------------------------------------------------------------------------- --- Update Bonus malus local DB according to server DB -function game:updatePlayerBonusMalus() - local numServerBonusMalus= tonumber(getDefine("num_server_bonus_malus")); - local numLocalBonusMalus= tonumber(getDefine("num_local_bonus_malus")); - local dbServerBonusBase= getDefine("bonus") .. ":" ; - local dbServerMalusBase= getDefine("malus") .. ":" ; - local dbLocalBonusBase= "UI:VARIABLES:BONUS:"; - local dbLocalMalusBase= "UI:VARIABLES:MALUS:"; - - local i; - local mustUpdateTextSetup= false; - - - -- *********************** - -- *** Insert Bonus - -- *********************** - local destIndex= 0; - local mustShowBonus= false; - - -- *** Insert XPCatalyzer first - local xpcatCount= getDbProp("SERVER:CHARACTER_INFO:XP_CATALYSER:Count"); - if(xpcatCount~=0) then - local xpcatLevel= getDbProp("SERVER:CHARACTER_INFO:XP_CATALYSER:Level"); - -- Get the most appropriate icon - local iconLevel= 50; - for i= 50,250,50 do - if(i<=xpcatLevel) then - iconLevel= i; - end - end - -- Set the DB for this brick - mustShowBonus= true; - setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":SHEET", getSheetId('big_xpcat_' .. tostring(iconLevel) .. '.sbrick' ) ); - setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":DISABLED", 0 ); - self.BonusMalus.XPCatSlotAfter = destIndex; - destIndex= destIndex+1; - else - self.BonusMalus.XPCatSlotAfter = -1; - end - if(self.BonusMalus.XPCatSlotAfter ~= self.BonusMalus.XPCatSlotBefore) then - mustUpdateTextSetup= true; - end - - -- *** Then insert RingXPCatalyzer - local ringxpcatCount= getDbProp("SERVER:CHARACTER_INFO:RING_XP_CATALYSER:Count"); - if(ringxpcatCount~=0) then - local ringxpcatLevel= getDbProp("SERVER:CHARACTER_INFO:RING_XP_CATALYSER:Level"); - -- Get the most appropriate icon - local iconLevel= 50; - for i= 50,250,50 do - if(i<=ringxpcatLevel) then - iconLevel= i; - end - end - -- Set the DB for this brick - mustShowBonus= true; - setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":SHEET", getSheetId('big_ring_xpcat_' .. tostring(iconLevel) .. '.sbrick' ) ); - setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":DISABLED", 0 ); - self.BonusMalus.RingXPCatSlotAfter = destIndex; - destIndex= destIndex+1; - else - self.BonusMalus.RingXPCatSlotAfter = -1; - end - if(self.BonusMalus.RingXPCatSlotAfter ~= self.BonusMalus.RingXPCatSlotBefore) then - mustUpdateTextSetup= true; - end - - - -- *** Insert PVPOutpost - local pvpOutpostPresent= getDbProp("SERVER:CHARACTER_INFO:PVP_OUTPOST:FLAG_PVP"); - local pvpOutpostEndOfPVPFlag= 0; - local pvpOutpostEndOfRound= 0; - if(pvpOutpostPresent~=0) then - local pvpOutpostLevel= 0; - pvpOutpostEndOfPVPFlag= getDbPropU('SERVER:CHARACTER_INFO:PVP_OUTPOST:FLAG_PVP_TIME_END'); - pvpOutpostEndOfRound= getDbPropU('SERVER:CHARACTER_INFO:PVP_OUTPOST:ROUND_END_DATE'); - -- set a level only if we have some round, and if the out timer is not set - if(pvpOutpostEndOfRound~=0 and pvpOutpostEndOfPVPFlag==0) then - pvpOutpostLevel= 1 + getDbProp('SERVER:CHARACTER_INFO:PVP_OUTPOST:ROUND_LVL_CUR'); - end - - -- Set the DB for this brick - mustShowBonus= true; - setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":SHEET", getSheetId('big_outpost_pvp_' .. tostring(pvpOutpostLevel) .. '.sbrick' ) ); - setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":DISABLED", 0 ); - self.BonusMalus.OutpostSlotAfter = destIndex; - destIndex= destIndex+1; - else - self.BonusMalus.OutpostSlotAfter = -1; - end - if(self.BonusMalus.OutpostSlotAfter ~= self.BonusMalus.OutpostSlotBefore) then - mustUpdateTextSetup= true; - end - - - -- *** Insert standard Bonus - for i=0,numServerBonusMalus-1 do - -- get - local sheet= getDbProp(dbServerBonusBase .. tostring(i) .. ":SHEET" ); - local disabled= getDbProp(dbServerBonusBase .. tostring(i) .. ":DISABLED" ); - if(sheet~=0) then - mustShowBonus= true; - end - -- copy (to index shifted if needed) - setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":SHEET", sheet ); - setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":DISABLED", disabled ); - destIndex= destIndex+1; - end - if(mustShowBonus) then - setDbProp("UI:VARIABLES:SHOW_BONUS", 1); - else - setDbProp("UI:VARIABLES:SHOW_BONUS", 0); - end - - - -- *** erase any remaining bonus - while destIndex 0 then result = concatUCString(tostring(seconds), i18n.get("uittSecondsShort")) end - if minutes > 0 then result = concatUCString(tostring(minutes), i18n.get("uittMinutesShort"), result) end - if hours > 0 then result = concatUCString(tostring(hours), i18n.get("uittHoursShort"), result) end - return result -end - ------------------------------------------------------------------------------------------------------------- --- display the time left for a power / auras in its tooltip -function game:setPhraseTooltipPowerRegenTime(ttWin, regenTimeInTicks) - local text = ttWin:find("regen_time") - if regenTimeInTicks == 0 then - text.active = false - else - text.active = true - text.uc_hardtext_single_line_format = concatUCString(i18n.get("uittRegenTime"), game:timeInSecondsToReadableTime(math.floor((regenTimeInTicks + 9) * 0.1))) - text:invalidateCoords() - ttWin:invalidateCoords() - end -end - - -local EmptyUCString = ucstring() - ------------------------------------------------------------------------------------------------------------- --- called by C++ code when the tooltip of a phrase is about to be displayed -function game:updatePhraseTooltip(phrase) - LastTooltipPhrase = phrase - local ttWin = getUI("ui:interface:action_context_help") - local text = phrase:getName() - - if not text or text == EmptyUCString then - text = ucstring("") - end - - local desc = phrase:getDesc() - if desc and desc ~= EmptyUCString then - local str = tostring(desc) - local charFound = false - for k = 1, string.len(str) do - if string.byte(str, k) ~= 32 then - charFound = true - break - end - end - if charFound then - text = concatUCString(text, "\n@{CCCF}", desc) - end - else - text = concatUCString(text, "@{CCCF}") - end - -- IMPORTANT : the following getters on 'phrase' take in account the 'total action malus' for the timebeing - self:setPhraseTooltipCarac(ttWin, "ChaScore1_cost", phrase:getChaScore1Cost()) - self:setPhraseTooltipCarac(ttWin, "ChaScore3_cost", phrase:getChaScore3Cost()) - self:setPhraseTooltipCarac(ttWin, "ChaScore2_cost", phrase:getChaScore2Cost()) - self:setPhraseTooltipCarac(ttWin, "ChaScore4_cost", phrase:getChaScore4Cost()) - self:setPhraseTooltipCarac(ttWin, "cast_time", phrase:getCastTime(), concatUCString(string.format("%.1f", phrase:getCastTime()), i18n.get("uittSeconds"))) - local castRange = phrase:getCastRange() - if not phrase:isMagicPhrase() then - castRange = 0 - end - self:setPhraseTooltipCarac(ttWin, "cast_range", castRange, concatUCString(tostring(castRange), i18n.get("uittMeters"))) - -- if the phrase is a power / aura, then we may want to display its regen time in the tooltip - if phrase:isPowerPhrase() then - setOnDraw(ttWin, "game:updatePowerPhraseTooltip()") - else - setOnDraw(ttWin, "") - end - -- - local successRateText = ttWin:find("success_rate") - local successRate = phrase:getSuccessRate() - if successRate == 0 then - successRateText.active = false - else - successRateText.active = true - successRateText.uc_hardtext_single_line_format = concatUCString(i18n.get("uittSuccessRate"), tostring(successRate), " %") - end - - local disableTimeText = ttWin:find("disable_time") - if phrase:isPowerPhrase() then - local disableTime = phrase:getPowerDisableTime() - if disableTime == 0 then - disableTimeText.active = false - else - disableTimeText.active = true - disableTimeText.uc_hardtext_single_line_format = concatUCString(i18n.get("uittDisableTime"), game:timeInSecondsToReadableTime(disableTime / 10)) - end - else - disableTimeText.active = false - end - game:updatePowerPhraseTooltip() - updateTooltipCoords() - return text -end - ------------------------------------------------------------------------------------------------------------- --- called at each frame when a power/aura tooltip is displayed,in order to update the regen countdown -function game:updatePowerPhraseTooltip() - local ttWin = getUI("ui:interface:action_context_help") - local leftRegenTime = 0 - if LastTooltipPhrase:isPowerPhrase() then - leftRegenTime = LastTooltipPhrase:getTotalRegenTime() - LastTooltipPhrase:getRegenTime() - end - if leftRegenTime < 0 then - leftRegenTime = 0 - end - self:setPhraseTooltipPowerRegenTime(ttWin, leftRegenTime) - updateTooltipCoords() -end - - --- *************************************************************************** --- *************************************************************************** --- CURRENT BUFF ITEM --- *************************************************************************** --- *************************************************************************** - ------------------------------------------------------------------------------------------------------------- --- called by C++ code when the tooltip of a buff item is about to be displayed -function game:updateBuffItemTooltip(buffItem) - local ttWin = getUI("ui:interface:buff_item_context_help") - local text = buffItem:getName() - - self:setPhraseTooltipCarac(ttWin, "ChaScore1_buff", buffItem:getChaScore1Buff()) - self:setPhraseTooltipCarac(ttWin, "ChaScore2_buff", buffItem:getChaScore2Buff()) - self:setPhraseTooltipCarac(ttWin, "ChaScore3_buff", buffItem:getChaScore3Buff()) - self:setPhraseTooltipCarac(ttWin, "ChaScore4_buff", buffItem:getChaScore4Buff()) - - updateTooltipCoords() - return text -end - --- *************************************************************************** --- *************************************************************************** --- CURRENT CRYSTALLIZED SPELL --- *************************************************************************** --- *************************************************************************** - ------------------------------------------------------------------------------------------------------------- --- called by C++ code when the tooltip of a cristallized spell is about to be displayed -function game:updateCrystallizedSpellTooltip(crystallizedSpell) - local ttWin = getUI("ui:interface:crystallized_spell_context_help") - local text = crystallizedSpell:getName() - - crystallizedSpell:buildCrystallizedSpellListBrick() - - updateTooltipCoords() - return text -end +-- In this file we define functions that serves for player windows + +function getDbPropU(dbEntry) + value = getDbProp(dbEntry) + if (value < 0) then + value = 4294967296+value + end + return value +end + +if string.find(_VERSION, "Lua 5.0") then + function math.fmod(a, b) + return math.mod(a, b) + end +end + +------------------------------------------------------------------------------------------------------------ +-- create the game namespace without reseting if already created in an other file. +if (game==nil) then + game= {}; +end + +if (game.PVP == nil) then + game.PVP = {}; + game.PVP.tagStartTimer = 0; + game.PVP.flagStartTimer = 0; + game.PVP.tagTimerStarted = false; + game.PVP.flagTimerStarted = false; +end + +if (game.BonusMalus == nil) then + game.BonusMalus = {}; + game.BonusMalus.DeathPenaltyBefore = -1; + game.BonusMalus.DeathPenaltyAfter = -1; + game.BonusMalus.XPCatSlotBefore = -1; + game.BonusMalus.XPCatSlotAfter = -1; + game.BonusMalus.RingXPCatSlotBefore = -1; + game.BonusMalus.RingXPCatSlotAfter = -1; + game.BonusMalus.OutpostSlotBefore = -1; + game.BonusMalus.OutpostSlotAfter = -1; + game.BonusMalus.BonusAHList= {}; + game.BonusMalus.MalusAHList= {}; +end + + +------------------------------------------------------------------------------------------------------------ +-- Update player bars in function of what we wants to display (we can hide each one of the 3 bars : sap,stamina and focus) +function game:updatePlayerBars() + + local dispChaScore3 = getDbProp('UI:SAVE:PLAYER:DISP_ChaScore3'); + local dispChaScore2 = getDbProp('UI:SAVE:PLAYER:DISP_ChaScore2'); + local dispChaScore4 = getDbProp('UI:SAVE:PLAYER:DISP_ChaScore4'); + + local ui = getUI('ui:interface:player:content'); + + -- active ui in function of what is displayed + + ui.b_ChaScore3.active = (dispChaScore3 == 1); + ui.jChaScore3.active = (dispChaScore3 == 1); + + ui.b_ChaScore2.active = (dispChaScore2 == 1); + ui.jChaScore2.active = (dispChaScore2 == 1); + + ui.b_ChaScore4.active = (dispChaScore4 == 1); + ui.jChaScore4.active = (dispChaScore4 == 1); + + -- choose good y-position + + local totalBarDisp = dispChaScore3 + dispChaScore2 + dispChaScore4; + if (totalBarDisp == 3) then + + ui.b_ChaScore3.y = -20; + ui.b_ChaScore2.y = -35; + ui.b_ChaScore4.y = -50; + ui.current_action.y = -65; + + elseif (totalBarDisp == 2) then + + if (dispChaScore3 == 0) then + ui.b_ChaScore2.y = -20; + ui.b_ChaScore4.y = -35; + end + + if (dispChaScore2 == 0) then + ui.b_ChaScore3.y = -20; + ui.b_ChaScore4.y = -35; + end + + if (dispChaScore4 == 0) then + ui.b_ChaScore3.y = -20; + ui.b_ChaScore2.y = -35; + end + + ui.current_action.y = -50; + + elseif (totalBarDisp == 1) then + + ui.b_ChaScore2.y = -20; + ui.b_ChaScore4.y = -20; + ui.b_ChaScore2.y = -20; + + ui.current_action.y = -35; + + else + ui.current_action.y = -20; + end + + +end + + +------------------------------------------------------------------------------------------------------------ +-- convert a boolean to a number 0 or 1 +function booleanToNumber(thebool) + if(thebool) then + return 1; + else + return 0; + end +end + +------------------------------------------------------------------------------------------------------------ +-- Update player pvp tag +function game:pvpTagUpdateDisplay() + local currentServerTick = getDbPropU('UI:VARIABLES:CURRENT_SERVER_TICK'); + local pvpServerTagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:ACTIVATION_TIME'); + local pvpServerFlagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:FLAG_PVP_TIME_LEFT'); + local uiPlayer= getUI('ui:interface:player:header_opened'); + + -- get the current state + local pvpServerFlag= pvpServerFlagTimer > currentServerTick; + local pvpLocalTag= (getDbProp('UI:TEMP:PVP_FACTION:TAG_PVP') == 1); + local pvpServerTag= (getDbProp('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:TAG_PVP') == 1); + local pvpServerActivateTimerOn= pvpServerTagTimer > currentServerTick; + + -- deduce the display state according to the current state + local GREEN= 0; + local ORANGE= 1; + local RED= 2; + local buttonMode= GREEN; + local buttonPushed= false; + local buttonTimer= false; + -- if the flag is activated, then must display PVP flag button and timer + if (pvpServerFlag) then + -- ** RED MODE + buttonMode= RED; + buttonPushed= false; + buttonTimer= true; + -- else must display correct mode according to the TAG state + else + -- There are 8 possibilities according to the combination of the 3 flags + -- Here: TL= pvpLocalTag, TS= pvpServerTag, AS= pvpServerActivateTimerOn) + -- TL TS AS + -- ** GREEN MODE ** + -- 0 0 0 -> Standard disabled PVP + -- 1 0 0 -> The user pressed the button but still no response from server + -- 1 1 1 -> The user pressed the button and got response from server. => GREEN icon with timer + -- 0 1 1 -> The user canceled the activation (server not acked yet the cancel). => default display + -- ** ORANGE MODE ** + -- 1 1 0 -> Standard enabled PVP + -- 0 1 0 -> The user pressed the button but still no response from server + -- 0 0 1 -> The user pressed the button and got response from server. => ORANGE icon with timer + -- 1 0 1 -> The user canceled the activation (server not acked yet the cancel). => default display + + -- From this table, we can deduce the following rules + + -- buttonMode is GREEN when TS==AS + if( pvpServerTag == pvpServerActivateTimerOn ) then + buttonMode= GREEN; + else + buttonMode= ORANGE; + end + + -- the button is pushed if (there is a timer and TL==TS), or (no timer and TL!=TS) + if( pvpServerActivateTimerOn == (pvpLocalTag == pvpServerTag) ) then + buttonPushed= true; + else + buttonPushed= false; + end + + -- display a timer only if the timer is activated and server and local tag are equals + if( pvpServerActivateTimerOn and pvpLocalTag == pvpServerTag ) then + buttonTimer= true; + else + buttonTimer= false; + end + + end + + -- setup the local display + setDbProp("UI:TEMP:PVP_FACTION:DSP_MODE", buttonMode); + setDbProp("UI:TEMP:PVP_FACTION:DSP_PUSHED", booleanToNumber(buttonPushed)); + setDbProp("UI:TEMP:PVP_FACTION:DSP_TIMER", booleanToNumber(buttonTimer)); + + -- setup the timer bar + if(buttonTimer) then + local uiBar = uiPlayer.pvp_timer; + local uiBarBg = uiPlayer.pvp_timer_bg; + -- Flag Bar? + if(buttonMode==RED) then + -- display a reverse timer + uiBar.w = uiBarBg.w * (pvpServerFlagTimer - currentServerTick) / (pvpServerFlagTimer - game.PVP.flagStartTimer); + else + -- display a forward timer + uiBar.w = uiBarBg.w * (currentServerTick - game.PVP.tagStartTimer) / (pvpServerTagTimer - game.PVP.tagStartTimer); + end + end + + -- force update of the tooltip for any button (by disabling then reenabling) + disableContextHelpForControl(uiPlayer.pvp_tag_button_0); + disableContextHelpForControl(uiPlayer.pvp_tag_button_1); + disableContextHelpForControl(uiPlayer.pvp_tag_button_2); +end + +------------------------------------------------------------------------------------------------------------ +-- Update player pvp tag +function game:pvpTag() + local buttonStat = getDbProp('UI:TEMP:PVP_FACTION:TAG_PVP'); + if (buttonStat == 0) then + setDbProp('UI:TEMP:PVP_FACTION:TAG_PVP',1); + else + setDbProp('UI:TEMP:PVP_FACTION:TAG_PVP',0); + end + sendMsgToServerPvpTag(buttonStat == 0); + + -- update display + self:pvpTagUpdateDisplay(); +end + +------------------------------------------------------------------------------------------------------------ +-- Update button due to server validation +function game:updatePvpTag() + -- force copy to temp of Server tag + local pvpServerTag= (getDbProp('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:TAG_PVP') == 1); + setDbProp('UI:TEMP:PVP_FACTION:TAG_PVP', booleanToNumber(pvpServerTag)); + + -- launch timer DB if necessary + local currentServerTick = getDbPropU('UI:VARIABLES:CURRENT_SERVER_TICK'); + local pvpServerTagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:ACTIVATION_TIME'); + local pvpServerFlagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:FLAG_PVP_TIME_LEFT'); + + if(pvpServerTagTimer > currentServerTick) or (pvpServerFlagTimer > currentServerTick) then + local ui = getUI('ui:interface:player'); + addOnDbChange(ui,'@UI:VARIABLES:CURRENT_SERVER_TICK', 'game:updatePvpTimer()'); + + if(pvpServerTagTimer > currentServerTick and game.PVP.tagTimerStarted == false) then + game.PVP.tagStartTimer = currentServerTick; + game.PVP.tagTimerStarted = true; + end + if(pvpServerFlagTimer > currentServerTick and game.PVP.flagTimerStarted == false) then + game.PVP.flagStartTimer = currentServerTick; + game.PVP.flagTimerStarted = true; + end + end + + -- update display (after start timer reseted) + self:pvpTagUpdateDisplay(); +end + +------------------------------------------------------------------------------------------------------------ +-- +function game:updatePvpTimer() + + -- update display + self:pvpTagUpdateDisplay(); + + -- try to stop + local currentServerTick = getDbPropU('UI:VARIABLES:CURRENT_SERVER_TICK'); + local pvpServerTagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:ACTIVATION_TIME'); + local pvpServerFlagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:FLAG_PVP_TIME_LEFT'); + + -- Manage Tag Timer display + if(pvpServerTagTimer <= currentServerTick) then + game.PVP.tagTimerStarted = false; + end + + -- Manage Flag Timer display + if(pvpServerFlagTimer <= currentServerTick) then + game.PVP.flagTimerStarted = false; + end + + -- if both off, stop the db update + if(game.PVP.tagTimerStarted == false) and (game.PVP.flagTimerStarted == false) then + removeOnDbChange(getUI('ui:interface:player'),'@UI:VARIABLES:CURRENT_SERVER_TICK'); + end +end + +------------------------------------------------------------------------------------------------------------ +-- +function game:formatTime(temps) + + local hours = math.floor(temps/(10*60*60)); + local minutes = math.floor((temps - (hours*10*60*60)) / (10*60)); + local seconds = math.floor((temps - (hours*10*60*60) - (minutes*10*60)) / 10); + + local fmt = i18n.get('uittPvPTime'); + fmt = findReplaceAll(fmt, '%h', tostring(hours)); + fmt = findReplaceAll(fmt, '%m', tostring(minutes)); + fmt = findReplaceAll(fmt, '%s', tostring(seconds)); + return fmt; +end + +------------------------------------------------------------------------------------------------------------ +-- +function game:playerTTPvp() + + -- The tooltip to display depends on the current display state + local buttonMode= getDbProp("UI:TEMP:PVP_FACTION:DSP_MODE"); + local buttonPushed= (getDbProp("UI:TEMP:PVP_FACTION:DSP_PUSHED")==1); + local buttonTimer= (getDbProp("UI:TEMP:PVP_FACTION:DSP_TIMER")==1); + local text; + + -- Flag mode? + if(buttonMode==2) then + local pvpServerFlagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:FLAG_PVP_TIME_LEFT'); + local currentServerTick = getDbPropU('UI:VARIABLES:CURRENT_SERVER_TICK'); + local tempsString = game:formatTime( pvpServerFlagTimer - currentServerTick ); + text = i18n.get('uittPvPModeFlag'); + text = findReplaceAll(text, '%temps', tempsString); + -- Tag mode + else + -- base text + if(buttonMode==0 and not(buttonPushed)) then + text = i18n.get('uittPvPModeTagOff'); + elseif(buttonMode==0 and buttonPushed) then + text = i18n.get('uittPvPModeTagOffChange'); + elseif(buttonMode==1 and not(buttonPushed)) then + text = i18n.get('uittPvPModeTagOn'); + elseif(buttonMode==1 and buttonPushed) then + text = i18n.get('uittPvPModeTagOnChange'); + else + text = ucstring(); + end + -- timer + if(buttonTimer) then + local pvpServerTagTimer = getDbPropU('SERVER:CHARACTER_INFO:PVP_FACTION_TAG:ACTIVATION_TIME'); + local currentServerTick = getDbPropU('UI:VARIABLES:CURRENT_SERVER_TICK'); + local tempsString = game:formatTime( pvpServerTagTimer - currentServerTick ); + local timeFmt= i18n.get('uittPvPTagTimer'); + timeFmt= findReplaceAll(timeFmt, '%temps', tempsString); + text= concatUCString(text, timeFmt); + end + end + + -- set the text + setContextHelpText(text); +end + + + +-- *************************************************************************** +-- *************************************************************************** +-- BONUS MALUS +-- *************************************************************************** +-- *************************************************************************** + + +------------------------------------------------------------------------------------------------------------ +function game:bonusMalusActiveText(ui, slot, state) + local uiTextGroup= ui["text" .. tostring(slot) ]; + if(uiTextGroup) then + uiTextGroup.active= state; + end +end + +------------------------------------------------------------------------------------------------------------ +function game:bonusMalusSetText(ui, slot, fmt) + local uiTextGroup= ui["text" .. tostring(slot) ]; + if(uiTextGroup) then + uiTextGroup.shade0.uc_hardtext_format= fmt; + uiTextGroup.shade1.uc_hardtext_format= fmt; + uiTextGroup.shade2.uc_hardtext_format= fmt; + uiTextGroup.shade3.uc_hardtext_format= fmt; + uiTextGroup.text.uc_hardtext_format= fmt; + uiTextGroup.text2.uc_hardtext_format= fmt; + end +end + +------------------------------------------------------------------------------------------------------------ +-- From given DB vals, compute the 'Xp Bonus' text info +function game:updateXpCatQuantity(textSlot, ui) + -- get the ui text to fill + if(ui==nil) then + ui= getUICaller(); + end + + -- format the text + local fmt= "x@{FF6F}" .. tostring( getDbProp("SERVER:CHARACTER_INFO:XP_CATALYSER:Count") ); + + self:bonusMalusSetText(ui, textSlot, fmt); +end + + +------------------------------------------------------------------------------------------------------------ +-- From given DB vals, compute the 'Ring Xp Bonus' text info +function game:updateRingXpCatQuantity(textSlot, ui) + -- get the ui text to fill + if(ui==nil) then + ui= getUICaller(); + end + + -- format the text + local fmt= "x@{FF6F}" .. tostring( getDbProp("SERVER:CHARACTER_INFO:RING_XP_CATALYSER:Count") ); + + self:bonusMalusSetText(ui, textSlot, fmt); +end + + +------------------------------------------------------------------------------------------------------------ +function game:outpostUpdatePVPTimer(textSlot, ui) + -- get the ui text to fill + if(ui==nil) then + ui= getUICaller(); + end + + -- Get the timer of interest (priority to player leaving the zone) + local endTimer= 0; + local endOfPvpTimer= getDbPropU('SERVER:CHARACTER_INFO:PVP_OUTPOST:FLAG_PVP_TIME_END'); + if( endOfPvpTimer>0 ) then + endTimer= endOfPvpTimer; + else + local endOfRound= getDbProp('SERVER:CHARACTER_INFO:PVP_OUTPOST:ROUND_END_DATE'); + if( endOfRound>0 ) then + endTimer= endOfRound; + end + end + + -- Use a text with a timer? + if( endTimer>0 ) then + -- compute the time that lefts in sec (suppose a smooth server tick is 1 ms) + local curTick= getDbPropU('UI:VARIABLES:CURRENT_SERVER_TICK'); + local timeSec= (endTimer- curTick)/10; + -- replace in str + local text= "@{FF6F}" .. runFct('secondsToTimeStringShort', timeSec); + self:bonusMalusSetText(ui, textSlot, text); + -- else Default display + else + self:bonusMalusSetText(ui, textSlot, "@{FF6F}on"); + end + +end + + +------------------------------------------------------------------------------------------------------------ +function game:deathPenaltyUpdateXPMalus() +end + + +------------------------------------------------------------------------------------------------------------ +-- called when someone click on a bonus malus icon. redirect to correct action handler if any +function game:onLeftClickBonus() + local ui= getUICaller(); + local id= getIndexInDB(ui); + local ah= self.BonusMalus.BonusAHList[id]; + if(ui and ah) then + runAH(ui, ah, ""); + end +end + +function game:onLeftClickMalus() + local ui= getUICaller(); + local id= getIndexInDB(ui); + local ah= self.BonusMalus.MalusAHList[id]; + if(ui and ah) then + runAH(ui, ah, ""); + end +end + +------------------------------------------------------------------------------------------------------------ +-- update if needed the ActionHandler and text update from DB +function game:updateBonusMalusTextSetup() + local numLocalBonusMalus= getDefine("num_local_bonus_malus"); + local uiBonus= getUI('ui:interface:bonus_malus:header_opened:bonus'); + local uiMalus= getUI('ui:interface:bonus_malus:header_opened:malus'); + local dbXpCat= "@SERVER:CHARACTER_INFO:XP_CATALYSER:Count"; + local dbRingXpCat= "@SERVER:CHARACTER_INFO:RING_XP_CATALYSER:Count"; + local dbOutpost= "@SERVER:CHARACTER_INFO:PVP_OUTPOST, @UI:VARIABLES:CURRENT_SERVER_TICK"; + local dbDeathPenalty= "@SERVER:USER:DEATH_XP_MALUS"; + + + -- reset cache + self.BonusMalus.DeathPenaltyBefore= self.BonusMalus.DeathPenaltyAfter; + self.BonusMalus.XPCatSlotBefore= self.BonusMalus.XPCatSlotAfter; + self.BonusMalus.RingXPCatSlotBefore= self.BonusMalus.RingXPCatSlotAfter; + self.BonusMalus.OutpostSlotBefore= self.BonusMalus.OutpostSlotAfter; + + + -- *** remove and hide any preceding + for i= 0,numLocalBonusMalus-1 do + -- reset AH + self.BonusMalus.BonusAHList[i]= nil; + self.BonusMalus.MalusAHList[i]= nil; + -- hide text view + self:bonusMalusActiveText(uiBonus, i, false); + -- reset special tooltip + setDbProp( formatUI('UI:VARIABLES:BONUS:#1:SPECIAL_TOOLTIP', i), game.TBonusMalusSpecialTT.None); + end + removeOnDbChange(uiBonus, dbXpCat); + removeOnDbChange(uiBonus, dbRingXpCat); + removeOnDbChange(uiBonus, dbOutpost); + + + -- *** set new XPCat setup + local slot= self.BonusMalus.XPCatSlotAfter; + if(slot~=-1) then + -- set AH to use for this slot + self.BonusMalus.BonusAHList[slot]= "xp_catalyser_stop_use"; + -- add DB change, and call now! else not updated + addOnDbChange(uiBonus, dbXpCat, formatUI("game:updateXpCatQuantity(#1, nil)", slot) ); + self:updateXpCatQuantity(slot, uiBonus); + -- show text + self:bonusMalusActiveText(uiBonus, slot, true); + -- set special tooltip (id==1 for xpcat) + setDbProp( formatUI('UI:VARIABLES:BONUS:#1:SPECIAL_TOOLTIP', slot), game.TBonusMalusSpecialTT.XpCatalyser); + end + + -- *** set new RingXPCat setup + local slot= self.BonusMalus.RingXPCatSlotAfter; + if(slot~=-1) then + -- set AH to use for this slot + self.BonusMalus.BonusAHList[slot]= "ring_xp_catalyser_stop_use"; + -- add DB change, and call now! else not updated + addOnDbChange(uiBonus, dbRingXpCat, formatUI("game:updateRingXpCatQuantity(#1, nil)", slot) ); + self:updateRingXpCatQuantity(slot, uiBonus); + -- show text + self:bonusMalusActiveText(uiBonus, slot, true); + -- set special tooltip (id==1 for ringxpcat) + setDbProp( formatUI('UI:VARIABLES:BONUS:#1:SPECIAL_TOOLTIP', slot), game.TBonusMalusSpecialTT.XpCatalyser); + end + + + -- *** set new Outpost setup + local slot= self.BonusMalus.OutpostSlotAfter; + if(slot~=-1) then + -- no AH + -- add DB change, and call now! else not updated + addOnDbChange(uiBonus, dbOutpost, formatUI("game:outpostUpdatePVPTimer(#1, nil)", slot) ); + self:outpostUpdatePVPTimer(slot, uiBonus); + -- show text + self:bonusMalusActiveText(uiBonus, slot, true); + -- don't set the tooltip here, because redone after return + end + + + -- *** set new DeathPenalty setup + local slot= self.BonusMalus.DeathPenaltyAfter; + if(slot~=-1) then + -- no AH + -- add DB change, and call now! else not updated + addOnDbChange(uiMalus, dbDeathPenalty, formatUI("game:deathPenaltyUpdateXPMalus(#1, nil)", slot) ); + self:deathPenaltyUpdateXPMalus(slot, uiMalus); + -- show text + self:bonusMalusActiveText(uiMalus, slot, true); + -- set special tooltip (id==1 for death penalty) + setDbProp( formatUI('UI:VARIABLES:MALUS:#1:SPECIAL_TOOLTIP', slot), game.TBonusMalusSpecialTT.DeathPenalty); + end + +end + +------------------------------------------------------------------------------------------------------------ +-- Update Bonus malus local DB according to server DB +function game:updatePlayerBonusMalus() + local numServerBonusMalus= tonumber(getDefine("num_server_bonus_malus")); + local numLocalBonusMalus= tonumber(getDefine("num_local_bonus_malus")); + local dbServerBonusBase= getDefine("bonus") .. ":" ; + local dbServerMalusBase= getDefine("malus") .. ":" ; + local dbLocalBonusBase= "UI:VARIABLES:BONUS:"; + local dbLocalMalusBase= "UI:VARIABLES:MALUS:"; + + local i; + local mustUpdateTextSetup= false; + + + -- *********************** + -- *** Insert Bonus + -- *********************** + local destIndex= 0; + local mustShowBonus= false; + + -- *** Insert XPCatalyzer first + local xpcatCount= getDbProp("SERVER:CHARACTER_INFO:XP_CATALYSER:Count"); + if(xpcatCount~=0) then + local xpcatLevel= getDbProp("SERVER:CHARACTER_INFO:XP_CATALYSER:Level"); + -- Get the most appropriate icon + local iconLevel= 50; + for i= 50,250,50 do + if(i<=xpcatLevel) then + iconLevel= i; + end + end + -- Set the DB for this brick + mustShowBonus= true; + setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":SHEET", getSheetId('big_xpcat_' .. tostring(iconLevel) .. '.sbrick' ) ); + setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":DISABLED", 0 ); + self.BonusMalus.XPCatSlotAfter = destIndex; + destIndex= destIndex+1; + else + self.BonusMalus.XPCatSlotAfter = -1; + end + if(self.BonusMalus.XPCatSlotAfter ~= self.BonusMalus.XPCatSlotBefore) then + mustUpdateTextSetup= true; + end + + -- *** Then insert RingXPCatalyzer + local ringxpcatCount= getDbProp("SERVER:CHARACTER_INFO:RING_XP_CATALYSER:Count"); + if(ringxpcatCount~=0) then + local ringxpcatLevel= getDbProp("SERVER:CHARACTER_INFO:RING_XP_CATALYSER:Level"); + -- Get the most appropriate icon + local iconLevel= 50; + for i= 50,250,50 do + if(i<=ringxpcatLevel) then + iconLevel= i; + end + end + -- Set the DB for this brick + mustShowBonus= true; + setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":SHEET", getSheetId('big_ring_xpcat_' .. tostring(iconLevel) .. '.sbrick' ) ); + setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":DISABLED", 0 ); + self.BonusMalus.RingXPCatSlotAfter = destIndex; + destIndex= destIndex+1; + else + self.BonusMalus.RingXPCatSlotAfter = -1; + end + if(self.BonusMalus.RingXPCatSlotAfter ~= self.BonusMalus.RingXPCatSlotBefore) then + mustUpdateTextSetup= true; + end + + + -- *** Insert PVPOutpost + local pvpOutpostPresent= getDbProp("SERVER:CHARACTER_INFO:PVP_OUTPOST:FLAG_PVP"); + local pvpOutpostEndOfPVPFlag= 0; + local pvpOutpostEndOfRound= 0; + if(pvpOutpostPresent~=0) then + local pvpOutpostLevel= 0; + pvpOutpostEndOfPVPFlag= getDbPropU('SERVER:CHARACTER_INFO:PVP_OUTPOST:FLAG_PVP_TIME_END'); + pvpOutpostEndOfRound= getDbPropU('SERVER:CHARACTER_INFO:PVP_OUTPOST:ROUND_END_DATE'); + -- set a level only if we have some round, and if the out timer is not set + if(pvpOutpostEndOfRound~=0 and pvpOutpostEndOfPVPFlag==0) then + pvpOutpostLevel= 1 + getDbProp('SERVER:CHARACTER_INFO:PVP_OUTPOST:ROUND_LVL_CUR'); + end + + -- Set the DB for this brick + mustShowBonus= true; + setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":SHEET", getSheetId('big_outpost_pvp_' .. tostring(pvpOutpostLevel) .. '.sbrick' ) ); + setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":DISABLED", 0 ); + self.BonusMalus.OutpostSlotAfter = destIndex; + destIndex= destIndex+1; + else + self.BonusMalus.OutpostSlotAfter = -1; + end + if(self.BonusMalus.OutpostSlotAfter ~= self.BonusMalus.OutpostSlotBefore) then + mustUpdateTextSetup= true; + end + + + -- *** Insert standard Bonus + for i=0,numServerBonusMalus-1 do + -- get + local sheet= getDbProp(dbServerBonusBase .. tostring(i) .. ":SHEET" ); + local disabled= getDbProp(dbServerBonusBase .. tostring(i) .. ":DISABLED" ); + if(sheet~=0) then + mustShowBonus= true; + end + -- copy (to index shifted if needed) + setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":SHEET", sheet ); + setDbProp(dbLocalBonusBase .. tostring(destIndex) .. ":DISABLED", disabled ); + destIndex= destIndex+1; + end + if(mustShowBonus) then + setDbProp("UI:VARIABLES:SHOW_BONUS", 1); + else + setDbProp("UI:VARIABLES:SHOW_BONUS", 0); + end + + + -- *** erase any remaining bonus + while destIndex 0 then result = concatUCString(tostring(seconds), i18n.get("uittSecondsShort")) end + if minutes > 0 then result = concatUCString(tostring(minutes), i18n.get("uittMinutesShort"), result) end + if hours > 0 then result = concatUCString(tostring(hours), i18n.get("uittHoursShort"), result) end + return result +end + +------------------------------------------------------------------------------------------------------------ +-- display the time left for a power / auras in its tooltip +function game:setPhraseTooltipPowerRegenTime(ttWin, regenTimeInTicks) + local text = ttWin:find("regen_time") + if regenTimeInTicks == 0 then + text.active = false + else + text.active = true + text.uc_hardtext_single_line_format = concatUCString(i18n.get("uittRegenTime"), game:timeInSecondsToReadableTime(math.floor((regenTimeInTicks + 9) * 0.1))) + text:invalidateCoords() + ttWin:invalidateCoords() + end +end + + +local EmptyUCString = ucstring() + +------------------------------------------------------------------------------------------------------------ +-- called by C++ code when the tooltip of a phrase is about to be displayed +function game:updatePhraseTooltip(phrase) + LastTooltipPhrase = phrase + local ttWin = getUI("ui:interface:action_context_help") + local text = phrase:getName() + + if not text or text == EmptyUCString then + text = ucstring("") + end + + local desc = phrase:getDesc() + if desc and desc ~= EmptyUCString then + local str = tostring(desc) + local charFound = false + for k = 1, string.len(str) do + if string.byte(str, k) ~= 32 then + charFound = true + break + end + end + if charFound then + text = concatUCString(text, "\n@{CCCF}", desc) + end + else + text = concatUCString(text, "@{CCCF}") + end + -- IMPORTANT : the following getters on 'phrase' take in account the 'total action malus' for the timebeing + self:setPhraseTooltipCarac(ttWin, "ChaScore1_cost", phrase:getChaScore1Cost()) + self:setPhraseTooltipCarac(ttWin, "ChaScore2_cost", phrase:getChaScore2Cost()) + self:setPhraseTooltipCarac(ttWin, "ChaScore3_cost", phrase:getChaScore3Cost()) + self:setPhraseTooltipCarac(ttWin, "ChaScore4_cost", phrase:getChaScore4Cost()) + self:setPhraseTooltipCarac(ttWin, "cast_time", phrase:getCastTime(), concatUCString(string.format("%.1f", phrase:getCastTime()), i18n.get("uittSeconds"))) + local castRange = phrase:getCastRange() + if not phrase:isMagicPhrase() then + castRange = 0 + end + self:setPhraseTooltipCarac(ttWin, "cast_range", castRange, concatUCString(tostring(castRange), i18n.get("uittMeters"))) + -- if the phrase is a power / aura, then we may want to display its regen time in the tooltip + if phrase:isPowerPhrase() then + setOnDraw(ttWin, "game:updatePowerPhraseTooltip()") + else + setOnDraw(ttWin, "") + end + -- + local successRateText = ttWin:find("success_rate") + local successRate = phrase:getSuccessRate() + if successRate == 0 then + successRateText.active = false + else + successRateText.active = true + successRateText.uc_hardtext_single_line_format = concatUCString(i18n.get("uittSuccessRate"), tostring(successRate), " %") + end + + local disableTimeText = ttWin:find("disable_time") + if phrase:isPowerPhrase() then + local disableTime = phrase:getPowerDisableTime() + if disableTime == 0 then + disableTimeText.active = false + else + disableTimeText.active = true + disableTimeText.uc_hardtext_single_line_format = concatUCString(i18n.get("uittDisableTime"), game:timeInSecondsToReadableTime(disableTime / 10)) + end + else + disableTimeText.active = false + end + game:updatePowerPhraseTooltip() + updateTooltipCoords() + return text +end + + +------------------------------------------------------------------------------------------------------------ +-- called at each frame when a power/aura tooltip is displayed,in order to update the regen countdown +function game:updatePowerPhraseTooltip() + local ttWin = getUI("ui:interface:action_context_help") + local leftRegenTime = 0 + if LastTooltipPhrase:isPowerPhrase() then + leftRegenTime = LastTooltipPhrase:getTotalRegenTime() - LastTooltipPhrase:getRegenTime() + end + if leftRegenTime < 0 then + leftRegenTime = 0 + end + self:setPhraseTooltipPowerRegenTime(ttWin, leftRegenTime) + updateTooltipCoords() +end + + +-- *************************************************************************** +-- *************************************************************************** +-- CURRENT BUFF ITEM +-- *************************************************************************** +-- *************************************************************************** + +------------------------------------------------------------------------------------------------------------ +-- called by C++ code when the tooltip of a buff item is about to be displayed +function game:updateBuffItemTooltip(buffItem) + local ttWin = getUI("ui:interface:buff_item_context_help") + local text = buffItem:getName() + + self:setPhraseTooltipCarac(ttWin, "ChaScore1_buff", buffItem:getChaScore1Buff()) + self:setPhraseTooltipCarac(ttWin, "ChaScore2_buff", buffItem:getChaScore2Buff()) + self:setPhraseTooltipCarac(ttWin, "ChaScore3_buff", buffItem:getChaScore3Buff()) + self:setPhraseTooltipCarac(ttWin, "ChaScore4_buff", buffItem:getChaScore4Buff()) + + updateTooltipCoords() + return text +end + +-- *************************************************************************** +-- *************************************************************************** +-- CURRENT CRYSTALLIZED SPELL +-- *************************************************************************** +-- *************************************************************************** + +------------------------------------------------------------------------------------------------------------ +-- called by C++ code when the tooltip of a cristallized spell is about to be displayed +function game:updateCrystallizedSpellTooltip(crystallizedSpell) + local ttWin = getUI("ui:interface:crystallized_spell_context_help") + local text = crystallizedSpell:getName() + + crystallizedSpell:buildCrystallizedSpellListBrick() + + updateTooltipCoords() + return text +end diff --git a/data/kh/kh_interfaces/reset.xml b/data/kh/kh_interfaces/reset.xml index c82ba211..ea13427c 100644 --- a/data/kh/kh_interfaces/reset.xml +++ b/data/kh/kh_interfaces/reset.xml @@ -1,477 +1,477 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/kh/kh_interfaces/widgets.xml b/data/kh/kh_interfaces/widgets.xml index eb164507..3f6db6e8 100644 --- a/data/kh/kh_interfaces/widgets.xml +++ b/data/kh/kh_interfaces/widgets.xml @@ -1029,7 +1029,7 @@ - - +