forked from chaorace/Civ6-UIFiles
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
146 changed files
with
22,206 additions
and
663 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
include("InstanceManager"); | ||
include("SupportFunctions"); | ||
include("EspionageViewManager"); | ||
|
||
local m_kPowerBreakdownIM:table = InstanceManager:new( "PowerLineInstance", "Top"); | ||
|
||
local m_kEspionageViewManager = EspionageViewManager:CreateManager(); | ||
|
||
-- =========================================================================== | ||
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 | ||
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 pCityPower = pCity:GetPower(); | ||
if pCityPower == nil then | ||
return; | ||
end | ||
|
||
-- Status | ||
local freePower:number = pCityPower:GetFreePower(); | ||
local temporaryPower:number = pCityPower:GetTemporaryPower(); | ||
local currentPower:number = freePower + temporaryPower; | ||
local requiredPower:number = pCityPower:GetRequiredPower(); | ||
local powerStatusName:string = "LOC_POWER_STATUS_POWERED_NAME"; | ||
local powerStatusDescription:string = "LOC_POWER_STATUS_POWERED_DESCRIPTION"; | ||
if (requiredPower == 0) then | ||
powerStatusName = "LOC_POWER_STATUS_NO_POWER_NEEDED_NAME"; | ||
powerStatusDescription = "LOC_POWER_STATUS_NO_POWER_NEEDED_DESCRIPTION"; | ||
elseif (not pCityPower:IsFullyPowered()) then | ||
powerStatusName = "LOC_POWER_STATUS_UNPOWERED_NAME"; | ||
powerStatusDescription = "LOC_POWER_STATUS_UNPOWERED_DESCRIPTION"; | ||
elseif (pCityPower:IsFullyPoweredByActiveProject()) then | ||
currentPower = requiredPower; | ||
end | ||
Controls.ConsumingPowerLabel:SetText(Locale.Lookup("LOC_POWER_PANEL_CONSUMED", Round(currentPower, 1))); | ||
Controls.RequiredPowerLabel:SetText(Locale.Lookup("LOC_POWER_PANEL_REQUIRED", Round(requiredPower, 1))); | ||
Controls.PowerStatusNameLabel:SetText(Locale.Lookup(powerStatusName)); | ||
|
||
-- Status Effects | ||
Controls.PowerStatusDescriptionLabel:SetText(Locale.Lookup(powerStatusDescription)); | ||
Controls.PowerStatusDescriptionBox:SetSizeY(Controls.PowerStatusDescriptionLabel:GetSizeY() + 15); | ||
|
||
-- Breakdown | ||
m_kPowerBreakdownIM:ResetInstances(); | ||
-----Consumed | ||
local temporaryPowerBreakdown:table = pCityPower:GetTemporaryPowerSources(); | ||
local freePowerBreakdown:table = pCityPower:GetFreePowerSources(); | ||
local somethingToShow:boolean = false; | ||
for _,innerTable in ipairs(temporaryPowerBreakdown) do | ||
somethingToShow = true; | ||
local scoreSource, scoreValue = next(innerTable); | ||
local lineInstance = m_kPowerBreakdownIM:GetInstance(Controls.ConsumedPowerBreakdownStack); | ||
lineInstance.LineTitle:SetText(scoreSource); | ||
lineInstance.LineValue:SetText("[ICON_Power]" .. Round(scoreValue, 1)); | ||
end | ||
for _,innerTable in ipairs(freePowerBreakdown) do | ||
somethingToShow = true; | ||
local scoreSource, scoreValue = next(innerTable); | ||
local lineInstance = m_kPowerBreakdownIM:GetInstance(Controls.ConsumedPowerBreakdownStack); | ||
lineInstance.LineTitle:SetText(scoreSource); | ||
lineInstance.LineValue:SetText("[ICON_Power]" .. Round(scoreValue, 1)); | ||
end | ||
Controls.ConsumedPowerBreakdownStack:CalculateSize(); | ||
Controls.ConsumedBreakdownBox:SetSizeY(Controls.ConsumedPowerBreakdownStack:GetSizeY() + 15); | ||
Controls.ConsumedBreakdownBox:SetHide(not somethingToShow); | ||
Controls.ConsumedTitle:SetHide(not somethingToShow); | ||
-----Required | ||
local requiredPowerBreakdown:table = pCityPower:GetRequiredPowerSources(); | ||
local somethingToShow:boolean = false; | ||
for _,innerTable in ipairs(requiredPowerBreakdown) do | ||
somethingToShow = true; | ||
local scoreSource, scoreValue = next(innerTable); | ||
local lineInstance = m_kPowerBreakdownIM:GetInstance(Controls.RequiredPowerBreakdownStack); | ||
lineInstance.LineTitle:SetText(scoreSource); | ||
lineInstance.LineValue:SetText("[ICON_Power]" .. Round(scoreValue, 1)); | ||
end | ||
Controls.RequiredPowerBreakdownStack:CalculateSize(); | ||
Controls.RequiredBreakdownBox:SetSizeY(Controls.RequiredPowerBreakdownStack:GetSizeY() + 15); | ||
Controls.RequiredBreakdownBox:SetHide(not somethingToShow); | ||
Controls.RequiredTitle:SetHide(not somethingToShow); | ||
-----Generated | ||
local generatedPowerBreakdown:table = pCityPower:GetGeneratedPowerSources(); | ||
local somethingToShow:boolean = false; | ||
for _,innerTable in ipairs(generatedPowerBreakdown) do | ||
somethingToShow = true; | ||
local scoreSource, scoreValue = next(innerTable); | ||
local lineInstance = m_kPowerBreakdownIM:GetInstance(Controls.GeneratedPowerBreakdownStack); | ||
lineInstance.LineTitle:SetText(scoreSource); | ||
lineInstance.LineValue:SetText("[ICON_Power]" .. Round(scoreValue, 1)); | ||
lineInstance.LineValue:SetColorByName("White"); | ||
end | ||
Controls.GeneratedPowerBreakdownStack:CalculateSize(); | ||
Controls.GeneratedBreakdownBox:SetSizeY(Controls.GeneratedPowerBreakdownStack:GetSizeY() + 15); | ||
Controls.GeneratedBreakdownBox:SetHide(not somethingToShow); | ||
Controls.GeneratedTitle:SetHide(not somethingToShow); | ||
|
||
-- Advisor | ||
if m_kEspionageViewManager:IsEspionageView() then | ||
Controls.PowerAdvisor:SetHide(true); | ||
else | ||
Controls.PowerAdvice:SetText(pCity:GetPowerAdvice()); | ||
Controls.PowerAdvisor:SetHide(false); | ||
end | ||
|
||
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 | ||
ContextPtr:SetSizeX(Controls.TabStack:GetSizeX()); | ||
ContextPtr:SetSizeY(Controls.TabStack:GetSizeY()); | ||
end | ||
|
||
-- =========================================================================== | ||
function OnTogglePowerPanel(pCity:table) | ||
if (pCity ~= nil) then | ||
UI.LookAtPlot(pCity:GetX(), pCity:GetY()); | ||
UI.SelectCity(pCity); | ||
LuaEvents.CityPanel_ToggleOverviewPower(); | ||
end | ||
end | ||
|
||
-- =========================================================================== | ||
function Initialize() | ||
LuaEvents.CityPanelTabRefresh.Add(OnRefresh); | ||
Events.CitySelectionChanged.Add( OnRefresh ); | ||
|
||
LuaEvents.CityBannerManager_ShowEnemyCityOverview.Add( OnShowEnemyCityOverview ); | ||
|
||
Controls.TabStack:RegisterSizeChanged( OnTabStackSizeChanged ); | ||
end | ||
Initialize(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Context> | ||
<Stack ID="TabStack" StackPadding="8"> | ||
<!-- Header --> | ||
<Grid ID="HeaderGrid" Anchor="L,T" Size="parent,24" Style="DivHeader"> | ||
<Container Size="parent,24"> | ||
<Image Texture="Controls_Gradient_HalfRadial" Size="parent, 120" FlipY="1" Anchor="C,T" Color="72,103,130,255"/> | ||
</Container> | ||
<Label Anchor="C,C" Offset="5,0" Style="CityPanelSubPanelTitle" String="LOC_CITY_PANEL_POWER_HEADER" /> | ||
</Grid> | ||
|
||
<!-- Power Status --> | ||
<Stack Offset="20,0" StackGrowth="Right"> | ||
<Stack Anchor="C,T" StackGrowth="Right" StackPadding="10"> | ||
<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 Anchor="C,T" Style="CityPanelText" String="LOC_POWER_PANEL_OF"/> | ||
<Label ID="RequiredPowerLabel" Anchor="C,T" Style="CityPanelText"/> | ||
</Stack> | ||
</Stack> | ||
</Grid> | ||
<Grid Size="125,55" Style="CityPanelSubPanelContainer"> | ||
<Image Anchor="L,C" AnchorSide="O,I" Texture="Controls_ThereforeArrow" Offset="-10,0"/> | ||
<Stack Anchor="C,C" StackGrowth="Right" StackPadding="6"> | ||
<Stack StackPadding="2"> | ||
<Label Anchor="C,T" Style="FontNormal16" String="LOC_POWER_PANEL_STATUS"/> | ||
<Label ID="PowerStatusNameLabel" Anchor="C,T" Style="CityPanelText" WrapWidth="120"/> | ||
</Stack> | ||
</Stack> | ||
</Grid> | ||
</Stack> | ||
</Stack> | ||
|
||
<!-- Powered Status Effects --> | ||
<Grid ID="PowerStatusDescriptionBox" Texture="CityPanel_StatPanelSubContainer" SliceCorner="7,7" SliceSize="1,1" SliceTextureSize="16,16" InnerPadding="4,2" Anchor="C,T" Size="260,55"> | ||
<Label ID="PowerStatusDescriptionLabel" Offset="4,0" Anchor="C,C" Style="CityPanelTextSmall" WrapWidth="200"/> | ||
</Grid> | ||
|
||
|
||
<!-- Breakdown --> | ||
<Stack Padding="4" Anchor="C,T" Offset="0,6"> | ||
<Grid ID="ConsumedTitle" Anchor="C,T" Size="parent,24" Style="DivHeader"> | ||
<Container Size="parent,24"> | ||
<Image Texture="Controls_Gradient_HalfRadial" Size="parent,120" FlipY="1" Anchor="C,T" Color="72,103,130,255"/> | ||
</Container> | ||
<Label Anchor="C,C" Offset="5,0" Style="CityPanelSubPanelTitle" FontSize="14" String="LOC_POWER_PANEL_CONSUMED_POWER" /> | ||
</Grid> | ||
<Grid ID="ConsumedBreakdownBox" Anchor="C,T" Size="260,230" Style="CityPanelSubPanelContainer"> | ||
<Stack ID="ConsumedPowerBreakdownStack" Offset="5,10" Anchor="L,T" Padding="5"/> | ||
</Grid> | ||
<Grid ID="RequiredTitle" Anchor="C,T" Size="parent,24" Style="DivHeader"> | ||
<Container Size="parent,24"> | ||
<Image Texture="Controls_Gradient_HalfRadial" Size="parent,120" FlipY="1" Anchor="C,T" Color="72,103,130,255"/> | ||
</Container> | ||
<Label Anchor="C,C" Offset="5,0" Style="CityPanelSubPanelTitle" FontSize="14" String="LOC_POWER_PANEL_REQUIRED_POWER" /> | ||
</Grid> | ||
<Grid ID="RequiredBreakdownBox" Anchor="C,T" Size="260,230" Style="CityPanelSubPanelContainer"> | ||
<Stack ID="RequiredPowerBreakdownStack" Offset="5,10" Anchor="L,T" Padding="5"/> | ||
</Grid> | ||
<Grid ID="GeneratedTitle" Anchor="C,T" Size="parent,24" Style="DivHeader"> | ||
<Container Size="parent,24"> | ||
<Image Texture="Controls_Gradient_HalfRadial" Size="parent,120" FlipY="1" Anchor="C,T" Color="72,103,130,255"/> | ||
</Container> | ||
<Label Anchor="C,C" Offset="5,0" Style="CityPanelSubPanelTitle" FontSize="14" String="LOC_POWER_PANEL_GENERATED_POWER" /> | ||
</Grid> | ||
<Grid ID="GeneratedBreakdownBox" Anchor="C,T" Size="260,230" Style="CityPanelSubPanelContainer"> | ||
<Stack ID="GeneratedPowerBreakdownStack" Offset="5,10" Anchor="L,T" Padding="5"/> | ||
</Grid> | ||
</Stack> | ||
|
||
<!-- Advisor --> | ||
<Container ID="PowerAdvisor" Offset="15,0" Size="parent-29,auto" > | ||
<Image Anchor="R,T" Size="64,64" Texture="Advisors64"/> | ||
<Grid Offset="3,0" Size="parent-64,auto" Style="AdvisorWordBubble" Color="255,255,255,50" InnerPadding="5,15"> | ||
<Label ID="PowerAdvice" Anchor="C,C" Offset="-20,0" WrapWidth="parent-40" Style="CityPanelTextSmall" String="LOC_HUD_CITY_ADVISOR_TRY_IMPROVING" /> | ||
</Grid> | ||
</Container> | ||
|
||
<!-- Spacer --> | ||
<Container Size="5,2"/> | ||
</Stack> | ||
|
||
<!-- Population Line Item Instance --> | ||
<Instance Name="PowerLineInstance"> | ||
<Grid ID="Top" Size="250,auto" Texture="CityPanel_StatPanelLineItem" SliceCorner="7,7" SliceSize="1,1" SliceTextureSize="16,16" MinSize="16,16"> | ||
<Label ID="LineTitle" Anchor="L,T" Offset="0,2" Style="CityPanelTextSmall" WrapWidth="parent-20"/> | ||
<Label ID="LineValue" Anchor="R,T" Offset="0,2" Style="CityPanelTextSmall"/> | ||
</Grid> | ||
</Instance> | ||
|
||
</Context> |
Oops, something went wrong.