Skip to content

Commit

Permalink
Gathering Storm update (1.0.0.290)
Browse files Browse the repository at this point in the history
  • Loading branch information
Azurency committed Feb 14, 2019
1 parent ad10389 commit efd507f
Show file tree
Hide file tree
Showing 81 changed files with 3,464 additions and 1,342 deletions.
18 changes: 10 additions & 8 deletions Additions/AllianceResearchSupport.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,19 @@ end
function HasMaxLevelResearchAlliance(playerID)
local localPlayerID = Game.GetLocalPlayer();

if playerID ~= localPlayerID then
if (localPlayerID ~= -1 and playerID ~= localPlayerID) then
local localPlayer = Players[localPlayerID];
local localPlayerDiplomacy = localPlayer:GetDiplomacy();
local allianceLevel = localPlayerDiplomacy:GetAllianceLevel(playerID);
if(localPlayer) then
local localPlayerDiplomacy = localPlayer:GetDiplomacy();
local allianceLevel = localPlayerDiplomacy:GetAllianceLevel(playerID);

if allianceLevel == MAX_ALLIANCE_LEVEL then
local allianceType = localPlayerDiplomacy:GetAllianceType(playerID);
if allianceLevel == MAX_ALLIANCE_LEVEL then
local allianceType = localPlayerDiplomacy:GetAllianceType(playerID);

-- If the player we're allied with changes their current research we need to refresh our tech list
if allianceType ~= -1 and GameInfo.Alliances[allianceType].AllianceType == "ALLIANCE_RESEARCH" then
return true;
-- If the player we're allied with changes their current research we need to refresh our tech list
if allianceType ~= -1 and GameInfo.Alliances[allianceType].AllianceType == "ALLIANCE_RESEARCH" then
return true;
end
end
end
end
Expand Down
42 changes: 34 additions & 8 deletions Additions/CityPanelCulture.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,41 @@ include("InstanceManager");
include("SupportFunctions");
include("CivilizationIcon");
include("LoyaltySupport");
include("EspionageViewManager");

local m_kPopulationGraphIM:table = InstanceManager:new( "PopulationGraphInstance", "Top", Controls.PopulationGraphStack );
local m_kIdentityBreakdownIM:table = InstanceManager:new( "CulturalIdentityLineInstance", "Top", Controls.IdentityBreakdownStack );
local m_kPlayerPresenceBreakdownIM:table = InstanceManager:new( "InfluenceLineInstance", "Top", Controls.InfluenceStack );

local m_kEspionageViewManager = EspionageViewManager:CreateManager();

-- ===========================================================================
function OnRefresh()
if ContextPtr:IsHidden() then
return;
end

local localPlayerID = Game.GetLocalPlayer();
local pPlayer = Players[localPlayerID];
local playerID = Game.GetLocalPlayer();
local pPlayer = Players[playerID];
if (pPlayer == nil) then
return;
end

local pCity = UI.GetHeadSelectedCity();
if (pCity == nil) then
pCity = m_kEspionageViewManager:GetEspionageViewCity();
if pCity == nil then
return;
end
else
m_kEspionageViewManager:ClearEspionageViewCity();
end

if pPlayer == nil or pCity == nil then
return;
end

local pPlayerConfig = PlayerConfigurations[localPlayerID];
local pPlayerConfig = PlayerConfigurations[playerID];
local kPlayerGovernors = pPlayer:GetGovernors();
local pCulturalIdentity = pCity:GetCulturalIdentity();

Expand Down Expand Up @@ -91,22 +105,22 @@ function OnRefresh()
Controls.LoyaltyFill:SetPercent(loyaltyPercent);

-- Update loyalty percentage string
Controls.LoyaltyPressureIcon:SetToolTipString(GetLoyaltyPressureIconTooltip(loyaltyPerTurn, localPlayerID));
Controls.LoyaltyPressureIcon:SetToolTipString(GetLoyaltyPressureIconTooltip(loyaltyPerTurn, playerID));
Controls.LoyaltyPressureIcon:SetText(loyaltyFontIcon);

local potentialNewOwner = pCulturalIdentity:GetPotentialTransferPlayer();
if potentialNewOwner ~= -1 then
local ownerController = CivilizationIcon:AttachInstance(Controls.CivilizationOwner);
ownerController:UpdateIconFromPlayerID(localPlayerID);
ownerController:UpdateIconFromPlayerID(playerID);

