Skip to content

Commit

Permalink
Minor code organization
Browse files Browse the repository at this point in the history
  • Loading branch information
astog committed Jul 28, 2017
1 parent 53cf7ad commit 2f3883a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 47 deletions.
46 changes: 18 additions & 28 deletions UI/MinimapPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ local MINIMAP_BACKING_PADDING_SIZEY:number = 60;

-- Used to control ModalLensPanel.lua
local MODDED_LENS_ID:table = {
NONE = 0,
APPEAL = 1,
BUILDER = 2,
ARCHAEOLOGIST = 3,
BARBARIAN = 4,
CITY_OVERLAP = 5,
RESOURCE = 6,
WONDER = 7,
ADJACENCY_YIELD = 8,
SCOUT = 9,
NATURALIST = 10,
CUSTOM = 11
NONE = 0;
APPEAL = 1;
BUILDER = 2;
ARCHAEOLOGIST = 3;
BARBARIAN = 4;
CITY_OVERLAP = 5;
RESOURCE = 6;
WONDER = 7;
ADJACENCY_YIELD = 8;
SCOUT = 9;
NATURALIST = 10;
CUSTOM = 11;
};

-- Different from above, since it uses a government lens, instead of appeal
local AREA_LENS_ID:table = {
NONE = 0,
GOVERNMENT = 1,
CITIZEN_MANAGEMENT = 2,
NONE = 0;
GOVERNMENT = 1;
CITIZEN_MANAGEMENT = 2;
}

-- Should the builder lens auto apply, when a builder is selected.
Expand Down Expand Up @@ -88,7 +88,6 @@ local m_TogglePoliticalLensId = Input.GetActionId("LensPolitical");
local m_ToggleTourismLensId = Input.GetActionId("LensTourism");
local m_Toggle2DViewId = Input.GetActionId("Toggle2DView");


local m_isMouseDragEnabled :boolean = true; -- Can the camera be moved by dragging on the minimap?
local m_isMouseDragging :boolean = false; -- Was LMB clicked inside the minimap, and has not been released yet?
local m_hasMouseDragged :boolean = false; -- Has there been any movements since m_isMouseDragging became true?
Expand Down Expand Up @@ -309,7 +308,6 @@ function ToggleAppealLens()
end

UILens.SetActive("Appeal");

RefreshInterfaceMode();
else
m_shouldCloseLensMenu = false;
Expand Down Expand Up @@ -395,7 +393,6 @@ function ToggleBuilderLens()
end

UILens.SetActive("Appeal");

RefreshInterfaceMode();
else
m_shouldCloseLensMenu = false;
Expand All @@ -418,7 +415,6 @@ function ToggleArchaeologistLens()
end

UILens.SetActive("Appeal");

RefreshInterfaceMode();
else
m_shouldCloseLensMenu = false;
Expand Down Expand Up @@ -466,7 +462,6 @@ function ToggleBarbarianLens()
end

UILens.SetActive("Appeal");

RefreshInterfaceMode();
else
m_shouldCloseLensMenu = false;
Expand Down Expand Up @@ -516,7 +511,6 @@ function ToggleWonderLens()
end

UILens.SetActive("Appeal");

RefreshInterfaceMode();
else
m_shouldCloseLensMenu = false;
Expand All @@ -539,7 +533,6 @@ function ToggleAdjacencyYieldLens()
end

UILens.SetActive("Appeal");

RefreshInterfaceMode();
else
m_shouldCloseLensMenu = false;
Expand All @@ -562,7 +555,6 @@ function ToggleScoutLens()
end

UILens.SetActive("Appeal");

