Skip to content

Commit

Permalink
Frontier Pass Update
Browse files Browse the repository at this point in the history
Fix for Maya
Ported changes from update to base files
  • Loading branch information
astog committed May 23, 2020
1 parent 926e86b commit 2e866e0
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 55 deletions.
62 changes: 45 additions & 17 deletions Base/Assets/UI/MinimapPanel.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
-- Copyright 2016-2018, Firaxis Games
include( "InstanceManager" );
include("GameCapabilities");

-- ===========================================================================
-- MODDED LENS (by Astog)
Expand Down Expand Up @@ -456,6 +457,13 @@ function OnCollapseToggle()
Controls.CompassArm:SetPercent(.5);
end
m_isCollapsed = not m_isCollapsed;
LuaEvents.WorldTracker_OnSetMinimapCollapsed(m_isCollapsed);
LuaEvents.ChatPanel_OnChatPanelRefresh();
end

-- ===========================================================================
function SetMinimapForChat()
LuaEvents.WorldTracker_SetMinimapSize(Controls.MinimapContainer:GetSizeY() + 110); -- sets the state of the minimap in WorldTracker to be used for chat resizing
end

-- ===========================================================================
Expand Down Expand Up @@ -552,8 +560,9 @@ function OnLensLayerOff( layerNum:number )
layerNum == m_HexColoringGovernment or
layerNum == m_HexColoringOwningCiv) then
UI.PlaySound("UI_Lens_Overlay_Off");

-- Clear Modded Lens (Appeal lens included)
-- Astog
--------------------------------------------------------------------------------------------------
-- Clear Modded Lens Seperately (Appeal lens included)
elseif layerNum == m_HexColoringAppeal then
UILens.ClearLayerHexes( m_MapHexMask );
if UI.GetInterfaceMode() ~= InterfaceModeTypes.VIEW_MODAL_LENS or (UI.GetHeadSelectedUnit() == nil) then
Expand Down Expand Up @@ -629,7 +638,6 @@ function SetOwningCivHexes()
end

-- ===========================================================================

function SetDefaultWaterHexes()
local FullWaterPlots:table = {};
local CoastalWaterPlots:table = {};
Expand All @@ -645,6 +653,11 @@ function SetDefaultWaterHexes()
local DisgustingColor :number = UI.GetColorValue("COLOR_DISGUSTING_APPEAL");
local localPlayer :number = Game.GetLocalPlayer();

if HasTrait("TRAIT_CIVILIZATION_MAYAB", Game.GetLocalPlayer())then
BreathtakingColor = AverageColor;
CharmingColor = AverageColor;
end

if(table.count(FullWaterPlots) > 0) then
UILens.SetLayerHexesColoredArea( m_HexColoringWaterAvail, localPlayer, FullWaterPlots, BreathtakingColor );
end
Expand Down Expand Up @@ -1158,11 +1171,9 @@ function GetMinimapMouseCoords( mousex:number, mousey:number )

return minix, miniy;
end

function IsMouseInMinimap( minix:number, miniy:number )
return minix >= 0 and minix <= 1 and miniy >= 0 and miniy <= 1;
end

function TranslateMinimapToWorld( minix:number, miniy:number )
local mapMinX, mapMinY, mapMaxX, mapMaxY = UI.GetMinimapWorldRect();

Expand All @@ -1178,11 +1189,10 @@ function TranslateMinimapToWorld( minix:number, miniy:number )
end

function OnInputHandler( pInputStruct:table )
local msg = pInputStruct:GetMessageType();

-- Astog
--------------------------------------------------------------------------------------------------
if pInputStruct:GetKey() == Keys.VK_CONTROL then
local msg = pInputStruct:GetMessageType();
if msg == KeyEvents.KeyDown then
if not m_AltSettlerLensOn and UILens.IsLayerOn(m_HexColoringWaterAvail) then
m_CurrentCursorPlotID = -1;
Expand All @@ -1200,6 +1210,7 @@ function OnInputHandler( pInputStruct:table )

-- Skip all handling when dragging is disabled or the minimap is collapsed
if m_isMouseDragEnabled and not m_isCollapsed then
local msg = pInputStruct:GetMessageType( );

-- Enable drag on LMB down
if (msg == MouseEvents.LButtonDown or msg == MouseEvents.PointerDown) then
Expand Down Expand Up @@ -1311,9 +1322,27 @@ function OnTutorial_SwitchToWorldView()
end

