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