Skip to content

Commit

Permalink
1.0.0.216 update
Browse files Browse the repository at this point in the history
  • Loading branch information
Azurency committed Feb 9, 2018
1 parent ab06504 commit 6c8d97f
Show file tree
Hide file tree
Showing 160 changed files with 5,771 additions and 3,893 deletions.
30 changes: 18 additions & 12 deletions ActionPanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ local TURN_TIMER_BAR_ACTIVE_COLOR :number = 0xffffffff;
local TURN_TIMER_BAR_INACTIVE_COLOR :number = 0xff0000ff;

local MAX_BLOCKER_BUTTONS :number = 4; -- Number of buttons around big action button
local ERA_DEGREES :table = { 209,190,171,153,137,122,106,106 }; -- Degrees to place the era indicator
local autoEndTurnOptionHash :number = DB.MakeHash("AutoEndTurn");
local cityRangeAttackTurnOptionHash :number = DB.MakeHash("CityRangeAttackTurnBlocking");

Expand Down Expand Up @@ -101,14 +100,16 @@ g_kMessageInfo[EndTurnBlockingTypes.ENDTURN_BLOCKING_SPY_CHOOSE_ESCAPE_ROUTE] =
g_kMessageInfo[EndTurnBlockingTypes.ENDTURN_BLOCKING_SPY_CHOOSE_DRAGNET_PRIORITY]={Message = chooseDragnetPriorityString, ToolTip = chooseDragnetPriorityTip , Icon="ICON_NOTIFICATION_SPY_CHOOSE_DRAGNET_PRIORITY"}
g_kMessageInfo[EndTurnBlockingTypes.ENDTURN_BLOCKING_ARTIFACT] ={Message = needArtifactPlayerString, ToolTip = needArtifactPlayerTip , Icon="ICON_NOTIFICATION_DISCOVER_ARTIFACT"}

g_kEras = {};

ERA_DEGREES = { 209,190,171,153,137,122,106,106 }; -- Degrees to place the era indicator

-- ===========================================================================
-- MEMBERS
-- ===========================================================================
local m_overflowIM : table = InstanceManager:new( "TurnBlockerInstance", "TurnBlockerButton", Controls.OverflowStack );
local m_shiftsHeld : number = 0;
local m_activeBlockerId : number = EndTurnBlockingTypes.NO_ENDTURN_BLOCKING; -- Blocking notification receiving attention
local m_kEras : table = {};
local m_kSoundsPlayed : table = {}; -- Track which notifications have had their associate sound played
local m_EndTurnId = Input.GetActionId("EndTurn"); -- Hotkey
local m_lastTurnTickTime : number = 0; -- When did we last make a tick sound for the turn timer?
Expand Down Expand Up @@ -314,18 +315,16 @@ function OnRefresh()
SetEndTurnFlashing(iFlashingState);

-- Set the era rotation and tooltip.
local eraIndex:number = pPlayer:GetEra() + 1; -- Engine is 0 Based
Controls.EraIndicator:Rotate( ERA_DEGREES[eraIndex] );

for _,era in pairs(m_kEras) do
if era.Index == eraIndex then
local displayEra = GetDisplayEra();
Controls.EraIndicator:Rotate( ERA_DEGREES[displayEra] );
for _,era in pairs(g_kEras) do
if era.Index == displayEra then
local description:string = Locale.Lookup("LOC_GAME_ERA_DESC", era.Description );
Controls.EraToolTipArea1:SetToolTipString( description );
Controls.EraToolTipArea2:SetToolTipString( description );
break;
end
end

end


