#include "missions.lua" #include "script/common.lua" missions = {"paperboy", "art_heist", "museum_heist", "museum_cam_heist", "museum_destroy"} function heading1() UiFont("regular.ttf", 18) UiColor(1,1,1) end function heading2() UiFont("regular.ttf", 14) UiColor(1,1,0) end function normal() UiFont("regular.ttf", 14) UiColor(1,1,1) end function drawDots(total, completed, width) local size = 10 local size2 = size/2.0 UiPush() local start = width - total * (size + 5) UiTranslate(start, -size) normal() for i = 1, completed do UiPush() UiColor(0,0,1) UiRect(size, size) UiTranslate(math.floor(size2 / 2.0), math.ceil(size - size2 / 2.0)) UiColor(1,1,1) UiText("x") UiPop() UiTranslate(size + 5, 0) end UiColor(0,0,1) for i = 1, (total - completed) do UiRect(size, size) UiTranslate(size + 5, 0) end UiPop() end function drawTimeLeft(timeLeft) UiPush() UiTranslate(150, 0) UiAlign("right") local s = math.floor(timeLeft*10+0.5)/10 UiText(s .. "s") UiPop() end function drawTime(time, width) UiPush() local m = math.floor(time/60) local s = math.floor(time-m*60) local timeText if m > 0 then timeText = m.." "..GetTranslatedStringByKey("TIME_MINUTES_SHORT").." "..s.." "..GetTranslatedStringByKey("TIME_SECONDS_SHORT") else timeText = s.." "..GetTranslatedStringByKey("TIME_SECONDS_SHORT") end UiTranslate(width - UiGetTextSize(timeText), 0) UiText(timeText) UiPop() end function drawRects(s) local sizeX = 4 local sizeY = 10 UiPush() for i = 1, #s do local c = string.sub(s,i,i) if c == "*" then UiRect(sizeX, sizeY) end UiTranslate(sizeX, 0) end UiPop() UiTranslate(0, sizeY) end function drawTrophy(width) UiPush() UiTranslate(width*0.5 - 5 * 12, 10) UiColor(1, 1, 0) drawRects(" ** **") drawRects(" ** ************* **") drawRects("** ************* **") drawRects("** ************* **") drawRects("** ************* **") drawRects(" ** ************* **") drawRects(" ** ************* **") drawRects(" ***********") drawRects(" ***********") drawRects(" ********") drawRects(" ********") drawRects(" ****") drawRects(" ****") drawRects(" **") drawRects(" **") drawRects(" ********") drawRects(" ********") UiPop() end function drawMissionStats(id, ignoreTargets, ignoreTimeLeft, width) local mission = gArtMissions[id] local score = GetInt("savegame.mod."..id..".score") local complete = GetBool("savegame.mod."..id..".complete") if score == 0 and not complete then return end local left = GetFloat("savegame.mod."..id..".timeleft") local time = GetFloat("savegame.mod."..id..".missiontime") local required = mission.required local optional = mission.primary + mission.secondary - mission.required local requiredTaken = math.min(mission.required, score) local optionalTaken = math.min(math.max(score - mission.required, 0), mission.primary + mission.secondary - mission.required) UiPush() UiTranslate(10, 0) UiColor(0,0,1) UiRect(width - 20, 20) UiTranslate(5, 10) UiPush() UiAlign("middle") heading1() UiText(mission.title) UiPop() UiTranslate(0, 28) UiPush() local w = 0 local h = 0 if not ignoreTargets then heading2() UiText(GetTranslatedStringByKey("UI_TEXT_TARGETS"), true) normal() local textWidth = 0 w, h = UiText(GetTranslatedStringByKey("UI_TEXT_REQUIRED")) if w > textWidth then textWidth = w end local textOptional = GetTranslatedStringByKey("UI_TEXT_OPTIONAL") local w1,h1 = UiGetTextSize(textOptional) if w1 > textWidth then textWidth = w1 end UiPush() UiTranslate(textWidth, 0) drawDots(required, requiredTaken, width - 20 - textWidth) UiPop() UiTranslate(0, h) if optional > 0 then UiText(textOptional) UiPush() UiTranslate(textWidth, 0) drawDots(optional, optionalTaken, width - 20 - textWidth) UiPop() end UiTranslate(0, h1) UiTranslate(0, 10) end heading2() UiText(GetTranslatedStringByKey("UI_TEXT_STATS"), true) local timeLeft = GetTranslatedStringByKey("UI_TEXT_TIME_LEFT") local textWidth, _ = UiGetTextSize(timeLeft) local missionTime = GetTranslatedStringByKey("UI_TEXT_MISSION_TIME") w, _ = UiGetTextSize(missionTime) if w > textWidth then textWidth = w end normal() if not ignoreTimeLeft then w, h = UiText(timeLeft) UiPush() UiTranslate(textWidth, 0) drawTime(left, width - 30 - textWidth) UiPop() UiTranslate(0, h) end UiText(missionTime) UiPush() UiTranslate(textWidth, 0) drawTime(time, width - 30 - textWidth) UiPop() UiPop() UiPop() UiTranslate(width, 0) end function draw() local hasScore = false local hasFullScore = true for i = 1, #missions do local score = GetInt("savegame.mod."..missions[i]..".score") local complete = GetInt("savegame.mod."..missions[i]..".complete") if score > 0 or complete then hasScore = true if score == 0 then hasFullScore = false end else hasFullScore = false end end if not hasScore then return end -- Top bar UiPush() normal() UiPush() UiTranslate(10, 30) UiText("112") UiPush() UiTranslate(40, 0) UiText(GetTranslatedStringByKey("UI_TEXT_TV_TEXT")) UiPop() UiPop() UiPush() UiTranslate(0, 40) UiColor(0,0,1) UiRect(UiWidth(), 20) UiPop() UiPop() -- Content UiPush() UiTranslate(0, 80) local width = UiWidth() / 3 UiPush() drawMissionStats(missions[1], false, false, width) drawMissionStats(missions[2], false, false, width) drawMissionStats(missions[3], false, false, width) UiPop() UiTranslate(0, 160) UiPush() drawMissionStats(missions[4], false, false, width) drawMissionStats(missions[5], true, true, width) if hasFullScore then drawTrophy(width) end UiPop() UiPop() UiPush() -- Bottom bar UiTranslate(0, UiHeight() - 40) UiColor(0,0,1) UiRect(UiWidth(), 20) heading1() UiPush() UiAlign("left middle") local textLocal = "loc@UI_TEXT_LOCAL_100" local textWorld = "loc@UI_TEXT_WORLD_120" local textIndex = "loc@UI_TEXT_INDEX_700" local widthLocal = GetTextSize(textLocal) local widthWorld = GetTextSize(textWorld) local widthIndex = GetTextSize(textIndex) local offset = 50 local totalWidth = widthLocal + offset + widthWorld + offset + widthIndex UiTranslate(UiCenter() - totalWidth / 2, 10) UiText(textLocal) UiTranslate(widthLocal + offset, 0) UiText(textWorld) UiTranslate(widthWorld + offset, 0) UiText(textIndex) UiPop() UiTranslate(0, 20) local w4 = UiWidth()/4 UiPush() normal() UiColor(1,0,0) UiAlign("center middle") UiTranslate(w4*0.5, 10) UiText("113") UiPop() UiTranslate(w4, 0) UiPush() normal() UiColor(0,1,0) UiAlign("center middle") UiTranslate(w4*0.5, 10) UiText("114") UiPop() UiTranslate(w4, 0) UiPush() normal() UiColor(1,1,0) UiAlign("center middle") UiTranslate(w4*0.5, 10) UiText("115") UiPop() UiTranslate(w4, 0) UiPush() normal() UiColor(0,1,1) UiAlign("center middle") UiTranslate(w4*0.5, 10) UiText("116") UiPop() UiPop() end