Skip to content

Commit

Permalink
Antarctic Late Summer update (1.0.0.314)
Browse files Browse the repository at this point in the history
  • Loading branch information
Azurency committed Apr 3, 2019
1 parent 277a1a7 commit daf3a41
Show file tree
Hide file tree
Showing 49 changed files with 740 additions and 424 deletions.
14 changes: 7 additions & 7 deletions Additions/CityPanelCulture.lua
Expand Up @@ -15,12 +15,6 @@ function OnRefresh()
if ContextPtr:IsHidden() then
return;
end

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

local pCity = UI.GetHeadSelectedCity();
if (pCity == nil) then
Expand All @@ -32,6 +26,12 @@ function OnRefresh()
m_kEspionageViewManager:ClearEspionageViewCity();
end

local playerID = pCity:GetOwner();
local pPlayer = Players[playerID];
if (pPlayer == nil) then
return;
end

if pPlayer == nil or pCity == nil then
return;
end
Expand Down Expand Up @@ -149,7 +149,7 @@ function OnRefresh()
totalLineInstance.LineValue:SetText(Locale.Lookup(pCulturalIdentity:GetLoyaltyPerTurnStatus()) .. " " .. Round(pCulturalIdentity:GetLoyaltyPerTurn(), 1));
Controls.IdentityBreakdownStack:CalculateSize();
Controls.BreakdownBox:SetSizeY(Controls.IdentityBreakdownStack:GetSizeY() + 15);
totalLineInstance.Top:SetColor(RGBAValuesToABGRHex(.3, .3, .3, .85));
totalLineInstance.Top:SetColor(UI.GetColorValue(.3, .3, .3, .85));
-- Identity Totals
if (loyaltyLevel < 3) then
Expand Down
2 changes: 1 addition & 1 deletion Additions/CityPanelCulture.xml
Expand Up @@ -41,7 +41,7 @@
<Stack Anchor="C,C" StackGrowth="Right" StackPadding="6">
<Stack StackPadding="2">
<Label Anchor="C,T" Style="FontNormal16" String="LOC_CULTURAL_IDENTITY_STATUS"/>
<Label ID="LoyaltyStatus" Anchor="C,T" Style="CityPanelText" WrapWidth="120"/>
<Label ID="LoyaltyStatus" Anchor="C,T" Align="Center" Style="CityPanelText" WrapWidth="115"/>
</Stack>
</Stack>
</Grid>
Expand Down
12 changes: 6 additions & 6 deletions Additions/CityPanelPower.lua
Expand Up @@ -12,12 +12,6 @@ function OnRefresh()
return;
end

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();
Expand All @@ -28,6 +22,12 @@ function OnRefresh()
m_kEspionageViewManager:ClearEspionageViewCity();
end

local playerID = pCity:GetOwner();
local pPlayer = Players[playerID];
if (pPlayer == nil) then
return;
end

if pPlayer == nil or pCity == nil then
return;
end
Expand Down
4 changes: 2 additions & 2 deletions Additions/CityPanelPower.xml
Expand Up @@ -15,9 +15,9 @@
<Grid Size="125,55" Style="CityPanelSubPanelContainer">
<Stack Anchor="C,C" StackGrowth="Right" StackPadding="6">
<Stack StackPadding="2">
<Label ID="ConsumingPowerLabel" Anchor="C,T" Style="CityPanelText"/>
<Label ID="ConsumingPowerLabel" Anchor="L,T" Style="CityPanelText"/>
<Label Anchor="C,T" Style="CityPanelText" String="LOC_POWER_PANEL_OF"/>
<Label ID="RequiredPowerLabel" Anchor="C,T" Style="CityPanelText"/>
<Label ID="RequiredPowerLabel" Anchor="L,T" Style="CityPanelText"/>
</Stack>
</Stack>
</Grid>
Expand Down
92 changes: 55 additions & 37 deletions Additions/ClimateScreen.lua
@@ -1,5 +1,5 @@
-- Copyright 2018, Firaxis Games

-- ===========================================================================
include("InstanceManager");
include("SupportFunctions"); --Round
Expand Down Expand Up @@ -131,7 +131,7 @@ function GetWorstCO2PlayerID()

if CO2Total > 0 then
for _,pPlayer in ipairs(PlayerManager.GetAliveMajors()) do
local CO2:number = GameClimate.GetPlayerCO2Footprint( pPlayer:GetID() );
local CO2:number = GameClimate.GetPlayerCO2Footprint( pPlayer:GetID(), false );
if CO2 > worstCO2 then
CO2TopPlayer = pPlayer:GetID();
worstCO2 = CO2;
Expand Down Expand Up @@ -316,6 +316,14 @@ function RefreshCurrentEvent()
-- Buff/Debuff
local bAnyBuff:boolean = false;