Expand Down Expand Up @@ -516,6 +515,7 @@ function DoEndTurn( optionalNewBlocker:number )
local attackCity = pPlayer:GetCities():GetFirstRangedAttackCity();
if(attackCity ~= nil) then
UI.SelectCity(attackCity);
UI.SetInterfaceMode(InterfaceModeTypes.CITY_RANGE_ATTACK);
else
error( "Unable to find selectable attack city while in CheckCityRangeAttackState()" );
end
Expand Down Expand Up @@ -975,15 +975,23 @@ end
-- Create a hash table of EraType to its chronological index.
-- ===========================================================================
function PopulateEraData()
m_kEras = {};
g_kEras = {};
for row:table in GameInfo.Eras() do
m_kEras[row.EraType] = {
g_kEras[row.EraType] = {
Description = Locale.Lookup(row.Name),
Index = row.ChronologyIndex,
}
end
end

function GetDisplayEra()
local pPlayer = Players[Game.GetLocalPlayer()];
if (pPlayer == nil) then
return 1;
end
return pPlayer:GetEra() + 1; -- Engine is 0 Based
end

-- ===========================================================================
-- Update turn timer meter
-- ===========================================================================
Expand Down Expand Up @@ -1098,8 +1106,6 @@ function OnTurnTimerUpdated(elapsedTime :number, maxTurnTime :number)
else
Controls.TurnTimerLabel:LocalizeAndSetText("-");
end

Controls.TurnTimerLabelBG:SetSizeX(Controls.TurnTimerLabel:GetSizeX() + 14 );
end
end

Expand Down
23 changes: 10 additions & 13 deletions ActionPanel.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</AlphaAnim>
<AlphaAnim ID="OverflowAlpha" AlphaBegin="0" AlphaEnd="1" Speed="5" Cycle="Once" Pause=".6" Hidden="0">
<SlideAnim ID="OverflowSlide" Anchor="L,T" Size="parent,parent" Begin="-30,20" End="0,0" Cycle="Once" Speed="1" Function="OutQuint" Pause=".6">
<Image ID="OverflowCheckboxGroup" Anchor="L,B" Offset="82,134" Size="50,50" Color="0,0,0,255" Texture="Controls_Glow2" >
<Image ID="OverflowCheckboxGroup" Anchor="L,B" Offset="82,134" Size="50,50" Color="0,0,0,255" Texture="Controls_Glow2" Hidden="1" >
<CheckBox ID="OverflowCheckbox" Anchor="C,T" ButtonTexture="Controls_ButtonPlus_Up" ButtonSize="36,36" UseSelectedTextures="1" CheckTexture="Controls_Bolt" CheckColor="0,0,0,0" />
</Image>
</SlideAnim>
Expand All @@ -62,17 +62,6 @@
</Button>

<Image Anchor="R,B" Texture="ActionPanel_Gold2.dds" Offset="20,2" >

<Container ID="TurnTimerContainer" Size="148,147" Hidden="1">
<Container Size="138,41" Offset="12,-7" Anchor="C,B">
<Grid ID="TurnTimerLabelBG" Offset="0,0" Anchor="C,B" Size="40,41" Texture="UnitPanel_ActionGroupSlot" SliceCorner="5,0" SliceSize="2,41" SliceTextureSize="12,41"/>
<Label ID="TurnTimerLabel" Offset="0,7" Anchor="C,B" Style="ActionPanelText"/>
</Container>
<Container Size="138,138" Offset="14,-2" >
<Image ID="TurnTimerMeterBG" Anchor="C,C" Texture="ActionPanel_MultiplayerTimerBacking"/>
<Meter ID="TurnTimerMeter" Anchor="C,C" Offset="0,-4" Size="116,117" Texture="ActionPanel_MultiplayerTimerFill" Speed="0"/>
</Container>
</Container>

<Image ID="EraIndicator" Offset="0,-15" Rotate="90" Texture="ActionPanel_EraIndicator" />
<FlipAnim FrameCount="17" Texture="ActionPanel_TurnProcessing" Columns="8" Anchor="R,B" Size="102,102" Offset="15,32" Stopped="0"/>
Expand All @@ -93,7 +82,15 @@
</BoxButton>

<AlphaAnim ID="TutorialSlowTurnEnableAnim" Anchor="R,B" Speed="0.5" Offset="-20,0" Size="180,220" AlphaStart="1" AlphaEnd="1" Cycle="Once" ConsumeAllMouse="1" Hidden="1" />

<Container ID="TurnTimerContainer" Size="148,147" Hidden="1">
<Container Size="138,138" Offset="14,-2">
<Meter ID="TurnTimerMeter" Anchor="C,C" Offset="0,-4" Size="95,95" Texture="ActionPanel_TurnTimerFill" Speed="0"/>
</Container>
<Container Size="138,41" Offset="7,-7" Anchor="C,C">
<Image ID="TurnTimerLabelBG" Offset="0,0" Anchor="C,C" Size="100,28" Texture="ActionPanel_TurnTimerFrame"/>
<Label ID="TurnTimerLabel" Anchor="C,C" Style="ActionPanelText"/>
</Container>
</Container>
</Image>

<Tutorial ID="TutNotificationPointer" Style="TutorialContainer" Anchor="L,T" Offset="-40,0" TriggerBy="TutorialNotificationPointer" >
Expand Down
2 changes: 1 addition & 1 deletion AdjacencyBonusSupport.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ function GetCityRelatedPlotIndexesDistrictsAlternative( pCity:table, districtHas
for _,plotId in pairs(tResults[CityCommandResults.PLOTS]) do

local kPlot :table = Map.GetPlotByIndex(plotId);
if kPlot:CanHaveDistrict(district.DistrictType, pCity:GetOwner(), pCity:GetID()) then
if kPlot:CanHaveDistrict(district.Index, pCity:GetOwner(), pCity:GetID()) then
local isValid :boolean = IsShownIfPlotPurchaseable(district.Index, pCity, kPlot);
if isValid then
table.insert(plots, plotId);
Expand Down
89 changes: 89 additions & 0 deletions Automation/Automation_Profile.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@

local UNIQUE_ERAS = { "ERA_ANCIENT", "ERA_CLASSICAL", "ERA_INDUSTRIAL", "ERA_MODERN" };
local m_TestList = {};
local m_CurrentTestIndex = 1;

local m_CurrentEra = nil;
local m_CurrentCiv = nil;

function BuildTestList()
m_TestList = {};
for tCiv in GameInfo.Civilizations() do
local strNameCiv = string.gsub( tCiv.CivilizationType, "CIVILIZATION_", "" );
for _, strEra in ipairs(UNIQUE_ERAS) do
local strNameEra = string.gsub( strEra, "ERA_", "" );
table.insert(m_TestList, {
civ = tCiv.Index,
era = GameInfo.Eras[strEra].Index,
zoom = 1,
name = strNameCiv .. "_" .. strNameEra-- .. "_FAR",
});
--table.insert(m_TestList, {
-- civ = tCiv.Index,
-- era = GameInfo.Eras[strEra].Index,
-- zoom = 0,
-- name = strNameCiv .. "_" .. strNameEra .. "_NEAR",
--});
end
end
m_CurrentTestIndex = 1;
end

function FillMapWith( civIndex, eraIndex )
if ( m_CurrentEra == eraIndex and m_CurrentCiv == eraIndex ) then
return; -- No changes necessary!
end
AssetPreview.ClearLandmarkSystem();
local maptype = Map.GetMapSize();
local mapx = GameInfo.Maps[maptype].GridWidth;
local mapy = GameInfo.Maps[maptype].GridHeight;
for y = 0, mapy-1, 1 do
for x = 0, mapx-1, 1 do
local plot = Map.GetPlot(x, y);
if ( not plot:IsImpassable() and not plot:IsWater() ) then
AssetPreview.PlaceCityAt( x, y, civIndex, eraIndex, 22 );
end
end
end
m_CurrentEra = eraIndex;
m_CurrentCiv = eraIndex;
end

function StartNextTest()
if ( m_CurrentTestIndex <= #m_TestList ) then
local test = m_TestList[m_CurrentTestIndex];
print("==================== Starting Benchmark: " .. test.name .. " ====================\n");
FillMapWith(test.civ, test.era);
AutoProfiler.SetCameraZoom(test.zoom);
AutoProfiler.Start(test.name);
m_CurrentTestIndex = m_CurrentTestIndex + 1;
end
end

function OnGameLoad()
AutoProfiler.SetAutomated( true );
-- This is a two-minute test.
-- 2.5s should leave enough time for the framerate to settle, though I'd prefer 3s.
-- The tradeoff is better map coverage vs more time to reach a steady-state framerate.
AutoProfiler.SetNumLookAtPositions( 48 );
AutoProfiler.SetLookAtLingerSeconds( 2.5 );
AutoProfiler.SetCameraPanSpeed( 0 );
AutoProfiler.SetAutoStartEnabled( true );
AutoProfiler.RunCommand( "toggle vfx" );
AutoProfiler.RunCommand( "toggle clutter" );


BuildTestList();
AssetPreview.ClearLandmarkSystem();
AutoProfiler.Start("BASELINE_EMPTY_MAP");
end
LuaEvents.AutomationGameStarted.Add( OnGameLoad );

function OnFinished()
StartNextTest();
end
LuaEvents.AutoProfilerBenchmarkFinished.Add( OnFinished );




69 changes: 24 additions & 45 deletions Choosers/CivicsChooser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ function View( playerID:number, kData:table )
table.sort(kData, function(a, b) return Locale.Compare(a.Name, b.Name) == -1; end);
for i, data in ipairs(kData) do
if data.IsCurrent or data.IsLastCompleted then
RealizeCurrentCivic( playerID, data, nil, m_CachedModifiers, extraIconDataCache );
RealizeCurrentCivic( playerID, data, nil, m_CachedModifiers );
if (data.Repeatable) then
AddAvailableCivic( playerID, data, extraIconDataCache );
AddAvailableCivic( playerID, data );
end
else
AddAvailableCivic( playerID, data, extraIconDataCache );
AddAvailableCivic( playerID, data );
end
end

Expand Down Expand Up @@ -168,25 +168,28 @@ function AddAvailableCivic( playerID:number, kData:table )
-- Include extra icons in total unlocks
local extraUnlocks:table = {};
local hideDescriptionIcon:boolean = false;
local cachedModifier:table = m_CachedModifiers[kData.CivicType];
for _,iconData in pairs(g_ExtraIconData) do
if iconData.ModifierType == cachedModifier.ModifierType then
hideDescriptionIcon = hideDescriptionIcon or iconData.HideDescriptionIcon;
table.insert(extraUnlocks, iconData);
local cachedModifiers:table = m_CachedModifiers[kData.CivicType];
if ( cachedModifiers ) then
for _,tModifier in ipairs(cachedModifiers) do
local tIconData :table = g_ExtraIconData[tModifier.ModifierType];
if ( tIconData ) then
hideDescriptionIcon = hideDescriptionIcon or tIconData.HideDescriptionIcon;
table.insert(extraUnlocks, {IconData=tIconData, ModifierTable=tModifier});
end
end
end

-- Handle overflow for unlock icons
numUnlockables = PopulateUnlockablesForCivic( playerID, kData.ID, unlockIM, nil, callback, hideDescriptionIcon );

-- Initialize extra icons
for _,iconData in pairs(extraUnlocks) do
iconData:Initialize(kItemInstance.UnlockStack, cachedModifier);
for _,tUnlock in pairs(extraUnlocks) do
tUnlock.IconData:Initialize(kItemInstance.UnlockStack, tUnlock.ModifierTable);
numUnlockables = numUnlockables + 1;
end

if numUnlockables ~= nil then
HandleOverflow(numUnlockables, kItemInstance);
HandleOverflow(numUnlockables, kItemInstance, 5, 5);
end

if kData.ResearchQueuePosition ~= -1 then
Expand Down Expand Up @@ -359,7 +362,7 @@ end
-- input processing) so we can defer the rebuild until here.
-- ===========================================================================
function FlushChanges()
if m_needsRefresh then
if m_needsRefresh and ContextPtr:IsVisible() then
Refresh();
end
end
Expand Down Expand Up @@ -390,6 +393,12 @@ function OnInit( isReload:boolean )
end
end
end

-- ===========================================================================
function OnShow()
Refresh();
end

-- ===========================================================================
function OnShutdown()
LuaEvents.GameDebug_AddValue(RELOAD_CACHE_ID, "m_currentID", m_currentID);
Expand All @@ -410,48 +419,17 @@ function OnGameDebugReturn(context:string, contextTable:table)
end
end


-- ===========================================================================
-- Obtain the data from the DB that doesn't change
-- Base costs and relationships (prerequisites)
-- RETURN: A table of node data (techs/civics/etc...) with a prereq for each entry.
-- ===========================================================================
function PopulateCachedModifiers()
-- Build main item table.
for row:table in GameInfo.Civics() do
local entry:table = {};
-- Look up and cache any civic modifiers we reward like envoys awarded
for civicModifier in GameInfo.CivicModifiers() do
if (row.CivicType == civicModifier.CivicType) then
for modifierType in GameInfo.Modifiers() do
if civicModifier.ModifierId == modifierType.ModifierId then
entry.ModifierId = modifierType.ModifierId;
entry.ModifierType = modifierType.ModifierType;
end
end
for modifierArguments in GameInfo.ModifierArguments() do
if civicModifier.ModifierId == modifierArguments.ModifierId then
entry.ModifierValue = modifierArguments.Value;
end
end
end
end


m_CachedModifiers[row.CivicType] = entry;
end
end

-- ===========================================================================
-- INIT
-- ===========================================================================
function Initialize()

-- Cache frequently used / expensive data
PopulateCachedModifiers();
m_CachedModifiers = TechAndCivicSupport_BuildCivicModifierCache();

-- Hot-reload events
ContextPtr:SetInitHandler(OnInit);
ContextPtr:SetShowHandler(OnShow);
ContextPtr:SetShutdown(OnShutdown);
LuaEvents.GameDebug_Return.Add(OnGameDebugReturn);

Expand All @@ -461,6 +439,7 @@ function Initialize()
-- Screen events
LuaEvents.ActionPanel_OpenChooseCivic.Add(OnOpenPanel);
LuaEvents.WorldTracker_OpenChooseCivic.Add(OnOpenPanel);
LuaEvents.LaunchBar_CloseChoosers.Add(OnClosePanel);

-- Game events
Events.CityInitialized.Add( OnCityInitialized );
Expand Down
Loading

0 comments on commit 6c8d97f

Please sign in to comment.