Skip to content

Commit

Permalink
Fix city yields not showing int the cityview
Browse files Browse the repository at this point in the history
Fixes #402
  • Loading branch information
Azurency committed May 13, 2019
1 parent 3298de5 commit 36249e2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
13 changes: 7 additions & 6 deletions Assets/Expansion1/CityBanners/citybannermanager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ local CQUI_SmartWorkIconAlpha = .45;
local g_smartbanner = true;

local CQUI_CityYields : number = UILens.CreateLensLayerHash("City_Yields");
local CQUI_CitizenManagement : number = UILens.CreateLensLayerHash("Citizen_Management");

function CQUI_OnSettingsInitialized()
CQUI_ShowYieldsOnCityHover = GameConfiguration.GetValue("CQUI_ShowYieldsOnCityHover");
Expand Down Expand Up @@ -270,7 +271,7 @@ function CQUI_OnBannerMouseOver(playerID: number, cityID: number)
-- Astog: Fix for lens being shown when other lenses are on.
-- Astog: Don't show this lens if any unit is selected.
-- This prevents the need to check if every lens is on or not, like builder, religious lens.
if CQUI_ShowCityManageAreaOnCityHover and not UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT)
if CQUI_ShowCityManageAreaOnCityHover and not UILens.IsLayerOn(CQUI_CitizenManagement)
and UI.GetInterfaceMode() == InterfaceModeTypes.SELECTION
and UI.GetHeadSelectedUnit() == nil then
LuaEvents.CQUI_ShowCitizenManagement(cityID);
Expand Down Expand Up @@ -304,7 +305,7 @@ function CQUI_OnBannerMouseOver(playerID: number, cityID: number)
local yields :table = {};
local yieldsIndex :table = {};

if (tPlots ~= nil and table.count(tPlots) ~= 0) and UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT) == false then
if (tPlots ~= nil and table.count(tPlots) ~= 0) and UILens.IsLayerOn(CQUI_CitizenManagement) == false then

CQUI_yieldsOn = UserConfiguration.ShowMapYield();

Expand Down Expand Up @@ -356,7 +357,7 @@ function CQUI_OnBannerMouseOver(playerID: number, cityID: number)

tPlots = tResults[CityCommandResults.PLOTS];

if (tPlots ~= nil and table.count(tPlots) ~= 0) and UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT) == false then
if (tPlots ~= nil and table.count(tPlots) ~= 0) and UILens.IsLayerOn(CQUI_CitizenManagement) == false then

for i,plotId in pairs(tPlots) do
local kPlot :table = Map.GetPlotByIndex(plotId);
Expand All @@ -375,11 +376,11 @@ function CQUI_OnBannerMouseOver(playerID: number, cityID: number)

local plotCount = Map.GetPlotCount();

if (CQUI_yieldsOn == false and not UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT)) then
if (CQUI_yieldsOn == false and not UILens.IsLayerOn(CQUI_CitizenManagement)) then
UILens.SetLayerHexesArea(CQUI_CityYields, Game.GetLocalPlayer(), yields);
UILens.ToggleLayerOn( CQUI_CityYields );
end
elseif UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT) == false then
elseif UILens.IsLayerOn(CQUI_CitizenManagement) == false then
local pInstance :table = CQUI_GetInstanceAt(pNextPlotID);
if (pInstance ~= nil) then
pInstance.CQUI_NextPlotLabel:SetString("[ICON_Turn]" .. Locale.Lookup("LOC_HUD_CITY_IN_TURNS" , TurnsUntilExpansion ) .. " ");
Expand All @@ -398,7 +399,7 @@ function CQUI_OnBannerMouseExit(playerID: number, cityID: number)

CQUI_yieldsOn = UserConfiguration.ShowMapYield();

if (CQUI_yieldsOn == false and not UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT)) then
if (CQUI_yieldsOn == false and not UILens.IsLayerOn(CQUI_CitizenManagement)) then
UILens.ClearLayerHexes( CQUI_CityYields );
end