if kCurrentEvent.FertilityAdded ~= nil and kCurrentEvent.FertilityAdded < 0 then
Controls.PlotLostFertileLabel:SetText(math.abs(kCurrentEvent.FertilityAdded));
Controls.PlotLostFertileContainer:SetHide(false);
bAnyBuff = true;
else
Controls.PlotLostFertileContainer:SetHide(true);
end

if kCurrentEvent.FertilityAdded ~= nil and kCurrentEvent.FertilityAdded > 0 then
Controls.PlotFertileLabel:SetText(kCurrentEvent.FertilityAdded);
Controls.PlotFertileContainer:SetHide(false);
Expand Down Expand Up @@ -378,7 +386,7 @@ function TabSelectOverview()
end

local CO2Total :number = GameClimate.GetTotalCO2Footprint();
local CO2Player :number = GameClimate.GetPlayerCO2Footprint( m_playerID );
local CO2Player :number = GameClimate.GetPlayerCO2Footprint( m_playerID, false );
local CO2TopPlayer :number = GetWorstCO2PlayerID();
local CO2Modifier :number = GameClimate.GetCO2FootprintModifier();

Expand Down Expand Up @@ -537,7 +545,7 @@ function BuildPieChart( uiHolder:table, sliceIM:table, kSliceAmounts:table, kCol

-- If colors were not passed in, generate a table.
if kColors == nil or table.count(kColors)==0 then
kColors = { 0xff000099, 0xff008888, 0xff009900, 0xff888800, 0xff990000, 0xff880088 };
kColors = { UI.GetColorValueFromHexLiteral(0xff000099), UI.GetColorValueFromHexLiteral(0xff008888), UI.GetColorValueFromHexLiteral(0xff009900), UI.GetColorValueFromHexLiteral(0xff888800), UI.GetColorValueFromHexLiteral(0xff990000), UI.GetColorValueFromHexLiteral(0xff880088) };
end
local maxColors:number = #kColors;

Expand Down Expand Up @@ -581,7 +589,7 @@ function TabSelectCO2Levels()
RealizePlayerCO2();

local CO2Total :number = GameClimate.GetTotalCO2Footprint();
local CO2Player :number = GameClimate.GetPlayerCO2Footprint(m_playerID);
local CO2Player :number = GameClimate.GetPlayerCO2Footprint(m_playerID, false );
local CO2Modifier :number = GameClimate.GetCO2FootprintModifier();

local sGlobalTotal:string = "";
Expand Down Expand Up @@ -670,9 +678,17 @@ function CreateEventInstance( kEvent:table, kEventDef:table, iTurn:number )
-- Effects
if kEvent.FertilityAdded > 0 then
kInstance.FertilizedTilesIcon:SetHide(false);
kInstance.LosingFertilizedTilesIcon:SetHide(true);
kInstance.FertilizedTiles:SetText(kEvent.FertilityAdded);
kInstance.FertilizedContainer:SetToolTipString(Locale.Lookup("LOC_CLIMATE_FERTILIZED_TILES"));
elseif kEvent.FertilityAdded < 0 then
kInstance.FertilizedTilesIcon:SetHide(true);
kInstance.LosingFertilizedTilesIcon:SetHide(false);
kInstance.FertilizedTiles:SetText(math.abs(kEvent.FertilityAdded));
kInstance.FertilizedContainer:SetToolTipString(Locale.Lookup("LOC_CLIMATE_LOST_FERTILIZED_TILES"));
else
kInstance.FertilizedTilesIcon:SetHide(true);
kInstance.LosingFertilizedTilesIcon:SetHide(true);
kInstance.FertilizedTiles:SetText("");
end

Expand Down Expand Up @@ -723,32 +739,30 @@ function RealizePlayerCO2()
m_kYourCO2IM:ResetInstances();

for kResourceInfo in GameInfo.Resources() do
local resourceIndex :number = kResourceInfo.Index;
if pResources:HasResource(resourceIndex) or pResources:HasExportedResource(resourceIndex) then

-- Player has the resource, but does the resource contribute to CO2?
local kConsumption:table = GameInfo.Resource_Consumption[kResourceInfo.ResourceType];
if kConsumption ~= nil and kConsumption.CO2perkWh ~= nil and kConsumption.CO2perkWh > 0 then
-- Does the resource contribute to CO2?
local kConsumption:table = GameInfo.Resource_Consumption[kResourceInfo.ResourceType];
if kConsumption ~= nil and kConsumption.CO2perkWh ~= nil and kConsumption.CO2perkWh > 0 then

-- Is the player using the resource?
local amount :number = GameClimate.GetPlayerResourceCO2Footprint( m_playerID, kResourceInfo.Index );
if amount > 0 then
-- Is the player using the resource?
local amount :number = GameClimate.GetPlayerResourceCO2Footprint( m_playerID, kResourceInfo.Index, false );
if amount > 0 then

local uiResource :table = m_kYourCO2IM:GetInstance();
local resourceName :string = Locale.Lookup( kResourceInfo.Name );
local co2Amount :number = amount;
local color :number = kColors[colorIndex];
local uiResource :table = m_kYourCO2IM:GetInstance();
local co2Amount :number = amount;
local color :number = kColors[colorIndex];
local amountLastTurn :number = GameClimate.GetPlayerResourceCO2Footprint( m_playerID, kResourceInfo.Index, true );
local resourceLastTurn :number = GameClimate.GetPlayerResourceConsumption( m_playerID, kResourceInfo.Index, true );

uiResource.Amount:SetText( co2Amount );
uiResource.Icon:SetIcon("ICON_" .. kResourceInfo.ResourceType);
uiResource.Palette:SetColor( color );
uiResource.Icon:SetToolTipString( resourceName );
uiResource.Amount:SetText( co2Amount );
uiResource.Icon:SetIcon("ICON_" .. kResourceInfo.ResourceType);
uiResource.Palette:SetColor( color );
uiResource.Top:SetToolTipString( Locale.Lookup("LOC_CLIMATE_RESOURCE_CONSUMED_LAST_TURN", resourceLastTurn, kResourceInfo.Name, amountLastTurn) );

table.insert( kResourceUseAmounts, amount);
total = total + co2Amount;
table.insert( kResourceUseAmounts, amount);
total = total + co2Amount;

colorIndex = (colorIndex + 1) % maxColors;
end
colorIndex = (colorIndex + 1) % maxColors;
end
end
end
Expand All @@ -757,10 +771,6 @@ function RealizePlayerCO2()
for i,amount in ipairs( kResourceUseAmounts ) do
table.insert(kSliceAmounts, amount/total );
end

-- TODO remove, ??TRON debug data
-- kSliceAmounts = { 0.02, 0.03, 0.2, 0.05, 0.1, 0.07, 0.13, 0.21, 0.04, 0.15 };
-- kSliceAmounts ={ 0.02, 0.03, 0.2, 0.05, 0.1 };

BuildPieChart( Controls.TotalContributionsPie, m_kSliceIM, kSliceAmounts, kColors );
end
Expand Down Expand Up @@ -789,9 +799,11 @@ function TabCO2ByCiviliation()
for _, pPlayer in ipairs(pPlayers) do

local playerID :number = pPlayer:GetID();
local CO2FootprintNum :number = GameClimate.GetPlayerCO2Footprint( playerID );
local CO2FootprintNum :number = GameClimate.GetPlayerCO2Footprint( playerID, false );

total = total + CO2FootprintNum;
if CO2FootprintNum > 0 then
total = total + CO2FootprintNum;
end

-- Only chart a slice if player has been met.
if pPlayerDiplomacy:HasMet(playerID) or m_playerID == playerID then
Expand Down Expand Up @@ -852,16 +864,15 @@ function TabCO2ByResource()

-- For all the resources in the game
for kResourceInfo in GameInfo.Resources() do
local resourceIndex :number = kResourceInfo.Index;


-- Does the resource contribute to CO2?
local kConsumption:table = GameInfo.Resource_Consumption[kResourceInfo.ResourceType];
if kConsumption ~= nil and kConsumption.CO2perkWh ~= nil and kConsumption.CO2perkWh > 0 then

-- Loop through all players and sum up the CO2
local amount :number = 0;
for _,pPlayer in ipairs(PlayerManager.GetAliveMajors()) do
amount = amount + GameClimate.GetPlayerResourceCO2Footprint( pPlayer:GetID(), kResourceInfo.Index );
amount = amount + GameClimate.GetPlayerResourceCO2Footprint( pPlayer:GetID(), kResourceInfo.Index, false );
end

-- If more than 0, add a UI element.
Expand Down Expand Up @@ -947,7 +958,7 @@ function UpdatePhaseBar( phase:number, realismAmount:number, globalTemp:number )
if (phase > 0) then
for i=1,phase,1 do
local uiSegment:table = m_kBarSegments[i];
uiSegment.Progress:SetColor(0xFFFFFFFF);
uiSegment.Progress:SetColor(UI.GetColorValue("COLOR_WHITE"));
uiSegment.Pip:SetTexture("Climate_PhaseMeterPip_On");
end
end
Expand All @@ -969,7 +980,7 @@ function InitPhaseSegment( segmentNum:number )
uiSegment.Name:SetText(Locale.ToRomanNumeral(segmentNum));
m_kBarSegments[segmentNum] = uiSegment;
uiSegment.Progress:SetTexture("Climate_PhaseMeter_" .. segmentNum);
uiSegment.Progress:SetColor(0x00FFFFFF);
uiSegment.Progress:SetColor(UI.GetColorValue("COLOR_CLEAR"));
uiSegment.Pip:SetTexture("Climate_PhaseMeterPip_Off");

UpdatePhaseTooltips(segmentNum);
Expand All @@ -987,13 +998,16 @@ function UpdatePhaseTooltips( segmentNum:number )
local szPhaseType = kEventDef.RandomEventType;
local iPoints = kEventDef.ClimateChangePoints;
local szAtOrAboveString = "";
local szLongDescription = "";

for row in GameInfo.CoastalLowlands() do
if (row.FloodedEvent == szPhaseType) then
szAtOrAboveString = Locale.Lookup("LOC_CLIMATE_TILES_AT_OR_BELOW_FLOOD_TOOLTIP", row.Name);
szLongDescription = GameInfo.RandomEvents[row.FloodedEvent].LongDescription;
break;
elseif (row.SubmergedEvent == szPhaseType) then
szAtOrAboveString = Locale.Lookup("LOC_CLIMATE_TILES_AT_OR_BELOW_SUBMERGE_TOOLTIP", row.Name);
szLongDescription = GameInfo.RandomEvents[row.SubmergedEvent].LongDescription;
break;
end
end
Expand All @@ -1012,6 +1026,10 @@ function UpdatePhaseTooltips( segmentNum:number )
.."[NEWLINE]"
.."[NEWLINE]"..Locale.Lookup("LOC_CLIMATE_POLAR_ICE_MELT_TOOLTIP", kEventDef.IceLoss);

if (szLongDescription ~= nil and szLongDescription ~= "") then
tooltip = tooltip .. "[NEWLINE][NEWLINE]" .. Locale.Lookup(szLongDescription);
end

m_kBarSegments[segmentNum].Progress:SetToolTipString( tooltip );
end

Expand Down Expand Up @@ -1041,7 +1059,7 @@ end
function LateInitialize()

-- Tab setup and setting of default tab.
m_tabs = CreateTabs( Controls.TabContainer, 42, 34, 0xFF331D05 );
m_tabs = CreateTabs( Controls.TabContainer, 42, 34, UI.GetColorValueFromHexLiteral(0xFF331D05) );
m_tabs.AddTab( Controls.ButtonOverview, TabSelectOverview );
m_tabs.AddTab( Controls.ButtonCO2Levels, TabSelectCO2Levels );
m_tabs.AddTab( Controls.ButtonEventHistory, TabSelectEventHistory );
Expand Down
7 changes: 6 additions & 1 deletion Additions/ClimateScreen.xml
Expand Up @@ -93,8 +93,9 @@
</Container>
<Box Size="2,parent" Color="0,0,0,40"/>
<!--Effects-->
<Container Size="70,parent" ToolTip="LOC_CLIMATE_FERTILIZED_TILES">
<Container ID="FertilizedContainer" Size="70,parent" ToolTip="LOC_CLIMATE_FERTILIZED_TILES">
<Image ID="FertilizedTilesIcon" Size="22,22" Offset="8,0" Anchor="L,C" Texture="ClimateHex_Buffed"/>
<Image ID="LosingFertilizedTilesIcon" Size="22,22" Offset="8,0" Anchor="L,C" Texture="ClimateHex_NotFertile"/>
<Label ID="FertilizedTiles" Offset="14,0" Anchor="C,C" Align="Center" WrapWidth="parent" Style="FontFlair20"/>
</Container>
<Box Size="2,parent" Color="0,0,0,40"/>
Expand Down Expand Up @@ -309,6 +310,10 @@
<Label ID="WeatherEffect" Anchor="C,T" Style="WorldClimateText" Align="Center" WrapWidth="300"/>
<Grid Anchor="C,T" Size="auto,auto" Texture="Climate_ImpactSlot" SliceCorner="11,11" SliceSize="2,2">
<Stack ID="BuffStack" Anchor="C,C" StackGrowth="Right" StackPadding="4">
<Container ID="PlotLostFertileContainer" Size="40,26" ToolTip="LOC_CLIMATE_LOST_FERTILIZED_TILES">
<Image Size="22,22" Anchor="L,C" Texture="ClimateHex_NotFertile"/>
<Label ID="PlotLostFertileLabel" Anchor="C,C" Offset="8,0" Style="FontNormal16" String="0"/>
</Container>
<Container ID="PlotFertileContainer" Size="40,26" ToolTip="LOC_CLIMATE_FERTILIZED_TILES">
<Image Size="22,22" Anchor="L,C" Texture="ClimateHex_Buffed"/>
<Label ID="PlotFertileLabel" Anchor="C,C" Offset="8,0" Style="FontNormal16" String="0"/>
Expand Down

0 comments on commit daf3a41

Please sign in to comment.