View difference between Paste ID: 3ccuhd3U and EtGqFdhy
SHOW: | | - or go back to the newest paste.
1
-------------------------------------------------
2
-- Turn Processing Popup
3
-------------------------------------------------
4
include( "IconSupport" );
5
include( "SupportFunctions" );
6
7
local ms_IsShowingMinorCiv = false;
8
9
-------------------------------------------------
10
-- QuickMovement toggle functions
11
-------------------------------------------------
12
function ToggleQuickMovementON()
13
14-
	OptionsManager.SetSinglePlayerQuickMovementEnabled_Cached(true)
14+
	OptionsManager.SetSinglePlayerQuickMovementEnabled_Cached(true);
15-
	OptionsManager.CommitGameOptions()
15+
	OptionsManager.CommitGameOptions();
16
	
17
	local options = {};
18
	table.insert(options, { "GAMEOPTION_QUICK_MOVEMENT", true });
19
	Network.SendGameOptions(options);
20
end
21
22
function ToggleQuickMovementOFF()
23
24-
	OptionsManager.SetSinglePlayerQuickMovementEnabled_Cached(false)
24+
	OptionsManager.SetSinglePlayerQuickMovementEnabled_Cached(false);
25-
	OptionsManager.CommitGameOptions()
25+
	OptionsManager.CommitGameOptions();
26
	
27
	local options = {};
28
	table.insert(options, { "GAMEOPTION_QUICK_MOVEMENT", false });
29
	Network.SendGameOptions(options);
30
end
31
32
------------------------------------------------------------
33
------------------------------------------------------------
34
function GetPlayer (iPlayerID)
35
	if (iPlayerID < 0) then
36
		return nil;
37
	end
38
39
	if (Players[iPlayerID]:IsHuman()) then
40
		return nil;
41
	end;
42
43
	return Players[iPlayerID];
44
end
45
46
-------------------------------------------------
47
-- OnAITurnStart
48
-------------------------------------------------
49
function OnAITurnStart(iPlayerID, szTag)
50
	
51
	if(PreGame.IsMultiplayerGame()) then
52
		-- Turn Queue UI (see ActionInfoPanel.lua) replaces the turn processing UI in multiplayer.  
53
		return;
54
	end
55
56
	if( ContextPtr:IsHidden() ) then
57
		ContextPtr:SetHide( false );
58
		Controls.Anim:SetHide( true );
59
		ms_IsShowingMinorCiv = false;
60
	end
61
	
62
	local player = GetPlayer(iPlayerID);
63
	if (player == nil) then
64
		return;	
65
	end
66
67
	if (not player:IsTurnActive()) then
68
		return;
69
	end
70
71
	-- Determine if the local player has met this player, else we will just a generic processing message
72
	
73
	local pLocalTeam = Teams[ Players[ Game.GetActivePlayer() ]:GetTeam() ];
74
    local bMet = pLocalTeam:IsHasMet( player:GetTeam() );
75
76
	local bIsMinorCiv = player:IsMinorCiv();
77
	
78
	if (bIsMinorCiv and ms_IsShowingMinorCiv) then
79
		-- If we are already showing the Minor Civ processing, just exit.  We don't show them individually because they are usually quick to process
80
		return;
81
	end
82
83
	local civDescription;
84
	local bIsBarbarian = player:IsBarbarian();
85
	if (bIsBarbarian and Game.IsOption(GameOptionTypes.GAMEOPTION_NO_BARBARIANS)) then
86
		-- Even if there are no barbarians, we will get this call, just skip out if they are turned off
87
		return;
88
	end
89
	-- If we have met them, or it is a minor civ or it is the barbarians, show it.
90
	if (bMet or bIsMinorCiv or bIsBarbarian) then
91
		-- Set Civ Icon
92
        Controls.CivIconBG:SetHide( false );
93
        Controls.CivIconShadow:SetHide( false );
94
		CivIconHookup(iPlayerID, 64, Controls.CivIcon, Controls.CivIconBG, Controls.CivIconShadow, false, true); 
95
			
96
		if (player:IsMinorCiv()) then
97
			civDescription = Locale.ConvertTextKey( "TXT_KEY_PROCESSING_MINOR_CIVS" );
98
			ms_IsShowingMinorCiv = true;
99
		else
100
			local civType = player:GetCivilizationType();
101
			local civInfo = GameInfo.Civilizations[civType];
102
			local strCiv = Locale.ConvertTextKey(civInfo.ShortDescription);
103
			ms_IsShowingMinorCiv = false;
104
			if(strCiv and #strCiv > 0) then
105
				civDescription = Locale.ConvertTextKey(strCiv);
106
			else	
107
				civDescription = Locale.ConvertTextKey( "TXT_KEY_MULTIPLAYER_DEFAULT_PLAYER_NAME", iPlayerID + 1 );
108
			end
109
				
110
			civDescription = Locale.ConvertTextKey( "TXT_KEY_PROCESSING_TURN_FOR", civDescription );
111
		end
112
	else
113
		civDescription = Locale.ConvertTextKey( "TXT_KEY_PROCESSING_TURN_FOR_UNMET_PLAYER", iPlayerID + 1 );
114
		Controls.CivIcon:SetTexture("CivSymbolsColor512.dds");
115
        Controls.CivIcon:SetTextureOffsetVal( 448 + 7, 128 + 7 );
116
        Controls.CivIcon:SetColor( Vector4( 1.0, 1.0, 1.0, 1.0 ) );
117
        Controls.CivIcon:SetHide( false );
118
        Controls.CivIconBG:SetHide( true );
119
        Controls.CivIconShadow:SetHide( true );
120
        ms_IsShowingMinorCiv = false;
121
	end		
122
	if (Controls.Anim:IsHidden()) then
123
		Controls.Anim:SetHide( false );
124
		Controls.Anim:BranchResetAnimation();
125
	end
126
	Controls.TurnProcessingTitle:SetText(civDescription);
127
128
end
129
Events.AIProcessingStartedForPlayer.Add( ToggleQuickMovementON );
130
Events.AIProcessingStartedForPlayer.Add( OnAITurnStart );
131
-------------------------------------------------------------------------
132
-- OnPlayerTurnStart
133
-- Human player's turn, hide the UI
134
-------------------------------------------------------------------------
135
function OnPlayerTurnStart()
136
	if (not ContextPtr:IsHidden()) then
137
		Controls.Anim:Reverse();
138
		Controls.Anim:Play();
139
	end
140
end
141
Events.ActivePlayerTurnStart.Add( ToggleQuickMovementOFF );
142
Events.ActivePlayerTurnStart.Add( OnPlayerTurnStart );
143
Events.RemotePlayerTurnStart.Add( ToggleQuickMovementOFF );
144
Events.RemotePlayerTurnStart.Add( OnPlayerTurnStart );
145
146
-------------------------------------------------------------------------
147
-- Callback while the alpha animation is playing.
148
-- It will also be called once, when the animation stops.
149
function OnAlphaAnim()
150
	if (Controls.Anim:IsStopped() and Controls.Anim:GetAlpha() == 0.0) then
151
		Controls.Anim:SetHide( true );
152
		ContextPtr:SetHide( true );
153
		print("Hiding TurnProcessing");
154
	end
155
end
156
Controls.Anim:RegisterAnimCallback( OnAlphaAnim );