-
Notifications
You must be signed in to change notification settings - Fork 3
/
verbgui.asc
2591 lines (2280 loc) · 99.8 KB
/
verbgui.asc
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
// Gui Script
#define LANGUAGE_COUNT 8
#define ACT_COUNT 10 // Action Button Count (gMain)
#define MAX_DOORS 99 // How many doors accessed by door script
#define UNHANDLED_MSG_COUNT 21 // Amount of unhandled messages
#define DOORSTRING_COUNT 7 // Amount of door strings
/***********************************************************************
* Distance(int x1, int y1, int x2, int y2)
* Returns the distance between two coordinates
*
***********************************************************************/
static float Geometry::Distance(int x1, int y1, int x2, int y2)
{
int dx = x1 - x2;
int dy = y1 - y2;
return Maths.Sqrt(IntToFloat(dx*dx+dy*dy));
}
/***********************************************************************
* Offset(int point1, int point2)
* Returns the offset between to two given values.
*
***********************************************************************/
static int Geometry::Offset(int point1, int point2)
{
int value = point1 - point2;
if (value<0) return -value;
else return value;
}
// ========================== internal variables =============================
// Please do not edit these option directly anymore, but use the VerbGuiSettings settings script instead!
struct ActionButtonData {
Action action; // Array containg the related actions like eGA_LookAt
int button; // Array containing the verb button Ids
int button_graphic_normal[LANGUAGE_COUNT]; // contains the verb button sprites
int button_graphic_highlight[LANGUAGE_COUNT]; // Contains the highlighted verb button sprites
int action_l_keycode[LANGUAGE_COUNT]; // lower case keycodes for the verbs
int action_u_keycode[LANGUAGE_COUNT]; // upper case keycodes for the verbs
};
ActionButtonData actionButtonData[ACT_COUNT];
struct VerbsData {
eLanguage lang;
int actionLabelColorNormal;
int actionLabelColorHighlighted;
int invUparrowONsprite;
int invUparrowOFFsprite;
int invUparrowHIsprite;
int invDownarrowONsprite;
int invDownarrowOFFsprite;
int invDownarrowHIsprite;
int walkOffScreenOffset;
bool approachCharInteract;
bool NPCfacingPlayer;
bool objHotTalk;
bool classicInvHandling;
bool classicGui;
bool exitDoorDoubleclick;
bool exitExtensionDoubleclick;
bool runOnDoubleClick;
int runCursorDistance;
int runSpeedupRate; //initialized in game_start
int global_action; // containing the current clicked action
int default_action; // default action (most likely walk-to)
int alternative_action; // right-click action
int used_action; // used_action = global_action, if not cancelled
int AGSCursorMode; // used mouse cursor mode
String location_ex; // hovered location name including extension
String location; // hovered location name excluding extension
String location_clicked; // clicked location name including extension
String inv_ex_location; // inventory name including extension
String inv_location; // inventory name location excluding extension
String temp_location; // needed to compare location & clicked location
int location_type; // the result of GetLocationType
int location_id; // on_mouse_click -> location id
int player_walk_x_speed; // Initial walking speed x coordinate
int player_walk_y_speed; // Initial walking speed y coordinate
int player_ani_speed; // Initial animation speed
bool player_is_running; // if character is currently running
bool player_frozen; // player can't move
bool disabled_gui; // GUI disabled
String tresult; // translated result of the action mode, eg. "Look at %s"
String act_object; // action_object - object used in action
String act_item; // inventory item to be used or given
int actionLabelWidth; // Width of the action label in the status bar
InventoryItem*ItemGiven; // Item given to a character
char key_l_yes[LANGUAGE_COUNT]; // translated keys for yes (lower)
char key_u_yes[LANGUAGE_COUNT]; // translated keys for yes (upper)
char key_l_no[LANGUAGE_COUNT]; // translated keys for no (lower)
char key_u_no[LANGUAGE_COUNT]; // translated keys for no (upper)
int door_state[MAX_DOORS];// Array for the door script
String door_strings[DOORSTRING_COUNT]; // default messages for the door script
String unhandled_strings[UNHANDLED_MSG_COUNT]; // default unhandled messages
// Default door sounds
AudioClip* openDoorSound,
closeDoorSound,
unlockDoorSound;
// Guis used by the module (we don't want to use global variables)
GUI* guiAction;
GUI* guiMain;
GUI* guiPause;
GUI* guiQuit;
// Fonts used by the module (we don't want to use global names)
FontType fontText;
FontType fontTextOut;
FontType fontSpeech;
FontType fontOutlineSpeech;
// Screenwidth and Screenhight
int ScreenWidth;
int ScreenHeight;
};
VerbsData verbsData;
// ============================= Helper functions ===========================================
/***********************************************************************
* seti_VerbGuiOptions(this Verbs*, eVerbGuiOptions index, int value)
* sets the template's options for the given index
*
***********************************************************************/
bool seti_VerbGuiOptions(static Verbs, eVerbGuiOptions index, int value)
{
// Template Language
if (index == eVerbGuiTemplateLanguage) verbsData.lang = value;
// colour used in action bar
if (index == eVerbGuiActionLabelColorNormal) verbsData.actionLabelColorNormal = value;
// highlighted colour used in action bar
if (index == eVerbGuiActionLabelColorHighlighted) verbsData.actionLabelColorHighlighted = value;
// sprite slot of the upper inv arrow / normal
if (index == eVerbGuiInvUparrowONsprite) verbsData.invUparrowONsprite = value;
// sprite slot of the upper inv arrow / disabled
if (index == eVerbGuiInvUparrowOFFsprite) verbsData.invUparrowOFFsprite = value;
// sprite slot of the upper inv arrow / highlighted
if (index == eVerbGuiInvUparrowHIsprite) verbsData.invUparrowHIsprite = value;
// sprite slot of the lower inv arrow / normal
if (index == eVerbGuiInvDownarrowONsprite) verbsData.invDownarrowONsprite = value;
// sprite slot of the lower inv arrow / disabled
if (index == eVerbGuiInvDownarrowOFFsprite) verbsData.invDownarrowOFFsprite = value;
// sprite slot of the lower inv arrow / highlighted
if (index == eVerbGuiInvDownarrowHIsprite) verbsData.invDownarrowHIsprite = value;
// offset used by WalkOffScreen and exit extensions
if (index == eVerbGuiWalkOffScreenOffset) verbsData.walkOffScreenOffset = value;
// walk to character before starting interaction
if (index == eVerbGuiApproachCharInteract) verbsData.approachCharInteract = value;
// Non playable characters are facing the player before talk-to and give-to
if (index == eVerbGuiNPCfacingPlayer) verbsData.NPCfacingPlayer = value;
// Enable Talk to Objects and Hotspots
if (index == eVerbGuiObjHotTalk) verbsData.objHotTalk = value;
// turned on: right-click on inv items is lookat, left-click is use
// all other extensions will be ignored
if (index == eVerbGuiClassicInvHandling) verbsData.classicInvHandling = value;
// action bar is fixed like in classic SCUMM games among other things
if (index == eVerbGuiClassicGui) verbsData.classicGui = value;
// Doubleclick on open doors changes room instantly
if (index == eVerbGuiExitDoorDoubleclick) verbsData.exitDoorDoubleclick = value;
// Doubleclick on anything with an exit extension
if (index == eVerbGuiExitExtensionDoubleclick) verbsData.exitExtensionDoubleclick = value;
// Character speed is doubled on doubleclick
if (index == eVerbGuiRunOnDoubleClick) verbsData.runOnDoubleClick = value;
// Distance between mouse cursor and player until running begins
if (index == eVerbGuiRunCursorDistance) verbsData.runCursorDistance = value;
// multiplied to the player movement speed, while running
// 1 = no speedup at all, 2 = double speed and so on
if (index == eVerbGuiRunSpeedupRate) verbsData.runSpeedupRate = value;
}
/***********************************************************************
* geti_VerbGuiOptions(this Verbs*, eVerbGuiOptions index)
* Returns the template's options for the given index
*
***********************************************************************/
int geti_VerbGuiOptions(static Verbs, eVerbGuiOptions index)
{
if (index == eVerbGuiTemplateLanguage) return verbsData.lang;
if (index == eVerbGuiActionLabelColorNormal) return verbsData.actionLabelColorNormal;
if (index == eVerbGuiActionLabelColorHighlighted) return verbsData.actionLabelColorHighlighted;
if (index == eVerbGuiInvUparrowONsprite) return verbsData.invUparrowONsprite;
if (index == eVerbGuiInvUparrowOFFsprite) return verbsData.invUparrowOFFsprite;
if (index == eVerbGuiInvUparrowHIsprite) return verbsData.invUparrowHIsprite;
if (index == eVerbGuiInvDownarrowONsprite) return verbsData.invDownarrowONsprite;
if (index == eVerbGuiInvDownarrowOFFsprite) return verbsData.invDownarrowOFFsprite;
if (index == eVerbGuiInvDownarrowHIsprite) return verbsData.invDownarrowHIsprite;
if (index == eVerbGuiWalkOffScreenOffset) return verbsData.walkOffScreenOffset;
if (index == eVerbGuiApproachCharInteract) return verbsData.approachCharInteract;
if (index == eVerbGuiNPCfacingPlayer) return verbsData.NPCfacingPlayer;
if (index == eVerbGuiObjHotTalk) return verbsData.objHotTalk;
if (index == eVerbGuiClassicInvHandling) return verbsData.classicInvHandling;
if (index == eVerbGuiClassicGui) return verbsData.classicGui;
if (index == eVerbGuiExitDoorDoubleclick) return verbsData.exitDoorDoubleclick;
if (index == eVerbGuiExitExtensionDoubleclick) return verbsData.exitExtensionDoubleclick;
if (index == eVerbGuiRunOnDoubleClick) return verbsData.runOnDoubleClick;
if (index == eVerbGuiRunCursorDistance) return verbsData.runCursorDistance;
if (index == eVerbGuiRunSpeedupRate) return verbsData.runSpeedupRate;
return 0;
}
/***********************************************************************
* seti_VerbGuiUnhandled(this Verbs*, eVerbGuiOptions index, int value)
* sets the messages for the unhandled events
*
***********************************************************************/
bool seti_VerbGuiUnhandled(static Verbs, eVerbGuiUnhandled index, String value)
{
verbsData.unhandled_strings[index] = value;
}
/***********************************************************************
* geti_VerbGuiUnhandled(this Verbs*, eVerbGuiOptions index, int value)
* gets the messages for the unhandled events
*
***********************************************************************/
String geti_VerbGuiUnhandled(static Verbs, eVerbGuiUnhandled index)
{
return verbsData.unhandled_strings[index];
}
/***********************************************************************
* BindGuis(GUI* _gAction, GUI* _gMain, GUI* _gPause, GUI* _gQuit)
* binds the according GUIs to the script. It defines, which GUIs will
* be used for displaying verbs and so on.
*
***********************************************************************/
static void Verbs::BindGuis(GUI* _gAction, GUI* _gMain, GUI* _gPause, GUI* _gQuit)
{
verbsData.guiAction = _gAction;
verbsData.guiMain = _gMain;
verbsData.guiPause = _gPause;
verbsData.guiQuit = _gQuit;
}
/***********************************************************************
* SetFonts(FontType fontText, FontType fontTextOut, FontType fontSpeech, FontType fontOutlineSpeech)
* defines the fonts used be the template
*
***********************************************************************/
static void Verbs::SetFonts(FontType fontText, FontType fontTextOut, FontType fontSpeech, FontType fontOutlineSpeech)
{
verbsData.fontText = fontText;
verbsData.fontTextOut = fontTextOut;
verbsData.fontSpeech = fontSpeech;
verbsData.fontOutlineSpeech = fontOutlineSpeech;
}
/***********************************************************************
* GetButtonAction(int action)
* Returns the connected action of a verb button.
*
***********************************************************************/
static int Verbs::GetButtonAction(Button* button)
{
if (button.OwningGUI != verbsData.guiMain) {
AbortGame("This button is not part of the Tumbleweed verbs GUI");
}
for (int action=0; action< ACT_COUNT; action++) {
if (actionButtonData[action].button == button.ID) {
return actionButtonData[action].action;
}
}
AbortGame("Could not find the action corresonding to this button.");
}
/***********************************************************************
* DisableGui()
* This functions disables the GUI (but does not necessarily hides it)
*
***********************************************************************/
static void Verbs::DisableGui()
{
verbsData.disabled_gui=true;
}
/***********************************************************************
* EnableGui()
* This functions enables the GUI (but does not necessarily makes it visible).
*
***********************************************************************/
static void Verbs::EnableGui()
{
verbsData.disabled_gui=false;
}
/***********************************************************************
* IsGuiDisabled()
* Returns true, if the GUI is currently disabled, false otherwise
*
***********************************************************************/
static bool Verbs::IsGuiDisabled()
{
return verbsData.disabled_gui;
}
/***********************************************************************
* ShowGui()
* Shows the verbs GUI and enables it
*
***********************************************************************/
static void Verbs::ShowGui()
{
Verbs.EnableGui();
verbsData.guiMain.Visible=true;
verbsData.guiAction.Visible=true;
Wait(1);
}
/***********************************************************************
* ShowGui()
* Hides the verbs GUI and disables it
*
***********************************************************************/
static void Verbs::HideGui()
{
Verbs.DisableGui();
verbsData.guiMain.Visible=false;
verbsData.guiAction.Visible=false;
}
/***********************************************************************
* IsGuiDisabled()
* Returns true, if the GUI is currently visibale, false otherwise
*
***********************************************************************/
static bool Verbs::IsGuiVisible()
{
return verbsData.guiMain.Visible;
}
/***********************************************************************
* HandleInvArrows()
* Takes care of showing or hiding the inventory scroll sprites
*
***********************************************************************/
static void Verbs::HandleInvArrows()
{
// change the arrows in the inventory to show if you
// can scroll the inventory:
if (invMain.TopItem > 0) {
// if inventory can scroll up
btnInvUp.NormalGraphic = verbsData.invUparrowONsprite;
btnInvUp.MouseOverGraphic = verbsData.invUparrowHIsprite;
if (InventoryItem.GetAtScreenXY(verbsData.guiMain.X + invMain.X + 1, verbsData.guiMain.Y + invMain.Y + 1) == null) invMain.TopItem -= invMain.ItemsPerRow;
}
else {
btnInvUp.NormalGraphic = verbsData.invUparrowOFFsprite;
btnInvUp.MouseOverGraphic = verbsData.invUparrowOFFsprite;
}
//if inv can scroll down
if (invMain.TopItem < invMain.ItemCount-(invMain.ItemsPerRow * invMain.RowCount)) {
btnInvDown.NormalGraphic = verbsData.invDownarrowONsprite;
btnInvDown.MouseOverGraphic = verbsData.invDownarrowHIsprite;
}
else{
btnInvDown.NormalGraphic = verbsData.invDownarrowOFFsprite;
btnInvDown.MouseOverGraphic = verbsData.invDownarrowOFFsprite;
}
}
// ============================= door init functions ===========================================
/***********************************************************************
* seti_VerbGuiUnhandled(this Verbs*, eVerbGuiOptions index, int value)
* sets the messages for the unhandled events
*
***********************************************************************/
bool seti_DoorStrings(static Doors, eDoorStrings index, String value)
{
if (!String.IsNullOrEmpty(value)) verbsData.door_strings[index] = value;
}
/***********************************************************************
* geti_VerbGuiUnhandled(this Verbs*, eVerbGuiOptions index, int value)
* gets the messages for the unhandled events
*
***********************************************************************/
String geti_DoorStrings(static Doors, eDoorStrings index)
{
return verbsData.door_strings[index];
}
/***********************************************************************
* SetDoorState(int door_id, int value)
* Call this function to set a door state for the given door_id. A door can have 3 different states:
* 0 = The door is closed
* 1 = The door is open
* 2 = The door is closed and locked
*
***********************************************************************/
static void Doors::SetDoorState(int door_id, int value)
{
verbsData.door_state[door_id] = value;
}
/***********************************************************************
* GetDoorState(int door_id)
* Returns the current state of a door.
*
***********************************************************************/
static int Doors::GetDoorState(int door_id)
{
return verbsData.door_state[door_id];
}
/***********************************************************************
* InitObject (int door_id, int obj)
* Used to set up the corresponding object, used by the door with the given id.
* If the state of the door is closed, the object will be invisible.
* Otherwise, the object will be shown. The object stays unclickable all the time.
*
***********************************************************************/
static void Doors::InitObject (int door_id, int obj)
{
if (Doors.GetDoorState(door_id) == 1) {
object[obj].Visible=true;
object[obj].Clickable=false;
}
else {
object[obj].Visible=false;
object[obj].Clickable=false;
}
}
// ============================= verb action functions ===========================================
/***********************************************************************
* TranslateAction(int action, int tr_lang)
* This function defines the text for the verb buttons, e.g. if you click on the talk verb button,
* "Talk to" is being displayed in the action/status bar. The second parameter defines the returned language.
* If you want to customize this text, you have to edit this function.
*
***********************************************************************/
static void Verbs::TranslateAction(int action, int tr_lang)
{
if (tr_lang == eLangDE) {
if (action == eGA_WalkTo) verbsData.tresult="Gehe zu %s";
else if (action == eGA_LookAt) verbsData.tresult="Schau %s an";
else if (action == eGA_TalkTo) verbsData.tresult="Rede mit %s";
else if (action == eGA_GiveTo) {
if (verbsData.act_item.Length > 0) verbsData.tresult="Gib !s an %s";
else verbsData.tresult="Gib %s";
}
else if (action == eGA_PickUp) verbsData.tresult="Nimm %s";
else if (action == eGA_Use) {
if (verbsData.act_item.Length > 0) verbsData.tresult="Benutze !s mit %s";
else verbsData.tresult="Benutze %s";
}
else if (action == eGA_Open) verbsData.tresult="Öffne %s";
else if (action == eGA_Close) verbsData.tresult="Schließe %s";
else if (action == eGA_Push) verbsData.tresult="Drücke %s";
else if (action == eGA_Pull) verbsData.tresult="Ziehe %s";
else verbsData.tresult=" ";
}
else if (tr_lang == eLangES) {
if (action == eGA_WalkTo) verbsData.tresult="Ir a %s";
else if (action == eGA_LookAt) verbsData.tresult="Mirar %s";
else if (action == eGA_TalkTo) verbsData.tresult="Hablar con %s";
else if (action == eGA_GiveTo) {
if (verbsData.act_item.Length > 0) verbsData.tresult="Dar !s a %s";
else verbsData.tresult="Dar %s";
}
else if (action == eGA_PickUp) verbsData.tresult="Coger %s";
else if (action == eGA_Use) {
if (verbsData.act_item.Length > 0) verbsData.tresult="Usar !s con %s";
else verbsData.tresult="Usar %s";
}
else if (action == eGA_Open) verbsData.tresult="Abrir %s";
else if (action == eGA_Close) verbsData.tresult="Cerrar %s";
else if (action == eGA_Push) verbsData.tresult="Empujar %s";
else if (action == eGA_Pull) verbsData.tresult="Tirar de %s";
else verbsData.tresult=" ";
}
else if (tr_lang == eLangFR) {
if (action == eGA_WalkTo) verbsData.tresult="Aller vers %s";
else if (action == eGA_LookAt) verbsData.tresult="Regarder %s";
else if (action == eGA_TalkTo) verbsData.tresult="Parler à %s";
else if (action == eGA_GiveTo) {
if (verbsData.act_item.Length>0) verbsData.tresult="Donner !s à %s";
else verbsData.tresult="Donner %s";
}
else if (action == eGA_PickUp) verbsData.tresult="Prendre %s";
else if (action == eGA_Use) {
if (verbsData.act_item.Length>0) verbsData.tresult="Utiliser !s sur %s";
else verbsData.tresult="Utiliser %s";
}
else if (action == eGA_Open) verbsData.tresult="Ouvrir %s";
else if (action == eGA_Close) verbsData.tresult="Fermer %s";
else if (action == eGA_Push) verbsData.tresult="Pousser %s";
else if (action == eGA_Pull) verbsData.tresult="Tirer %s";
else verbsData.tresult=" ";
}
else if (tr_lang == eLangIT) {
if (action == eGA_WalkTo) verbsData.tresult="Vai a %s";
else if (action == eGA_LookAt) verbsData.tresult="Esamina %s";
else if (action == eGA_TalkTo) verbsData.tresult="Parla con %s";
else if (action == eGA_GiveTo) {
if (verbsData.act_item.Length > 0) verbsData.tresult="Dai !s a %s";
else verbsData.tresult="Dai %s";
}
else if (action == eGA_PickUp) verbsData.tresult="Raccogli %s";
else if (action == eGA_Use) {
if (verbsData.act_item.Length > 0) verbsData.tresult="Usa !s con %s";
else verbsData.tresult="Usa %s";
}
else if (action == eGA_Open) verbsData.tresult="Apri %s";
else if (action == eGA_Close) verbsData.tresult="Ferma %s";
else if (action == eGA_Push) verbsData.tresult="Premi %s";
else if (action == eGA_Pull) verbsData.tresult="Tira %s";
else verbsData.tresult=" ";
}
else if (tr_lang == eLangPT) {
if (action == eGA_WalkTo) verbsData.tresult="Ir para %s";
else if (action == eGA_LookAt) verbsData.tresult="Olhar para %s";
else if (action == eGA_TalkTo) verbsData.tresult="Falar com %s";
else if (action == eGA_GiveTo) {
if (verbsData.act_item.Length > 0) verbsData.tresult="Dar !s a %s";
else verbsData.tresult="Dar %s";
}
else if (action == eGA_PickUp) verbsData.tresult="Apanhar %s";
else if (action == eGA_Use) {
if (verbsData.act_item.Length > 0) verbsData.tresult="Usar !s com %s";
else verbsData.tresult="Usar %s";
}
else if (action == eGA_Open) verbsData.tresult="Abrir %s";
else if (action == eGA_Close) verbsData.tresult="Fechar %s";
else if (action == eGA_Push) verbsData.tresult="Empurrar %s";
else if (action == eGA_Pull) verbsData.tresult="Puxar %s";
else verbsData.tresult=" ";
}
else if (tr_lang == eLangNL) {
if (action == eGA_WalkTo) verbsData.tresult="Ga naar %s";
else if (action == eGA_LookAt) verbsData.tresult="Bekijk %s";
else if (action == eGA_TalkTo) verbsData.tresult="Praat met %s";
else if (action == eGA_GiveTo) {
if (verbsData.act_item.Length>0) verbsData.tresult="Geef !s aan %s";
else verbsData.tresult="Geef %s";
}
else if (action == eGA_PickUp) verbsData.tresult="Pak %s";
else if (action == eGA_Use) {
if (verbsData.act_item.Length>0) verbsData.tresult="Gebruik !s met %s";
else verbsData.tresult="Gebruik %s";
}
else if (action == eGA_Open) verbsData.tresult="Open %s";
else if (action == eGA_Close) verbsData.tresult="Sluit %s";
else if (action == eGA_Push) verbsData.tresult="Duw %s";
else if (action == eGA_Pull) verbsData.tresult="Trek %s";
else verbsData.tresult=" ";
}
else {
if (action == eGA_WalkTo) verbsData.tresult="Walk to %s";
else if (action == eGA_LookAt) verbsData.tresult="Look at %s";
else if (action == eGA_TalkTo) verbsData.tresult="Talk to %s";
else if (action == eGA_GiveTo) {
if (verbsData.act_item.Length > 0) verbsData.tresult="Give !s to %s";
else verbsData.tresult="Give %s";
}
else if (action == eGA_PickUp) verbsData.tresult="Pick up %s";
else if (action == eGA_Use) {
if (verbsData.act_item.Length > 0) verbsData.tresult="Use !s with %s";
else verbsData.tresult="Use %s";
}
else if (action == eGA_Open) verbsData.tresult="Open %s";
else if (action == eGA_Close) verbsData.tresult="Close %s";
else if (action == eGA_Push) verbsData.tresult="Push %s";
else if (action == eGA_Pull) verbsData.tresult="Pull %s";
else verbsData.tresult=" ";
}
// fill object and item into action template
verbsData.tresult = GetTranslation(verbsData.tresult);
int ip = verbsData.tresult.IndexOf("!s");
if (ip >= 0) {
int op = verbsData.tresult.Contains("%s");
verbsData.tresult = verbsData.tresult.ReplaceCharAt(ip, '%');
if (ip < op) verbsData.tresult=String.Format(verbsData.tresult, verbsData.act_item, verbsData.act_object);
else verbsData.tresult=String.Format(verbsData.tresult, verbsData.act_object, verbsData.act_item);
}
else {
if (verbsData.act_object == null) verbsData.act_object = "";
verbsData.tresult=String.Format(verbsData.tresult, verbsData.act_object);
}
}
/***********************************************************************
* IsAction(Action test_action)
* Used to check, if the current action is the one, given in the parameter.
*
***********************************************************************/
static bool Verbs::IsAction(Action test_action)
{
return verbsData.global_action == test_action;
}
/***********************************************************************
* UsedAction(Action test_action)
* Used to determine, which action has been selected by the player.
* Instead of checking cursor modes, this function is used.
*
***********************************************************************/
static bool Verbs::UsedAction(Action test_action)
{
return (( verbsData.used_action == test_action) && ( verbsData.AGSCursorMode != eModeUseinv)) ||
((test_action == eGA_UseInv) && ( verbsData.used_action == eGA_Use) && ( verbsData.AGSCursorMode == eModeUseinv)) ||
((test_action == eGA_GiveTo) && ( verbsData.used_action == eGA_GiveTo) && ( verbsData.AGSCursorMode == eModeUseinv) && verbsData.ItemGiven!=null);
}
/***********************************************************************
* SetAction(Action new_action)
* Since the cursor modes are bypassed, this function defines the current action.
* Among other things, this function is called by clicking a verb button.
*
***********************************************************************/
static void Verbs::SetAction(Action new_action)
{
// set default action
if (new_action == eGA_Default) new_action= verbsData.default_action;
// set corresponding cursormode
if (new_action == eGA_WalkTo) mouse.Mode=eModeUsermode2;
else if (new_action == eGA_LookAt) mouse.Mode=eModeLookat;
else if (new_action == eGA_TalkTo) mouse.Mode=eModeTalkto;
else if (new_action == eGA_GiveTo) mouse.Mode=eModeInteract;
else if (new_action == eGA_PickUp) mouse.Mode=eModePickup;
else if (new_action == eGA_Use) mouse.Mode=eModeInteract;
else if (new_action == eGA_Open) mouse.Mode=eModeUsermode1;
else if (new_action == eGA_Close) mouse.Mode=eModeUsermode1;
else if (new_action == eGA_Push) mouse.Mode=eModeUsermode1;
else if (new_action == eGA_Pull) mouse.Mode=eModeUsermode1;
// save action
verbsData.global_action=new_action;
}
/***********************************************************************
* SetDefaultAction(Action def_action)
* Used to define, which action is being used, if no verb has been clicked.
* Usually this is walk to.
*
***********************************************************************/
static void Verbs::SetDefaultAction(Action def_action)
{
verbsData.default_action = def_action;
Verbs.SetAction(eGA_Default);
}
/***********************************************************************
* Action GetUsedAction()
* Returns directly which action was selected by the player
*
***********************************************************************/
static Action Verbs::GetUsedAction() {
if(Verbs.UsedAction(eGA_WalkTo)){
return eGA_WalkTo;
}
else if(Verbs.UsedAction(eGA_LookAt)){
return eGA_LookAt;
}
else if(Verbs.UsedAction(eGA_TalkTo)){
return eGA_TalkTo;
}
else if(Verbs.UsedAction(eGA_GiveTo)){
return eGA_GiveTo;
}
else if(Verbs.UsedAction(eGA_PickUp)){
return eGA_PickUp;
}
else if(Verbs.UsedAction(eGA_Use)){
return eGA_Use;
}
else if(Verbs.UsedAction(eGA_UseInv)){
return eGA_UseInv;
}
else if(Verbs.UsedAction(eGA_Open)){
return eGA_Open;
}
else if(Verbs.UsedAction(eGA_Close)){
return eGA_Close;
}
else if(Verbs.UsedAction(eGA_Push)){
return eGA_Push;
}
else if(Verbs.UsedAction(eGA_Pull)){
return eGA_Pull;
}
return -1;
}
/***********************************************************************
* Action GetItemGiven()
* Returns the item that has been given by the player. It's more or less player.ActiveInventory with more subtle logic
*
***********************************************************************/
static InventoryItem* Verbs::GetItemGiven()
{
return verbsData.ItemGiven;
}
// ============================= GlobalCondition ===========================================
/***********************************************************************
* GlobalCondition(eGlobCond condition)
* Used to check for conditions that are used many times in the script.
* For example, its used to check, if the mouse cursor is in the inventory and the mode walk or pickup are selected.
* Returns 1, if the condition is true and 0 otherwise.
*
***********************************************************************/
static int Verbs::GlobalCondition(eGlobCond condition)
{
// here are some conditions that are used many times in the script
int cond;
InventoryItem*ii = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
GUIControl*gc = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
int gcid = -1;
if (gc != null) gcid = gc.ID;
// if the mouse is in the inventory and mode Walk is selected
if (condition == eGlob_MouseInvWalk ) {
cond = (ii != null && (Verbs.IsAction(eGA_WalkTo)));
}
// if the mouse is in the inventory and mode Pickup is selected
else if (condition == eGlob_MouseInvPickup) {
cond = (ii != null && (Verbs.IsAction(eGA_PickUp)));
}
// if the mode is useinv and the mouse is over the active inv (like "use knife on knife")
else if (condition == eGlob_InvOnInv) {
cond =(player.ActiveInventory == ii && Mouse.Mode == eModeUseinv);
}
// if the mode is talk or "Give", and the mouse isnt over a character
else if (condition == eGlob_GiveTalkNoChar) {
if ( verbsData.objHotTalk && Verbs.IsAction(eGA_TalkTo) ) {
cond = false;
}
else {
cond =((Verbs.IsAction(eGA_TalkTo) || (Verbs.IsAction(eGA_GiveTo) && (Mouse.Mode == eModeUseinv))) && (GetLocationType(mouse.x, mouse.y) != eLocationCharacter));
}
}
// if its GIVE and the mouse isnt over a inv.item
else if (condition == eGlob_GiveNoInv)
cond = ((Mouse.Mode == eModeInteract) && Verbs.IsAction(eGA_GiveTo) && (ii == null));
// if the mouse is in the inventory and mode TalkTo is selected
else if (condition == eGlob_InvTalk)
cond = (ii != null && (Verbs.IsAction(eGA_TalkTo)));
return cond;
}
// ============================= Verb Extensions and actions ===========================================
/***********************************************************************
* ExtensionEx(int index, String name)
* Returns the n-th extension of the given string.
*
***********************************************************************/
static char Verbs::ExtensionEx(int index, String name)
{
//returns the extension in the position 'index' of the string 'name'.
//returns 0 if the name has no extension or if you passed an empty string.
if (name.Length == 0) return 0;//if you passed an empty string
int pos;
pos = name.IndexOf(">");
if (pos == -1) return 0;
else if (pos+index<name.Length) return name.Chars[pos+index];
else return 0;
}
/***********************************************************************
* Extension()
* Returns the first extention of the location
*
***********************************************************************/
static char Verbs::Extension()
{
// Check the (first) extension (>*) of a string
return Verbs.ExtensionEx(1, verbsData.location);
}
/***********************************************************************
* RemoveExtension()
* Used to remove the extension from a location (Hotspots, Objects etc.), so it doesnt get displayed in the status bar.
*
***********************************************************************/
static int Verbs::RemoveExtension()
{
//removes the extension of a string
int pos = verbsData.location.IndexOf(">");
int length = verbsData.location.Length;
if (Verbs.Extension() != 0) verbsData.location = verbsData.location.Truncate(pos);
return pos;
}
/***********************************************************************
* AddExtension()
* Used to add a default extension in case the location doesnt have one.
*
***********************************************************************/
static void Verbs::AddExtension(char extension)
{
//adds an extension to a thing that doesn't have one
int length=verbsData.location.Length;
if (Verbs.Extension() == 0) {
verbsData.location=verbsData.location.Append(">n");
verbsData.location=verbsData.location.ReplaceCharAt(length+1, extension);
}
}
/***********************************************************************
* SetAlternativeAction(char extension, Action alt_action)
* This function makes the right-click shortcuts work.
* If you use extensions like >p (e.g. pickup), this function makes sure, that the correct verb button is highlighted.
*
***********************************************************************/
static void Verbs::SetAlternativeAction(char extension, Action alt_action)
{
if (alt_action == eGA_Default) {
if (Verbs.Extension() == extension)
verbsData.alternative_action = alt_action;
}
else {
int button = actionButtonData[alt_action].button;
int normalbuttonpic = actionButtonData[alt_action].button_graphic_normal[verbsData.lang];
int overbuttonpic = actionButtonData[alt_action].button_graphic_highlight[verbsData.lang];
// used for setting the default action given the extension.
GUIControl*gc = verbsData.guiMain.Controls[button];
Button*b = gc.AsButton;
if (Verbs.Extension() == extension) {
b.NormalGraphic = overbuttonpic;
verbsData.alternative_action = alt_action;
}
else b.NormalGraphic = normalbuttonpic;
b.MouseOverGraphic = overbuttonpic;
}
}
/***********************************************************************
* OpenCloseExtension(int door_id)
* Used in combination with the door scripts. This function returns a close extension, if the door with the given id is open and vice versa.
*
***********************************************************************/
static void Verbs::OpenCloseExtension(int door_id)
{
if ((Doors.GetDoorState(door_id)==0) || (Doors.GetDoorState(door_id)==2)) Verbs.AddExtension('o');
else Verbs.AddExtension('c');
}
/***********************************************************************
* VariableExtensions(
* This function is called, if you have have set "v" as an extension for a certain location.
* Currently it is used for the OpenClose extension, but of course you can add your own variable extensions here,
* for example "turn on / turn off"
*
***********************************************************************/
static void Verbs::VariableExtensions()
{
//player.Say(
//sanity check this and implement it
if (OvenHasBeenOpened == false)
{
if (object[0].Visible == true) //window is open
{
//action should be "close"
Verbs.AddExtension('c');
}
else if (object[0].Visible == false) //window is closed
{
//action should be "open"
Verbs.AddExtension('o');
}
}
else if (OvenHasBeenOpened == true)
{
//player.Say("Debug!! oven NOT opened");
if (WindowHasBeenLookedOut == false)
{
//action should be "look"
Verbs.AddExtension('l');
}
else if (WindowHasBeenLookedOut == true)
{
if (object[0].Visible == true) //window is open
{
if (player.HasInventory(iBurger) == false)
{
//action should be "use"
Verbs.AddExtension('u');
}
else
{
//action should be "close" //all tasks are done so window is just a toggle now
Verbs.AddExtension('c');
}
}
else if (object[0].Visible == false) //window is closed
{
//action should be "open"
Verbs.AddExtension('o');
}
}
}
/*
// define here, which things will use a variable extension (>v)
// by default, it's only used for doors.
int r = player.Room;
Object*oo = Object.GetAtScreenXY(mouse.x, mouse.y);
int o=0;
if (oo != null) o = oo.ID;
Hotspot*hh = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
int h = hh.ID;
// Other possible extensions could be: Turn On/Turn Off
// Open/Close Extension:
// Room | Hotspot |(Door_id)
// if (r==4 && h == 2) Verbs.OpenCloseExtension (10);
if (r==4 && h == 2) Verbs.AddExtension('c');
//else if (r==2 && h == 2) OpenCloseExtension (3);
*/
}
/***********************************************************************
* CheckDefaultAction()
* This function checks for a given extension in hotspots, objects and characters.
* If there isnt an extension, a default action is given, e.g. Talk to if the mouse is over a character.
* In case of a given extension, the default actions are being overridden.
*
***********************************************************************/
static void Verbs::CheckDefaultAction()
{
// you could want to change which extension activates which default action, or which button sprite