ScummVM API documentation
sraf_computer.h
1 
2 /* ScummVM - Graphic Adventure Engine
3  *
4  * ScummVM is the legal property of its developers, whose names
5  * are too numerous to list here. Please refer to the COPYRIGHT
6  * file distributed with this source distribution.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef BAGEL_SPACEBAR_SRAF_COMPUTER_H
24 #define BAGEL_SPACEBAR_SRAF_COMPUTER_H
25 
26 #include "bagel/boflib/gui/button.h"
27 #include "bagel/boflib/gui/list_box.h"
28 #include "bagel/boflib/gui/text_box.h"
29 #include "bagel/boflib/gui/dialog.h"
30 #include "bagel/boflib/file.h"
31 #include "bagel/baglib/storage_dev_win.h"
32 
33 namespace Bagel {
34 namespace SpaceBar {
35 
36 class SrafCompItem {
37 public:
38  const char *_pItem;
39 };
40 
41 enum SELLERS {
42  IRK4 = 0, YEEF8, QUOSH23
43 };
44 
46 public:
47  SELLERS _eSellerID;
48  int _nSellerOffer;
49  const char *_pSellerName;
50 };
51 
52 enum BUYERS {
53  PYLON3 = 0, DIPPIK10, VEBBIL18, GUNG14,
54  REYES24, GILD13, HEM20, DORK44, RAWLEY23,
55  JELLA37, SINJIN11, HUNDEY42, CHANDRA15, CLANG2,
56  MINMARTZN, MINMARTBA, MINMARTRG, MINMARTUT,
57  MINMARTPN, MINMARTSZ
58 };
59 
60 enum STAFFERS {
61  NORG72 = 0, PNURTH81, ZIG64, LENTIL24, VARGAS20, CHURG53, DURTEEN97
62 };
63 
65 public:
66  BUYERS _eBuyerID;
67  int _nBuyerOffer;
68  const char *_pBuyerName;
69 };
70 
71 #define mOtherParty 0x0001
72 #define mBuyer 0x0002
73 #define mSeller 0x0004
74 
75 // The ordering of these flags must match the ordering of these same
76 // characters in the array in which they are defined.
77 #define mNorg72 0x0008
78 #define mPnurth81 0x0010
79 #define mZig64 0x0020
80 #define mLentil24 0x0040
81 #define mVargas20 0x0080
82 #define mChurg53 0x0100
83 
84 #define mStafferMale 0x0200
85 #define mStafferFemale 0x0400
86 
88 public:
89  int _nFlags = 0;
90  int _nMeetWithID = 0;
91  int _nDispatchTime = 0;
92  int _nTeamCaptain = 0;
93  int _nMeetingTime = 0;
94 };
95 
96 class SrafTextScreen : public CBofDialog {
97 private:
98  static CBofWindow *_pSaveActiveWin;
99 
100  CBofTextBox *_pTextBox = nullptr; // Bof text box for all kinds of cool info
101  CBofBmpButton *_pOKButton = nullptr;
102  CBofString _text;
103 
104  CBofRect gCompDisplay;
105  CBofRect gTextWindow;
106  CBofRect gStafferDisplay;
107  CBofRect gSrafTextWindow;
108 
109 public:
110  SrafTextScreen(const CBofString &str, bool isText = false);
111  virtual ~SrafTextScreen();
112  int createTextScreen(CBofWindow *pParent = nullptr);
113  void displayTextScreen();
114 
115  void onBofButton(CBofObject *, int) override;
116  void onClose() override;
117  void onPaint(CBofRect * pRect) override;
118 };
119 
120 // Number of constants...
121 #define NUM_MAIL_MESSAGES 8
122 #define NUM_MINERALS 14
123 #define NUM_STAFFERS 6
124 #define NUM_MAIN_ITEMS 11
125 #define NUM_SELLERS 3
126 #define NUM_BUYERS 20
127 #define NUM_OTHER_PARTYS 3
128 #define NUM_MUSICAL_SCORES 7
129 #define NUM_CODE_WORDS 10
130 #define NUM_SRAFCOMPBUTT 11
131 #define NUM_OFFERINGS 2
132 
133 // Constants for get meet member
134 
135 #define kOthersList 1
136 #define kSellersList 2
137 #define kBuyersList 3
138 #define kStaffersList 4
139 
140 // Sraffin text only screens (for stuff like biographies)
141 
143 public:
144  SrafComputer();
145  virtual ~SrafComputer();
146  void onKeyHit(uint32 lKey, uint32 nRepCount) override;
147  ErrorCode attach() override;
148  ErrorCode detach() override;
149  void onLButtonDown(uint32 nFlags, CBofPoint *xPoint, void * = nullptr) override;
150  void onLButtonUp(uint32 nFlags, CBofPoint *xPoint, void * = nullptr) override;
151  void onMainLoop() override;
152  void onPaint(CBofRect *pRect) override;
153  void onBofButton(CBofObject *, int) override;
154  void onBofListBox(CBofObject *pListBox, int nItemIndex) override;
155  void setOn();
156  void setOff();
157  void setQuit();
158  void alignAtColumn(CBofString &sStr, const char *szRightText, int nAlignAt);
159  CBofString &buildBidString(int index);
160 
161  void deleteListBox();
162 
163  ErrorCode createListBox();
164 
165  void fillMain();
166 
167  void hideAllButtons();
168 
169  void activateDealSummary();
170  void activateBuyerBids();
171  void activateDealBackground();
172  void activateSellerBios();
173  void activateOtherBios();
174  void activateStaffBios();
175  void activateDispatchTeam();
176  void activateCurrentEMail();
177  void activateAudioSettings();
178  void activateRoboButler();
179  void activateCheckTeams();
180  void activateCodeWords();
181 
182  void deactivateMainScreen();
183  void activateMainScreen();
184 
185  void initDealSummary();
186  void initBuyerBids();
187  void initDealBackground();
188  void initSellerBios();
189  void initOtherBios();
190  void initStaffBios();
191  void initDispatchTeam();
192  void initCurrentEMail();
193  void initAudioSettings();
194  void initRoboButler();
195 
196  void onListMainScreen();
197  void onListDealSummary();
198  void onListBuyerBids();
199  void onListDealBackground();
200  void onListSellerBios();
201  void onListOtherBios();
202  void onListStaffBios();
203  void onListDispatchTeam();
204  void onListCurrentEMail();
205  void onListAudioSettings();
206  void onListRoboButler();
207  void onListCheckTeams();
208  void onListCodeWords();
209 
210  void onButtonMainScreen(CBofButton *pButton, int nState);
211  void onButtonDealSummary(CBofButton *pButton, int nState);
212  void onButtonBuyerBids(CBofButton *pButton, int nState);
213  void onButtonDealBackground(CBofButton *pButton, int nState);
214  void onButtonSellerBios(CBofButton *pButton, int nState);
215  void onButtonOtherBios(CBofButton *pButton, int nState);
216  void onButtonStaffBios(CBofButton *pButton, int nState);
217  void onButtonDispatchTeam(CBofButton *pButton, int nState);
218  void onButtonCurrentEMail(CBofButton *pButton, int nState);
219  void onButtonAudioSettings(CBofButton *pButton, int nState);
220  void onButtonRoboButler(CBofButton *pButton, int nState);
221  void onButtonCheckTeams(CBofButton *pButton, int nState);
222  void onButtonCodeWords(CBofButton *pButton, int nState);
223 
224  // biography support routines
225  void displayTextScreen(CBofString &);
226 
227  void recalcSellerSummaryList();
228  void recalcBuyerSummaryList();
229  void recalcDispatchList(int);
230 
231  bool onButtonSubmitOffer();
232 
233  // support routines to return info about a list
234  int getMeetMember(int);
235 
240  int getAdjustedIndex(int, int, bool);
241 
242  // Dispatch support routines
243  bool verifyDispatchTeam();
244  void notifyBoss(CBofString &, int);
245  int calculateMeetingTime(int nFlags);
246  bool reportMeetingStatus(int);
247 
252  void setMeetingResult(int, int, bool);
253 
254  int getTeamCaptain(int nFlags);
255  int getTeamGender(int nFlags);
256 
257  // Robobutler service methods
258 
259  void doOrderBeverage();
260  void doOrderSnack();
261  void doShowChowButtons();
262 
263  // To activate the main screen from outside the sraffan computer
264 
265  static void setMainScreen();
266  static CBofBitmap *getComputerBackdrop();
267 
268  // User interaction
269 
270  void displayMessage(const char *szMsg);
271 
272  // Finally, all done!
273  void incrementTurnCount();
274 
275 
280  void displayTurnCount(int);
281  void onButtonFinished(bool);
282 
283  // Save/Restore
284 
285  void saveSraffanVars();
286  void restoreSraffanVars();
287 
288 protected:
289  enum SrafCompModeC {
290  SC_ON, SC_OFF, SC_DONE
291  } _eMode;
292 
293  enum SrafCurScreen {
294  SC_MAIN, SC_DEAL, SC_BIDS, SC_BACKGROUND_DATA,
295  SC_SELLER_BIOS, SC_OTHER_BIOS, SC_STAFF_BIOS,
296  SC_DISPATCH, SC_EMAIL, SC_AUDIO, SC_ORDER,
297  SC_CHECK_TEAMS, SC_CODE_WORDS
298  } _eCurScreen;
299 
300  CBofBmpButton *_pButtons[NUM_SRAFCOMPBUTT];
301  RGBCOLOR _cTextColor;
302  RGBCOLOR _cTextHiliteColor;
303  RGBCOLOR _cTextLineColor;
304 
305  CBofListBox *_pLBox; // Main screen list
306  CBofList<SrafCompItem> *_pMainList;
307  CBofList<DealSummarySellerItem> *_pSellerSummaryList;
308  CBofList<DealSummaryBuyerItem> *_pBuyerSummaryList;
309  CBofList<DispatchedTeamItem> *_pTeamList;
310 
311  CBofBitmap *_pStafferBmp[NUM_STAFFERS + 1]; // (one extra staffer, durteen)
312 
313  int _nSelection;
314  int _nListPointSize;
315  int _nListItemHeight;
316  SrafTextScreen *_pTextOnlyScreen;
317 
318  // Code words
319 
320  CBofString *_pszGroup1Word;
321  CBofString *_pszGroup2Word;
322  bool _bSrafAttached;
323 
324  static bool _bSwonzaEnlightened;
325  static int _nStartingTime;
326 
327  static SrafComputer *_pHead; // Unique pointer to head of list
328 
329  static bool _bRandomAudio;
330  static int _nRandomTime;
331 
332  static bool _bFailureNotified;
333 
334 private:
335  CBofRect gCompDisplay;
336  CBofRect gTextWindow;
337  CBofRect gStafferDisplay;
338  CBofRect gSrafTextWindow;
339  CBofString gBidStr;
340 };
341 
342 } // namespace SpaceBar
343 } // namespace Bagel
344 
345 #endif
Definition: storage_dev_win.h:406
Definition: window.h:50
Definition: sraf_computer.h:45
Definition: sraf_computer.h:96
Definition: object.h:28
Definition: bitmap.h:55
Definition: list_box.h:49
Definition: dialog.h:38
Definition: sraf_computer.h:142
Definition: rect.h:36
Definition: button.h:109
Definition: text_box.h:34
Definition: sraf_computer.h:87
Definition: string.h:38
Definition: bagel.h:31
Definition: point.h:34
Definition: list.h:60
Definition: sraf_computer.h:64
Definition: button.h:53
Definition: sraf_computer.h:36