local ownerCivIconTooltip:string = Locale.Lookup("LOC_LOYALTY_CITY_IS_LOYAL_TO_TT", Locale.Lookup(pPlayerConfig:GetCivilizationDescription()));
local ownerCivIconTooltip:string = Locale.Lookup("LOC_LOYALTY_CITY_IS_LOYAL_TO_TT", pPlayerConfig:GetCivilizationDescription());
Controls.CivilizationOwner.CivIconBacking:SetToolTipString(ownerCivIconTooltip);

local rivalController = CivilizationIcon:AttachInstance(Controls.CivilizationRival);
rivalController:UpdateIconFromPlayerID(potentialNewOwner);

local pNewOwnerConfig = PlayerConfigurations[potentialNewOwner];
local newOwnerCivIconTooltip:string = Locale.Lookup("LOC_LOYALTY_CITY_IS_LOYAL_TO_TT", Locale.Lookup(pNewOwnerConfig:GetCivilizationDescription()));
local newOwnerCivIconTooltip:string = Locale.Lookup("LOC_LOYALTY_CITY_WILL_FALL_TO_TT", pNewOwnerConfig:GetCivilizationDescription());
Controls.CivilizationRival.CivIconBacking:SetToolTipString(newOwnerCivIconTooltip);
else
Controls.CivilizationOwner.CivIconBacking:SetHide(true);
Expand Down Expand Up @@ -149,7 +163,12 @@ function OnRefresh()
Controls.CulturalIdentityEffectBox:SetSizeY(Controls.CulturalIdentityEffectLabel:GetSizeY() + 15);

-- Loyalty Advisor
Controls.CulturalIdentityAdvice:SetText(pCity:GetLoyaltyAdvice());
if m_kEspionageViewManager:IsEspionageView() then
Controls.CulturalIdentityAdvisor:SetHide(true);
else
Controls.CulturalIdentityAdvice:SetText(pCity:GetLoyaltyAdvice());
Controls.CulturalIdentityAdvisor:SetHide(false);
end

--Diplomatic Presence
local identitiesInCity = pCulturalIdentity:GetPlayerIdentitiesInCity();
Expand Down Expand Up @@ -223,6 +242,12 @@ function OnRefresh()
Controls.TabStack:CalculateSize();
end

-- ===========================================================================
function OnShowEnemyCityOverview( ownerID:number, cityID:number)
m_kEspionageViewManager:SetEspionageViewCity( ownerID, cityID );
OnRefresh();
end

-- ===========================================================================
function OnTabStackSizeChanged()
-- Manually resize the context to fit the child stack
Expand Down Expand Up @@ -266,6 +291,7 @@ function Initialize()
Events.CityLoyaltyChanged.Add( OnRefresh );

LuaEvents.CityPanelCulture_ToggleLoyalty.Add( OnToggleLoyaltyPanel );
LuaEvents.CityBannerManager_ShowEnemyCityOverview.Add( OnShowEnemyCityOverview );

Controls.TabStack:RegisterSizeChanged( OnTabStackSizeChanged );
end
Expand Down
28 changes: 15 additions & 13 deletions Additions/DedicationPopup.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
--[[
-- Created by Samuel Batista on Friday Apr 19 2017
-- Copyright (c) Firaxis Games
--]]
-- Copyright 2017-2018, Firaxis Games

include("InstanceManager");


-- ===========================================================================
-- CONSTANTS
-- ===========================================================================
Expand Down Expand Up @@ -67,7 +65,7 @@ function OnGameEraChanged(prevEraIndex:number, newEraIndex:number)
local selectionsAllowed:number = gameEras:GetPlayerNumAllowedCommemorations(localPlayerID);

if m_CommemorationInstanceManager.m_iAllocatedInstances > 0 and selectionsAllowed > 0 then
OnShow();
ShowPopup();
m_SelectedCommemorationTypes = {};
Controls.Confirm:SetDisabled(true);
Controls.CommemorationsStack:CalculateSize();
Expand Down Expand Up @@ -101,7 +99,7 @@ function OnGameEraChanged(prevEraIndex:number, newEraIndex:number)
Controls.HeroicFrameGlow:SetHide(true);
end
elseif m_CurrentEraIndex < 0 then
UI.DataError("Error in PrideCommemorationPopup: Invalid Previous Era.");
UI.DataError("DedicationPopup has an invalid current era index: "..tostring(m_CurrentEraIndex));
OnClose();
end