Expand Down
13 changes: 7 additions & 6 deletions Assets/Expansion2/CityBanners/citybannermanager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ local CQUI_SmartWorkIconAlpha = .45;
local g_smartbanner = true;

local CQUI_CityYields : number = UILens.CreateLensLayerHash("City_Yields");
local CQUI_CitizenManagement : number = UILens.CreateLensLayerHash("Citizen_Management");

function CQUI_OnSettingsInitialized()
CQUI_ShowYieldsOnCityHover = GameConfiguration.GetValue("CQUI_ShowYieldsOnCityHover");
Expand Down Expand Up @@ -278,7 +279,7 @@ function CQUI_OnBannerMouseOver(playerID: number, cityID: number)
-- Astog: Fix for lens being shown when other lenses are on.
-- Astog: Don't show this lens if any unit is selected.
-- This prevents the need to check if every lens is on or not, like builder, religious lens.
if CQUI_ShowCityManageAreaOnCityHover and not UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT)
if CQUI_ShowCityManageAreaOnCityHover and not UILens.IsLayerOn(CQUI_CitizenManagement)
and UI.GetInterfaceMode() == InterfaceModeTypes.SELECTION
and UI.GetHeadSelectedUnit() == nil then
LuaEvents.CQUI_ShowCitizenManagement(cityID);
Expand Down Expand Up @@ -312,7 +313,7 @@ function CQUI_OnBannerMouseOver(playerID: number, cityID: number)
local yields :table = {};
local yieldsIndex :table = {};

if (tPlots ~= nil and table.count(tPlots) ~= 0) and UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT) == false then
if (tPlots ~= nil and table.count(tPlots) ~= 0) and UILens.IsLayerOn(CQUI_CitizenManagement) == false then

CQUI_yieldsOn = UserConfiguration.ShowMapYield();

Expand Down Expand Up @@ -364,7 +365,7 @@ function CQUI_OnBannerMouseOver(playerID: number, cityID: number)

tPlots = tResults[CityCommandResults.PLOTS];

if (tPlots ~= nil and table.count(tPlots) ~= 0) and UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT) == false then
if (tPlots ~= nil and table.count(tPlots) ~= 0) and UILens.IsLayerOn(CQUI_CitizenManagement) == false then

for i,plotId in pairs(tPlots) do
local kPlot :table = Map.GetPlotByIndex(plotId);
Expand All @@ -383,11 +384,11 @@ function CQUI_OnBannerMouseOver(playerID: number, cityID: number)

local plotCount = Map.GetPlotCount();

if (CQUI_yieldsOn == false and not UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT)) then
if (CQUI_yieldsOn == false and not UILens.IsLayerOn(CQUI_CitizenManagement)) then
UILens.SetLayerHexesArea(CQUI_CityYields, Game.GetLocalPlayer(), yields);
UILens.ToggleLayerOn( CQUI_CityYields );
end
elseif UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT) == false then
elseif UILens.IsLayerOn(CQUI_CitizenManagement) == false then
local pInstance :table = CQUI_GetInstanceAt(pNextPlotID);
if (pInstance ~= nil) then
pInstance.CQUI_NextPlotLabel:SetString("[ICON_Turn]" .. Locale.Lookup("LOC_HUD_CITY_IN_TURNS" , TurnsUntilExpansion ) .. " ");
Expand All @@ -406,7 +407,7 @@ function CQUI_OnBannerMouseExit(playerID: number, cityID: number)

CQUI_yieldsOn = UserConfiguration.ShowMapYield();

if (CQUI_yieldsOn == false and not UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT)) then
if (CQUI_yieldsOn == false and not UILens.IsLayerOn(CQUI_CitizenManagement)) then
UILens.ClearLayerHexes( CQUI_CityYields );
end

Expand Down
15 changes: 8 additions & 7 deletions Assets/UI/WorldView/citybannermanager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ local CQUI_SmartWorkIconAlpha = .45;
local g_smartbanner = true;

local CQUI_CityYields : number = UILens.CreateLensLayerHash("City_Yields");
local CQUI_CitizenManagement : number = UILens.CreateLensLayerHash("Citizen_Management");

