-- -- Autor: BenjamÌn de la Fuente Ranea -- Fecha: 28-11-2008 -- -- Script de carga inicial -- -- Construye el texto informativo de la carrera de cada coche function getCarResultText(_pos) local carName = GetCarNameByPos(_pos) local playerId = GetPlayerIdByPos(_pos) local playerName = GetPlayerName(carName) return {playerName, ConvertTimeToString(GetCarRaceTime(carName)), GetPlayerPoints(playerId) .. ""} end -- Actualiza los datos de la tabla de resultados con forme van entrando los coche por meta function updateRaceResult(_pos, _bForceShow) if ExistsActor("Menu") then if #g_carsFinished == 0 or _bForceShow then --log("--------------------------------- SI " .. _pos) if IsUserCar(GetCarNameByPos(_pos)) then SetEffectParamColor( "name_fg" .. _pos, "blanco" .. _pos, "g_matDiffuse", {0.87,0.57,0.0,1.0} ) SetEffectParamColor( "points_fg" .. _pos, "blanco" .. _pos, "g_matDiffuse", {0.87,0.57,0.0,1.0} ) SetEffectParamColor( "time_fg" .. _pos, "blanco" .. _pos, "g_matDiffuse", {0.87,0.57,0.0,1.0} ) end local text = getCarResultText(_pos) SetText("name_fg" .. _pos, text[1]) SetText("name_bg" .. _pos, text[1]) SetText("time_fg" .. _pos, text[2]) SetText("time_bg" .. _pos, text[2]) SetText("points_fg" .. _pos, text[3]) SetText("points_bg" .. _pos, text[3]) SetActorAnim("Menu", { anim = "menu/race_results_finished_" .. _pos .. ".anm", loop = false, }) else --log("--------------------------------- ENCOLAR " .. _pos) EnqueueExecuteScript("Menu", "updateRaceResult(" .. _pos .. ")") end else --log("--------------------------------- NO " .. _pos ) table.insert(g_carsFinished, _pos) table.sort(g_carsFinished) end end function first() return { scale = 0.1, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = g_Text._1st, align = E_ALIGN_LEFT, layer = LF_PANELS+1 } end function second() return { scale = 0.1, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = g_Text._2nd, align = E_ALIGN_LEFT, layer = LF_PANELS+1 } end function third() return { scale = 0.1, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = g_Text._3rd, align = E_ALIGN_LEFT, layer = LF_PANELS+1 } end function fourth() return { scale = 0.1, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = g_Text._4th, align = E_ALIGN_LEFT, layer = LF_PANELS+1 } end function raceResultText(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 end return { scale = 0.095, font = fontStr, overlap = g_TextOverlap, text = g_Text.raceResults, align = E_ALIGN_LEFT, layer = layerFlag } end function results(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 end return { scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = g_Text.results, align = E_ALIGN_LEFT, layer = layerFlag } end function race_name() return { scale = 0.1, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = TrackSelected .. "- " .. g_trackInfo[CupSelected][TrackSelected].comercialName, align = E_ALIGN_LEFT } end function firstname(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local fgbg = "_bg" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 fgbg = "_fg" end return { name = "name" .. fgbg .. "1", scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = "", align = E_ALIGN_LEFT, layer = layerFlag } end function secondname(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local fgbg = "_bg" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 fgbg = "_fg" end return { name = "name" .. fgbg .. "2", scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = "", align = E_ALIGN_LEFT, layer = layerFlag } end function thirdname(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local fgbg = "_bg" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 fgbg = "_fg" end return { name = "name" .. fgbg .. "3", scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = "", align = E_ALIGN_LEFT, layer = layerFlag } end function fourthname(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local fgbg = "_bg" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 fgbg = "_fg" end return { name = "name" .. fgbg .. "4", scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = "", align = E_ALIGN_LEFT, layer = layerFlag } end function ptsletters(_pos, _bForeGround) --local carName = GetCarNameByClasification(_pos) --local playerId = GetPlayerIdByCarName(carName) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local auxname = "ptsletters" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 else auxname = auxname .. "bg" end log(auxname .. _pos) return { scale = 0.08, name = auxname .. _pos, font = fontStr, overlap = g_TextOverlap, text = g_Text.pts, align = E_ALIGN_LEFT, layer = layerFlag } end function firstpoints(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local fgbg = "_bg" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 fgbg = "_fg" end return { name = "points" .. fgbg .. "1", scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = "", align = E_ALIGN_LEFT, layer = layerFlag } end function secondpoints(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local fgbg = "_bg" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 fgbg = "_fg" end return { name = "points" .. fgbg .. "2", scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = "", align = E_ALIGN_LEFT, layer = layerFlag } end function thirdpoints(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local fgbg = "_bg" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 fgbg = "_fg" end return { name = "points" .. fgbg .. "3", scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = "", align = E_ALIGN_LEFT, layer = layerFlag } end function fourthpoints(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local fgbg = "_bg" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 fgbg = "_fg" end return { name = "points" .. fgbg .. "4", scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = "", align = E_ALIGN_LEFT, layer = layerFlag } end function firsttime(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local fgbg = "_bg" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 fgbg = "_fg" end return { name = "time" .. fgbg .. "1", scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = "", align = E_ALIGN_LEFT, layer = layerFlag } end function secondtime(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local fgbg = "_bg" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 fgbg = "_fg" end return { name = "time" .. fgbg .. "2", scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = "", align = E_ALIGN_LEFT, layer = layerFlag } end function thirdtime(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local fgbg = "_bg" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 fgbg = "_fg" end return { name = "time" .. fgbg .. "3", scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = "", align = E_ALIGN_LEFT, layer = layerFlag } end function fourthtime(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS local fgbg = "_bg" if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 1 fgbg = "_fg" end return { name = "time" .. fgbg .. "4", scale = 0.085, font = fontStr, overlap = g_TextOverlap, text = "", align = E_ALIGN_LEFT, layer = layerFlag } end g_carsFinished = {} function tournamentRaceResults() CreateActor("ActorGeom", { name = "Menu", model = "menu/race_results.mesh", touchable = true, camera = "HUD", layer = LF_PANELS }) SetActorAnim("Menu", { anim = "menu/race_results_start.anm", loop = false, velocity = 1.5, }) --tinto la llama pintada, que va bajo el nombre del circuito if(CupSelected == 1) then SetEffectParamColor( "Menu", "menu_tint", "g_matDiffuse", {0,0,0,1.0}) SetEffectParamColor( "Menu", "menu_tint", "g_ambientColor", {0.514,0.735,0.977,1.0} ) elseif(CupSelected == 2) then SetEffectParamColor( "Menu", "menu_tint", "g_matDiffuse", {0,0,0,1.0}) SetEffectParamColor( "Menu", "menu_tint", "g_ambientColor", {1.0,1.0,0.28,1.0} ) elseif(CupSelected == 3) then SetEffectParamColor( "Menu", "menu_tint", "g_matDiffuse", {0,0,0,1.0}) SetEffectParamColor( "Menu", "menu_tint", "g_ambientColor", {0.769,0.190,0.190,1.0} ) end -- TODO: ver cuantos coches han entrado ya y ponerles la animción encolada for i, v in ipairs(g_carsFinished) do EnqueueExecuteScript("Menu", "updateRaceResult(" .. v .. ", true)") --updateRaceResult(v, true) end EnqueueExecuteScript("Menu", "g_carsFinished = {}") end