forked from videogamepreservation/7kaa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OR_NAT.cpp
1097 lines (852 loc) · 30.5 KB
/
OR_NAT.cpp
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
/*
* Seven Kingdoms: Ancient Adversaries
*
* Copyright 1997,1998 Enlight Software Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
//Filename : OR_NAT.CPP
//Description : Nation Report
#include <stdlib.h>
#include <KEY.h>
#include <OCONFIG.h>
#include <OVGA.h>
#include <OFONT.h>
#include <OSTR.h>
#include <OGETA.h>
#include <ODATE.h>
#include <OMOUSE.h>
#include <OIMGRES.h>
#include <OVBROWIF.h>
#include <OBUTTON.h>
#include <OSYS.h>
#include <ONATION.h>
#include <OTALKRES.h>
#include <OINFO.h>
#include <OREMOTE.h>
//------------- Define coordinations -----------//
enum { REPORT_BROWSE_X1 = ZOOM_X1+6,
REPORT_BROWSE_Y1 = ZOOM_Y1+6,
REPORT_BROWSE_X2 = ZOOM_X2-6,
REPORT_BROWSE_Y2 = REPORT_BROWSE_Y1+206,
REPORT_BUTTON_X1 = ZOOM_X1+8,
REPORT_BUTTON_Y1 = REPORT_BROWSE_Y2+6,
REPORT_BUTTON_WIDTH = 135,
REPORT_BUTTON_Y2 = REPORT_BUTTON_Y1+20,
REPORT_BUTTON_X_SPACE = 130,
REPORT_DET_X1 = ZOOM_X1+6,
REPORT_DET_Y1 = REPORT_BUTTON_Y2+4,
REPORT_DET_X2 = ZOOM_X2-6,
REPORT_DET_Y2 = ZOOM_Y2-6,
REPORT_TALK_Y2 = ZOOM_Y2-86, // use a shorter height for the diplomacy menu as it needs to let the player looks at the messages received.
};
//---------- Define report mode strings ---------//
static char* report_mode_str_array[MAX_NATION_REPORT_MODE] =
{
"Information",
"Diplomacy",
"Chat",
"Diplomatic Log",
"Debug",
};
//---------- Define chat receiver str strings ---------//
static char* chat_receiver_str_array[MAX_CHAT_RECEIVER_TYPE] =
{
"Send to the selected kingdom",
"Send to all allied human controlled kingdoms",
"Send to all human controlled kingdoms",
};
//----------- Define static variables ----------//
static VBrowseIF browse_nation, browse_talk_msg;
static ButtonGroup button_allow_attack(2);
static ButtonGroup button_chat_receiver(MAX_CHAT_RECEIVER_TYPE);
static int init_get_chat = 0;
static GetA get_chat;
//----------- Define static functions ----------//
static void put_nation_rec(int recNo, int x, int y, int refreshFlag);
static void put_talk_msg_rec(int recNo, int x, int y, int refreshFlag);
static int nation_filter(int recNo=0);
static void disp_button();
static int detect_button();
static void disp_detail(int refreshFlag);
static void detect_detail();
static void disp_nation_info();
static void detect_nation_info();
static void disp_debug_info();
static void disp_nation_talk();
static void detect_nation_talk();
static void disp_nation_chat(int refreshFlag);
static void detect_nation_chat();
static void disp_talk_msg_sent(int refreshFlag);
static int sort_talk_msg( const void *a, const void *b );
//--------- Begin of function Info::disp_nation ---------//
//
// <int> refreshFlag - INFO_REPAINT - the user has just switched
// to this report.
// INFO_UPDATE - the report is already in this mode,
// just keep displaying and updating.
//
void Info::disp_nation(int refreshFlag)
{
//--------- Create nation income and expenses browsers -------//
int x=REPORT_BROWSE_X1+9, y=REPORT_BROWSE_Y1+4;
vga_back.d3_panel_up(REPORT_BROWSE_X1, REPORT_BROWSE_Y1, REPORT_BROWSE_X2, REPORT_BROWSE_Y1+33 );
font_san.put( x , y+7, "Kingdom" );
font_san.put( x+185, y+7, "Reputation" );
font_san.put( x+275, y+7, "Status" );
#if(defined(SPANISH))
font_san.put( x+335, y , "Allow" );
font_san.put( x+335, y+13, "Attack" );
font_san.put( x+395, y, "Acuerdo" );
font_san.put( x+395, y+13, "Comerc." );
font_san.put( x+468, y , "Cantidad" );
font_san.put( x+468, y+13, "Comerciada" );
#elif(defined(FRENCH))
font_san.put( x+335, y , "Allow" );
font_san.put( x+335, y+13, "Attack" );
font_san.put( x+395, y, "Accord" );
font_san.put( x+395, y+13, "Commercial" );
font_san.put( x+473, y , "Montant" );
font_san.put( x+473, y+13, "Commercial" );
#elif(defined(GERMAN))
font_san.put( x+345, y , "Allow" );
font_san.put( x+343, y+13, "Attack" );
font_san.put( x+405, y , "Handels-" );
font_san.put( x+405, y+13, "Vertrag" );
font_san.put( x+465, y , "Handels-" );
font_san.put( x+465, y+13, "Betrag" );
#else
font_san.put( x+345, y , "Allow" );
font_san.put( x+343, y+13, "Attack" );
font_san.put( x+405, y , "Trade" );
font_san.put( x+405, y+13, "Treaty" );
font_san.put( x+465, y , "Trade" );
font_san.put( x+465, y+13, "Amount" );
#endif
if( refreshFlag == INFO_REPAINT )
{
browse_nation.init( REPORT_BROWSE_X1, REPORT_BROWSE_Y1+35, REPORT_BROWSE_X2, REPORT_BROWSE_Y2,
0, 20, nation_filter(), put_nation_rec, 1 );
browse_nation.open(browse_nation_recno);
}
else
{
browse_nation.paint();
browse_nation.open(browse_nation_recno, nation_filter());
}
browse_nation_recno = browse_nation.recno();
//------- disp report buttons --------//
disp_button();
//--------- display detail info --------//
if( refreshFlag==INFO_REPAINT )
{
info.last_talk_nation_recno = 0;
browse_talk_msg_recno = 1;
}
disp_detail(refreshFlag);
}
//----------- End of function Info::disp_nation -----------//
//--------- Begin of function Info::detect_nation ---------//
//
void Info::detect_nation()
{
//------- detect nation browser ------//
if( browse_nation.detect() )
{
browse_nation_recno = browse_nation.recno();
return;
}
//------- detect report buttons --------//
if( detect_button() )
return;
//--------- detect detail info -------//
detect_detail();
}
//----------- End of function Info::detect_nation -----------//
//--------- Begin of function Info::init_player_reply ---------//
//
// This function is called by TalkRes::player_reply() when the
// player is going to reply to a diplomatic message from another
// nation.
//
// <int> talkToNationRecno - recno of the nation the player is
// going to talk to.
//
void Info::init_player_reply(int talkToNationRecno)
{
nation_report_mode = NATION_REPORT_TALK;
info.player_reply_mode = 1;
//--- go to the nation in the browser which the player is going to talk to ---//
int nationCount = nation_filter();
int i;
for( i=1 ; i<=nationCount ; i++ )
{
if( nation_filter(i) == talkToNationRecno )
{
browse_nation_recno = i;
break;
}
}
err_when( i>nationCount );
//----- if currently it's in nation report mode -----//
if( sys.view_mode == MODE_NATION )
browse_nation.refresh(browse_nation_recno);
}
//----------- End of function Info::init_player_reply -----------//
//-------- Begin of static function nation_filter --------//
//
// This function has dual purpose :
//
// 1. when <int> recNo is not given :
// - return the total no. of nations of this nation
//
// 2. when <int> recNo is given :
// - return the nation recno in nation_array of the given recno.
//
static int nation_filter(int recNo)
{
int i, nationCount=0;
Nation* viewingNation = nation_array[info.viewing_nation_recno];
for( i=1 ; i<=nation_array.size() ; i++ )
{
if( nation_array.is_deleted(i) )
continue;
if( i==info.viewing_nation_recno ||
viewingNation->get_relation(i)->has_contact )
{
nationCount++;
}
if( recNo && nationCount==recNo )
return i;
}
err_when( recNo ); // the recNo is not found, it is out of range
return nationCount;
}
//----------- End of static function nation_filter -----------//
//-------- Begin of static function put_nation_rec --------//
//
static void put_nation_rec(int recNo, int x, int y, int refreshFlag)
{
int nationRecno = nation_filter(recNo);
Nation* nationPtr = nation_array[nationRecno];
Nation* viewingNation = nation_array[info.viewing_nation_recno];
NationRelation* nationRelation = viewingNation->get_relation(nationRecno);
x+=3;
y+=5;
nationPtr->disp_nation_color(x, y+1);
font_san.put( x+20 , y, nationPtr->nation_name(), 0, x+215 );
font_san.put( x+220, y, m.format((int) nationPtr->reputation) );
//------- display relation parameters --------//
if( nationRecno != info.viewing_nation_recno )
{
font_san.put( x+272, y, nationRelation->status_str() );
font_san.put( x+355, y, nationRelation->should_attack ? (char*)"Yes" : (char*)"No" );
font_san.put( x+412, y, nationRelation->trade_treaty ? (char*)"Yes" : (char*)"No" );
font_san.put( x+465, y, m.format( (int) viewingNation->total_year_trade(nationRecno),2) );
if( config.show_ai_info )
{
font_san.put( x+510, y, m.format(nationPtr->get_relation(info.viewing_nation_recno)->ai_relation_level) );
font_san.put( x+180, y, m.format( (int) nationPtr->get_relation(info.viewing_nation_recno)->good_relation_duration_rating) );
}
}
}
//----------- End of static function put_nation_rec -----------//
//--------- Begin of static function disp_button ---------//
//
static void disp_button()
{
int x=REPORT_BUTTON_X1;
for( int i=1 ; i<=MAX_NATION_REPORT_MODE ; i++ )
{
if( i==NATION_REPORT_DEBUG )
{
if( remote.is_enable() ||
( !sys.debug_session && !sys.testing_session ) )
{
continue;
}
}
else if( !sys.debug_session && i==NATION_REPORT_CHAT )
{
if( !remote.is_enable() )
continue;
}
//-----------------------------------------//
if( info.nation_report_mode == i )
vga.d3_panel_down( x, REPORT_BUTTON_Y1, x+REPORT_BUTTON_WIDTH-1, REPORT_BUTTON_Y2 );
else
vga.d3_panel_up( x, REPORT_BUTTON_Y1, x+REPORT_BUTTON_WIDTH-1, REPORT_BUTTON_Y2 );
font_san.center_put( x, REPORT_BUTTON_Y1, x+REPORT_BUTTON_WIDTH-1, REPORT_BUTTON_Y2, report_mode_str_array[i-1] );
x+=REPORT_BUTTON_WIDTH;
}
}
//----------- End of static function disp_button -----------//
//--------- Begin of static function detect_button ---------//
//
static int detect_button()
{
int x=REPORT_BUTTON_X1;
for( int i=1 ; i<=MAX_NATION_REPORT_MODE ; i++ )
{
if( i==NATION_REPORT_DEBUG )
{
if( remote.is_enable() ||
( !sys.debug_session && !sys.testing_session ) )
{
continue;
}
}
else if( !sys.debug_session && i==NATION_REPORT_CHAT )
{
if( !remote.is_enable() )
continue;
}
//-----------------------------------------//
if( mouse.single_click( x, REPORT_BUTTON_Y1, x+REPORT_BUTTON_WIDTH-1, REPORT_BUTTON_Y2 ) )
{
info.nation_report_mode = i;
return 1;
}
x+=REPORT_BUTTON_WIDTH;
}
return 0;
}
//----------- End of static function detect_button -----------//
//--------- Begin of static function disp_detail ---------//
//
static void disp_detail(int refreshFlag)
{
if( browse_nation.recno()==0 ) // no records in the list
return;
switch( info.nation_report_mode )
{
case NATION_REPORT_INFO:
disp_nation_info();
break;
case NATION_REPORT_TALK:
disp_nation_talk();
break;
case NATION_REPORT_CHAT:
disp_nation_chat(refreshFlag);
break;
case NATION_REPORT_TALK_LOG:
disp_talk_msg_sent(refreshFlag);
break;
case NATION_REPORT_DEBUG:
disp_debug_info();
break;
}
}
//----------- End of static function disp_detail -----------//
//--------- Begin of static function detect_detail ---------//
//
static void detect_detail()
{
switch( info.nation_report_mode )
{
case NATION_REPORT_INFO:
detect_nation_info();
break;
case NATION_REPORT_TALK:
detect_nation_talk();
break;
case NATION_REPORT_CHAT:
detect_nation_chat();
break;
case NATION_REPORT_TALK_LOG:
if( browse_talk_msg.detect() )
info.browse_talk_msg_recno = browse_talk_msg.recno();
break;
}
}
//----------- End of static function detect_detail -----------//
//--------- Begin of static function disp_nation_info ---------//
//
static void disp_nation_info()
{
vga.d3_panel_down( REPORT_DET_X1, REPORT_DET_Y1, REPORT_DET_X2, REPORT_DET_Y2 );
//----------- display info ------------//
int nationRecno = nation_filter(browse_nation.recno());
Nation* nationPtr = nation_array[nationRecno];
Nation* viewingNation = nation_array[info.viewing_nation_recno];
NationRelation* nationRelation = viewingNation->get_relation(nationRecno);
int x1=REPORT_DET_X1+6, x2=REPORT_DET_X1+340, x3=REPORT_DET_X2-10;
int y=REPORT_DET_Y1+6;
//-------- display economic data ----------//
String str;
if( nationRecno == info.viewing_nation_recno )
{
font_san.put_field( x1, y, "Your Food", x2, nationPtr->food_str() );
str = "$";
str += nationPtr->cash_str();
font_san.put_field( x1, y+=16, "Your Treasure", x2, str );
font_san.field( x1, y+=16, "Your Continuous Peace Time", x2, nationPtr->peace_duration_str(), x3, INFO_REPAINT, "PEACE" );
}
else
{
str = translate.process("Your Yearly Import from ");
str += nationPtr->nation_name();
font_san.field( x1, y , str, x2, (int) viewingNation->get_relation(nationRecno)->import_365days(IMPORT_TOTAL), 2, x3, INFO_REPAINT, "IMPORT" );
str = translate.process("Your Yearly Export to ");
str += nationPtr->nation_name();
font_san.field( x1, y+=16, str, x2, (int) nationPtr->get_relation(info.viewing_nation_recno)->import_365days(IMPORT_TOTAL), 2, x3, INFO_REPAINT, "EXPORT" );
str = translate.process("Continuous Peace Time of ");
str += nationPtr->nation_name();
font_san.field( x1, y+=16, str, x2, nationPtr->peace_duration_str(), x3, INFO_REPAINT, "PEACE" );
//--------- duration of current status ----------//
#if(defined(SPANISH))
str = "Duración del estado de ";
str += translate.process(nationRelation->status_str());
#elif(defined(FRENCH))
str = "Duration of ";
str += nationRelation->status_str();
str += " Status";
str = translate.process(str);
#else
// GERMAN and US
str = translate.process("Duration of ");
str += translate.process(nationRelation->status_str());
str += " Status";
#endif
font_san.field( x1, y+=16, str, x2, nationRelation->status_duration_str(), x3, INFO_REPAINT, "STATTIME" );
//------- display the allow_attack field --------//
#if(defined(SPANISH))
// str = "Permitir que tus Unidades ataquen al ";
str = "Permitir atacar al ";
str += nationPtr->nation_name();
#elif(defined(FRENCH))
str = "Autoriser attaque contre le ";
str += nationPtr->nation_name();
#elif(defined(GERMAN))
str = "Angriffe auf ";
str += nationPtr->nation_name();
str += " erlauben";
#else
str = "Allow Your Units to Attack ";
str += nationPtr->nation_name();
#endif
font_san.field( x1, y+=16, str, x2, "", x3, INFO_REPAINT, "ALLOWATK" );
button_allow_attack[1].create_text( x2+6 , y, x2+50 , y+15, "Yes" );
button_allow_attack[0].create_text( x2+54, y, x2+100, y+15, "No" );
button_allow_attack.paint( viewingNation->get_relation(nationRecno)->should_attack );
//---- if this nation is our ally, display its cash and food ----//
if( viewingNation->get_relation(nationRecno)->status == NATION_ALLIANCE )
{
#if(defined(SPANISH))
str = "Tesoro del ";
str += nationPtr->nation_name();
#elif(defined(FRENCH))
str = "Trésor du ";
str += nationPtr->nation_name();
#else
// GERMAN and US
str = nationPtr->nation_name();
str += " 's Treasure";
#endif
font_san.field( x1, y+=16, str, x2, nationPtr->cash, 2, x3, INFO_REPAINT );
#if(defined(SPANISH))
str = "Alimentos del ";
str += nationPtr->nation_name();
#elif(defined(FRENCH))
str = "Réserves de nourriture du ";
str += nationPtr->nation_name();
#else
// GERMAN and US
str = nationPtr->nation_name();
str += " 's Food";
#endif
font_san.field( x1, y+=16, str, x2, nationPtr->food, 2, x3, INFO_REPAINT );
}
}
y+=26;
//----- display its relation status with other nations -----//
if( info.viewing_nation_recno != nationRecno )
{
String str;
#if(defined(SPANISH))
str = "Estado Diplomático del ";
str += nationPtr->nation_name();
str += " con otros Reinos:";
#elif(defined(FRENCH))
str = "Relations diplomatiques de ";
str += nationPtr->nation_name();
str += " avec les autres royaumes:";
#else
// GERMAN and US
str = nationPtr->nation_name();
str += "'s ";
str += translate.process( "Diplomatic Status with Other Kingdoms:" );
#endif
nationPtr->disp_nation_color(x1, y+1);
font_san.put(x1+20, y, str);
y+=20;
for( int i=1 ; i<=nation_array.size() ; i++ )
{
if( nation_array.is_deleted(i) ||
i == nationRecno ||
i == info.viewing_nation_recno )
{
continue;
}
nation_array[i]->disp_nation_color(x1, y+1);
font_san.put( x1+20, y, nation_array[i]->nation_name() );
font_san.put( x1+240, y, nationPtr->get_relation(i)->status_str() );
if( nationPtr->get_relation(i)->trade_treaty )
{
font_san.put( x1+330, y, "Trade Treaty" );
#if(defined(FRENCH))
font_san.put( x1+460, y, m.format((int)nationPtr->total_year_trade(i),2) );
#else
// German and US
font_san.put( x1+450, y, m.format((int)nationPtr->total_year_trade(i),2) );
#endif
}
if( config.show_ai_info )
{
font_san.put( x1+500, y, nationPtr->get_relation(i)->ai_relation_level );
font_san.put( x1+530, y, (int) nationPtr->get_relation(i)->good_relation_duration_rating );
}
y+=16;
}
}
}
//----------- End of static function disp_nation_info -----------//
//--------- Begin of static function detect_nation_info ---------//
//
static void detect_nation_info()
{
int nationRecno = nation_filter(browse_nation.recno());
Nation* viewingNation = nation_array[info.viewing_nation_recno];
if( button_allow_attack.detect() >= 0 )
viewingNation->set_relation_should_attack(nationRecno, button_allow_attack.button_pressed, COMMAND_PLAYER);
}
//----------- End of static function detect_nation_info -----------//
//--------- Begin of static function disp_debug_info ---------//
//
static void disp_debug_info()
{
vga.d3_panel_down( REPORT_DET_X1, REPORT_DET_Y1, REPORT_DET_X2, REPORT_DET_Y2 );
//----------- display info ------------//
int nationRecno = nation_filter(browse_nation.recno());
Nation* nationPtr = nation_array[nationRecno];
int x1=REPORT_DET_X1+6, x2=REPORT_DET_X1+160;
int y=REPORT_DET_Y1+6;
int refreshFlag = INFO_REPAINT;
//------------ display AI info ----------//
font_san.put_field( x1, y , "Food ", x2, nationPtr->food_str() );
font_san.put_field( x1, y+=16, "Treasure", x2, nationPtr->cash_str() );
font_san.put_field( x1, y+=16, "ai_capture_enemy_town_recno", x2, nationPtr->ai_capture_enemy_town_recno, 1 );
font_san.put_field( x1, y+=16, "Surplus supply rating", x2, nationPtr->surplus_supply_rating() );
y+=48;
//--------- display AI preference ----------//
x2 += 60;
font_san.put_field( x1, y+=16, "Unit Chase Distance" , x2, nationPtr->pref_unit_chase_distance , 1 );
font_san.put_field( x1, y+=16, "Military Development" , x2, nationPtr->pref_military_development , 1 );
font_san.put_field( x1, y+=16, "Economic Development" , x2, nationPtr->pref_economic_development , 1 );
font_san.put_field( x1, y+=16, "Increase Pop by Capture" , x2, nationPtr->pref_inc_pop_by_capture , 1 );
font_san.put_field( x1, y+=16, "Increase Pop by Growth" , x2, nationPtr->pref_inc_pop_by_growth , 1 );
font_san.put_field( x1, y+=16, "Peacefulness" , x2, nationPtr->pref_peacefulness , 1 );
font_san.put_field( x1, y+=16, "Military Courage" , x2, nationPtr->pref_military_courage , 1 );
font_san.put_field( x1, y+=16, "Territorial Cohesiveness", x2, nationPtr->pref_territorial_cohesiveness, 1 );
font_san.put_field( x1, y+=16, "Trading Tendency" , x2, nationPtr->pref_trading_tendency , 1 );
x1 += (REPORT_DET_X2-REPORT_DET_X1)/2;
x2 += (REPORT_DET_X2-REPORT_DET_X1)/2;
y=REPORT_DET_Y1+6;
font_san.put_field( x1, y , "Allying Tendency" , x2, nationPtr->pref_allying_tendency , 1 );
font_san.put_field( x1, y+=16, "Honesty" , x2, nationPtr->pref_honesty , 1 );
font_san.put_field( x1, y+=16, "Town Harmony" , x2, nationPtr->pref_town_harmony , 1 );
font_san.put_field( x1, y+=16, "Citizen Loyalty Concern" , x2, nationPtr->pref_loyalty_concern , 1 );
font_san.put_field( x1, y+=16, "Forgiveness" , x2, nationPtr->pref_forgiveness , 1 );
font_san.put_field( x1, y+=16, "Collect Tax Tendency" , x2, nationPtr->pref_collect_tax , 1 );
font_san.put_field( x1, y+=16, "Build Inn Tendency" , x2, nationPtr->pref_hire_unit , 1 );
font_san.put_field( x1, y+=16, "Use Weapon Tendency" , x2, nationPtr->pref_use_weapon , 1 );
font_san.put_field( x1, y+=16, "Keep Generals Tendency" , x2, nationPtr->pref_keep_general , 1 );
font_san.put_field( x1, y+=16, "Keep Skilled Units Tendency", x2, nationPtr->pref_keep_skilled_unit , 1 );
font_san.put_field( x1, y+=16, "Attack Monster" , x2, nationPtr->pref_attack_monster , 1 );
font_san.put_field( x1, y+=16, "Use Spies" , x2, nationPtr->pref_spy , 1 );
font_san.put_field( x1, y+=16, "Use Counter Spies" , x2, nationPtr->pref_counter_spy , 1 );
font_san.put_field( x1, y+=16, "Food Reserve" , x2, nationPtr->pref_food_reserve , 1 );
font_san.put_field( x1, y+=16, "Cash Reserve" , x2, nationPtr->pref_cash_reserve , 1 );
font_san.put_field( x1, y+=16, "Use Marine" , x2, nationPtr->pref_use_marine , 1 );
}
//----------- End of static function disp_debug_info -----------//
//--------- Begin of static function disp_nation_talk ---------//
//
static void disp_nation_talk()
{
int nationRecno = nation_filter(info.browse_nation_recno);
//----- if the selected nation is the viewing nation ----//
if( nationRecno != info.viewing_nation_recno &&
info.viewing_nation_recno == nation_array.player_recno )
{
vga.d3_panel_down( REPORT_DET_X1, REPORT_DET_Y1, REPORT_DET_X2, REPORT_TALK_Y2 );
if( info.last_talk_nation_recno != nationRecno && !info.player_reply_mode )
talk_res.init_conversion(nationRecno);
info.player_reply_mode = 0;
info.last_talk_nation_recno = nationRecno;
talk_res.disp_talk();
}
}
//----------- End of static function disp_nation_talk -----------//
//--------- Begin of static function detect_nation_talk ---------//
//
static void detect_nation_talk()
{
int nationRecno = nation_filter(info.browse_nation_recno);
//----- if the selected nation is the viewing nation ----//
if( nationRecno != info.viewing_nation_recno &&
info.viewing_nation_recno == nation_array.player_recno )
{
talk_res.detect_talk();
}
}
//----------- End of static function detect_nation_talk -----------//
//--------- Begin of static function disp_talk_msg_sent ---------//
//
static void disp_talk_msg_sent(int refreshFlag)
{
//--- filter out talk messages sent by this nation and sort them by date ---//
TalkMsg* talkMsg;
TalkMsgDisp talkMsgDisp;
static short lastNationRecno=0;
int nationRecno = nation_filter(info.browse_nation_recno);
if( lastNationRecno != nationRecno )
{
info.browse_talk_msg_recno = 1; // reset the browser recno of the viewing nation has been changed
lastNationRecno = nationRecno;
}
//--------------------------------------------//
info.talk_msg_disp_array.zap();
for( short i=1 ; i<=talk_res.talk_msg_count() ; i++ )
{
if( talk_res.is_talk_msg_deleted(i) )
continue;
talkMsg = talk_res.get_talk_msg(i);
if( !talkMsg->is_valid_to_disp() ) // don't link it out, otherwise it may cause multiplayer sync problem.
continue;
if( talkMsg->from_nation_recno == nationRecno ||
talkMsg->to_nation_recno == nationRecno )
{
if( talkMsg->from_nation_recno == info.viewing_nation_recno ||
talkMsg->to_nation_recno == info.viewing_nation_recno )
{
if( !nation_array.is_deleted(talkMsg->from_nation_recno) &&
!nation_array.is_deleted(talkMsg->to_nation_recno) )
{
talkMsgDisp.recno = i;
talkMsgDisp.date = talkMsg->date;
talkMsgDisp.is_reply = 0;
info.talk_msg_disp_array.linkin(&talkMsgDisp);
if( talkMsg->reply_date )
{
talkMsgDisp.recno = i;
talkMsgDisp.date = talkMsg->reply_date;
talkMsgDisp.is_reply = 1;
info.talk_msg_disp_array.linkin(&talkMsgDisp);
}
}
}
}
}
if( info.talk_msg_disp_array.size() > 0 )
info.talk_msg_disp_array.quick_sort(sort_talk_msg);
//----- display a browser of the talk msg sent -----//
if( refreshFlag == INFO_REPAINT || !browse_talk_msg.init_flag )
{
browse_talk_msg.init( REPORT_DET_X1, REPORT_DET_Y1, REPORT_DET_X2, REPORT_DET_Y2,
0, 30, info.talk_msg_disp_array.size(), put_talk_msg_rec, 1 );
browse_talk_msg.open(info.browse_talk_msg_recno);
}
else
{
browse_talk_msg.paint();
browse_talk_msg.open(info.browse_talk_msg_recno, info.talk_msg_disp_array.size());
}
info.browse_talk_msg_recno = browse_talk_msg.recno();
}
//----------- End of static function disp_talk_msg_sent -----------//
//------ Begin of function sort_talk_msg ------//
//
static int sort_talk_msg( const void *a, const void *b )
{
if( ((TalkMsgDisp*)b)->recno == ((TalkMsgDisp*)a)->recno )
return ((TalkMsgDisp*)b)->is_reply ? 1 : -1;
return ((TalkMsgDisp*)b)->date - ((TalkMsgDisp*)a)->date;
}
//------- End of function sort_talk_msg ------//
//-------- Begin of static function put_talk_msg_rec --------//
//
static void put_talk_msg_rec(int recNo, int x1, int y, int refreshFlag)
{
TalkMsgDisp* talkMsgDisp = (TalkMsgDisp*) info.talk_msg_disp_array.get(recNo);
TalkMsg* talkMsg = talk_res.get_talk_msg(talkMsgDisp->recno);
int x=x1, isTo;
x+=3;
y+=2;
if( !talkMsgDisp->is_reply ) // if not a replying message
isTo = talkMsg->from_nation_recno == info.viewing_nation_recno; // you send a message to a nation
else
isTo = talkMsg->from_nation_recno != info.viewing_nation_recno;
//---------------------------------------//
char* str1;
if( isTo )
str1 = translate.process("To");
else
str1 = translate.process("From");
font_san.put( x , y, str1 );
x += font_san.text_width(str1)+5;
//---------------------------------------//
if( talkMsg->from_nation_recno == info.viewing_nation_recno )
nation_array[talkMsg->to_nation_recno]->disp_nation_color(x, y+2);
else
nation_array[talkMsg->from_nation_recno]->disp_nation_color(x, y+2);
x+=18;
String str;
str = translate.process("on ");
if( talkMsgDisp->is_reply )
str += date.date_str(talkMsg->reply_date);
else
str += date.date_str(talkMsg->date);
str += " :";
font_san.put( x , y, str );
font_san.put( x1, y+13, talkMsg->msg_str(info.viewing_nation_recno, talkMsgDisp->is_reply), 0, browse_talk_msg.ix2 );
}
//----------- End of static function put_talk_msg_rec -----------//
//--------- Begin of static function disp_nation_chat ---------//
//
static void disp_nation_chat(int refreshFlag)
{
int nationRecno = nation_filter(info.browse_nation_recno);
//----- if the selected nation is the viewing nation ----//
if( !(sys.debug_session || nation_array[nationRecno]->nation_type == NATION_REMOTE &&
info.viewing_nation_recno == nation_array.player_recno ) )
{
return;
}
//-------- display the chat get control -------//
vga.d3_panel_down( REPORT_DET_X1, REPORT_DET_Y1, REPORT_DET_X2, REPORT_TALK_Y2 );
font_san.put( REPORT_DET_X1+10, REPORT_DET_Y1+10,
"Please enter your chat message and press <Enter> to send." );
// ###### begin Gilbert 15/10 #######//
if( !init_get_chat )
{
get_chat.init( REPORT_DET_X1+10, REPORT_DET_Y1+30, REPORT_DET_X2-10,
info.player_chat_str, CHAT_STR_LEN, &font_san, 0, 0 );
get_chat.clear();
init_get_chat = 1;
}
// ###### end Gilbert 15/10 #######//
int vgaUseBack = vga.use_back_buf;
vga.use_back();
get_chat.paint(1); // 1-paint cursor
if( !vgaUseBack )
vga.use_front();
//-------- display receiver type buttons ---------//
int y=REPORT_TALK_Y2-70;
for( int i=1 ; i<=MAX_CHAT_RECEIVER_TYPE ; i++, y+=22 )
{
if( info.chat_receiver_type == i )
vga.d3_panel_down( REPORT_DET_X1+10, y, REPORT_DET_X2-10, y+20 );
else
vga.d3_panel_up( REPORT_DET_X1+10, y, REPORT_DET_X2-10, y+20 );
font_san.center_put( REPORT_DET_X1+10, y, REPORT_DET_X2-10, y+20, chat_receiver_str_array[i-1] );
}
}
//----------- End of static function disp_nation_chat -----------//
//--------- Begin of static function detect_nation_chat ---------//
//
static void detect_nation_chat()
{
int nationRecno = nation_filter(info.browse_nation_recno);
//----- if the selected nation is the viewing nation ----//
if( sys.debug_session || nation_array[nationRecno]->nation_type == NATION_REMOTE &&