-
-
Notifications
You must be signed in to change notification settings - Fork 999
/
sraf_computer.cpp
5260 lines (4316 loc) · 141 KB
/
sraf_computer.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
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 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/>.
*
*/
#include "bagel/spacebar/sraf_computer.h"
#include "bagel/spacebar/sraf_msg.h"
#include "bagel/spacebar/sraf_file.h"
#include "bagel/boflib/app.h"
#include "bagel/baglib/bagel.h"
#include "bagel/boflib/sound.h"
#include "bagel/baglib/link_object.h"
#include "bagel/bagel.h"
#include "bagel/boflib/file_functions.h"
#include "bagel/boflib/std_keys.h"
namespace Bagel {
namespace SpaceBar {
#define SRAF_DIR "$SBARDIR\\SRAFFA\\CLOSEUP\\COMPUTER\\"
#define SRAF_MALE_DIR "$SBARDIR\\SRAFFA\\CHAR\\GMALE\\"
#define SRAF_FEMALE_DIR "$SBARDIR\\SRAFFA\\CHAR\\GFEMALE\\"
#define SRAF_AUDIO_DIR "$SBARDIR\\SRAFFA\\AUDIO\\EVENTS\\"
#define SRAF_TIMEOUT "SFTIMOUT.WAV"
#define USE_TEXT_WIDTHS true
// Local constants
//
// Deal summary constants
#define kUnknownTermStr "(Unknown)"
#define kRightColumnAlign 25
// Sraffan flashback max turns...
#define kSrafMaxTurns 200
// Amount of time to figure out who is driving...
#define kDrivingTime 5
// Constants not linked to any one screen
#define kCheckmark 'x'
#define kStandardIndentation 4
#define kStandardDoubleIndentation 8
// Buyer bids summary
#define kFirstMineralColumn 12
#define kBuyerBidsPointSize 14
#define kOtherPointSize 13
#define kMineralColWidth 4
#define kBuyerBidsPointWidth 6
#define kLineItemHeight kBuyerBidsPointSize + 4
// Add instructions to the main screen
#define kactivateFooterStr1 "NOTE: On any subsequent screens where the information displayed does"
#define kactivateFooterStr2 "not fit on the screen, scroll up or down one line using up-arrow and"
#define kactivateFooterStr3 "down-arrow. Scroll up or down a page using page-up or page-down."
#define kBuyerBidsHeaderStr "BUYER Zn Ba Rg Ut Pn Sz 0 H20 LH CH ME TE AS PD ACCEPT"
#define kBuyerBidsMessage1 "Click on any buyer to see their biography. Click in the 'ACCEPT' column "
#define kBuyerBidsMessage2 "to incorporate that buyer into the current offer."
// EMail constants
#define kEmailHeaderStr "SUBJECT FROM TO"
#define kMessageFromColumn 25
#define kMessageToColumn 48
// Audio constants
#define kAudioHeaderStr "TITLE AUTHOR PLANET"
#define kAudioAuthorCol 32
#define kAudioPlanetCol 53
// Robobutler constants
#define kRobobutlerHeaderStr " TODAY'S SPECIAL OFFERINGS"
#define kRobobutlerCol 20
// Check teams constants
#define kCheckTeamHeaderStr1 "MEETING DISPATCH YOUR STAFF ATTENDING MEETING"
#define kCheckTeamHeaderStr2 "WITH TIME"
// 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
#define kCheckTeamTimeCol 18
#define kCheckTeamStaffCol 28
#define kCheckDispatchTeamFooter1 "To check the status of a meeting, click in the 'MEETING WITH' column"
#define kCheckDispatchTeamFooter2 "on the same line as the meeting attendees."
// Staffer constants
#define kMaxStafferNameLen 9
// Dispatch negotiating team constants
#define kDispatchHeaderStr "MEET WITH: TEAM TO INCLUDE: AVAILABLE INCLUDE ON TEAM"
#define kMeetTitleColumn 5
#define kMeetSubColumn 9
#define kTeamMemberColumn 36
#define kTeamAvailableColumn 56
#define kTeamIncludeColumn 73
#define kDispatchFooterStr1 "To meet with an individual, click in the 'MEET WITH' column to the"
#define kDispatchFooterStr2 "left of the name. To read an individual's biography, click on that"
#define kDispatchFooterStr3 "individual's name. To include a staff member on the negotiating "
#define kDispatchFooterStr4 "team, click in the 'INCLUDE ON TEAM' column. Click on 'Dispatch "
#define kDispatchFooterStr5 "Team' when the negotiating team is fully assembled."
// Code word constants
#define kCodeWordsHeader1 "Your offer was accepted by the sellers! Please choose a code name"
#define kCodeWordsHeader2 "for the deal by selecting one word from each group."
#define kCodeWordsHeader3 " ***GROUP ONE*** ***GROUP TWO***"
// 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
#define kGroup1Col2 15
#define kGroup2Col1 45
#define kGroup2Col2 60
// Have to know some mineral constants in the grid
enum {
ZINC = 0,
BARIUM,
RIGELLIUM,
UPTITE,
PLATINUM,
SANZIUM,
OXYGEN,
WATER,
LUMBER,
CROP,
MEDICINE,
TURF,
STRUCTURE,
POLLUTION,
WEAPONS
};
// Main menu items
enum {
DEALSUMMARY = 0,
BUYERBIDS,
DEALBACKGROUND,
SELLERBIOS,
OTHERBIOS,
STAFFBIOS,
DISPATCHTEAM,
CURRENTEMAIL,
AUDIOSETTINGS,
ROBOBUTLER,
CHECKTEAMS
};
// Local structs
struct ST_BUTTONS {
const char *_pszName;
const char *_pszUp;
const char *_pszDown;
const char *_pszFocus;
const char *_pszDisabled;
int _nLeft;
int _nTop;
int _nWidth;
int _nHeight;
int _nID;
};
#define SRAF_NO_MEETING 0
#define SRAF_GOOD_MEETING 1
#define SRAF_BAD_MEETING 2
struct SELLERITEM {
const char *_pszName;
int16 _nAmount;
SELLERS _nSellerID;
const char *_pszSellerBio;
bool _bMeetWith;
bool _bAvailable;
int16 _nMeetingResult;
};
// Struct for email messages
struct EMAILITEM {
const char *_pszMessageSubj;
const char *_pszMessageFrom;
const char *_pszMessageTo;
const char *_pszMessageFile;
};
// Struct for buyer bids grid
struct BUYERBIDSREC {
const char *_pszName;
int16 _nMineralVal[NUM_MINERALS];
int16 _nBidSum;
bool _bAccept;
BUYERS _nBuyerID;
const char *_pszBuyerBio;
bool _bMeetWith;
bool _bAvailable;
int16 _nFlags;
int16 _nMeetingResult;
};
// Mineral information
struct MINERAL_NAMES {
const char *_pszMineralName;
const char *_pszMineralAbbrev;
};
// Staffer bio information
struct STAFFERITEM {
const char *_pszStafferName;
const char *_pszStafferBio;
const char *_pszStafferBmp;
bool _bAvailable;
bool _bOnCurrentTeam;
int _nFlags;
int _nNegotiatingStrength;
int _nMeetingTime;
};
// Staffer bio information
struct OTHERITEM {
const char *_pszName;
const char *_pszOtherPartyBio;
bool _bMeetWith;
bool _bAvailable;
int16 _nPaymentAmount;
int16 _nMeetingResult;
};
struct AUDIOITEM {
const char *_pszTitle;
const char *_pszAuthor;
const char *_pszPlanet;
const char *_pszAudioFile;
CBofSound *_pMidiTrack;
};
#define kRandomPlayTime 15
struct OFFERINGITEM {
const char *_pszType;
const char *_pszOffering;
const char *_pszFile;
const char *_pszRcvOfferingFile;
};
// Codewords
struct CODEWORDITEM {
const char *_pszCodeWord1;
const char *_pszCodeWord2;
const char *_pszCodeWord3;
const char *_pszCodeWord4;
};
// Local globals
//
// there are 6 regular staffers, but durteen, the 7th, is the one that notifies deven that
// time has run out... we need room in the structure for him also, although he won't be
// doing any negotiating or meetings for us.
static STAFFERITEM g_staffers[NUM_STAFFERS + 1] = {
{ "Norg-72", "nor72bio.txt", "sanenorg.bmp", true, false, mStafferMale, 1, 30 },
{ "Pnurth-81", "Pnu81bio.txt", "sanepnur.bmp", true, false, mStafferFemale, 3, 30 },
{ "Zig-64", "Zig64bio.txt", "sanezig.bmp", true, false, mStafferFemale, 6, 18 },
{ "Lentil-24", "Len24bio.txt", "sanelent.bmp", true, false, mStafferFemale, 5, 15 },
{ "Vargas-20", "Var20bio.txt", "sanevarg.bmp", true, false, mStafferMale, 10, 25 },
{ "Churg-53", "Chu53bio.txt", "sanechur.bmp", true, false, mStafferMale, 5, 22 },
{ "Durteen-97", "DUR97bio.txt", "sanedurt.bmp", true, false, mStafferMale, 0, 0 },
};
static const char *g_stMainItems[NUM_MAIN_ITEMS] = {
"* Deal Summary",
"* Buyer Bids and Biographies",
"* Deal Background Data",
"* Seller Biographies",
"* Biographies of Other Parties",
"* Staff Biographies",
"* Dispatch Negotiating Team",
"* Current E-Mail",
"* Household Audio",
"* Robobutler Service",
"* Status of Negotiations"
};
static SELLERITEM g_stSellerNames[NUM_SELLERS] = {
{ "Irk-4", -1, IRK4, "IRK4BIO.TXT", false, true, SRAF_NO_MEETING },
{ "Yeef-8", 38, YEEF8, "YEE8BIO.TXT", false, true, SRAF_NO_MEETING },
{ "Quosh-23", -1, QUOSH23, "QUO11BIO.TXT", false, true, SRAF_NO_MEETING },
};
// Yeef can be talked down!
#define kYeefTalkedDownAmount 33
#define mBuyerMale 0x0001
#define mBuyerFemale 0x0002
// Can talk these buyers up... here are there amounts.
#define kSinjinTalkedUpAmount 7
#define kSinjinMineralID STRUCTURE
#define kGungTalkedUpAmount 8
#define kGungMineralID BARIUM
#define kDorkTalkedUpAmount 8
#define kDorkMineralID UPTITE
#define kGildTalkedUpAmount1 11
#define kGildTalkedUpAmount2 8
#define kGildMineralID1 ZINC
#define kGildMineralID2 PLATINUM
#define MIN_MART_ENTRIES 6
// Buyer bids grid, dork, gung sinjin and gild can be talked up, but the
// rest of them are non-negotiable. Only dork and gung are part of the
// final solution.
static BUYERBIDSREC g_stBuyerBids[NUM_BUYERS] = {
{ "Pylon-3", { 0, 0, 0, 0, 0, 0, 7, 9, 2, 3, 4, 8, 0, 0 }, 33, false, PYLON3, "PYL3BIO.TXT", false, true, mBuyerFemale, SRAF_NO_MEETING },
{ "Dippik-10", { 0, 0, 0, 0, 0, 0, 5, 4, 0, 0, 0, 0, 6, 8 }, 23, false, DIPPIK10, "DIP10BIO.TXT", false, true, mBuyerMale, SRAF_NO_MEETING },
{ "Vebbil-18", { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0 }, 7, false, VEBBIL18, "VEB18BIO.TXT", false, true, mBuyerFemale, SRAF_NO_MEETING },
{ "Gung-14", { 0, 4, 2, 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0 }, 16, false, GUNG14, "GUN14BIO.TXT", false, true, mBuyerMale, SRAF_NO_MEETING },
{ "Reyes-24", { 10, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 17, false, REYES24, "REY24BIO.TXT", false, true, mBuyerMale, SRAF_NO_MEETING },
{ "Gild-13", { 6, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 10, false, GILD13, "GIL13BIO.TXT", false, true, mBuyerFemale, SRAF_NO_MEETING },
{ "Hem-20", { 0, 0, 3, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 8, false, HEM20, "HEM20BIO.TXT", false, true, mBuyerFemale, SRAF_NO_MEETING },
{ "Dork-44", { 0, 6, 0, 4, 0, 11, 0, 0, 0, 0, 0, 0, 0, 0 }, 21, false, DORK44, "DOR44BIO.TXT", false, true, mBuyerMale, SRAF_NO_MEETING },
{ "Rawley-23", { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0 }, 8, false, RAWLEY23, "RAW23BIO.TXT", false, true, mBuyerFemale, SRAF_NO_MEETING },
{ "Jella-37", { 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0 }, 4, false, JELLA37, "JEL37BIO.TXT", false, true, mBuyerFemale, SRAF_NO_MEETING },
{ "Sinjin-11", { 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 0, 0, 5, 6 }, 23, false, SINJIN11, "SIN11BIO.TXT", false, true, mBuyerMale, SRAF_NO_MEETING },
{ "Hundey-42", { 0, 0, 4, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 6 }, 13, false, HUNDEY42, "HUN42BIO.TXT", false, true, mBuyerMale, SRAF_NO_MEETING },
{ "Chandra-15", { 0, 0, 0, 0, 0, 0, 0, 13, 0, 2, 4, 0, 0, 0 }, 19, false, CHANDRA15, "CHA15BIO.TXT", false, true, mBuyerFemale, SRAF_NO_MEETING },
{ "Clang-2", { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9 }, 9, false, CLANG2, "CLA2BIO.TXT", false, true, mBuyerMale, SRAF_NO_MEETING },
{ "Min. Mart", { 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 4, false, MINMARTZN, "MINBIO.TXT", false, true, 0, SRAF_NO_MEETING },
{ "Min. Mart", { 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 3, false, MINMARTBA, "MINBIO.TXT", false, true, 0, SRAF_NO_MEETING },
{ "Min. Mart", { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 1, false, MINMARTRG, "MINBIO.TXT", false, true, 0, SRAF_NO_MEETING },
{ "Min. Mart", { 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 3, false, MINMARTUT, "MINBIO.TXT", false, true, 0, SRAF_NO_MEETING },
{ "Min. Mart", { 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 3, false, MINMARTPN, "MINBIO.TXT", false, true, 0, SRAF_NO_MEETING },
{ "Min. Mart", { 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0 }, 7, false, MINMARTSZ, "MINBIO.TXT", false, true, 0, SRAF_NO_MEETING },
};
static MINERAL_NAMES g_stMinerals[NUM_MINERALS] = {
{ "Zinc Mining Rights", "Zn" },
{ "Barium Mining Rights", "Ba" },
{ "Rigellium Mining Rights", "Rg" },
{ "Uptite Mining Rights", "Ut" },
{ "Pandemonium Mining Rights", "Pn" },
{ "Sanzium Mining Rights", "Sz" },
{ "Oxygen Mining Rights", "O" },
{ "Water Extraction Rights", "H2O" },
{ "Lumber Harvesting Rights", "LH" },
{ "Crop Harvesting Rights", "CH" },
{ "Medicine Extraction Rights", "ME" },
{ "Turf Extraction Rights", "TE" },
{ "Artificial Structure Ownership and Removal Rights", "AS" },
{ "Exclusive Pollution Dumping Rights", "PD" },
};
static EMAILITEM g_stEmailMessages[NUM_MAIL_MESSAGES] = {
{ "Armpit III", "Irk-4", "Deven-7", "SRAMAIL1.TXT" },
{ "Pool", "Devo-185", "Deven-7", "SRAMAIL2.TXT" },
{ "Rumor", "Durteen-97", "Deven-7", "SRAMAIL3.TXT" },
{ "Mona Lisa", "Fezint-40", "Deven-7", "SRAMAIL4.TXT" },
{ "A Special Offer", "Acme Upholstery Corp", "Deven-7", "SRAMAIL5.TXT" },
{ "Swonza-5", "Churg-53", "Deven-7", "SRAMAIL6.TXT" },
{ "Pinna-6C", "Chippik-9", "Deven-7", "SRAMAIL7.TXT" },
{ "Armpit III", "Yeef-8", "Deven-7", "SRAMAIL8.TXT" },
};
enum OTHERPARTYS {
SWONZA5 = 0, POLITICIANS, ENVIRONMENTALISTS
};
static OTHERITEM g_stOtherPartys[NUM_OTHER_PARTYS] = {
{ "Swonza-5", "SWO5BIO.TXT", false, true, -1, SRAF_NO_MEETING },
{ "Politicians", "POLITBIO.TXT", false, true, -30, SRAF_NO_MEETING },
{ "Environmentalists", "ENVIRBIO.TXT", false, true, -1, SRAF_NO_MEETING },
};
// Sraffin computer buttons
#define ON_BUTTON 0
#define OFF_BUTTON 1
#define QUIT_BUTTON 2
#define RETURN_TO_MAIN_BUTTON 3
#define SUBMIT_BUTTON 4
#define DISPLAY_KEY_BUTTON 5
#define DISPATCH_TEAM_BUTTON 6
#define NO_MUSIC_BUTTON 7
#define DONE_BUTTON 8
#define ORDER_BEVERAGE_BUTTON 9
#define ORDER_SNACK_BUTTON 10
// Define our buttons to go on the bottom of the main screen
static ST_BUTTONS g_stButtons[NUM_SRAFCOMPBUTT] = {
{ "On", "onup.bmp", "ondn.bmp", "onup.bmp", "onup.bmp", 20, 445, 200, 30, ON_BUTTON },
{ "Off", "offup.bmp", "offdn.bmp", "offup.bmp", "offup.bmp", 20, 445, 200, 30, OFF_BUTTON },
{ "Quit", "quitup.bmp", "quitdn.bmp", "quitup.bmp", "quitup.bmp", 407, 445, 200, 30, QUIT_BUTTON },
{ "Return to Main", "mainup.bmp", "maindn.bmp", "mainup.bmp", "mainup.bmp", 430, 445, 200, 30, RETURN_TO_MAIN_BUTTON },
{ "Submit Offer", "offerup.bmp", "offerdn.bmp", "offerup.bmp", "offerup.bmp", 220, 445, 200, 30, SUBMIT_BUTTON },
{ "Display the Key", "keyup.bmp", "keydn.bmp", "keyup.bmp", "keyup.bmp", 220, 445, 200, 30, DISPLAY_KEY_BUTTON },
{ "Dispatch Team", "teamup.bmp", "teamdn.bmp", "teamup.bmp", "teamup.bmp", 220, 445, 200, 30, DISPATCH_TEAM_BUTTON },
{ "No Music", "musicup.bmp", "musicdn.bmp", "musicup.bmp", "musicup.bmp", 220, 445, 200, 30, NO_MUSIC_BUTTON },
{ "Done", "doneup.bmp", "donedn.bmp", "doneup.bmp", "doneup.bmp", 430, 445, 200, 30, DONE_BUTTON },
{ "Order Beverage", "bevup.bmp", "bevdn.bmp", "bevup.bmp", "bevup.bmp", 20, 445, 200, 30, ORDER_BEVERAGE_BUTTON },
{ "Order Snack", "snackup.bmp", "snackdn.bmp", "snackup.bmp", "snackup.bmp", 225, 445, 200, 30, ORDER_SNACK_BUTTON }
};
static AUDIOITEM g_audioTracks[NUM_MUSICAL_SCORES] = {
{ "Harpsichord Invention #1", "J. S. Bach", "Earth", "SRAFFAN1.MID", nullptr },
{ "Jazz Theme #44981", "Urgon-Thmo", "Thelbia", "SRAFFAN2.MID", nullptr },
{ "Bamboo Breeze", "H. Fugimachi", "Earth", "SRAFFAN3.MID", nullptr },
{ "Power of Crystal, OP. 12", "Brak-44", "H'poctyl", "SRAFFAN4.MID", nullptr },
{ "String Quartet", "J. Salesin", "Earth", "SRAFFAN5.MID", nullptr },
{ "The Womp Song", "The Womps", "Armpit IV", "SRAFFAN6.MID", nullptr },
{ "Mixed Selections", " ", " ", nullptr, nullptr },
};
static AUDIOITEM g_chickenDance = \
{ "Chicken Dance", "Unknown Origin", "Mars", "CHIKDANC.MID", nullptr };
// Pointers to the g_audioTracks entries. For the Mac, The Womp Song
// is replaced with the Chicken Dance
static AUDIOITEM *g_stAudioSetting[NUM_MUSICAL_SCORES] = {
&g_audioTracks[0],
&g_audioTracks[1],
&g_audioTracks[2],
&g_audioTracks[3],
&g_audioTracks[4],
&g_audioTracks[5],
&g_audioTracks[6]
};
static OFFERINGITEM g_stOfferings[NUM_OFFERINGS] = {
{ "BEVERAGE:", "Distilled Fleeblunx Sap", "BEVDESC.TXT", "DRINKRCV.TXT" },
{ "LIGHT SNACK:", "Br'thl'gian Centipede Legs", "SNKDESC.TXT", "SNACKRCV.TXT" }
};
// Codewords
static CODEWORDITEM g_stCodeWords[NUM_CODE_WORDS] = {
{ "ANGRY", "LUCKY", "BAGPIPE", "MOSS" },
{ "BRASS", "MELTED", "BANANA", "MUFFIN" },
{ "BURNT", "MOIST", "BANSHEE", "PAJAMAS" },
{ "DEAD", "NOISY", "BULLET", "PUCK" },
{ "ELVISH", "POINTY", "COOKIE", "SHRUB" },
{ "ENCRUSTED", "SIMPLE", "FRISBEE", "SWORD" },
{ "FUZZY", "SMOKY", "GALOSHES", "TORPEDO" },
{ "GIGGLING", "TWITCHING", "GUITAR", "TUNIC" },
{ "HUNGRY", "UNITED", "HYENA", "UMBRELLA" },
{ "HURLING", "VARNISHED", "LANTERN", "ZUCCHINI" }
};
static bool gTextScreenFrontmost = false;
static int gDispatchCurState = 0; // Retain current state of dispatch negotiating team screen
static int gTurncountLineNo = 0; // Keep track of turncount line number
// Member static initializations
bool SrafComputer::_bSwonzaEnlightened = false;
SrafComputer *SrafComputer::_pHead = nullptr; // Only sraffan computer
int SrafComputer::_nStartingTime = 0;
bool SrafComputer::_bRandomAudio = false;
int SrafComputer::_nRandomTime = 0;
bool SrafComputer::_bFailureNotified = false;
// States that the dispatch negotiating team can take on
#define mSellersExpanded 0x01
#define mBuyersExpanded 0x02
#define mOthersExpanded 0x04
CBofWindow *SrafTextScreen::_pSaveActiveWin = nullptr;
// Local prototype functions
const char *buildSrafDir(const char *pszFile);
const char *buildAudioDir(const char *pszFile);
const char *buildMaleSrafDir(const char *pszFile);
const char *buildFemaleSrafDir(const char *pszFile);
// Local prototypes
SrafComputer::SrafComputer() :
gCompDisplay(40, 40, 600, 440), gTextWindow(0, 0, 640 - 1, 480 - 1),
gStafferDisplay(0, 0, 640 - 1, 480 - 1), gSrafTextWindow(0, 440, 640 - 1, 480 - 1) {
int i;
_cTextColor = CTEXT_WHITE; // Start out with white as our text color
_cTextHiliteColor = RGB(255, 255, 255); // and some other color as our hilite
_cTextLineColor = CTEXT_YELLOW;
// Computer starts as off and at the main screen
_eMode = SC_OFF;
_eCurScreen = SC_MAIN;
// initialize our three buttons
for (i = 0; i < NUM_SRAFCOMPBUTT; i++) {
_pButtons[i] = nullptr;
}
// initialize bitmaps (one extra staffer, durteen)
for (i = 0; i < (NUM_STAFFERS + 1); i++) {
_pStafferBmp[i] = nullptr;
}
// List and text box
_pLBox = nullptr;
_pMainList = nullptr;
_nSelection = -1;
_nListPointSize = kOtherPointSize;
_nListItemHeight = 20;
// Subscreen initializations
_pSellerSummaryList = nullptr;
_pBuyerSummaryList = nullptr;
_pTeamList = nullptr;
// Text only screen initializations
_pTextOnlyScreen = nullptr;
_pszGroup1Word = nullptr;
_pszGroup2Word = nullptr;
_bSrafAttached = false;
_pHead = this;
}
// FYI: It only uses the seller summary list to build the onscreen
// list, we use the global to store intermediate data.
void SrafComputer::recalcSellerSummaryList() {
// initialize the initial state of the seller summary
if (_pSellerSummaryList == nullptr) {
_pSellerSummaryList = new CBofList<DealSummarySellerItem>;
assert(_pSellerSummaryList != nullptr);
} else {
delete _pSellerSummaryList;
_pSellerSummaryList = nullptr;
}
// Lets verify that its all set before we go to use it
if (_pSellerSummaryList == nullptr) {
_pSellerSummaryList = new CBofList<DealSummarySellerItem>;
assert(_pSellerSummaryList != nullptr);
}
int i = 0;
while (i < NUM_SELLERS) {
DealSummarySellerItem sellerItem;
sellerItem._eSellerID = g_stSellerNames[i]._nSellerID;
sellerItem._nSellerOffer = g_stSellerNames[i]._nAmount;
sellerItem._pSellerName = g_stSellerNames[i]._pszName;
_pSellerSummaryList->addToTail(sellerItem);
i++;
}
}
void SrafComputer::recalcBuyerSummaryList() {
// initialize the initial state of the deal summary
if (_pBuyerSummaryList == nullptr) {
_pBuyerSummaryList = new CBofList<DealSummaryBuyerItem>;
assert(_pBuyerSummaryList != nullptr);
} else {
delete _pBuyerSummaryList;
_pBuyerSummaryList = nullptr;
}
// Lets verify that its all set before we go to use it
if (_pBuyerSummaryList == nullptr) {
_pBuyerSummaryList = new CBofList<DealSummaryBuyerItem>;
assert(_pBuyerSummaryList != nullptr);
}
int i = 0;
while (i < NUM_BUYERS) {
if (g_stBuyerBids[i]._bAccept) {
DealSummaryBuyerItem *pBuyerItem = new DealSummaryBuyerItem();
assert(pBuyerItem != nullptr);
pBuyerItem->_eBuyerID = g_stBuyerBids[i]._nBuyerID;
pBuyerItem->_nBuyerOffer = g_stBuyerBids[i]._nBidSum;
pBuyerItem->_pBuyerName = g_stBuyerBids[i]._pszName;
_pBuyerSummaryList->addToTail(*pBuyerItem);
delete pBuyerItem;
}
i++;
}
}
bool SrafComputer::verifyDispatchTeam() {
bool bValidTeam = true;
char szFailureReason[256];
int nTeam = 0;
// Make sure that we have someone to meet
int nMeetOthers = getMeetMember(kOthersList);
int nMeetSellers = getMeetMember(kSellersList);
int nMeetBuyers = getMeetMember(kBuyersList);
if (nMeetOthers == -1 && nMeetSellers == -1 && nMeetBuyers == -1) {
bool bStafferSelected = false;
// Nobody to meet with, see if we have any team members selected.
// This changes the error message.
for (int i = 0; i < NUM_STAFFERS; i++) {
if (g_staffers[i]._bOnCurrentTeam) {
bStafferSelected = true;
break;
}
}
if (bStafferSelected == false) {
Common::strcpy_s(szFailureReason, kszNotEvenClose);
} else {
Common::strcpy_s(szFailureReason, kszNoNegotiators);
}
bValidTeam = false;
}
if (bValidTeam) {
if ((nMeetOthers != -1 && nMeetSellers != -1 && nMeetBuyers != -1)) {
Common::sprintf_s(szFailureReason, ksz3MeetingTargets,
g_stSellerNames[nMeetSellers]._pszName,
g_stOtherPartys[nMeetOthers]._pszName,
g_stBuyerBids[nMeetBuyers]._pszName);
bValidTeam = false;
}
}
if (bValidTeam) {
if ((nMeetOthers != -1 && nMeetSellers != -1)) {
Common::sprintf_s(szFailureReason, ksz2MeetingTargets,
g_stSellerNames[nMeetSellers]._pszName,
g_stOtherPartys[nMeetOthers]._pszName);
bValidTeam = false;
}
}
if (bValidTeam) {
if ((nMeetSellers != -1 && nMeetBuyers != -1)) {
Common::sprintf_s(szFailureReason, ksz2MeetingTargets,
g_stSellerNames[nMeetSellers]._pszName,
g_stBuyerBids[nMeetBuyers]._pszName);
bValidTeam = false;
}
}
if (bValidTeam) {
if ((nMeetOthers != -1 && nMeetBuyers != -1)) {
Common::sprintf_s(szFailureReason, ksz2MeetingTargets,
g_stOtherPartys[nMeetOthers]._pszName,
g_stBuyerBids[nMeetBuyers]._pszName);
bValidTeam = false;
}
}
// Make sure at least one staff member is sent on this mission
int nMaleMembers = 0, nFemaleMembers = 0;
if (bValidTeam) {
for (int i = 0; i < NUM_STAFFERS; i++) {
if (g_staffers[i]._bOnCurrentTeam) {
nTeam |= (1 << (i + 3));
if (g_staffers[i]._nFlags & mStafferMale)
nMaleMembers++;
else
nFemaleMembers++;
}
}
if (nTeam == 0) {
Common::strcpy_s(szFailureReason, kszNoTeamMembers);
bValidTeam = false;
}
}
// No meetings with irk or quosh allowed.
if (bValidTeam) {
if (nMeetSellers == IRK4) {
Common::strcpy_s(szFailureReason, kszCantMeetIrk);
bValidTeam = false;
}
if (nMeetSellers == QUOSH23) {
Common::strcpy_s(szFailureReason, kszCantMeetQuosh);
bValidTeam = false;
}
}
// Don't allow repeat negotiations with someone that
// has already been successfully negotiated with.
if (bValidTeam) {
if (nMeetSellers != -1) {
if (g_stSellerNames[nMeetSellers]._nMeetingResult == SRAF_GOOD_MEETING) {
Common::strcpy_s(szFailureReason, kszCantRenegSeller);
bValidTeam = false;
}
}
if (nMeetOthers != -1) {
if (g_stOtherPartys[nMeetOthers]._nMeetingResult == SRAF_GOOD_MEETING) {
Common::strcpy_s(szFailureReason, kszCantRenegOther);
bValidTeam = false;
}
}
if (nMeetBuyers != -1) {
if (g_stBuyerBids[nMeetBuyers]._nMeetingResult == SRAF_GOOD_MEETING) {
Common::strcpy_s(szFailureReason, kszCantRenegBuyer);
bValidTeam = false;
}
}
}
// Build a valid meeting list element.
DispatchedTeamItem *pTeamItem = nullptr;
if (bValidTeam) {
int nDispatchFlags = (nMeetOthers != -1 ? mOtherParty : (nMeetSellers != -1 ? mSeller : mBuyer));
int nMeetingWith = (nMeetOthers != -1 ? nMeetOthers : (nMeetSellers != -1 ? nMeetSellers : nMeetBuyers));
if (_pTeamList == nullptr) {
_pTeamList = new CBofList<DispatchedTeamItem>;
assert(_pTeamList != nullptr);
}
pTeamItem = new DispatchedTeamItem();
assert(pTeamItem != nullptr);
pTeamItem->_nFlags = nTeam | nDispatchFlags;
pTeamItem->_nMeetWithID = nMeetingWith;
CBagVar *pVar = g_VarManager->getVariable("SRATURNCOUNT");
assert(pVar != nullptr);
pTeamItem->_nDispatchTime = pVar->getNumValue();
pTeamItem->_nMeetingTime = calculateMeetingTime(pTeamItem->_nFlags);
// The spokesperson will be the majority of the sexes
// If same number of each, then randomize it.
if (nMaleMembers == nFemaleMembers) {
// Get a random number to decide the spokesperson of even team
int nRand = pTeamItem->_nDispatchTime;
nMaleMembers += (nRand & 1 ? 1 : -1);
}
// Pick a team captain, must be same sex as the announcer.
pTeamItem->_nTeamCaptain = getTeamCaptain(pTeamItem->_nFlags);
// Team gender is based on sex of captain.
pTeamItem->_nFlags |= getTeamGender(pTeamItem->_nFlags);
_pTeamList->addToTail(*pTeamItem);
// Finally, since we have a valid team, set those team members who are attending to
// be unavailable for any other staff meetings, also reset them to false for
// on current team
for (int i = 0; i < NUM_STAFFERS; i++) {
if (g_staffers[i]._bOnCurrentTeam) {
g_staffers[i]._bOnCurrentTeam = false;
g_staffers[i]._bAvailable = false;
}
}
}
// There are all kinds of ways to screw up a meeting, but we address those in some kind of
// staff meeting grid (search StaffMeeting)
if (bValidTeam == false) {
displayMessage(szFailureReason);
} else {
char szLocalBuff[256];
szLocalBuff[0] = '\0';
CBofString sStr(szLocalBuff, 256);
// We're very excited, we notified the user, now clear up the globals and reset.
if (nMeetOthers != -1) {
g_stOtherPartys[nMeetOthers]._bMeetWith = false;
g_stOtherPartys[nMeetOthers]._bAvailable = false;
} else if (nMeetSellers != -1) {
g_stSellerNames[nMeetSellers]._bMeetWith = false;
g_stSellerNames[nMeetSellers]._bAvailable = false;
} else {
g_stBuyerBids[nMeetBuyers]._bMeetWith = false;
g_stBuyerBids[nMeetBuyers]._bAvailable = false;
}
// Redraw the screen with the meeting with column collapsed and
// the checkmarks out of the staffer columns. This assures that
// any screen capture will come back to us ready for display to the
// user.
initDispatchTeam();
activateDispatchTeam();
// Also have to give the boss a sound or text file to play.
if (pTeamItem->_nFlags & mStafferMale) {
sStr = buildMaleSrafDir(kGSM1SraMaleStr);
} else {
sStr = buildFemaleSrafDir(kGSM1SraFemStr);
}
// Notify Deven...
notifyBoss(sStr, pTeamItem->_nTeamCaptain);
// All done with our team item, trash it.
delete pTeamItem;
updateWindow();
}
return bValidTeam;
}
SrafComputer::~SrafComputer() {
// These lists are persistent across turning the computer on and off, so
// delete them only at the end of the game, not when you turn on/off the
// computer (attach/detach)
if (_pSellerSummaryList != nullptr) {
delete _pSellerSummaryList;
_pSellerSummaryList = nullptr;
}
if (_pBuyerSummaryList != nullptr) {
delete _pBuyerSummaryList;
_pBuyerSummaryList = nullptr;
}
if (_pTeamList != nullptr) {
delete _pTeamList;
_pTeamList = nullptr;
}
// We grab these bad babies in the attach sequence, but since
// we need them to live past having the computer on, we need to
// destruct them in the destructor.
for (int i = 0; i < (NUM_MUSICAL_SCORES - 1); i++) {
if (g_stAudioSetting[i]->_pMidiTrack != nullptr) {
delete g_stAudioSetting[i]->_pMidiTrack;
g_stAudioSetting[i]->_pMidiTrack = nullptr;
}
}
_pTextOnlyScreen = nullptr;
_pHead = nullptr;
}
void SrafComputer::onMainLoop() {
if (_bFirstPaint) {
_bFirstPaint = false;
attachActiveObjects();
}
}
void SrafComputer::onPaint(CBofRect *pRect) {
if (getBackdrop()) {
assert(getWorkBmp() != nullptr);
// erase everything from the background
getWorkBmp()->paint(getBackdrop(), pRect, pRect);
// paint all the objects to the background
paintStorageDevice(nullptr, getBackdrop(), pRect);
}
// Paint the backdrop
if (getBackdrop()) {
paintBackdrop();
}
if (_eMode == SC_OFF) {
_pButtons[ON_BUTTON]->paint(nullptr);
} else {
_pButtons[OFF_BUTTON]->paint(nullptr);
}
}
ErrorCode SrafComputer::attach() {
ErrorCode rc = CBagStorageDevWnd::attach();
if (rc == ERR_NONE) {
// Build our main menu list
assert(_pMainList == nullptr);
_pMainList = new CBofList<SrafCompItem>;
assert(_pMainList != nullptr);
fillMain();
// If we're on the Mac version, slot in the Chicken Dance song
if (g_engine->getPlatform() == Common::kPlatformMacintosh)
g_stAudioSetting[5] = &g_chickenDance;
// Bring in all our audio tracks
for (int i = 0; i < (NUM_MUSICAL_SCORES - 1); i++) {
if (g_stAudioSetting[i]->_pMidiTrack == nullptr) {
g_stAudioSetting[i]->_pMidiTrack = new CBofSound(this, buildAudioDir(g_stAudioSetting[i]->_pszAudioFile), SOUND_MIDI | SOUND_ASYNCH | SOUND_LOOP, 32000);
assert(g_stAudioSetting[i]->_pMidiTrack != nullptr);
}
}
// Must have a valid backdrop by now
assert(_pBackdrop != nullptr);
CBofPalette *pPal = _pBackdrop->getPalette();
for (int i = 0; i < NUM_SRAFCOMPBUTT; i++) {
_pButtons[i] = new CBofBmpButton;
if (_pButtons[i] != nullptr) {
CBofBitmap *pUp = loadBitmap(buildSrafDir(g_stButtons[i]._pszUp), pPal);
CBofBitmap *pDown = loadBitmap(buildSrafDir(g_stButtons[i]._pszDown), pPal);
CBofBitmap *pFocus = loadBitmap(buildSrafDir(g_stButtons[i]._pszFocus), pPal);
CBofBitmap *pDis = loadBitmap(buildSrafDir(g_stButtons[i]._pszDisabled), pPal);
_pButtons[i]->loadBitmaps(pUp, pDown, pFocus, pDis);
_pButtons[i]->create(g_stButtons[i]._pszName, g_stButtons[i]._nLeft, g_stButtons[i]._nTop, g_stButtons[i]._nWidth, g_stButtons[i]._nHeight, this, g_stButtons[i]._nID);
if (i != QUIT_BUTTON)
_pButtons[i]->hide();
}
}
// Get our code words
_pszGroup1Word = new CBofString();
_pszGroup2Word = new CBofString();
// Set the starting time...
if (_nStartingTime == 0) {
CBagVar *pVar = g_VarManager->getVariable("SRATURNCOUNT");
assert(pVar != nullptr);
_nStartingTime = pVar->getNumValue();
}
assert(_pszGroup1Word != nullptr);
assert(_pszGroup2Word != nullptr);
setOn();
show();
updateWindow();
// Finally, use our regular system cursor, not the custom ones
CBagCursor::showSystemCursor();
// Bring in all the external variables
restoreSraffanVars();
// Finally, if we're hallucinating, turn off the hallucination filter.
CBagVar *pVar = g_VarManager->getVariable("HALLUCINATE");
if (pVar && pVar->getNumValue() > 0) {
pVar->setValue(0);
}
}
_bSrafAttached = true;
_bFailureNotified = false;
// No start state for dispatch screen
gDispatchCurState = 0;
return ERR_NONE;
}
ErrorCode SrafComputer::detach() {
// Computer gets turned off
_eMode = SC_OFF;
// Get rid of the system cursor
if (_bSrafAttached) {
CBagCursor::hideSystemCursor();
_bSrafAttached = false;
}
// Remove any capture/focus
CBofApp::getApp()->setCaptureControl(nullptr);
CBofApp::getApp()->setFocusControl(nullptr);
// save all the external variables
saveSraffanVars();
// Delete our computer buttons
for (int i = 0; i < NUM_SRAFCOMPBUTT; i++) {
if (_pButtons[i] != nullptr) {