Expand Down Expand Up @@ -219,8 +217,8 @@ function OnConfirm()
end

-- ===========================================================================
function OnShow()
UIManager:QueuePopup(ContextPtr, PopupPriority.High);
function ShowPopup()
UIManager:QueuePopup(ContextPtr, PopupPriority.MediumHigh);
end

-- ===========================================================================
Expand All @@ -242,8 +240,8 @@ end
-- ===========================================================================
function OnShutdown()
LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "isVisible", not ContextPtr:IsHidden());
LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "prevEraIndex", m_PreviewEraIndex);
LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "nextEraIndex", m_CurrentEraIndex);
LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "m_PreviewEraIndex", m_PreviewEraIndex);
LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "m_CurrentEraIndex", m_CurrentEraIndex);
end

-- ===========================================================================
Expand All @@ -255,8 +253,12 @@ function OnGameDebugReturn(context:string, contextTable:table)
if contextTable["isVisible"] ~= nil then
ContextPtr:SetHide(not contextTable["isVisible"]);
end
if contextTable["prevEraIndex"] ~= nil and contextTable["nextEraIndex"] ~= nil then
OnGameEraChanged(contextTable["prevEraIndex"], contextTable["nextEraIndex"]);

m_PreviewEraIndex = contextTable["m_PreviewEraIndex"];
m_CurrentEraIndex = contextTable["m_CurrentEraIndex"];

if m_CurrentEraIndex >= 0 then
OnGameEraChanged(m_PreviewEraIndex, m_CurrentEraIndex);
end
end
end
Expand Down Expand Up @@ -288,6 +290,6 @@ function Initialize()

-- Lua Events
LuaEvents.GameDebug_Return.Add(OnGameDebugReturn);
LuaEvents.DedicationPopup_Show.Add(OnGameEraChanged);
LuaEvents.EraReviewPopup_MakeDedication.Add(OnGameEraChanged);
end
Initialize();
16 changes: 16 additions & 0 deletions Additions/DiplomacyActionView_AllianceRow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ function Refresh(selectedPlayerID:number)
if localPlayer:GetTeam() == selectedPlayer:GetTeam() then
relationshipString = "(" .. Locale.Lookup("LOC_WORLD_RANKINGS_TEAM", localPlayer:GetTeam()) .. ") " .. relationshipString;
end

if(localPlayerDiplomacy:IsPromiseMade(selectedPlayer:GetID(), PromiseTypes.DONT_SETTLE_NEAR_ME)) then
relationshipString = relationshipString .. "[NEWLINE]" .. Locale.Lookup("LOC_DIPLOACTION_KEEP_PROMISE_DONT_SETTLE_TOO_NEAR_NAME");
end
if(localPlayerDiplomacy:IsPromiseMade(selectedPlayer:GetID(), PromiseTypes.DONT_SPY_ON_ME)) then
relationshipString = relationshipString .. ",[NEWLINE]" .. Locale.Lookup("LOC_DIPLOACTION_KEEP_PROMISE_DONT_SPY_NAME") .. " ";
end
if(localPlayerDiplomacy:IsPromiseMade(selectedPlayer:GetID(), PromiseTypes.DONT_DIG_UP_MY_ARTIFACTS)) then
relationshipString = relationshipString .. ",[NEWLINE]" .. Locale.Lookup("LOC_DIPLOACTION_KEEP_PROMISE_DONT_DIG_ARTIFACTS_NAME") .. " ";
end
if(localPlayerDiplomacy:IsPromiseMade(selectedPlayer:GetID(), PromiseTypes.DONT_CONVERT_MY_CITIES)) then
relationshipString = relationshipString .. ",[NEWLINE]" .. Locale.Lookup("LOC_DIPLOACTION_KEEP_PROMISE_DONT_CONVERT_NAME") .. " ";
end

Controls.RelationshipText:SetText( relationshipString );

