@@ -8,21 +8,22 @@ include( "SupportFunctions" );
8
8
include ( " Colors" );
9
9
include ( " MapTacks" );
10
10
11
+
11
12
-- ===========================================================================
12
13
-- CONSTANTS
13
14
-- ===========================================================================
14
15
15
16
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 );
19
21
local FLAGSTATE_NORMAL :number = 0 ;
20
22
local FLAGSTATE_FORTIFIED :number = 1 ;
21
23
local FLAGSTATE_EMBARKED :number = 2 ;
22
24
local FLAGSTYLE_MILITARY :number = 0 ;
23
25
local FLAGSTYLE_CIVILIAN :number = 1 ;
24
26
local FLAGTYPE_UNIT :number = 0 ;
25
- local ZOOM_MULT_DELTA :number = .01 ;
26
27
local TEXTURE_BASE :string = " MapPinFlag" ;
27
28
local TEXTURE_MASK_BASE :string = " MapPinFlagMask" ;
28
29
@@ -37,9 +38,6 @@ local m_SelectedContainer :table = ContextPtr:LookUpControl( "../SelectedMapPi
37
38
38
39
local m_InstanceManager :table = InstanceManager :new ( " MapPinFlag" , " Anchor" , Controls .MapPinFlags );
39
40
40
- local m_cameraFocusX :number = - 1 ;
41
- local m_cameraFocusY :number = - 1 ;
42
- local m_zoomMultiplier :number = 1 ;
43
41
local m_MapPinInstances :table = {};
44
42
local m_MapPinStacks :table = {};
45
43
201
199
202
200
---- --------------------------------------------------------------
203
201
function OnMapPinFlagRightClick ( playerID : number , pinID : number )
202
+ -- TODO it might be nice to enable this if shift is down
204
203
--[[
205
204
-- If we are the owner of this pin, delete the pin.
206
205
if(playerID == Game.GetLocalPlayer()) then
232
231
function MapPinFlag .SetColor ( self : MapPinFlag )
233
232
local primaryColor , secondaryColor = UI .GetPlayerColors (self .m_Player :GetID ());
234
233
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 );
239
237
240
238
local iconType = MapTacks .IconType (self :GetMapPin ()) or MapTacks .STOCK ;
241
239
-- set icon tint appropriate for the icon color
@@ -248,7 +246,7 @@ function MapPinFlag.SetColor( self : MapPinFlag )
248
246
self .m_Instance .UnitIcon :SetColor (tintedIconColor );
249
247
else
250
248
-- full color
251
- self .m_Instance .UnitIcon :SetColor (- 1 ); -- pure white
249
+ self .m_Instance .UnitIcon :SetColor (COLOR_WHITE );
252
250
end
253
251
self .m_Instance .FlagBase :SetColor ( primaryColor );
254
252
self .m_Instance .FlagBaseOutline :SetColor ( primaryColor );
@@ -417,13 +415,14 @@ function MapPinFlag.SetPosition( self : MapPinFlag, worldX : number, worldY : nu
417
415
local pMapPin : table = self :GetMapPin ();
418
416
if (pMapPin ~= nil ) then
419
417
-- 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
424
422
if pin == pMapPin then
425
423
found = true ;
426
- elseif not found then
424
+ break ;
425
+ else
427
426
depth = depth + 1 ;
428
427
end
429
428
end
466
465
-- ===========================================================================
467
466
-- Engine Event
468
467
-- ===========================================================================
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
-
486
468
---- --------------------------------------------------------------
487
469
function OnPlayerConnectChanged (iPlayerID )
488
470
-- When a human player connects/disconnects, their unit flag tooltips need to be updated.
@@ -702,7 +684,6 @@ function Initialize()
702
684
ContextPtr :SetShutdown ( OnShutdown );
703
685
704
686
Events .BeginWonderReveal .Add ( OnBeginWonderReveal );
705
- Events .Camera_Updated .Add ( OnCameraUpdate );
706
687
Events .CombatVisBegin .Add ( OnCombatVisBegin );
707
688
Events .CombatVisEnd .Add ( OnCombatVisEnd );
708
689
Events .EndWonderReveal .Add ( OnEndWonderReveal );
0 commit comments