1 #include "Directories.h"
2 #include "Font.h"
3 #include "HImage.h"
4 #include "Laptop.h"
5 #include "Florist.h"
6 #include "Florist_Order_Form.h"
7 #include "VObject.h"
8 #include "WordWrap.h"
9 #include "Cursors.h"
10 #include "Florist_Gallery.h"
11 #include "Florist_Cards.h"
12 #include "Text_Input.h"
13 #include "Finances.h"
14 #include "Game_Clock.h"
15 #include "English.h"
16 #include "Text.h"
17 #include "LaptopSave.h"
18 #include "Random.h"
19 #include "Button_System.h"
20 #include "Video.h"
21 #include "VSurface.h"
22 #include "Font_Control.h"
23 #include "Meanwhile.h"
24 #include "StrategicMap.h"
25 #include "MapScreen.h"
26
27 #include "ContentManager.h"
28 #include "GameInstance.h"
29 #include "ShippingDestinationModel.h"
30
31 #include <string_theory/format>
32 #include <string_theory/string>
33
34
35 #define FLOWER_ORDEER_TINY_FONT FONT10ARIAL
36 #define FLOWER_ORDEER_SMALL_FONT FONT12ARIAL
37 #define FLOWER_ORDEER_BIG_FONT FONT12ARIAL
38 #define FLOWER_ORDEER_SMALL_COLOR FONT_MCOLOR_WHITE
39 #define FLOWER_ORDEER_LINK_COLOR FONT_MCOLOR_LTYELLOW
40 #define FLOWER_ORDEER_DROP_DOWN_FONT FONT12ARIAL
41 #define FLOWER_ORDEER_DROP_DOWN_COLOR FONT_MCOLOR_WHITE
42
43 #define FLOWER_ORDER_STATIC_TEXT_COLOR 76
44
45 #define FLOWER_ORDER_FLOWER_BOX_X LAPTOP_SCREEN_UL_X + 7
46 #define FLOWER_ORDER_FLOWER_BOX_Y LAPTOP_SCREEN_WEB_UL_Y + 63
47 #define FLOWER_ORDER_FLOWER_BOX_WIDTH 75
48 #define FLOWER_ORDER_FLOWER_BOX_HEIGHT 100
49
50
51 #define FLOWER_ORDER_SENTIMENT_BOX_X LAPTOP_SCREEN_UL_X + 14
52 #define FLOWER_ORDER_SENTIMENT_BOX_Y LAPTOP_SCREEN_WEB_UL_Y + 226
53
54 #define FLOWER_ORDER_NAME_BOX_X LAPTOP_SCREEN_UL_X + 60
55 #define FLOWER_ORDER_NAME_BOX_Y LAPTOP_SCREEN_WEB_UL_Y + 314 - FLOWER_ORDER_SMALLER_PS_OFFSET_Y
56
57 #define FLOWER_ORDER_SMALLER_PS_OFFSET_Y 27
58
59
60 #define FLOWER_ORDER_DELIVERY_LOCATION_X LAPTOP_SCREEN_UL_X + 205
61 #define FLOWER_ORDER_DELIVERY_LOCATION_Y LAPTOP_SCREEN_WEB_UL_Y + 143
62 #define FLOWER_ORDER_DELIVERY_LOCATION_WIDTH 252
63 #define FLOWER_ORDER_DELIVERY_LOCATION_HEIGHT 20
64
65 #define FLOWER_ORDER_BACK_BUTTON_X LAPTOP_SCREEN_UL_X + 8
66 #define FLOWER_ORDER_BACK_BUTTON_Y LAPTOP_SCREEN_WEB_UL_Y + 12
67
68 #define FLOWER_ORDER_SEND_BUTTON_X LAPTOP_SCREEN_UL_X + 124
69 #define FLOWER_ORDER_SEND_BUTTON_Y LAPTOP_SCREEN_WEB_UL_Y + 364
70
71 #define FLOWER_ORDER_CLEAR_BUTTON_X LAPTOP_SCREEN_UL_X + 215
72 #define FLOWER_ORDER_CLEAR_BUTTON_Y FLOWER_ORDER_SEND_BUTTON_Y
73
74 #define FLOWER_ORDER_GALLERY_BUTTON_X LAPTOP_SCREEN_UL_X + 305
75 #define FLOWER_ORDER_GALLERY_BUTTON_Y FLOWER_ORDER_SEND_BUTTON_Y
76
77 #define FLOWER_ORDER_FLOWER_NAME_X LAPTOP_SCREEN_UL_X + 94
78 #define FLOWER_ORDER_FLOWER_NAME_Y LAPTOP_SCREEN_WEB_UL_Y + 68
79
80 #define FLOWER_ORDER_BOUQUET_NAME_X FLOWER_ORDER_FLOWER_NAME_X
81 #define FLOWER_ORDER_BOUQUET_NAME_Y FLOWER_ORDER_ORDER_NUM_NAME_Y + 15//FLOWER_ORDER_FLOWER_NAME_Y + 15
82
83 #define FLOWER_ORDER_ORDER_NUM_NAME_X FLOWER_ORDER_BOUQUET_NAME_X
84 #define FLOWER_ORDER_ORDER_NUM_NAME_Y FLOWER_ORDER_FLOWER_NAME_Y + 15//FLOWER_ORDER_BOUQUET_NAME_Y + 15
85
86 #define FLOWER_ORDER_DATE_X FLOWER_ORDER_FLOWER_NAME_X
87 #define FLOWER_ORDER_DATE_Y LAPTOP_SCREEN_WEB_UL_Y + 126
88
89 #define FLOWER_ORDER_LOCATION_X FLOWER_ORDER_FLOWER_NAME_X
90 #define FLOWER_ORDER_LOCATION_Y FLOWER_ORDER_DELIVERY_LOCATION_Y + 4
91
92 #define FLOWER_ORDER_ADDITIONAL_SERVICES_X FLOWER_ORDER_FLOWER_BOX_X
93 #define FLOWER_ORDER_ADDITIONAL_SERVICES_Y LAPTOP_SCREEN_WEB_UL_Y + 167
94
95 #define FLOWER_ORDER_PERSONAL_SENT_TEXT_X FLOWER_ORDER_ADDITIONAL_SERVICES_X
96 #define FLOWER_ORDER_PERSONAL_SENT_TEXT_Y LAPTOP_SCREEN_WEB_UL_Y + 212
97
98 #define FLOWER_ORDER_PERSONAL_SENT_BOX_X FLOWER_ORDER_SENTIMENT_BOX_X + 5
99 #define FLOWER_ORDER_PERSONAL_SENT_BOX_Y FLOWER_ORDER_SENTIMENT_BOX_Y + 5
100 #define FLOWER_ORDER_PERSONAL_SENT_TEXT_WIDTH 457
101 #define FLOWER_ORDER_PERSONAL_SENT_TEXT_HEIGHT 17//44
102
103 #define FLOWER_ORDER_BILLING_INFO_X FLOWER_ORDER_ADDITIONAL_SERVICES_X
104 #define FLOWER_ORDER_BILLING_INFO_Y LAPTOP_SCREEN_WEB_UL_Y + 296 - FLOWER_ORDER_SMALLER_PS_OFFSET_Y
105
106 #define FLOWER_ORDER_NAME_TEXT_X FLOWER_ORDER_ADDITIONAL_SERVICES_X
107 #define FLOWER_ORDER_NAME_TEXT_Y FLOWER_ORDER_NAME_BOX_Y+4
108 #define FLOWER_ORDER_NAME_TEXT_WIDTH 50
109
110 #define FLOWER_ORDER_NAME_TEXT_BOX_X FLOWER_ORDER_NAME_BOX_X + 3
111 #define FLOWER_ORDER_NAME_TEXT_BOX_Y FLOWER_ORDER_NAME_BOX_Y + 3
112 #define FLOWER_ORDER_NAME_TEXT_BOX_WIDTH 257
113 #define FLOWER_ORDER_NAME_TEXT_BOX_HEIGHT 15
114
115 #define FLOWER_ORDER_CHECK_WIDTH 20
116 #define FLOWER_ORDER_CHECK_HEIGHT 17
117
118 #define FLOWER_ORDER_CHECK_BOX_0_X LAPTOP_SCREEN_UL_X + 186
119 #define FLOWER_ORDER_CHECK_BOX_0_Y FLOWER_ORDER_DATE_Y - 3
120
121 #define FLOWER_ORDER_CHECK_BOX_1_X LAPTOP_SCREEN_UL_X + 270
122 #define FLOWER_ORDER_CHECK_BOX_1_Y FLOWER_ORDER_CHECK_BOX_0_Y
123
124 #define FLOWER_ORDER_CHECK_BOX_2_X LAPTOP_SCREEN_UL_X + 123
125 #define FLOWER_ORDER_CHECK_BOX_2_Y FLOWER_ORDER_ADDITIONAL_SERVICES_Y
126
127 #define FLOWER_ORDER_CHECK_BOX_3_X LAPTOP_SCREEN_UL_X + 269
128 #define FLOWER_ORDER_CHECK_BOX_3_Y FLOWER_ORDER_CHECK_BOX_2_Y
129
130 #define FLOWER_ORDER_CHECK_BOX_4_X FLOWER_ORDER_CHECK_BOX_2_X
131 #define FLOWER_ORDER_CHECK_BOX_4_Y FLOWER_ORDER_CHECK_BOX_2_Y + 25
132
133 #define FLOWER_ORDER_CHECK_BOX_5_X FLOWER_ORDER_CHECK_BOX_3_X
134 #define FLOWER_ORDER_CHECK_BOX_5_Y FLOWER_ORDER_CHECK_BOX_4_Y
135
136 #define FLOWER_ORDER_LINK_TO_CARD_GALLERY_X LAPTOP_SCREEN_UL_X + 190
137 #define FLOWER_ORDER_LINK_TO_CARD_GALLERY_Y LAPTOP_SCREEN_WEB_UL_Y + 284 - FLOWER_ORDER_SMALLER_PS_OFFSET_Y
138
139 #define FLOWER_ORDER_DROP_DOWN_LOCATION_X FLOWER_ORDER_DELIVERY_LOCATION_X
140 #define FLOWER_ORDER_DROP_DOWN_LOCATION_Y FLOWER_ORDER_DELIVERY_LOCATION_Y + 19
141 #define FLOWER_ORDER_DROP_DOWN_LOCATION_WIDTH 230
142
143 #define FLOWER_ORDER_DROP_DOWN_CITY_START_X FLOWER_ORDER_DROP_DOWN_LOCATION_X + 5
144 #define FLOWER_ORDER_DROP_DOWN_CITY_START_Y FLOWER_ORDER_DROP_DOWN_LOCATION_Y + 3
145
146 #define FLOWER_ORDER_PERSONEL_SENTIMENT_NUM_CHARS 75
147 #define FLOWER_ORDER_NAME_FIELD_NUM_CHARS 35
148
149 // Checkbox positions.
150 // They will be initialized at run time when we know
151 // the screen size.
152 static SGPPoint g_order_check_box_pos[6];
153
154 static SGPVObject* guiDeliveryLocation;
155 static SGPVObject* guiFlowerFrame;
156 static SGPVObject* guiCurrentlySelectedFlowerImage;
157 static SGPVObject* guiNameBox;
158 static SGPVObject* guiPersonalSentiments;
159 static SGPVObject* guiFlowerOrderCheckBoxButtonImage;
160 static SGPVObject* guiDropDownBorder;
161
162
163 static BOOLEAN gfFLoristCheckBox0Down = FALSE; // next day delviery
164 static BOOLEAN gfFLoristCheckBox1Down = TRUE; // when it gets there delivery
165 static BOOLEAN gfFLoristCheckBox2Down = FALSE;
166 static BOOLEAN gfFLoristCheckBox3Down = FALSE;
167 static BOOLEAN gfFLoristCheckBox4Down = FALSE;
168 static BOOLEAN gfFLoristCheckBox5Down = FALSE;
169
170 static UINT32 guiFlowerPrice;
171
172 //drop down menu
173 enum
174 {
175 FLOWER_ORDER_DROP_DOWN_NO_ACTION,
176 FLOWER_ORDER_DROP_DOWN_CREATE,
177 FLOWER_ORDER_DROP_DOWN_DESTROY,
178 FLOWER_ORDER_DROP_DOWN_DISPLAY,
179 };
180 //the current mode of the drop down display
181 static UINT8 gubFlowerDestDropDownMode;
182 static UINT8 gubCurrentlySelectedFlowerLocation;
183
184
185 static ST::string gsSentimentTextField;
186 static ST::string gsNameTextField;
187
188
189 //buttons
190 static BUTTON_PICS* guiFlowerOrderButtonImage;
191
192 static UINT8 const gubFlowerOrder_AdditioanalServicePrices[] = { 10, 20, 10, 10 };
193
194 static void BtnFlowerOrderBackButtonCallback(GUI_BUTTON *btn, INT32 reason);
195 static GUIButtonRef guiFlowerOrderBackButton;
196
197 static void BtnFlowerOrderSendButtonCallback(GUI_BUTTON *btn, INT32 reason);
198 static GUIButtonRef guiFlowerOrderSendButton;
199
200 static void BtnFlowerOrderClearButtonCallback(GUI_BUTTON *btn, INT32 reason);
201 static GUIButtonRef guiFlowerOrderClearButton;
202
203 static void BtnFlowerOrderGalleryButtonCallback(GUI_BUTTON *btn, INT32 reason);
204 static GUIButtonRef guiFlowerOrderGalleryButton;
205
206
207 //Clicking on OrderCheckBox
208 static MOUSE_REGION gSelectedFloristCheckBoxRegion[6];
209
210 //link to the card gallery
211 static MOUSE_REGION gSelectedFloristCardGalleryLinkRegion;
212
213 //link to the flower gallery by clicking on the flower
214 static MOUSE_REGION gSelectedFloristGalleryLinkRegion;
215
216
217 //the drop down for the city
218 static MOUSE_REGION gSelectedFloristDropDownRegion;
219
220 //to disable the drop down window
221 static MOUSE_REGION gSelectedFloristDisableDropDownRegion;
222
223
224 //mouse region for the drop down city location area
225 static std::vector<MOUSE_REGION> gSelectedFlowerDropDownRegion;
226
227
MakeButton(const ST::string & text,INT16 x,INT16 y,GUI_CALLBACK click)228 static GUIButtonRef MakeButton(const ST::string& text, INT16 x, INT16 y, GUI_CALLBACK click)
229 {
230 const INT16 shadow_col = FLORIST_BUTTON_TEXT_SHADOW_COLOR;
231 GUIButtonRef const btn = CreateIconAndTextButton(guiFlowerOrderButtonImage, text, FLORIST_BUTTON_TEXT_FONT, FLORIST_BUTTON_TEXT_UP_COLOR, shadow_col, FLORIST_BUTTON_TEXT_DOWN_COLOR, shadow_col, x, y, MSYS_PRIORITY_HIGH, click);
232 btn->SetCursor(CURSOR_WWW);
233 return btn;
234 }
235
236
237 static void InitFlowerOrderTextInputBoxes(void);
238 static void SelectFloristCardGalleryLinkRegionCallBack(MOUSE_REGION* pRegion, INT32 iReason);
239 static void SelectFloristDisableDropDownRegionCallBack(MOUSE_REGION* pRegion, INT32 iReason);
240 static void SelectFloristDropDownRegionCallBack(MOUSE_REGION* pRegion, INT32 iReason);
241 static void SelectFloristGalleryLinkRegionCallBack(MOUSE_REGION* pRegion, INT32 iReason);
242 static void SelectFlorsitCheckBoxRegionCallBack(MOUSE_REGION* pRegion, INT32 iReason);
243
244
EnterFloristOrderForm()245 void EnterFloristOrderForm()
246 {
247 InitFloristDefaults();
248
249 // runtime initialization of the checkbox positions
250 g_order_check_box_pos[0].set(FLOWER_ORDER_CHECK_BOX_0_X, FLOWER_ORDER_CHECK_BOX_0_Y);
251 g_order_check_box_pos[1].set(FLOWER_ORDER_CHECK_BOX_1_X, FLOWER_ORDER_CHECK_BOX_1_Y);
252 g_order_check_box_pos[2].set(FLOWER_ORDER_CHECK_BOX_2_X, FLOWER_ORDER_CHECK_BOX_2_Y);
253 g_order_check_box_pos[3].set(FLOWER_ORDER_CHECK_BOX_3_X, FLOWER_ORDER_CHECK_BOX_3_Y);
254 g_order_check_box_pos[4].set(FLOWER_ORDER_CHECK_BOX_4_X, FLOWER_ORDER_CHECK_BOX_4_Y);
255 g_order_check_box_pos[5].set(FLOWER_ORDER_CHECK_BOX_5_X, FLOWER_ORDER_CHECK_BOX_5_Y);
256
257 guiDeliveryLocation = AddVideoObjectFromFile(LAPTOPDIR "/deliverylocation.sti");
258 guiFlowerFrame = AddVideoObjectFromFile(LAPTOPDIR "/flowerframe.sti");
259 guiPersonalSentiments = AddVideoObjectFromFile(LAPTOPDIR "/personalsentiments.sti");
260 guiNameBox = AddVideoObjectFromFile(LAPTOPDIR "/namebox.sti");
261 guiFlowerOrderCheckBoxButtonImage = AddVideoObjectFromFile(LAPTOPDIR "/ordercheckbox.sti");
262
263 // load the currently selected flower bouquet
264 char sTemp[40];
265 sprintf(sTemp, LAPTOPDIR "/flower_%d.sti", guiCurrentlySelectedFlower);
266 guiCurrentlySelectedFlowerImage = AddVideoObjectFromFile(sTemp);
267
268 guiDropDownBorder = AddVideoObjectFromFile(INTERFACEDIR "/tactpopup.sti");
269
270 guiFlowerOrderButtonImage = LoadButtonImage(LAPTOPDIR "/floristbuttons.sti", 0, 1);
271 guiFlowerOrderBackButton = MakeButton(sOrderFormText[FLORIST_ORDER_BACK], FLOWER_ORDER_BACK_BUTTON_X, FLOWER_ORDER_BACK_BUTTON_Y, BtnFlowerOrderBackButtonCallback);
272 guiFlowerOrderSendButton = MakeButton(sOrderFormText[FLORIST_ORDER_SEND], FLOWER_ORDER_SEND_BUTTON_X, FLOWER_ORDER_SEND_BUTTON_Y, BtnFlowerOrderSendButtonCallback);
273 guiFlowerOrderClearButton = MakeButton(sOrderFormText[FLORIST_ORDER_CLEAR], FLOWER_ORDER_CLEAR_BUTTON_X, FLOWER_ORDER_CLEAR_BUTTON_Y, BtnFlowerOrderClearButtonCallback);
274 guiFlowerOrderGalleryButton = MakeButton(sOrderFormText[FLORIST_ORDER_GALLERY], FLOWER_ORDER_GALLERY_BUTTON_X, FLOWER_ORDER_GALLERY_BUTTON_Y, BtnFlowerOrderGalleryButtonCallback);
275
276 // The check box mouse regions
277 for (UINT32 i = 0; i < lengthof(g_order_check_box_pos); ++i)
278 {
279 MOUSE_REGION* const r = &gSelectedFloristCheckBoxRegion[i];
280 SGPPoint const* const xy = &g_order_check_box_pos[i];
281 MSYS_DefineRegion(r, xy->iX, xy->iY, xy->iX + FLOWER_ORDER_CHECK_WIDTH, xy->iY + FLOWER_ORDER_CHECK_HEIGHT, MSYS_PRIORITY_HIGH, CURSOR_WWW, MSYS_NO_CALLBACK, SelectFlorsitCheckBoxRegionCallBack);
282 MSYS_SetRegionUserData(r, 0, i);
283 }
284
285 UINT16 const x = StringPixLength(sOrderFormText[FLORIST_ORDER_SELECT_FROM_OURS], FLOWER_ORDEER_SMALL_FONT) + 2 + FLOWER_ORDER_LINK_TO_CARD_GALLERY_X;
286 UINT16 const w = StringPixLength(sOrderFormText[FLORIST_ORDER_STANDARDIZED_CARDS], FLOWER_ORDEER_SMALL_FONT);
287 UINT16 const h = GetFontHeight(FLOWER_ORDEER_SMALL_FONT);
288 MSYS_DefineRegion(&gSelectedFloristCardGalleryLinkRegion, x, FLOWER_ORDER_LINK_TO_CARD_GALLERY_Y, x + w, FLOWER_ORDER_LINK_TO_CARD_GALLERY_Y + h, MSYS_PRIORITY_HIGH, CURSOR_WWW, MSYS_NO_CALLBACK, SelectFloristCardGalleryLinkRegionCallBack);
289
290 //flower link
291 MSYS_DefineRegion(&gSelectedFloristGalleryLinkRegion, FLOWER_ORDER_FLOWER_BOX_X, FLOWER_ORDER_FLOWER_BOX_Y, FLOWER_ORDER_FLOWER_BOX_X + FLOWER_ORDER_FLOWER_BOX_WIDTH, FLOWER_ORDER_FLOWER_BOX_Y + FLOWER_ORDER_FLOWER_BOX_HEIGHT, MSYS_PRIORITY_HIGH, CURSOR_WWW, MSYS_NO_CALLBACK, SelectFloristGalleryLinkRegionCallBack);
292
293 //drop down city location
294 MSYS_DefineRegion(&gSelectedFloristDropDownRegion, FLOWER_ORDER_DELIVERY_LOCATION_X, FLOWER_ORDER_DELIVERY_LOCATION_Y, FLOWER_ORDER_DELIVERY_LOCATION_X + FLOWER_ORDER_DELIVERY_LOCATION_WIDTH, FLOWER_ORDER_DELIVERY_LOCATION_Y + FLOWER_ORDER_DELIVERY_LOCATION_HEIGHT, MSYS_PRIORITY_HIGH, CURSOR_WWW, MSYS_NO_CALLBACK, SelectFloristDropDownRegionCallBack);
295
296 //to disable the drop down city location
297 MSYS_DefineRegion(&gSelectedFloristDisableDropDownRegion, LAPTOP_SCREEN_UL_X, LAPTOP_SCREEN_WEB_UL_Y, LAPTOP_SCREEN_LR_X, LAPTOP_SCREEN_WEB_LR_Y, MSYS_PRIORITY_HIGH + 2, CURSOR_LAPTOP_SCREEN, MSYS_NO_CALLBACK, SelectFloristDisableDropDownRegionCallBack);
298 gSelectedFloristDisableDropDownRegion.Disable();
299
300 InitFlowerOrderTextInputBoxes();
301
302 LaptopSaveInfo.uiFlowerOrderNumber += Random(5) + 1;
303
304 RenderFloristOrderForm();
305 }
306
307
InitFloristOrderFormVariables()308 void InitFloristOrderFormVariables()
309 {
310 guiFlowerPrice = 0;
311 gubFlowerDestDropDownMode = FLOWER_ORDER_DROP_DOWN_NO_ACTION;
312 gubCurrentlySelectedFlowerLocation = 0;
313 }
314
315
316 static void DestroyFlowerOrderTextInputBoxes(void);
317
318
ExitFloristOrderForm()319 void ExitFloristOrderForm()
320 {
321 UINT8 i;
322 RemoveFloristDefaults();
323
324 DeleteVideoObject(guiDeliveryLocation);
325 DeleteVideoObject(guiFlowerFrame);
326 DeleteVideoObject(guiNameBox);
327 DeleteVideoObject(guiPersonalSentiments);
328 DeleteVideoObject(guiFlowerOrderCheckBoxButtonImage);
329 DeleteVideoObject(guiCurrentlySelectedFlowerImage);
330 DeleteVideoObject(guiDropDownBorder);
331
332 for(i=0; i<6; i++)
333 MSYS_RemoveRegion( &gSelectedFloristCheckBoxRegion[i]);
334
335 //card gallery link
336 MSYS_RemoveRegion( &gSelectedFloristCardGalleryLinkRegion);
337
338 //flower link
339 MSYS_RemoveRegion( &gSelectedFloristGalleryLinkRegion);
340
341 //flower link
342 MSYS_RemoveRegion( &gSelectedFloristDropDownRegion);
343
344 //disable the drop down window
345 MSYS_RemoveRegion( &gSelectedFloristDisableDropDownRegion);
346
347 UnloadButtonImage( guiFlowerOrderButtonImage );
348
349 RemoveButton( guiFlowerOrderBackButton );
350 RemoveButton( guiFlowerOrderSendButton );
351 RemoveButton( guiFlowerOrderClearButton );
352 RemoveButton( guiFlowerOrderGalleryButton );
353
354 //Store the text fields
355 gsSentimentTextField = GetStringFromField(1);
356 gsNameTextField = GetStringFromField(2);
357 gbCurrentlySelectedCard = -1;
358
359
360 DestroyFlowerOrderTextInputBoxes();
361 }
362
363
364 static BOOLEAN CreateDestroyFlowerOrderDestDropDown(UINT8 ubDropDownMode);
365 static void HandleFloristOrderKeyBoardInput(void);
366
367
HandleFloristOrderForm()368 void HandleFloristOrderForm()
369 {
370 if( gubFlowerDestDropDownMode != FLOWER_ORDER_DROP_DOWN_NO_ACTION )
371 {
372 CreateDestroyFlowerOrderDestDropDown( gubFlowerDestDropDownMode );
373 }
374 HandleFloristOrderKeyBoardInput();
375
376 RenderAllTextFields();
377 }
378
379
380 static void DisplayFloristCheckBox(void);
381 static void DisplayFlowerDynamicItems(void);
382 static void FlowerOrderDisplayShippingLocationCity(void);
383
384
RenderFloristOrderForm()385 void RenderFloristOrderForm()
386 {
387 UINT16 usPosX;
388 UINT32 uiStartLoc=0;
389
390 DisplayFloristDefaults();
391
392 BltVideoObject(FRAME_BUFFER, guiDeliveryLocation, 0, FLOWER_ORDER_DELIVERY_LOCATION_X, FLOWER_ORDER_DELIVERY_LOCATION_Y);
393 BltVideoObject(FRAME_BUFFER, guiFlowerFrame, 0, FLOWER_ORDER_FLOWER_BOX_X, FLOWER_ORDER_FLOWER_BOX_Y);
394 BltVideoObject(FRAME_BUFFER, guiCurrentlySelectedFlowerImage, 0, FLOWER_ORDER_FLOWER_BOX_X + 5, FLOWER_ORDER_FLOWER_BOX_Y + 5);
395 BltVideoObject(FRAME_BUFFER, guiNameBox, 0, FLOWER_ORDER_NAME_BOX_X, FLOWER_ORDER_NAME_BOX_Y);
396 BltVideoObject(FRAME_BUFFER, guiPersonalSentiments, 0, FLOWER_ORDER_SENTIMENT_BOX_X, FLOWER_ORDER_SENTIMENT_BOX_Y);
397
398 //Bouquet name, price and order number,text
399 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_NAME_BOUQUET], FLOWER_ORDER_FLOWER_NAME_X, FLOWER_ORDER_FLOWER_NAME_Y, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDER_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
400 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_PRICE], FLOWER_ORDER_BOUQUET_NAME_X, FLOWER_ORDER_BOUQUET_NAME_Y, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDER_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
401 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_ORDER_NUMBER], FLOWER_ORDER_ORDER_NUM_NAME_X, FLOWER_ORDER_ORDER_NUM_NAME_Y, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDER_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
402
403 //The flower name
404 usPosX = StringPixLength( sOrderFormText[FLORIST_ORDER_NAME_BOUQUET], FLOWER_ORDEER_SMALL_FONT) + 5 + FLOWER_ORDER_FLOWER_NAME_X;
405 uiStartLoc = FLOR_GALLERY_TEXT_TOTAL_SIZE * guiCurrentlySelectedFlower;
406 ST::string sTemp = GCM->loadEncryptedString(FLOR_GALLERY_TEXT_FILE, uiStartLoc, FLOR_GALLERY_TEXT_TITLE_SIZE);
407 DrawTextToScreen(sTemp, usPosX, FLOWER_ORDER_FLOWER_NAME_Y, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDEER_SMALL_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
408
409
410 //Deliverry Date
411 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_DELIVERY_DATE], FLOWER_ORDER_ORDER_NUM_NAME_X, FLOWER_ORDER_DATE_Y, 0, FLOWER_ORDEER_BIG_FONT, FLOWER_ORDER_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
412
413 //Next day
414 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_NEXT_DAY], FLOWER_ORDER_CHECK_BOX_0_X + FLOWER_ORDER_CHECK_WIDTH + 3, FLOWER_ORDER_CHECK_BOX_0_Y + 2, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDEER_SMALL_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
415
416 //When it get there
417 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_GETS_THERE], FLOWER_ORDER_CHECK_BOX_1_X + FLOWER_ORDER_CHECK_WIDTH + 3, FLOWER_ORDER_CHECK_BOX_1_Y + 2, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDEER_SMALL_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
418
419 //Deliverry locatiuon
420 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_DELIVERY_LOCATION], FLOWER_ORDER_ORDER_NUM_NAME_X, FLOWER_ORDER_LOCATION_Y, 0, FLOWER_ORDEER_BIG_FONT, FLOWER_ORDER_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
421
422 //Additional services
423 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_ADDITIONAL_CHARGES], FLOWER_ORDER_ADDITIONAL_SERVICES_X, FLOWER_ORDER_ADDITIONAL_SERVICES_Y, 0, FLOWER_ORDEER_BIG_FONT, FLOWER_ORDER_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
424
425 //crushed bouquet
426 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_CRUSHED], FLOWER_ORDER_CHECK_BOX_2_X + FLOWER_ORDER_CHECK_WIDTH + 3, FLOWER_ORDER_CHECK_BOX_2_Y + 2, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDEER_SMALL_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
427
428 //black roses
429 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_BLACK_ROSES], FLOWER_ORDER_CHECK_BOX_3_X + FLOWER_ORDER_CHECK_WIDTH + 3, FLOWER_ORDER_CHECK_BOX_3_Y + 2, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDEER_SMALL_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
430
431 //wilted bouquet
432 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_WILTED], FLOWER_ORDER_CHECK_BOX_4_X + FLOWER_ORDER_CHECK_WIDTH + 3, FLOWER_ORDER_CHECK_BOX_4_Y + 2, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDEER_SMALL_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
433
434 //fruit cake
435 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_FRUIT_CAKE], FLOWER_ORDER_CHECK_BOX_5_X + FLOWER_ORDER_CHECK_WIDTH + 3, FLOWER_ORDER_CHECK_BOX_5_Y + 2, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDEER_SMALL_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
436
437
438 //Personal sentiment
439 usPosX = FLOWER_ORDER_PERSONAL_SENT_TEXT_X + StringPixLength( sOrderFormText[FLORIST_ORDER_PERSONAL_SENTIMENTS], FLOWER_ORDEER_BIG_FONT) + 5;
440 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_PERSONAL_SENTIMENTS], FLOWER_ORDER_PERSONAL_SENT_TEXT_X, FLOWER_ORDER_PERSONAL_SENT_TEXT_Y, 0, FLOWER_ORDEER_BIG_FONT, FLOWER_ORDER_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
441 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_CARD_LENGTH], usPosX, FLOWER_ORDER_PERSONAL_SENT_TEXT_Y +2, 0, FLOWER_ORDEER_TINY_FONT, FLOWER_ORDEER_SMALL_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
442
443 //Billing information
444 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_BILLING_INFO], FLOWER_ORDER_BILLING_INFO_X, FLOWER_ORDER_BILLING_INFO_Y, 0, FLOWER_ORDEER_BIG_FONT, FLOWER_ORDER_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
445
446 //Billing Name
447 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_NAME], FLOWER_ORDER_NAME_TEXT_X, FLOWER_ORDER_NAME_TEXT_Y, FLOWER_ORDER_NAME_TEXT_WIDTH, FLOWER_ORDEER_BIG_FONT, FLOWER_ORDER_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, RIGHT_JUSTIFIED);
448
449 //the text to link to the card gallery
450 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_SELECT_FROM_OURS], FLOWER_ORDER_LINK_TO_CARD_GALLERY_X, FLOWER_ORDER_LINK_TO_CARD_GALLERY_Y, 0, FLOWER_ORDEER_BIG_FONT, FLOWER_ORDER_STATIC_TEXT_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
451 usPosX = StringPixLength( sOrderFormText[FLORIST_ORDER_SELECT_FROM_OURS], FLOWER_ORDEER_SMALL_FONT) + 5 + FLOWER_ORDER_LINK_TO_CARD_GALLERY_X;
452 DrawTextToScreen(sOrderFormText[FLORIST_ORDER_STANDARDIZED_CARDS], usPosX, FLOWER_ORDER_LINK_TO_CARD_GALLERY_Y, 0, FLOWER_ORDEER_BIG_FONT, FLOWER_ORDEER_LINK_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
453
454 DisplayFloristCheckBox();
455
456 //display all the things that change for the different bouquet collections
457 DisplayFlowerDynamicItems();
458
459 //Display the currently selected city
460 FlowerOrderDisplayShippingLocationCity();
461
462 MarkButtonsDirty( );
463 RenderWWWProgramTitleBar( );
464 InvalidateRegion(LAPTOP_SCREEN_UL_X,LAPTOP_SCREEN_WEB_UL_Y,LAPTOP_SCREEN_LR_X,LAPTOP_SCREEN_WEB_LR_Y);
465 }
466
467
BtnFlowerOrderBackButtonCallback(GUI_BUTTON * btn,INT32 reason)468 static void BtnFlowerOrderBackButtonCallback(GUI_BUTTON *btn, INT32 reason)
469 {
470 if (reason & MSYS_CALLBACK_REASON_LBUTTON_UP)
471 {
472 guiCurrentLaptopMode = LAPTOP_MODE_FLORIST_FLOWER_GALLERY;
473 }
474 }
475
476
BtnFlowerOrderSendButtonCallback(GUI_BUTTON * btn,INT32 reason)477 static void BtnFlowerOrderSendButtonCallback(GUI_BUTTON *btn, INT32 reason)
478 {
479 if (reason & MSYS_CALLBACK_REASON_LBUTTON_UP)
480 {
481 //add an entry in the finacial page for the medical deposit
482 AddTransactionToPlayersBook(PURCHASED_FLOWERS, 0, GetWorldTotalMin(), -(INT32)guiFlowerPrice);
483
484 auto destination = GCM->getShippingDestination(gubCurrentlySelectedFlowerLocation);
485 if (GetTownIdForSector(destination->getDeliverySector()) == MEDUNA)
486 {
487 // sent to meduna!
488 if (gfFLoristCheckBox0Down)
489 {
490 HandleFlowersMeanwhileScene(0);
491 }
492 else
493 {
494 HandleFlowersMeanwhileScene(1);
495 }
496 }
497
498 //increment the order number
499 LaptopSaveInfo.uiFlowerOrderNumber += 1 + Random(2);
500
501 guiCurrentLaptopMode = LAPTOP_MODE_FLORIST;
502 InitFloristOrderForm();
503 }
504 }
505
506
BtnFlowerOrderClearButtonCallback(GUI_BUTTON * btn,INT32 reason)507 static void BtnFlowerOrderClearButtonCallback(GUI_BUTTON *btn, INT32 reason)
508 {
509 if (reason & MSYS_CALLBACK_REASON_LBUTTON_UP)
510 {
511 guiCurrentLaptopMode = LAPTOP_MODE_FLORIST;
512 InitFloristOrderForm();
513 }
514 }
515
516
BtnFlowerOrderGalleryButtonCallback(GUI_BUTTON * btn,INT32 reason)517 static void BtnFlowerOrderGalleryButtonCallback(GUI_BUTTON *btn, INT32 reason)
518 {
519 if (reason & MSYS_CALLBACK_REASON_LBUTTON_UP)
520 {
521 guiCurrentLaptopMode = LAPTOP_MODE_FLORIST_FLOWER_GALLERY;
522 //reset the gallery back to page 0
523 gubCurFlowerIndex = 0;
524 }
525 }
526
527
SelectFlorsitCheckBoxRegionCallBack(MOUSE_REGION * pRegion,INT32 iReason)528 static void SelectFlorsitCheckBoxRegionCallBack(MOUSE_REGION* pRegion, INT32 iReason)
529 {
530 if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
531 {
532 UINT32 uiUserData;
533
534 uiUserData = MSYS_GetRegionUserData( pRegion, 0 );
535
536 switch( uiUserData )
537 {
538 case 0:
539 if( gfFLoristCheckBox0Down )
540 {
541 gfFLoristCheckBox0Down = FALSE;
542 gfFLoristCheckBox1Down = TRUE;
543 }
544 else
545 {
546 gfFLoristCheckBox0Down = TRUE;
547 gfFLoristCheckBox1Down = FALSE;
548 }
549 break;
550 case 1:
551 if( gfFLoristCheckBox1Down )
552 {
553 gfFLoristCheckBox1Down = FALSE;
554 gfFLoristCheckBox0Down = TRUE;
555 }
556 else
557 {
558 gfFLoristCheckBox1Down = TRUE;
559 gfFLoristCheckBox0Down = FALSE;
560 }
561 break;
562 case 2:
563 if( gfFLoristCheckBox2Down )
564 gfFLoristCheckBox2Down = FALSE;
565 else
566 gfFLoristCheckBox2Down = TRUE;
567 break;
568 case 3:
569 if( gfFLoristCheckBox3Down )
570 gfFLoristCheckBox3Down = FALSE;
571 else
572 gfFLoristCheckBox3Down = TRUE;
573 break;
574 case 4:
575 if( gfFLoristCheckBox4Down )
576 gfFLoristCheckBox4Down = FALSE;
577 else
578 gfFLoristCheckBox4Down = TRUE;
579 break;
580 case 5:
581 if( gfFLoristCheckBox5Down )
582 gfFLoristCheckBox5Down = FALSE;
583 else
584 gfFLoristCheckBox5Down = TRUE;
585 break;
586 }
587 DisplayFloristCheckBox();
588 fPausedReDrawScreenFlag = TRUE;
589 }
590 }
591
592
DisplayFloristCheckBox(void)593 static void DisplayFloristCheckBox(void)
594 {
595 BltVideoObject(FRAME_BUFFER, guiFlowerOrderCheckBoxButtonImage, gfFLoristCheckBox0Down ? 1 : 0, FLOWER_ORDER_CHECK_BOX_0_X, FLOWER_ORDER_CHECK_BOX_0_Y);
596 BltVideoObject(FRAME_BUFFER, guiFlowerOrderCheckBoxButtonImage, gfFLoristCheckBox1Down ? 1 : 0, FLOWER_ORDER_CHECK_BOX_1_X, FLOWER_ORDER_CHECK_BOX_1_Y);
597 BltVideoObject(FRAME_BUFFER, guiFlowerOrderCheckBoxButtonImage, gfFLoristCheckBox2Down ? 1 : 0, FLOWER_ORDER_CHECK_BOX_2_X, FLOWER_ORDER_CHECK_BOX_2_Y);
598 BltVideoObject(FRAME_BUFFER, guiFlowerOrderCheckBoxButtonImage, gfFLoristCheckBox3Down ? 1 : 0, FLOWER_ORDER_CHECK_BOX_3_X, FLOWER_ORDER_CHECK_BOX_3_Y);
599 BltVideoObject(FRAME_BUFFER, guiFlowerOrderCheckBoxButtonImage, gfFLoristCheckBox4Down ? 1 : 0, FLOWER_ORDER_CHECK_BOX_4_X, FLOWER_ORDER_CHECK_BOX_4_Y);
600 BltVideoObject(FRAME_BUFFER, guiFlowerOrderCheckBoxButtonImage, gfFLoristCheckBox5Down ? 1 : 0, FLOWER_ORDER_CHECK_BOX_5_X, FLOWER_ORDER_CHECK_BOX_5_Y);
601
602 InvalidateRegion(LAPTOP_SCREEN_UL_X,LAPTOP_SCREEN_WEB_UL_Y,LAPTOP_SCREEN_LR_X,LAPTOP_SCREEN_WEB_LR_Y);
603 }
604
605
SelectFloristCardGalleryLinkRegionCallBack(MOUSE_REGION * pRegion,INT32 iReason)606 static void SelectFloristCardGalleryLinkRegionCallBack(MOUSE_REGION* pRegion, INT32 iReason)
607 {
608 if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
609 {
610 guiCurrentLaptopMode = LAPTOP_MODE_FLORIST_CARD_GALLERY;
611 }
612 }
613
614
615 //display the things that change on the screen
DisplayFlowerDynamicItems(void)616 static void DisplayFlowerDynamicItems(void)
617 {
618 UINT32 uiStartLoc=0;
619 UINT16 usPosX;
620 ST::string sTemp;
621 UINT16 usPrice;
622
623 //order number
624 usPosX = StringPixLength( sOrderFormText[FLORIST_ORDER_ORDER_NUMBER], FLOWER_ORDEER_SMALL_FONT) + 5 + FLOWER_ORDER_ORDER_NUM_NAME_X;
625 sTemp = ST::format("{}", LaptopSaveInfo.uiFlowerOrderNumber);
626 DrawTextToScreen(sTemp, usPosX, FLOWER_ORDER_ORDER_NUM_NAME_Y, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDEER_SMALL_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
627
628 guiFlowerPrice = 0;
629 // the user selected crushed bouquet
630 if( gfFLoristCheckBox2Down )
631 guiFlowerPrice += gubFlowerOrder_AdditioanalServicePrices[0];
632
633 // the user selected blak roses
634 if( gfFLoristCheckBox3Down )
635 guiFlowerPrice += gubFlowerOrder_AdditioanalServicePrices[1];
636
637 // the user selected wilted bouquet
638 if( gfFLoristCheckBox4Down )
639 guiFlowerPrice += gubFlowerOrder_AdditioanalServicePrices[2];
640
641 // the user selected fruit cake
642 if( gfFLoristCheckBox5Down )
643 guiFlowerPrice += gubFlowerOrder_AdditioanalServicePrices[3];
644
645 //price
646 usPosX = StringPixLength( sOrderFormText[FLORIST_ORDER_PRICE], FLOWER_ORDEER_SMALL_FONT) + 5 + FLOWER_ORDER_BOUQUET_NAME_X;
647 uiStartLoc = FLOR_GALLERY_TEXT_TOTAL_SIZE * guiCurrentlySelectedFlower + FLOR_GALLERY_TEXT_TITLE_SIZE;
648 sTemp = GCM->loadEncryptedString(FLOR_GALLERY_TEXT_FILE, uiStartLoc, FLOR_GALLERY_TEXT_PRICE_SIZE);
649 sscanf(sTemp.c_str(), "%hu", &usPrice);
650
651 //if its the next day delivery
652 auto destination = GCM->getShippingDestination(gubCurrentlySelectedFlowerLocation);
653 if( gfFLoristCheckBox0Down )
654 guiFlowerPrice += usPrice + destination->flowersNextDayDeliveryCost;
655 //else its the 'when it gets there' delivery
656 else
657 guiFlowerPrice += usPrice + destination->flowersWhenItGetsThereCost;
658
659 sTemp = ST::format("${}.00 {}", guiFlowerPrice, pMessageStrings[MSG_USDOLLAR_ABBREVIATION]);
660 DrawTextToScreen(sTemp, usPosX, FLOWER_ORDER_BOUQUET_NAME_Y, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDEER_SMALL_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
661 }
662
663
SelectFloristGalleryLinkRegionCallBack(MOUSE_REGION * pRegion,INT32 iReason)664 static void SelectFloristGalleryLinkRegionCallBack(MOUSE_REGION* pRegion, INT32 iReason)
665 {
666 if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
667 {
668 guiCurrentLaptopMode = LAPTOP_MODE_FLORIST_FLOWER_GALLERY;
669 }
670 }
671
672
SelectFloristDropDownRegionCallBack(MOUSE_REGION * pRegion,INT32 iReason)673 static void SelectFloristDropDownRegionCallBack(MOUSE_REGION* pRegion, INT32 iReason)
674 {
675 if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
676 {
677 gubFlowerDestDropDownMode = FLOWER_ORDER_DROP_DOWN_CREATE;
678 }
679 }
680
681
SelectFloristDisableDropDownRegionCallBack(MOUSE_REGION * pRegion,INT32 iReason)682 static void SelectFloristDisableDropDownRegionCallBack(MOUSE_REGION* pRegion, INT32 iReason)
683 {
684 if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
685 {
686 gubFlowerDestDropDownMode = FLOWER_ORDER_DROP_DOWN_DESTROY;
687 }
688 }
689
690
691 static void FlowerOrderDrawSelectedCity(UINT8 ubNumber);
692
693
SelectFlowerDropDownRegionCallBack(MOUSE_REGION * pRegion,INT32 iReason)694 static void SelectFlowerDropDownRegionCallBack(MOUSE_REGION* pRegion, INT32 iReason)
695 {
696 if (iReason & MSYS_CALLBACK_REASON_LBUTTON_UP)
697 {
698 gubCurrentlySelectedFlowerLocation = (UINT8)MSYS_GetRegionUserData( pRegion, 0 );
699 FlowerOrderDrawSelectedCity( gubCurrentlySelectedFlowerLocation );
700 gubFlowerDestDropDownMode = FLOWER_ORDER_DROP_DOWN_DESTROY;
701 }
702 }
703
704
SelectFlowerDropDownMovementCallBack(MOUSE_REGION * pRegion,INT32 reason)705 static void SelectFlowerDropDownMovementCallBack(MOUSE_REGION* pRegion, INT32 reason)
706 {
707 if( reason & MSYS_CALLBACK_REASON_LOST_MOUSE )
708 {
709 InvalidateRegion(pRegion->RegionTopLeftX, pRegion->RegionTopLeftY, pRegion->RegionBottomRightX, pRegion->RegionBottomRightY);
710 }
711 else if( reason & MSYS_CALLBACK_REASON_GAIN_MOUSE )
712 {
713 gubCurrentlySelectedFlowerLocation = (UINT8)MSYS_GetRegionUserData( pRegion, 0 );
714 FlowerOrderDrawSelectedCity( gubCurrentlySelectedFlowerLocation );
715
716 InvalidateRegion(pRegion->RegionTopLeftX, pRegion->RegionTopLeftY, pRegion->RegionBottomRightX, pRegion->RegionBottomRightY);
717 }
718 }
719
720
GetInputText()721 static void GetInputText()
722 {
723 // Get the current text from the text box
724 UINT8 const text_field_id = GetActiveFieldID();
725 if (text_field_id == 1)
726 { // The personel sentiment field
727 gsSentimentTextField = GetStringFromField(text_field_id);
728 }
729 else if (text_field_id == 2)
730 { // The name field
731 gsNameTextField = GetStringFromField(text_field_id);
732 }
733
734 SetActiveField(0);
735 }
736
737
CreateDestroyFlowerOrderDestDropDown(UINT8 ubDropDownMode)738 static BOOLEAN CreateDestroyFlowerOrderDestDropDown(UINT8 ubDropDownMode)
739 {
740 static UINT16 usHeight;
741 static BOOLEAN fMouseRegionsCreated=FALSE;
742
743 switch( ubDropDownMode )
744 {
745 case FLOWER_ORDER_DROP_DOWN_NO_ACTION:
746 {
747
748 }
749 break;
750
751 case FLOWER_ORDER_DROP_DOWN_CREATE:
752 {
753 UINT8 i;
754 UINT16 usPosX, usPosY;
755 UINT16 usTemp;
756 UINT16 usFontHeight = GetFontHeight( FLOWER_ORDEER_DROP_DOWN_FONT );
757
758 if( fMouseRegionsCreated )
759 {
760 return(FALSE);
761 }
762
763 GetInputText();
764
765 fMouseRegionsCreated = TRUE;
766
767 usPosX = FLOWER_ORDER_DROP_DOWN_CITY_START_X;
768 usPosY = FLOWER_ORDER_DROP_DOWN_CITY_START_Y;
769
770 gSelectedFlowerDropDownRegion.resize(GCM->getShippingDestinations().size(), {});
771 for (i = 0; i < gSelectedFlowerDropDownRegion.size(); i++)
772 {
773 MSYS_DefineRegion(&gSelectedFlowerDropDownRegion[i], usPosX, usPosY + 4, usPosX + FLOWER_ORDER_DROP_DOWN_LOCATION_WIDTH, usPosY + usFontHeight, MSYS_PRIORITY_HIGH + 3, CURSOR_WWW, SelectFlowerDropDownMovementCallBack, SelectFlowerDropDownRegionCallBack);
774 MSYS_SetRegionUserData( &gSelectedFlowerDropDownRegion[ i ], 0, i);
775
776 usPosY += usFontHeight + 2;
777 }
778 usTemp = FLOWER_ORDER_DROP_DOWN_CITY_START_Y;
779 usHeight = usPosY - usTemp + 10;
780
781
782 gubFlowerDestDropDownMode = FLOWER_ORDER_DROP_DOWN_DISPLAY;
783 gSelectedFloristDisableDropDownRegion.Enable();
784
785
786 //disable the text entry fields
787 //DisableAllTextFields();
788 gsSentimentTextField = GetStringFromField(1);
789 KillTextInputMode();
790
791 //disable the clear order and accept order buttons, (their rendering interferes with the drop down graphics)
792 }
793 break;
794
795 case FLOWER_ORDER_DROP_DOWN_DESTROY:
796 {
797 if( !fMouseRegionsCreated )
798 break;
799
800 for (auto& region : gSelectedFlowerDropDownRegion)
801 {
802 MSYS_RemoveRegion(®ion);
803 }
804
805 //display the name on the title bar
806 ColorFillVideoSurfaceArea( FRAME_BUFFER, FLOWER_ORDER_DROP_DOWN_LOCATION_X+3, FLOWER_ORDER_DELIVERY_LOCATION_Y+3, FLOWER_ORDER_DROP_DOWN_LOCATION_X+FLOWER_ORDER_DROP_DOWN_LOCATION_WIDTH, FLOWER_ORDER_DELIVERY_LOCATION_Y+FLOWER_ORDER_DELIVERY_LOCATION_HEIGHT-2, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
807 DrawTextToScreen(*(GCM->getShippingDestinationName(gubCurrentlySelectedFlowerLocation)), FLOWER_ORDER_DROP_DOWN_CITY_START_X + 6, FLOWER_ORDER_DROP_DOWN_CITY_START_Y + 3, 0, FLOWER_ORDEER_DROP_DOWN_FONT, FLOWER_ORDEER_DROP_DOWN_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
808
809 //enable the drop down region
810 gSelectedFloristDisableDropDownRegion.Disable();
811
812 fPausedReDrawScreenFlag = TRUE;
813 fMouseRegionsCreated = FALSE;
814 gubFlowerDestDropDownMode = FLOWER_ORDER_DROP_DOWN_NO_ACTION;
815
816 //enable the text entry fields
817 InitFlowerOrderTextInputBoxes();
818 }
819 break;
820
821 case FLOWER_ORDER_DROP_DOWN_DISPLAY:
822 {
823 UINT8 i;
824 UINT16 usPosY, usPosX;
825 UINT16 usFontHeight = GetFontHeight( FLOWER_ORDEER_DROP_DOWN_FONT );
826
827 //Display the background for the drop down window
828 ColorFillVideoSurfaceArea( FRAME_BUFFER, FLOWER_ORDER_DROP_DOWN_LOCATION_X, FLOWER_ORDER_DROP_DOWN_LOCATION_Y, FLOWER_ORDER_DROP_DOWN_LOCATION_X+FLOWER_ORDER_DROP_DOWN_LOCATION_WIDTH, FLOWER_ORDER_DROP_DOWN_LOCATION_Y+usHeight, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
829
830 //
831 // Place the border around the background
832 //
833
834 SGPVObject* const hImageHandle = guiDropDownBorder;
835
836 usPosX = usPosY = 0;
837 //blit top row of images
838 for(i=10; i< FLOWER_ORDER_DROP_DOWN_LOCATION_WIDTH-10; i+=10)
839 {
840 //TOP ROW
841 BltVideoObject(FRAME_BUFFER, hImageHandle, 1,i+FLOWER_ORDER_DROP_DOWN_LOCATION_X, usPosY+FLOWER_ORDER_DROP_DOWN_LOCATION_Y);
842
843 //BOTTOM ROW
844 BltVideoObject(FRAME_BUFFER, hImageHandle, 6,i+FLOWER_ORDER_DROP_DOWN_LOCATION_X, usHeight-10+6+FLOWER_ORDER_DROP_DOWN_LOCATION_Y);
845 }
846
847 //blit the left and right row of images
848 usPosX = 0;
849 for(i=10; i< usHeight-10; i+=10)
850 {
851 BltVideoObject(FRAME_BUFFER, hImageHandle, 3,usPosX+FLOWER_ORDER_DROP_DOWN_LOCATION_X, i+FLOWER_ORDER_DROP_DOWN_LOCATION_Y);
852 BltVideoObject(FRAME_BUFFER, hImageHandle, 4,usPosX+FLOWER_ORDER_DROP_DOWN_LOCATION_WIDTH-4+FLOWER_ORDER_DROP_DOWN_LOCATION_X, i+FLOWER_ORDER_DROP_DOWN_LOCATION_Y);
853 }
854
855 //blt the corner images for the row
856 //top left
857 BltVideoObject(FRAME_BUFFER, hImageHandle, 0, 0+FLOWER_ORDER_DROP_DOWN_LOCATION_X, usPosY+FLOWER_ORDER_DROP_DOWN_LOCATION_Y);
858 //top right
859 BltVideoObject(FRAME_BUFFER, hImageHandle, 2, FLOWER_ORDER_DROP_DOWN_LOCATION_WIDTH-10+FLOWER_ORDER_DROP_DOWN_LOCATION_X, usPosY+FLOWER_ORDER_DROP_DOWN_LOCATION_Y);
860 //bottom left
861 BltVideoObject(FRAME_BUFFER, hImageHandle, 5, 0+FLOWER_ORDER_DROP_DOWN_LOCATION_X, usHeight-10+FLOWER_ORDER_DROP_DOWN_LOCATION_Y);
862 //bottom right
863 BltVideoObject(FRAME_BUFFER, hImageHandle, 7, FLOWER_ORDER_DROP_DOWN_LOCATION_WIDTH-10+FLOWER_ORDER_DROP_DOWN_LOCATION_X, usHeight-10+FLOWER_ORDER_DROP_DOWN_LOCATION_Y);
864
865
866 //Display the list of cities
867 usPosY = FLOWER_ORDER_DROP_DOWN_CITY_START_Y + 3;
868 for (i = 0; i < GCM->getShippingDestinations().size(); i++)
869 {
870 DrawTextToScreen(*(GCM->getShippingDestinationName(i)), FLOWER_ORDER_DROP_DOWN_CITY_START_X + 6, usPosY, 0, FLOWER_ORDEER_DROP_DOWN_FONT, FLOWER_ORDEER_DROP_DOWN_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
871 usPosY += usFontHeight + 2;
872 }
873
874 FlowerOrderDrawSelectedCity( gubCurrentlySelectedFlowerLocation );
875
876 InvalidateRegion(LAPTOP_SCREEN_UL_X,LAPTOP_SCREEN_WEB_UL_Y,LAPTOP_SCREEN_LR_X,LAPTOP_SCREEN_WEB_LR_Y);
877 }
878 break;
879 }
880 return(TRUE);
881 }
882
883
FlowerOrderDrawSelectedCity(UINT8 ubNumber)884 static void FlowerOrderDrawSelectedCity(UINT8 ubNumber)
885 {
886 UINT16 usPosY;
887 UINT16 usFontHeight = GetFontHeight( FLOWER_ORDEER_DROP_DOWN_FONT );
888
889 usPosY = (usFontHeight + 2) * ubNumber + FLOWER_ORDER_DROP_DOWN_CITY_START_Y;
890
891 //display the name in the list
892 ColorFillVideoSurfaceArea( FRAME_BUFFER, FLOWER_ORDER_DROP_DOWN_CITY_START_X, usPosY+2, FLOWER_ORDER_DROP_DOWN_CITY_START_X+FLOWER_ORDER_DROP_DOWN_LOCATION_WIDTH-9, usPosY+usFontHeight+4, Get16BPPColor( FROMRGB( 255, 255, 255 ) ) );
893
894 SetFontShadow(NO_SHADOW);
895 DrawTextToScreen(*(GCM->getShippingDestinationName(ubNumber)), FLOWER_ORDER_DROP_DOWN_CITY_START_X + 6, usPosY + 3, 0, FLOWER_ORDEER_DROP_DOWN_FONT, 2, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
896 SetFontShadow(DEFAULT_SHADOW);
897
898 FlowerOrderDisplayShippingLocationCity();
899 }
900
901
FlowerOrderDisplayShippingLocationCity(void)902 static void FlowerOrderDisplayShippingLocationCity(void)
903 {
904 //display the name on the title bar
905 ColorFillVideoSurfaceArea( FRAME_BUFFER, FLOWER_ORDER_DROP_DOWN_LOCATION_X+3, FLOWER_ORDER_DELIVERY_LOCATION_Y+3, FLOWER_ORDER_DROP_DOWN_LOCATION_X+FLOWER_ORDER_DROP_DOWN_LOCATION_WIDTH, FLOWER_ORDER_DELIVERY_LOCATION_Y+FLOWER_ORDER_DELIVERY_LOCATION_HEIGHT-2, Get16BPPColor( FROMRGB( 0, 0, 0 ) ) );
906 DrawTextToScreen(*(GCM->getShippingDestinationName(gubCurrentlySelectedFlowerLocation)), FLOWER_ORDER_DELIVERY_LOCATION_X + 5, FLOWER_ORDER_DELIVERY_LOCATION_Y + 5, 0, FLOWER_ORDEER_SMALL_FONT, FLOWER_ORDEER_SMALL_COLOR, FONT_MCOLOR_BLACK, LEFT_JUSTIFIED);
907 }
908
909
InitFlowerOrderTextInputBoxes(void)910 static void InitFlowerOrderTextInputBoxes(void)
911 {
912 InitTextInputMode();
913 SetTextInputFont(FONT12ARIAL);
914 Set16BPPTextFieldColor( Get16BPPColor(FROMRGB( 255, 255, 255) ) );
915 SetBevelColors( Get16BPPColor(FROMRGB(136, 138, 135)), Get16BPPColor(FROMRGB(24, 61, 81)) );
916 SetTextInputRegularColors( 2, FONT_WHITE );
917 SetTextInputHilitedColors( FONT_WHITE, 2, 141 );
918 SetCursorColor( Get16BPPColor(FROMRGB(0, 0, 0) ) );
919
920 AddUserInputField(NULL);
921
922 if( gbCurrentlySelectedCard != -1 )
923 {
924 //Get and display the card saying
925 //Display Flower Desc
926
927 const UINT32 uiStartLoc = FLOR_CARD_TEXT_TITLE_SIZE * gbCurrentlySelectedCard;
928 ST::string sTemp = GCM->loadEncryptedString( FLOR_CARD_TEXT_FILE, uiStartLoc, FLOR_CARD_TEXT_TITLE_SIZE);
929 ST::string sText = CleanOutControlCodesFromString(sTemp);
930
931 gsSentimentTextField = sText;
932
933 gbCurrentlySelectedCard = -1;
934
935 }
936
937 //personal sentiment box
938 AddTextInputField(FLOWER_ORDER_PERSONAL_SENT_BOX_X, FLOWER_ORDER_PERSONAL_SENT_BOX_Y, FLOWER_ORDER_PERSONAL_SENT_TEXT_WIDTH, FLOWER_ORDER_PERSONAL_SENT_TEXT_HEIGHT, MSYS_PRIORITY_HIGH + 2, gsSentimentTextField, FLOWER_ORDER_PERSONEL_SENTIMENT_NUM_CHARS, INPUTTYPE_FULL_TEXT);
939
940 //Name box
941 AddTextInputField(FLOWER_ORDER_NAME_TEXT_BOX_X, FLOWER_ORDER_NAME_TEXT_BOX_Y, FLOWER_ORDER_NAME_TEXT_BOX_WIDTH, FLOWER_ORDER_NAME_TEXT_BOX_HEIGHT, MSYS_PRIORITY_HIGH + 2, gsNameTextField, FLOWER_ORDER_NAME_FIELD_NUM_CHARS, INPUTTYPE_FULL_TEXT);
942 }
943
944
DestroyFlowerOrderTextInputBoxes(void)945 static void DestroyFlowerOrderTextInputBoxes(void)
946 {
947 KillTextInputMode();
948 }
949
950
HandleFloristOrderKeyBoardInput(void)951 static void HandleFloristOrderKeyBoardInput(void)
952 {
953 InputAtom InputEvent;
954 while (DequeueEvent(&InputEvent))
955 {
956 if( !HandleTextInput( &InputEvent ) && InputEvent.usEvent == KEY_DOWN )
957 {
958 switch (InputEvent.usParam)
959 {
960 case SDLK_RETURN:
961 GetInputText();
962 break;
963
964 case SDLK_ESCAPE: SetActiveField(0); break;
965
966 default:
967 HandleKeyBoardShortCutsForLapTop( InputEvent.usEvent, InputEvent.usParam, InputEvent.usKeyState );
968 break;
969 }
970 }
971 }
972 }
973
974
975 //Initialize the Florsit Order Page (reset some variables)
InitFloristOrderForm()976 void InitFloristOrderForm()
977 {
978 gfFLoristCheckBox0Down = FALSE; // next day delviery
979 gfFLoristCheckBox1Down = TRUE; // when it gets there delivery
980 gfFLoristCheckBox2Down = FALSE;
981 gfFLoristCheckBox3Down = FALSE;
982 gfFLoristCheckBox4Down = FALSE;
983 gfFLoristCheckBox5Down = FALSE;
984
985 guiFlowerPrice = 0;
986
987 gubCurrentlySelectedFlowerLocation = 0;
988 gbCurrentlySelectedCard = -1;
989
990 gsSentimentTextField = ST::null;
991 gsNameTextField = ST::null;
992 }
993