#include "game.lua" gScoreDisplay = nil gScoreDisplayTimer = nil gScoreCurrent = nil gScoreRank = nil gScoreRankScale = nil gScoreRankTimer = nil gScoreRankZoom = nil gUiScaleUpFactor = nil function init() gScoreDisplay = GetInt("savegame.hub.score") gScoreDisplayTimer = 1 gScoreCurrent = getTotalScore() gScoreRank = getRank(gScoreDisplay) gScoreRankScale = 0 gScoreRankTimer = 0 gScoreRankZoom = 0 gUiScaleUpFactor = 1.0 local showLargeUI = GetBool("game.largeui") if showLargeUI then gUiScaleUpFactor = 1.3 end end function splash(i) UiPush() UiColor(0,0,0) UiRect(UiWidth(), UiHeight()) UiFont("bold.ttf", 64) UiTranslate(UiCenter(), UiMiddle()) UiColor(1,1,1) UiScale(2) UiAlign("center middle") if i==1 then UiText("loc@UI_TEXT_PART_ONE") elseif i==2 then UiText("loc@UI_TEXT_PART_TWO") end SetBool("game.disableinput", true) SetBool("hud.disable", true) UiPop() end function getTotalScore() local score = 0 local missions = ListKeys("savegame.mission") for i=1,#missions do score = score + GetInt("savegame.mission."..missions[i]..".score") end return score end function getRank(score) local r = 0 for i=1,#gRanks do if score >= gRanks[i].score then r = i end end return r end RankBar = {} RankBar.contentW = 300 RankBar.contentH = 34 RankBar.hPadding = 20 function drawRank() if GetFloat("game.map.fade") > 0 then return end if GetBool("game.player.usescreen") or gScoreCurrent == 0 then return end if gScoreDisplay < gScoreCurrent then if gScoreDisplayTimer > 0 then gScoreDisplayTimer = gScoreDisplayTimer - GetTimeStep() if gScoreDisplayTimer <= 0 then gScoreDisplay = gScoreDisplay + 1 UiSound("score.ogg") if gScoreDisplay == gScoreCurrent then SetInt("savegame.hub.score", gScoreCurrent) end gScoreDisplayTimer = 0.2 end end end UiPush() local r = getRank(gScoreDisplay) if r ~= gScoreRank then gScoreRank = r gScoreRankScale = 0 SetValue("gScoreRankScale", 1, "bounce", 0.5) gScoreRankTimer = 0 gScoreRankZoom = 1 UiSound("new-rank.ogg") end UiScale(gUiScaleUpFactor) UiFont("bold.ttf", 22) UiAlign("top left") UiTranslate(20, 10) UiColor(1, 1, 1, 0.5) UiImageBox( "ui/common/box-solid-10.png", RankBar.contentW + RankBar.hPadding * 2, RankBar.contentH, 10, 10) UiWindow(RankBar.contentW + RankBar.hPadding * 2, RankBar.contentH) UiAlign("middle left") UiColor(0, 0, 0) UiTranslate(20, RankBar.contentH / 2) UiBeginFrame() local score_text = GetTranslatedStringByKey("UI_TEXT_SCORE") .. " " .. gScoreDisplay local w, _ = UiGetTextSize(score_text) UiText(score_text) UiTranslate(30 + w, 0) UiText(gRanks[gScoreRank].name) RankBar.contentW, _ = UiEndFrame() UiPop() if gScoreRankScale > 0 then UiPush() if gScoreRankZoom>0 then SetBool("hud.aimdot", false) end local x = 190 * (1-gScoreRankZoom) + UiCenter() * gScoreRankZoom local y = 110 * (1-gScoreRankZoom) + UiMiddle() * gScoreRankZoom UiTranslate(x, y) UiColor(0,0,0, 0.5+gScoreRankZoom*0.5) UiAlign("center middle") UiScale(1, gScoreRankScale) UiScale(1+0.5*gScoreRankZoom) UiImageBox("ui/common/box-solid-10.png", 340, 120, 10, 10) UiWindow(340, 120) UiFont("bold.ttf", 22) UiTranslate(UiCenter(), 30) UiAlign("center middle") UiPush() UiScale(1.5) UiColor(1, 1, .4) UiText(gRanks[gScoreRank].name) UiPop() UiTranslate(0, 35) UiColor(1,1,1) UiText("loc@UI_TEXT_YOU_REACHED") UiTranslate(0, 22) UiColor(.7, .7, .7) if gRanks[gScoreRank].tool then if not GetBool("savegame.tool."..gRanks[gScoreRank].tool..".enabled") then UiText("loc@UI_TEXT_A_NEW") end end if gRanks[gScoreRank].cash then if not GetBool("savegame.reward."..gRanks[gScoreRank].cash) then UiText("loc@UI_TEXT_A_CASH") end end UiPop() gScoreRankTimer = gScoreRankTimer + GetTimeStep() if gScoreRankTimer > 3 and gScoreRankZoom == 1 then SetValue("gScoreRankZoom", 0, "cosine", 0.5) end --Hide rank notification when picked up (if tool) or on timer (if cash) if gScoreRankTimer > 1 and gScoreRankScale == 1 and not GetBool("level.toolspawn") then SetValue("gScoreRankScale", 0, "easein", 0.25) end end end function handleCommand(cmd, arg0, arg1, arg2) if cmd == "quicksave" then -- if we quicksaved before aquiring tool if gScoreRankScale > 0 and gRanks[gScoreRank].tool and not GetBool("savegame.tool."..gRanks[gScoreRank].tool..".enabled") then -- save this information in quicksave registry SetBool("game.tool."..gRanks[gScoreRank].tool .. ".notaquired", true) end end end function draw() -- if we found this registry parameter that mean we quicksaved if gRanks[gScoreRank].tool and GetBool("game.tool."..gRanks[gScoreRank].tool .. ".notaquired") then -- remove this parameter from registry SetBool("game.tool."..gRanks[gScoreRank].tool .. ".notaquired", false) -- and remove tool, if it is present SetBool("savegame.tool."..gRanks[gScoreRank].tool .. ".enabled", false) end if not GetBool("savegame.mission.mall_intro") and GetTime() < 3 then splash(1) return elseif GetInt("savegame.mission.frustrum_chase.score") > 0 and not GetBool("savegame.mission.factory_espionage") then --PART 2 if GetTime() < 4 then splash(2) if GetTime() > 1 then UiFont("bold.ttf", 64) UiTranslate(UiCenter(), UiMiddle()+80) UiColor(1,1,1) UiAlign("center middle") UiScale(1.1) UiText("loc@UI_TEXT_SIX_MONTHS") --SetString("hud.hintinfo", GetTranslatedStringByKey("UI_HUD_HINT_SIX_MONTHS")) end return end end drawRank() end