function OnShutdown()
LuaEvents.Tutorial_SwitchToWorldView.Remove( OnTutorial_SwitchToWorldView );
LuaEvents.Tutorial_DisableMapDrag.Remove( OnTutorial_DisableMapDrag );

-- Game Events
Events.CityAddedToMap.Remove( OnCityAddedToMap );
Events.InputActionTriggered.Remove( OnInputActionTriggered );
Events.InterfaceModeChanged.Remove( OnInterfaceModeChanged );
Events.LensLayerOn.Remove( OnLensLayerOn );
Events.LensLayerOff.Remove( OnLensLayerOff );
Events.LocalPlayerChanged.Remove( OnLocalPlayerChanged );
Events.UserOptionsActivated.Remove( OnUserOptionsActivated );

LuaEvents.MinimapPanel_CloseAllLenses.Remove( CloseAllLenses );
LuaEvents.MinimapPanel_RefreshMinimapOptions.Remove( RefreshMinimapOptions );
LuaEvents.MinimapPanel_ToggleGrid.Remove( ToggleGrid );
LuaEvents.NotificationPanel_ShowContinentLens.Remove(OnToggleContinentLensExternal);
LuaEvents.Tutorial_DisableMapDrag.Remove( OnTutorial_DisableMapDrag )
LuaEvents.Tutorial_SwitchToWorldView.Remove( OnTutorial_SwitchToWorldView );
LuaEvents.CityPanelOverview_Opened.Remove( function()
if not Controls.LensPanel:IsHidden() then
OnToggleLensList();
end
end );

m_LensButtonIM:ResetInstances();
m_MapOptionIM:ResetInstances();
Expand All @@ -1329,7 +1358,7 @@ function OnCityAddedToMap(playerID, cityID, x, y)
end

-- ===========================================================================
function LateInitialize()
function LateInitialize( isReload:boolean )
m_MiniMap_xmloffsety = Controls.MiniMap:GetOffsetY();
g_ContinentsCache = Map.GetContinentsInUse();

Expand All @@ -1352,7 +1381,7 @@ function LateInitialize()
Controls.ContinentLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_CONTINENT"));
Controls.EmpireLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_EMPIRE"));
Controls.LensToggleStack:CalculateSize();
-- Astog: We want to disable lens panel resizing size it is too large to show without scroll panel
-- Astog: We want to disable lens panel resizing size. It is too large to show without scroll panel
-- Controls.LensPanel:SetSizeY(Controls.LensToggleStack:GetSizeY() + LENS_PANEL_OFFSET);

if GameCapabilities.HasCapability("CAPABILITY_SEARCH_GAME_MAP") then
Expand Down Expand Up @@ -1429,20 +1458,19 @@ function LateInitialize()
Controls.WaterLensButton:RegisterCallback( Mouse.eLClick, ToggleWaterLens );

-- Game Events
Events.CityAddedToMap.Add( OnCityAddedToMap );
Events.InputActionTriggered.Add( OnInputActionTriggered );
Events.InterfaceModeChanged.Add( OnInterfaceModeChanged );
Events.LensLayerOn.Add( OnLensLayerOn );
Events.LensLayerOff.Add( OnLensLayerOff );
Events.LocalPlayerChanged.Add( OnLocalPlayerChanged );
Events.UserOptionsActivated.Add( OnUserOptionsActivated );

Events.CityAddedToMap.Add( OnCityAddedToMap );

end

-- ===========================================================================
function OnInit( isReload:boolean )
LateInitialize();
LateInitialize( isReload );
end

function CloseAllLenses()
Expand Down Expand Up @@ -1477,12 +1505,12 @@ function Initialize()
Controls.SwitcherImage:SetTextureOffsetVal(0,24);
end