local localPlayerDiplomacy = localPlayer:GetDiplomacy();
Expand Down Expand Up @@ -90,6 +104,8 @@ function Refresh(selectedPlayerID:number)
-- Show alliance information if we have an alliance
local allianceType = localPlayerDiplomacy:GetAllianceType(selectedPlayerID);
if allianceType ~= -1 then
Controls.RelationshipText:SetToolTipString(Locale.Lookup("LOC_DIPLOACTION_EXPIRES_IN_X_TURNS", localPlayerDiplomacy:GetAllianceTurnsUntilExpiration(selectedPlayerID)));

-- Alliance Type
local iAllianceType = GameInfo.Alliances[allianceType];
Controls.AllianceTypeText:SetText(Locale.Lookup(iAllianceType.Name));
Expand Down
2 changes: 1 addition & 1 deletion Additions/DiplomacyActionView_EmergencyRow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ end
-- ===========================================================================
function AddEmergencyRowEntry( crisis:table )
local entryInst:table = ms_EmergencyRowEntryIM:GetInstance( Controls.EmergencyStack );
entryInst.EmergencyName:SetText(crisis.NameText);
entryInst.EmergencyName:LocalizeAndSetText(crisis.NameText);
entryInst.EmergencyRowEntryTop:SetToolTipString(crisis.DescriptionText);
end

Expand Down
2 changes: 1 addition & 1 deletion Additions/DiplomacyActionView_EmergencyTab.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ end
-- ===========================================================================
function AddEmergencyTabEntry( crisis:table, parentControl:table )
local entryInst:table = ms_EmergencyTabEntryIM:GetInstance( parentControl );
entryInst.EmergencyNameLabel:SetText(crisis.NameText);
entryInst.EmergencyNameLabel:LocalizeAndSetText(crisis.NameText);
entryInst.EmergencyGoalsLabel:SetText(crisis.GoalDescription);

-- If TurnsLeft < 0 emergency is completed so label it as such
Expand Down
4 changes: 2 additions & 2 deletions Additions/DiplomacyActionView_EmergencyTab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<Image Anchor="L,C" Offset="4,0" Size="32,32" IconSize="32" Icon="ICON_EMERGENCY"/>
<Stack StackGrowth="Down" StackPadding="4">
<Label ID="EmergencyNameLabel" Style="FontNormal16" Offset="44,4"/>
<Label ID="EmergencyGoalsLabel" Style="FontNormal14" Offset="44,0" Color0="164,164,164,255" WrapWidth="385"/>
<Label ID="EmergencyGoalsLabel" Style="FontNormal14" Offset="44,0" Color0="164,164,164,255" WrapWidth="355"/>
</Stack>
<Stack Anchor="R,C" Offset="6,0" StackGrowth="Right">
<Stack Anchor="R,t" Offset="6,4" StackGrowth="Right">
<Label ID="EmergencyTurnsIcon" Style="FontNormal16" String="[ICON_TURN]"/>
<Label ID="EmergencyTurnsLabel" Style="FontNormal16"/>
</Stack>
Expand Down
4 changes: 2 additions & 2 deletions Additions/DisloyalCityChooser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ local g_pSelectedCity;

function OnKeepButton()
local tParameters = {};
tParameters[UnitOperationTypes.PARAM_FLAGS] = 2;
tParameters[UnitOperationTypes.PARAM_FLAGS] = CityDestroyDirectives.KEEP;
if (CityManager.CanStartCommand( g_pSelectedCity, CityCommandTypes.DESTROY, tParameters)) then
CityManager.RequestCommand( g_pSelectedCity, CityCommandTypes.DESTROY, tParameters);
end
OnClose();
end
function OnRejectButton()
local tParameters = {};
tParameters[UnitOperationTypes.PARAM_FLAGS] = 4;
tParameters[UnitOperationTypes.PARAM_FLAGS] = CityDestroyDirectives.REJECT;
if (CityManager.CanStartCommand( g_pSelectedCity, CityCommandTypes.DESTROY, tParameters)) then
UI.DeselectAllCities();
CityManager.RequestCommand( g_pSelectedCity, CityCommandTypes.DESTROY, tParameters);
Expand Down
Loading

0 comments on commit efd507f

Please sign in to comment.