diff --git a/Lenses/MovementCosts/ModLens_MovementCosts.lua b/Lenses/MovementCosts/ModLens_MovementCosts.lua new file mode 100644 index 0000000..f02b5b1 --- /dev/null +++ b/Lenses/MovementCosts/ModLens_MovementCosts.lua @@ -0,0 +1,122 @@ +local LENS_NAME = "ML_MovementCosts" +local ML_LENS_LAYER = UILens.CreateLensLayerHash("Hex_Coloring_Appeal_Level") + +-- =========================================================================== +-- Movement Costs Lens Support +-- =========================================================================== + +local function IsPortal(plot) + local improvementType = plot:GetImprovementType() + if improvementType == nil then + return false + end + + local improvement = GameInfo.Improvements[improvementType] + if improvement == nil then + return false + end + + local type = improvement.ImprovementType + if type == nil then + return false + end + + --IMPROVEMENT_MOUNTAIN_ROAD is Qhapaq Ñan improvement + return type == "IMPROVEMENT_MOUNTAIN_ROAD" or type == "IMPROVEMENT_MOUNTAIN_TUNNEL" +end + +local function GetMovementCosts(plot) + if plot:IsImpassable() then + return -1 + end + + if plot:IsCity() and plot:GetOwner() ~= Game.GetLocalPlayer() then + return -1 + end + + if plot:IsRoute() then + local routeInfo = GameInfo.Routes[plot:GetRouteType()]; + if (routeInfo ~= nil and routeInfo.MovementCost ~= nil) then + return routeInfo.MovementCost + end + end + + return plot:GetMovementCost() +end + +-- =========================================================================== +-- Exported functions +-- =========================================================================== + +local function OnGetColorPlotTable() + local mapWidth, mapHeight = Map.GetGridSize() + local localPlayer: number = Game.GetLocalPlayer() + local localPlayerVis:table = PlayersVisibility[localPlayer] + + local colorLookup = { + [0.25] = "COLOR_RAILROAD", + [0.5] = "COLOR_MODERN_ROAD", + [0.75] = "COLOR_INDUSTRIAL_ROAD", + [1] = "COLOR_MOVEMENT_COSTS_ONE", + [2] = "COLOR_MOVEMENT_COSTS_TWO", + [3] = "COLOR_MOVEMENT_COSTS_THREE", + [-1] = "COLOR_IMPASSABLE", + } + + local colorPlot = {} + local colorString: string + + for i = 0, (mapWidth * mapHeight) - 1, 1 do + local pPlot: table = Map.GetPlotByIndex(i) + if localPlayerVis:IsRevealed(pPlot:GetX(), pPlot:GetY()) and not pPlot:IsWater() then + colorString = nil + if IsPortal(pPlot) then + colorString = "COLOR_PORTAL" + else + local movementCosts = GetMovementCosts(pPlot) + if colorLookup[movementCosts] ~= nil then + colorString = colorLookup[movementCosts] + end + end + + local colorValue = UI.GetColorValue(colorString) + if colorString ~= nil and colorValue then + if colorPlot[colorValue] == nil then + colorPlot[colorValue] = {} + end + + table.insert(colorPlot[colorValue], i) + end + end + end + + return colorPlot +end + +local MovementCostsLensEntry = { + LensButtonText = "LOC_HUD_MOVEMENTCOSTS_LENS", + LensButtonTooltip = "LOC_HUD_MOVEMENTCOSTS_LENS_TOOLTIP", + Initialize = nil, + GetColorPlotTable = OnGetColorPlotTable +} + +-- minimappanel.lua +if g_ModLenses ~= nil then + g_ModLenses[LENS_NAME] = MovementCostsLensEntry +end + +-- modallenspanel.lua +if g_ModLensModalPanel ~= nil then + g_ModLensModalPanel[LENS_NAME] = {} + g_ModLensModalPanel[LENS_NAME].LensTextKey = "LOC_HUD_MOVEMENTCOSTS_LENS" + g_ModLensModalPanel[LENS_NAME].Legend = { + {"LOC_TOOLTIP_MOVEMENTCOSTS_LENS_RAILROAD", UI.GetColorValue("COLOR_RAILROAD")}, + {"LOC_TOOLTIP_MOVEMENTCOSTS_LENS_MODERN_ROAD", UI.GetColorValue("COLOR_MODERN_ROAD")}, + {"LOC_TOOLTIP_MOVEMENTCOSTS_LENS_INDUSTRIAL_ROAD", UI.GetColorValue("COLOR_INDUSTRIAL_ROAD")}, + {"LOC_TOOLTIP_MOVEMENTCOSTS_LENS_COSTS_ONE", UI.GetColorValue("COLOR_MOVEMENT_COSTS_ONE")}, + {"LOC_TOOLTIP_MOVEMENTCOSTS_LENS_COSTS_TWO", UI.GetColorValue("COLOR_MOVEMENT_COSTS_TWO")}, + {"LOC_TOOLTIP_MOVEMENTCOSTS_LENS_COSTS_THREE", UI.GetColorValue("COLOR_MOVEMENT_COSTS_THREE")}, + {"LOC_TOOLTIP_MOVEMENTCOSTS_LENS_PORTAL", UI.GetColorValue("COLOR_PORTAL")}, + {"LOC_TOOLTIP_MOVEMENTCOSTS_LENS_IMPASSABLE", UI.GetColorValue("COLOR_IMPASSABLE")} + } +end diff --git a/MoreLenses.modinfo b/MoreLenses.modinfo index 1405f25..45288ad 100644 --- a/MoreLenses.modinfo +++ b/MoreLenses.modinfo @@ -78,6 +78,7 @@ Lenses/Barbarian/ModLens_Barbarian.lua Lenses/Naturalist/ModLens_Naturalist.lua Lenses/Wonder/ModLens_Wonder.lua + Lenses/MovementCosts/ModLens_MovementCosts.lua @@ -194,6 +195,7 @@ Lenses/CityOverlap/ModLens_CityOverlap.lua Lenses/Resource/ModLens_Resource.xml Lenses/Resource/ModLens_Resource.lua + Lenses/MovementCosts/ModLens_MovementCosts.lua Settings/ml_settingspanel.xml diff --git a/MoreLenses_Colors.sql b/MoreLenses_Colors.sql index 8525866..2581c70 100644 --- a/MoreLenses_Colors.sql +++ b/MoreLenses_Colors.sql @@ -117,6 +117,24 @@ VALUES ( 'COLOR_ALT_SETTLER_HILL', '0', '1', INSERT INTO Colors ( Type, Red, Green, Blue, Alpha) VALUES ( 'COLOR_ALT_SETTLER_REGULAR', '0.75', '0.75', '0.75', '0.5'); +-- Movement Costs Colors +INSERT INTO Colors ( Type, Red, Green, Blue, Alpha) +VALUES ( 'COLOR_RAILROAD', '0', '1', '0', '0.5'); +INSERT INTO Colors ( Type, Red, Green, Blue, Alpha) +VALUES ( 'COLOR_MODERN_ROAD', '0', '0.8', '0', '0.5'); +INSERT INTO Colors ( Type, Red, Green, Blue, Alpha) +VALUES ( 'COLOR_INDUSTRIAL_ROAD', '0', '0.6', '0', '0.5'); +INSERT INTO Colors ( Type, Red, Green, Blue, Alpha) +VALUES ( 'COLOR_MOVEMENT_COSTS_ONE', '0.68', '0.68', '0.68', '0.5'); +INSERT INTO Colors ( Type, Red, Green, Blue, Alpha) +VALUES ( 'COLOR_MOVEMENT_COSTS_TWO', '1', '0.70', '0.35', '0.5'); +INSERT INTO Colors ( Type, Red, Green, Blue, Alpha) +VALUES ( 'COLOR_MOVEMENT_COSTS_THREE', '1', '0.47', '0', '0.5'); +INSERT INTO Colors ( Type, Red, Green, Blue, Alpha) +VALUES ( 'COLOR_PORTAL', '0.2', '0.2', '1', '0.5'); +INSERT INTO Colors ( Type, Red, Green, Blue, Alpha) +VALUES ( 'COLOR_IMPASSABLE', '1', '0', '0', '0.5'); + -- Test Colors INSERT INTO Colors ( Type, Red, Green, Blue, Alpha) VALUES ( 'COLOR_MORELENSES_BLACK', '0', '0', '0', '0.5'); diff --git a/README.md b/README.md index 5e6519d..e7bb3ce 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,12 @@ Highlights goody huts on the map. Automatically applies when a scout / ranger is ![Imgur](http://i.imgur.com/TnnErfb.jpg) ___ +___ +#### Movement Costs Lens: +Visualizes movement costs. + +![Imgur](https://i.imgur.com/bQrw8Vv.jpg) +___ ## Installation If you are using [Chao's QUI](https://github.com/chaorace/cqui) follow these steps: diff --git a/Text/MoreLenses_Text.xml b/Text/MoreLenses_Text.xml index d499e99..1e692d5 100644 --- a/Text/MoreLenses_Text.xml +++ b/Text/MoreLenses_Text.xml @@ -170,6 +170,38 @@ Needs fixing to be used for a park + + + Movement Costs + + + Visualizes the movement costs + + + 0.25 + + + 0.5 + + + 0.75 + + + 1 + + + 2 + + + 3 + + + Portal + + + Impassable + + More Lenses - Settings Panel diff --git a/Text/MoreLenses_Text_de.xml b/Text/MoreLenses_Text_de.xml index 6876f59..d627725 100644 --- a/Text/MoreLenses_Text_de.xml +++ b/Text/MoreLenses_Text_de.xml @@ -153,5 +153,37 @@ Benötigt Verbesserung um zum Nationalpark zu werden + + + Fortbewegungskosten + + + Visualisiert die Fortbewegungskosten + + + 0.25 + + + 0.5 + + + 0.75 + + + 1 + + + 2 + + + 3 + + + Portal + + + Unpassierbar + + diff --git a/Text/MoreLenses_Text_es.xml b/Text/MoreLenses_Text_es.xml index 48fb4fd..c4b382d 100644 --- a/Text/MoreLenses_Text_es.xml +++ b/Text/MoreLenses_Text_es.xml @@ -126,5 +126,37 @@ Aldea Tribal + + + Gastos de transporte + + + Visualiza los costes de movimiento + + + 0.25 + + + 0.5 + + + 0.75 + + + 1 + + + 2 + + + 3 + + + Portal + + + Intransitable + + diff --git a/Text/MoreLenses_Text_fr.xml b/Text/MoreLenses_Text_fr.xml index 4c5228b..da6b654 100644 --- a/Text/MoreLenses_Text_fr.xml +++ b/Text/MoreLenses_Text_fr.xml @@ -126,5 +126,37 @@ Village Tribal + + + coûts des mouvements + + + Visualise les coûts de déplacement + + + 0.25 + + + 0.5 + + + 0.75 + + + 1 + + + 2 + + + 3 + + + Portail + + + Impraticable + + diff --git a/Text/MoreLenses_Text_it.xml b/Text/MoreLenses_Text_it.xml index 05786db..de4ef53 100644 --- a/Text/MoreLenses_Text_it.xml +++ b/Text/MoreLenses_Text_it.xml @@ -153,5 +153,37 @@ Necessita una lavorazione per poterci costruire il Parco Nazionale + + + Costi di movimento + + + Visualizza i costi di movimento + + + 0.25 + + + 0.5 + + + 0.75 + + + 1 + + + 2 + + + 3 + + + Portale + + + Impraticabile + + diff --git a/Text/MoreLenses_Text_jp.xml b/Text/MoreLenses_Text_jp.xml index 060385c..c6f0cac 100644 --- a/Text/MoreLenses_Text_jp.xml +++ b/Text/MoreLenses_Text_jp.xml @@ -153,5 +153,37 @@ 要修正タイル + + + 移動コスト + + + 移動コストを可視化 + + + 0.25 + + + 0.5 + + + 0.75 + + + 1 + + + 2 + + + 3 + + + ポータル + + + 通行不可 + + diff --git a/Text/MoreLenses_Text_ko.xml b/Text/MoreLenses_Text_ko.xml index 814fbb6..d16d9d0 100644 --- a/Text/MoreLenses_Text_ko.xml +++ b/Text/MoreLenses_Text_ko.xml @@ -126,5 +126,37 @@ 부족 마을 + + + 이사 비용 + + + 이동 비용 시각화 + + + 0.25 + + + 0.5 + + + 0.75 + + + 1 + + + 2 + + + 3 + + + 포털 + + + 통과 불가 + + diff --git a/Text/MoreLenses_Text_pl.xml b/Text/MoreLenses_Text_pl.xml index 49eb262..cd9cfb9 100644 --- a/Text/MoreLenses_Text_pl.xml +++ b/Text/MoreLenses_Text_pl.xml @@ -126,5 +126,37 @@ Wioska plemienna + + + Koszty przeniesienia + + + Wizualizuje koszty ruchu + + + 0.25 + + + 0.5 + + + 0.75 + + + 1 + + + 2 + + + 3 + + + Portal + + + Nieprzejezdny + + diff --git a/Text/MoreLenses_Text_pt_br.xml b/Text/MoreLenses_Text_pt_br.xml index 28df68d..5d8f0ed 100644 --- a/Text/MoreLenses_Text_pt_br.xml +++ b/Text/MoreLenses_Text_pt_br.xml @@ -210,5 +210,37 @@ Ativa automaticamente a lente de batedores ao selecionar um qualquer unidade militar. + + + Custos de movimentação + + + Visualiza os custos de movimentação + + + 0.25 + + + 0.5 + + + 0.75 + + + 1 + + + 2 + + + 3 + + + Portal + + + Intransitável + + diff --git a/Text/MoreLenses_Text_ru.xml b/Text/MoreLenses_Text_ru.xml index 656f577..7dfc806 100644 --- a/Text/MoreLenses_Text_ru.xml +++ b/Text/MoreLenses_Text_ru.xml @@ -126,5 +126,37 @@ Племенное поселение + + + Расходы на перемещение + + + Визуализация затрат на перемещение + + + 0.25 + + + 0.5 + + + 0.75 + + + 1 + + + 2 + + + 3 + + + Портал + + + Непроходимый + + diff --git a/Text/MoreLenses_Text_zh.xml b/Text/MoreLenses_Text_zh.xml index 2f2b6b8..79ec24a 100644 --- a/Text/MoreLenses_Text_zh.xml +++ b/Text/MoreLenses_Text_zh.xml @@ -156,5 +156,37 @@ 修改后可建造国家公园 + + + 变动费用 + + + 可视化运动成本 + + + 0.25 + + + 0.5 + + + 0.75 + + + 1 + + + 2 + + + 3 + + + 门户网站 + + + 无法通行 + +