LuaEvents.MinimapPanel_CloseAllLenses.Add( CloseAllLenses );
LuaEvents.MinimapPanel_RefreshMinimapOptions.Add( RefreshMinimapOptions );
LuaEvents.MinimapPanel_ToggleGrid.Add( ToggleGrid );
LuaEvents.NotificationPanel_ShowContinentLens.Add(OnToggleContinentLensExternal);
LuaEvents.Tutorial_DisableMapDrag.Add( OnTutorial_DisableMapDrag );
LuaEvents.Tutorial_SwitchToWorldView.Add( OnTutorial_SwitchToWorldView );
LuaEvents.MinimapPanel_ToggleGrid.Add( ToggleGrid );
LuaEvents.MinimapPanel_RefreshMinimapOptions.Add( RefreshMinimapOptions );
LuaEvents.MinimapPanel_CloseAllLenses.Add( CloseAllLenses );
LuaEvents.CityPanelOverview_Opened.Add( function()
if not Controls.LensPanel:IsHidden() then
OnToggleLensList();
Expand Down
4 changes: 2 additions & 2 deletions Base/Assets/UI/MinimapPanel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<Image Texture="Controls_ButtonExtendSmall" TextureOffset="0,60" Size="20,20" Anchor="L,B" Offset="22,10"/>
</Grid>

<Grid ID="MapOptionsPanel" Anchor="L,T" AnchorSide="I,O" Size="220,119" Offset="-10,-5" Texture="Tracker_OptionsBacking.dds" SliceCorner="55,61" SliceSize="1,1" SliceTextureSize="121,119" ConsumeAllMouse="1" Hidden="1">
<Grid ID="MapOptionsPanel" Anchor="L,T" AnchorSide="I,O" Size="220,119" MinSize="121,119" Offset="-10,-5" Texture="Tracker_OptionsBacking.dds" SliceCorner="55,61" SliceSize="1,1" SliceTextureSize="121,119" ConsumeAllMouse="1" Hidden="1">
<Label ID="MapOptionsLabel" Anchor="C,T" String="{LOC_HUD_MAP_OPTIONS:upper}" Offset="-6,10" Style="FontFlair16" Color0="106,93,69,255" Color1="0,0,0,150" Color2="146,133,109,255" FontStyle="Glow" SmallCaps="20" SmallCapsLeading="0" SmallCapsType="EveryWord" KerningAdjustment="0"/>
<ScrollPanel ID="MapOptionsList" Anchor="C,B" Offset="10,30" Size="parent,parent-60" AutoScrollBar="1" Vertical="1">
<Stack ID="MapOptionsStack" Anchor="R,C" StackGrowth="Bottom" Offset="25,0" StackPadding="1" >
Expand Down Expand Up @@ -82,7 +82,7 @@
</Container>

<Instance Name="LensButtonInstance">
<RadioButton ID="LensButton" RadioGroup="ActiveLens" TextOffset="-5,0" String="$LensName$" AllowClickOff="1" Style="WhiteSemiBold14" Offset="10,4" ButtonTexture="Controls_RadioButtonLarge.dds" ButtonSize="35,35" CheckTexture="Controls_RadioButtonLarge.dds" CheckSize="35,35" CheckTextureOffset="0,140" Anchor="L,T" BoxOnLeft="1"/>
<RadioButton ID="LensButton" RadioGroup="ActiveLens" TextOffset="-5,0" String="$LensName$" AllowClickOff="1" Style="WhiteSemiBold14" Offset="10,4" ButtonTexture="Controls_RadioButtonLarge.dds" ButtonSize="35,35" CheckTexture="Controls_RadioButtonLarge.dds" CheckSize="35,35" CheckTextureOffset="0,35" Anchor="L,T" BoxOnLeft="1"/>
</Instance>

<Instance Name="MapOptionInstance">
Expand Down
85 changes: 51 additions & 34 deletions Base/Assets/UI/Panels/ModalLensPanel.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- Provides info about currently active Modal Lens

include( "InstanceManager" );
include("GameCapabilities");

-- ===========================================================================
-- MODDED LENS
Expand All @@ -9,11 +10,6 @@ include( "InstanceManager" );
g_ModLensModalPanel = {} -- Populated by ModLens_*.lua scripts
include( "ModLens_", true )

-- ===========================================================================
-- Globals
-- ===========================================================================
g_KeyStackIM = InstanceManager:new( "KeyEntry", "KeyColorImage", Controls.KeyStack );

-- ===========================================================================
-- Members
-- =======================================================e====================
Expand All @@ -28,6 +24,8 @@ local m_HexColoringWaterAvail : number = UILens.CreateLensLayerHash("Hex_Colorin
local m_TouristTokens : number = UILens.CreateLensLayerHash("Tourist_Tokens");
local m_EmpireDetails : number = UILens.CreateLensLayerHash("Empire_Details");

local m_KeyStackIM:table = InstanceManager:new( "KeyEntry", "KeyColorImage", Controls.KeyStack );

--============================================================================
function Close()
--ContextPtr:SetHide(true);
Expand All @@ -36,7 +34,7 @@ end

--============================================================================
function ShowAppealLensKey()
g_KeyStackIM: ResetInstances();
ResetKeyStackIM();

-- Breathtaking
AddKeyEntry("LOC_TOOLTIP_APPEAL_BREATHTAKING", UI.GetColorValue("COLOR_BREATHTAKING_APPEAL"));
Expand All @@ -59,18 +57,22 @@ end

--============================================================================
function ShowSettlerLensKey()
g_KeyStackIM: ResetInstances();
ResetKeyStackIM();

-- Fresh Water
local FreshWaterBonus:number = GlobalParameters.CITY_POPULATION_RIVER_LAKE - GlobalParameters.CITY_POPULATION_NO_WATER;
AddKeyEntry("LOC_HUD_UNIT_PANEL_TOOLTIP_FRESH_WATER", UI.GetColorValue("COLOR_BREATHTAKING_APPEAL"), "ICON_HOUSING", "+" .. tostring(FreshWaterBonus));
if(HasTrait("TRAIT_CIVILIZATION_MAYAB", Game.GetLocalPlayer()))then
AddKeyEntry("LOC_HUD_UNIT_PANEL_TOOLTIP_VALID_LOCATION", UI.GetColorValue("COLOR_AVERAGE_APPEAL"));
else
-- Fresh Water
local FreshWaterBonus:number = GlobalParameters.CITY_POPULATION_RIVER_LAKE - GlobalParameters.CITY_POPULATION_NO_WATER;
AddKeyEntry("LOC_HUD_UNIT_PANEL_TOOLTIP_FRESH_WATER", UI.GetColorValue("COLOR_BREATHTAKING_APPEAL"), "ICON_HOUSING", "+" .. tostring(FreshWaterBonus));

-- Coastal Water
local CoastalWaterBonus:number = GlobalParameters.CITY_POPULATION_COAST - GlobalParameters.CITY_POPULATION_NO_WATER;
AddKeyEntry("LOC_HUD_UNIT_PANEL_TOOLTIP_COASTAL_WATER", UI.GetColorValue("COLOR_CHARMING_APPEAL"), "ICON_HOUSING", "+" .. tostring(CoastalWaterBonus));
-- Coastal Water
local CoastalWaterBonus:number = GlobalParameters.CITY_POPULATION_COAST - GlobalParameters.CITY_POPULATION_NO_WATER;
AddKeyEntry("LOC_HUD_UNIT_PANEL_TOOLTIP_COASTAL_WATER", UI.GetColorValue("COLOR_CHARMING_APPEAL"), "ICON_HOUSING", "+" .. tostring(CoastalWaterBonus));

-- No Water
AddKeyEntry("LOC_HUD_UNIT_PANEL_TOOLTIP_NO_WATER", UI.GetColorValue("COLOR_AVERAGE_APPEAL"));
-- No Water
AddKeyEntry("LOC_HUD_UNIT_PANEL_TOOLTIP_NO_WATER", UI.GetColorValue("COLOR_AVERAGE_APPEAL"));
end

-- Too Close To City
AddKeyEntry("LOC_HUD_UNIT_PANEL_TOOLTIP_TOO_CLOSE_TO_CITY", UI.GetColorValue("COLOR_DISGUSTING_APPEAL"));
Expand All @@ -81,7 +83,7 @@ end

--============================================================================
function ShowReligionLensKey()
g_KeyStackIM:ResetInstances();
ResetKeyStackIM();

-- Track which types we've added so we don't add duplicates
local visibleTypes:table = {};
Expand Down Expand Up @@ -111,7 +113,7 @@ end

--============================================================================
function ShowGovernmentLensKey()
g_KeyStackIM:ResetInstances();
ResetKeyStackIM();

-- Track which types we've added so we don't add duplicates
local visibleTypes:table = {};
Expand Down Expand Up @@ -152,7 +154,7 @@ end

--============================================================================
function ShowPoliticalLensKey()
g_KeyStackIM:ResetInstances();
ResetKeyStackIM();

local hasAddedCityStateEntry = false;
local localPlayer = Players[Game.GetLocalPlayer()];
Expand Down Expand Up @@ -212,7 +214,7 @@ end

--============================================================================
function ShowContinentLensKey()
g_KeyStackIM: ResetInstances();
ResetKeyStackIM();

for ContinentID,ColorValue in pairs(m_ContinentColorList) do
local visibleContinentPlots:table = Map.GetVisibleContinentPlots(ContinentID);
Expand All @@ -227,12 +229,24 @@ function ShowContinentLensKey()
end

-- ===========================================================================
function AddKeyEntry(textString:string, colorValue:number, bonusIcon:string, bonusValue:string)
local keyEntryInstance:table = g_KeyStackIM:GetInstance();
function ResetKeyStackIM()
m_KeyStackIM:ResetInstances();
end

-- ===========================================================================
function AddKeyEntry(textString:string, colorValue:number, bonusIcon:string, bonusValue:string, bUseEmptyTexture:boolean)
local keyEntryInstance:table = m_KeyStackIM:GetInstance();

-- Update key text
keyEntryInstance.KeyLabel:SetText(Locale.Lookup(textString));

-- Set the texture if we want to use the hollow, border only hex texture
if bUseEmptyTexture == true then
keyEntryInstance.KeyColorImage:SetTexture("Controls_KeySwatchHexEmpty");
else
keyEntryInstance.KeyColorImage:SetTexture("Controls_KeySwatchHex");
end

-- Update key color
keyEntryInstance.KeyColorImage:SetColor(colorValue);

Expand Down Expand Up @@ -262,7 +276,6 @@ function AddKeyEntry(textString:string, colorValue:number, bonusIcon:string, bon
end

keyEntryInstance.KeyInfoStack:CalculateSize();
keyEntryInstance.KeyInfoStack:ReprocessAnchoring();
end

-- ===========================================================================
Expand All @@ -275,7 +288,7 @@ function OnLensLayerOn( layerNum:number )
Controls.KeyPanel:SetHide(true);
ShowContinentLensKey();
elseif layerNum == m_HexColoringAppeal then
-- Check for mod lens
-- Astog: Check for mod lens
local lens = {}
LuaEvents.MinimapPanel_GetActiveModLens(lens)
if lens ~= nil and lens[1] ~= "NONE" then
Expand Down Expand Up @@ -311,20 +324,20 @@ function OnInterfaceModeChanged(eOldMode:number, eNewMode:number)
if eNewMode == InterfaceModeTypes.VIEW_MODAL_LENS then
ContextPtr:SetHide(false);
end
if eOldMode == InterfaceModeTypes.VIEW_MODAL_LENS then
ContextPtr:SetHide(true);
if eOldMode == InterfaceModeTypes.VIEW_MODAL_LENS or eOldMode == InterfaceModeTypes.CITY_SELECTION then
if not ContextPtr:IsHidden() then
ContextPtr:SetHide(true);
end
end
end

-- ===========================================================================
-- INIT (ModalLensPanel)
-- ===========================================================================
function AddLensEntry(lensKey:string, lensEntry:table)
g_ModLensModalPanel[lensKey] = lensEntry
function OnInit(isReload:boolean)
LateInitialize();
end

function InitializeModalLensPanel()

-- ===========================================================================
function LateInitialize()
if (Game.GetLocalPlayer() == -1) then
return;
end
Expand All @@ -335,8 +348,12 @@ function InitializeModalLensPanel()
Events.LensLayerOn.Add( OnLensLayerOn );

LuaEvents.MinimapPanel_AddContinentColorPair.Add(OnAddContinentColorPair);
end

-- Mod Lens Support
LuaEvents.ModalLensPanel_AddLensEntry.Add( AddLensEntry )
-- ===========================================================================
-- INIT (ModalLensPanel)
-- ===========================================================================
function Initialize()
ContextPtr:SetInitHandler(OnInit);
end
InitializeModalLensPanel();
Initialize();
2 changes: 1 addition & 1 deletion DLC/Expansion1/UI/Replacements/MinimapPanel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
</Container>

<Instance Name="LensButtonInstance">
<RadioButton ID="LensButton" RadioGroup="ActiveLens" TextOffset="-5,0" String="$LensName$" AllowClickOff="1" Style="WhiteSemiBold14" Offset="10,4" ButtonTexture="Controls_RadioButtonLarge.dds" ButtonSize="35,35" CheckTexture="Controls_RadioButtonLarge.dds" CheckSize="35,35" CheckTextureOffset="0,140" Anchor="L,T" BoxOnLeft="1"/>
<RadioButton ID="LensButton" RadioGroup="ActiveLens" TextOffset="-5,0" String="$LensName$" AllowClickOff="1" Style="WhiteSemiBold14" Offset="10,4" ButtonTexture="Controls_RadioButtonLarge.dds" ButtonSize="35,35" CheckTexture="Controls_RadioButtonLarge.dds" CheckSize="35,35" CheckTextureOffset="0,35" Anchor="L,T" BoxOnLeft="1"/>
</Instance>

<Instance Name="MapOptionInstance">
Expand Down
Loading

0 comments on commit 2e866e0

Please sign in to comment.