-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathTopPanel.lua
568 lines (496 loc) · 22.4 KB
/
TopPanel.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
-- ===========================================================================
-- HUD Top of Screen Area
-- ===========================================================================
include( "InstanceManager" );
include( "SupportFunctions" ); -- Round
include( "ToolTipHelper_PlayerYields" );
-- ===========================================================================
-- Yield handles
-- ===========================================================================
local m_YieldButtonSingleManager = InstanceManager:new( "YieldButton_SingleLabel", "Top", Controls.YieldStack );
local m_YieldButtonDoubleManager = InstanceManager:new( "YieldButton_DoubleLabel", "Top", Controls.YieldStack );
g_ExtraYieldLoaders = {};
include("TopPanelLoader_", true);
-- ===========================================================================
local m_kResourceIM :table = InstanceManager:new( "ResourceInstance", "ResourceText", Controls.ResourceStack );
local YIELD_PADDING_Y = 20;
local META_PADDING = 100; -- The amount of padding to give the meta area to make enough room for the (+) when there is resource overflow
local FONT_MULTIPLIER = 11; -- The amount to multiply times the string length to approximate the width in pixels of the label control
local m_OpenPediaId;
local m_viewReportsX :number = 0; -- With of view report button
-- ===========================================================================
-- Yield handles
-- ===========================================================================
local m_ScienceYieldButton:table = nil;
local m_CultureYieldButton:table = nil;
local m_GoldYieldButton:table = nil;
local m_TourismYieldButton:table = nil;
local m_FaithYieldButton:table = nil;
-- ===========================================================================
-- Game Engine Event
-- ===========================================================================
function OnCityInitialized(owner, ID)
if owner == Game.GetLocalPlayer() then
local player = Players[owner];
local pPlayerCities :table = player:GetCities();
if table.count(pPlayerCities) == 1 then
-- Remove?
--Controls.YieldStack:SetHide(false); -- Once the first city is founded, then display the corner.
end
RefreshYields();
end
end
-- ===========================================================================
-- Game Engine Event
-- ===========================================================================
function OnLocalPlayerChanged( playerID:number , prevLocalPlayerID:number )
if playerID == -1 then return; end
local player = Players[playerID];
local pPlayerCities :table = player:GetCities();
RefreshAll();
end
-- ===========================================================================
function OnMenu()
UIManager:QueuePopup( LookUpControl( "/InGame/TopOptionsMenu" ), PopupPriority.Utmost );
end
-- ===========================================================================
-- UI Callback
-- Send signal to open/close the Reports Screen
-- ===========================================================================
function OnToggleReportsScreen()
local pReportsScreen :table = ContextPtr:LookUpControl( "/InGame/ReportScreen" );
if pReportsScreen == nil then
UI.DataError("Unable to toggle Reports Screen. Not found in '/InGame/ReportScreen'.");
return;
end
if pReportsScreen:IsHidden() then
LuaEvents.TopPanel_OpenReportsScreen();
else
LuaEvents.TopPanel_CloseReportsScreen();
end
end
-- ===========================================================================
-- Callback
-- ===========================================================================
function OnOpenCivilopedia()
LuaEvents.OpenCivilopedia();
end
-- ===========================================================================
-- Takes a value and returns the string verison with +/- and rounded to
-- the tenths decimal place.
-- ===========================================================================
function FormatValuePerTurn( value:number )
if(value == 0) then
return Locale.ToNumber(value);
else
return Locale.Lookup("{1: number +#,###.#;-#,###.#}", value);
end
end
-- ===========================================================================
function Resize()
Controls.ViewReports:SetSizeToText(20,11);
Controls.Backing:ReprocessAnchoring();
Controls.Backing2:ReprocessAnchoring();
Controls.RightContents:ReprocessAnchoring();
end
-- ===========================================================================
-- Refresh Data and View
-- ===========================================================================
function RefreshYields()
local ePlayer :number = Game.GetLocalPlayer();
local localPlayer :table= nil;
if ePlayer ~= -1 then
localPlayer = Players[ePlayer];
if localPlayer == nil then
return;
end
else
return;
end
---- SCIENCE ----
m_ScienceYieldButton = m_ScienceYieldButton or m_YieldButtonSingleManager:GetInstance();
local playerTechnology :table = localPlayer:GetTechs();
local currentScienceYield :number = playerTechnology:GetScienceYield();
m_ScienceYieldButton.YieldPerTurn:SetText( FormatValuePerTurn(currentScienceYield) );
m_ScienceYieldButton.YieldBacking:SetToolTipString( GetScienceTooltip() );
m_ScienceYieldButton.YieldIconString:SetText("[ICON_ScienceLarge]");
m_ScienceYieldButton.YieldButtonStack:CalculateSize();
m_ScienceYieldButton.YieldBacking:SetSizeX(m_ScienceYieldButton.YieldButtonStack:GetSizeX() + YIELD_PADDING_Y);
---- CULTURE----
m_CultureYieldButton = m_CultureYieldButton or m_YieldButtonSingleManager:GetInstance();
local playerCulture :table = localPlayer:GetCulture();
local currentCultureYield :number = playerCulture:GetCultureYield();
m_CultureYieldButton.YieldPerTurn:SetText( FormatValuePerTurn(currentCultureYield) );
m_CultureYieldButton.YieldPerTurn:SetColorByName("ResCultureLabelCS");
m_CultureYieldButton.YieldBacking:SetToolTipString( GetCultureTooltip() );
m_CultureYieldButton.YieldBacking:SetColor(0x99fe2aec);
m_CultureYieldButton.YieldIconString:SetText("[ICON_CultureLarge]");
m_CultureYieldButton.YieldButtonStack:CalculateSize();
m_CultureYieldButton.YieldBacking:SetSizeX(m_CultureYieldButton.YieldButtonStack:GetSizeX() + YIELD_PADDING_Y);
---- FAITH ----
m_FaithYieldButton = m_FaithYieldButton or m_YieldButtonDoubleManager:GetInstance();
local playerReligion :table = localPlayer:GetReligion();
local faithYield :number = playerReligion:GetFaithYield();
local faithBalance :number = playerReligion:GetFaithBalance();
m_FaithYieldButton.YieldBalance:SetText( Locale.ToNumber(faithBalance, "#,###.#") );
m_FaithYieldButton.YieldPerTurn:SetText( FormatValuePerTurn(faithYield) );
m_FaithYieldButton.YieldBacking:SetToolTipString( GetFaithTooltip() );
m_FaithYieldButton.YieldIconString:SetText("[ICON_FaithLarge]");
m_FaithYieldButton.YieldButtonStack:CalculateSize();
m_FaithYieldButton.YieldBacking:SetSizeX(m_FaithYieldButton.YieldButtonStack:GetSizeX() + YIELD_PADDING_Y);
---- GOLD ----
m_GoldYieldButton = m_GoldYieldButton or m_YieldButtonDoubleManager:GetInstance();
local playerTreasury:table = localPlayer:GetTreasury();
local goldYield :number = playerTreasury:GetGoldYield() - playerTreasury:GetTotalMaintenance();
local goldBalance :number = math.floor(playerTreasury:GetGoldBalance());
m_GoldYieldButton.YieldBalance:SetText( Locale.ToNumber(goldBalance, "#,###.#") );
m_GoldYieldButton.YieldBalance:SetColorByName("ResGoldLabelCS");
m_GoldYieldButton.YieldPerTurn:SetText( FormatValuePerTurn(goldYield) );
m_GoldYieldButton.YieldIconString:SetText("[ICON_GoldLarge]");
m_GoldYieldButton.YieldPerTurn:SetColorByName("ResGoldLabelCS");
m_GoldYieldButton.YieldBacking:SetToolTipString( GetGoldTooltip() );
m_GoldYieldButton.YieldBacking:SetColorByName("ResGoldLabelCS");
m_GoldYieldButton.YieldButtonStack:CalculateSize();
m_GoldYieldButton.YieldBacking:SetSizeX(m_GoldYieldButton.YieldButtonStack:GetSizeX() + YIELD_PADDING_Y);
---- TOURISM ----
if GameCapabilities.HasCapability("CAPABILITY_TOURISM") then
m_TourismYieldButton = m_TourismYieldButton or m_YieldButtonSingleManager:GetInstance();
local tourismRate = Round(localPlayer:GetStats():GetTourism(), 1);
local tourismRateTT:string = Locale.Lookup("LOC_WORLD_RANKINGS_OVERVIEW_CULTURE_TOURISM_RATE", tourismRate);
local tourismBreakdown = localPlayer:GetStats():GetTourismToolTip();
if(tourismBreakdown and #tourismBreakdown > 0) then
tourismRateTT = tourismRateTT .. "[NEWLINE][NEWLINE]" .. tourismBreakdown;
end
m_TourismYieldButton.YieldPerTurn:SetText( tourismRate );
m_TourismYieldButton.YieldBacking:SetToolTipString(tourismRateTT);
m_TourismYieldButton.YieldPerTurn:SetColorByName("ResTourismLabelCS");
m_TourismYieldButton.YieldBacking:SetColorByName("ResTourismLabelCS");
m_TourismYieldButton.YieldIconString:SetText("[ICON_TourismLarge]");
if (tourismRate > 0) then
m_TourismYieldButton.Top:SetHide(false);
else
m_TourismYieldButton.Top:SetHide(true);
end
end
for _, loader in pairs(g_ExtraYieldLoaders) do
loader:RefreshExtraYields(m_YieldButtonSingleManager, m_YieldButtonDoubleManager);
end
Controls.YieldStack:CalculateSize();
Controls.StaticInfoStack:CalculateSize();
Controls.InfoStack:CalculateSize();
RefreshResources();
end
-- ===========================================================================
-- Game Engine Event
function OnRefreshYields()
ContextPtr:RequestRefresh();
end
-- ===========================================================================
function RefreshTrade()
local localPlayer = Players[Game.GetLocalPlayer()];
if (localPlayer == nil) then
return;
end
---- ROUTES ----
local playerTrade :table = localPlayer:GetTrade();
local routesActive :number = playerTrade:GetNumOutgoingRoutes();
local sRoutesActive :string = "" .. routesActive;
local routesCapacity:number = playerTrade:GetOutgoingRouteCapacity();
if (routesCapacity > 0) then
if (routesActive > routesCapacity) then
sRoutesActive = "[COLOR_RED]" .. sRoutesActive .. "[ENDCOLOR]";
elseif (routesActive < routesCapacity) then
sRoutesActive = "[COLOR_GREEN]" .. sRoutesActive .. "[ENDCOLOR]";
end
Controls.TradeRoutesActive:SetText(sRoutesActive);
Controls.TradeRoutesCapacity:SetText(routesCapacity);
local sTooltip = Locale.Lookup("LOC_TOP_PANEL_TRADE_ROUTES_TOOLTIP_ACTIVE", routesActive);
sTooltip = sTooltip .. "[NEWLINE]";
sTooltip = sTooltip .. Locale.Lookup("LOC_TOP_PANEL_TRADE_ROUTES_TOOLTIP_CAPACITY", routesCapacity);
sTooltip = sTooltip .. "[NEWLINE][NEWLINE]";
sTooltip = sTooltip .. Locale.Lookup("LOC_TOP_PANEL_TRADE_ROUTES_TOOLTIP_SOURCES_HELP");
Controls.TradeRoutes:SetToolTipString(sTooltip);
Controls.TradeRoutes:SetHide(false);
else
Controls.TradeRoutes:SetHide(true);
end
Controls.TradeStack:CalculateSize();
Controls.TradeStack:ReprocessAnchoring();
--Controls.TradeBacking:SetSizeX(Controls.TradeStack:GetSizeX() + YIELD_PADDING_Y);
end
-- ===========================================================================
function RefreshInfluence()
if GameCapabilities.HasCapability("CAPABILITY_TOP_PANEL_ENVOYS") then
local localPlayer = Players[Game.GetLocalPlayer()];
if (localPlayer == nil) then
return;
end
local playerInfluence :table = localPlayer:GetInfluence();
local influenceBalance :number = Round(playerInfluence:GetPointsEarned(), 1);
local influenceRate :number = Round(playerInfluence:GetPointsPerTurn(), 1);
local influenceThreshold:number = playerInfluence:GetPointsThreshold();
local envoysPerThreshold:number = playerInfluence:GetTokensPerThreshold();
local currentEnvoys :number = playerInfluence:GetTokensToGive();
local sTooltip = "";
if (currentEnvoys > 0) then
sTooltip = sTooltip .. Locale.Lookup("LOC_TOP_PANEL_INFLUENCE_TOOLTIP_ENVOYS", currentEnvoys);
sTooltip = sTooltip .. "[NEWLINE][NEWLINE]";
end
sTooltip = sTooltip .. Locale.Lookup("LOC_TOP_PANEL_INFLUENCE_TOOLTIP_POINTS_THRESHOLD", envoysPerThreshold, influenceThreshold);
sTooltip = sTooltip .. "[NEWLINE][NEWLINE]";
sTooltip = sTooltip .. Locale.Lookup("LOC_TOP_PANEL_INFLUENCE_TOOLTIP_POINTS_BALANCE", influenceBalance);
sTooltip = sTooltip .. "[NEWLINE]";
sTooltip = sTooltip .. Locale.Lookup("LOC_TOP_PANEL_INFLUENCE_TOOLTIP_POINTS_RATE", influenceRate);
sTooltip = sTooltip .. "[NEWLINE][NEWLINE]";
sTooltip = sTooltip .. Locale.Lookup("LOC_TOP_PANEL_INFLUENCE_TOOLTIP_SOURCES_HELP");
local meterRatio = influenceBalance / influenceThreshold;
if (meterRatio < 0) then
meterRatio = 0;
elseif (meterRatio > 1) then
meterRatio = 1;
end
Controls.EnvoysMeter:SetPercent(meterRatio);
Controls.EnvoysNumber:SetText(tostring(currentEnvoys));
Controls.Envoys:SetToolTipString(sTooltip);
Controls.EnvoysStack:CalculateSize();
Controls.EnvoysStack:ReprocessAnchoring();
else
Controls.Envoys:SetHide(true);
end
end
-- ===========================================================================
function RefreshTime()
local format = UserConfiguration.GetClockFormat();
local strTime;
if(format == 1) then
strTime = os.date("%H:%M");
else
strTime = os.date("%I:%M %p");
-- Remove the leading zero (if any) from 12-hour clock format
if(string.sub(strTime, 1, 1) == "0") then
strTime = string.sub(strTime, 2);
end
end
Controls.Time:SetText( strTime );
local d = Locale.Lookup("{1_Time : datetime full}", os.time());
Controls.Time:SetToolTipString(d);
Controls.TimeArea:ReprocessAnchoring();
end
-- ===========================================================================
function RefreshResources()
local localPlayerID = Game.GetLocalPlayer();
if (localPlayerID ~= -1) then
m_kResourceIM:ResetInstances();
local pPlayerResources = Players[localPlayerID]:GetResources();
local yieldStackX = Controls.YieldStack:GetSizeX();
local metaStackX = Controls.RightContents:GetSizeX();
local screenX, _:number = UIManager:GetScreenSizeVal();
local maxSize = screenX - yieldStackX - metaStackX - m_viewReportsX - META_PADDING;
local currSize = 0;
local isOverflow = false;
local overflowString = "";
local plusInstance:table;
for resource in GameInfo.Resources() do
if (resource.ResourceClassType ~= nil and resource.ResourceClassType ~= "RESOURCECLASS_BONUS" and resource.ResourceClassType ~="RESOURCECLASS_LUXURY" and resource.ResourceClassType ~="RESOURCECLASS_ARTIFACT") then
local amount = pPlayerResources:GetResourceAmount(resource.ResourceType);
if (amount > 0) then
local resourceText = "[ICON_"..resource.ResourceType.."] ".. amount;
local numDigits = 3;
if (amount >= 10) then
numDigits = 4;
end
local guessinstanceWidth = math.ceil(numDigits * FONT_MULTIPLIER);
if(currSize + guessinstanceWidth < maxSize and not isOverflow) then
if (amount ~= 0) then
local instance:table = m_kResourceIM:GetInstance();
instance.ResourceText:SetText(resourceText);
instance.ResourceText:SetToolTipString(Locale.Lookup(resource.Name).."[NEWLINE]"..Locale.Lookup("LOC_TOOLTIP_STRATEGIC_RESOURCE"));
instanceWidth = instance.ResourceText:GetSizeX();
currSize = currSize + instanceWidth;
end
else
if (not isOverflow) then
overflowString = amount.. "[ICON_"..resource.ResourceType.."]".. Locale.Lookup(resource.Name);
local instance:table = m_kResourceIM:GetInstance();
instance.ResourceText:SetText("[ICON_Plus]");
plusInstance = instance.ResourceText;
else
overflowString = overflowString .. "[NEWLINE]".. amount.. "[ICON_"..resource.ResourceType.."]".. Locale.Lookup(resource.Name);
end
isOverflow = true;
end
end
end
end
if (plusInstance ~= nil) then
plusInstance:SetToolTipString(overflowString);
end
Controls.ResourceStack:CalculateSize();
if(Controls.ResourceStack:GetSizeX() == 0) then
Controls.Resources:SetHide(true);
else
Controls.Resources:SetHide(false);
end
end
end
-- ===========================================================================
-- Game Engine Event
-- ===========================================================================
function OnRefreshResources()
RefreshResources();
end
-- ===========================================================================
-- Use an animation control to occasionally (not per frame!) callback for
-- an update on the current time.
-- ===========================================================================
function OnRefreshTimeTick()
RefreshTime();
Controls.TimeCallback:SetToBeginning();
Controls.TimeCallback:Play();
end
Controls.TimeCallback:RegisterEndCallback(OnRefreshTimeTick);
-- ===========================================================================
function RefreshTurnsRemaining()
local endTurn = Game.GetGameEndTurn(); -- This EXCLUSIVE, i.e. the turn AFTER the last playable turn.
local turn = Game.GetCurrentGameTurn();
if GameCapabilities.HasCapability("CAPABILITY_DISPLAY_NORMALIZED_TURN") then
turn = (turn - GameConfiguration.GetStartTurn()) + 1; -- Keep turns starting at 1.
if endTurn > 0 then
endTurn = endTurn - GameConfiguration.GetStartTurn();
end
end
if endTurn > 0 then
-- We have a hard turn limit
Controls.Turns:SetText(tostring(turn) .. "/" .. tostring(endTurn - 1));
else
Controls.Turns:SetText(tostring(turn));
end
local strDate = Calendar.MakeYearStr(turn);
Controls.CurrentDate:SetText(strDate);
end
-- ===========================================================================
function OnWMDUpdate(owner, WMDtype)
local eLocalPlayer = Game.GetLocalPlayer();
if ( eLocalPlayer ~= -1 and owner == eLocalPlayer ) then
local player = Players[owner];
local playerWMDs = player:GetWMDs();
for entry in GameInfo.WMDs() do
if (entry.WeaponType == "WMD_NUCLEAR_DEVICE") then
local count = playerWMDs:GetWeaponCount(entry.Index);
if (count > 0) then
Controls.NuclearDevices:SetHide(false);
Controls.NuclearDeviceCount:SetText(count);
else
Controls.NuclearDevices:SetHide(true);
end
elseif (entry.WeaponType == "WMD_THERMONUCLEAR_DEVICE") then
local count = playerWMDs:GetWeaponCount(entry.Index);
if (count > 0) then
Controls.ThermoNuclearDevices:SetHide(false);
Controls.ThermoNuclearDeviceCount:SetText(count);
else
Controls.ThermoNuclearDevices:SetHide(true);
end
end
end
Controls.YieldStack:CalculateSize();
end
OnRefreshYields(); -- Don't directly refresh, call EVENT version so it's queued in the next context update.
end
-- ===========================================================================
function OnGreatPersonActivated(playerID:number)
if ( Game.GetLocalPlayer() == playerID ) then
OnRefreshYields();
end
end
-- ===========================================================================
function OnGreatWorkCreated(playerID:number)
if ( Game.GetLocalPlayer() == playerID ) then
OnRefreshYields();
end
end
-- ===========================================================================
function RefreshAll()
RefreshTurnsRemaining();
RefreshTrade();
RefreshInfluence();
RefreshYields();
RefreshTime();
OnWMDUpdate( Game.GetLocalPlayer() );
end
-- ===========================================================================
-- Game Engine Event
-- ===========================================================================
function OnTurnBegin()
RefreshAll();
end
-- ===========================================================================
-- Game Engine Event
-- ===========================================================================
function OnUpdateUI( type:number, tag:string, iData1:number, iData2:number, strData1:string)
if type == SystemUpdateUI.ScreenResize then
Resize();
end
end
-- ===========================================================================
function OnRefresh()
ContextPtr:ClearRequestRefresh();
RefreshYields();
end
-- ===========================================================================
-- Game Engine Event
-- Wait until the game engine is done loading before the initial refresh,
-- otherwise there is a chance the load of the LUA threads (UI & core) will
-- clash and then we'll all have a bad time. :(
-- ===========================================================================
function OnLoadGameViewStateDone()
RefreshAll();
end
-- ===========================================================================
function Initialize()
m_viewReportsX = Controls.ViewReports:GetSizeX();
Resize();
-- UI Callbacks
ContextPtr:SetRefreshHandler( OnRefresh );
Controls.CivpediaButton:RegisterCallback( Mouse.eLClick, OnOpenCivilopedia );
Controls.CivpediaButton:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end);
Controls.MenuButton:RegisterCallback( Mouse.eLClick, OnMenu );
Controls.MenuButton:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end);
Controls.ViewReports:RegisterCallback( Mouse.eLClick, OnToggleReportsScreen );
Controls.ViewReports:RegisterCallback( Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end);
-- Game Events
Events.AnarchyBegins.Add( OnRefreshYields );
Events.AnarchyEnds.Add( OnRefreshYields );
Events.BeliefAdded.Add( OnRefreshYields );
Events.CityInitialized.Add( OnCityInitialized );
Events.CityFocusChanged.Add( OnRefreshYields );
Events.CityWorkerChanged.Add( OnRefreshYields );
Events.DiplomacySessionClosed.Add( OnRefreshYields );
Events.FaithChanged.Add( OnRefreshYields );
Events.GovernmentChanged.Add( OnRefreshYields );
Events.GovernmentPolicyChanged.Add( OnRefreshYields );
Events.GovernmentPolicyObsoleted.Add( OnRefreshYields );
Events.GreatWorkCreated.Add( OnGreatWorkCreated );
Events.ImprovementAddedToMap.Add( OnRefreshResources );
Events.ImprovementRemovedFromMap.Add( OnRefreshResources );
Events.InfluenceChanged.Add( RefreshInfluence );
Events.LoadGameViewStateDone.Add( OnLoadGameViewStateDone );
Events.LocalPlayerChanged.Add( OnLocalPlayerChanged );
Events.PantheonFounded.Add( OnRefreshYields );
Events.PlayerAgeChanged.Add( OnRefreshYields );
Events.ResearchCompleted.Add( OnRefreshResources );
Events.PlayerResourceChanged.Add( OnRefreshResources );
Events.SystemUpdateUI.Add( OnUpdateUI );
Events.TradeRouteActivityChanged.Add( RefreshTrade );
Events.TradeRouteCapacityChanged.Add( RefreshTrade );
Events.TreasuryChanged.Add( OnRefreshYields );
Events.TurnBegin.Add( OnTurnBegin );
Events.UnitAddedToMap.Add( OnRefreshYields );
Events.UnitGreatPersonActivated.Add( OnGreatPersonActivated );
Events.UnitKilledInCombat.Add( OnRefreshYields );
Events.UnitRemovedFromMap.Add( OnRefreshYields );
Events.VisualStateRestored.Add( OnTurnBegin );
Events.WMDCountChanged.Add( OnWMDUpdate );
OnTurnBegin();
end
Initialize();