-- -- Autor: Catalin Marcu -- Date: 20-09-2009 -- -- Main loading script -- local lastOverItem = -1 local exitScreen = false --=============================================================================== function ScrollVOverItem(index) -- print("over item: " .. index) if (exitScreen == true) then return end if (lastOverItem ~= -1) then SetTextColor("getTeamText(" .. (32 - lastOverItem) .. ")", 0, 0, 0, 255) end lastOverItem = index SetTextColor("getTeamText(" .. (32 - lastOverItem) .. ")", 255, 255, 255, 255) end --=============================================================================== function ScrollVSelectItem(index) -- print("set item: " .. index) if (exitScreen == true) then return end if (lastOverItem ~= -1) then SetTextColor("getTeamText(" .. (32 - lastOverItem) .. ")", 0, 0, 0, 255) end if (selectedTeam ~= -1) then SetTextColor("getTeamText(" .. (32 - selectedTeam) .. ")", 0, 0, 0, 255) if (selectUserTeam == true) then updatePlayerLook("MenuPlayer", index) if (currentPlayerAnim ~= 7 and currentPlayerAnim ~= 1) then currentPlayerAnim = 7 ClearActorAnims("MenuPlayer", true, true) SetActorAnimPenalty("MenuPlayer", { anim = "Main_menu_player_miraropa.anm", loop = false }) prepareChangePlayerAnim("MenuPlayer", 1) end else updatePlayerLook("PlayerVersus", index) if (currentOpponentAnim ~= 7) then currentOpponentAnim = 7 SetActorAnimPenalty("PlayerVersus", { anim = "Main_menu_playervs_miraropa.anm", loop = false }) EnqueueExecuteScript("PlayerVersus", "currentOpponentAnim = 0") end end end selectedTeam = index lastOverItem = index SetTextColor("getTeamText(" .. (32 - selectedTeam) .. ")", 255, 255, 255, 255) setCurrentTeam(index) --SetText("TextPrecision", "" .. currentTeam.precision .. "%%") --SetText("TextPower", "" .. currentTeam.power .. "%%") --SetText("TextDive", "" .. currentTeam.dive .. "%%") --SetText("TextClearance", "" .. currentTeam.clearance .. "%%") SetText("TextPrecision", string.format("%3d%%%%", currentTeam.precision)) SetText("TextPower", string.format("%3d%%%%", currentTeam.power)) SetText("TextDive", string.format("%3d%%%%", currentTeam.dive)) SetText("TextClearance", string.format("%3d%%%%", currentTeam.clearance)) Sound.PlaySound(MenuSounds.Fx.buttonOk, false) statsScale = 0.2 EnqueueExecuteScript("TeamStats", "modifyTeamStats(" .. index .. ")") end --=============================================================================== function modifyTeamStats(index) if (exitScreen == true) then return end local yPos = -38.5 local actorNames = {"TeamPrecision", "TeamPower", "TeamDive", "TeamClearance"} local color = {0, 0, 0, 0} local width = 30 local yPos = {-33, -51, -68.5, -86} local xPos = -155 if (selectUserTeam == false) then xPos = 113 end local height = {4, 4, 4, 4} if (IPAD_VERSION == true) then yPos = {-72, -109, -146, -184} height = {11, 11, 11, 11} xPos = -330 if (selectUserTeam == false) then xPos = 240 end end -- for android, scale the iPhone positions according to the real viewport aspect ratio. local xRatio, yRatio if ANDROID_VERSION == true then local vpWidth, vpHeight = GetViewportSize() xRatio = vpWidth / 480 yRatio = vpHeight / 320 xPos = xPos * xRatio for i=1,#yPos do yPos[i] = yPos[i] * yRatio end for i=1,#height do height[i] = height[i] * yRatio end end setCurrentTeam(index) -- defined in teams.lua local stats = {currentTeam.precision, currentTeam.power, currentTeam.dive, currentTeam.clearance} destroyStats() for count = 1, 4 do if stats[count] <= 50 then color = { 214, 59, 63, 255 } elseif stats[count] <= 70 then color = { 238, 202, 54, 255 } else color = { 24, 179, 85, 255 } end if (IPAD_VERSION == true) then width = stats[count] * 0.82 * statsScale else width = stats[count] * 0.39 * statsScale end if ANDROID_VERSION == true then width = width * xRatio end CreateActorImage(actorNames[count], xPos + width, yPos[count], width, height[count], "statusbar.pvr", color[1], color[2], color[3], color[4], "") SetLayerFlags(actorNames[count], LF_PANELS) end if (statsScale < 1.0) then statsScale = statsScale + 0.2 EnqueueExecuteScript("TeamStats", "modifyTeamStats(" .. index .. ")") end end --=============================================================================== function destroyStats() local actorNames = {"TeamPrecision", "TeamPower", "TeamDive", "TeamClearance"} for count = 1, 4 do if (ExistsActor(actorNames[count]) == true) then DestroyActor(actorNames[count]) end end end --=============================================================================== function getTeamText(index) if (selectUserTeam == true) then return { scale = 0.09, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, align = E_ALIGN_RIGHT, layer = LF_PANELS, vertical = E_VALIGN_CENTER, text = getTeamFullName(32 - index) } else return { scale = 0.09, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, align = E_ALIGN_LEFT, layer = LF_PANELS, vertical = E_VALIGN_CENTER, text = getTeamFullName(32 - index) } end end --=============================================================================== function getStatusText(index) if (index == 1) then return { scale = 0.1, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, layer = LF_PANELS, vertical = E_VALIGN_CENTER, text = txtBack } elseif (index == 2) then return { scale = 0.1, font = "font4.fnt", overlap = -3, color = {0, 0, 0, 255}, layer = LF_PANELS, vertical = E_VALIGN_CENTER, text = txtOk } elseif (index == 3) then return { scale = 0.065, font = "font4.fnt", overlap = -3, color = {255, 255, 255, 255}, layer = LF_PANELS, align = E_ALIGN_LEFT, vertical = E_VALIGN_CENTER, text = txtPrecision } elseif (index == 4) then return { scale = 0.065, font = "font4.fnt", overlap = -3, color = {255, 255, 255, 255}, layer = LF_PANELS, align = E_ALIGN_LEFT, vertical = E_VALIGN_CENTER, text = txtPower } elseif (index == 5) then return { scale = 0.065, font = "font4.fnt", overlap = -3, color = {255, 255, 255, 255}, layer = LF_PANELS, align = E_ALIGN_LEFT, vertical = E_VALIGN_CENTER, text = txtDive } elseif (index == 6) then return { scale = 0.065, font = "font4.fnt", overlap = -3, color = {255, 255, 255, 255}, layer = LF_PANELS, align = E_ALIGN_LEFT, vertical = E_VALIGN_CENTER, text = txtClearance } elseif (index == 7) then return { scale = 0.08, font = "font4.fnt", overlap = -3, color = {255, 255, 255, 255}, layer = LF_PANELS, vertical = E_VALIGN_CENTER, text = txtTeamProfile } elseif (index == 8) then return { name = "TextPrecision", scale = 0.065, font = "font4.fnt", overlap = -3, color = {255, 255, 255, 255}, layer = LF_PANELS, vertical = E_VALIGN_CENTER, text = "" } elseif (index == 9) then return { name = "TextPower", scale = 0.065, font = "font4.fnt", overlap = -3, color = {255, 255, 255, 255}, layer = LF_PANELS, vertical = E_VALIGN_CENTER, text = "" } elseif (index == 10) then return { name = "TextDive", scale = 0.065, font = "font4.fnt", overlap = -3, color = {255, 255, 255, 255}, layer = LF_PANELS, vertical = E_VALIGN_CENTER, text = "" } elseif (index == 11) then return { name = "TextClearance", scale = 0.065, font = "font4.fnt", overlap = -3, color = {255, 255, 255, 255}, layer = LF_PANELS, vertical = E_VALIGN_CENTER, text = "" } end end --=============================================================================== function exitTeamSelection(functionName) -- print("exiting team selection") exitScreen = true destroyStats() SetVScroll("") ClearActorAnims("MenuArrowsBack", true, true) ClearActorAnims("MenuArrowsFront", true, true) if (selectUserTeam == true) then SetActorAnimPenalty("MenuArrowsBack", { anim = "Select_team_arrowsback_out.anm", loop = false }) SetActorAnimPenalty("MenuArrowsFront", { anim = "Select_team_arrowsfront_out.anm", loop = false }) SetActorAnimPenalty("TeamSelectMarker", { anim = "Select_team_marker_out.anm", loop = false }) SetActorAnimPenalty("TeamStats", { anim = "Main_menu_status_out.anm", loop = false }) SetActorAnimPenalty("TeamScroll", { anim = "Select_team_Scroll_out.anm", loop = false }) else SetActorAnimPenalty("MenuArrowsBack", { anim = "Select_team_arrowsback_mirror_out.anm", loop = false }) SetActorAnimPenalty("MenuArrowsFront", { anim = "Select_team_arrowsfront_mirror_out.anm", loop = false }) SetActorAnimPenalty("TeamSelectMarker", { anim = "Select_team_marker_mirror_out.anm", loop = false }) SetActorAnimPenalty("TeamStats", { anim = "Main_menu_status_mirror_out.anm", loop = false }) SetActorAnimPenalty("TeamScroll", { anim = "Select_team_Scroll_mirror_out.anm", loop = false }) -- currentPlayerAnim = 8 -- ClearAllTimeExecuteScripts() -- ClearActorAnims("MenuPlayer", true, true) -- SetActorAnimPenalty("MenuPlayer", { anim = "Main_menu_player_salejugadormenu.anm", loop = false }) -- EnqueueExecuteScript("MenuPlayer", "updatePlayerLook(\"MenuPlayer\", userTeamId)") -- EnqueueExecuteScript("MenuPlayer", "SetActorAnimPenalty(\"MenuPlayer\", { anim = \"Main_menu_player_entrada.anm\", loop = false })\n" .. -- "prepareChangePlayerAnim(\"MenuPlayer\", 1)") end Sound.PlaySound(MenuSounds.Fx.panelOut, false) EnqueueExecuteScript("MenuArrowsFront", "destroyTeamSelection()") EnqueueExecuteScript("MenuArrowsFront", functionName) end --=============================================================================== function destroyTeamSelection() DestroyActor("MenuArrowsBack") DestroyActor("MenuArrowsFront") DestroyActor("TeamSelectMarker") DestroyActor("TeamStats") DestroyActor("TeamScroll") end --=============================================================================== function goToPreviousScreen() if (previousScreen == SCREEN_MAIN_MENU) then goToMainMenu() elseif (previousScreen == SCREEN_QUICK_SHOOTOUT) then goToQuickShootout() elseif (previousScreen == SCREEN_MULTIPLAYER) then goToMultiplayer() end end --=============================================================================== function getScroll() if (selectUserTeam == true) then return {name = "TeamSelect", model = "Select_team_slider.mesh", touchable = false, camera = "backgroundCamera", layer = LF_PANELS, internalCulling = true} else return {name = "TeamSelect", model = "Select_team_slider_mirror.mesh", touchable = false, camera = "backgroundCamera", layer = LF_PANELS, internalCulling = true} end end --=============================================================================== function goToTeamSelection() currentScreen = SCREEN_TEAM_SELECTION exitScreen = false stopMusicOnExitScreen=true if (selectUserTeam == true) then CreateActor("ActorGeom", {name = "MenuArrowsBack", model = "Select_team_arrowsback.mesh", touchable = false, camera = "backgroundCamera"}) SetActorAnimPenalty("MenuArrowsBack", { anim = "Select_team_arrowsback_in.anm", loop = false }) DeactivateActor("MenuPlayer") ActivateActor("MenuPlayer") CreateActor("ActorGeom", {name = "MenuArrowsFront", model = "Select_team_arrowsfront.mesh", touchable = false, camera = "backgroundCamera", layer = LF_PANELS}) SetActorAnimPenalty("MenuArrowsFront", { anim = "Select_team_arrowsfront_in.anm", loop = false }) CreateActor("ActorGeom", {name = "TeamSelectMarker", model = "Select_team_marker.mesh", touchable = false, camera = "backgroundCamera"}) SetActorAnimPenalty("TeamSelectMarker", { anim = "Select_team_marker_in.anm", loop = false }) CreateActor("ActorGeom", {name = "TeamScroll", model = "Select_team_Scroll.mesh", touchable = false, camera = "backgroundCamera", layer = LF_PANELS}) SetActorAnimPenalty("TeamScroll", { anim = "Select_team_Scroll_in.anm", loop = false }) SetVScroll("TeamSelect", "Select_team_slider.anm", false, 32, 0.4, 0.4, true) EnableScrollOverCall(false, true) CreateActor("ActorGeom", {name = "TeamStats", model = "Main_menu_status.mesh", touchable = true, camera = "backgroundCamera", layer = LF_PANELS}) SetActorAnimPenalty("TeamStats", { anim = "Main_menu_status_in.anm", loop = false }) else CreateActor("ActorGeom", {name = "MenuArrowsBack", model = "Select_team_arrowsback_mirror.mesh", touchable = false, camera = "backgroundCamera"}) SetActorAnimPenalty("MenuArrowsBack", { anim = "Select_team_arrowsback_mirror_in.anm", loop = false }) DeactivateActor("PlayerVersus") ActivateActor("PlayerVersus") currentOpponentAnim = 0 CreateActor("ActorGeom", {name = "MenuArrowsFront", model = "Select_team_arrowsfront_mirror.mesh", touchable = false, camera = "backgroundCamera", layer = LF_PANELS}) SetActorAnimPenalty("MenuArrowsFront", { anim = "Select_team_arrowsfront_mirror_in.anm", loop = false }) CreateActor("ActorGeom", {name = "TeamSelectMarker", model = "Select_team_marker_mirror.mesh", touchable = false, camera = "backgroundCamera"}) SetActorAnimPenalty("TeamSelectMarker", { anim = "Select_team_marker_mirror_in.anm", loop = false }) CreateActor("ActorGeom", {name = "TeamScroll", model = "Select_team_Scroll_mirror.mesh", touchable = false, camera = "backgroundCamera", layer = LF_PANELS}) SetActorAnimPenalty("TeamScroll", { anim = "Select_team_Scroll_mirror_in.anm", loop = false }) SetVScroll("TeamSelect", "Select_team_slider_mirror.anm", false, 32, 0.4, 0.4, true) EnableScrollOverCall(false, true) CreateActor("ActorGeom", {name = "TeamStats", model = "Main_menu_status_mirror.mesh", touchable = true, camera = "backgroundCamera", layer = LF_PANELS}) SetActorAnimPenalty("TeamStats", { anim = "Main_menu_status_mirror_in.anm", loop = false }) end Sound.PlaySound(MenuSounds.Fx.panelIn, false) local team if (selectUserTeam == true) then team = userTeamId else team = opponentTeamId -- print("" .. opponentTeamId) -- updatePlayerLook("MenuPlayer", opponentTeamId) -- ClearActorAnims("MenuPlayer", true, true) -- SetActorAnimPenalty("MenuPlayer", { anim = "Main_menu_player_entrada.anm", loop = false }) -- currentPlayerAnim = 1 -- prepareChangePlayerAnim("MenuPlayer", 1) end selectedTeam = -1 lastOverItem = -1 -- if (team > -1) then -- if (team > 5) then -- SelectVScrollItem(team - 5, false, 1.0) -- SetTextColor("getTeamText(" .. (32 - (team - 5)) .. ")", 0, 0, 0, 255) -- end -- SelectVScrollItem(team, true, 30.0) -- end SelectVScrollItem(team, false, 1.0) selectedTeam = team if (selectUserTeam == true) then else end end