forked from civfanatics/Civ6-UIFiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiplomacyActionView.lua
3059 lines (2592 loc) · 123 KB
/
DiplomacyActionView.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
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- ===========================================================================
-- Diplomacy Trade View Manager
-- ===========================================================================
include( "InstanceManager" );
include( "SupportFunctions" );
include( "Civ6Common" );
include( "LeaderSupport" );
include( "DiplomacyRibbonSupport" );
include( "DiplomacyStatementSupport" );
include( "TeamSupport" );
include( "GameCapabilities" );
include( "LeaderIcon" );
include( "PopupDialog" );
include( "CivilizationIcon" );
-- ===========================================================================
-- GLOBALS
-- ===========================================================================
g_ActionListIM = InstanceManager:new( "ActionButton", "Button" );
g_SubActionListIM = InstanceManager:new( "ActionButton", "Button" );
MAX_BEFORE_TRUNC_BUTTON_INST = 350;
COLOR_BLUE_GRAY = UI.GetColorValueFromHexLiteral(0xFF9c8772);
COLOR_BUTTONTEXT_SELECTED = UI.GetColorValueFromHexLiteral(0xFF291F10);
COLOR_BUTTONTEXT_SELECTED_SHADOW = UI.GetColorValueFromHexLiteral(0xAAD8B489);
COLOR_BUTTONTEXT_NORMAL = UI.GetColorValueFromHexLiteral(0xFFC9DAE7);
COLOR_BUTTONTEXT_NORMAL_SHADOW = UI.GetColorValueFromHexLiteral(0xA291F10);
COLOR_BUTTONTEXT_DISABLED = UI.GetColorValueFromHexLiteral(0xFF90999F);
g_bIsLocalPlayerTurn = true;
-- ===========================================================================
-- CONSTANTS
-- ===========================================================================
local LEADERTEXT_PADDING_X :number = 40;
local LEADERTEXT_PADDING_Y :number = 40;
local SELECTION_PADDING_Y :number = 20;
local OVERVIEW_MODE = 0;
local CONVERSATION_MODE = 1;
local CINEMA_MODE = 2;
local DEAL_MODE = 3;
local SIZE_BUILDING_ICON :number = 32;
local SIZE_UNIT_ICON :number = 32;
local INTEL_NO_SUB_PANEL = -1;
local INTEL_ACCESS_LEVEL_PANEL = 0;
local INTEL_RELATIONSHIP_PANEL = 1;
local INTEL_GOSSIP_HISTORY_PANEL = 2;
local INTEL_AGENDA_PANEL = 3;
local DIPLOMACY_RIBBON_OFFSET = 64;
local MAX_BEFORE_TRUNC_BUTTON_INST = 280;
local PADDING_FOR_SCROLLPANEL = 220;
local TEAM_RIBBON_SIZE :number = 53;
local TEAM_RIBBON_SMALL_SIZE :number = 30;
local TEAM_RIBBON_PREFIX :string = "ICON_TEAM_RIBBON_";
local VOICEOVER_SUPPORT: table = {"KUDOS", "WARNING", "DECLARE_WAR_FROM_HUMAN", "DECLARE_WAR_FROM_AI", "FIRST_MEET", "DEFEAT","ENRAGED"};
--This is the multiplier for the portion of the screen which the conversation control should cover.
local CONVO_X_MULTIPLIER = .328;
-- ===========================================================================
-- VARIABLES
-- ===========================================================================
local ms_PlayerPanelIM :table = InstanceManager:new( "PlayerPanel", "Root" );
local ms_DiplomacyRibbonIM :table = InstanceManager:new( "DiplomacyRibbonVert", "Root" );
local ms_DiplomacyRibbonLeaderIM :table = InstanceManager:new( "DiplomacyRibbonLeader", "Root" );
local ms_IconOnlyIM :table = InstanceManager:new( "IconOnly", "Icon");
local ms_IconAndTextIM :table = InstanceManager:new( "IconAndText", "SelectButton", Controls.IconAndTextContainer );
local ms_LeftRightListIM :table = InstanceManager:new( "LeftRightList", "List", Controls.LeftRightListContainer );
local ms_TopDownListIM :table = InstanceManager:new( "TopDownList", "List", Controls.TopDownListContainer );
local ms_IntelPanelIM :table = InstanceManager:new( "IntelPanel", "Panel" );
local ms_IntelTabButtonIM :table = InstanceManager:new( "IntelTabButtonInstance", "Button" );
-- Intel panel instances
local ms_IntelOverviewIM :table = InstanceManager:new( "IntelOverviewInstance", "Top" );
local ms_IntelGossipIM :table = InstanceManager:new( "IntelGossipHistoryPanel", "Top" );
local ms_IntelAccessLevelIM :table = InstanceManager:new( "IntelAccessLevelPanel", "Top" );
local ms_IntelRelationshipIM :table = InstanceManager:new( "IntelRelationshipPanel", "Top" );
local ms_IntelTabAnchorIM :table = InstanceManager:new( "IntelTabAnchorInstance", "Anchor" );
-- Intel overview row instances
local ms_IntelOverviewDividerIM :table = InstanceManager:new( "IntelOverviewDividerInstance", "TheDivider" );
local ms_IntelOverviewGossipIM :table = InstanceManager:new( "IntelOverviewGossipInstance", "Top" );
local ms_IntelOverviewAccessLevelIM :table = InstanceManager:new( "IntelOverviewAccessLevelInstance", "Top" );
local ms_IntelOverviewGovernmentIM :table = InstanceManager:new( "IntelOverviewGovernmentInstance", "Top" );
local ms_IntelOverviewAgendasIM :table = InstanceManager:new( "IntelOverviewAgendasInstance", "Top" );
local ms_IntelOverviewAgendaEntryIM :table = InstanceManager:new( "IntelOverviewAgendaEntryInstance", "Top" );
local ms_IntelOverviewAgreementsIM :table = InstanceManager:new( "IntelOverviewAgreementsInstance", "Top" );
local ms_IntelOverviewOurRelationshipIM :table = InstanceManager:new( "IntelOverviewOurRelationshipInstance", "Top" );
local ms_IntelOverviewOtherRelationshipsIM :table = InstanceManager:new( "IntelOverviewOtherRelationshipsInstance", "Top" );
local ms_IntelOverviewAnchorIM :table = InstanceManager:new( "IntelOverviewAnchorInstance", "Anchor" );
local ms_IntelRelationshipReasonIM :table = InstanceManager:new( "IntelRelationshipReasonEntry", "Background" );
local ms_RelationshipIconsIM :table = InstanceManager:new( "RelationshipIcon", "Background" );
local ms_IntelGossipHistoryPanelEntryIM :table = InstanceManager:new( "IntelGossipHistoryPanelEntry", "Background" );
local ms_ConversationSelectionIM :table = InstanceManager:new( "ConversationSelectionInstance", "SelectionButton", Controls.ConversationSelectionStack );
local ms_uniqueIconIM :table = InstanceManager:new("IconInfoInstance", "Top", Controls.FeaturesStack );
local ms_uniqueTextIM :table = InstanceManager:new("TextInfoInstance", "Top", Controls.FeaturesStack );
local OTHER_PLAYER = 0;
local LOCAL_PLAYER = 1;
local ms_PlayerPanel = nil;
ms_DiplomacyRibbon = nil;
local ms_LocalPlayerLeaderID = -1;
-- The 'other' player who may have contacted local player, which brought us to this view. Can be nil.
local ms_OtherPlayer = nil;
local ms_OtherPlayerID = -1;
local ms_SelectedPlayerLeaderTypeName = nil;
local ms_showingLeaderName = "";
local ms_bLeaderShowRequested = false;
local ms_LeaderIDToRibbonEntry = {}; -- List of the ribbon entries indexed by leader ID
local ms_InitiatedByPlayerID = -1;
local ms_bIsViewInitialized = false;
local ms_currentViewMode = -1;
local ms_bShowingDeal = false;
local m_isInHotload = false;
local m_bCloseSessionOnFadeComplete = false;
local m_eventID:number = 0;
local m_firstOpened = true;
local m_LeaderCoordinates :table = {};
local m_lastLeaderPlayedMusicFor = -1;
local m_bCurrentMusicIsModder : boolean = false;
local ms_LastDealResponseAnimation = nil;
-- VOICEOVER SUPPORT
local m_voiceoverText :string = "";
local m_cinemaMode :boolean = false;
local m_currentLeaderAnim :string = "";
local m_currentSceneEffect :string = "";
local ms_OtherID;
m_LiteMode = false;
-- ===========================================================================
-- GLOBALS (accessible in scripts that include this file)
-- ===========================================================================
ms_IntelPanel = nil;
ms_LocalPlayer = nil;
ms_LocalPlayerID = -1;
-- The selected player. This can be any player, including the local player
ms_SelectedPlayerID = -1;
ms_SelectedPlayer = nil;
ms_ActiveSessionID = nil;
m_bottomPanelHeight = 0;
m_PopupDialog = PopupDialog:new("DiplomacyActionViewPopup");
-- ===========================================================================
function GetOtherPlayer(player : table)
if (player ~= nil and player:GetID() == ms_OtherPlayer:GetID()) then
return ms_LocalPlayer;
end
return ms_OtherPlayer;
end
-- ===========================================================================
function GetStatementMood( fromPlayer : number, inputMood : number )
local pPlayer = Players[fromPlayer];
local otherPlayerID = GetOtherPlayer(pPlayer):GetID();
local eFromPlayerMood = inputMood;
if (inputMood == DiplomacyMoodTypes.UNDEFINED) then
-- If the mood was not defined in the statement, get the current mood. This is most often the case because when the statement has been sent, the
-- diplomacy action that it is in reaction to has usually not taken effect, so the mood is not correct at that time.
return DiplomacySupport_GetPlayerMood(pPlayer, otherPlayerID);
else
return inputMood;
end
end
local DiplomaticStateIndexToVisState = {};
DiplomaticStateIndexToVisState[DiplomaticStates.ALLIED] = 0;
DiplomaticStateIndexToVisState[DiplomaticStates.DECLARED_FRIEND] = 1;
DiplomaticStateIndexToVisState[DiplomaticStates.FRIENDLY] = 2;
DiplomaticStateIndexToVisState[DiplomaticStates.NEUTRAL] = 3;
DiplomaticStateIndexToVisState[DiplomaticStates.UNFRIENDLY] = 4;
DiplomaticStateIndexToVisState[DiplomaticStates.DENOUNCED] = 5;
DiplomaticStateIndexToVisState[DiplomaticStates.WAR] = 6;
-- ===========================================================================
-- Take the diplomatic state index and convert it to a vis state index for our icons
-- Yes, *currently* the index state is the same, but it is NOT good practice
-- to assume starting position or order of a database item, ever.
function GetVisStateFromDiplomaticState(iState)
local eStateHash = GameInfo.DiplomaticStates[iState].Hash;
local iVisState = DiplomaticStateIndexToVisState[eStateHash];
if (iVisState ~= nil) then
return iVisState;
end
return 0;
end
-- ===========================================================================
function UpdateSelectedPlayer(allowDeadPlayer)
if (allowDeadPlayer == nil) then
allowDeadPlayer = false;
end
-- Have we met them and are they in the ribbon (alive) or allowing dead players (for defeat messages)
if (ms_LocalPlayer:GetDiplomacy():HasMet(ms_SelectedPlayerID) and (allowDeadPlayer == true or ms_LeaderIDToRibbonEntry[ms_SelectedPlayerID] ~= nil)) then
ms_SelectedPlayer = Players[ms_SelectedPlayerID];
else
ms_SelectedPlayer = ms_LocalPlayer;
ms_SelectedPlayerID = ms_LocalPlayerID;
end
if (ms_SelectedPlayer ~= nil) then
local playerConfig = PlayerConfigurations[ms_SelectedPlayer:GetID()];
if (playerConfig ~= nil) then
ms_SelectedPlayerLeaderTypeName = playerConfig:GetLeaderTypeName();
ms_OtherCivilizationID = playerConfig:GetCivilizationTypeID();
ms_OtherLeaderID = playerConfig:GetLeaderTypeID();
ms_OtherID = ms_SelectedPlayer:GetID();
ResetPlayerPanel();
end
end
end
-- ===========================================================================
function CreateHorizontalGroup(rootStack : table, title : string)
local iconList = ms_LeftRightListIM:GetInstance(rootStack);
if (title == nil or title == "") then
iconList.Title:SetHide(true); -- No title
else
iconList.TitleText:LocalizeAndSetText(title);
end
return iconList;
end
-- ===========================================================================
function CreateVerticalGroup(rootStack : table, title : string)
local iconList = ms_TopDownListIM:GetInstance(rootStack);
if (title == nil or title == "") then
iconList.Title:SetHide(true); -- No title
else
iconList.TitleText:LocalizeAndSetText(title);
end
return iconList;
end
-- ===========================================================================
function CreatePlayerPanel(rootControl : table)
local playerPanel = ms_PlayerPanelIM:GetInstance(rootControl);
return playerPanel;
end
-- ===========================================================================
function CreateDiplomacyRibbon(rootControl : table)
local diplomacyRibbon = ms_DiplomacyRibbonIM:GetInstance(rootControl);
return diplomacyRibbon;
end
-- ===========================================================================
function CreatePanels()
-- Create the Player Panel
ms_PlayerPanel = CreatePlayerPanel(Controls.PlayerContainer);
-- Create the Diplomacy Ribbon
ms_DiplomacyRibbon = CreateDiplomacyRibbon(Controls.DiplomacyRibbonContainer);
end
-- ===========================================================================
-- Make sure the active session is still there.
function ValidateActiveSession()
if (ms_ActiveSessionID ~= nil) then
if (not DiplomacyManager.IsSessionIDOpen(ms_ActiveSessionID)) then
ms_ActiveSessionID = nil;
return false;
end
end
return true;
end
-- ===========================================================================
-- Exit the conversation mode.
function ExitConversationMode()
if (ms_currentViewMode == CONVERSATION_MODE) then
ValidateActiveSession();
if (ms_ActiveSessionID ~= nil) then
-- Close the session, this will handle exiting back to OVERVIEW_MODE or exiting, if the other leader contacted us.
if (HasNextQueuedSession(ms_ActiveSessionID)) then
-- There is another session right after this one, so we want to delay sending the CloseSession until the screen goes to black.
m_bCloseSessionOnFadeComplete = true;
StartFadeOut();
else
-- Close the session now.
DiplomacyManager.CloseSession( ms_ActiveSessionID );
end
else
-- No session for some reason, just go directly back.
SelectPlayer(ms_OtherPlayerID, OVERVIEW_MODE);
end
ResetPlayerPanel();
end
end
-- ===========================================================================
function StartFadeOut()
Controls.BlackFade:SetHide(false);
Controls.BlackFadeAnim:SetToBeginning();
Controls.BlackFadeAnim:Play();
Controls.FadeTimerAnim:SetToBeginning();
Controls.FadeTimerAnim:Play();
end
-- ===========================================================================
function StartFadeIn()
Controls.BlackFade:SetHide(false);
-- Only do the BlackFadeAnim
Controls.BlackFadeAnim:SetToBeginning(); -- This forces a clear of the reverse flag.
Controls.BlackFadeAnim:SetToEnd();
Controls.BlackFadeAnim:Reverse();
end
-- ===========================================================================
function IsWarChoice(key)
local isWar :boolean = key == "CHOICE_DECLARE_SURPRISE_WAR"
or key == "CHOICE_DECLARE_FORMAL_WAR"
or key == "CHOICE_DECLARE_HOLY_WAR"
or key == "CHOICE_DECLARE_LIBERATION_WAR"
or key == "CHOICE_DECLARE_RECONQUEST_WAR"
or key == "CHOICE_DECLARE_PROTECTORATE_WAR"
or key == "CHOICE_DECLARE_COLONIAL_WAR"
or key == "CHOICE_DECLARE_TERRITORIAL_WAR";
return isWar;
end
function GetWarType(key)
if (key == "CHOICE_DECLARE_FORMAL_WAR") then return WarTypes.FORMAL_WAR; end;
if (key == "CHOICE_DECLARE_HOLY_WAR") then return WarTypes.HOLY_WAR; end;
if (key == "CHOICE_DECLARE_LIBERATION_WAR") then return WarTypes.LIBERATION_WAR; end;
if (key == "CHOICE_DECLARE_RECONQUEST_WAR") then return WarTypes.RECONQUEST_WAR; end;
if (key == "CHOICE_DECLARE_PROTECTORATE_WAR") then return WarTypes.PROTECTORATE_WAR; end;
if (key == "CHOICE_DECLARE_COLONIAL_WAR") then return WarTypes.COLONIAL_WAR; end;
if (key == "CHOICE_DECLARE_TERRITORIAL_WAR") then return WarTypes.TERRITORIAL_WAR; end;
return WarTypes.SURPRISE_WAR;
end
function GetGoldCost(key)
local szActionString = "";
if (key == "CHOICE_DIPLOMATIC_DELEGATION") then szActionString = "DIPLOACTION_DIPLOMATIC_DELEGATION"; end;
if (key == "CHOICE_RESIDENT_EMBASSY") then szActionString = "DIPLOACTION_RESIDENT_EMBASSY"; end;
if (key == "CHOICE_OPEN_BORDERS") then szActionString = "DIPLOACTION_OPEN_BORDERS"; end;
if (szActionString == "") then return 0; end;
return ms_LocalPlayer:GetDiplomacy():GetDiplomaticActionCost(szActionString);
end
-- ===========================================================================
function IsPeaceChoice(key)
local isPeace :boolean = (key == "CHOICE_MAKE_PEACE");
return isPeace;
end
function CanInitiateDiplomacyStatement()
return ms_LocalPlayerID ~= ms_SelectedPlayerID and ms_SelectedPlayerID >= 0 and not GameConfiguration.IsPaused();
end
-- ===========================================================================
-- Handle a statement selection from the OVERVIEW_MODE. We are not
-- in a session with the other player yet, this will start one.
function OnSelectInitialDiplomacyStatement(key)
if CanInitiateDiplomacyStatement() then
if (key == "CHOICE_DECLARE_SURPRISE_WAR") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "DECLARE_SURPRISE_WAR");
elseif (key == "CHOICE_DECLARE_FORMAL_WAR") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "DECLARE_FORMAL_WAR");
elseif (key == "CHOICE_DECLARE_HOLY_WAR") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "DECLARE_HOLY_WAR");
elseif (key == "CHOICE_DECLARE_LIBERATION_WAR") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "DECLARE_LIBERATION_WAR");
elseif (key == "CHOICE_DECLARE_RECONQUEST_WAR") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "DECLARE_RECONQUEST_WAR");
elseif (key == "CHOICE_DECLARE_PROTECTORATE_WAR") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "DECLARE_PROTECTORATE_WAR");
elseif (key == "CHOICE_DECLARE_COLONIAL_WAR") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "DECLARE_COLONIAL_WAR");
elseif (key == "CHOICE_DECLARE_TERRITORIAL_WAR") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "DECLARE_TERRITORIAL_WAR");
elseif (key == "CHOICE_MAKE_PEACE") then
-- DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "MAKE_PEACE");
-- Clear the outgoing deal, if we have nothing pending, so the user starts out with an empty deal.
if (not DealManager.HasPendingDeal(ms_LocalPlayerID, ms_SelectedPlayerID)) then
DealManager.ClearWorkingDeal(DealDirection.OUTGOING, ms_LocalPlayerID, ms_SelectedPlayerID);
local pDeal = DealManager.GetWorkingDeal(DealDirection.OUTGOING, ms_LocalPlayer:GetID(), ms_SelectedPlayerID);
if (pDeal ~= nil) then
pDealItem = pDeal:AddItemOfType(DealItemTypes.AGREEMENTS, ms_LocalPlayer:GetID());
if (pDealItem ~= nil) then
pDealItem:SetSubType(DealAgreementTypes.MAKE_PEACE);
pDealItem:SetLocked(true);
end
-- Validate the deal, this will make sure peace is on both sides of the deal.
pDeal:Validate();
end
end
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "MAKE_DEAL");
elseif (key == "CHOICE_MAKE_DEAL") then
-- Clear the outgoing deal, if we have nothing pending, so the user starts out with an empty deal.
if (not DealManager.HasPendingDeal(ms_LocalPlayerID, ms_SelectedPlayerID)) then
DealManager.ClearWorkingDeal(DealDirection.OUTGOING, ms_LocalPlayerID, ms_SelectedPlayerID);
end
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "MAKE_DEAL");
elseif (key == "CHOICE_VIEW_DEAL") then
DealManager.ViewPendingDeal(ms_LocalPlayerID, ms_SelectedPlayerID);
elseif (key == "CHOICE_MAKE_DEMAND") then
-- Clear the outgoing deal, if we have nothing pending, so the user starts out with an empty deal.
if (not DealManager.HasPendingDeal(ms_LocalPlayerID, ms_SelectedPlayerID)) then
DealManager.ClearWorkingDeal(DealDirection.OUTGOING, ms_LocalPlayerID, ms_SelectedPlayerID);
end
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "MAKE_DEMAND");
elseif (key == "CHOICE_VIEW_DEMAND") then
DealManager.ViewPendingDeal(ms_LocalPlayerID, ms_SelectedPlayerID);
elseif (key == "CHOICE_DENOUNCE") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "DENOUNCE");
elseif (key == "CHOICE_DIPLOMATIC_DELEGATION") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "DIPLOMATIC_DELEGATION");
elseif (key == "CHOICE_DECLARE_FRIENDSHIP") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "DECLARE_FRIEND");
elseif (key == "CHOICE_RESIDENT_EMBASSY") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "RESIDENT_EMBASSY");
elseif (key == "CHOICE_OPEN_BORDERS") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "OPEN_BORDERS");
elseif (key == "CHOICE_DEMAND_PROMISE_DONT_SPY") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "WARNING_STOP_SPYING_ON_ME");
elseif (key == "CHOICE_DEMAND_PROMISE_DONT_SETTLE_TOO_NEAR") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "WARNING_DONT_SETTLE_NEAR_ME");
elseif (key == "CHOICE_DEMAND_PROMISE_DONT_CONVERT_CITY") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "WARNING_STOP_CONVERTING_MY_CITIES");
elseif (key == "CHOICE_DEMAND_PROMISE_DONT_DIG_ARTIFACTS") then
DiplomacyManager.RequestSession(ms_LocalPlayerID, ms_SelectedPlayerID, "WARNING_STOP_DIGGING_UP_ARTIFACTS");
end
end
end
-- ===========================================================================
-- Handle a statment selection when in CONVERSATION_MODE. We will already be
-- in a session with the other player.
function OnSelectConversationDiplomacyStatement(key)
if (key == "CHOICE_EXIT") then
ExitConversationMode();
else
if (key == "CHOICE_DECLARE_SURPRISE_WAR") then
DiplomacyManager.AddStatement(ms_ActiveSessionID, Game.GetLocalPlayer(), "DECLARE_SURPRISE_WAR");
elseif (key == "CHOICE_DECLARE_FORMAL_WAR") then
DiplomacyManager.AddStatement(ms_ActiveSessionID, Game.GetLocalPlayer(), "DECLARE_FORMAL_WAR");
elseif (key == "CHOICE_DECLARE_HOLY_WAR") then
DiplomacyManager.AddStatement(ms_ActiveSessionID, Game.GetLocalPlayer(), "DECLARE_HOLY_WAR");
elseif (key == "CHOICE_DECLARE_LIBERATION_WAR") then
DiplomacyManager.AddStatement(ms_ActiveSessionID, Game.GetLocalPlayer(), "DECLARE_LIBERATION_WAR");
elseif (key == "CHOICE_DECLARE_RECONQUEST_WAR") then
DiplomacyManager.AddStatement(ms_ActiveSessionID, Game.GetLocalPlayer(), "DECLARE_RECONQUEST_WAR");
elseif (key == "CHOICE_DECLARE_PROTECTORATE_WAR") then
DiplomacyManager.AddStatement(ms_ActiveSessionID, Game.GetLocalPlayer(), "DECLARE_PROTECTORATE_WAR");
elseif (key == "CHOICE_DECLARE_COLONIAL_WAR") then
DiplomacyManager.AddStatement(ms_ActiveSessionID, Game.GetLocalPlayer(), "DECLARE_COLONIAL_WAR");
elseif (key == "CHOICE_DECLARE_TERRITORIAL_WAR") then
DiplomacyManager.AddStatement(ms_ActiveSessionID, Game.GetLocalPlayer(), "DECLARE_TERRITORIAL_WAR");
elseif (key == "CHOICE_MAKE_PEACE") then
DiplomacyManager.AddStatement(ms_ActiveSessionID, Game.GetLocalPlayer(), "MAKE_PEACE");
elseif (key == "CHOICE_MAKE_DEAL") then
DiplomacyManager.AddStatement(ms_ActiveSessionID, Game.GetLocalPlayer(), "MAKE_DEAL");
elseif (key == "CHOICE_MAKE_DEMAND") then
DiplomacyManager.AddStatement(ms_ActiveSessionID, Game.GetLocalPlayer(), "MAKE_DEMAND");
else
if (key == "CHOICE_POSITIVE") then
DiplomacyManager.AddResponse(ms_ActiveSessionID, Game.GetLocalPlayer(), "POSITIVE");
else
if (key == "CHOICE_NEGATIVE") then
DiplomacyManager.AddResponse(ms_ActiveSessionID, Game.GetLocalPlayer(), "NEGATIVE");
else
if (key == "CHOICE_IGNORE") then
DiplomacyManager.AddResponse(ms_ActiveSessionID, Game.GetLocalPlayer(), "RESPONSE_IGNORE");
else
-- Just pass the choice key through as a response string.
DiplomacyManager.AddResponse(ms_ActiveSessionID, Game.GetLocalPlayer(), key);
end
end
end
end
end
end
-- ===========================================================================
-- This applies the current statement to the CONVERSATION_MODE controls
function ApplyStatement(handler : table, statementTypeName : string, statementSubTypeName : string, toPlayer : number, kStatement : table)
local eFromPlayerMood = GetStatementMood( kStatement.FromPlayer, kStatement.FromPlayerMood);
local kParsedStatement = handler.ExtractStatement(handler, statementTypeName, statementSubTypeName, kStatement.FromPlayer, eFromPlayerMood, kStatement.Initiator);
handler.RemoveInvalidSelections(kParsedStatement, ms_LocalPlayerID, ms_OtherPlayerID);
local leaderstr :string = "";
local reasonStr :string = "";
if (kParsedStatement.StatementText ~= nil) then
leaderstr = Locale.Lookup( DiplomacyManager.FindTextKey( kParsedStatement.StatementText, kStatement.FromPlayer, kStatement.FromMood, toPlayer));
local reasonStrKey : string = DiplomacyManager.FindReasonTextKey( kParsedStatement.ReasonText, kStatement.FromPlayer, kStatement.AiReason, kStatement.AiModifier);
if ( reasonStrKey ~= nil ) then
reasonStr = Locale.Lookup( reasonStrKey );
local agendaStr = DiplomacyManager.FindReasonAgendaTextKey(kStatement.FromPlayer, toPlayer, kStatement.AiReason, kStatement.AiModifier);
if (agendaStr ~= nil ) then
reasonStr = reasonStr .. agendaStr;
end
end
Controls.LeaderResponseText:SetText( leaderstr );
m_voiceoverText = leaderstr;
end
ms_ConversationSelectionIM:ResetInstances();
if (kParsedStatement.Selections ~= nil) then
for _, selection in ipairs(kParsedStatement.Selections) do
local instance :table = ms_ConversationSelectionIM:GetInstance();
instance.SelectionText:SetText( Locale.Lookup(selection.Text) );
local texth :number = math.max( instance.SelectionText:GetSizeY() + SELECTION_PADDING_Y, 45 );
instance.SelectionButton:SetSizeY( texth );
instance.SelectionButton:SetToolTipString(); -- Clear any tooltips that may have been lingering
if (selection.IsDisabled == nil or selection.IsDisabled == false) then
instance.SelectionButton:SetDisabled( false );
instance.SelectionButton:RegisterCallback(Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end);
instance.SelectionButton:RegisterCallback( Mouse.eLClick,
function()
handler.OnSelectionButtonClicked(selection.Key);
end );
else
-- It is disabled
instance.SelectionButton:SetDisabled( true );
if (selection.FailureReasons ~= nil) then
instance.SelectionButton:SetToolTipString(Locale.Lookup(selection.FailureReasons[1]));
end
end
end
end
Controls.ConversationSelectionStack:CalculateSize();
-- Update leader response
Controls.LeaderResponseText:SetText( leaderstr );
-- Update leader reason
Controls.LeaderReasonText:SetText( reasonStr );
m_currentLeaderAnim = kParsedStatement.LeaderAnimation;
m_currentSceneEffect = kParsedStatement.SceneEffect;
local ePlayerMood = DiplomacySupport_GetPlayerMood(ms_SelectedPlayer, ms_LocalPlayerID);
if (ms_currentViewMode == CONVERSATION_MODE) then
LeaderSupport_QueueAnimationSequence( ms_OtherLeaderName, kParsedStatement.LeaderAnimation, ePlayerMood );
LeaderSupport_QueueSceneEffect( kParsedStatement.SceneEffect );
elseif (ms_currentViewMode == DEAL_MODE) then
if (ePlayerMood == DiplomacyMoodTypes.HAPPY) then
LeaderSupport_QueueAnimationSequence( ms_SelectedPlayerLeaderTypeName, "HAPPY_IDLE" );
elseif (ePlayerMood == DiplomacyMoodTypes.NEUTRAL) then
LeaderSupport_QueueAnimationSequence( ms_SelectedPlayerLeaderTypeName, "NEUTRAL_IDLE" );
elseif (ePlayerMood == DiplomacyMoodTypes.UNHAPPY) then
LeaderSupport_QueueAnimationSequence( ms_SelectedPlayerLeaderTypeName, "UNHAPPY_IDLE" );
end
end
-- Leader icon
local leaderIconController = CivilizationIcon:AttachInstance(Controls.LeaderResponseIcon);
leaderIconController:UpdateIconFromPlayerID(kStatement.FromPlayer);
-- Leader name
local leaderDesc = PlayerConfigurations[kStatement.FromPlayer]:GetLeaderName();
Controls.LeaderResponseName:SetText(Locale.ToUpper(Locale.Lookup("LOC_DIPLOMACY_DEAL_OTHER_PLAYER_SAYS", leaderDesc)));
end
-- ===========================================================================
function GetStatementButtonTooltip(pActionDef)
if pActionDef and pActionDef.Description then -- Make sure everything is there, Description is optional!
return Locale.Lookup(pActionDef.Description);
end
return nil;
end
-- ===========================================================================
function PopulateStatementList( options: table, rootControl: table, isSubList: boolean )
local buttonIM:table;
local stackControl:table;
local selectionText :string = "[SIZE_16]"; -- Resetting the string size for the new button instance
if (isSubList) then
buttonIM = g_ActionListIM;
stackControl = rootControl.SubOptionStack;
else
buttonIM = g_SubActionListIM;
stackControl = rootControl.OptionStack;
end
buttonIM:ResetInstances();
for _, selection in ipairs(options) do
local instance :table = buttonIM:GetInstance(stackControl);
local selectionText :string = selectionText.. Locale.Lookup(selection.Text);
local callback :ifunction;
local tooltipString :string = nil;
if( selection.Key ~= nil) then
callback = function() OnSelectInitialDiplomacyStatement( selection.Key ) end;
local pActionDef = GameInfo.DiplomaticActions[selection.DiplomaticActionType];
instance.Button:SetToolTipString(GetStatementButtonTooltip(pActionDef));
-- If costs gold add text
local iCost = GetGoldCost(selection.Key);
if iCost > 0 then
local szGoldString = Locale.Lookup("LOC_DIPLO_CHOICE_GOLD_INFO", iCost);
selectionText = selectionText .. szGoldString;
end
-- If war statement add warmongering info
if (IsWarChoice(selection.Key))then
local eWarType = GetWarType(selection.Key);
local iWarmongerPoints = ms_LocalPlayer:GetDiplomacy():ComputeDOWWarmongerPoints(ms_SelectedPlayerID, eWarType);
local szWarmongerLevel = ms_LocalPlayer:GetDiplomacy():GetWarmongerLevel(-iWarmongerPoints);
local szWarmongerString = Locale.Lookup("LOC_DIPLO_CHOICE_WARMONGER_INFO", szWarmongerLevel);
selectionText = selectionText .. szWarmongerString;
-- Change callback to prompt first.
callback = function()
LuaEvents.DiplomacyActionView_ConfirmWarDialog(ms_LocalPlayerID, ms_SelectedPlayerID, eWarType);
end;
end
--If denounce statement change callback to prompt first.
if (selection.Key == "CHOICE_DENOUNCE")then
local denounceFn = function() OnSelectInitialDiplomacyStatement( selection.Key ); end;
callback = function()
local playerConfig = PlayerConfigurations[ms_SelectedPlayer:GetID()];
if (playerConfig ~= nil) then
selectedCivName = Locale.Lookup(playerConfig:GetCivilizationShortDescription());
m_PopupDialog:Reset();
m_PopupDialog:AddText(Locale.Lookup("LOC_DENOUNCE_POPUP_BODY", selectedCivName));
m_PopupDialog:AddButton(Locale.Lookup("LOC_CANCEL"), nil);
m_PopupDialog:AddButton(Locale.Lookup("LOC_DIPLO_CHOICE_DENOUNCE"), denounceFn, nil, nil, "PopupButtonInstanceRed");
m_PopupDialog:Open();
end
end;
end
instance.ButtonText:SetText( selectionText );
if (selection.IsDisabled == nil or selection.IsDisabled == false) then
instance.Button:RegisterCallback(Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end);
instance.Button:RegisterCallback( Mouse.eLClick, callback );
instance.ButtonText:SetColor( COLOR_BUTTONTEXT_NORMAL );
instance.Button:SetDisabled( false );
else
instance.ButtonText:SetColor( COLOR_BUTTONTEXT_DISABLED );
instance.Button:SetDisabled( true );
if (selection.FailureReasons ~= nil) then
instance.Button:SetToolTipString(Locale.Lookup(selection.FailureReasons[1]));
end
end
instance.Button:SetDisabled(not g_bIsLocalPlayerTurn or selection.IsDisabled == true);
else
callback = selection.Callback;
instance.ButtonText:SetColor( COLOR_BUTTONTEXT_NORMAL );
instance.Button:SetDisabled(not g_bIsLocalPlayerTurn);
if ( selection.ToolTip ~= nil) then
tooltipString = Locale.Lookup(selection.ToolTip);
instance.Button:SetToolTipString(tooltipString);
else
instance.Button:SetToolTipString(nil); -- Clear any existing
end
end
local wasTruncated :boolean = TruncateString(instance.ButtonText, MAX_BEFORE_TRUNC_BUTTON_INST, selectionText);
if wasTruncated then
local finalTooltipString :string = selectionText;
if tooltipString ~= nil then
finalTooltipString = finalTooltipString .. "[NEWLINE]" .. tooltipString;
end
instance.Button:SetToolTipString( finalTooltipString );
end
-- Append tooltip string to the end of the tooltip if it exists in this selection
if selection.Tooltip then
local currentTooltipString = instance.Button:GetToolTipString();
instance.Button:SetToolTipString(currentTooltipString .. Locale.Lookup(selection.Tooltip));
end
instance.Button:RegisterCallback(Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end);
instance.Button:RegisterCallback( Mouse.eLClick, callback );
end
if (isSubList) then
local instance :table = buttonIM:GetInstance(stackControl);
selectionText = selectionText.. Locale.Lookup("LOC_CANCEL_BUTTON");
instance.ButtonText:SetText( selectionText );
instance.Button:SetToolTipString(nil);
instance.Button:SetDisabled(false);
instance.ButtonText:SetColor( COLOR_BUTTONTEXT_NORMAL );
instance.Button:RegisterCallback(Mouse.eMouseEnter, function() UI.PlaySound("Main_Menu_Mouse_Over"); end);
instance.Button:RegisterCallback( Mouse.eLClick, function() ShowOptionStack(false); end );
end
stackControl:CalculateSize();
end
-- ===========================================================================
-- This function allows modders to prevent certain options from showing up
-- on the top level statement list. By overwritting this and the function
-- below, they can have fine grained control over the initial options.
function ShouldAddTopLevelStatementOption(uiGroup)
return true;
end
-- ===========================================================================
function GetInitialStatementOptions(parsedStatements, rootControl)
local discussOptions: table = {};
local warOptions: table = {};
local topOptions: table = {};
for _, selection in ipairs(parsedStatements) do
local uiGroup = nil;
local pActionDef = GameInfo.DiplomaticActions[selection.DiplomaticActionType];
if pActionDef and pActionDef.UIGroup then -- Make sure everything is there before accessing!
uiGroup = pActionDef.UIGroup;
end
if uiGroup == "DISCUSS" then
table.insert(discussOptions, selection);
elseif uiGroup == "FORMALWAR" then
table.insert(warOptions, selection);
elseif ShouldAddTopLevelStatementOption(uiGroup) then
table.insert(topOptions, selection);
end
end
if(table.count(discussOptions) > 0) then
table.insert(topOptions, {
Text = Locale.Lookup("LOC_DIPLOMACY_DISCUSS").. " [ICON_List]",
Callback =
function()
PopulateStatementList( discussOptions, rootControl, true );
ShowOptionStack(true);
end,
});
end
if(table.count(warOptions) > 0) then
table.insert(topOptions, {
Text = Locale.Lookup("LOC_DIPLOMACY_CASUS_BELLI").. " [ICON_List]",
Callback =
function()
PopulateStatementList( warOptions, rootControl, true );
ShowOptionStack(true);
end,
ToolTip = "LOC_DIPLOMACY_CASUS_BELLI_TT"
});
end
return topOptions;
end
-- ===========================================================================
function AddStatmentOptions(rootControl : table)
g_ActionListIM:ResetInstances();
g_SubActionListIM:ResetInstances();
if (ms_LocalPlayerID ~= -1 and ms_SelectedPlayerID ~= -1) then
local useStatementType:string = (ms_LocalPlayerID ~= ms_SelectedPlayerID) and "GREETING" or "NO_TARGET";
-- Get the handler for the specific statement we will be using to fill in the initial statements
-- The normal statement that the initial selections are taken from is the GREETING statement
-- This usually contains all the possible selections, then they are filtered out if that are not applicable
-- for the current diplomacy state.
local handler = GetStatementHandler(useStatementType);
-- Get the statement options
local kParsedStatement = handler.ExtractStatement(handler, useStatementType, "NONE", ms_LocalPlayerID, DiplomacyMoodTypes.ANY, DiplomacyInitiatorTypes.HUMAN);
handler.RemoveInvalidSelections(kParsedStatement, ms_LocalPlayerID, ms_SelectedPlayerID);
-- Don't need the exit choice at this time
DiplomacySupport_RemoveSelectionByKey(kParsedStatement, "CHOICE_EXIT");
if kParsedStatement and kParsedStatement.Selections then
local topOptions:table = GetInitialStatementOptions(kParsedStatement.Selections, rootControl);
PopulateStatementList(topOptions, rootControl, false);
end
end
end
-- ===========================================================================
function OnActivateIntelRelationshipPanel(relationshipInstance : table)
local intelSubPanel = relationshipInstance;
-- Get the selected player's Diplomactic AI
local selectedPlayerDiplomaticAI = ms_SelectedPlayer:GetDiplomaticAI();
-- What do they think of us?
local iState = selectedPlayerDiplomaticAI:GetDiplomaticStateIndex(ms_LocalPlayerID);
local kStateEntry = GameInfo.DiplomaticStates[iState];
local eState = kStateEntry.Hash;
intelSubPanel.RelationshipText:LocalizeAndSetText( Locale.ToUpper(kStateEntry.Name) );
-- Fill the relationship bar to reflect the current status
local relationshipPercent = 1.0;
-- If we are at war, show the special flashing red bar
if (eState == DiplomaticStates.WAR) then
intelSubPanel.FlashingBar:SetHide(false);
intelSubPanel.AllyBar:SetHide(true);
intelSubPanel.WarBar:SetHide(false);
relationshipPercent = .02;
elseif (eState == DiplomaticStates.ALLIED) then
intelSubPanel.FlashingBar:SetHide(false);
intelSubPanel.AllyBar:SetHide(false);
intelSubPanel.WarBar:SetHide(true);
relationshipPercent = .92;
else
relationshipPercent = kStateEntry.RelationshipLevel / 100;
intelSubPanel.FlashingBar:SetHide(true);
end
intelSubPanel.RelationshipBar:SetPercent(relationshipPercent);
intelSubPanel.RelationshipIcon:SetOffsetX(relationshipPercent*intelSubPanel.RelationshipBar:GetSizeX());
intelSubPanel.RelationshipIcon:SetVisState( GetVisStateFromDiplomaticState(iState) );
local toolTips = selectedPlayerDiplomaticAI:GetDiplomaticModifiers(ms_LocalPlayerID);
ms_IntelRelationshipReasonIM:ResetInstances();
if(toolTips) then
table.sort(toolTips, function(a,b) return a.Score > b.Score; end);
for i, tip in ipairs(toolTips) do
local score = tip.Score;
local text = tip.Text;
if(score ~= 0) then
local relationshipReason = ms_IntelRelationshipReasonIM:GetInstance(intelSubPanel.RelationshipReasonStack);
local scoreText = Locale.Lookup("{1_Score : number +#,###.##;-#,###.##}", score);
if(score > 0) then
relationshipReason.Score:SetText("[COLOR_Civ6Green]" .. scoreText .. "[ENDCOLOR]");
else
relationshipReason.Score:SetText("[COLOR_Civ6Red]" .. scoreText .. "[ENDCOLOR]");
end
if(text == "LOC_TOOLTIP_DIPLOMACY_UNKNOWN_REASON") then
relationshipReason.Text:SetText("[COLOR_Grey]" .. Locale.Lookup(text) .. "[ENDCOLOR]");
else
relationshipReason.Text:SetText(Locale.Lookup(text));
end
end
end
end
intelSubPanel.RelationshipReasonStack:CalculateSize();
if(intelSubPanel.RelationshipReasonStack:GetSizeY()==0) then
intelSubPanel.NoReasons:SetHide(false);
else
intelSubPanel.NoReasons:SetHide(true);
end
if GameCapabilities.HasCapability("CAPABILITY_DIPLOMACY_RELATIONSHIP_INFO") then
-- Set the advisor icon
intelSubPanel.AdvisorIcon:SetTexture(IconManager:FindIconAtlas("ADVISOR_GENERIC", 32));
-- Get the advisor text
local advisorText = "";
local selectedCivName = "";
-- HACK: This is completely faked in for now... Ultimately this list will need to be much smarter
local playerConfig = PlayerConfigurations[ms_SelectedPlayer:GetID()];
if (playerConfig ~= nil) then
selectedCivName = playerConfig:GetCivilizationDescription();
end
local advisorTextlower = "[COLOR_Grey]";
advisorTextlower = advisorTextlower .. Locale.Lookup("LOC_DIPLOMACY_ADVISOR_OFFER");
advisorTextlower = advisorTextlower .. "[NEWLINE]";
-- advisorTextlower = advisorTextlower .. Locale.Lookup("LOC_DIPLOMACY_ADVISOR_DENOUNCE", selectedCivName);
-- advisorTextlower = advisorTextlower .. "[NEWLINE]";
advisorTextlower = advisorTextlower .. Locale.Lookup("LOC_DIPLOMACY_ADVISOR_TRADE_ROUTE", selectedCivName);
advisorTextlower = advisorTextlower .. "[NEWLINE]";
if (not ms_SelectedPlayer:GetDiplomacy():HasOpenBordersFrom(ms_LocalPlayer:GetID())) then
advisorTextlower = advisorTextlower .. Locale.Lookup("LOC_DIPLOMACY_ADVISOR_OPEN_BORDERS", selectedCivName);
advisorTextlower = advisorTextlower .. "[NEWLINE]";
end
if (not ms_LocalPlayer:GetDiplomacy():HasDelegationAt(ms_SelectedPlayer:GetID()) and not ms_LocalPlayer:GetDiplomacy():HasEmbassyAt(ms_SelectedPlayer:GetID())) then
advisorTextlower = advisorTextlower .. Locale.Lookup("LOC_DIPLOMACY_ADVISOR_DELEGATION_EMBASSY");
advisorTextlower = advisorTextlower .. "[NEWLINE]";
end
advisorTextlower = advisorTextlower .. Locale.Lookup("LOC_DIPLOMACY_ADVISOR_POSITIVE_AGENDA", selectedCivName);
advisorTextlower = advisorTextlower .. "[NEWLINE]";
advisorTextlower = advisorTextlower .. "[ENDCOLOR]";
local advisorTextRaise = "[COLOR_Grey]";
-- advisorTextRaise = advisorTextRaise .. Locale.Lookup("LOC_DIPLOMACY_ADVISOR_DENOUNCE_FRIEND", selectedCivName);
-- advisorTextRaise = advisorTextRaise .. "[NEWLINE]";
-- advisorTextRaise = advisorTextRaise .. Locale.Lookup("LOC_DIPLOMACY_ADVISOR_DECLARE_FRIENDSHIP", selectedCivName);
-- advisorTextRaise = advisorTextRaise .. "[NEWLINE]";
advisorTextRaise = advisorTextRaise .. Locale.Lookup("LOC_DIPLOMACY_ADVISOR_NEGATIVE_AGENDA", selectedCivName);
advisorTextRaise = advisorTextRaise .. "[NEWLINE]";
advisorTextRaise = advisorTextRaise .. Locale.Lookup("LOC_DIPLOMACY_ADVISOR_DENOUNCE_THEM");
advisorTextRaise = advisorTextRaise .. "[NEWLINE]";
advisorTextRaise = advisorTextRaise .. Locale.Lookup("LOC_DIPLOMACY_ADVISOR_REJECT_PROMISE");
advisorTextRaise = advisorTextRaise .. "[NEWLINE]";
advisorTextRaise = advisorTextRaise .. Locale.Lookup("LOC_DIPLOMACY_ADVISOR_BREAK_PROMISE");
advisorTextRaise = advisorTextRaise .. "[NEWLINE]";
advisorTextRaise = advisorTextRaise .. "[ENDCOLOR]";
intelSubPanel.AdvisorTextRaise:SetText(advisorTextlower);
intelSubPanel.AdvisorTextLower:SetText(advisorTextRaise);
intelSubPanel.Advisor:SetHide(false);
end
end
-- ===========================================================================
function OnActivateIntelAccessLevelPanel(accessLevelInstance : table)
local intelSubPanel = accessLevelInstance;
-- Get the selected player's Diplomactic AI
local selectedPlayerDiplomaticAI = ms_SelectedPlayer:GetDiplomaticAI();
local localPlayerDiplomacy = ms_LocalPlayer:GetDiplomacy();
local iAccessLevel = localPlayerDiplomacy:GetVisibilityOn(ms_SelectedPlayerID);
-- Get the items that contribute to our access level.
local accessContributionText = "";
for row in GameInfo.DiplomaticVisibilitySources () do
if (localPlayerDiplomacy:IsVisibilitySourceActive(ms_SelectedPlayerID, row.Index)) then
if (row.Description ~= nil) then
if (#accessContributionText > 0) then
accessContributionText = accessContributionText .. "[NEWLINE]";
end
accessContributionText = accessContributionText .. Locale.Lookup(row.Description);
end
end
end
if (#accessContributionText > 0) then
intelSubPanel.AccessContributionText:SetText(accessContributionText);
intelSubPanel.AccessContribution:SetHide(false);
else
intelSubPanel.AccessContribution:SetHide(true);
end
-- Access Level button and icon
intelSubPanel.AccessLevelText:LocalizeAndSetText(Locale.ToUpper(GameInfo.Visibilities[iAccessLevel].Name));
-- Shift to the correct place in the icon strip, using the vis states.
intelSubPanel.AccessLevelIcon:SetVisState( iAccessLevel-1 );
-- Set the information shared string
local szInfoSharedText = "";
local iNumAdded = 0;
for row in GameInfo.Gossips () do
if (row.VisibilityLevel == iAccessLevel) then
if (row.Description ~= nil) then
if (iNumAdded > 0) then