diff --git a/Base/Assets/UI/Panels/modallenspanel.lua b/Base/Assets/UI/Panels/modallenspanel.lua
index 45202b3..d7d00cb 100644
--- a/Base/Assets/UI/Panels/modallenspanel.lua
+++ b/Base/Assets/UI/Panels/modallenspanel.lua
@@ -346,6 +346,37 @@ function AddLensEntry(lensKey:string, lensEntry:table, refreshPanel)
end
end
+-- ===========================================================================
+function RefreshLensKey(lensKey:string)
+ ResetKeyStackIM();
+ ShowModLensKey(lensKey);
+end
+
+-- ===========================================================================
+function ML_SettingsPanelClosed()
+ -- Get the active lens and refresh it, updating any color changes made
+ local activeModLens = {};
+ LuaEvents.MinimapPanel_GetActiveModLens(activeModLens);
+ if (activeModLens[1] ~= nil and activeModLens[1] ~= "NONE") then
+ if (UILens.IsLensActive("Appeal")) then
+ -- Lens is enabled via the Lenses list
+ RefreshLensKey(activeModLens[1]);
+ -- Turn off and Turn on the Appeal Lens to refresh the colors
+ UILens.SetActive("Default");
+ LuaEvents.MinimapPanel_SetActiveModLens(activeModLens[1]);
+ -- Appeal is used for all of the Modded Lenses
+ UILens.SetActive("Appeal");
+ elseif (UILens.IsLensActive("Default")) then
+ -- Lens is enabled because of a selected unit (e.g. Builder, Scout)
+ local hash = UILens.CreateLensLayerHash("Hex_Coloring_Appeal_Level")
+ UILens.ToggleLayerOff(hash);
+ UILens.ToggleLayerOn(hash);
+ else
+ print("!! ERROR: ActiveModLens is "..tostring(activeModLens[1]).." but UILens is not Appeal or Default!");
+ end
+ end
+end
+
-- ===========================================================================
function LateInitialize()
if (Game.GetLocalPlayer() == -1) then
@@ -359,6 +390,8 @@ function LateInitialize()
-- Mod Lens Support
LuaEvents.ModalLensPanel_AddLensEntry.Add( AddLensEntry )
+ -- Support for updating Mod Lens Colors
+ LuaEvents.ML_SettingsPanelClosed.Add( ML_SettingsPanelClosed );
LuaEvents.MinimapPanel_AddContinentColorPair.Add(OnAddContinentColorPair);
end
diff --git a/Lenses/Archaeologist/ModLens_Archaeologist.lua b/Lenses/Archaeologist/ModLens_Archaeologist.lua
index 76a92c4..fd578a9 100644
--- a/Lenses/Archaeologist/ModLens_Archaeologist.lua
+++ b/Lenses/Archaeologist/ModLens_Archaeologist.lua
@@ -1,8 +1,23 @@
+include("LensSupport")
local LENS_NAME = "ML_ARCHAEOLOGIST"
local ML_LENS_LAYER = UILens.CreateLensLayerHash("Hex_Coloring_Appeal_Level")
+local m_LensSettings = {
+ ["COLOR_ARCHAEOLOGIST_LENS_ARTIFACT"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_ARCHAEOLOGIST_LENS_ARTIFACT"), KeyLabel = "LOC_HUD_ARCHAEOLOGIST_LENS_ARTIFACT" },
+ ["COLOR_ARCHAEOLOGIST_LENS_SHIPWRECK"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_ARCHAEOLOGIST_LENS_SHIPWRECK"), KeyLabel = "LOC_HUD_ARCHAEOLOGIST_LENS_SHIPWRECK" }
+}
+
-- Should the archaeologist lens auto apply, when a archaeologist is selected.
-local AUTO_APPLY_ARCHEOLOGIST_LENS:boolean = false
+local AUTO_APPLY_ARCHAEOLOGIST_LENS:boolean = false
+
+local function ML_OnSettingsInitialized()
+ -- NOTE: Setting to control auto-applying the Archaeologist lens is missing?
+ UpdateLensConfiguredColors(m_LensSettings, g_ModLensModalPanel, LENS_NAME);
+end
+
+local function ML_OnSettingsUpdate()
+ ML_OnSettingsInitialized();
+end
-- ===========================================================================
-- Archaeologist Lens Support
@@ -34,8 +49,8 @@ local function OnGetColorPlotTable()
local pPlayer:table = Players[localPlayer]
local localPlayerVis:table = PlayersVisibility[localPlayer]
- local AntiquityColor = UI.GetColorValue("COLOR_ARTIFACT_ARCH_LENS")
- local ShipwreckColor = UI.GetColorValue("COLOR_SHIPWRECK_ARCH_LENS")
+ local AntiquityColor = m_LensSettings["COLOR_ARCHAEOLOGIST_LENS_ARTIFACT"].ConfiguredColor
+ local ShipwreckColor = m_LensSettings["COLOR_ARCHAEOLOGIST_LENS_SHIPWRECK"].ConfiguredColor
local IgnoreColor = UI.GetColorValue("COLOR_MORELENSES_GREY")
local colorPlot = {}
colorPlot[AntiquityColor] = {}
@@ -81,12 +96,12 @@ local function OnUnitSelectionChanged( playerID:number, unitID:number, hexI:numb
local unitType = GetUnitTypeFromIDs(playerID, unitID)
if unitType then
if bSelected then
- if unitType == "UNIT_ARCHAEOLOGIST" and AUTO_APPLY_ARCHEOLOGIST_LENS then
+ if unitType == "UNIT_ARCHAEOLOGIST" and AUTO_APPLY_ARCHAEOLOGIST_LENS then
ShowArchaeologistLens()
end
-- Deselection
else
- if unitType == "UNIT_ARCHAEOLOGIST" and AUTO_APPLY_ARCHEOLOGIST_LENS then
+ if unitType == "UNIT_ARCHAEOLOGIST" and AUTO_APPLY_ARCHAEOLOGIST_LENS then
ClearArchaeologistLens()
end
end
@@ -99,7 +114,7 @@ local function OnUnitRemovedFromMap( playerID: number, unitID : number )
local lens = {}
LuaEvents.MinimapPanel_GetActiveModLens(lens)
if playerID == localPlayer then
- if lens[1] == LENS_NAME and AUTO_APPLY_ARCHEOLOGIST_LENS then
+ if lens[1] == LENS_NAME and AUTO_APPLY_ARCHAEOLOGIST_LENS then
ClearArchaeologistLens()
end
end
@@ -110,7 +125,7 @@ function OnUnitCaptured( currentUnitOwner, unit, owningPlayer, capturingPlayer )
local localPlayer = Game.GetLocalPlayer()
if owningPlayer == localPlayer then
local unitType = GetUnitTypeFromIDs(owningPlayer, unitID)
- if unitType and unitType == "UNIT_ARCHAEOLOGIST" and AUTO_APPLY_ARCHEOLOGIST_LENS then
+ if unitType and unitType == "UNIT_ARCHAEOLOGIST" and AUTO_APPLY_ARCHAEOLOGIST_LENS then
ClearArchaeologistLens()
end
end
@@ -139,7 +154,11 @@ if g_ModLensModalPanel ~= nil then
g_ModLensModalPanel[LENS_NAME] = {}
g_ModLensModalPanel[LENS_NAME].LensTextKey = "LOC_HUD_ARCHAEOLOGIST_LENS"
g_ModLensModalPanel[LENS_NAME].Legend = {
- {"LOC_TOOLTIP_ARCHAEOLOGIST_LENS_ARTIFACT", UI.GetColorValue("COLOR_ARTIFACT_ARCH_LENS")},
- {"LOC_TOOLTIP_ARCHAEOLOGIST_LENS_SHIPWRECK", UI.GetColorValue("COLOR_SHIPWRECK_ARCH_LENS")}
+ {m_LensSettings["COLOR_ARCHAEOLOGIST_LENS_ARTIFACT"].KeyLabel, m_LensSettings["COLOR_ARCHAEOLOGIST_LENS_ARTIFACT"].ConfiguredColor},
+ {m_LensSettings["COLOR_ARCHAEOLOGIST_LENS_SHIPWRECK"].KeyLabel, m_LensSettings["COLOR_ARCHAEOLOGIST_LENS_SHIPWRECK"].ConfiguredColor}
}
end
+
+-- Add ML LuaEvent Hooks for minimappanel and modallenspanel contexts
+LuaEvents.ML_SettingsUpdate.Add(ML_OnSettingsUpdate);
+LuaEvents.ML_SettingsInitialized.Add(ML_OnSettingsInitialized);
diff --git a/Lenses/Barbarian/ModLens_Barbarian.lua b/Lenses/Barbarian/ModLens_Barbarian.lua
index 251534d..ff917a6 100644
--- a/Lenses/Barbarian/ModLens_Barbarian.lua
+++ b/Lenses/Barbarian/ModLens_Barbarian.lua
@@ -1,6 +1,11 @@
+include("LensSupport")
local LENS_NAME = "ML_BARBARIAN"
local ML_LENS_LAYER = UILens.CreateLensLayerHash("Hex_Coloring_Appeal_Level")
+local m_LensSettings = {
+ ["COLOR_BARBARIAN_LENS_ENCAMPMENT"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_BARBARIAN_LENS_ENCAMPMENT"), KeyLabel = "LOC_HUD_BARBARIAN_LENS_ENCAMPMENT" }
+}
+
-- ===========================================================================
-- Barbarian Lens Support
-- ===========================================================================
@@ -22,7 +27,7 @@ local function OnGetColorPlotTable()
local localPlayer :number = Game.GetLocalPlayer()
local localPlayerVis:table = PlayersVisibility[localPlayer]
- local BarbarianColor = UI.GetColorValue("COLOR_BARBARIAN_BARB_LENS")
+ local BarbarianColor = m_LensSettings["COLOR_BARBARIAN_LENS_ENCAMPMENT"].ConfiguredColor
local IgnoreColor = UI.GetColorValue("COLOR_MORELENSES_GREY")
local colorPlot:table = {}
colorPlot[BarbarianColor] = {}
@@ -58,6 +63,7 @@ end
local function OnInitialize()
-- Nothing to do
end
+
]]
local BarbarianLensEntry = {
@@ -67,6 +73,16 @@ local BarbarianLensEntry = {
GetColorPlotTable = OnGetColorPlotTable
}
+-- ===========================================================================
+local function ML_OnSettingsInitialized()
+ UpdateLensConfiguredColors(m_LensSettings, g_ModLensModalPanel, LENS_NAME);
+end
+
+-- ===========================================================================
+local function ML_OnSettingsUpdate()
+ ML_OnSettingsInitialized();
+end
+
-- minimappanel.lua
if g_ModLenses ~= nil then
g_ModLenses[LENS_NAME] = BarbarianLensEntry
@@ -77,6 +93,10 @@ if g_ModLensModalPanel ~= nil then
g_ModLensModalPanel[LENS_NAME] = {}
g_ModLensModalPanel[LENS_NAME].LensTextKey = "LOC_HUD_BARBARIAN_LENS"
g_ModLensModalPanel[LENS_NAME].Legend = {
- {"LOC_TOOLTIP_BARBARIAN_LENS_ENCAPMENT", UI.GetColorValue("COLOR_BARBARIAN_BARB_LENS")}
+ {m_LensSettings["COLOR_BARBARIAN_LENS_ENCAMPMENT"].KeyLabel, m_LensSettings["COLOR_BARBARIAN_LENS_ENCAMPMENT"].ConfiguredColor}
}
end
+
+-- Add ML LuaEvent Hooks for minimappanel and modallenspanel contexts
+LuaEvents.ML_SettingsUpdate.Add(ML_OnSettingsUpdate);
+LuaEvents.ML_SettingsInitialized.Add(ML_OnSettingsInitialized);
\ No newline at end of file
diff --git a/Lenses/Builder/BuilderLens_Config_Default.lua b/Lenses/Builder/BuilderLens_Config_Default.lua
index 75693e1..6623044 100644
--- a/Lenses/Builder/BuilderLens_Config_Default.lua
+++ b/Lenses/Builder/BuilderLens_Config_Default.lua
@@ -1,6 +1,5 @@
include("BuilderLens_Support")
-
-- From GovernorSupport.lua
-- modified to catch unappointed errors
function GetAppointedGovernor(playerID:number, governorTypeIndex:number)
@@ -34,26 +33,14 @@ end
-- Add rules for builder lens
-- ===========================================================================
-local m_BuilderLens_PN = UI.GetColorValue("COLOR_BUILDER_LENS_PN")
-local m_BuilderLens_PD = UI.GetColorValue("COLOR_BUILDER_LENS_PD")
-local m_BuilderLens_P1 = UI.GetColorValue("COLOR_BUILDER_LENS_P1")
-local m_BuilderLens_P1N = UI.GetColorValue("COLOR_BUILDER_LENS_P1N")
-local m_BuilderLens_P2 = UI.GetColorValue("COLOR_BUILDER_LENS_P2")
-local m_BuilderLens_P3 = UI.GetColorValue("COLOR_BUILDER_LENS_P3")
-local m_BuilderLens_P4 = UI.GetColorValue("COLOR_BUILDER_LENS_P4")
-local m_BuilderLens_P5 = UI.GetColorValue("COLOR_BUILDER_LENS_P5")
-local m_BuilderLens_P6 = UI.GetColorValue("COLOR_BUILDER_LENS_P6")
-local m_BuilderLens_P7 = UI.GetColorValue("COLOR_BUILDER_LENS_P7")
-
-
-- NATIONAL PARK
--------------------------------------
-table.insert(g_ModLenses_Builder_Config[m_BuilderLens_PN],
+table.insert(GetConfigRules("COLOR_BUILDER_LENS_PN"),
function(pPlot)
local localPlayer = Game.GetLocalPlayer()
if pPlot:GetOwner() == localPlayer then
if pPlot:IsNationalPark() then
- return m_BuilderLens_PN
+ return GetColorForNothingPlot()
end
end
return -1
@@ -62,7 +49,7 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_PN],
-- RESOURCE
--------------------------------------
-table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P1],
+table.insert(GetConfigRules("COLOR_BUILDER_LENS_P1"),
function(pPlot)
local localPlayer = Game.GetLocalPlayer()
local pPlayer:table = Players[localPlayer]
@@ -70,22 +57,22 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P1],
if playerHasDiscoveredResource(pPlayer, pPlot) then
if plotHasImprovement(pPlot) then
if plotHasCorrectImprovement(pPlot) then
- return m_BuilderLens_PN
+ return GetColorForNothingPlot()
end
end
if plotResourceImprovable(pPlayer, pPlot) then
-- If the plot is within working range go ahead with correct highlight
if plotWithinWorkingRange(pPlayer, pPlot) then
- return m_BuilderLens_P1
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P1")
else
-- If the plot is outside working range, it is less important
-- We still might want to suggest it because of vital strategic resource / luxury, or a unique wonder
-- that can provide bonuses to it example (Temple of Artemis)
- return m_BuilderLens_P1N
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P1N")
end
else
- return m_BuilderLens_PN
+ return GetColorForNothingPlot()
end
end
end
@@ -96,7 +83,7 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P1],
-- GEOTHERMAL PLANTS (Only add if exists)
--------------------------------------
if GameInfo.Improvements["IMPROVEMENT_GEOTHERMAL_PLANT"] ~= nil then
- table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P2],
+ table.insert(GetConfigRules("COLOR_BUILDER_LENS_P2"),
function(pPlot)
local localPlayer = Game.GetLocalPlayer()
local pPlayer:table = Players[localPlayer]
@@ -107,7 +94,7 @@ if GameInfo.Improvements["IMPROVEMENT_GEOTHERMAL_PLANT"] ~= nil then
if featureInfo.FeatureType == "FEATURE_GEOTHERMAL_FISSURE" then
local plantImprovInfo = GameInfo.Improvements["IMPROVEMENT_GEOTHERMAL_PLANT"]
if playerCanHave(pPlayer, plantImprovInfo) then
- return m_BuilderLens_P2
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P2")
end
end
end
@@ -117,7 +104,7 @@ end
-- SEASIDE RESORTS
--------------------------------------
-table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P2],
+table.insert(GetConfigRules("COLOR_BUILDER_LENS_P2"),
function(pPlot)
local localPlayer = Game.GetLocalPlayer()
local pPlayer:table = Players[localPlayer]
@@ -128,7 +115,7 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P2],
and pPlot:GetImprovementType() ~= resortImprovInfo.Index then
if plotCanHaveImprovement(pPlayer, pPlot, resortImprovInfo) then
- return m_BuilderLens_P2
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P2")
end
end
end)
@@ -137,7 +124,7 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P2],
-- SKI RESORTS (Only add if exists)
--------------------------------------
if GameInfo.Improvements["IMPROVEMENT_SKI_RESORT"] ~= nil then
- table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P2],
+ table.insert(GetConfigRules("COLOR_BUILDER_LENS_P2"),
function(pPlot)
local localPlayer = Game.GetLocalPlayer()
local pPlayer:table = Players[localPlayer]
@@ -147,7 +134,7 @@ if GameInfo.Improvements["IMPROVEMENT_SKI_RESORT"] ~= nil then
local resortImprovInfo = GameInfo.Improvements["IMPROVEMENT_SKI_RESORT"]
if plotCanHaveImprovement(pPlayer, pPlot, resortImprovInfo)
and not plotHasAdjImprovement(pPlot, "IMPROVEMENT_SKI_RESORT") then
- return m_BuilderLens_P2
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P2")
end
end
end)
@@ -156,12 +143,12 @@ end
-- PILLAGED / UA
--------------------------------------
-table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P2],
+table.insert(GetConfigRules("COLOR_BUILDER_LENS_P2"),
function(pPlot)
local localPlayer = Game.GetLocalPlayer()
if pPlot:GetOwner() == localPlayer and not plotHasDistrict(pPlot) then
if plotHasImprovement(pPlot) and pPlot:IsImprovementPillaged() then
- return m_BuilderLens_P2
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P2")
end
end
return -1
@@ -170,33 +157,33 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P2],
-- IGNORE PLOTS (Performance optimizations)
--------------------------------------
-table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P3],
+table.insert(GetConfigRules("COLOR_BUILDER_LENS_P3"),
function(pPlot)
-- Non local player plots
local localPlayer = Game.GetLocalPlayer()
if pPlot:GetOwner() ~= localPlayer then
- return -2 -- special flag to completely ignore coloring
+ return GetIgnorePlotColor() -- special flag to completely ignore coloring
end
-- Districts. Assume unique abilities are handled earlier (P2 typically)
if plotHasDistrict(pPlot) then
- return m_BuilderLens_PN
+ return GetColorForNothingPlot()
end
-- If an improvement is here, assume we are done with this plot
if plotHasImprovement(pPlot) then
- return m_BuilderLens_PN
+ return GetColorForNothingPlot()
end
-- Mountains or impassable wonders
if pPlot:IsImpassable() then
- return m_BuilderLens_PN
+ return GetColorForNothingPlot()
end
-- Outside of working range can be ignored from here on out
local pPlayer:table = Players[localPlayer]
if not plotWithinWorkingRange(pPlayer, pPlot) then
- return m_BuilderLens_PN
+ return GetColorForNothingPlot()
end
end)
@@ -204,7 +191,7 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P3],
-- RECOMMENDED PLOTS
--------------------------------------
-- These are generic plots, but have some buff on it that can make it desirable to improve
-table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P3],
+table.insert(GetConfigRules("COLOR_BUILDER_LENS_P3"),
function(pPlot)
local localPlayer = Game.GetLocalPlayer()
local pPlayer:table = Players[localPlayer]
@@ -212,7 +199,7 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P3],
if plotHasFeature(pPlot) then
local featureInfo = GameInfo.Features[pPlot:GetFeatureType()]
if featureInfo.NaturalWonder then
- return m_BuilderLens_PN
+ return GetColorForNothingPlot()
end
-- 1. Non-hill woods next to river (lumbermill)
@@ -222,7 +209,7 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P3],
and featureInfo.FeatureType == "FEATURE_FOREST" and pPlot:IsRiver()
and playerCanHave(pPlayer, lumberImprovInfo) then
- return m_BuilderLens_P3
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P3")
end
-- 2. Floodplains
@@ -230,7 +217,7 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P3],
local farmImprovInfo = GameInfo.Improvements["IMPROVEMENT_FARM"]
local spitResult = Split(featureInfo.FeatureType, "_")
if #spitResult > 1 and spitResult[2] == "FLOODPLAINS" and playerCanHave(pPlayer, farmImprovInfo) then
- return m_BuilderLens_P3
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P3")
end
]]
@@ -238,18 +225,18 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P3],
-- 3. Volconic soil or tile next to buffing wonder
if featureInfo.FeatureType == "FEATURE_VOLCANIC_SOIL" and canHaveImpr then
- return m_BuilderLens_P3
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P3")
end
-- 4. Wonder buffed tile
if plotNextToBuffingWonder(pPlot) and canHaveImpr then
- return m_BuilderLens_P3
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P3")
end
end
-- 5. Currently worked tile that does not have a improvement but can have one
if plotWorkedByCitizen(pPlot) and plotCanHaveSomeImprovement(pPlayer, pPlot) then
- return m_BuilderLens_P3
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P3")
end
return -1
end)
@@ -258,12 +245,12 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P3],
-- HILLS
--------------------------------------
-- Typically hills have a base +1 Production hence any improvement on top of it is desirable
-table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P4],
+table.insert(GetConfigRules("COLOR_BUILDER_LENS_P4"),
function(pPlot)
local localPlayer = Game.GetLocalPlayer()
local pPlayer:table = Players[localPlayer]
if pPlot:IsHills() and plotCanHaveSomeImprovement(pPlayer, pPlot) then
- return m_BuilderLens_P4
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P4")
end
return -1
end)
@@ -271,12 +258,12 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P4],
-- EXTRACTABLE FEATURE
--------------------------------------
-table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P5],
+table.insert(GetConfigRules("COLOR_BUILDER_LENS_P5"),
function(pPlot)
local localPlayer = Game.GetLocalPlayer()
local pPlayer:table = Players[localPlayer]
if plotHasYieldExtractingFeature(pPlayer, pPlot) then
- return m_BuilderLens_P5
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P5")
end
return -1
end)
@@ -284,16 +271,16 @@ table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P5],
-- GENERIC (Last rule)
--------------------------------------
-table.insert(g_ModLenses_Builder_Config[m_BuilderLens_P7],
+table.insert(GetConfigRules("COLOR_BUILDER_LENS_P7"),
function(pPlot)
local localPlayer = Game.GetLocalPlayer()
local pPlayer:table = Players[localPlayer]
-- Can we build any improvement add it here
if plotCanHaveSomeImprovement(pPlayer, pPlot) then
- return m_BuilderLens_P7
+ return GetConfiguredColor("COLOR_BUILDER_LENS_P7")
end
-- Assume at this point we can't do anything
- return m_BuilderLens_PN
+ return GetColorForNothingPlot()
end)
diff --git a/Lenses/Builder/BuilderLens_Support.lua b/Lenses/Builder/BuilderLens_Support.lua
index aa6ee8c..4cbf8fd 100644
--- a/Lenses/Builder/BuilderLens_Support.lua
+++ b/Lenses/Builder/BuilderLens_Support.lua
@@ -1,5 +1,3 @@
-include("LensSupport")
-
-- ===========================================================================
-- Helpers
-- ===========================================================================
@@ -419,7 +417,7 @@ function plotHasCorrectImprovement(pPlot:table)
end
function plotWorkedByCitizen(pPlot:table)
- print("Checking worked by for " .. pPlot:GetIndex())
+ -- print("Checking worked by for " .. pPlot:GetIndex())
return pPlot:GetWorkerCount() > 0
end
diff --git a/Lenses/Builder/ModLens_Builder.lua b/Lenses/Builder/ModLens_Builder.lua
index 6f0c887..560cf07 100644
--- a/Lenses/Builder/ModLens_Builder.lua
+++ b/Lenses/Builder/ModLens_Builder.lua
@@ -1,54 +1,82 @@
include("LensSupport")
-
-local m_BuilderLens_PN = UI.GetColorValue("COLOR_BUILDER_LENS_PN")
-local m_BuilderLens_PD = UI.GetColorValue("COLOR_BUILDER_LENS_PD")
-local m_BuilderLens_P1 = UI.GetColorValue("COLOR_BUILDER_LENS_P1")
-local m_BuilderLens_P1N = UI.GetColorValue("COLOR_BUILDER_LENS_P1N")
-local m_BuilderLens_P2 = UI.GetColorValue("COLOR_BUILDER_LENS_P2")
-local m_BuilderLens_P3 = UI.GetColorValue("COLOR_BUILDER_LENS_P3")
-local m_BuilderLens_P4 = UI.GetColorValue("COLOR_BUILDER_LENS_P4")
-local m_BuilderLens_P5 = UI.GetColorValue("COLOR_BUILDER_LENS_P5")
-local m_BuilderLens_P6 = UI.GetColorValue("COLOR_BUILDER_LENS_P6")
-local m_BuilderLens_P7 = UI.GetColorValue("COLOR_BUILDER_LENS_P7")
-
-local m_FallbackColor = m_BuilderLens_PN
-
-local m_ModLenses_Builder_Priority = {
- m_BuilderLens_PN,
- m_BuilderLens_PD,
- m_BuilderLens_P1,
- m_BuilderLens_P2,
- m_BuilderLens_P3,
- m_BuilderLens_P4,
- m_BuilderLens_P5,
- m_BuilderLens_P6,
- m_BuilderLens_P7,
+-- Note: Include for BuilderLens_Config and BuilderLens_Support occurs below, as supporting calls need to be added first
+-- Key: PN = Nothing PD = Dangerous P1 = Resources P1N = Resources Outside Range P2 = Recommended/Pillaged/Unique
+-- P3 = Currently Worked / Wonder-Buffed P4 = Hills P5 = Feature Extraction P6 = Nothing(Disabled) P7 = General
+local m_LensSettings = {
+ ["COLOR_BUILDER_LENS_PN"] = { Index = 0x01, ConfiguredColor = GetLensColorFromSettings("COLOR_BUILDER_LENS_PN"), ConfigRules = {}, KeyLabel = "LOC_HUD_BUILDER_LENS_PN" },
+ ["COLOR_BUILDER_LENS_PD"] = { Index = 0x02, ConfiguredColor = GetLensColorFromSettings("COLOR_BUILDER_LENS_PD"), ConfigRules = {}, KeyLabel = "LOC_HUD_BUILDER_LENS_PD" },
+ ["COLOR_BUILDER_LENS_P1"] = { Index = 0x10, ConfiguredColor = GetLensColorFromSettings("COLOR_BUILDER_LENS_P1"), ConfigRules = {}, KeyLabel = "LOC_HUD_BUILDER_LENS_P1" },
+ ["COLOR_BUILDER_LENS_P1N"] = { Index = 0x11, ConfiguredColor = GetLensColorFromSettings("COLOR_BUILDER_LENS_P1N"), ConfigRules = {}, KeyLabel = "LOC_HUD_BUILDER_LENS_P1N"},
+ ["COLOR_BUILDER_LENS_P2"] = { Index = 0x20, ConfiguredColor = GetLensColorFromSettings("COLOR_BUILDER_LENS_P2"), ConfigRules = {}, KeyLabel = "LOC_HUD_BUILDER_LENS_P2" },
+ ["COLOR_BUILDER_LENS_P3"] = { Index = 0x30, ConfiguredColor = GetLensColorFromSettings("COLOR_BUILDER_LENS_P3"), ConfigRules = {}, KeyLabel = "LOC_HUD_BUILDER_LENS_P3" },
+ ["COLOR_BUILDER_LENS_P4"] = { Index = 0x40, ConfiguredColor = GetLensColorFromSettings("COLOR_BUILDER_LENS_P4"), ConfigRules = {}, KeyLabel = "LOC_HUD_BUILDER_LENS_P4" },
+ ["COLOR_BUILDER_LENS_P5"] = { Index = 0x50, ConfiguredColor = GetLensColorFromSettings("COLOR_BUILDER_LENS_P5"), ConfigRules = {}, KeyLabel = "LOC_HUD_BUILDER_LENS_P5" },
+ ["COLOR_BUILDER_LENS_P6"] = { Index = 0x60, ConfiguredColor = GetLensColorFromSettings("COLOR_BUILDER_LENS_P6"), ConfigRules = {}, KeyLabel = "LOC_HUD_BUILDER_LENS_P6" },
+ ["COLOR_BUILDER_LENS_P7"] = { Index = 0x70, ConfiguredColor = GetLensColorFromSettings("COLOR_BUILDER_LENS_P7"), ConfigRules = {}, KeyLabel = "LOC_HUD_BUILDER_LENS_P7" }
}
-g_ModLenses_Builder_Config = {
- [m_BuilderLens_PN] = {},
- [m_BuilderLens_PD] = {},
- [m_BuilderLens_P1] = {},
- [m_BuilderLens_P2] = {},
- [m_BuilderLens_P3] = {},
- [m_BuilderLens_P4] = {},
- [m_BuilderLens_P5] = {},
- [m_BuilderLens_P6] = {},
- [m_BuilderLens_P7] = {},
-}
+local m_LensSettings_SortedIndexMap = {}
+for k,v in pairs(m_LensSettings) do
+ table.insert(m_LensSettings_SortedIndexMap, {Index = m_LensSettings[k].Index, Key = k});
+end
+table.sort(m_LensSettings_SortedIndexMap, function(a,b) return a.Index < b.Index end)
+
+local DISABLE_NOTHING_PLOT_HIGHLIGHT:boolean = true;
+local AUTO_APPLY_BUILDER_LENS:boolean = true;
+local DISABLE_DANGEROUS_PLOT_HIGHLIGHT:boolean = false;
+local IGNORE_PLOT_COLOR:number = -2
+
+-- ==== Functions called by the "include" Files
+-- ===========================================================================
+function GetColorForNothingPlot()
+ if DISABLE_NOTHING_PLOT_HIGHLIGHT then
+ return IGNORE_PLOT_COLOR;
+ else
+ return m_LensSettings["COLOR_BUILDER_LENS_PN"].ConfiguredColor;
+ end
+end
+
+-- ===========================================================================
+function GetIgnorePlotColor()
+ return IGNORE_PLOT_COLOR;
+end
+
+-- ===========================================================================
+function GetConfigRules(lensName)
+ return m_LensSettings[lensName].ConfigRules;
+end
+-- ===========================================================================
+function GetConfiguredColor(lensName)
+ return m_LensSettings[lensName].ConfiguredColor;
+end
+
+-- ===========================================================================
-- Import config files for builder lens
include("BuilderLens_Config_", true)
+-- ===========================================================================
local LENS_NAME = "ML_BUILDER"
local ML_LENS_LAYER = UILens.CreateLensLayerHash("Hex_Coloring_Appeal_Level")
--- Should the builder lens auto apply, when a builder is selected.
-local AUTO_APPLY_BUILDER_LENS:boolean = GameConfiguration.GetValue("ML_AutoApplyBuilderLens")
--- Disables the nothing color being highlted by the builder
-local DISABLE_NOTHING_PLOT_HIGHLIGHT:boolean = GameConfiguration.GetValue("ML_BuilderLensDisableNothingHighlight")
--- Disables the dangerous plots highlted by the builder (barbs/military units at war with)
-local DISABLE_DANGEROUS_PLOT_HIGHLIGHT:boolean = GameConfiguration.GetValue("ML_BuilderLensDisableDangerousHighlight")
+-- ===========================================================================
+local function ML_OnSettingsInitialized()
+ -- Should the builder lens auto apply, when a builder is selected.
+ AUTO_APPLY_BUILDER_LENS = GameConfiguration.GetValue("ML_AutoApplyBuilderLens");
+ -- Disables the nothing color being highlted by the builder
+ DISABLE_NOTHING_PLOT_HIGHLIGHT = GameConfiguration.GetValue("ML_BuilderLensDisableNothingHighlight");
+ -- Disables the dangerous plots highlted by the builder (barbs/military units at war with)
+ DISABLE_DANGEROUS_PLOT_HIGHLIGHT = GameConfiguration.GetValue("ML_BuilderLensDisableDangerousHighlight");
+ print(AUTO_APPLY_BUILDER_LENS)
+ print(DISABLE_NOTHING_PLOT_HIGHLIGHT)
+ print(DISABLE_DANGEROUS_PLOT_HIGHLIGHT)
+ UpdateLensConfiguredColors(m_LensSettings, g_ModLensModalPanel, LENS_NAME);
+end
+
+-- ===========================================================================
+local function ML_OnSettingsUpdate()
+ ML_OnSettingsInitialized();
+end
-- ===========================================================================
-- Exported functions
@@ -63,7 +91,8 @@ local function OnGetColorPlotTable()
local colorPlot:table = {}
local dangerousPlotsHash:table = {}
- colorPlot[m_FallbackColor] = {}
+ local fallbackColorIndex = m_LensSettings["COLOR_BUILDER_LENS_PN"].Index;
+ colorPlot[fallbackColorIndex] = {}
if not DISABLE_DANGEROUS_PLOT_HIGHLIGHT then
-- Make hash of all dangerous plots
@@ -107,15 +136,15 @@ local function OnGetColorPlotTable()
local pPlot:table = Map.GetPlotByIndex(i)
if dangerousPlotsHash[i] == nil and localPlayerVis:IsRevealed(pPlot:GetX(), pPlot:GetY()) then
local bPlotColored:boolean = false
- for _, color in ipairs(m_ModLenses_Builder_Priority) do
- config = g_ModLenses_Builder_Config[color]
+ for _, lensEntry in ipairs(m_LensSettings_SortedIndexMap) do
+ config = m_LensSettings[lensEntry.Key].ConfigRules
if config ~= nil and table.count(config) > 0 then
for _, rule in ipairs(config) do
if rule ~= nil then
ruleColor = rule(pPlot)
if ruleColor ~= nil and ruleColor ~= -1 then
-- Catch special flag that says to completely ignore coloring
- if ruleColor == -2 then
+ if ruleColor == IGNORE_PLOT_COLOR then
bPlotColored = true
break
end
@@ -138,20 +167,17 @@ local function OnGetColorPlotTable()
end
if not bPlotColored and pPlot:GetOwner() == localPlayer then
- table.insert(colorPlot[m_FallbackColor], i)
+ table.insert(colorPlot[fallbackColorIndex], i)
end
end
end
- if DISABLE_NOTHING_PLOT_HIGHLIGHT then
- colorPlot[m_BuilderLens_PN] = nil
- end
-
if not DISABLE_DANGEROUS_PLOT_HIGHLIGHT then
-- From hash build our colorPlot entry
- colorPlot[m_BuilderLens_PD] = {}
+ local pdLensIndex = m_LensSettings["COLOR_BUILDER_LENS_PD"].Index;
+ colorPlot[pdLensIndex] = {}
for iPlot, _ in pairs(dangerousPlotsHash) do
- table.insert(colorPlot[m_BuilderLens_PD], iPlot)
+ table.insert(colorPlot[pdLensIndex], iPlot)
end
end
@@ -219,22 +245,11 @@ local function OnUnitRemovedFromMap( playerID: number, unitID : number )
end
end
-local function OnLensSettingsUpdate()
- -- Refresh our local settings from updated GameConfig
- AUTO_APPLY_BUILDER_LENS = GameConfiguration.GetValue("ML_AutoApplyBuilderLens")
- DISABLE_NOTHING_PLOT_HIGHLIGHT = GameConfiguration.GetValue("ML_BuilderLensDisableNothingHighlight")
- DISABLE_DANGEROUS_PLOT_HIGHLIGHT = GameConfiguration.GetValue("ML_BuilderLensDisableDangerousHighlight")
- print(AUTO_APPLY_BUILDER_LENS)
- print(DISABLE_NOTHING_PLOT_HIGHLIGHT)
- print(DISABLE_DANGEROUS_PLOT_HIGHLIGHT)
-end
-
local function OnInitialize()
Events.UnitSelectionChanged.Add( OnUnitSelectionChanged );
Events.UnitCaptured.Add( OnUnitCaptured );
Events.UnitChargesChanged.Add( OnUnitChargesChanged );
Events.UnitRemovedFromMap.Add( OnUnitRemovedFromMap );
- LuaEvents.ML_SettingsUpdate.Add( OnLensSettingsUpdate )
end
local BuilderLensEntry = {
@@ -253,18 +268,16 @@ end
if g_ModLensModalPanel ~= nil then
g_ModLensModalPanel[LENS_NAME] = {}
g_ModLensModalPanel[LENS_NAME].LensTextKey = "LOC_HUD_BUILDER_LENS"
-
- -- TODO: Make this automatic based on added rules
- g_ModLensModalPanel[LENS_NAME].Legend = {
- {"LOC_HUD_BUILDER_LENS_PN", m_BuilderLens_PN},
- {"LOC_HUD_BUILDER_LENS_PD", m_BuilderLens_PD},
- {"LOC_HUD_BUILDER_LENS_P1", m_BuilderLens_P1},
- {"LOC_HUD_BUILDER_LENS_P1N", m_BuilderLens_P1N},
- {"LOC_HUD_BUILDER_LENS_P2", m_BuilderLens_P2},
- {"LOC_HUD_BUILDER_LENS_P3", m_BuilderLens_P3},
- {"LOC_HUD_BUILDER_LENS_P4", m_BuilderLens_P4},
- {"LOC_HUD_BUILDER_LENS_P5", m_BuilderLens_P5},
- -- {"LOC_HUD_BUILDER_LENS_P6", m_BuilderLens_P6},
- {"LOC_HUD_BUILDER_LENS_P7", m_BuilderLens_P7},
- }
+ g_ModLensModalPanel[LENS_NAME].Legend = {}
+ -- Insert in priority order and only those with Rules that do coloring
+ for _,lensInfo in ipairs(m_LensSettings_SortedIndexMap) do
+ local lensData = m_LensSettings[lensInfo.Key];
+ if (#lensData.ConfigRules > 0) then
+ table.insert(g_ModLensModalPanel[LENS_NAME].Legend, {lensData.KeyLabel, lensData.ConfiguredColor});
+ end
+ end
end
+
+-- Add ML LuaEvent Hooks for minimappanel and modallenspanel contexts
+LuaEvents.ML_SettingsUpdate.Add(ML_OnSettingsUpdate);
+LuaEvents.ML_SettingsInitialized.Add(ML_OnSettingsInitialized);
diff --git a/Lenses/CityOverlap/ModLens_CityOverlap.lua b/Lenses/CityOverlap/ModLens_CityOverlap.lua
index e6c039c..987beaa 100644
--- a/Lenses/CityOverlap/ModLens_CityOverlap.lua
+++ b/Lenses/CityOverlap/ModLens_CityOverlap.lua
@@ -16,6 +16,18 @@ local m_isOpen:boolean = false
local m_cityOverlapRange:number = DEFAULT_OVERLAP_RANGE
local m_currentCursorPlotID:number = -1
+local m_LensSettings = {
+ -- Note the special case handling with the KeyLabel
+ ["COLOR_CITYOVERLAP_LENS_1"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_CITYOVERLAP_LENS_1"), KeyLabel = "LOC_WORLDBUILDER_TAB_CITIES".." +1" },
+ ["COLOR_CITYOVERLAP_LENS_2"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_CITYOVERLAP_LENS_2"), KeyLabel = "LOC_WORLDBUILDER_TAB_CITIES".." +2" },
+ ["COLOR_CITYOVERLAP_LENS_3"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_CITYOVERLAP_LENS_3"), KeyLabel = "LOC_WORLDBUILDER_TAB_CITIES".." +3" },
+ ["COLOR_CITYOVERLAP_LENS_4"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_CITYOVERLAP_LENS_4"), KeyLabel = "LOC_WORLDBUILDER_TAB_CITIES".." +4" },
+ ["COLOR_CITYOVERLAP_LENS_5"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_CITYOVERLAP_LENS_5"), KeyLabel = "LOC_WORLDBUILDER_TAB_CITIES".." +5" },
+ ["COLOR_CITYOVERLAP_LENS_6"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_CITYOVERLAP_LENS_6"), KeyLabel = "LOC_WORLDBUILDER_TAB_CITIES".." +6" },
+ ["COLOR_CITYOVERLAP_LENS_7"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_CITYOVERLAP_LENS_7"), KeyLabel = "LOC_WORLDBUILDER_TAB_CITIES".." +7" },
+ ["COLOR_CITYOVERLAP_LENS_8"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_CITYOVERLAP_LENS_8"), KeyLabel = "LOC_WORLDBUILDER_TAB_CITIES".." +8" }
+}
+
-- ===========================================================================
-- City Overlap Support functions
-- ===========================================================================
@@ -55,10 +67,11 @@ local function SetModalKey(maxCityOverlap)
local CityOverlapLensModalPanelEntry = {}
CityOverlapLensModalPanelEntry.Legend = {}
CityOverlapLensModalPanelEntry.LensTextKey = "LOC_HUD_CITYOVERLAP_LENS"
+ -- NOTE: Not using the KeyLabel here, in order to place the bonus value on the next line
for i = 1, 8 do
local params:table = {
"LOC_WORLDBUILDER_TAB_CITIES",
- UI.GetColorValue("COLOR_GRADIENT8_" .. tostring(i)),
+ m_LensSettings["COLOR_CITYOVERLAP_LENS_" .. tostring(i)].ConfiguredColor,
nil, -- bonus icon
"+ " .. tostring(i + (maxCityOverlap - 8)) -- bonus value
}
@@ -122,8 +135,8 @@ local function SetCityOverlapLens()
local relativeNumCities:number = numCityEntries[i] - cityOffset
if relativeNumCities > 0 then
- local colorLookup:string = "COLOR_GRADIENT8_" .. tostring(relativeNumCities)
- local color:number = UI.GetColorValue(colorLookup)
+ local colorLookup:string = "COLOR_CITYOVERLAP_LENS_" .. tostring(relativeNumCities)
+ local color:number = m_LensSettings[colorLookup].ConfiguredColor
UILens.SetLayerHexesColoredArea( ML_LENS_LAYER, localPlayer, {plotEntries[i]}, color )
end
end
@@ -153,12 +166,12 @@ local function SetRangeMouseLens(range)
end
if (table.count(cityPlots) > 0) then
- local plotColor:number = UI.GetColorValue("COLOR_GRADIENT8_1")
+ local plotColor:number = m_LensSettings["COLOR_CITYOVERLAP_LENS_1"].ConfiguredColor
UILens.SetLayerHexesColoredArea( ML_LENS_LAYER, localPlayer, cityPlots, plotColor )
end
if (table.count(normalPlot) > 0) then
- local plotColor:number = UI.GetColorValue("COLOR_GRADIENT8_3")
+ local plotColor:number = m_LensSettings["COLOR_CITYOVERLAP_LENS_3"].ConfiguredColor
UILens.SetLayerHexesColoredArea( ML_LENS_LAYER, localPlayer, normalPlot, plotColor )
end
end
@@ -284,6 +297,17 @@ local function OnShutdown()
end
end
+local function ML_OnSettingsInitialized()
+ -- NOTE: Do not update the g_ModLensModalPanel directly, use the local function to handle that
+ -- as it has special-case handling for the Modal Panel key text
+ UpdateLensConfiguredColors(m_LensSettings, nil, LENS_NAME);
+ SetModalKey(maxCityOverlap);
+end
+
+local function ML_OnSettingsUpdate()
+ ML_OnSettingsInitialized();
+end
+
-- ===========================================================================
-- Init
-- ===========================================================================
@@ -297,6 +321,10 @@ local CityOverlapLensEntry = {
GetColorPlotTable = nil -- Pass nil since we have our own trigger
}
+-- Add ML LuaEvent Hooks for minimappanel and modallenspanel contexts
+LuaEvents.ML_SettingsUpdate.Add(ML_OnSettingsUpdate);
+LuaEvents.ML_SettingsInitialized.Add(ML_OnSettingsInitialized);
+
-- Don't import this into g_ModLenses, since this for the UI (ie not lens)
local function Initialize()
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
diff --git a/Lenses/LensSupport.lua b/Lenses/LensSupport.lua
index 48d62ba..ee4dc5e 100644
--- a/Lenses/LensSupport.lua
+++ b/Lenses/LensSupport.lua
@@ -430,3 +430,46 @@ end
end
end
-- End of iterator code --------------------
+
+function GetLensColorFromSettings(lensName)
+ -- A lens color can be set by the ML Settings elements
+ local lensData = GameConfiguration.GetValue(lensName);
+ if (lensData == nil) then
+ lensData = GameInfo.Colors[lensName];
+ if (lensData == nil) then
+ lensData = {}
+ lensData["Red"] = 0;
+ lensData["Blue"] = 0;
+ lensData["Green"] = 0;
+ end
+
+ GameConfiguration.SetValue(lensName, lensData);
+ end
+
+ return UI.GetColorValue(lensData["Red"], lensData["Green"], lensData["Blue"]);
+end
+
+-- lensEntitiesTable is a list of Lens Entities (Colors) for that Particular Lens
+-- modLensModalPanelTable is the table used by modalpanel.lua to construct the Key table for any lens
+-- lens_name is the LENS_NAME value from that lens
+function UpdateLensConfiguredColors(lensEntitiesTable, modLensModalPanelTable, lens_name)
+ -- Called whenever we want to force the Lens Colors to be refreshed
+ -- GetLensColorFromSettings will get the value if stored by GameConfiguration.SetValue,
+ -- otherwise it will load the value from the GameInfo.Colors table that was updated by the MoreLenses SQL file
+ for lensKey, lensConfig in pairs(lensEntitiesTable) do
+ lensColor = GetLensColorFromSettings(lensKey);
+ lensEntitiesTable[lensKey].ConfiguredColor = lensColor;
+ -- Not sure there's a better way to do this and also keep the structure of g_ModLensModalPanel?
+ -- defined only by modellenspanel.lua, so only gets called when in the modellenspanel context
+ if modLensModalPanelTable ~= nil then
+ lensLegend = modLensModalPanelTable[lens_name].Legend;
+ for idx, entry in ipairs(modLensModalPanelTable[lens_name].Legend) do
+ locVal, colorVal = unpack(entry);
+ if locVal == lensEntitiesTable[lensKey].KeyLabel then
+ modLensModalPanelTable[lens_name].Legend[idx] = {lensEntitiesTable[lensKey].KeyLabel, lensColor};
+ break;
+ end
+ end
+ end
+ end
+end
diff --git a/Lenses/Naturalist/ModLens_Naturalist.lua b/Lenses/Naturalist/ModLens_Naturalist.lua
index b0aa270..ea39de1 100644
--- a/Lenses/Naturalist/ModLens_Naturalist.lua
+++ b/Lenses/Naturalist/ModLens_Naturalist.lua
@@ -3,6 +3,12 @@ include("LensSupport")
local LENS_NAME = "ML_NATURALIST"
local ML_LENS_LAYER = UILens.CreateLensLayerHash("Hex_Coloring_Appeal_Level")
+local m_LensSettings = {
+ ["COLOR_NATURALIST_LENS_PARK"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_NATURALIST_LENS_PARK"), KeyLabel = "LOC_HUD_NATURALIST_LENS_PARK" },
+ ["COLOR_NATURALIST_LENS_OK"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_NATURALIST_LENS_OK"), KeyLabel = "LOC_HUD_NATURALIST_LENS_OK" },
+ ["COLOR_NATURALIST_LENS_FIXABLE"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_NATURALIST_LENS_FIXABLE"), KeyLabel = "LOC_HUD_NATURALIST_LENS_FIXABLE" }
+}
+
-- ===========================================================================
-- Naturalist Lens Support
-- ===========================================================================
@@ -36,9 +42,9 @@ local function OnGetColorPlotTable()
local localPlayer:number = Game.GetLocalPlayer()
local localPlayerVis:table = PlayersVisibility[localPlayer]
- local parkPlotColor:number = UI.GetColorValue("COLOR_PARK_NATURALIST_LENS")
- local OkColor:number = UI.GetColorValue("COLOR_OK_NATURALIST_LENS")
- local FixableColor:number = UI.GetColorValue("COLOR_FIXABLE_NATURALIST_LENS")
+ local parkPlotColor:number = m_LensSettings["COLOR_NATURALIST_LENS_PARK"].ConfiguredColor
+ local OkColor:number = m_LensSettings["COLOR_NATURALIST_LENS_OK"].ConfiguredColor
+ local FixableColor:number = m_LensSettings["COLOR_NATURALIST_LENS_FIXABLE"].ConfiguredColor
local colorPlot = {}
colorPlot[OkColor] = {}
@@ -195,7 +201,7 @@ local function ClearNaturalistLens()
end
local function OnInitialize()
- -- Nothing to do
+ -- Nothing to do
end
]]
@@ -206,6 +212,16 @@ local NaturalistLensEntry = {
GetColorPlotTable = OnGetColorPlotTable
}
+-- ===========================================================================
+local function ML_OnSettingsInitialized()
+ UpdateLensConfiguredColors(m_LensSettings, g_ModLensModalPanel, LENS_NAME);
+end
+
+-- ===========================================================================
+local function ML_OnSettingsUpdate()
+ ML_OnSettingsInitialized();
+end
+
-- minimappanel.lua
if g_ModLenses ~= nil then
g_ModLenses[LENS_NAME] = NaturalistLensEntry
@@ -216,8 +232,12 @@ if g_ModLensModalPanel ~= nil then
g_ModLensModalPanel[LENS_NAME] = {}
g_ModLensModalPanel[LENS_NAME].LensTextKey = "LOC_HUD_NATURALIST_LENS"
g_ModLensModalPanel[LENS_NAME].Legend = {
- {"LOC_TOOLTIP_NATURALIST_LENS_NPARK", UI.GetColorValue("COLOR_PARK_NATURALIST_LENS")},
- {"LOC_TOOLTIP_NATURALIST_LENS_OK", UI.GetColorValue("COLOR_OK_NATURALIST_LENS")},
- {"LOC_TOOLTIP_NATURALIST_LENS_FIXABLE", UI.GetColorValue("COLOR_FIXABLE_NATURALIST_LENS")}
+ {m_LensSettings["COLOR_NATURALIST_LENS_PARK"].KeyLabel, m_LensSettings["COLOR_NATURALIST_LENS_PARK"].ConfiguredColor},
+ {m_LensSettings["COLOR_NATURALIST_LENS_OK"].KeyLabel, m_LensSettings["COLOR_NATURALIST_LENS_OK"].ConfiguredColor},
+ {m_LensSettings["COLOR_NATURALIST_LENS_FIXABLE"].KeyLabel, m_LensSettings["COLOR_NATURALIST_LENS_FIXABLE"].ConfiguredColor}
}
end
+
+-- Add ML LuaEvent Hooks for minimappanel and modallenspanel contexts
+LuaEvents.ML_SettingsUpdate.Add(ML_OnSettingsUpdate);
+LuaEvents.ML_SettingsInitialized.Add(ML_OnSettingsInitialized);
diff --git a/Lenses/Resource/ModLens_Resource.lua b/Lenses/Resource/ModLens_Resource.lua
index c99c898..ebddbab 100644
--- a/Lenses/Resource/ModLens_Resource.lua
+++ b/Lenses/Resource/ModLens_Resource.lua
@@ -28,18 +28,27 @@ local m_resourceExclusionList:table = {
"RESOURCE_SHIPWRECK"
}
+local m_LensSettings = {
+ ["COLOR_RESOURCE_LENS_LUXCONNECTED"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_RESOURCE_LENS_LUXCONNECTED"), KeyLabel = "LOC_HUD_RESOURCE_LENS_LUXCONNECTED" },
+ ["COLOR_RESOURCE_LENS_STRATCONNECTED"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_RESOURCE_LENS_STRATCONNECTED"), KeyLabel = "LOC_HUD_RESOURCE_LENS_STRATCONNECTED" },
+ ["COLOR_RESOURCE_LENS_BONUSCONNECTED"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_RESOURCE_LENS_BONUSCONNECTED"), KeyLabel = "LOC_HUD_RESOURCE_LENS_BONUSCONNECTED" },
+ ["COLOR_RESOURCE_LENS_LUXNCONNECTED"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_RESOURCE_LENS_LUXNCONNECTED"), KeyLabel = "LOC_HUD_RESOURCE_LENS_LUXNCONNECTED" },
+ ["COLOR_RESOURCE_LENS_STRATNCONNECTED"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_RESOURCE_LENS_STRATNCONNECTED"), KeyLabel = "LOC_HUD_RESOURCE_LENS_STRATNCONNECTED" },
+ ["COLOR_RESOURCE_LENS_BONUSNCONNECTED"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_RESOURCE_LENS_BONUSNCONNECTED"), KeyLabel = "LOC_HUD_RESOURCE_LENS_BONUSNCONNECTED" }
+}
+
-- ===========================================================================
-- Resource Support functions
-- ===========================================================================
local function ShowResourceLens()
- print("Showing " .. LENS_NAME)
+ -- print("Showing " .. LENS_NAME)
LuaEvents.MinimapPanel_SetActiveModLens(LENS_NAME)
UILens.ToggleLayerOn(ML_LENS_LAYER)
end
local function ClearResourceLens()
- print("Clearing " .. LENS_NAME)
+ -- print("Clearing " .. LENS_NAME)
if UILens.IsLayerOn(ML_LENS_LAYER) then
UILens.ToggleLayerOff(ML_LENS_LAYER)
else
@@ -387,12 +396,12 @@ function SetResourceLens()
local pPlayer:table = Players[localPlayer]
local localPlayerVis:table = PlayersVisibility[localPlayer]
- local LuxConnectedColor :number = UI.GetColorValue("COLOR_LUXCONNECTED_RES_LENS")
- local StratConnectedColor :number = UI.GetColorValue("COLOR_STRATCONNECTED_RES_LENS")
- local BonusConnectedColor :number = UI.GetColorValue("COLOR_BONUSCONNECTED_RES_LENS")
- local LuxNConnectedColor :number = UI.GetColorValue("COLOR_LUXNCONNECTED_RES_LENS")
- local StratNConnectedColor :number = UI.GetColorValue("COLOR_STRATNCONNECTED_RES_LENS")
- local BonusNConnectedColor :number = UI.GetColorValue("COLOR_BONUSNCONNECTED_RES_LENS")
+ local LuxConnectedColor :number = m_LensSettings["COLOR_RESOURCE_LENS_LUXCONNECTED"].ConfiguredColor
+ local StratConnectedColor :number = m_LensSettings["COLOR_RESOURCE_LENS_STRATCONNECTED"].ConfiguredColor
+ local BonusConnectedColor :number = m_LensSettings["COLOR_RESOURCE_LENS_BONUSCONNECTED"].ConfiguredColor
+ local LuxNConnectedColor :number = m_LensSettings["COLOR_RESOURCE_LENS_LUXNCONNECTED"].ConfiguredColor
+ local StratNConnectedColor:number = m_LensSettings["COLOR_RESOURCE_LENS_STRATNCONNECTED"].ConfiguredColor
+ local BonusNConnectedColor:number = m_LensSettings["COLOR_RESOURCE_LENS_BONUSNCONNECTED"].ConfiguredColor
local IgnoreColor :number = UI.GetColorValue("COLOR_MORELENSES_GREY")
local ConnectedLuxury = {}
@@ -472,6 +481,9 @@ function SetResourceLens()
if table.count(IgnorePlots) > 0 then
UILens.SetLayerHexesColoredArea( ML_LENS_LAYER, localPlayer, IgnorePlots, IgnoreColor )
end
+
+ -- This takes care of updating the colors in the Modal Lens Key Panel
+ SetModalKeyResourceLens()
end
function RefreshResourcePicker()
@@ -795,6 +807,16 @@ local function ChangeContainer()
Controls.ResourceLensOptionsPanel:ChangeParent(hudContainer)
end
+local function ML_OnSettingsInitialized()
+ -- NOTE: This lens uses a special case to do the color key for the Modal Lens panel (as this lens is its own Context)
+ -- It will update the modal panel key when function to show the lens is called
+ UpdateLensConfiguredColors(m_LensSettings, nil, LENS_NAME);
+end
+
+local function ML_OnSettingsUpdate()
+ ML_OnSettingsInitialized();
+end
+
local function OnInit(isReload:boolean)
if isReload then
ChangeContainer()
@@ -823,17 +845,26 @@ local ResourceLensEntry = {
}
-- modallenspanel.lua
+function SetModalKeyResourceLens()
local ResourceLensModalPanelEntry = {}
ResourceLensModalPanelEntry.LensTextKey = "LOC_HUD_RESOURCE_LENS"
ResourceLensModalPanelEntry.Legend = {
- {"LOC_TOOLTIP_RESOURCE_LENS_LUXURY", UI.GetColorValue("COLOR_LUXCONNECTED_RES_LENS")},
- {"LOC_TOOLTIP_RESOURCE_LENS_NLUXURY", UI.GetColorValue("COLOR_LUXNCONNECTED_RES_LENS")},
- {"LOC_TOOLTIP_RESOURCE_LENS_BONUS", UI.GetColorValue("COLOR_BONUSCONNECTED_RES_LENS")},
- {"LOC_TOOLTIP_RESOURCE_LENS_NBONUS", UI.GetColorValue("COLOR_BONUSNCONNECTED_RES_LENS")},
- {"LOC_TOOLTIP_RESOURCE_LENS_STRATEGIC", UI.GetColorValue("COLOR_STRATCONNECTED_RES_LENS")},
- {"LOC_TOOLTIP_RESOURCE_LENS_NSTRATEGIC", UI.GetColorValue("COLOR_STRATNCONNECTED_RES_LENS")}
+ {m_LensSettings["COLOR_RESOURCE_LENS_LUXCONNECTED"].KeyLabel, m_LensSettings["COLOR_RESOURCE_LENS_LUXCONNECTED"].ConfiguredColor},
+ {m_LensSettings["COLOR_RESOURCE_LENS_LUXNCONNECTED"].KeyLabel, m_LensSettings["COLOR_RESOURCE_LENS_LUXNCONNECTED"].ConfiguredColor},
+ {m_LensSettings["COLOR_RESOURCE_LENS_BONUSCONNECTED"].KeyLabel, m_LensSettings["COLOR_RESOURCE_LENS_BONUSCONNECTED"].ConfiguredColor},
+ {m_LensSettings["COLOR_RESOURCE_LENS_BONUSNCONNECTED"].KeyLabel, m_LensSettings["COLOR_RESOURCE_LENS_BONUSNCONNECTED"].ConfiguredColor},
+ {m_LensSettings["COLOR_RESOURCE_LENS_STRATCONNECTED"].KeyLabel, m_LensSettings["COLOR_RESOURCE_LENS_STRATCONNECTED"].ConfiguredColor},
+ {m_LensSettings["COLOR_RESOURCE_LENS_STRATNCONNECTED"].KeyLabel, m_LensSettings["COLOR_RESOURCE_LENS_STRATNCONNECTED"].ConfiguredColor}
}
+ -- -- overwrite the old entry and refresh key panel
+ LuaEvents.ModalLensPanel_AddLensEntry(LENS_NAME, ResourceLensModalPanelEntry, true)
+end
+
+-- Add ML LuaEvent Hooks for minimappanel and modallenspanel contexts
+LuaEvents.ML_SettingsUpdate.Add(ML_OnSettingsUpdate);
+LuaEvents.ML_SettingsInitialized.Add(ML_OnSettingsInitialized);
+
-- Don't import this into g_ModLenses, since this for the UI (ie not lens)
local function Initialize()
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
@@ -850,7 +881,7 @@ local function Initialize()
function()
ChangeContainer()
LuaEvents.MinimapPanel_AddLensEntry(LENS_NAME, ResourceLensEntry)
- LuaEvents.ModalLensPanel_AddLensEntry(LENS_NAME, ResourceLensModalPanelEntry)
+ SetModalKeyResourceLens()
end
)
Events.LensLayerOn.Add( OnLensLayerOn )
diff --git a/Lenses/Scout/ModLens_Scout.lua b/Lenses/Scout/ModLens_Scout.lua
index 7ea2165..76caf8d 100644
--- a/Lenses/Scout/ModLens_Scout.lua
+++ b/Lenses/Scout/ModLens_Scout.lua
@@ -1,9 +1,27 @@
+include("LensSupport")
local LENS_NAME = "ML_SCOUT"
local ML_LENS_LAYER = UILens.CreateLensLayerHash("Hex_Coloring_Appeal_Level")
+local m_LensSettings = {
+ ["COLOR_SCOUT_LENS_GHUT"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_SCOUT_LENS_GHUT"), KeyLabel = "LOC_HUD_SCOUT_LENS_GHUT" }
+}
+
-- Should the scout lens auto apply, when a scout/ranger is selected.
-local AUTO_APPLY_SCOUT_LENS:boolean = GameConfiguration.GetValue("ML_AutoApplyScoutLens")
-local AUTO_APPLY_SCOUT_LENS_EXTRA:boolean = GameConfiguration.GetValue("ML_AutoApplyScoutLensExtra")
+local AUTO_APPLY_SCOUT_LENS:boolean = true;
+-- Should the scout lens auto-apply with any military unit
+local AUTO_APPLY_SCOUT_LENS_EXTRA:boolean = false;
+
+local function ML_OnSettingsInitialized()
+ -- Should the builder lens auto apply, when a builder is selected.
+ AUTO_APPLY_SCOUT_LENS = GameConfiguration.GetValue("ML_AutoApplyScoutLens");
+ AUTO_APPLY_SCOUT_LENS_EXTRA = GameConfiguration.GetValue("ML_AutoApplyScoutLensExtra");
+ UpdateLensConfiguredColors(m_LensSettings, g_ModLensModalPanel, LENS_NAME);
+end
+
+local function ML_OnSettingsUpdate()
+ ML_OnSettingsInitialized();
+end
+
-- ===========================================================================
-- Scout Lens Support
@@ -27,7 +45,7 @@ local function OnGetColorPlotTable()
local localPlayer :number = Game.GetLocalPlayer()
local localPlayerVis:table = PlayersVisibility[localPlayer]
- local GoodyHutColor :number = UI.GetColorValue("COLOR_GHUT_SCOUT_LENS")
+ local GoodyHutColor :number = m_LensSettings["COLOR_SCOUT_LENS_GHUT"].ConfiguredColor
local colorPlot = {}
colorPlot[GoodyHutColor] = {}
@@ -140,7 +158,6 @@ local function OnInitialize()
Events.UnitRemovedFromMap.Add( OnUnitRemovedFromMap )
Events.UnitMoveComplete.Add( OnUnitMoveComplete )
Events.GoodyHutReward.Add( OnGoodyHutReward )
- LuaEvents.ML_SettingsUpdate.Add( OnLensSettingsUpdate )
end
local ScoutLensEntry = {
@@ -160,6 +177,10 @@ if g_ModLensModalPanel ~= nil then
g_ModLensModalPanel[LENS_NAME] = {}
g_ModLensModalPanel[LENS_NAME].LensTextKey = "LOC_HUD_SCOUT_LENS"
g_ModLensModalPanel[LENS_NAME].Legend = {
- {"LOC_TOOLTIP_SCOUT_LENS_GHUT", UI.GetColorValue("COLOR_GHUT_SCOUT_LENS")}
+ {m_LensSettings["COLOR_SCOUT_LENS_GHUT"].KeyLabel, m_LensSettings["COLOR_SCOUT_LENS_GHUT"].ConfiguredColor}
}
end
+
+-- Add ML LuaEvent Hooks for minimappanel and modallenspanel contexts
+LuaEvents.ML_SettingsUpdate.Add(ML_OnSettingsUpdate);
+LuaEvents.ML_SettingsInitialized.Add(ML_OnSettingsInitialized);
\ No newline at end of file
diff --git a/Lenses/UnitAction/ModLens_UnitAction.lua b/Lenses/UnitAction/ModLens_UnitAction.lua
index b2e6c0b..f47760c 100644
--- a/Lenses/UnitAction/ModLens_UnitAction.lua
+++ b/Lenses/UnitAction/ModLens_UnitAction.lua
@@ -1,9 +1,14 @@
+include("LensSupport")
local LENS_NAME = "ML_UNITACTION"
local ML_LENS_LAYER = UILens.CreateLensLayerHash("Hex_Coloring_Appeal_Level")
-- Should the scout lens auto apply, when a scout/ranger is selected.
local AUTO_APPLY_SCOUT_LENS:boolean = true
+local m_LensSettings = {
+ ["COLOR_SCOUT_LENS_GHUT"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_SCOUT_LENS_GHUT"), KeyLabel = "LOC_HUD_SCOUT_LENS_GHUT" }
+}
+
-- ===========================================================================
-- Scout Lens Support
-- ===========================================================================
@@ -26,7 +31,7 @@ local function OnGetColorPlotTable()
local localPlayer :number = Game.GetLocalPlayer()
local localPlayerVis:table = PlayersVisibility[localPlayer]
- local GoodyHutColor :number = UI.GetColorValue("COLOR_GHUT_SCOUT_LENS")
+ local GoodyHutColor :number = m_LensSettings["COLOR_SCOUT_LENS_GHUT"].ConfiguredColor
local colorPlot = {}
colorPlot[GoodyHutColor] = {}
@@ -116,6 +121,14 @@ local function OnGoodyHutReward( playerID:number )
end
end
+local function ML_OnSettingsInitialized()
+ UpdateLensConfiguredColors(m_LensSettings, g_ModLensModalPanel, LENS_NAME);
+end
+
+local function ML_OnSettingsUpdate()
+ ML_OnSettingsInitialized();
+end
+
local function OnInitialize()
Events.UnitSelectionChanged.Add( OnUnitSelectionChanged )
Events.UnitRemovedFromMap.Add( OnUnitRemovedFromMap )
@@ -140,6 +153,10 @@ if g_ModLensModalPanel ~= nil then
g_ModLensModalPanel[LENS_NAME] = {}
g_ModLensModalPanel[LENS_NAME].LensTextKey = "LOC_HUD_SCOUT_LENS"
g_ModLensModalPanel[LENS_NAME].Legend = {
- {"LOC_TOOLTIP_SCOUT_LENS_GHUT", UI.GetColorValue("COLOR_GHUT_SCOUT_LENS")}
+ {m_LensSettings["COLOR_SCOUT_LENS_GHUT"].KeyLabel, m_LensSettings["COLOR_SCOUT_LENS_GHUT"].ConfiguredColor}
}
end
+
+-- Add ML LuaEvent Hooks for minimappanel and modallenspanel contexts
+LuaEvents.ML_SettingsUpdate.Add(ML_OnSettingsUpdate);
+LuaEvents.ML_SettingsInitialized.Add(ML_OnSettingsInitialized);
\ No newline at end of file
diff --git a/Lenses/Wonder/ModLens_Wonder.lua b/Lenses/Wonder/ModLens_Wonder.lua
index dbb42e9..e77f890 100644
--- a/Lenses/Wonder/ModLens_Wonder.lua
+++ b/Lenses/Wonder/ModLens_Wonder.lua
@@ -2,6 +2,10 @@ include("LensSupport")
local LENS_NAME = "ML_WONDER"
local ML_LENS_LAYER = UILens.CreateLensLayerHash("Hex_Coloring_Appeal_Level")
+local m_LensSettings = {
+ ["COLOR_WONDER_LENS_NATURAL"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_WONDER_LENS_NATURAL"), KeyLabel = "LOC_HUD_WONDER_LENS_NATURAL" },
+ ["COLOR_WONDER_LENS_PLAYER"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_WONDER_LENS_PLAYER"), KeyLabel = "LOC_HUD_WONDER_LENS_PLAYER" }
+}
-- ===========================================================================
-- Wonder Lens Support
@@ -16,8 +20,8 @@ local function OnGetColorPlotTable()
local localPlayer :number = Game.GetLocalPlayer()
local localPlayerVis:table = PlayersVisibility[localPlayer]
- local NaturalWonderColor :number = UI.GetColorValue("COLOR_NATURAL_WONDER_LENS")
- local PlayerWonderColor :number = UI.GetColorValue("COLOR_PLAYER_WONDER_LENS")
+ local NaturalWonderColor :number = m_LensSettings["COLOR_WONDER_LENS_NATURAL"].ConfiguredColor
+ local PlayerWonderColor :number = m_LensSettings["COLOR_WONDER_LENS_PLAYER"].ConfiguredColor
local IgnoreColor = UI.GetColorValue("COLOR_MORELENSES_GREY")
local colorPlot:table = {}
colorPlot[NaturalWonderColor] = {}
@@ -63,6 +67,16 @@ local function OnInitialize()
end
]]
+-- ===========================================================================
+local function ML_OnSettingsInitialized()
+ UpdateLensConfiguredColors(m_LensSettings, g_ModLensModalPanel, LENS_NAME);
+end
+
+-- ===========================================================================
+local function ML_OnSettingsUpdate()
+ ML_OnSettingsInitialized();
+end
+
local WonderLensEntry = {
LensButtonText = "LOC_HUD_WONDER_LENS",
LensButtonTooltip = "LOC_HUD_WONDER_LENS_TOOLTIP",
@@ -80,7 +94,11 @@ if g_ModLensModalPanel ~= nil then
g_ModLensModalPanel[LENS_NAME] = {}
g_ModLensModalPanel[LENS_NAME].LensTextKey = "LOC_HUD_WONDER_LENS"
g_ModLensModalPanel[LENS_NAME].Legend = {
- {"LOC_TOOLTIP_WONDER_LENS_NWONDER", UI.GetColorValue("COLOR_NATURAL_WONDER_LENS")},
- {"LOC_TOOLTIP_RESOURCE_LENS_PWONDER", UI.GetColorValue("COLOR_PLAYER_WONDER_LENS")}
+ {m_LensSettings["COLOR_WONDER_LENS_NATURAL"].KeyLabel, m_LensSettings["COLOR_WONDER_LENS_NATURAL"].ConfiguredColor},
+ {m_LensSettings["COLOR_WONDER_LENS_PLAYER"].KeyLabel, m_LensSettings["COLOR_WONDER_LENS_PLAYER"].ConfiguredColor}
}
end
+
+-- Add ML LuaEvent Hooks for minimappanel and modallenspanel contexts
+LuaEvents.ML_SettingsUpdate.Add(ML_OnSettingsUpdate);
+LuaEvents.ML_SettingsInitialized.Add(ML_OnSettingsInitialized);
diff --git a/MoreLenses_Colors.sql b/MoreLenses_Colors.sql
index 8525866..0b17260 100644
--- a/MoreLenses_Colors.sql
+++ b/MoreLenses_Colors.sql
@@ -36,72 +36,74 @@ INSERT INTO Colors ( Type, Red, Gree
VALUES ( 'COLOR_BUILDER_LENS_PN', '0.33', '0.33', '0.33', '0.5');
-- Archeologist lens
-INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_ARTIFACT_ARCH_LENS', '1', '0', '0', '0.5');
-INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_SHIPWRECK_ARCH_LENS', '0', '1', '0', '0.5');
+INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
+VALUES ( 'COLOR_ARCHAEOLOGIST_LENS_ARTIFACT', '1', '0', '0', '0.5');
+INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
+VALUES ( 'COLOR_ARCHAEOLOGIST_LENS_SHIPWRECK', '0', '1', '0', '0.5');
-- Gradient 8
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_GRADIENT8_1', '0.9', '0.0', '0.05', '0.5');
+VALUES ( 'COLOR_CITYOVERLAP_LENS_1', '0.9', '0.0', '0.05', '0.5');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_GRADIENT8_2', '0.8', '0.48', '0.0', '0.5');
+VALUES ( 'COLOR_CITYOVERLAP_LENS_2', '0.8', '0.48', '0.0', '0.5');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_GRADIENT8_3', '0.75', '0.75', '0.75', '0.5');
+VALUES ( 'COLOR_CITYOVERLAP_LENS_3', '0.75', '0.75', '0.75', '0.5');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_GRADIENT8_4', '0.5', '1', '0.5', '0.5');
+VALUES ( 'COLOR_CITYOVERLAP_LENS_4', '0.5', '1', '0.5', '0.5');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_GRADIENT8_5', '0', '1', '0', '0.5');
+VALUES ( 'COLOR_CITYOVERLAP_LENS_5', '0', '1', '0', '0.5');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_GRADIENT8_6', '0.0', '0.98', '0.93', '0.5');
+VALUES ( 'COLOR_CITYOVERLAP_LENS_6', '0.0', '0.98', '0.93', '0.5');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_GRADIENT8_7', '0.56', '0.0', '0.98', '0.5');
+VALUES ( 'COLOR_CITYOVERLAP_LENS_7', '0.56', '0.0', '0.98', '0.5');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_GRADIENT8_8', '0.98', '0.0', '0.81', '0.5');
+VALUES ( 'COLOR_CITYOVERLAP_LENS_8', '0.98', '0.0', '0.81', '0.5');
-- Barbarian Lens
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_BARBARIAN_BARB_LENS', '1', '0', '0', '0.5');
+VALUES ( 'COLOR_BARBARIAN_LENS_ENCAMPMENT', '1', '0', '0', '0.5');
-- Resources Lens
-INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_LUXCONNECTED_RES_LENS', '0.82', '0.65', '0.96', '0.5');
-INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_LUXNCONNECTED_RES_LENS', '1', '0', '1', '0.5');
+INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
+VALUES ( 'COLOR_RESOURCE_LENS_LUXCONNECTED', '0.82', '0.65', '0.96', '0.5');
+INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
+VALUES ( 'COLOR_RESOURCE_LENS_LUXNCONNECTED', '1', '0', '1', '0.5');
-INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_STRATCONNECTED_RES_LENS', '0.96', '0.54', '0.54', '0.5');
-INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_STRATNCONNECTED_RES_LENS', '1', '0', '0', '0.5');
+INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
+VALUES ( 'COLOR_RESOURCE_LENS_STRATCONNECTED', '0.96', '0.54', '0.54', '0.5');
+INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
+VALUES ( 'COLOR_RESOURCE_LENS_STRATNCONNECTED','1', '0', '0', '0.5');
-INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_BONUSCONNECTED_RES_LENS', '0.5', '1', '0.5', '0.5');
-INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_BONUSNCONNECTED_RES_LENS', '0', '1', '0', '0.5');
+INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
+VALUES ( 'COLOR_RESOURCE_LENS_BONUSCONNECTED', '0.5', '1', '0.5', '0.5');
+INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
+VALUES ( 'COLOR_RESOURCE_LENS_BONUSNCONNECTED','0', '1', '0', '0.5');
-- Wonder Lens
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_NATURAL_WONDER_LENS', '0', '1', '0', '0.5');
+VALUES ( 'COLOR_WONDER_LENS_NATURAL', '0', '1', '0', '0.5');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_PLAYER_WONDER_LENS', '1', '0', '1', '0.5');
+VALUES ( 'COLOR_WONDER_LENS_PLAYER', '1', '0', '1', '0.5');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_GHUT_SCOUT_LENS', '1', '0', '1', '0.5');
+VALUES ( 'COLOR_SCOUT_LENS_GHUT', '1', '0', '1', '0.5');
-- Naturalist Lens
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_PARK_NATURALIST_LENS', '0', '1', '0', '0.5');
+VALUES ( 'COLOR_NATURALIST_LENS_PARK', '0', '1', '0', '0.5');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_OK_NATURALIST_LENS', '0', '1', '1', '0.5');
+VALUES ( 'COLOR_NATURALIST_LENS_OK', '0', '1', '1', '0.5');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_FIXABLE_NATURALIST_LENS', '0.56', '0.0', '0.98', '0.5');
+VALUES ( 'COLOR_NATURALIST_LENS_FIXABLE', '0.56', '0.0', '0.98', '0.5');
-- City Manager Colors
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_CITY_PLOT_WORKING', '1', '0.5', '0', '0.2');
+VALUES ( 'COLOR_CITY_PLOT_LENS_WORKING', '1', '0.5', '0', '0.2');
+INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
+VALUES ( 'COLOR_CITY_PLOT_LENS_LOCKED', '0', '1', '0', '0.2');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
-VALUES ( 'COLOR_CITY_PLOT_LOCKED', '0', '1', '0', '0.2');
+VALUES ( 'COLOR_CITY_PLOT_LENS_CULTURE', '0.89', '0.431', '0.862', '0.5');
INSERT INTO Colors ( Type, Red, Green, Blue, Alpha)
VALUES ( 'COLOR_AREA_LENS_NEUTRAL', '0', '0', '0', '0.0');
diff --git a/Settings/ml_settingspanel.lua b/Settings/ml_settingspanel.lua
index 83f01ee..ab8670e 100644
--- a/Settings/ml_settingspanel.lua
+++ b/Settings/ml_settingspanel.lua
@@ -1,8 +1,9 @@
+include("InstanceManager");
-- ===========================================================================
-- Helper Functions
-- ===========================================================================
--- Sourced from Azurency's CQUI link: https://github.com/Azurency/CQUI_Community-Edition/blob/master/Assets/UI/civ6common.lua
+-- Sourced from CivFanatics CQUI GitHub (originally via Azurency's GitHub): https://github.com/civfanatics/CQUI_Community-Edition/blob/main/Assets/cqui_settingselement.lua
local function PopulateCheckBox(control, setting_name)
local current_value = GameConfiguration.GetValue(setting_name);
if (current_value == nil) then
@@ -29,6 +30,31 @@ local function PopulateCheckBox(control, setting_name)
);
end
+-- Object containing functions that convert either a value to a set slider notch, or convert a notch to a value
+local SliderControlConverter = {
+ ToSteps = function(value, min, max, numsteps)
+ -- Determine the position of the slider based on the number of steps in total
+ -- If the value is the same as the minimum, then the step value is 0.
+ local stepIncrement = math.floor((max - min + 1) / numsteps);
+ local out = math.floor((value - min) / stepIncrement);
+ if (out < 0) then
+ out = 0;
+ end
+
+ return out;
+ end,
+
+ ToValue = function(curstep, min, max, numsteps)
+ local stepIncrement = math.floor((max - min + 1) / numsteps);
+ local out = (curstep * stepIncrement) + min;
+
+ if (out > max) then
+ out = max;
+ end
+ return out;
+ end
+};
+
function InitButton(control, callbackLClick, callbackRClick)
control:RegisterCallback(Mouse.eLClick, callbackLClick)
if callbackRClick ~= nil then
@@ -48,6 +74,8 @@ end
local function OnClose()
ContextPtr:SetHide(true);
+ LuaEvents.ML_SettingsUpdate();
+ LuaEvents.ML_SettingsPanelClosed();
end
-- ===========================================================================
@@ -75,6 +103,233 @@ local function OnShutdown()
end
end
+-- TEMP TEMP
+function DoClose()
+ local hudContainer = ContextPtr:LookUpControl("/InGame/HUD")
+ if hudContainer ~= nil then
+ hudContainer:DestroyChild(Controls.SettingsPanel)
+ end
+end
+
+-- ===========================================================================
+-- Configurable Colors for More Lenses controls (the_m4a, from CQUI)
+-- ===========================================================================
+
+-- This file contains the logic tied to the control instances created to allow updating
+-- of the lens colors in the More Lenses Settings panel
+local m_lensRGBSettingsIM = InstanceManager:new("LensRGBPickerLensGroupInstance", "LensRGBPickerLensGroupInstanceRoot", Controls.LensRGBPickerLensGroupStack);
+local m_sliderUpdating = false;
+local m_editBoxUpdating = false;
+
+-- ===========================================================================
+-- Create all of the control instances for each of the various colors available for each of the lenses
+-- Each "Lens" as found in the Modal Lens Panel is considered a Lens Category
+-- Each individual item in that Lens Category is a lens, where a slider control or an edit
+-- box can be used to set the RGB values for that lens
+function PopulateLensRGBPickerSettings()
+ m_lensRGBSettingsIM:ResetInstances();
+
+ -- These are the modded lenses that have been updated so their colors can be set via the settings panel
+ -- The Lens names and locale text strings have been updated to follow a specific pattern,
+ -- Where a Lens "Base Name" has COLOR_LENSNAME_LENS, and all items for that lens are COLOR_LENSNAME_LENS_ITEM
+ -- For example, COLOR_ARCHAEOLOGIST_LENS_SHIPWRECK is for all of the ShipWreck tiles shown by the Archaeologist lens
+ local lensGroups = {
+ { LensGroupName = "LOC_HUD_ARCHAEOLOGIST_LENS", LensBaseName = "COLOR_ARCHAEOLOGIST_LENS"},
+ { LensGroupName = "LOC_HUD_BARBARIAN_LENS", LensBaseName = "COLOR_BARBARIAN_LENS"},
+ { LensGroupName = "LOC_HUD_BUILDER_LENS", LensBaseName = "COLOR_BUILDER_LENS" },
+ { LensGroupName = "LOC_HUD_CITYOVERLAP_LENS", LensBaseName = "COLOR_CITYOVERLAP_LENS", RowLabelFunc = GenerateCityOverlapRowLabel},
+ { LensGroupName = "LOC_HUD_NATURALIST_LENS", LensBaseName = "COLOR_NATURALIST_LENS"},
+ { LensGroupName = "LOC_HUD_RESOURCE_LENS", LensBaseName = "COLOR_RESOURCE_LENS"},
+ { LensGroupName = "LOC_HUD_SCOUT_LENS", LensBaseName = "COLOR_SCOUT_LENS"},
+ { LensGroupName = "LOC_HUD_WONDER_LENS", LensBaseName = "COLOR_WONDER_LENS"}
+ };
+
+ for _,lensGroup in ipairs(lensGroups) do
+ -- catEntry is an entry for the category, containing 1-to-n rows of RGB Sliders
+ local lensGroupInstance = m_lensRGBSettingsIM:GetInstance();
+ lensGroupInstance.LensGroupLabel:SetText(Locale.Lookup(lensGroup.LensGroupName));
+ local lensRGBPickerRowIM = InstanceManager:new("LensRGBPickerRowInstance", "LensRGBPickerRowInstanceRoot", lensGroupInstance.LensRGBPickerRowInstanceStack);
+ -- MoreLenses adds its colors into the GameInfo.Colors table, so cycling through that list will get us the lens items in each lens category
+ for lensColorEntry in GameInfo.Colors() do
+ -- If LensBaseName is COLOR_FOO_LENS, then this matches COLOR_FOO_LENS_BAR, COLOR_FOO_LENS_STUFF, etc for the Type field of the item in GameInfo.Colors
+ if (string.find(lensColorEntry["Type"], lensGroup.LensBaseName)) then
+ local rowLabel = "";
+ if (lensGroup.RowLabelFunc ~= nil) then
+ -- This lens group has a custom function for assigning the Row Label
+ rowLabel = lensGroup.RowLabelFunc(lensColorEntry["Type"]);
+ else
+ -- This turns COLOR_FOO_LENS_BAR into LOC_HUD_FOO_LENS_BAR
+ rowLabel = Locale.Lookup(string.gsub(lensColorEntry["Type"], lensGroup.LensBaseName, lensGroup.LensGroupName));
+ end
+
+ -- Skip any entries that have a blank row label
+ if (string.len(rowLabel) > 0) then
+ local lensRGBPickerRowInstance = lensRGBPickerRowIM:GetInstance();
+ PopulateLensRGBPickerRowInstance(lensRGBPickerRowInstance, lensColorEntry["Type"], rowLabel);
+ end
+ end
+ end
+ end
+
+ -- Both of these controls are found in ml_settingspanel.xml
+ Controls.LensRGBPickerLensGroupStack:CalculateSize();
+ Controls.LensesOptionsScrollPanel:CalculateSize();
+end
+
+-- ===========================================================================
+-- Used to populate the Lens RGB Color Pickers asdf(each row item added to the settings control)
+-- pickerRowInstance: The instance returned by the lensColorSetting:GetInstance() call
+-- settingName: The name of the lens color item to be retrieved (e.g. COLOR_WONDER_LENS_NATURAL)
+-- rowLabel: The label for that row
+function PopulateLensRGBPickerRowInstance(pickerRowInstance, settingName, rowLabel)
+ local lensItemColorData = GameConfiguration.GetValue(settingName);
+ if (lensItemColorData == nil or lensItemColorData["Red"] == nil) then
+ -- if lensItemColor data is nil, then it has not yet been added to this GameConfiguration...
+ -- or if it has, but one of the fields (like Red) is nil, then the entire data structure may be corrupt.
+ -- So, get the default values from GameInfo.Colors that was placed by the MoreLenses_Colors.sql
+ if (GameInfo.Colors[settingName]) then
+ lensItemColorData = GameInfo.Colors[settingName];
+ else
+ -- Somehow this value does not exist. Manually create it. Note, there are missing fields, but we don't touch them, so...
+ lensItemColorData = { Type = settingName, Red = 0, Green = 0, Blue = 0, Alpha = 0.5 }
+ end
+
+ GameConfiguration.SetValue(settingName, lensItemColorData);
+ end
+
+ pickerRowInstance.RowLabel:SetText(rowLabel);
+
+ -- Add 3 instances of the Label/EditBox/Slider control, one each for Red, Green, and Blue
+ local lesIM = InstanceManager:new("LensRGBPickerLabelEditBoxSliderInstance", "LensRGBPickerLabelEditBoxSliderInstanceRoot", pickerRowInstance.LensRGBPickerLabelEditBoxSliderInstanceStack);
+ local lesArray = { Red = lesIM:GetInstance(), Green = lesIM:GetInstance(), Blue = lesIM:GetInstance()};
+ for color, lesInstance in pairs(lesArray) do
+ lesInstance.LabelCtrl:SetText(Locale.Lookup("LOC_ML_LENSES_RGB_COLOR_SETTINGS_" .. string.upper(color)));
+
+ -- lensItemColorData[color] is a float (from the RGB Color setting) that requires conversion; this accomplishes rounding the value correctly, as well
+ local currentValue = math.floor((lensItemColorData[color] * 255) + 0.5);
+ lesInstance.SliderCtrl:SetStep(SliderControlConverter.ToSteps(currentValue, 0, 255, lesInstance.SliderCtrl:GetNumSteps()));
+ lesInstance.EditBoxCtrl:SetText(currentValue);
+
+ -- Callback function called whenever the slider changes
+ lesInstance.SliderCtrl:RegisterSliderCallback(LensRGBPickerSliderCallback(lesInstance, pickerRowInstance.ColorPreviewBox, settingName, color));
+ -- Callback function called whenever the edit box is updated
+ lesInstance.EditBoxCtrl:RegisterStringChangedCallback(LensRGBPickerEditBoxCallback(lesInstance, pickerRowInstance.ColorPreviewBox, settingName, color));
+
+ if (tooltip ~= nil and string.len(tooltip) > 0) then
+ editBoxControl:SetToolTipString(tooltip);
+ end
+
+ lesInstance.LabelStack:CalculateSize();
+ end
+
+ pickerRowInstance.LensRGBPickerLabelEditBoxSliderInstanceStack:CalculateSize();
+
+ -- Give the color preview box its initial coloring
+ pickerRowInstance.ColorPreviewBox:SetColor(UI.GetColorValue(lensItemColorData["Red"], lensItemColorData["Green"], lensItemColorData["Blue"]));
+
+ -- Configure the click action for the Default button, which will reset the color preview box as well as the slider control and edit boxes
+ pickerRowInstance.RestoreDefaultButton:RegisterCallback(Mouse.eLClick, LensRGBPickerRestoreDefaultButtonCallback(pickerRowInstance, lesArray, settingName));
+end
+
+-- ===============================================================================================
+-- Callback function for when the Restore Default button is clicked
+function LensRGBPickerRestoreDefaultButtonCallback(pickerRowInstance, lesArray, settingName)
+ return function()
+ -- Get the default value from the GameInfo.Colors DB (as set by morelenses_colors.sql),
+ -- then set the setting by the same name in GameConfiguration to that value.
+ lensColorData = GameInfo.Colors[settingName];
+ GameConfiguration.SetValue(settingName, lensColorData);
+ -- Update all of the controls
+ pickerRowInstance.ColorPreviewBox:SetColor(UI.GetColorValue(lensColorData["Red"], lensColorData["Green"], lensColorData["Blue"]));
+ for color, lesInstance in pairs(lesArray) do
+ -- This is effectively how to round a value in lua
+ local current_value = math.floor((lensColorData[color] * 255) + 0.5);
+ lesInstance.SliderCtrl:SetStep(SliderControlConverter.ToSteps(current_value, 0, 255, lesInstance.SliderCtrl:GetNumSteps()));
+ lesInstance.EditBoxCtrl:SetText(current_value);
+ end
+ end
+end
+
+-- ===========================================================================
+-- Callback function for when a Slider control is being manipulated
+function LensRGBPickerSliderCallback(lesInstance, previewBoxCtrl, settingName, controlColor)
+ return function()
+ m_sliderUpdating = true;
+
+ -- Get value, update the color changed, set value
+ local value = SliderControlConverter.ToValue(lesInstance.SliderCtrl:GetStep(), 0, 255, lesInstance.SliderCtrl:GetNumSteps());
+ local lensData = GameConfiguration.GetValue(settingName);
+ lensData[controlColor] = value / 255.0;
+ GameConfiguration.SetValue(settingName, lensData);
+
+ if (false == m_editBoxUpdating) then
+ -- if m_editBoxUpdating is true, then this callback was called as a result of the editbox callback updating the slider control
+ -- therefore it is not necessary to set the preview box or editbox control values, as they will already be updated in that callback
+ lesInstance.EditBoxCtrl:SetText(value);
+ previewBoxCtrl:SetColor(UI.GetColorValue(lensData["Red"], lensData["Green"], lensData["Blue"]));
+ end
+
+ -- Note: Calling the ML_SettingsUpdate LuaEvent here is very slow and not necessary as this Callback is called with every movement
+ -- of the slider tab. Instead, the ML_SettingsUpdate LuaEvent is called when the ML Settings panel is closed.
+ m_sliderUpdating = false;
+ end
+end
+
+-- ===========================================================================
+-- Callback function for when a text box is being edited
+function LensRGBPickerEditBoxCallback(lesInstance, previewBoxCtrl, settingName, controlColor)
+ return function()
+ m_editBoxUpdating = true;
+
+ local numVal:number = 0;
+ local userInput:string = lesInstance.EditBoxCtrl:GetText();
+ if (string.len(userInput) > 0 and tonumber(userInput) == nil) then
+ -- Box isn't blank, but also not a number
+ lesInstance.EditBoxCtrl:SetText("0");
+ else
+ numVal = tonumber(userInput);
+ if (numVal < 0) then
+ lesInstance.EditBoxCtrl:SetText("0");
+ numVal = 0;
+ elseif (numVal > 255) then
+ lesInstance.EditBoxCtrl:SetText("255");
+ numVal = 255;
+ end
+ end
+
+ local lensData = GameConfiguration.GetValue(settingName);
+ lensData[controlColor] = numVal / 255.0;
+ GameConfiguration.SetValue(settingName, lensData);
+
+ if (false == m_sliderUpdating) then
+ -- if m_sliderUpdating is true, then this callback was called as a result of the slider callback updating the edit box value
+ -- therefore it is not necessary to set the preview box or slider control values, as they will already be updated in that callback
+ previewBoxCtrl:SetColor(UI.GetColorValue(lensData["Red"], lensData["Green"], lensData["Blue"]));
+ lesInstance.SliderCtrl:SetStep(SliderControlConverter.ToSteps(numVal, 0, 255, lesInstance.SliderCtrl:GetNumSteps()));
+ end
+
+ -- Note: Calling the ML_SettingsUpdate LuaEvent here is not necessary.
+ -- Instead, the ML_SettingsUpdate LuaEvent is called when the ML Settings panel is closed.
+ m_editBoxUpdating = false;
+ end
+end
+
+-- ===========================================================================
+-- Generate the Row Label for the City Overlap entry
+function GenerateCityOverlapRowLabel(lensTypeName)
+ -- CityOverlap has a special case handling for the KeyLabel
+ -- ["COLOR_CITYOVERLAP_LENS_1"] = { ConfiguredColor = GetLensColorFromSettings("COLOR_CITYOVERLAP_LENS_1"), KeyLabel = "LOC_WORLDBUILDER_TAB_CITIES".." +1" },
+ -- So, if lensTypeName is COLOR_CITYOVERLAP_LENS_1, the row Label should be "Cities +1", which uses the LOC_WORLDBUILDER_TAB_CITIES string
+ -- This gets the last two characters in the string, so it would get 1 from COLOR_CITYOVERLAP_LENS_1
+ local cityOverlapLensRow = string.sub(lensTypeName, -1);
+ local rowLabel = Locale.Lookup("LOC_WORLDBUILDER_TAB_CITIES").." +"..cityOverlapLensRow;
+ return rowLabel;
+end
+
+-- ===========================================================================
+-- End Section imported from CQUI Settings
+-- ===========================================================================
+
-- ===========================================================================
-- Init
-- ===========================================================================
@@ -94,6 +349,9 @@ local function Initialize()
PopulateCheckBox(Controls.AutoApplyScoutLensCheckbox, "ML_AutoApplyScoutLens")
PopulateCheckBox(Controls.AutoApplyScoutLensExtraCheckbox, "ML_AutoApplyScoutLensExtra")
+ -- Add color settings for lenses added by ML
+ PopulateLensRGBPickerSettings();
+
-- Call this once to ensure all files have updated settings
LuaEvents.ML_SettingsUpdate();
diff --git a/Settings/ml_settingspanel.xml b/Settings/ml_settingspanel.xml
index 2cdbdcf..f76a33b 100644
--- a/Settings/ml_settingspanel.xml
+++ b/Settings/ml_settingspanel.xml
@@ -1,26 +1,75 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Text/MoreLenses_Text.xml b/Text/MoreLenses_Text.xml
index d499e99..2815010 100644
--- a/Text/MoreLenses_Text.xml
+++ b/Text/MoreLenses_Text.xml
@@ -50,10 +50,10 @@
Highlights archaeologist dig sites.
-
+ Artifact
-
+ Shipwreck
@@ -68,7 +68,7 @@
Highlight outside border
- No Mouse
+ No MouseRange
@@ -87,7 +87,7 @@
Highlights barbarian encampments on the map
-
+ Barbarian Encampment
@@ -101,22 +101,22 @@
You own {1_Count} ({2_Count} improved) of the total {3_Count} discovered plots of {4_Resource}.
-
+ Bonus Resource
-
+ Unconnected Bonus Resource
-
+ Luxury Resource
-
+ Unconnected Luxury Resource
-
+ Strategic Resource
-
+ Unconnected Strategic Resource
@@ -127,10 +127,10 @@
Highlights natural wonders and built wonders built by players
-
+ Natural Wonder
-
+ Player-made Wonder
@@ -149,7 +149,7 @@
Highlights goody huts on the map
-
+ Goody Hut
@@ -160,13 +160,13 @@
Highlights places where National Parks can be built
-
+ Area is ready for National Park
-
+ Tile could be used, if some other plot is fixed
-
+ Needs fixing to be used for a park
@@ -210,5 +210,17 @@
Enable this to automatically apply the Scout lens when selecting all military units.
+
+ RGB Color Settings for Custom Lenses
+
+
+ Red
+
+
+ Green
+
+
+ Blue
+
diff --git a/Text/MoreLenses_Text_de.xml b/Text/MoreLenses_Text_de.xml
index 6876f59..2eff1d0 100644
--- a/Text/MoreLenses_Text_de.xml
+++ b/Text/MoreLenses_Text_de.xml
@@ -36,10 +36,10 @@
Zeigt Ausgrabungsstätten auf der Karte.
-
+ Artefakt
-
+ Schiffswrack
@@ -73,7 +73,7 @@
Zeigt Barbaren-Lager auf der Karte.
-
+ Barbaren-Lager
@@ -84,22 +84,22 @@
Zeigt Ressourcenfelder.
-
+ Luxusressource
-
+ Unerschlossene Luxusressource
-
+ Strategische Ressource
-
+ Unerschlossene strateg. Ressource
-
+ Bonusressource
-
+ Unerschlossene Bonusressource
@@ -110,10 +110,10 @@
Zeigt Naturwunder und errichtete Wunder auf der Karte.
-
+ Naturwunder
-
+ Errichtete Wunder
@@ -132,7 +132,7 @@
Zeigt Stammesdörfer auf der Karte.
-
+ Stammesdorf
@@ -143,15 +143,30 @@
Hebe geeignete Plätze zum Bau von Nationalparks hervor
-
+ Gebiete bereit für einen Nationalpark
-
+ Feld als Nationalpark tauglich, wenn umliegende Grundstücke verbessert werden
-
+ Benötigt Verbesserung um zum Nationalpark zu werden
+
+ RGB-Farbeinstellungen für benutzerdefinierte Objektive
+
+
+ Blau
+
+
+ Geben Sie einen Wert zwischen 0 und 255 ein.
+
+
+ Grün
+
+
+ Rot
+
diff --git a/Text/MoreLenses_Text_es.xml b/Text/MoreLenses_Text_es.xml
index 48fb4fd..ffebbef 100644
--- a/Text/MoreLenses_Text_es.xml
+++ b/Text/MoreLenses_Text_es.xml
@@ -33,10 +33,10 @@
Resalta puntos de excavación arqueológica.
-
+ Artefacto
-
+ Naufragio
@@ -63,7 +63,7 @@
Resalta los Campamentos Bárbaros del mapa
-
+ Campamento bárbaro
@@ -74,22 +74,22 @@
Resalta los recursos del mapa
-
+ Recursos de lujo
-
+ Recursos de lujo no conectados
-
+ Recursos estratégicos
-
+ Recursos estratégicos no conectados
-
+ Recursos adicionales
-
+ Recursos adicionales no conectados
@@ -100,10 +100,10 @@
Resalta las maravillas naturales y las maravillas construidas por los jugadores
-
+ Maravillas Naturales
-
+ Maravillas Construidas
@@ -122,9 +122,25 @@
Resalta las aldeas tribales del mapa
-
+ Aldea Tribal
+
+ Ajustes de color RGB para lentes personalizados
+
+
+ azul
+
+
+ Introduzca un valor entre 0 y 255
+
+
+ verde
+
+
+ rojo
+
+
diff --git a/Text/MoreLenses_Text_fr.xml b/Text/MoreLenses_Text_fr.xml
index 4c5228b..9749a18 100644
--- a/Text/MoreLenses_Text_fr.xml
+++ b/Text/MoreLenses_Text_fr.xml
@@ -33,10 +33,10 @@
Montrer les sites archéologiques.
-
+ Artéfact
-
+ Épave
@@ -63,7 +63,7 @@
Montrer les campements barbares sur la carte
-
+ Campement barbare
@@ -74,22 +74,22 @@
Montrer les ressources sur la carte
-
+ Ressource de Luxe
-
+ Ressource de luxe inexploitée
-
+ Ressource Stratégique
-
+ Ressource stratégique inexploitée
-
+ Ressource bonus
-
+ Ressource bonus inexploitée
@@ -100,10 +100,10 @@
Montrer les merveilles naturelles et celles des joueurs
-
+ Merveille Naturelle
-
+ Merveille des Joueurs
@@ -122,9 +122,24 @@
Montrer les villages tribaux sur la carte
-
+ Village Tribal
+
+ Paramètres de couleur RVB pour les objectifs personnalisés
+
+
+ bleu
+
+
+ Entrez une valeur comprise entre 0 et 255
+
+
+ vert
+
+
+ rouge
+
diff --git a/Text/MoreLenses_Text_it.xml b/Text/MoreLenses_Text_it.xml
index 05786db..340c09e 100644
--- a/Text/MoreLenses_Text_it.xml
+++ b/Text/MoreLenses_Text_it.xml
@@ -36,10 +36,10 @@
Evidenzia siti di scavo archeologici.
-
+ Artefatto
-
+ Relitto
@@ -73,7 +73,7 @@
Evidenzia gli accampamenti barbari sulla mappa
-
+ Accampamenti Barbari
@@ -84,22 +84,22 @@
Evidenzia le risorse sulla mappa
-
+ Risorse di Lusso
-
+ Risorse non Migliorate
-
+ Risorse Strategiche
-
+ Risorse Strategiche non Migliorate
-
+ Risorse Bonus
-
+ Risorse Bonus non Migliorate
@@ -110,10 +110,10 @@
Evidenzia le meraviglie naturali e quelle costruite dai giocatori
-
+ Meraviglie Naturali
-
+ Meraviglie costruite dai giocartori
@@ -132,7 +132,7 @@
Evidenzia i villaggi tribali sulla mappa
-
+ Villaggi Tribali
@@ -143,15 +143,30 @@
Evidenzia le caselle dove è possibile costruire Parchi Nazionali
-
+ L'area è pronta per il Parco Nazionale
-
+ La casella può essere usata solo dopo la lavorazione di altre
-
+ Necessita una lavorazione per poterci costruire il Parco Nazionale
+
+ Impostazioni colore RGB per obiettivi personalizzati
+
+
+ blu
+
+
+ Immettere un valore compreso tra 0 e 255
+
+
+ verde
+
+
+ rosso
+
diff --git a/Text/MoreLenses_Text_jp.xml b/Text/MoreLenses_Text_jp.xml
index 060385c..5a99153 100644
--- a/Text/MoreLenses_Text_jp.xml
+++ b/Text/MoreLenses_Text_jp.xml
@@ -36,10 +36,10 @@
考古学者が発掘できるタイルを表示します。
-
+ 史跡
-
+ 沈没船
@@ -73,7 +73,7 @@
蛮族の前哨地があるタイルを表示します。
-
+ 前哨地
@@ -84,22 +84,22 @@
資源のあるタイルを表示します。
-
+ 高級資源
-
+ 高級資源[NEWLINE] (未改善)
-
+ 戦略資源
-
+ 戦略資源[NEWLINE] (未改善)
-
+ ボーナス資源
-
+ ボーナス資源[NEWLINE] (未改善)
@@ -110,10 +110,10 @@
自然遺産や世界遺産のあるタイルを表示します。
-
+ 自然遺産
-
+ 世界遺産
@@ -132,7 +132,7 @@
原住民の集落があるタイルを表示します。
-
+ 原住民の集落
@@ -143,15 +143,30 @@
国立公園が建設できるタイルを表示します。
-
+ 国立公園が建設可能
-
+ 他のタイルを修正すれば建設可能
-
+ 要修正タイル
+
+ カスタムレンズの RGB カラー設定
+
+
+ 青い
+
+
+ 0 ~ 255 の値を入力してください
+
+
+ 緑
+
+
+ 赤い
+
diff --git a/Text/MoreLenses_Text_ko.xml b/Text/MoreLenses_Text_ko.xml
index 814fbb6..d6e123c 100644
--- a/Text/MoreLenses_Text_ko.xml
+++ b/Text/MoreLenses_Text_ko.xml
@@ -33,10 +33,10 @@
고고학자가 작업할 수 있는 타일을 나타냅니다.
-
+ 사적지
-
+ 난파선
@@ -63,7 +63,7 @@
야만인 전초기지를 나타냅니다.
-
+ 야만인 전초기지
@@ -74,22 +74,22 @@
자원의 상태를 나타냅니다.
-
+ 개발한 사치 자원
-
+ 미개발 사치 자원
-
+ 개발한 전략 자원
-
+ 미개발 전략 자원
-
+ 개발한 보너스 자원
-
+ 미개발 보너스 자원
@@ -100,10 +100,10 @@
자연경관과 불가사의를 나타냅니다.
-
+ 자연경관
-
+ 불가사의
@@ -122,9 +122,24 @@
부족 마을을 나타냅니다.
-
+ 부족 마을
+
+ 사용자 지정 렌즈용 RGB 색상 설정
+
+
+ 파랑
+
+
+ 0에서 255 사이의 값을 입력합니다.
+
+
+ 녹색
+
+
+ 빨강
+
diff --git a/Text/MoreLenses_Text_pl.xml b/Text/MoreLenses_Text_pl.xml
index 49eb262..1d6a015 100644
--- a/Text/MoreLenses_Text_pl.xml
+++ b/Text/MoreLenses_Text_pl.xml
@@ -33,10 +33,10 @@
Podświetla archeologiczne ślady przeszłości.
-
+ Artefakt
-
+ Wrak statku
@@ -63,7 +63,7 @@
Podświetla obozy barbarzyńców
-
+ Obóz barbarzyńców
@@ -74,22 +74,22 @@
Podświetla zasoby na mapie
-
+ Zasób luksusowy
-
+ Nieprzyłączony zasób luksusowy
-
+ Zasób strategiczny
-
+ Nieprzyłączony zasób strategiczny
-
+ Zasób dodatkowy
-
+ Nieprzyłączony zasób dodatkowy
@@ -100,10 +100,10 @@
Podświetla cuda natury oraz cuda zbudowane przez graczy
-
+ Cud natury
-
+ Cud zbudowany przez gracza
@@ -122,9 +122,24 @@
Podświetla wioski plemienne
-
+ Wioska plemienna
+
+ Ustawienia kolorów RGB dla obiektywów niestandardowych
+
+
+ niebieski
+
+
+ Wprowadź wartość z 0 do 255
+
+
+ zielony
+
+
+ czerwony
+
diff --git a/Text/MoreLenses_Text_pt_br.xml b/Text/MoreLenses_Text_pt_br.xml
index c7445d3..12378f3 100644
--- a/Text/MoreLenses_Text_pt_br.xml
+++ b/Text/MoreLenses_Text_pt_br.xml
@@ -36,10 +36,10 @@
Mostra os Sítios Arqueológicos.
-
+ Local da Antiguidade
-
+ Naufrágio
@@ -73,7 +73,7 @@
Mostra os postos avançados bárbaros no mapa
-
+ Posto Avançado Bárbaro
@@ -84,22 +84,22 @@
Mostra os recursos no mapa
-
+ Recurso de Luxo
-
+ Recurso de Luxo sem Melhoria
-
+ Recurso Estratégico
-
+ Recurso Estratégico sem Melhoria
-
+ Recurso Bônus
-
+ Recurso Bônus sem Melhoria
@@ -110,10 +110,10 @@
Mostra as Maravilhas da Natureza e Maravilhas construídas por civilizações
-
+ Maravilha da Natureza
-
+ Maravilha Construída
@@ -132,7 +132,7 @@
Mostra as Aldeias Tribais no mapa
-
+ Aldeia Tribal
@@ -143,15 +143,30 @@
Mostra os locais onde Parques Nacionais podem ser contruídos
-
+ Área propícia para Parque Nacional
-
+ Área propícia após melhora de painel ao redor
-
+ Precisa de melhoras para ser utilizado em um parque
+
+ Configurações de cores RGB para lentes personalizadas
+
+
+ azul
+
+
+ Digite um valor entre 0 e 255
+
+
+ verde
+
+
+ vermelho
+
diff --git a/Text/MoreLenses_Text_ru.xml b/Text/MoreLenses_Text_ru.xml
index 656f577..27270e2 100644
--- a/Text/MoreLenses_Text_ru.xml
+++ b/Text/MoreLenses_Text_ru.xml
@@ -33,10 +33,10 @@
Выделяет места раскопок.
-
+ Артефакт
-
+ Кораблекрушение
@@ -63,7 +63,7 @@
Выделяет лагеря варваров на карте
-
+ Лагерь Варваров
@@ -74,22 +74,22 @@
Выделяет ресурсы на карте
-
+ Редкий
-
+ Необработанный редкий
-
+ Стратегический
-
+ Необработанный стратегический
-
+ Бонусный
-
+ Необработанный бонусный
@@ -100,10 +100,10 @@
Выделяет чудеса природы и чудеса света, построенные игроками
-
+ Чудо природы
-
+ Чудо света
@@ -122,9 +122,24 @@
Выделяет племенные поселения на карте
-
+ Племенное поселение
+
+ Настройки цвета RGB для пользовательских линз
+
+
+ синий
+
+
+ Введите значение от 0 до 255
+
+
+ зеленый
+
+
+ красный
+
diff --git a/Text/MoreLenses_Text_zh.xml b/Text/MoreLenses_Text_zh.xml
index 2f2b6b8..8d69ce4 100644
--- a/Text/MoreLenses_Text_zh.xml
+++ b/Text/MoreLenses_Text_zh.xml
@@ -36,10 +36,10 @@
高亮显示可被考古学家发掘的地块
-
+ 历史古迹
-
+ 海难遗址
@@ -76,7 +76,7 @@
高亮显示地图上的野蛮人营地
-
+ 蛮族哨站
@@ -87,22 +87,22 @@
高亮显示地图上的资源
-
+ 已开发奢侈品资源
-
+ 奢侈品资源
-
+ 已开发战略资源
-
+ 战略资源
-
+ 已开发加成资源
-
+ 加成资源
@@ -113,10 +113,10 @@
高亮显示自然奇观和玩家建造的世界奇观
-
+ 自然奇观
-
+ 世界奇观
@@ -135,7 +135,7 @@
高亮显示地图上的部落村庄
-
+ 部落村庄
@@ -146,15 +146,30 @@
高亮显示可建造国家公园的地块
-
+ 可立即建造国家公园
-
+ 修改其他地块后可建造国家公园
-
+ 修改后可建造国家公园
+
+ 用于自定义镜头的 RGB 颜色设置
+
+
+ 蓝
+
+
+ 输入 0 和 255 之间的值
+
+
+ 绿
+
+
+ 红
+