function SelectPlayer(playerID, mode, refresh, allowDeadPlayer)
if (mode == nil) then
mode = ms_currentViewMode;
end
if (refresh == nil) then
refresh = false;
end
if (allowDeadPlayer == nil) then
allowDeadPlayer = false;
end
local isDifferentPlayer = false;
if (ms_SelectedPlayerID ~= playerID or mode ~= ms_currentViewMode or refresh == true) then
isDifferentPlayer = true;
-- Deselect them in the ribbon
if (ms_SelectedPlayerID ~= -1) then
local ribbonEntry = ms_LeaderIDToRibbonEntry[ms_SelectedPlayerID];
if (ribbonEntry ~= nil) then
ribbonEntry.SelectedBackground:SetHide( true );
end
end
if (m_firstOpened == false) then
if (ms_SelectedPlayerID == playerID) then
isDifferentPlayer = false;
end
end
ms_SelectedPlayerID = playerID;
UpdateSelectedPlayer(allowDeadPlayer); -- Make sure it is valid
if (ms_SelectedPlayerID ~= -1) then
local ribbonEntry = ms_LeaderIDToRibbonEntry[ms_SelectedPlayerID];
if (ribbonEntry ~= nil) then -- can select a dead player, so check for nil
ribbonEntry.SelectedBackground:SetHide( false );
end
if(ms_SelectedPlayerID ~= ms_LocalPlayerID) then
PopulatePlayerPanelHeader(ms_PlayerPanel, ms_SelectedPlayer);
PopulatePlayerPanel(ms_PlayerPanel, ms_SelectedPlayer);
end
Controls.LeaderAnchor:SetHide(false);
-- If we are switching from one mode into another, show and hide the appropriate controls/ set the appropriate data
if (ms_currentViewMode ~= mode or refresh) then
if (mode == CONVERSATION_MODE) then
SetConversationMode(ms_SelectedPlayer);
elseif (mode == CINEMA_MODE) then
-- If we are switching into CINEMA_MODE.. we have to wait to update our displays until AFTER the fade-down.
-- FadeTimeAnim has an end callback registered to function "ToggleCinemaMode"
if (ContextPtr:IsHidden()) then
-- Unless the context is hidden, in which case we will go directly into cinema mode when the context is showm
m_cinemaMode = true;
else
StartFadeOut();
end
elseif (mode == OVERVIEW_MODE) then
Controls.ConversationContainer:SetHide(true);
Controls.OverviewContainer:SetHide(false);
Controls.VoiceoverTextContainer:SetHide(true);
if (not m_firstOpened) then
Controls.AlphaIn:SetSpeed(3);
Controls.SlideIn:SetSpeed(3);
Controls.AlphaIn:SetPauseTime(0);
Controls.SlideIn:SetPauseTime(0);
Controls.SlideIn:SetBeginVal(-20,0);
end
Controls.AlphaIn:SetToBeginning();
Controls.SlideIn:SetToBeginning();
Controls.AlphaIn
lay();
Controls.SlideIn
lay();
UI.PlaySound("UI_Diplomacy_Open_Long");
end
ms_currentViewMode = mode;
end
ShowLeader(ms_SelectedPlayer);
end
end
if (isDifferentPlayer and ms_SelectedPlayerID ~= ms_LocalPlayerID) then
LuaEvents.DiploScene_LeaderSelect(playerID);
end
m_firstOpened = false;
local w,h = UIManager:GetScreenSizeVal();
-- Set up special display if the player is YOU
if(ms_SelectedPlayerID == ms_LocalPlayerID) then
Controls.NameFade:SetHide(false);
local playerConfig = PlayerConfigurations[ms_LocalPlayerID];
if (playerConfig ~= nil) then
-- Set the leader name
Controls.NameFade:SetToBeginning();
Controls.NameFade
lay();
Controls.NameSlide:SetToBeginning();
Controls.NameSlide
lay();
local leaderDesc = playerConfig:GetLeaderName();
Controls.PlayerNameText:LocalizeAndSetText( Locale.ToUpper( Locale.Lookup(leaderDesc)));
Controls.CivNameText:LocalizeAndSetText( Locale.ToUpper( Locale.Lookup(playerConfig:GetCivilizationDescription())));
SetUniqueCivLeaderData();
end
Controls.PlayerContainer:SetHide(true);
--Controls.LeaderAnchor:SetOffsetX(w - (w/2.5));
UI.SetLeaderPosition(Controls.LeaderAnchor:GetScreenOffset());
LuaEvents.DiploScene_CinemaSequence(ms_SelectedPlayerID);
else
Controls.NameFade:SetHide(true);
Controls.PlayerContainer:SetHide(false);
Controls.LeaderAnchor:SetOffsetX(w - (w/3.5));
UI.SetLeaderPosition(Controls.LeaderAnchor:GetScreenOffset());
end
end