RefreshInterfaceMode();
else
m_shouldCloseLensMenu = false;
Expand Down Expand Up @@ -631,13 +623,15 @@ function OnCollapseToggle()
if ( m_isCollapsed ) then
UI.PlaySound("Minimap_Open");
Controls.ExpandButton:SetHide( true );
Controls.CollapseButton:SetHide( false );
Controls.ExpandAnim:SetEndVal(0, -Controls.MinimapContainer:GetOffsetY() - Controls.MinimapContainer:GetSizeY());
Controls.ExpandAnim:SetToBeginning();
Controls.ExpandAnim:Play();
Controls.CompassArm:SetPercent(.25);
else
UI.PlaySound("Minimap_Closed");
Controls.ExpandButton:SetHide( false );
Controls.CollapseButton:SetHide( true );
Controls.Pause:Play();
Controls.CollapseAnim:SetEndVal(0, Controls.MinimapContainer:GetOffsetY() + Controls.MinimapContainer:GetSizeY());
Controls.CollapseAnim:SetToBeginning();
Expand Down Expand Up @@ -2314,7 +2308,6 @@ function IsAdjYieldWonder(featureInfo)
end
end
end

return false
end

Expand All @@ -2325,7 +2318,6 @@ function plotNextToBuffingWonder(plot)
return true
end
end

return false
end

Expand Down Expand Up @@ -2365,9 +2357,7 @@ function plotHasRecomFeature(plot)
return true
end
end

end

return false
end

Expand All @@ -2376,7 +2366,6 @@ function plotHasAnitquitySite(plot)
if resourceInfo ~= nil and resourceInfo.ResourceType == "RESOURCE_ANTIQUITY_SITE" then
return true;
end

return false
end

Expand Down Expand Up @@ -2412,6 +2401,7 @@ function plotCanHaveFarm(plot)
return true;
end
end
return false
end

function plotHasGoodyHut(plot)
Expand Down
39 changes: 20 additions & 19 deletions UI/Panels/ModalLensPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ include( "InstanceManager" );
-- Similiar to MinimapPanel.lua to control modded lenses
-- Used to control ModalLensPanel.lua
local MODDED_LENS_ID:table = {
NONE = 0,
APPEAL = 1,
BUILDER = 2,
ARCHAEOLOGIST = 3,
BARBARIAN = 4,
CITY_OVERLAP = 5,
RESOURCE = 6,
WONDER = 7,
ADJACENCY_YIELD = 8,
SCOUT = 9,
NATURALIST = 10,
CUSTOM = 11
NONE = 0;
APPEAL = 1;
BUILDER = 2;
ARCHAEOLOGIST = 3;
BARBARIAN = 4;
CITY_OVERLAP = 5;
RESOURCE = 6;
WONDER = 7;
ADJACENCY_YIELD = 8;
SCOUT = 9;
NATURALIST = 10;
CUSTOM = 11;
};

-- Different from above, since it uses a government lens, instead of appeal
local AREA_LENS_ID:table = {
NONE = 0,
GOVERNMENT = 1,
CITIZEN_MANAGEMENT = 2,
NONE = 0;
GOVERNMENT = 1;
CITIZEN_MANAGEMENT = 2;
}

local m_KeyStackIM:table = InstanceManager:new( "KeyEntry", "KeyColorImage", Controls.KeyStack );
Expand Down Expand Up @@ -455,15 +455,16 @@ function OnLensLayerOn( layerNum:number )
elseif m_CurrentModdedLensOn == MODDED_LENS_ID.NATURALIST then
Controls.LensText:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_NATURALIST_LENS")));
ShowNaturalistLensKey();
-- elseif m_CurrentModdedLensOn == MODDED_LENS_ID.CUSTOM then
-- print("Hiding")
-- ContextPtr:SetHide(true); -- Hide the Modal Panel if custom
elseif m_CurrentModdedLensOn == MODDED_LENS_ID.CUSTOM then
print("Hiding")
ContextPtr:SetHide(true); -- Hide the Modal Panel if custom
end
elseif layerNum == LensLayers.HEX_COLORING_GOVERNMENT then
if m_CurrentAreaLensOn == AREA_LENS_ID.GOVERNMENT then
Controls.LensText:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_GOVERNMENT_LENS")));
ShowGovernmentLensKey();
-- else -- Add extra area lenses here
-- else
-- Add extra area lenses here
end
elseif layerNum == LensLayers.HEX_COLORING_OWING_CIV then
Controls.LensText:SetText(Locale.ToUpper(Locale.Lookup("LOC_HUD_OWNER_LENS")));
Expand Down

0 comments on commit 2f3883a

Please sign in to comment.