Skip to content

Commit

Permalink
Merge pull request #49 from bszonye/bradd/editor-layout
Browse files Browse the repository at this point in the history
Revise editor layout
  • Loading branch information
bszonye authored Feb 28, 2019
2 parents 0d79976 + 332cddf commit c3bef0b
Show file tree
Hide file tree
Showing 8 changed files with 658 additions and 401 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Map Tacks 1.2.0 [<img align="right" src="maptacks.png" height="256" width="256">](https://steamcommunity.com/sharedfiles/filedetails/?id=1122081356)
# Map Tacks 2.0.0 [<img align="right" src="maptacks.png" height="256" width="256">](https://steamcommunity.com/sharedfiles/filedetails/?id=1122081356)
Adds new map icons
Enhances list interface
Fixes bugs and styling

## New icons
The map tack editor adds many new icons:

* districts, customized with civilization unique districts
* improvements, including unique & bonus improvements from civilization
abilities, city states, and governors
* unit actions like harvesting, repair, archaeology, and espionage
* scouting markers for barbarian outposts and tribal villages
* all types of great people, and
* a golden tile to mark wonder sites
* districts
* improvements
* villages and barbarians
* common unit actions
* great people
* wonders

All new icons have tooltips, with game effects for districts and improvements.
All new icons have tooltips, including game effects for districts,
improvements, and wonders.

## Scrollable map tack list
The list dynamically resizes to show up to 15 map tacks, with a scrollbar to
Expand Down
25 changes: 10 additions & 15 deletions mappinlistpanel.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
----------------------------------------------------------------
----------------------------------------------------------------
-- Map Pin List Panel
----------------------------------------------------------------
----------------------------------------------------------------

include( "MapTacks" );


local m_playerMapPins :table = {};
local m_MapPinListButtonToPinEntry :table = {}; -- map pin entries keyed to their MapPinListButton object string names. This is currently just used for sorting, please becareful if you use it for anything else as it is cleared after use.

local PlayerMapPinListTTStr :string = Locale.Lookup( "LOC_MAP_PIN_LIST_REMOTE_PIN_TOOLTIP" );
local RemoteMapPinListTTStr :string = Locale.Lookup( "LOC_MAP_PIN_LIST_REMOTE_PIN_TOOLTIP" );

-------------------------------------------------
-------------------------------------------------
-- Map Pin List Scripting
-------------------------------------------------
function GetMapPinConfig(iPlayerID :number, mapPinID :number)
Expand All @@ -31,7 +30,7 @@ function SetMapPinIcon(imageControl :table, mapPinIconName :string)
if(imageControl ~= nil and mapPinIconName ~= nil) then
local iconName = mapPinIconName;
if(not imageControl:SetIcon(iconName)) then
imageControl:SetIcon("ICON_MAP_PIN_SQUARE");
imageControl:SetIcon(MapTacks.UNKNOWN);
end
end
end
Expand Down Expand Up @@ -113,7 +112,7 @@ function GetMapPinListEntry(iPlayerID :number, mapPinID :number)
else
mapPinEntry.EditMapPin:SetHide(true);
end

mapPinEntry.MapPinListButton:RegisterCallback(Mouse.eLClick, OnMapPinEntryLeftClick);

if(iPlayerID == Game.GetLocalPlayer()) then
Expand Down Expand Up @@ -153,7 +152,7 @@ function BuildMapPinList()

-- Don't need this anymore, get rid of the references so they can be properly released!
m_MapPinListButtonToPinEntry = {};

-- Recalc after sorting so the anchoring can account for hidden elements.
Controls.MapPinEntryStack:CalculateSize();
Controls.MapPinEntryStack:ReprocessAnchoring();
Expand All @@ -169,7 +168,7 @@ function BuildMapPinList()
end


-------------------------------------------------
-------------------------------------------------
-- Button Event Handlers
-------------------------------------------------
function OnMapPinEntryLeftClick(iPlayerID :number, mapPinID :number)
Expand Down Expand Up @@ -208,7 +207,7 @@ function OnAddPinButton()
end


-------------------------------------------------
-------------------------------------------------
-- External Event Handlers
-------------------------------------------------
function OnPlayerInfoChanged(playerID)
Expand All @@ -235,8 +234,8 @@ end
-- ShowHideHandler
-------------------------------------------------
function ShowHideHandler( bIsHide, bIsInit )
if(not bIsHide) then
end
if(not bIsHide) then
end
end
ContextPtr:SetShowHideHandler( ShowHideHandler );

Expand All @@ -249,11 +248,7 @@ function Initialize()
Events.InterfaceModeChanged.Add( OnInterfaceModeChanged );
Events.LocalPlayerChanged.Add( OnLocalPlayerChanged );


BuildMapPinList();

-- XXX debug
-- Controls.AddPinButton:RegisterCallback( Mouse.eRClick, MapTacksTestPattern );
end
Initialize()

Expand Down
88 changes: 46 additions & 42 deletions mappinmanager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ include( "SupportFunctions" );
include( "Colors" );
include( "MapTacks" );


-- ===========================================================================
-- CONSTANTS
-- ===========================================================================
Expand Down Expand Up @@ -78,20 +77,20 @@ hstructure MapPinFlag

m_InstanceManager : table; -- The instance manager that made the control set.
m_Instance : table; -- The instanced control set.

m_Type : number; -- Pin type
m_IsSelected : boolean;
m_IsCurrentlyVisible : boolean;
m_IsForceHide : boolean;
m_IsDimmed : boolean;
m_OverrideDimmed : boolean;
m_OverrideDim : boolean;

m_Player : table;
m_pinID : number; -- The pin ID. Keeping just the ID, rather than a reference because there will be times when we need the value, but the pin instance will not exist.
end

-- Create one instance of the meta object as a global variable with the same name as the data structure portion.
-- Create one instance of the meta object as a global variable with the same name as the data structure portion.
-- This allows us to do a MapPinFlag:new, so the naming looks consistent.
MapPinFlag = hmake MapPinFlagMeta {};

Expand Down Expand Up @@ -123,15 +122,15 @@ function MapPinFlag.new( self : MapPinFlagMeta, playerID: number, pinID : number
if (m_MapPinInstances[playerID] == nil) then
m_MapPinInstances[playerID] = {};
end

m_MapPinInstances[playerID][pinID] = o;
end

------------------------------------------------------------------
function MapPinFlag.destroy( self : MapPinFlag )
if ( self.m_InstanceManager ~= nil ) then
if ( self.m_InstanceManager ~= nil ) then
self:UpdateSelected( false );

if (self.m_Instance ~= nil) then
self.m_InstanceManager:ReleaseInstance( self.m_Instance );
m_MapPinInstances[ self.m_Player:GetID() ][ self.m_pinID ] = nil;
Expand Down Expand Up @@ -159,7 +158,7 @@ function MapPinFlag.Initialize( self : MapPinFlag, playerID: number, pinID : num
self.m_IsForceHide = false;
self.m_IsDimmed = false;
self.m_OverrideDimmed = false;

self.m_Player = Players[playerID];
self.m_pinID = pinID;

Expand Down Expand Up @@ -193,7 +192,7 @@ function OnMapPinFlagLeftClick( playerID : number, pinID : number )
local flagInstance = GetMapPinFlag( playerID, pinID );
if (flagInstance ~= nil) then
local pMapPin = flagInstance:GetMapPin();
if(pMapPin ~= nil) then
if(pMapPin ~= nil) then
LuaEvents.MapPinPopup_RequestMapPin(pMapPin:GetHexX(), pMapPin:GetHexY());
end
end
Expand All @@ -220,7 +219,7 @@ function MapPinFlag.SetInteractivity( self : MapPinFlag )
local localPlayerID :number = Game.GetLocalPlayer();
local flagPlayerID :number = self.m_Player:GetID();
local pinID :number = self.m_pinID;


self.m_Instance.NormalButton:SetVoid1( flagPlayerID );
self.m_Instance.NormalButton:SetVoid2( pinID );
Expand All @@ -231,23 +230,25 @@ end
------------------------------------------------------------------
-- Set the flag color based on the player colors.
function MapPinFlag.SetColor( self : MapPinFlag )
local primaryColor, secondaryColor = MapTacksColors(self.m_Player:GetID());

local darkerFlagColor :number = MapTacksTint(primaryColor, -85);
local brighterFlagColor :number = MapTacksTint(primaryColor, 90);
local brighterIconColor :number = MapTacksTint(secondaryColor, 20);
-- local darkerIconColor :number = MapTacksTint(secondaryColor, -30);

local iconType = MapTacksType(self:GetMapPin()) or MAPTACKS_STOCK;
-- print(iconName);
local primaryColor, secondaryColor = UI.GetPlayerColors(self.m_Player:GetID());

local darkerFlagColor :number = MapTacks.Tint(primaryColor, -85);
local brighterFlagColor :number = MapTacks.Tint(primaryColor, 90);
local brighterIconColor :number = MapTacks.Tint(secondaryColor, 20);
-- local darkerIconColor :number = MapTacks.Tint(secondaryColor, -30);

local iconType = MapTacks.IconType(self:GetMapPin()) or MapTacks.STOCK;
-- set icon tint appropriate for the icon color
if iconType <= MAPTACKS_WHITE then
if iconType <= MapTacks.WHITE then
-- stock & white map pins
self.m_Instance.UnitIcon:SetColor( brighterIconColor );
elseif iconType == MAPTACKS_GRAY then
elseif iconType == MapTacks.GRAY then
-- shaded icons: match midtones to stock pin color
local tintedIconColor = MapTacksIconTint(brighterIconColor);
local tintedIconColor = MapTacks.IconTint(brighterIconColor);
self.m_Instance.UnitIcon:SetColor(tintedIconColor);
else
-- full color
self.m_Instance.UnitIcon:SetColor(-1); -- pure white
end
self.m_Instance.FlagBase:SetColor( primaryColor );
self.m_Instance.FlagBaseOutline:SetColor( primaryColor );
Expand All @@ -265,19 +266,23 @@ function MapPinFlag.SetFlagUnitEmblem( self : MapPinFlag )
local pMapPin = self:GetMapPin();
if pMapPin ~= nil then
local iconName = pMapPin:GetIconName();
local iconType = MapTacksType(pMapPin);
if iconType == MAPTACKS_COLOR then
self.m_Instance.DistrictIcon:SetIcon(iconName);
self.m_Instance.DistrictIcon:SetHide(false);
local iconType = MapTacks.IconType(pMapPin);
if iconType == MapTacks.HEX then
-- district icons are embedded into the tack head (HexIcon)
if not self.m_Instance.HexIcon:SetIcon(iconName) then
self.m_Instance.HexIcon:SetIcon(MapTacks.UNKNOWN);
end
self.m_Instance.HexIcon:SetHide(false);
self.m_Instance.UnitIcon:SetHide(true);
else
local size = (iconType == MAPTACKS_STOCK and 24) or 26;
-- other icons sit on top of the tack (UnitIcon)
local size = MapTacks.iconSizes[iconType];
self.m_Instance.UnitIcon:SetSizeVal(size, size);
if not self.m_Instance.UnitIcon:SetIcon(iconName) then
self.m_Instance.UnitIcon:SetIcon("ICON_MAP_PIN_UNKNOWN_WHITE");
self.m_Instance.UnitIcon:SetIcon(MapTacks.UNKNOWN);
end
self.m_Instance.UnitIcon:SetHide(false);
self.m_Instance.DistrictIcon:SetHide(true);
self.m_Instance.HexIcon:SetHide(true);
end

end
Expand All @@ -297,14 +302,14 @@ function MapPinFlag.OverrideDimmed( self : MapPinFlag, bOverride : boolean )
self.m_OverrideDimmed = bOverride;
self:UpdateDimmedState();
end

-----------------------------------------------------------------
-- Set the flag's alpha state, based on the current dimming flags.
function MapPinFlag.UpdateDimmedState( self : MapPinFlag )
if( self.m_IsDimmed and not self.m_OverrideDimmed ) then
self.m_Instance.FlagRoot:SetAlpha( ALPHA_DIM );
else
self.m_Instance.FlagRoot:SetAlpha( 1.0 );
self.m_Instance.FlagRoot:SetAlpha( 1.0 );
end
end

Expand All @@ -328,10 +333,10 @@ end
function MapPinFlag.UpdateFlagType( self : MapPinFlag )
local textureName:string;
local maskName:string;

textureName = TEXTURE_BASE;
maskName = TEXTURE_MASK_BASE;

self.m_Instance.FlagBaseDarken:SetTexture( textureName );
self.m_Instance.FlagBaseLighten:SetTexture( textureName );
self.m_Instance.FlagBase:SetTexture( textureName );
Expand All @@ -340,7 +345,7 @@ function MapPinFlag.UpdateFlagType( self : MapPinFlag )
self.m_Instance.NormalSelect:SetTexture( textureName );
self.m_Instance.FlagOver:SetTexture( textureName );
self.m_Instance.LightEffect:SetTexture( textureName );

self.m_Instance.NormalScrollAnim:SetMask( maskName );
end

Expand Down Expand Up @@ -379,18 +384,18 @@ end
-- The selection state has changed.
function MapPinFlag.UpdateSelected( self : MapPinFlag, isSelected : boolean )
self.m_IsSelected = isSelected;

self.m_Instance.NormalSelect:SetHide( not self.m_IsSelected );


-- If selected, change our parent to the selection container so we are on top in the drawing order
if( self.m_IsSelected ) then
self.m_Instance.Anchor:ChangeParent( m_SelectedContainer );
else
-- Re-attach back to the manager parent
self.m_Instance.Anchor:ChangeParent( self.m_InstanceManager.m_ParentControl );
-- Re-attach back to the manager parent
self.m_Instance.Anchor:ChangeParent( self.m_InstanceManager.m_ParentControl );
end

self:OverrideDimmed( self.m_IsSelected );
end

Expand Down Expand Up @@ -449,7 +454,7 @@ function CreateMapPinFlag(mapPinCfg : table)
if(flagInstance ~= nil) then
-- Flag already exists, we're probably just reusing the pinID, refresh the pin.
flagInstance:UpdateName();
flagInstance:UpdatePosition();
flagInstance:UpdatePosition();
return;
end

Expand Down Expand Up @@ -621,7 +626,6 @@ function StackMapPin(pMapPin :table)
local iW, iH = Map.GetGridSize();
local y = pMapPin:GetHexY() % iH;
local x = pMapPin:GetHexX() % iW;
-- print(string.format('%d %d', x, y));
local stack = m_MapPinStacks[y][x];
if stack then
stack[#stack + 1] = pMapPin;
Expand Down Expand Up @@ -699,7 +703,7 @@ function Initialize()

Events.BeginWonderReveal.Add( OnBeginWonderReveal );
Events.Camera_Updated.Add( OnCameraUpdate );
Events.CombatVisBegin.Add( OnCombatVisBegin );
Events.CombatVisBegin.Add( OnCombatVisBegin );
Events.CombatVisEnd.Add( OnCombatVisEnd );
Events.EndWonderReveal.Add( OnEndWonderReveal );
Events.LocalPlayerChanged.Add(OnLocalPlayerChanged);
Expand Down
18 changes: 8 additions & 10 deletions mappinmanager.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<Context >
<Container ID="MapPinFlags"/>

<Container ID="MapPinFlags"/>

<Instance Name="MapPinFlag">
<Instance Name="MapPinFlag">
<WorldAnchor ID="Anchor">
<Container ID="FlagRoot" Anchor="C,B" Size="48,48">
<Container Anchor="C,C" Size="50,50">
Expand All @@ -23,7 +21,7 @@
</Image>

<Button ID="NormalButton" Anchor="C,T" Size="50,50" NoDefaultSound="1">
<Image ID="DistrictIcon" Anchor="C,C" Size="32,32" Hide="1"/>
<Image ID="HexIcon" Anchor="C,C" Size="32,32" Hide="1"/>
<ScrollAnim ID="NormalScrollAnim" Size="50,50" Pause=".05" Speed="3" Texture="UnitFlagShine" MaskTexture="MapPinFlagMask" Cycle="Once" ShowOnMouseOver="1"/>
<Image ID="FlagOver" Size="50,50" TextureOffset="0,50" Texture="MapPinFlag"/>
</Button>
Expand All @@ -36,12 +34,12 @@
</AlphaAnim>

<Image ID="NameContainer" Texture="Controls_DropShadow4" Color="0,0,0,150" Size="auto,20" Anchor="C,T" AnchorSide="I,O" StretchMode="Fill" AutoSizePadding="15,8" Offset="0,-8">
<Label ID="NameLabel" Anchor="C,C" String="UNKNOWN_MAP_PIN_NAME" Style="FontNormal14" FontStyle="Glow" ColorSet="BodyTextBright"/>
<Label ID="NameLabel" Anchor="C,C" String="UNKNOWN_MAP_PIN_NAME" Style="FontNormal14" FontStyle="Glow" ColorSet="BodyTextBright"/>
</Image>

</Container>
</Container>
</WorldAnchor>
</Instance>
</WorldAnchor>
</Instance>
</Context>
<!-- vim: set sw=2 ts=2: -->
<!-- vim: set sw=2 ts=2 et: -->
Loading

0 comments on commit c3bef0b

Please sign in to comment.