From 9eec5836660bd531a8c8933eebd49a8c3bf4ce2a Mon Sep 17 00:00:00 2001 From: astog Date: Thu, 19 Sep 2019 20:21:50 -0500 Subject: [PATCH] Fixes for September 2019 patch --- Base/Assets/UI/MinimapPanel.lua | 454 +++++++++++++++++--------------- Lenses/ModLens_Scout.lua | 14 +- 2 files changed, 247 insertions(+), 221 deletions(-) diff --git a/Base/Assets/UI/MinimapPanel.lua b/Base/Assets/UI/MinimapPanel.lua index 24e1ce9..bf3147a 100644 --- a/Base/Assets/UI/MinimapPanel.lua +++ b/Base/Assets/UI/MinimapPanel.lua @@ -51,17 +51,16 @@ local m_ContinentsCreated :boolean=false; local m_MiniMap_xmloffsety :number = 0; local m_kFlyoutControlIds :table = { "MapOptions", "Lens", "MapPinList", "MapSearch" }; -- Name of controls that are the backing for "flyout" menus. -local m_ToggleReligionLensId = Input.GetActionId("LensReligion"); -local m_ToggleContinentLensId = Input.GetActionId("LensContinent"); -local m_ToggleAppealLensId = Input.GetActionId("LensAppeal"); -local m_ToggleSettlerLensId = Input.GetActionId("LensSettler"); -local m_ToggleGovernmentLensId = Input.GetActionId("LensGovernment"); -local m_TogglePoliticalLensId = Input.GetActionId("LensPolitical"); -local m_ToggleTourismLensId = Input.GetActionId("LensTourism"); -local m_ToggleEmpireLensId = Input.GetActionId("LensEmpire"); +local m_ToggleReligionLensId = -1; +local m_ToggleContinentLensId = -1; +local m_ToggleAppealLensId = -1; +local m_ToggleSettlerLensId = -1; +local m_ToggleGovernmentLensId = -1; +local m_TogglePoliticalLensId = -1; +local m_ToggleTourismLensId = -1; +local m_ToggleEmpireLensId = -1; local m_Toggle2DViewId = Input.GetActionId("Toggle2DView"); - -local m_OpenMapSearchId = Input.GetActionId("OpenMapSearch"); +local m_OpenMapSearchId = -1; local m_isMouseDragEnabled :boolean = true; -- Can the camera be moved by dragging on the minimap? local m_isMouseDragging :boolean = false; -- Was LMB clicked inside the minimap, and has not been released yet? @@ -75,6 +74,7 @@ local m_HexColoringOwningCiv : number = UILens.CreateLensLayerHash("Hex_Coloring local m_HexColoringWaterAvail : number = UILens.CreateLensLayerHash("Hex_Coloring_Water_Availablity"); local m_TouristTokens : number = UILens.CreateLensLayerHash("Tourist_Tokens"); + -- =========================================================================== -- FUNCTIONS -- =========================================================================== @@ -205,18 +205,6 @@ function OnToggleLensList() Controls.LensButton:SetSelected( not Controls.LensPanel:IsHidden() ); if Controls.LensPanel:IsHidden() then CloseLensList(); - else - Controls.ReligionLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_RELIGION")); - Controls.AppealLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_APPEAL")); - Controls.GovernmentLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_GOVERNMENT")); - Controls.WaterLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_SETTLER")); - Controls.TourismLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_TOURISM")); - Controls.ContinentLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_CONTINENT")); - Controls.EmpireLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_EMPIRE")); - Controls.LensToggleStack:CalculateSize(); - - -- Astog: Disable increasing size of panel, since now we have a scrollbar - -- Controls.LensPanel:SetSizeY(Controls.LensToggleStack:GetSizeY() + LENS_PANEL_OFFSET); end end @@ -279,16 +267,14 @@ end function ToggleResourceIcons() local bOldValue :boolean = UserConfiguration.ShowMapResources(); UserConfiguration.ShowMapResources( not bOldValue ); - - local bOther = UserConfiguration.ShowMapGrid(); end -- =========================================================================== function RestoreYieldIcons() if UserConfiguration.ShowMapYield() then - LuaEvents.MinimapPanel_ShowYieldIcons(); + LuaEvents.PlotInfo_ShowYieldIcons(); else - LuaEvents.MinimapPanel_HideYieldIcons(); + LuaEvents.PlotInfo_HideYieldIcons(); end end @@ -418,10 +404,9 @@ end -- =========================================================================== function ToggleGrid() - local bOldState :boolean = UserConfiguration.ShowMapGrid(); - UserConfiguration.ShowMapGrid( not bOldState ); - local bNewState :boolean = UserConfiguration.ShowMapGrid(); - UI.ToggleGrid( not bOldState ); + local bShouldShowGrid = not UserConfiguration.ShowMapGrid(); + UserConfiguration.ShowMapGrid( bShouldShowGrid ); + UI.ToggleGrid( bShouldShowGrid ); end -- =========================================================================== @@ -476,7 +461,12 @@ end -- =========================================================================== function OnMinimapImageSizeChanged() ResizeBacking(); + + -- Astog + -------------------------------------------------------------------------------------------------- + -- Reoffset custom lens panels based on the minimap size change LuaEvents.ML_ReoffsetPanels() + -------------------------------------------------------------------------------------------------- end -- =========================================================================== @@ -557,7 +547,6 @@ function OnLensLayerOff( layerNum:number ) UILens.ClearLayerHexes(m_MovementZoneOfControl); end - -- print("OnLensLayerOff", layerNum) if (layerNum == m_HexColoringReligion or layerNum == g_HexColoringContinent or layerNum == m_HexColoringGovernment or @@ -675,10 +664,8 @@ end -------------------------------------------------------------------------------------------------- function SetWaterHexes() if (not m_CtrlDown) then - print("default") SetDefaultWaterHexes() else - print("alt") SetSettlerLens() end end @@ -778,7 +765,7 @@ end -- =========================================================================== function SetGovernmentHexes() - local localPlayer : number = Game.GetLocalPlayer(); + local localPlayer : number = Game.GetLocalPlayer(); local localPlayerVis:table = PlayersVisibility[localPlayer]; if (localPlayerVis ~= nil) then local players = Game.GetPlayers(); @@ -786,7 +773,7 @@ function SetGovernmentHexes() local pCities :table = players[i]:GetCities(); local pCulture :table = player:GetCulture(); local governmentId :number = pCulture:GetCurrentGovernment(); - local governmentColor :number; + local governmentColor :number; if pCulture:IsInAnarchy() then governmentColor = UI.GetColorValue("COLOR_CLEAR"); @@ -801,12 +788,12 @@ function SetGovernmentHexes() for _, pCity in pCities:Members() do local plots:table = Map.GetCityPlots():GetPurchasedPlots(pCity); - + if(table.count(plots) > 0) then UILens.SetLayerHexesColoredArea( m_HexColoringGovernment, localPlayer, plots, governmentColor ); end end - end + end end end @@ -893,6 +880,10 @@ function OnInputActionTriggered( actionId ) return; end + if GameConfiguration.IsWorldBuilderEditor() then + return; + end + if m_ToggleReligionLensId ~= nil and (actionId == m_ToggleReligionLensId) and GameCapabilities.HasCapability("CAPABILITY_LENS_RELIGION") then LensPanelHotkeyControl( Controls.ReligionLensButton ); ToggleReligionLens(); @@ -950,6 +941,159 @@ function OnInputActionTriggered( actionId ) end end +-- =========================================================================== +-- Modded Lens Support (by Astog) +-- =========================================================================== +function SetModLens() + if m_CurrentModdedLensOn ~= nil and m_CurrentModdedLensOn ~= "NONE" and + g_ModLenses[m_CurrentModdedLensOn] ~= nil then + -- print("Highlighting " .. m_CurrentModdedLensOn .. " hexes") + local getPlotColorFn = g_ModLenses[m_CurrentModdedLensOn].GetColorPlotTable + local funNonStandard = g_ModLenses[m_CurrentModdedLensOn].NonStandardFunction + if getPlotColorFn ~= nil then + SetModLensHexes(getPlotColorFn()) + elseif funNonStandard ~= nil then + funNonStandard() + else + print("ERROR: No Plot Color Function") + end + else + print("ERROR: Given lens has no entry") + end +end + +function SetModLensHexes(colorPlot:table) + if colorPlot ~= nil and table.count(colorPlot) > 0 then + -- UILens.ClearLayerHexes(m_HexColoringAppeal); + local localPlayer = Game.GetLocalPlayer() + for color, plots in pairs(colorPlot) do + if table.count(plots) > 0 then + -- print("Showing " .. table.count(plots) .. " plots with color " .. color) + UILens.SetLayerHexesColoredArea( m_HexColoringAppeal, localPlayer, plots, color); + end + end + else + print("ERROR: Invalid colorPlot table") + end +end + +function SetActiveModdedLens(lensName:string) + m_CurrentModdedLensOn = lensName + LuaEvents.MinimapPanel_ModdedLensOn(lensName) +end + +function GetActiveModdedLens(returnLens:table) + returnLens[1] = m_CurrentModdedLensOn +end + +function GetLensPanelOffsets(offsets:table) + local y = Controls.MinimapContainer:GetSizeY() + Controls.MinimapContainer:GetOffsetY() + if m_isCollapsed then + y = y - Controls.MinimapContainer:GetSizeY() + end + offsets.Y = y + offsets.X = Controls.LensPanel:GetSizeX() + Controls.LensPanel:GetOffsetX() +end + +function ToggleModLens(buttonControl:table, lensName:string) + if buttonControl:IsChecked() then + SetActiveModdedLens(lensName); + + -- Check if the appeal lens is already active. Needed to clear any modded lens + if UILens.IsLayerOn(m_HexColoringAppeal) then + -- Unapply the appeal lens, so it can be cleared from the screen + UILens.SetActive("Default"); + end + + LuaEvents.ML_CloseLensPanels() + if g_ModLenses[lensName].OnToggle ~= nil then + g_ModLenses[lensName].OnToggle() + end + UILens.SetActive("Appeal"); + RefreshInterfaceMode(); + else + g_shouldCloseLensMenu = false; + if UI.GetInterfaceMode() == InterfaceModeTypes.VIEW_MODAL_LENS then + UI.SetInterfaceMode(InterfaceModeTypes.SELECTION); + end + LuaEvents.ML_CloseLensPanels() + SetActiveModdedLens("NONE"); + end +end + +function InitLens(lensName, modLens) + print("Adding ModLens: " .. lensName) + if modLens.Initialize ~= nil then + modLens.Initialize() + end + + -- Add this lens to button stack + local modLensToggle = m_LensButtonIM:GetInstance(); + local pLensButton = modLensToggle.LensButton:GetTextButton() + local pToolTip = Locale.Lookup(modLens.LensButtonTooltip) + pLensButton:LocalizeAndSetText(modLens.LensButtonText) + modLensToggle.LensButton:SetToolTipString(pToolTip) + modLensToggle.LensButton:RegisterCallback(Mouse.eLClick, + function() + ToggleModLens(modLensToggle.LensButton, lensName); + end + ) +end + +function AddLensEntry(lensKey:string, lensEntry:table) + g_ModLenses[lensKey] = lensEntry + InitLens(lensKey, lensEntry) +end + +function InitializeModLens() + print("Initializing " .. table.count(g_ModLenses) .. " lenses") + -- sort here + local sortedModLenses:table = {} + for lensName, modLens in pairs(g_ModLenses) do + table.insert(sortedModLenses, { SortOrder = modLens.SortOrder, Name = lensName, Lens = modLens } ) + end + table.sort(sortedModLenses, function(a,b) return (a.SortOrder and a.SortOrder or 999) < (b.SortOrder and b.SortOrder or 999) end) + -- initilize sorted + for _,modLens in ipairs(sortedModLenses) do + InitLens(modLens.Name, modLens.Lens) + end +end + +function HandleMouseForModdedLens() + if not m_isMouseDragging then + LuaEvents.ML_HandleMouse() + + -- If the alternate settler lens is on, check for plot change, or clear it + if m_AltSettlerLensOn then + -- Get plot under cursor + local plotId = UI.GetCursorPlotID(); + if (not Map.IsPlot(plotId)) then + return; + end + + -- If the cursor plot has not changed don't refresh + if (m_CurrentCursorPlotID == plotId) then + return + end + + m_CurrentCursorPlotID = plotId + + local pPlot = Map.GetPlotByIndex(m_CurrentCursorPlotID) + local selectedUnit = UI.GetHeadSelectedUnit() + + if m_CtrlDown then + RefreshSettlerLens() + elseif UI.GetInterfaceMode() == InterfaceModeTypes.VIEW_MODAL_LENS then + RefreshSettlerLens() + m_AltSettlerLensOn = false + else + RecheckSettlerLens() + m_AltSettlerLensOn = false + end + end + end +end + -- =========================================================================== -- Game Engine Event -- =========================================================================== @@ -972,6 +1116,8 @@ function OnInterfaceModeChanged(eOldMode:number, eNewMode:number) Controls.TourismLensButton:SetCheck(false); Controls.EmpireLensButton:SetCheck(false); + -- Astog + -------------------------------------------------------------------------------------------------- -- Toggle each mod lens local i = 1 local lensButtonInstance = m_LensButtonIM:GetAllocatedInstance(i) @@ -995,6 +1141,7 @@ function OnInterfaceModeChanged(eOldMode:number, eNewMode:number) UILens.ClearLayerHexes(m_MovementZoneOfControl); LuaEvents.ML_CloseLensPanels() + -------------------------------------------------------------------------------------------------- end end @@ -1038,7 +1185,6 @@ function OnInputHandler( pInputStruct:table ) if pInputStruct:GetKey() == Keys.VK_CONTROL then if msg == KeyEvents.KeyDown then if not m_AltSettlerLensOn and UILens.IsLayerOn(m_HexColoringWaterAvail) then - print("ctrl down") m_CurrentCursorPlotID = -1; m_CtrlDown = true m_AltSettlerLensOn = true @@ -1054,6 +1200,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 + -- Enable drag on LMB down if (msg == MouseEvents.LButtonDown or msg == MouseEvents.PointerDown) then local minix, miniy = GetMinimapMouseCoords( pInputStruct:GetX(), pInputStruct:GetY() ); @@ -1094,10 +1241,26 @@ function OnInputHandler( pInputStruct:table ) -- Update tooltip as the mouse is moved over the minimap elseif (msg == MouseEvents.MouseMove or msg == MouseEvents.PointerUpdate) and not UI.IsFullscreenMapEnabled() then + ShowMinimapTooltips(pInputStruct:GetX(), pInputStruct:GetY()) + end + + -- TODO the letterbox background should block mouse input + end + + local uiMsg = pInputStruct:GetMessageType(); + if uiMsg == KeyEvents.KeyUp and pInputStruct:GetKey() == Keys.VK_ESCAPE and not Controls.LensPanel:IsHidden() then + OnToggleLensList(); + return true; + end + + return false; +end + +function ShowMinimapTooltips(inputX:number, inputY:number) local ePlayer : number = Game.GetLocalPlayer(); local pPlayerVis:table = PlayersVisibility[ePlayer]; - local minix, miniy = GetMinimapMouseCoords( pInputStruct:GetX(), pInputStruct:GetY() ); + local minix, miniy = GetMinimapMouseCoords( inputX, inputY ); if (pPlayerVis ~= nil and IsMouseInMinimap(minix, miniy)) then local wx, wy = TranslateMinimapToWorld(minix, miniy); local plotX, plotY = UI.GetPlotCoordFromWorld(wx, wy); @@ -1131,18 +1294,6 @@ function OnInputHandler( pInputStruct:table ) end end end - end - - -- TODO the letterbox background should block mouse input - end - - local uiMsg = pInputStruct:GetMessageType(); - if uiMsg == KeyEvents.KeyUp and pInputStruct:GetKey() == Keys.VK_ESCAPE and not Controls.LensPanel:IsHidden() then - OnToggleLensList(); - return true; - end - - return false; end @@ -1178,171 +1329,35 @@ function OnCityAddedToMap(playerID, cityID, x, y) end -- =========================================================================== --- Modded Lens Support (by Astog) --- =========================================================================== -function SetModLens() - if m_CurrentModdedLensOn ~= nil and m_CurrentModdedLensOn ~= "NONE" and - g_ModLenses[m_CurrentModdedLensOn] ~= nil then - -- print("Highlighting " .. m_CurrentModdedLensOn .. " hexes") - local getPlotColorFn = g_ModLenses[m_CurrentModdedLensOn].GetColorPlotTable - local funNonStandard = g_ModLenses[m_CurrentModdedLensOn].NonStandardFunction - if getPlotColorFn ~= nil then - SetModLensHexes(getPlotColorFn()) - elseif funNonStandard ~= nil then - funNonStandard() - else - print("ERROR: No Plot Color Function") - end - else - print("ERROR: Given lens has no entry") - end -end - -function SetModLensHexes(colorPlot:table) - if colorPlot ~= nil and table.count(colorPlot) > 0 then - -- UILens.ClearLayerHexes(m_HexColoringAppeal); - local localPlayer = Game.GetLocalPlayer() - for color, plots in pairs(colorPlot) do - if table.count(plots) > 0 then - -- print("Showing " .. table.count(plots) .. " plots with color " .. color) - UILens.SetLayerHexesColoredArea( m_HexColoringAppeal, localPlayer, plots, color); - end - end - else - print("ERROR: Invalid colorPlot table") - end -end - -function SetActiveModdedLens(lensName:string) - m_CurrentModdedLensOn = lensName - LuaEvents.MinimapPanel_ModdedLensOn(lensName) -end - -function GetActiveModdedLens(returnLens:table) - returnLens[1] = m_CurrentModdedLensOn -end - -function GetLensPanelOffsets(offsets:table) - local y = Controls.MinimapContainer:GetSizeY() + Controls.MinimapContainer:GetOffsetY() - if m_isCollapsed then - y = y - Controls.MinimapContainer:GetSizeY() - end - offsets.Y = y - offsets.X = Controls.LensPanel:GetSizeX() + Controls.LensPanel:GetOffsetX() -end - -function ToggleModLens(buttonControl:table, lensName:string) - if buttonControl:IsChecked() then - SetActiveModdedLens(lensName); - - -- Check if the appeal lens is already active. Needed to clear any modded lens - if UILens.IsLayerOn(m_HexColoringAppeal) then - -- Unapply the appeal lens, so it can be cleared from the screen - UILens.SetActive("Default"); - end - - LuaEvents.ML_CloseLensPanels() - if g_ModLenses[lensName].OnToggle ~= nil then - -- print("Toggling....") - g_ModLenses[lensName].OnToggle() - end - UILens.SetActive("Appeal"); - RefreshInterfaceMode(); - else - g_shouldCloseLensMenu = false; - if UI.GetInterfaceMode() == InterfaceModeTypes.VIEW_MODAL_LENS then - UI.SetInterfaceMode(InterfaceModeTypes.SELECTION); - end - LuaEvents.ML_CloseLensPanels() - SetActiveModdedLens("NONE"); - end -end - -function InitLens(lensName, modLens) - print("Adding ModLens: " .. lensName) - if modLens.Initialize ~= nil then - modLens.Initialize() - end - - -- Add this lens to button stack - local modLensToggle = m_LensButtonIM:GetInstance(); - local pLensButton = modLensToggle.LensButton:GetTextButton() - local pToolTip = Locale.Lookup(modLens.LensButtonTooltip) - pLensButton:LocalizeAndSetText(modLens.LensButtonText) - modLensToggle.LensButton:SetToolTipString(pToolTip) - modLensToggle.LensButton:RegisterCallback(Mouse.eLClick, - function() - ToggleModLens(modLensToggle.LensButton, lensName); - end - ) -end - -function AddLensEntry(lensKey:string, lensEntry:table) - g_ModLenses[lensKey] = lensEntry - InitLens(lensKey, lensEntry) -end +function LateInitialize() + m_MiniMap_xmloffsety = Controls.MiniMap:GetOffsetY(); + g_ContinentsCache = Map.GetContinentsInUse(); -function InitializeModLens() - print("Initializing " .. table.count(g_ModLenses) .. " lenses") - -- sort here - local sortedModLenses:table = {} - for lensName, modLens in pairs(g_ModLenses) do - table.insert(sortedModLenses, { SortOrder = modLens.SortOrder, Name = lensName, Lens = modLens } ) + if GameCapabilities.HasCapability("CAPABILITY_LENS_TOGGLING_UI") then + m_ToggleReligionLensId = Input.GetActionId("LensReligion"); + m_ToggleContinentLensId = Input.GetActionId("LensContinent"); + m_ToggleAppealLensId = Input.GetActionId("LensAppeal"); + m_ToggleSettlerLensId = Input.GetActionId("LensSettler"); + m_ToggleGovernmentLensId= Input.GetActionId("LensGovernment"); + m_TogglePoliticalLensId = Input.GetActionId("LensPolitical"); + m_ToggleTourismLensId = Input.GetActionId("LensTourism"); + m_ToggleEmpireLensId = Input.GetActionId("LensEmpire"); end - table.sort(sortedModLenses, function(a,b) return (a.SortOrder and a.SortOrder or 999) < (b.SortOrder and b.SortOrder or 999) end) - -- initilize sorted - for _,modLens in ipairs(sortedModLenses) do - InitLens(modLens.Name, modLens.Lens) - end -end - -function HandleMouseForModdedLens() - if not m_isMouseDragging then - LuaEvents.ML_HandleMouse() - -- If the alternate settler lens is on, check for plot change, or clear it - if m_AltSettlerLensOn then - -- Get plot under cursor - local plotId = UI.GetCursorPlotID(); - if (not Map.IsPlot(plotId)) then - return; - end + Controls.ReligionLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_RELIGION")); + Controls.AppealLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_APPEAL")); + Controls.GovernmentLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_GOVERNMENT")); + Controls.WaterLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_SETTLER")); + Controls.TourismLensButton:SetHide(not GameCapabilities.HasCapability("CAPABILITY_LENS_TOURISM")); + 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 + -- Controls.LensPanel:SetSizeY(Controls.LensToggleStack:GetSizeY() + LENS_PANEL_OFFSET); - -- If the cursor plot has not changed don't refresh - if (m_CurrentCursorPlotID == plotId) then - return - end - - m_CurrentCursorPlotID = plotId - - local pPlot = Map.GetPlotByIndex(m_CurrentCursorPlotID) - local selectedUnit = UI.GetHeadSelectedUnit() - - if m_CtrlDown then - RefreshSettlerLens() - elseif UI.GetInterfaceMode() == InterfaceModeTypes.VIEW_MODAL_LENS then - RefreshSettlerLens() - m_AltSettlerLensOn = false - else - RecheckSettlerLens() - m_AltSettlerLensOn = false - end - end + if GameCapabilities.HasCapability("CAPABILITY_SEARCH_GAME_MAP") then + m_OpenMapSearchId = Input.GetActionId("OpenMapSearch"); end -end - --- =========================================================================== -function LateInitialize() - m_MiniMap_xmloffsety = Controls.MiniMap:GetOffsetY(); - g_ContinentsCache = Map.GetContinentsInUse(); - - m_HexColoringReligion = UILens.CreateLensLayerHash("Hex_Coloring_Religion"); - m_HexColoringAppeal = UILens.CreateLensLayerHash("Hex_Coloring_Appeal_Level"); - m_HexColoringGovernment = UILens.CreateLensLayerHash("Hex_Coloring_Government"); - m_HexColoringOwningCiv = UILens.CreateLensLayerHash("Hex_Coloring_Owning_Civ"); - g_HexColoringContinent = UILens.CreateLensLayerHash("Hex_Coloring_Continent"); - m_HexColoringWaterAvail = UILens.CreateLensLayerHash("Hex_Coloring_Water_Availablity"); - m_TouristTokens = UILens.CreateLensLayerHash("Tourist_Tokens"); Controls.MinimapImage:RegisterSizeChanged( OnMinimapImageSizeChanged ); UI.SetMinimapImageControl( Controls.MinimapImage ); @@ -1376,22 +1391,31 @@ function LateInitialize() Controls.MapPinListButton:SetHide(false); Controls.FullscreenMapButton:SetDisabled(false); Controls.FullscreenMapButton:SetHide(false); - Controls.MapSearchButton:SetDisabled(false); - Controls.MapSearchButton:SetHide(false); Controls.MapPinListButton:RegisterCallback( Mouse.eLClick, ToggleMapPinMode ); Controls.MapPinListButton:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.FullscreenMapButton:RegisterCallback( Mouse.eLClick, ShowFullscreenMap ); Controls.FullscreenMapButton:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); - Controls.MapSearchButton:RegisterCallback( Mouse.eLClick, ToggleMapSearchPanel ); - Controls.MapSearchButton:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.ToggleResourcesButton:SetHide(false); Controls.ToggleYieldsButton:SetHide(false); + + local hideSearch:boolean = not GameCapabilities.HasCapability("CAPABILITY_SEARCH_GAME_MAP"); + Controls.MapSearchButton:SetDisabled(hideSearch); + Controls.MapSearchButton:SetHide(hideSearch); + Controls.MapSearchButton:RegisterCallback( Mouse.eLClick, ToggleMapSearchPanel ); + Controls.MapSearchButton:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); end Controls.MapOptionsButton:RegisterCallback( Mouse.eLClick, ToggleMapOptionsList ); Controls.MapOptionsButton:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); Controls.MapOptionsButton:SetHide(false); + + local hideLensStack:boolean = not GameCapabilities.HasCapability("CAPABILITY_LENS_TOGGLING_UI"); + if GameConfiguration.IsWorldBuilderEditor() then + hideLensStack = true; + end + Controls.LensButton:SetHide( hideLensStack ); Controls.LensButton:RegisterCallback( Mouse.eLClick, OnToggleLensList ); Controls.LensButton:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end); + Controls.OwnerLensButton:RegisterCallback( Mouse.eLClick, ToggleOwnerLens ); Controls.TourismLensButton:RegisterCallback( Mouse.eLClick, ToggleTourismLens ); Controls.EmpireLensButton:RegisterCallback( Mouse.eLClick, ToggleEmpireLens ); diff --git a/Lenses/ModLens_Scout.lua b/Lenses/ModLens_Scout.lua index 1bea4c2..ee01a9b 100644 --- a/Lenses/ModLens_Scout.lua +++ b/Lenses/ModLens_Scout.lua @@ -82,9 +82,8 @@ local function OnUnitSelectionChanged( playerID:number, unitID:number, hexI:numb end local function OnUnitRemovedFromMap( playerID: number, unitID : number ) - local localPlayer = Game.GetLocalPlayer() local lens = {} - if playerID == localPlayer then + if playerID == Game.GetLocalPlayer() then LuaEvents.MinimapPanel_GetActiveModLens(lens) if lens[1] == LENS_NAME and AUTO_APPLY_SCOUT_LENS then ClearScoutLens() @@ -94,10 +93,13 @@ end local function OnUnitMoveComplete( playerID:number, unitID:number ) if playerID == Game.GetLocalPlayer() then - local unitType = GetUnitTypeFromIDs(playerID, unitID) - local promotionClass = GameInfo.Units[unitType].PromotionClass - if unitType then - if promotionClass == "PROMOTION_CLASS_RECON" and AUTO_APPLY_SCOUT_LENS then + local pPlayer = Game.Players[playerID] + local pUnit = pPlayer:GetUnits():FindID(unitID) + -- Ensure the unit is selected. Scout could be exploring automated + if UI.IsUnitSelected(pUnit) then + local unitType = GetUnitTypeFromIDs(playerID, unitID) + local promotionClass = GameInfo.Units[unitType].PromotionClass + if unitType and promotionClass == "PROMOTION_CLASS_RECON" and AUTO_APPLY_SCOUT_LENS then RefreshScoutLens() end end