-- -- Autor: BenjamÌn de la Fuente Ranea -- Fecha: 28-11-2008 -- -- carga pantalla de seleccion de pista de timetrial -- -- Esta función se llama cuando el usuario pulsa sobre un circuito para mostrar su info en el panel de la derecha execute("menu/timeTrialRaceResults.lua") function selectTrackText(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS + 2 if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 3 end return { scale = 0.12, font = fontStr, overlap = g_TextOverlap, text = g_Text.selectTrack, align = E_ALIGN_LEFT, layer = layerFlag } end function onlineText(_bForeGround) local fontStr = "fontTRN_bg.fnt" local layerFlag = LF_PANELS + 2 if _bForeGround then fontStr = "fontTRN_fg.fnt" layerFlag = LF_PANELS + 3 end return { scale = 0.12, font = fontStr, overlap = g_TextOverlap, text = g_Text.timetrial, align = E_ALIGN_LEFT, layer = layerFlag } end function getTimeMark(_id) if(trackIsLocked(_id)) then return {"",""} else local cup, track = GetCupAndTrackFromTrackId(_id) local ghostTime = GetTrackLocalRecord(cup, track) if ghostTime == 0 then return {"-:--.", "---"} else local timeStr = ConvertTimeToString(ghostTime) return {string.sub(timeStr, 1, -4),string.sub(timeStr, -3)} end end end function getRecordTimeMark(_id) return {"1:30.","000"} end function yourtimebg(_id) return { scale = 0.07, font = "fontTRN_bg.fnt", overlap = g_TextOverlap, text = getTimeMark(_id)[1], align = E_ALIGN_RIGHT, layer = LF_PANELS } end function yourtimefg(_id) return { scale = 0.07, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = getTimeMark(_id)[1], align = E_ALIGN_RIGHT, layer = LF_PANELS + 1 } end function yourtimebg_millis(_id) return { scale = 0.07, font = "fontTRN_bg.fnt", overlap = g_TextOverlap, text = getTimeMark(_id)[2], align = E_ALIGN_LEFT, layer = LF_PANELS } end function yourtimefg_millis(_id) return { scale = 0.07, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = getTimeMark(_id)[2], align = E_ALIGN_LEFT, layer = LF_PANELS + 1 } end function track_record(_id) return { scale = 0.07, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = getRecordTimeMark(_id)[1], align = E_ALIGN_LEFT } end function track_record_millis(_id) return { scale = 0.07, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = getTimeMark(_id)[2], align = E_ALIGN_LEFT } end function trackNextText() log("Next text") return { scale = 0.10, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = g_Text.nextButton, align = E_ALIGN_LEFT} end function trackBackText() log("Back text") return { scale = 0.10, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = g_Text.backButton, align = E_ALIGN_LEFT } end function yourtimeText(_id) --local txt = "Your time:" --if(trackIsLocked(_id)) then -- txt = "Best time:" --end local texto = "" if(trackIsLocked(_id)) then texto = g_Text.lockedCAPS else texto = g_Text.yourTime end return { scale = 0.07, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = texto, align = E_ALIGN_LEFT } end function posText(_id) local txt = "Track" if(trackIsLocked(_id)) then txt = "" end return { scale = 0.05, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = txt, align = E_ALIGN_LEFT } end function yourpos(_id) local txt = "" if(not trackIsLocked(_id)) then txt = txt .. _id end return { scale = 0.19, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = txt, align = E_ALIGN_CENTER } end -- Devuelve el texto y formato para la infromación de cada circuito function trackTitleText(_id) local cup, track = GetCupAndTrackFromTrackId(_id) return { scale = 0.075, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = g_trackInfo[cup][track].comercialName, align = E_ALIGN_LEFT } end --ActorGeoms function prizeIcon(_id) if(trackIsLocked(_id)) then return { model = "lock.mesh", name = "prizeIcon" .. _id } end end function prizeIconBase(_id) if(trackIsLocked(_id)) then return { model = "lockbase.mesh", name = "prizeIconBase" .. _id } end end function track_prize_icon() --return { name = "track_prize_icon", model = "track_prize_icon.mesh" } end --Other function tracksRecordsReceived(_bOk) if _bOk == true then -- Actualizar la tabla de datos UpdateTracksRecords() else -- Animación de cuenta atrás UpdateWaitTime(10) end end function ScrollVSelectItem(_id) Sound.PlaySound(g_ScrollSound) --log( "Me llaman " .. (_id + 1) ) local cup, track = GetCupAndTrackFromTrackId(_id + 1) selectTrack(cup, track) if trackIsLocked(_id+1) then SetEffectParamColor("Menu2", "amarillo", "g_matDiffuse", {0.188, 0.188, 0.188, 1.0} ) else SetEffectParamColor("Menu2", "amarillo", "g_matDiffuse", {0.98, 0.854, 0.0, 1.0} ) end end function trackIsLocked(_id) local bestCS = CUP_LOCKED local cup, track = GetCupAndTrackFromTrackId(_id) for level = 0, 2, 1 do local cupState = GetBestCupState(cup, level) if bestCS < cupState then bestCS = cupState end end --log(_id .. " - " .. bestCS) if bestCS == CUP_LOCKED then return true else return false end end function selectTrack(_cupId, _trackId) if SNSS.IsUserOnline() then local userRank = SNSS.GetUserRank(GetCircuitLeaderBoardId(_cupId, _trackId)) SetText("onlineRankPositionText", iif(userRank > 0, formatBigNumber(userRank), "- - - - -")) SetTextSize("onlineRankPositionText", 0.09) else SetText("onlineRankPositionText", "Not connected") SetTextSize("onlineRankPositionText", 0.07) end log("Información del circuito\nseleccionado" .. _cupId .. " , " .. _trackId) if(CupSelected ~= _cupId) then log(CupSelected .. " > " .. _cupId) SetEffectParamTexture("Background","background","g_diffuseTexture", "cup" .. CupSelected .. "_background.pvr") SetEffectParamTexture("Background","foreground","g_diffuseTexture", "cup" .. _cupId .. "_background.pvr") SetEffectParamTexture("BackgroundMask","backgroundalfa","g_diffuseTexture", "cup" .. CupSelected .. "_background_mask.pvr") SetEffectParamTexture("BackgroundMask","foregroundalfa","g_diffuseTexture", "cup" .. _cupId .. "_background_mask.pvr") SetActorAnim("Background", { anim = "garage/bg_to_fg.anm", loop = false, }) SetActorAnim("BackgroundMask", { anim = "garage/bg_to_fg_alfa.anm", loop = false, }) end --------------------------------------------------------------------------------------------------------------- SetEffectParamTexture("Menu","image","g_diffuseTexture", g_trackInfo[_cupId][_trackId].bigPreview) TrackSelected = _trackId CupSelected = _cupId end function onlineRankText() return { scale = 0.08, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = g_Text.onlineRank, align = E_ALIGN_LEFT } end function onlineRankPositionText() return { name = "onlineRankPositionText", scale = 0.09, font = "fontTRN_fg.fnt", overlap = g_TextOverlap, text = "- - - - -", align = E_ALIGN_LEFT } end function timeTrialBegin() DestroyActor("Menu") DestroyActor("Menu2") CreateActor("ActorGeom", { name = "Background", model = "garage/garage2D_2planos.mesh", layer = LF_WORLD}) CreateActor("ActorGeom", { name = "Menu", model = "menu/timetrial_scroll.mesh", internalCulling = true, layer = LF_PANELS }) CreateActor("ActorGeom", { name = "BackgroundMask", model = "garage/garage2D_2planosalfa.mesh", layer = LF_PANELS+2}) CreateActor("ActorGeom", { name = "Menu2", model = "menu/timetrial_mask.mesh", touchable = true, layer = LF_PANELS+3}) --animaciones de entrada dependiendo de si voy o si vuelvo... if(not g_backMenu ) then if(not ExistsActor("Fade")) then CreateActor("ActorGeom", { name = "Fade", model = "menu/fade_to_black.mesh", layer = LF_PANELS+4}) end ActivateActor("Fade") log("ejecuto fade_black_from_1_to_0") SetActorAnim("Fade", { anim = "menu/fade_black_from_1_to_0.anm", loop = false, }) SetActorAnim("Menu", { anim = "menu/timetrial_start.anm", loop = false, velocity = 1.5, }) SetActorAnim("Menu2", { anim = "menu/timetrial_mask_start.anm", loop = false, velocity = 1.5, }) else SetActorAnim("Menu", { anim = "menu/timetrial_return.anm", loop = false, velocity = 1.5, }) SetActorAnim("Menu2", { anim = "menu/timetrial_mask_return.anm", loop = false, velocity = 1.5, }) end EnqueueExecuteScript("Menu", [[ SetVScroll("Menu", "menu/timetrial_scroll.anm", false, 18, 0.15, 0.15, true) SelectScrollItem(false,0,false) selectTrack(1, 1)]]) end --Actions... setMenuMusic() Sound.PlaySound(g_ShinningButtonSound) TrackSelected = 1 CupSelected = 1 UserLevel = 2 GameMode = E_MODE_ONLINE InitTrial() ActivateActor("Fade") if(not g_backFromGarageToTimetrial) then if(not ExistsActor("Fade")) then CreateActor("ActorGeom", { name = "Fade", model = "menu/fade_to_black.mesh", layer = LF_PANELS+4 }) end SetActorAnim("Fade", { anim = "menu/fade_black_from_0_to_1_15f.anm", loop = false, }) end if(ExistsActor("Menu")) then ClearActorAnims("Menu", true, true) SetActorAnim("Menu", { anim = "menu/main_timetrialpush.anm", loop = false, velocity = 1.2 }) end g_backFromGarageToTimetrial = false EnqueueExecuteScript("Fade", "timeTrialBegin()") if(currentMenuScreen ~= nil) then currentMenuScreen:postFreeScreenResources() end currentMenuScreen = TTimeTrialMenuScreen:new() currentMenuScreen:resetScreen()