function CQUI_OnSettingsInitialized()
CQUI_ShowYieldsOnCityHover = GameConfiguration.GetValue("CQUI_ShowYieldsOnCityHover");
Expand Down Expand Up @@ -296,7 +297,7 @@ function CQUI_OnBannerMouseOver(playerID: number, cityID: number)
-- Astog: Fix for lens being shown when other lenses are on.
-- Astog: Don't show this lens if any unit is selected.
-- This prevents the need to check if every lens is on or not, like builder, religious lens.
if CQUI_ShowCityManageAreaOnCityHover and not UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT)
if CQUI_ShowCityManageAreaOnCityHover and not UILens.IsLayerOn(CQUI_CitizenManagement)
and UI.GetInterfaceMode() == InterfaceModeTypes.SELECTION
and UI.GetHeadSelectedUnit() == nil then
LuaEvents.CQUI_ShowCitizenManagement(cityID);
Expand Down Expand Up @@ -330,7 +331,7 @@ function CQUI_OnBannerMouseOver(playerID: number, cityID: number)
local yields :table = {};
local yieldsIndex :table = {};

if (tPlots ~= nil and table.count(tPlots) ~= 0) and UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT) == false then
if (tPlots ~= nil and table.count(tPlots) ~= 0) and UILens.IsLayerOn(CQUI_CitizenManagement) == false then

CQUI_yieldsOn = UserConfiguration.ShowMapYield();

Expand Down Expand Up @@ -382,7 +383,7 @@ function CQUI_OnBannerMouseOver(playerID: number, cityID: number)

tPlots = tResults[CityCommandResults.PLOTS];

if (tPlots ~= nil and table.count(tPlots) ~= 0) and UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT) == false then
if (tPlots ~= nil and table.count(tPlots) ~= 0) and UILens.IsLayerOn(CQUI_CitizenManagement) == false then

for i,plotId in pairs(tPlots) do
local kPlot :table = Map.GetPlotByIndex(plotId);
Expand All @@ -401,11 +402,11 @@ function CQUI_OnBannerMouseOver(playerID: number, cityID: number)

local plotCount = Map.GetPlotCount();

if (CQUI_yieldsOn == false and not UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT)) then
if (CQUI_yieldsOn == false and not UILens.IsLayerOn(CQUI_CitizenManagement)) then
UILens.SetLayerHexesArea(CQUI_CityYields, Game.GetLocalPlayer(), yields);
UILens.ToggleLayerOn( CQUI_CityYields );
end
elseif UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT) == false then
elseif UILens.IsLayerOn(CQUI_CitizenManagement) == false then
local pInstance :table = CQUI_GetInstanceAt(pNextPlotID);
if (pInstance ~= nil) then
pInstance.CQUI_NextPlotLabel:SetString("[ICON_Turn]" .. Locale.Lookup("LOC_HUD_CITY_IN_TURNS" , TurnsUntilExpansion ) .. " ");
Expand All @@ -424,7 +425,7 @@ function CQUI_OnBannerMouseExit(playerID: number, cityID: number)

CQUI_yieldsOn = UserConfiguration.ShowMapYield();

if (CQUI_yieldsOn == false and not UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT)) then
if (CQUI_yieldsOn == false and not UILens.IsLayerOn(CQUI_CitizenManagement)) then
UILens.ClearLayerHexes( CQUI_CityYields );
end

Expand Down Expand Up @@ -473,7 +474,7 @@ function CQUI_OnBannerMouseExit(playerID: number, cityID: number)
pInstance = CQUI_ReleaseInstanceAt(index);

-- Eventually remove colored hex
-- if UILens.IsLayerOn(LensLayers.CITIZEN_MANAGEMENT) == false then
-- if UILens.IsLayerOn(CQUI_CitizenManagement) == false then
-- UILens.ClearHex(LensLayers.PURCHASE_PLOT, index);
-- UILens.ToggleLayerOff( LensLayers.PURCHASE_PLOT );
-- end
Expand Down

0 comments on commit 36249e2

Please sign in to comment.