Skip to content

Commit 59f27f3

Browse files
authored
Merge pull request #52 from bszonye/bradd/integration
Integrate official release
2 parents 6e694d5 + eed86e5 commit 59f27f3

7 files changed

+116
-199
lines changed

README.md

+6-28
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,11 @@
1-
# Map Tacks 2.0.1 [<img align="right" src="maptacks.png" height="256" width="256">](https://steamcommunity.com/sharedfiles/filedetails/?id=1122081356)
2-
Adds new map icons
3-
Enhances list interface
4-
Fixes bugs and styling
1+
# Map Tacks 3.0.0 [<img align="right" src="maptacks.png" height="256" width="256">](https://steamcommunity.com/sharedfiles/filedetails/?id=1122081356)
2+
The Map Tacks mod is now
3+
[included in Civilization VI](https://civilization.com/news/entries/civilization-vi-gathering-storm-patch-update-april-2019/)!
54

6-
## New icons
7-
The map tack editor adds many new icons:
5+
This optional add-on makes a few small changes to the official interface:
86

9-
* districts
10-
* improvements
11-
* villages and barbarians
12-
* common unit actions
13-
* great people
14-
* wonders
15-
16-
All new icons have tooltips, including game effects for districts,
17-
improvements, and wonders.
18-
19-
## Scrollable map tack list
20-
The list dynamically resizes to show up to 15 map tacks, with a scrollbar to
21-
manage longer lists. It groups all named locations at the top, followed by all
22-
unnamed locations in numerical order.
23-
24-
## Bug fixes and restyling
25-
The mod fixes a few base-game bugs and styling problems. It handles large
26-
numbers of map tacks without breaking the popup list or causing performance
27-
problems. Unnamed markers now sort correctly when there are more than ten.
28-
Labels and controls have more consistent alignment and spacing. The mod
29-
improves overlapping and stacked icons, so that closer tacks always look
30-
closer, and the current player always appears on top in multiplayer.
7+
* improve the editor layout for Gathering Storm districts
8+
* fix some in-game text that still refers to map pins instead of tacks
319

3210
## Compatibility
3311
The Map Tacks mod does not affect saved games, so you can add it to a game in

mappinlistpanel.lua

+1-7
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,7 @@ function GetMapPinListEntry(iPlayerID :number, mapPinID :number)
122122
end
123123

124124
UpdateMapPinListEntry(iPlayerID, mapPinID);
125-
126125
Controls.MapPinEntryStack:CalculateSize();
127-
Controls.MapPinEntryStack:ReprocessAnchoring();
128126
end
129127
return mapPinEntry;
130128
end
@@ -155,16 +153,13 @@ function BuildMapPinList()
155153

156154
-- Recalc after sorting so the anchoring can account for hidden elements.
157155
Controls.MapPinEntryStack:CalculateSize();
158-
Controls.MapPinEntryStack:ReprocessAnchoring();
156+
159157
-- Dynamically resize scroll panel
160158
local maxY = 15 * 25 - 1; -- show up to 15 pins without a scrollbar
161159
local stackY = Controls.MapPinEntryStack:GetSizeY();
162160
local panelY = math.min(maxY, stackY);
163161
Controls.MapPinScrollPanel:SetSizeY(panelY);
164-
Controls.MapPinScrollPanel:ReprocessAnchoring();
165162
Controls.MapPinStack:CalculateSize();
166-
Controls.MapPinStack:ReprocessAnchoring();
167-
Controls.MapPinPanel:ReprocessAnchoring();
168163
end
169164

170165

@@ -239,7 +234,6 @@ function ShowHideHandler( bIsHide, bIsInit )
239234
end
240235
ContextPtr:SetShowHideHandler( ShowHideHandler );
241236

242-
243237
-- ===========================================================================
244238
function Initialize()
245239
Controls.AddPinButton:RegisterCallback( Mouse.eLClick, OnAddPinButton );

mappinmanager.lua

+16-35
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@ include( "SupportFunctions" );
88
include( "Colors" );
99
include( "MapTacks" );
1010

11+
1112
-- ===========================================================================
1213
-- CONSTANTS
1314
-- ===========================================================================
1415

1516
local ALPHA_DIM :number = 0.45;
16-
local COLOR_RED :number = 0xFF0101F5;
17-
local COLOR_YELLOW :number = 0xFF2DFFF8;
18-
local COLOR_GREEN :number = 0xFF4CE710;
17+
local COLOR_RED :number = UI.GetColorValueFromHexLiteral(0xFF0101F5);
18+
local COLOR_YELLOW :number = UI.GetColorValueFromHexLiteral(0xFF2DFFF8);
19+
local COLOR_GREEN :number = UI.GetColorValueFromHexLiteral(0xFF4CE710);
20+
local COLOR_WHITE :number = UI.GetColorValueFromHexLiteral(0xFFFFFFFF);
1921
local FLAGSTATE_NORMAL :number= 0;
2022
local FLAGSTATE_FORTIFIED :number= 1;
2123
local FLAGSTATE_EMBARKED :number= 2;
2224
local FLAGSTYLE_MILITARY :number= 0;
2325
local FLAGSTYLE_CIVILIAN :number= 1;
2426
local FLAGTYPE_UNIT :number= 0;
25-
local ZOOM_MULT_DELTA :number = .01;
2627
local TEXTURE_BASE :string = "MapPinFlag";
2728
local TEXTURE_MASK_BASE :string = "MapPinFlagMask";
2829

@@ -37,9 +38,6 @@ local m_SelectedContainer :table = ContextPtr:LookUpControl( "../SelectedMapPi
3738

3839
local m_InstanceManager :table = InstanceManager:new( "MapPinFlag", "Anchor", Controls.MapPinFlags );
3940

40-
local m_cameraFocusX :number = -1;
41-
local m_cameraFocusY :number = -1;
42-
local m_zoomMultiplier :number = 1;
4341
local m_MapPinInstances :table = {};
4442
local m_MapPinStacks :table = {};
4543

@@ -201,6 +199,7 @@ end
201199

202200
------------------------------------------------------------------
203201
function OnMapPinFlagRightClick( playerID : number, pinID : number )
202+
-- TODO it might be nice to enable this if shift is down
204203
--[[
205204
-- If we are the owner of this pin, delete the pin.
206205
if(playerID == Game.GetLocalPlayer()) then
@@ -232,10 +231,9 @@ end
232231
function MapPinFlag.SetColor( self : MapPinFlag )
233232
local primaryColor, secondaryColor = UI.GetPlayerColors(self.m_Player:GetID());
234233

235-
local darkerFlagColor :number = MapTacks.Tint(primaryColor, -85);
236-
local brighterFlagColor :number = MapTacks.Tint(primaryColor, 90);
237-
local brighterIconColor :number = MapTacks.Tint(secondaryColor, 20);
238-
-- local darkerIconColor :number = MapTacks.Tint(secondaryColor, -30);
234+
local darkerFlagColor :number = UI.DarkenLightenColor(primaryColor, -85, 255);
235+
local brighterFlagColor :number = UI.DarkenLightenColor(primaryColor, 90, 255);
236+
local brighterIconColor :number = UI.DarkenLightenColor(secondaryColor, 20, 255);
239237

240238
local iconType = MapTacks.IconType(self:GetMapPin()) or MapTacks.STOCK;
241239
-- set icon tint appropriate for the icon color
@@ -248,7 +246,7 @@ function MapPinFlag.SetColor( self : MapPinFlag )
248246
self.m_Instance.UnitIcon:SetColor(tintedIconColor);
249247
else
250248
-- full color
251-
self.m_Instance.UnitIcon:SetColor(-1); -- pure white
249+
self.m_Instance.UnitIcon:SetColor(COLOR_WHITE);
252250
end
253251
self.m_Instance.FlagBase:SetColor( primaryColor );
254252
self.m_Instance.FlagBaseOutline:SetColor( primaryColor );
@@ -417,13 +415,14 @@ function MapPinFlag.SetPosition( self : MapPinFlag, worldX : number, worldY : nu
417415
local pMapPin : table = self:GetMapPin();
418416
if (pMapPin ~= nil) then
419417
-- If there are multiple map pins sharing a hex, recenter them
420-
local stack = GetPinStack(pMapPin);
421-
local found = false;
422-
local depth = 0;
423-
for i, pin in ipairs(stack) do
418+
local kStack : table = GetPinStack(pMapPin);
419+
local found : boolean = false;
420+
local depth : number = 0;
421+
for i, pin in ipairs(kStack) do
424422
if pin == pMapPin then
425423
found = true;
426-
elseif not found then
424+
break;
425+
else
427426
depth = depth + 1;
428427
end
429428
end
@@ -466,23 +465,6 @@ end
466465
-- ===========================================================================
467466
-- Engine Event
468467
-- ===========================================================================
469-
-------------------------------------------------
470-
-- Zoom level calculation
471-
-------------------------------------------------
472-
function OnCameraUpdate( vFocusX:number, vFocusY:number, fZoomLevel:number )
473-
m_cameraFocusX = vFocusX;
474-
m_cameraFocusY = vFocusY;
475-
476-
-- If no change in the zoom, no update necessary.
477-
if( math.abs( (1-fZoomLevel) - m_zoomMultiplier ) < ZOOM_MULT_DELTA ) then
478-
return;
479-
end
480-
m_zoomMultiplier= 1-fZoomLevel;
481-
482-
-- Map pins do not really use zoom, so skip the refresh.
483-
-- Refresh();
484-
end
485-
486468
------------------------------------------------------------------
487469
function OnPlayerConnectChanged(iPlayerID)
488470
-- When a human player connects/disconnects, their unit flag tooltips need to be updated.
@@ -702,7 +684,6 @@ function Initialize()
702684
ContextPtr:SetShutdown( OnShutdown );
703685

704686
Events.BeginWonderReveal.Add( OnBeginWonderReveal );
705-
Events.Camera_Updated.Add( OnCameraUpdate );
706687
Events.CombatVisBegin.Add( OnCombatVisBegin );
707688
Events.CombatVisEnd.Add( OnCombatVisEnd );
708689
Events.EndWonderReveal.Add( OnEndWonderReveal );

mappinpopup.lua

+44-24
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ include( "PlayerTargetLogic" );
88
include( "ToolTipHelper" );
99
include( "MapTacks" );
1010

11+
1112
----------------------------------------------------------------
1213
-- Globals
1314
----------------------------------------------------------------
14-
local COLOR_YELLOW :number = 0xFF2DFFF8;
15-
local COLOR_WHITE :number = 0xFFFFFFFF;
15+
local COLOR_YELLOW : number = UI.GetColorValue("COLOR_YELLOW");
16+
local COLOR_WHITE : number = UI.GetColorValue("COLOR_WHITE");
1617

1718
local NO_EDIT_PIN_ID :number = -1;
1819
local g_editPinID :number = NO_EDIT_PIN_ID;
@@ -126,24 +127,46 @@ function PopulateIconOptions()
126127
g_iconOptionEntries = {};
127128
Controls.IconOptionStack:DestroyAllChildren();
128129

129-
-- calculate column width
130-
local columns = 7;
131-
for j, section in ipairs(g_iconPulldownOptions) do
132-
local width = #section;
133-
if columns < width and width <= 21 and 1 < j then
134-
columns = width;
130+
-- Fit the icons within 1024x768
131+
-- If a mod adds a ton of new improvements/districts we might need to add a scrollbar
132+
local MIN_COLS = 8;
133+
local MAX_COLS = 18;
134+
local MAX_ROWS = 12;
135+
136+
-- find the dimensions that have the fewest blank spaces that fits the minimum resolution
137+
local columns = MAX_COLS;
138+
local nMinBlanks = MAX_COLS * MAX_ROWS;
139+
for i=MIN_COLS,MAX_COLS do
140+
local nBlanks = 0;
141+
local nRows = 0;
142+
for j, section in ipairs(g_iconPulldownOptions) do
143+
nRows = nRows + math.ceil(#section / i);
144+
local remainder = #section % i;
145+
if remainder > 0 then
146+
nBlanks = nBlanks + (i - remainder);
147+
end
148+
end
149+
if nBlanks < nMinBlanks and nRows <= MAX_ROWS then
150+
nMinBlanks = nBlanks;
151+
columns = i;
135152
end
136153
end
137-
local sectionTable = {};
154+
print("Selected " .. columns .. " columns");
155+
138156
local controlTable = {};
139157
local newIconEntry = {};
140158
for j, section in ipairs(g_iconPulldownOptions) do
141159
g_iconOptionEntries[j] = {};
160+
local sectionTable = {};
142161
ContextPtr:BuildInstanceForControl( "IconOptionRowInstance", sectionTable, Controls.IconOptionStack );
143162
-- dynamically determine section spacing
144163
local ht = math.floor((#section + columns - 1) / columns);
145-
local wd = math.floor((#section + ht - 1) / ht);
146-
sectionTable.IconOptionRowStack:SetWrapWidth(40 * ht);
164+
local wd = columns;
165+
-- rebalance sections with very short final rows
166+
if (#section % wd) < MIN_COLS then
167+
wd = math.floor((#section + ht - 1) / ht);
168+
end
169+
sectionTable.IconOptionRowStack:SetWrapWidth(44 * wd);
147170
if j > 1 and (ht > 1 or columns < #g_iconPulldownOptions[j - 1]) then
148171
-- leave a break around multi-row sections
149172
sectionTable.IconOptionRowStack:SetOffsetY(8);
@@ -165,29 +188,26 @@ function PopulateIconOptions()
165188
g_iconOptionEntries[j][i] = newIconEntry;
166189

167190
UpdateIconOptionColor(i, j);
168-
end
169-
for i=#section+1,ht*wd do
170-
-- fill out section blocks with disabled boxes
171-
controlTable = {};
172-
ContextPtr:BuildInstanceForControl( "IconOptionInstance", controlTable, sectionTable.IconOptionRowStack );
173-
controlTable.IconOptionButton:SetDisabled(true);
174-
controlTable.Icon:SetHide(true);
191+
192+
if (#section % wd) ~= 0 then
193+
-- this section has a partially filled row, create a new stack at
194+
-- the end of the final full row, so it can be centered properly
195+
if (i % wd) == 0 and (i / wd) == (ht - 1) then
196+
sectionTable = {};
197+
ContextPtr:BuildInstanceForControl( "IconOptionRowInstance", sectionTable, Controls.IconOptionStack );
198+
sectionTable.IconOptionRowStack:SetWrapWidth(44 * wd);
199+
end
200+
end
175201
end
176202
end
177203

178204
-- set width dynamically according to widest section
179205
Controls.Window:SetSizeX(44 * columns + 30);
180206
Controls.OptionsStack:SetWrapWidth(44 * columns + 8);
181-
-- Controls.PinFrame:SetSizeX(44 * (columns - 4) + 2);
182207
Controls.IconOptionStack:CalculateSize();
183-
Controls.IconOptionStack:ReprocessAnchoring();
184208
Controls.OptionsStack:CalculateSize();
185-
Controls.OptionsStack:ReprocessAnchoring();
186209
Controls.WindowContentsStack:CalculateSize();
187-
Controls.WindowContentsStack:ReprocessAnchoring();
188210
Controls.WindowStack:CalculateSize();
189-
Controls.WindowStack:ReprocessAnchoring();
190-
Controls.WindowContainer:ReprocessAnchoring();
191211
end
192212

193213
-- ===========================================================================

mappinpopup.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<Context xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="..\..\..\..\..\CivTech\Libs\ForgeUI\ForgeUI_Assets\Controls.xsd"
33
ColorSet="Beige_Black" FontStyle="Shadow">
44

5-
65
<Box Color="0,0,0,150" Size="parent,parent" ConsumeMouse="1">
76
<AlphaAnim ID="PopupAlphaIn" AlphaBegin="0" AlphaEnd="1" Speed="3" Function="Root" Cycle="Once" Size="parent,parent">
87
<SlideAnim ID="PopupSlideIn" Start="0,-20" End="0,0" Speed="3" Function="Root" Cycle="Once" Size="parent,parent">
@@ -45,7 +44,7 @@
4544
</Box>
4645

4746
<Instance Name="IconOptionRowInstance">
48-
<Stack ID="IconOptionRowStack" Anchor="C,T" StackGrowth="Down" Padding="4" WrapWidth="40" WrapGrowth="Right"/>
47+
<Stack ID="IconOptionRowStack" Anchor="C,T" StackGrowth="Right" Padding="4" WrapWidth="40" WrapGrowth="Down"/>
4948
</Instance>
5049

5150
<Instance Name="IconOptionInstance">

0 commit comments

Comments
 (0)