Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2022
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 104.63 KB | Gaming | 0 0
  1. // Gui Script
  2. #define LANGUAGE_COUNT 8
  3. #define ACT_COUNT 10  // Action Button Count (gMain)
  4. #define MAX_DOORS 99  // How many doors accessed by door script
  5. #define UNHANDLED_MSG_COUNT 21 // Amount of unhandled messages
  6. #define DOORSTRING_COUNT 7     // Amount of door strings
  7.  
  8.  
  9. /***********************************************************************
  10.  * Distance(int x1, int y1, int x2, int y2)
  11.  * Returns the distance between two coordinates
  12.  *
  13.  ***********************************************************************/
  14. static float Geometry::Distance(int x1, int y1, int x2, int y2)
  15. {
  16.   int dx = x1 - x2;
  17.   int dy = y1 - y2;
  18.   return Maths.Sqrt(IntToFloat(dx*dx+dy*dy));
  19. }
  20.  
  21. /***********************************************************************
  22.  * Offset(int point1, int point2)
  23.  * Returns the offset between to two given values.
  24.  *
  25.  ***********************************************************************/
  26. static int Geometry::Offset(int point1, int point2)
  27. {
  28.   int value = point1 - point2;
  29.  
  30.   if (value<0) return -value;
  31.   else return value;
  32. }
  33.  
  34. // ========================== internal variables =============================
  35. // Please do not edit these option directly anymore, but use the VerbGuiSettings settings script instead!
  36.  
  37.  
  38.  
  39. struct ActionButtonData {
  40.     Action action;  // Array containg the related actions like eGA_LookAt
  41.     int button; // Array containing the verb button Ids
  42.    
  43.     int button_graphic_normal[LANGUAGE_COUNT];     // contains the verb button sprites
  44.     int button_graphic_highlight[LANGUAGE_COUNT];  // Contains the highlighted verb button sprites
  45.     int action_l_keycode[LANGUAGE_COUNT]; // lower case keycodes for the verbs
  46.     int action_u_keycode[LANGUAGE_COUNT]; // upper case keycodes for the verbs
  47.    
  48. };
  49.  
  50. ActionButtonData actionButtonData[ACT_COUNT];
  51.  
  52.  
  53. struct VerbsData {
  54.        
  55.      
  56.     eLanguage lang;          
  57.     int actionLabelColorNormal;  
  58.     int actionLabelColorHighlighted;
  59.     int invUparrowONsprite;
  60.     int invUparrowOFFsprite;
  61.     int invUparrowHIsprite;
  62.     int invDownarrowONsprite;      
  63.     int invDownarrowOFFsprite;
  64.     int invDownarrowHIsprite;
  65.     int walkOffScreenOffset;
  66.     bool approachCharInteract;
  67.     bool NPCfacingPlayer;  
  68.     bool objHotTalk;
  69.     bool classicInvHandling;  
  70.     bool classicGui;
  71.  
  72.     bool exitDoorDoubleclick;
  73.     bool exitExtensionDoubleclick;
  74.     bool runOnDoubleClick;
  75.     int runCursorDistance;
  76.     int runSpeedupRate;       //initialized in game_start
  77.  
  78.     int global_action;        // containing the current clicked action
  79.     int default_action;       // default action (most likely walk-to)
  80.     int alternative_action;   // right-click action
  81.     int used_action;          // used_action = global_action, if not cancelled
  82.     int AGSCursorMode;        // used mouse cursor mode
  83.  
  84.     String location_ex;       // hovered  location name including extension
  85.     String location;          // hovered  location name excluding extension
  86.     String location_clicked;  // clicked location name including extension
  87.     String inv_ex_location;   // inventory name including extension
  88.     String inv_location;      // inventory name location excluding extension
  89.  
  90.     String temp_location;     // needed to compare location & clicked location
  91.  
  92.     int location_type;        // the result of GetLocationType
  93.     int location_id;          // on_mouse_click -> location id
  94.  
  95.     int player_walk_x_speed;  // Initial walking speed x coordinate
  96.     int player_walk_y_speed;  // Initial walking speed y coordinate
  97.     int player_ani_speed;     // Initial animation speed
  98.     bool player_is_running;   // if character is currently running
  99.  
  100.  
  101.     bool player_frozen;       // player can't move
  102.     bool disabled_gui;        // GUI disabled
  103.    
  104.  
  105.    
  106.     String tresult;           // translated result of the action mode, eg. "Look at %s"
  107.     String act_object;        // action_object - object used in action
  108.     String act_item;          // inventory item to be used or given
  109.     int actionLabelWidth; // Width of the action label in the status bar
  110.  
  111.  
  112.     InventoryItem*ItemGiven;        // Item given to a character
  113.     char key_l_yes[LANGUAGE_COUNT]; // translated keys for yes (lower)
  114.     char key_u_yes[LANGUAGE_COUNT]; // translated keys for yes (upper)
  115.     char key_l_no[LANGUAGE_COUNT]; // translated keys for no (lower)
  116.     char key_u_no[LANGUAGE_COUNT];  // translated keys for no (upper)
  117.  
  118.     int door_state[MAX_DOORS];// Array for the door script
  119.     String door_strings[DOORSTRING_COUNT];   // default messages for the door script
  120.  
  121.     String unhandled_strings[UNHANDLED_MSG_COUNT]; // default unhandled messages
  122.  
  123.     // Default door sounds
  124.     AudioClip*  openDoorSound,  
  125.                 closeDoorSound,
  126.                 unlockDoorSound;
  127.    
  128.     // Guis used by the module (we don't want to use global variables)
  129.     GUI* guiAction;
  130.     GUI* guiMain;
  131.     GUI* guiPause;
  132.     GUI* guiQuit;
  133.    
  134.     // Fonts used by the module (we don't want to use global names)
  135.     FontType fontText;
  136.     FontType fontTextOut;
  137.     FontType fontSpeech;
  138.     FontType fontOutlineSpeech;
  139.    
  140.  
  141.    
  142. };
  143. VerbsData verbsData;
  144.  
  145.  
  146.  
  147.  
  148.            
  149. // ============================= Helper functions ===========================================
  150.  
  151. /***********************************************************************
  152.  * seti_VerbGuiOptions(this Verbs*, eVerbGuiOptions index,  int value)
  153.  * sets the template's options for the given index
  154.  *
  155.  ***********************************************************************/
  156. bool seti_VerbGuiOptions(static Verbs, eVerbGuiOptions index,  int value)
  157. {
  158.   // Template Language
  159.   if (index == eVerbGuiTemplateLanguage) verbsData.lang = value;
  160.  
  161.   // colour used in action bar
  162.   if (index == eVerbGuiActionLabelColorNormal) verbsData.actionLabelColorNormal = value;
  163.  
  164.   // highlighted colour used in action bar
  165.   if (index == eVerbGuiActionLabelColorHighlighted) verbsData.actionLabelColorHighlighted = value;
  166.  
  167.  
  168.   // sprite slot of the upper inv arrow / normal
  169.   if (index == eVerbGuiInvUparrowONsprite) verbsData.invUparrowONsprite = value;
  170.   // sprite slot of the upper inv arrow / disabled
  171.   if (index == eVerbGuiInvUparrowOFFsprite) verbsData.invUparrowOFFsprite = value;
  172.   // sprite slot of the upper inv arrow / highlighted
  173.   if (index == eVerbGuiInvUparrowHIsprite) verbsData.invUparrowHIsprite = value;
  174.  
  175.  
  176.   // sprite slot of the lower inv arrow / normal
  177.   if (index == eVerbGuiInvDownarrowONsprite) verbsData.invDownarrowONsprite = value;
  178.   // sprite slot of the lower inv arrow / disabled
  179.   if (index == eVerbGuiInvDownarrowOFFsprite) verbsData.invDownarrowOFFsprite = value;
  180.   // sprite slot of the lower inv arrow / highlighted
  181.   if (index == eVerbGuiInvDownarrowHIsprite) verbsData.invDownarrowHIsprite = value;
  182.  
  183.   // offset used by WalkOffScreen and exit extensions
  184.   if (index == eVerbGuiWalkOffScreenOffset) verbsData.walkOffScreenOffset = value;
  185.  
  186.   // walk to character before starting interaction
  187.   if (index == eVerbGuiApproachCharInteract) verbsData.approachCharInteract = value;
  188.  
  189.   // Non playable characters are facing the player before talk-to and give-to
  190.   if (index == eVerbGuiNPCfacingPlayer) verbsData.NPCfacingPlayer = value;
  191.  
  192.   // Enable Talk to Objects and Hotspots
  193.   if (index == eVerbGuiObjHotTalk)  verbsData.objHotTalk = value;
  194.  
  195.   // turned on: right-click on inv items is lookat, left-click is use
  196.   // all other extensions will be ignored
  197.   if (index == eVerbGuiClassicInvHandling)  verbsData.classicInvHandling = value;
  198.  
  199.   // action bar is fixed like in classic SCUMM games among other things
  200.   if (index == eVerbGuiClassicGui)  verbsData.classicGui = value;
  201.  
  202.   // Doubleclick on open doors changes room instantly
  203.   if (index == eVerbGuiExitDoorDoubleclick)  verbsData.exitDoorDoubleclick = value;
  204.  
  205.   // Doubleclick on anything with an exit extension
  206.   if (index == eVerbGuiExitExtensionDoubleclick)  verbsData.exitExtensionDoubleclick = value;
  207.  
  208.   // Character speed is doubled on doubleclick
  209.   if (index == eVerbGuiRunOnDoubleClick)  verbsData.runOnDoubleClick = value;
  210.  
  211.   // Distance between mouse cursor and player until running begins
  212.   if (index == eVerbGuiRunCursorDistance)  verbsData.runCursorDistance = value;
  213.  
  214.   // multiplied to the player movement speed, while running
  215.   // 1 = no speedup at all, 2 = double speed and so on
  216.   if (index == eVerbGuiRunSpeedupRate)  verbsData.runSpeedupRate = value;
  217.  
  218. }
  219.  
  220. /***********************************************************************
  221.  * geti_VerbGuiOptions(this Verbs*, eVerbGuiOptions index)
  222.  * Returns the template's options for the given index
  223.  *
  224.  ***********************************************************************/
  225. int geti_VerbGuiOptions(static Verbs, eVerbGuiOptions index)
  226. {
  227.   if (index == eVerbGuiTemplateLanguage) return verbsData.lang;
  228.   if (index == eVerbGuiActionLabelColorNormal) return verbsData.actionLabelColorNormal;
  229.   if (index == eVerbGuiActionLabelColorHighlighted) return verbsData.actionLabelColorHighlighted;
  230.   if (index == eVerbGuiInvUparrowONsprite) return verbsData.invUparrowONsprite;
  231.   if (index == eVerbGuiInvUparrowOFFsprite) return verbsData.invUparrowOFFsprite;
  232.   if (index == eVerbGuiInvUparrowHIsprite) return verbsData.invUparrowHIsprite;
  233.   if (index == eVerbGuiInvDownarrowONsprite) return verbsData.invDownarrowONsprite;
  234.   if (index == eVerbGuiInvDownarrowOFFsprite) return verbsData.invDownarrowOFFsprite;
  235.   if (index == eVerbGuiInvDownarrowHIsprite) return verbsData.invDownarrowHIsprite;
  236.   if (index == eVerbGuiWalkOffScreenOffset) return verbsData.walkOffScreenOffset;
  237.   if (index == eVerbGuiApproachCharInteract) return verbsData.approachCharInteract;
  238.   if (index == eVerbGuiNPCfacingPlayer) return verbsData.NPCfacingPlayer;
  239.   if (index == eVerbGuiObjHotTalk) return  verbsData.objHotTalk;
  240.   if (index == eVerbGuiClassicInvHandling) return  verbsData.classicInvHandling;
  241.   if (index == eVerbGuiClassicGui) return  verbsData.classicGui;
  242.   if (index == eVerbGuiExitDoorDoubleclick) return  verbsData.exitDoorDoubleclick;
  243.   if (index == eVerbGuiExitExtensionDoubleclick) return  verbsData.exitExtensionDoubleclick;
  244.   if (index == eVerbGuiRunOnDoubleClick) return  verbsData.runOnDoubleClick;
  245.   if (index == eVerbGuiRunCursorDistance) return  verbsData.runCursorDistance;
  246.   if (index == eVerbGuiRunSpeedupRate) return  verbsData.runSpeedupRate;
  247.   return 0;
  248. }
  249.  
  250. /***********************************************************************
  251.  * seti_VerbGuiUnhandled(this Verbs*, eVerbGuiOptions index,  int value)
  252.  * sets the messages for the unhandled events
  253.  *
  254.  ***********************************************************************/
  255. bool seti_VerbGuiUnhandled(static Verbs, eVerbGuiUnhandled index, String value)
  256. {
  257.   verbsData.unhandled_strings[index] = value;
  258. }
  259.  
  260. /***********************************************************************
  261.  * geti_VerbGuiUnhandled(this Verbs*, eVerbGuiOptions index,  int value)
  262.  * gets the messages for the unhandled events
  263.  *
  264.  ***********************************************************************/
  265. String geti_VerbGuiUnhandled(static Verbs, eVerbGuiUnhandled index)
  266. {
  267.   return verbsData.unhandled_strings[index];
  268. }
  269.  
  270.  
  271.  
  272. static void Verbs::BindGuis(GUI* _gAction, GUI* _gMain, GUI* _gPause, GUI* _gQuit)
  273. {
  274.     verbsData.guiAction     = _gAction;
  275.     verbsData.guiMain       = _gMain;
  276.     verbsData.guiPause      = _gPause;
  277.     verbsData.guiQuit       = _gQuit;
  278. }
  279.  
  280. static void Verbs::SetFonts(FontType fontText, FontType fontTextOut, FontType fontSpeech, FontType fontOutlineSpeech)
  281. {
  282.     verbsData.fontText          = fontText;
  283.     verbsData.fontTextOut       = fontTextOut;
  284.     verbsData.fontSpeech        = fontSpeech;
  285.     verbsData.fontOutlineSpeech = fontOutlineSpeech;
  286. }
  287.  
  288.  
  289.  
  290. /***********************************************************************
  291.  * GetButtonAction(int action)
  292.  * Returns the connected action of a verb button.
  293.  *
  294.  ***********************************************************************/
  295. static int Verbs::GetButtonAction(Button* button)
  296. {
  297.   if (button.OwningGUI != verbsData.guiMain) {
  298.       AbortGame("This button is not part of the Tumbleweed verbs GUI");
  299.   }
  300.  
  301.   for (int action=0; action< ACT_COUNT; action++) {
  302.       if (actionButtonData[action].button == button.ID) {
  303.             return actionButtonData[action].action;
  304.       }
  305.   }
  306.   AbortGame("Could not find the action corresonding to this button.");
  307. }
  308.  
  309. /***********************************************************************
  310.  * DisableGui()
  311.  * This functions disables the GUI (but does not necessarily hides it)
  312.  *
  313.  ***********************************************************************/
  314. static void Verbs::DisableGui()
  315. {
  316.   verbsData.disabled_gui=true;
  317. }
  318.  
  319. /***********************************************************************
  320.  * EnableGui()
  321.  * This functions enables the GUI (but does not necessarily makes it visible).
  322.  *
  323.  ***********************************************************************/
  324. static void Verbs::EnableGui()
  325. {
  326.   verbsData.disabled_gui=false;
  327. }
  328.  
  329. /***********************************************************************
  330.  * IsGuiDisabled()
  331.  * Returns true, if the GUI is currently disabled, false otherwise
  332.  *
  333.  ***********************************************************************/
  334. static bool Verbs::IsGuiDisabled()
  335. {
  336.   return verbsData.disabled_gui;
  337. }
  338.  
  339.  
  340. /***********************************************************************
  341.  * ShowGui()
  342.  * Shows the verbs GUI and enables it
  343.  *
  344.  ***********************************************************************/
  345. static void Verbs::ShowGui()
  346. {
  347.   Verbs.EnableGui();
  348.   verbsData.guiMain.Visible=true;
  349.   verbsData.guiAction.Visible=true;
  350.   Wait(1);
  351. }
  352.  
  353. /***********************************************************************
  354.  * ShowGui()
  355.  * Hides the verbs GUI and disables it
  356.  *
  357.  ***********************************************************************/
  358. static void Verbs::HideGui()
  359. {
  360.   Verbs.DisableGui();
  361.   verbsData.guiMain.Visible=false;
  362.   verbsData.guiAction.Visible=false;
  363. }
  364.  
  365. /***********************************************************************
  366.  * IsGuiDisabled()
  367.  * Returns true, if the GUI is currently visibale, false otherwise
  368.  *
  369.  ***********************************************************************/
  370. static bool Verbs::IsGuiVisible()
  371. {
  372.    return verbsData.guiMain.Visible;
  373. }
  374.  
  375.  
  376. /***********************************************************************
  377.  * HandleInvArrows()
  378.  * Takes care of showing or hiding the inventory scroll sprites
  379.  *
  380.  ***********************************************************************/
  381. static void Verbs::HandleInvArrows()
  382. {
  383.   // change the arrows in the inventory to show if you
  384.   // can scroll the inventory:
  385.   if (invMain.TopItem > 0) {
  386.     // if inventory can scroll up
  387.     btnInvUp.NormalGraphic    = verbsData.invUparrowONsprite;
  388.     btnInvUp.MouseOverGraphic = verbsData.invUparrowHIsprite;
  389.    
  390.     if (InventoryItem.GetAtScreenXY(verbsData.guiMain.X + invMain.X + 1, verbsData.guiMain.Y + invMain.Y + 1) == null) invMain.TopItem -= invMain.ItemsPerRow;
  391.   }
  392.   else {
  393.     btnInvUp.NormalGraphic    = verbsData.invUparrowOFFsprite;
  394.     btnInvUp.MouseOverGraphic = verbsData.invUparrowOFFsprite;
  395.   }
  396.   //if inv can scroll down
  397.   if (invMain.TopItem < invMain.ItemCount-(invMain.ItemsPerRow * invMain.RowCount)) {
  398.     btnInvDown.NormalGraphic    = verbsData.invDownarrowONsprite;
  399.     btnInvDown.MouseOverGraphic = verbsData.invDownarrowHIsprite;
  400.   }
  401.   else{
  402.     btnInvDown.NormalGraphic    = verbsData.invDownarrowOFFsprite;
  403.     btnInvDown.MouseOverGraphic = verbsData.invDownarrowOFFsprite;
  404.   }
  405. }
  406.  
  407. // ============================= door init functions ===========================================
  408. /***********************************************************************
  409.  * seti_VerbGuiUnhandled(this Verbs*, eVerbGuiOptions index,  int value)
  410.  * sets the messages for the unhandled events
  411.  *
  412.  ***********************************************************************/
  413. bool seti_DoorStrings(static Doors, eDoorStrings index, String value)
  414. {
  415.   if (!String.IsNullOrEmpty(value)) verbsData.door_strings[index] = value;
  416. }
  417.  
  418. /***********************************************************************
  419.  * geti_VerbGuiUnhandled(this Verbs*, eVerbGuiOptions index,  int value)
  420.  * gets the messages for the unhandled events
  421.  *
  422.  ***********************************************************************/
  423. String geti_DoorStrings(static Doors, eDoorStrings index)
  424. {
  425.   return verbsData.door_strings[index];
  426. }
  427. /***********************************************************************
  428.  * SetDoorState(int door_id, int value)
  429.  * Call this function to set a door state for the given door_id. A door can have 3 different states:
  430.  *  0 = The door is closed
  431.  *  1 = The door is open
  432.  *  2 = The door is closed and locked
  433.  *
  434.  ***********************************************************************/
  435. static void Doors::SetDoorState(int door_id, int value)
  436. {
  437.   verbsData.door_state[door_id] = value;
  438. }
  439.  
  440. /***********************************************************************
  441.  * GetDoorState(int door_id)
  442.  * Returns the current state of a door.
  443.  *
  444.  ***********************************************************************/
  445. static int Doors::GetDoorState(int door_id)
  446. {
  447.   return verbsData.door_state[door_id];
  448. }
  449.  
  450. /***********************************************************************
  451.  * InitObject (int door_id, int obj)
  452.  * Used to set up the corresponding object, used by the door with the given id.
  453.  * If the state of the door is closed, the object will be invisible.
  454.  * Otherwise, the object will be shown. The object stays unclickable all the time.
  455.  *
  456.  ***********************************************************************/
  457. static void Doors::InitObject (int door_id, int obj)
  458. {
  459.   if (Doors.GetDoorState(door_id) == 1) {
  460.     object[obj].Visible=true;
  461.     object[obj].Clickable=false;
  462.   }
  463.   else {
  464.     object[obj].Visible=false;
  465.     object[obj].Clickable=false;
  466.   }
  467. }
  468.  
  469.  
  470. // ============================= verb action functions ===========================================
  471.  
  472. /***********************************************************************
  473.  * TranslateAction(int action, int tr_lang)
  474.  * This function defines the text for the verb buttons, e.g. if you click on the talk verb button,
  475.  * "Talk to" is being displayed in the action/status bar. The second parameter defines the returned language.
  476.  * If you want to customize this text, you have to edit this function.
  477.  *
  478.  ***********************************************************************/
  479. static void Verbs::TranslateAction(int action, int tr_lang)
  480. {
  481.   if (tr_lang == eLangDE) {
  482.     if (action == eGA_WalkTo)        verbsData.tresult="Gehe zu %s";
  483.     else if (action == eGA_LookAt)   verbsData.tresult="Schau %s an";
  484.     else if (action == eGA_TalkTo)   verbsData.tresult="Rede mit %s";
  485.     else if (action == eGA_GiveTo) {
  486.       if (verbsData.act_item.Length > 0)       verbsData.tresult="Gib !s an %s";
  487.       else                           verbsData.tresult="Gib %s";
  488.     }
  489.     else if (action == eGA_PickUp)   verbsData.tresult="Nimm %s";
  490.     else if (action == eGA_Use) {
  491.       if (verbsData.act_item.Length > 0)       verbsData.tresult="Benutze !s mit %s";
  492.       else                           verbsData.tresult="Benutze %s";
  493.     }
  494.     else if (action == eGA_Open)     verbsData.tresult="Öffne %s";
  495.     else if (action == eGA_Close)    verbsData.tresult="Schließe %s";
  496.     else if (action == eGA_Push)     verbsData.tresult="Drücke %s";
  497.     else if (action == eGA_Pull)     verbsData.tresult="Ziehe %s";
  498.     else verbsData.tresult=" ";  
  499.   }
  500.   else if (tr_lang == eLangES) {
  501.     if (action == eGA_WalkTo)        verbsData.tresult="Ir a %s";
  502.     else if (action == eGA_LookAt)   verbsData.tresult="Mirar %s";
  503.     else if (action == eGA_TalkTo)   verbsData.tresult="Hablar con %s";
  504.     else if (action == eGA_GiveTo) {
  505.       if (verbsData.act_item.Length > 0)       verbsData.tresult="Dar !s a %s";
  506.       else                           verbsData.tresult="Dar %s";
  507.     }
  508.     else if (action == eGA_PickUp)   verbsData.tresult="Coger %s";
  509.     else if (action == eGA_Use) {
  510.       if (verbsData.act_item.Length > 0)       verbsData.tresult="Usar !s con %s";
  511.       else                           verbsData.tresult="Usar %s";
  512.     }
  513.     else if (action == eGA_Open)     verbsData.tresult="Abrir %s";
  514.     else if (action == eGA_Close)    verbsData.tresult="Cerrar %s";
  515.     else if (action == eGA_Push)     verbsData.tresult="Empujar %s";
  516.     else if (action == eGA_Pull)     verbsData.tresult="Tirar de %s";
  517.     else verbsData.tresult=" ";    
  518.   }
  519.   else if (tr_lang == eLangFR) {
  520.     if (action == eGA_WalkTo)        verbsData.tresult="Aller vers %s";
  521.     else if (action == eGA_LookAt)   verbsData.tresult="Regarder %s";
  522.     else if (action == eGA_TalkTo)   verbsData.tresult="Parler à %s";
  523.     else if (action == eGA_GiveTo) {
  524.       if (verbsData.act_item.Length>0)         verbsData.tresult="Donner !s à %s";
  525.       else                           verbsData.tresult="Donner %s";
  526.     }
  527.     else if (action == eGA_PickUp)   verbsData.tresult="Prendre %s";
  528.     else if (action == eGA_Use) {
  529.       if (verbsData.act_item.Length>0)         verbsData.tresult="Utiliser !s sur %s";
  530.       else                           verbsData.tresult="Utiliser %s";
  531.     }
  532.     else if (action == eGA_Open)     verbsData.tresult="Ouvrir %s";
  533.     else if (action == eGA_Close)    verbsData.tresult="Fermer %s";
  534.     else if (action == eGA_Push)     verbsData.tresult="Pousser %s";
  535.     else if (action == eGA_Pull)     verbsData.tresult="Tirer %s";
  536.     else verbsData.tresult=" ";
  537.   }  
  538.   else if (tr_lang == eLangIT) {
  539.     if (action == eGA_WalkTo)        verbsData.tresult="Vai a %s";
  540.     else if (action == eGA_LookAt)   verbsData.tresult="Esamina %s";
  541.     else if (action == eGA_TalkTo)   verbsData.tresult="Parla con %s";
  542.     else if (action == eGA_GiveTo) {
  543.     if (verbsData.act_item.Length > 0)         verbsData.tresult="Dai !s a %s";
  544.     else                             verbsData.tresult="Dai %s";
  545.     }
  546.     else if (action == eGA_PickUp)   verbsData.tresult="Raccogli %s";
  547.     else if (action == eGA_Use) {
  548.     if (verbsData.act_item.Length > 0)         verbsData.tresult="Usa !s con %s";
  549.     else                             verbsData.tresult="Usa %s";
  550.     }
  551.     else if (action == eGA_Open)     verbsData.tresult="Apri %s";
  552.     else if (action == eGA_Close)    verbsData.tresult="Ferma %s";
  553.     else if (action == eGA_Push)     verbsData.tresult="Premi %s";
  554.     else if (action == eGA_Pull)     verbsData.tresult="Tira %s";
  555.     else verbsData.tresult=" ";
  556.   }
  557.   else if (tr_lang == eLangPT) {
  558.     if (action == eGA_WalkTo)        verbsData.tresult="Ir para %s";
  559.     else if (action == eGA_LookAt)   verbsData.tresult="Olhar para %s";
  560.     else if (action == eGA_TalkTo)   verbsData.tresult="Falar com %s";
  561.     else if (action == eGA_GiveTo) {
  562.     if (verbsData.act_item.Length > 0)         verbsData.tresult="Dar !s a %s";
  563.     else                             verbsData.tresult="Dar %s";
  564.     }
  565.     else if (action == eGA_PickUp)   verbsData.tresult="Apanhar %s";
  566.     else if (action == eGA_Use) {
  567.     if (verbsData.act_item.Length > 0)         verbsData.tresult="Usar !s com %s";
  568.     else                             verbsData.tresult="Usar %s";
  569.     }
  570.     else if (action == eGA_Open)     verbsData.tresult="Abrir %s";
  571.     else if (action == eGA_Close)    verbsData.tresult="Fechar %s";
  572.     else if (action == eGA_Push)     verbsData.tresult="Empurrar %s";
  573.     else if (action == eGA_Pull)     verbsData.tresult="Puxar %s";
  574.     else verbsData.tresult=" ";
  575.   }
  576.   else if (tr_lang == eLangNL) {
  577.     if (action == eGA_WalkTo)        verbsData.tresult="Ga naar %s";
  578.     else if (action == eGA_LookAt)   verbsData.tresult="Bekijk %s";
  579.     else if (action == eGA_TalkTo)   verbsData.tresult="Praat met %s";
  580.     else if (action == eGA_GiveTo) {
  581.     if (verbsData.act_item.Length>0)           verbsData.tresult="Geef !s aan %s";
  582.     else                             verbsData.tresult="Geef %s";
  583.     }
  584.     else if (action == eGA_PickUp)   verbsData.tresult="Pak %s";
  585.     else if (action == eGA_Use) {
  586.     if (verbsData.act_item.Length>0)           verbsData.tresult="Gebruik !s met %s";
  587.     else                             verbsData.tresult="Gebruik %s";
  588.     }
  589.     else if (action == eGA_Open)     verbsData.tresult="Open %s";
  590.     else if (action == eGA_Close)    verbsData.tresult="Sluit %s";
  591.     else if (action == eGA_Push)     verbsData.tresult="Duw %s";
  592.     else if (action == eGA_Pull)     verbsData.tresult="Trek %s";
  593.     else verbsData.tresult=" ";
  594.   }  
  595.   else {
  596.     if (action == eGA_WalkTo)        verbsData.tresult="Walk to %s";
  597.     else if (action == eGA_LookAt)   verbsData.tresult="Look at %s";
  598.     else if (action == eGA_TalkTo)   verbsData.tresult="Talk to %s";
  599.     else if (action == eGA_GiveTo) {
  600.       if (verbsData.act_item.Length > 0)       verbsData.tresult="Give !s to %s";
  601.       else                           verbsData.tresult="Give %s";
  602.     }
  603.     else if (action == eGA_PickUp)   verbsData.tresult="Pick up %s";
  604.     else if (action == eGA_Use) {
  605.       if (verbsData.act_item.Length > 0)       verbsData.tresult="Use !s with %s";
  606.       else                           verbsData.tresult="Use %s";
  607.     }
  608.     else if (action == eGA_Open)     verbsData.tresult="Open %s";
  609.     else if (action == eGA_Close)    verbsData.tresult="Close %s";
  610.     else if (action == eGA_Push)     verbsData.tresult="Push %s";
  611.     else if (action == eGA_Pull)     verbsData.tresult="Pull %s";
  612.     else verbsData.tresult=" ";    
  613.   }
  614.   // fill object and item into action template
  615.   verbsData.tresult = GetTranslation(verbsData.tresult);
  616.   int ip = verbsData.tresult.IndexOf("!s");
  617.   if (ip >= 0) {
  618.     int op  = verbsData.tresult.Contains("%s");
  619.     verbsData.tresult = verbsData.tresult.ReplaceCharAt(ip, '%');
  620.     if (ip < op) verbsData.tresult=String.Format(verbsData.tresult, verbsData.act_item, verbsData.act_object);
  621.     else         verbsData.tresult=String.Format(verbsData.tresult, verbsData.act_object, verbsData.act_item);
  622.   }
  623.   else {
  624.     if (verbsData.act_object == null) verbsData.act_object = "";
  625.     verbsData.tresult=String.Format(verbsData.tresult, verbsData.act_object);
  626.   }
  627. }
  628.  
  629. /***********************************************************************
  630.  * IsAction(Action test_action)
  631.  * Used to check, if the current action is the one, given in the parameter.
  632.  *
  633.  ***********************************************************************/
  634. static bool Verbs::IsAction(Action test_action)
  635. {
  636.   return  verbsData.global_action == test_action;
  637. }
  638.  
  639. /***********************************************************************
  640.  * UsedAction(Action test_action)
  641.  * Used to determine, which action has been selected by the player.
  642.  * Instead of checking cursor modes, this function is used.
  643.  *
  644.  ***********************************************************************/
  645. static bool Verbs::UsedAction(Action test_action)
  646. {
  647.   return (( verbsData.used_action == test_action) && ( verbsData.AGSCursorMode != eModeUseinv)) ||
  648.          ((test_action == eGA_UseInv)  && ( verbsData.used_action == eGA_Use) && ( verbsData.AGSCursorMode == eModeUseinv)) ||
  649.          ((test_action == eGA_GiveTo)  && ( verbsData.used_action == eGA_GiveTo) && ( verbsData.AGSCursorMode == eModeUseinv) && verbsData.ItemGiven!=null);
  650. }
  651.  
  652. /***********************************************************************
  653.  * SetAction(Action new_action)
  654.  * Since the cursor modes are bypassed, this function defines the current action.
  655.  * Among other things, this function is called by clicking a verb button.
  656.  *
  657.  ***********************************************************************/
  658. static void Verbs::SetAction(Action new_action)
  659. {
  660.   // set default action
  661.   if (new_action == eGA_Default) new_action= verbsData.default_action;
  662.   // set corresponding cursormode
  663.        if (new_action == eGA_WalkTo) mouse.Mode=eModeUsermode2;
  664.   else if (new_action == eGA_LookAt) mouse.Mode=eModeLookat;
  665.   else if (new_action == eGA_TalkTo) mouse.Mode=eModeTalkto;
  666.   else if (new_action == eGA_GiveTo) mouse.Mode=eModeInteract;
  667.   else if (new_action == eGA_PickUp) mouse.Mode=eModePickup;
  668.   else if (new_action == eGA_Use)    mouse.Mode=eModeInteract;
  669.   else if (new_action == eGA_Open)   mouse.Mode=eModeUsermode1;
  670.   else if (new_action == eGA_Close)  mouse.Mode=eModeUsermode1;
  671.   else if (new_action == eGA_Push)   mouse.Mode=eModeUsermode1;
  672.   else if (new_action == eGA_Pull)   mouse.Mode=eModeUsermode1;
  673.   // save action
  674.    verbsData.global_action=new_action;
  675. }
  676.  
  677. /***********************************************************************
  678.  * SetDefaultAction(Action def_action)
  679.  * Used to define, which action is being used, if no verb has been clicked.
  680.  * Usually this is “walk to”.
  681.  *
  682.  ***********************************************************************/
  683. static void Verbs::SetDefaultAction(Action def_action)
  684. {
  685.    verbsData.default_action = def_action;
  686.   Verbs.SetAction(eGA_Default);
  687. }
  688.  
  689.  
  690. /***********************************************************************
  691.  * Action GetUsedAction()
  692.  * Returns directly which action was selected by the player
  693.  *
  694.  ***********************************************************************/
  695.  
  696. static Action Verbs::GetUsedAction() {
  697.   if(Verbs.UsedAction(eGA_WalkTo)){
  698.     return eGA_WalkTo;
  699.   }
  700.   else if(Verbs.UsedAction(eGA_LookAt)){
  701.     return eGA_LookAt;
  702.   }
  703.   else if(Verbs.UsedAction(eGA_TalkTo)){
  704.     return eGA_TalkTo;
  705.   }
  706.   else if(Verbs.UsedAction(eGA_GiveTo)){
  707.     return eGA_GiveTo;
  708.   }
  709.   else if(Verbs.UsedAction(eGA_PickUp)){
  710.     return eGA_PickUp;
  711.   }
  712.   else if(Verbs.UsedAction(eGA_Use)){
  713.     return eGA_Use;
  714.   }
  715.   else if(Verbs.UsedAction(eGA_UseInv)){
  716.     return eGA_UseInv;
  717.   }
  718.   else if(Verbs.UsedAction(eGA_Open)){
  719.     return eGA_Open;
  720.   }
  721.   else if(Verbs.UsedAction(eGA_Close)){
  722.     return eGA_Close;
  723.   }
  724.   else if(Verbs.UsedAction(eGA_Push)){
  725.     return eGA_Push;
  726.   }
  727.   else if(Verbs.UsedAction(eGA_Pull)){
  728.     return eGA_Pull;
  729.   }
  730.   return -1;
  731. }
  732.  
  733. /***********************************************************************
  734.  * Action GetItemGiven()
  735.  * Returns the item that has been given by the player. It's more or less player.ActiveInventory with more subtle logic
  736.  *
  737.  ***********************************************************************/
  738.  
  739.  
  740. static InventoryItem* Verbs::GetItemGiven()
  741. {
  742.     return verbsData.ItemGiven;
  743. }
  744.  
  745.  
  746.  
  747. // ============================= GlobalCondition ===========================================
  748.  
  749. /***********************************************************************
  750.  * GlobalCondition(eGlobCond condition)
  751.  * Used to check for conditions that are used many times in the script.
  752.  * For example, it’s used to check, if the mouse cursor is in the inventory and the mode walk or pickup are selected.
  753.  * Returns 1, if the condition is true and 0 otherwise.
  754.  *
  755.  ***********************************************************************/
  756. static int Verbs::GlobalCondition(eGlobCond condition)
  757. {
  758.   // here are some conditions that are used many times in the script
  759.   int cond;
  760.   InventoryItem*ii = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  761.   GUIControl*gc    = GUIControl.GetAtScreenXY(mouse.x, mouse.y);
  762.   int gcid = -1;
  763.   if (gc != null) gcid = gc.ID;
  764.  
  765.   // if the mouse is in the inventory and mode Walk is selected
  766.   if (condition == eGlob_MouseInvWalk ) {
  767.     cond = (ii != null && (Verbs.IsAction(eGA_WalkTo)));
  768.   }
  769.   // if the mouse is in the inventory and mode Pickup is selected
  770.   else if (condition == eGlob_MouseInvPickup) {
  771.     cond = (ii != null && (Verbs.IsAction(eGA_PickUp)));
  772.   }
  773.   // if the mode is useinv and the mouse is over the active inv (like "use knife on knife")
  774.   else if (condition == eGlob_InvOnInv) {
  775.     cond =(player.ActiveInventory == ii && Mouse.Mode == eModeUseinv);
  776.   }
  777.   // if the mode is talk or "Give", and the mouse isnt over a character
  778.   else if (condition == eGlob_GiveTalkNoChar) {
  779.    
  780.     if ( verbsData.objHotTalk && Verbs.IsAction(eGA_TalkTo) ) {
  781.       cond = false;    
  782.     }  
  783.     else {
  784.       cond =((Verbs.IsAction(eGA_TalkTo) || (Verbs.IsAction(eGA_GiveTo) && (Mouse.Mode == eModeUseinv))) && (GetLocationType(mouse.x, mouse.y) != eLocationCharacter));
  785.     }
  786.   }
  787.    
  788.   // if its GIVE and the mouse isnt over a inv.item
  789.   else if (condition == eGlob_GiveNoInv)
  790.     cond = ((Mouse.Mode == eModeInteract) && Verbs.IsAction(eGA_GiveTo) && (ii == null));
  791.  
  792.   // if the mouse is in the inventory and mode TalkTo is selected
  793.   else if (condition == eGlob_InvTalk)
  794.     cond =  (ii != null && (Verbs.IsAction(eGA_TalkTo)));
  795.  
  796.   return cond;
  797. }
  798.  
  799. // ============================= Verb Extensions and actions ===========================================
  800.  
  801. /***********************************************************************
  802.  * ExtensionEx(int index, String name)
  803.  * Returns the n-th extension of the given string.
  804.  *
  805.  ***********************************************************************/
  806. static char Verbs::ExtensionEx(int index, String name)
  807. {
  808.   //returns the extension in the position 'index' of the string 'name'.
  809.   //returns 0 if the name has no extension or if you passed an empty string.
  810.   if (name.Length == 0) return 0;//if you passed an empty string
  811.   int pos;
  812.   pos = name.IndexOf(">");
  813.   if (pos == -1) return 0;
  814.   else if (pos+index<name.Length) return name.Chars[pos+index];
  815.   else return 0;
  816. }
  817.  
  818. /***********************************************************************
  819.  * Extension()
  820.  * Returns the first extention of the location
  821.  *
  822.  ***********************************************************************/
  823. static char Verbs::Extension()
  824. {
  825.   // Check the (first) extension (>*) of a string
  826.   return Verbs.ExtensionEx(1, verbsData.location);
  827. }
  828.  
  829. /***********************************************************************
  830.  * RemoveExtension()
  831.  * Used to remove the extension from a location (Hotspots, Objects etc.), so it doesn’t get displayed in the status bar.
  832.  *
  833.  ***********************************************************************/
  834. static int Verbs::RemoveExtension()
  835. {
  836.   //removes the extension of a string  
  837.   int pos = verbsData.location.IndexOf(">");
  838.   int length = verbsData.location.Length;
  839.   if (Verbs.Extension() != 0) verbsData.location = verbsData.location.Truncate(pos);
  840.   return pos;
  841. }
  842.  
  843. /***********************************************************************
  844.  * AddExtension()
  845.  * Used to add a default extension in case the location doesn’t have one.
  846.  *
  847.  ***********************************************************************/
  848. static void Verbs::AddExtension(char extension)
  849. {
  850.   //adds an extension to a thing that doesn't have one
  851.   int length=verbsData.location.Length;
  852.   if (Verbs.Extension() == 0) {
  853.     verbsData.location=verbsData.location.Append(">n");
  854.     verbsData.location=verbsData.location.ReplaceCharAt(length+1, extension);
  855.   }
  856. }
  857.  
  858. /***********************************************************************
  859.  * SetAlternativeAction(char extension, Action alt_action)
  860.  * This function makes the right-click shortcuts work.
  861.  * If you use extensions like “>p” (e.g. pickup), this function makes sure, that the correct verb button is highlighted.
  862.  *
  863.  ***********************************************************************/
  864. static void Verbs::SetAlternativeAction(char extension, Action alt_action)
  865. {
  866.   if (alt_action == eGA_Default) {
  867.     if (Verbs.Extension() == extension)
  868.        verbsData.alternative_action = alt_action;
  869.   }
  870.   else {
  871.     int button          = actionButtonData[alt_action].button;
  872.     int normalbuttonpic = actionButtonData[alt_action].button_graphic_normal[verbsData.lang];
  873.     int overbuttonpic   = actionButtonData[alt_action].button_graphic_highlight[verbsData.lang];
  874.    
  875.     // used for setting the default action given the extension.
  876.     GUIControl*gc = verbsData.guiMain.Controls[button];
  877.     Button*b = gc.AsButton;
  878.    
  879.     if (Verbs.Extension() == extension) {
  880.       b.NormalGraphic = overbuttonpic;
  881.        verbsData.alternative_action = alt_action;
  882.     }
  883.     else b.NormalGraphic = normalbuttonpic;
  884.     b.MouseOverGraphic = overbuttonpic;
  885.   }
  886. }
  887.  
  888. /***********************************************************************
  889.  * OpenCloseExtension(int door_id)
  890.  * 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.
  891.  *
  892.  ***********************************************************************/
  893. static void Verbs::OpenCloseExtension(int door_id)
  894. {
  895.   if ((Doors.GetDoorState(door_id)==0) || (Doors.GetDoorState(door_id)==2)) Verbs.AddExtension('o');
  896.   else Verbs.AddExtension('c');
  897. }
  898.  
  899. /***********************************************************************
  900.  * VariableExtensions(
  901.  * This function is called, if you have have set "v" as an extension for a certain location.
  902.  * Currently it is used for the OpenClose extension, but of course you can add your own variable extensions here,
  903.  * for example "turn on / turn off"
  904.  *
  905.  ***********************************************************************/
  906. static void Verbs::VariableExtensions()
  907. {
  908.   // define here, which things will use a variable extension (>v)
  909.   // by default, it's only used for doors.
  910.   int r = player.Room;
  911.   Object*oo = Object.GetAtScreenXY(mouse.x, mouse.y);
  912.   int o=0;
  913.   if (oo != null) o = oo.ID;
  914.   Hotspot*hh = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  915.   int h = hh.ID;
  916.  
  917.   // Other possible extensions could be: Turn On/Turn Off
  918.  
  919.   // Open/Close Extension:
  920.   // Room | Hotspot |(Door_id)
  921.   if (r==2 && h == 1)  Verbs.OpenCloseExtension (10);
  922.   //else if (r==2  && h == 2)  OpenCloseExtension (3);  
  923. }
  924.  
  925. /***********************************************************************
  926.  * CheckDefaultAction()
  927.  * This function checks for a given extension in hotspots, objects and characters.
  928.  * If there isn’t an extension, a default action is given, e.g. “Talk to” if the mouse is over a character.
  929.  * In case of a given extension, the default actions are being overridden.
  930.  *
  931.  ***********************************************************************/
  932. static void Verbs::CheckDefaultAction()
  933. {
  934.   // you could want to change which extension activates which default action, or which button sprite
  935.   // it changes. The extensions are characters, so remember enclose them in single quotes ' , not double quotes ".
  936.   int x = mouse.x;
  937.   int y = mouse.y;
  938.  
  939.   verbsData.location = Game.GetLocationName(x, y);
  940.    verbsData.location_ex = verbsData.location;
  941.  
  942.  
  943.   // Setting default modes if the thing has no extension:
  944.   if (Verbs.Extension() == 0 ) {
  945.     if (GetLocationType(x, y) == eLocationCharacter) // if it is a character
  946.       Verbs.AddExtension('t'); // set default action "talk to"
  947.     else if ((GetLocationType(x, y) != eLocationNothing) || (InventoryItem.GetAtScreenXY(x, y)!=null))
  948.       // if its an inv item, a hotspot or an object
  949.       Verbs.AddExtension('n'); // set default action "look at"
  950.     else
  951.       Verbs.AddExtension('n'); // set default action "none"
  952.   }
  953.   else if (Verbs.Extension()=='v') { // if the default action depends on some events
  954.     Verbs.RemoveExtension();
  955.     Verbs.VariableExtensions();
  956.   }
  957.   if (Verbs.GlobalCondition(eGlob_InvOnInv) || (! verbsData.objHotTalk && Verbs.GlobalCondition(eGlob_GiveTalkNoChar)) || Verbs.GlobalCondition(eGlob_GiveNoInv) ) {
  958.     //Dont send the name of the hotspt/obj/char/inv to the action bar and set default action "none"
  959.     if (!Verbs.GlobalCondition(eGlob_InvTalk)) verbsData.location=">n";
  960.   }
  961.  
  962.   verbsData.inv_ex_location=verbsData.location;
  963.  
  964.   // Set "Look" as default action for Inv items
  965.   if ((Verbs.Extension()=='u') && (InventoryItem.GetAtScreenXY(x, y) != null)) {
  966.     // it's an inv item
  967.     Verbs.RemoveExtension();
  968.     Verbs.AddExtension('l'); // set default action "look at"
  969.   }
  970.  
  971.   Verbs.SetAlternativeAction('n', eGA_Default);
  972.   Verbs.SetAlternativeAction('g', eGA_GiveTo);
  973.   Verbs.SetAlternativeAction('p', eGA_PickUp);
  974.   Verbs.SetAlternativeAction('u', eGA_Use);
  975.   Verbs.SetAlternativeAction('o', eGA_Open);
  976.   Verbs.SetAlternativeAction('l', eGA_LookAt);
  977.   Verbs.SetAlternativeAction('s', eGA_Push);
  978.   Verbs.SetAlternativeAction('c', eGA_Close);
  979.   Verbs.SetAlternativeAction('t', eGA_TalkTo);
  980.   Verbs.SetAlternativeAction('y', eGA_Pull);  
  981.   Verbs.RemoveExtension();
  982.   verbsData.inv_location = verbsData.location;
  983. }
  984. // ============================= ActionBar ===========================================
  985.  
  986.  
  987. /***********************************************************************
  988.  * AdjustActionBarPosition()
  989.  * Moves the action label above the mouse cursor
  990.  *
  991.  ***********************************************************************/
  992. static void Verbs::AdjustActionBarPosition()
  993. {
  994.   int actionLabelHalf = verbsData.actionLabelWidth / 2;
  995.   int xpos = mouse.x - actionLabelHalf ;
  996.   int ypos = mouse.y - Game.SpriteHeight[mouse.GetModeGraphic(mouse.Mode)] - 4;
  997.  
  998.   if (xpos + verbsData.actionLabelWidth >= Screen.Width) xpos = Screen.Width - verbsData.actionLabelWidth;
  999.   else if (xpos < 0) xpos = 0;
  1000.  
  1001.   if (ypos < 0 ) ypos = 0;
  1002.  
  1003.   lblAction.X = xpos;
  1004.   lblAction.Y = ypos;
  1005.   lblAction.Width = verbsData.actionLabelWidth;
  1006.  
  1007. }
  1008.  
  1009. /***********************************************************************
  1010.  * UpdateActionBar()
  1011.  * This function is used to show and update the status bar.
  1012.  * It checks for an extension, triggers the translation and renders the results on screen.
  1013.  *
  1014.  ***********************************************************************/
  1015. static void Verbs::UpdateActionBar()
  1016. {
  1017.   // set the text in the action bar
  1018.   int action =  verbsData.global_action;
  1019.   verbsData.act_object = verbsData.inv_location;  
  1020.   verbsData.act_item = "";
  1021.  
  1022.   if (Mouse.Mode==eModeUseinv) { // use or give inventory item
  1023.     verbsData.act_item = player.ActiveInventory.Name;
  1024.     verbsData.location = verbsData.act_item;
  1025.     Verbs.RemoveExtension();
  1026.     verbsData.act_item = verbsData.location;
  1027.   }
  1028.   // if the mouse is in the inventory and modes Walk or pickup are selected
  1029.   else if (Verbs.GlobalCondition(eGlob_MouseInvWalk)) {
  1030.       action = eGA_Use;
  1031.   }
  1032.  
  1033.   Verbs.TranslateAction(action, verbsData.lang);
  1034.   // show action text
  1035.   if (! verbsData.classicGui && verbsData.act_object == "" && action == eGA_WalkTo) lblAction.Text = " ";
  1036.   else lblAction.Text=verbsData.tresult;
  1037.  
  1038.   lblAction.TextColor = verbsData.actionLabelColorNormal;
  1039.   verbsData.actionLabelWidth = GetTextWidth(lblAction.Text, verbsData.fontTextOut) + 4; //+4 because GetTextWidth doesn't work too well with automatic outlined fonts
  1040.  
  1041.   if (lblAction.Width != Screen.Width) {  
  1042.     lblAction.Width = Screen.Width;
  1043.     lblAction.Y = verbsData.guiMain.Y - lblAction.Height;
  1044.   }
  1045.  
  1046.   // Show option button
  1047.   if ( mouse.x > Screen.Width - btnShowOptions.Width +1 && mouse.y < btnShowOptions.Height +1 ) {
  1048.     btnShowOptions.Visible = true;
  1049.     verbsData.guiAction.Clickable = true;
  1050.   }
  1051.   else {
  1052.     verbsData.guiAction.Clickable = false;
  1053.     btnShowOptions.Visible = false;
  1054.   }
  1055.  
  1056. }
  1057.  
  1058. /***********************************************************************
  1059.  * ToogleGuiStyle(int enable_new)
  1060.  * Switches between classic Scumm mode and new one.
  1061.  *
  1062.  ***********************************************************************/
  1063. static void Verbs::ToogleGuiStyle(int enable_new)
  1064. {
  1065.   if (enable_new == 1) {
  1066.      verbsData.classicGui = false;
  1067.     Verbs.AdjustActionBarPosition();
  1068.   }
  1069.   else {
  1070.      verbsData.classicGui = true;
  1071.     lblAction.Width = Screen.Width;
  1072.     lblAction.X = 0;
  1073.     lblAction.Y = verbsData.guiMain.Y - lblAction.Height ;
  1074.   }
  1075.   Verbs.UpdateActionBar();
  1076. }
  1077.  
  1078.  
  1079. // ============================= translation ===========================================
  1080.  
  1081. /***********************************************************************
  1082.  * SetActionButtons(Action action, int btn_ID)
  1083.  * This functions connects the verb buttons with the action
  1084.  *
  1085.  ***********************************************************************/
  1086. static void Verbs::SetActionButton(Action action, Button* btn)
  1087. {
  1088.   //Display("Mapping button %d of gui %d to action %d", btn.ID, btn.OwningGUI.ID, action);
  1089.   if (btn.OwningGUI.ID != verbsData.guiMain.ID) {
  1090.       AbortGame("This button is not part of the Verbs GUI.");
  1091.   }
  1092.   actionButtonData[action].action=action;
  1093.   actionButtonData[action].button=btn.ID;
  1094. }
  1095.  
  1096.  
  1097. /***********************************************************************
  1098.  * LocalizeActionButtons(int lang,  Action action, int sprite, int sprite_highlight, char key)
  1099.  * This fisused to assign / change the graphics of the verb buttons.
  1100.  *
  1101.  ***********************************************************************/
  1102. static void Verbs::LocalizeActionButton(eLanguage lang,  Action action, int sprite, int sprite_highlight, char key)
  1103. {
  1104.   String upperkey = String.Format("%c", key);
  1105.   upperkey = upperkey.UpperCase();
  1106.  
  1107.   actionButtonData[action].button_graphic_normal[lang] = sprite;
  1108.   actionButtonData[action].button_graphic_highlight[lang] = sprite_highlight;
  1109.   actionButtonData[action].action_l_keycode[lang] = key;
  1110.   actionButtonData[action].action_u_keycode[lang] = upperkey.Chars[0];
  1111.  
  1112. }
  1113.  
  1114.  
  1115. /***********************************************************************
  1116.  * MapButtons()
  1117.  * This sets up everything related to the verb buttons, so you need to take a look at this, if you want to customize your GUI.
  1118.  * You can call SetActionButton in your own scripts to customize the default buttons mapping.
  1119.  *
  1120.  ***********************************************************************/
  1121. static void Verbs::MapButtons()
  1122. {
  1123.     Verbs.SetActionButton(eGA_Open,    verbsData.guiMain.Controls[0].AsButton);
  1124.     Verbs.SetActionButton(eGA_Close,   verbsData.guiMain.Controls[1].AsButton);
  1125.     Verbs.SetActionButton(eGA_GiveTo,  verbsData.guiMain.Controls[2].AsButton);
  1126.     Verbs.SetActionButton(eGA_PickUp,  verbsData.guiMain.Controls[3].AsButton);
  1127.     Verbs.SetActionButton(eGA_LookAt,  verbsData.guiMain.Controls[4].AsButton);
  1128.     Verbs.SetActionButton(eGA_TalkTo,  verbsData.guiMain.Controls[5].AsButton);
  1129.     Verbs.SetActionButton(eGA_Push,    verbsData.guiMain.Controls[6].AsButton);
  1130.     Verbs.SetActionButton(eGA_Pull,    verbsData.guiMain.Controls[7].AsButton);
  1131.     Verbs.SetActionButton(eGA_Use,     verbsData.guiMain.Controls[8].AsButton);
  1132. }
  1133.  
  1134.  
  1135. /***********************************************************************
  1136.  * SetKeys(int lang,  char key_yes, char key_no)
  1137.  * Lets you tell the module what should be the shortcuts for 'yes' and 'no'
  1138.  *
  1139.  ***********************************************************************/
  1140. static void Verbs::SetKeys(eLanguage lang,  char key_yes, char key_no)
  1141. {
  1142.     String sYes = String.Format("%c", key_yes);
  1143.     String sNo = String.Format("%c", key_no);
  1144.     sYes = sYes.UpperCase();
  1145.     sNo = sNo.UpperCase();
  1146.     verbsData.key_u_yes[lang] = sYes.Chars[0];
  1147.     verbsData.key_u_no[lang] = sNo.Chars[0];
  1148.     sYes = sYes.LowerCase();
  1149.     sNo = sNo.LowerCase();
  1150.     verbsData.key_l_yes[lang] = sYes.Chars[0];
  1151.     verbsData.key_l_no[lang] = sNo.Chars[0];
  1152. }
  1153.  
  1154.  
  1155.  
  1156. /***********************************************************************
  1157.  * AdjustLanguage()
  1158.  * This re-applies the buttons graphics and shortcuts accordingly to the language if you switch languages
  1159.  *
  1160.  ***********************************************************************/
  1161. static void Verbs::Localize()
  1162. {
  1163.  
  1164.   // English - eLangEN
  1165.     // yes/no-keys
  1166.     Verbs.SetKeys(eLangEN,  'y',  'n');
  1167.    
  1168.     Verbs.LocalizeActionButton(eLangEN,eGA_Open,    59, 60, 'q');
  1169.     Verbs.LocalizeActionButton(eLangEN,eGA_Close,   61, 62, 'a');
  1170.     Verbs.LocalizeActionButton(eLangEN,eGA_GiveTo,  63, 64, 'z');
  1171.     Verbs.LocalizeActionButton(eLangEN,eGA_PickUp,  71, 72, 'w');
  1172.     Verbs.LocalizeActionButton(eLangEN,eGA_LookAt,  73, 74, 's');
  1173.     Verbs.LocalizeActionButton(eLangEN,eGA_TalkTo,  75, 76, 'x');
  1174.     Verbs.LocalizeActionButton(eLangEN,eGA_Push,    65, 66, 'e');
  1175.     Verbs.LocalizeActionButton(eLangEN,eGA_Pull,    67, 68, 'd');
  1176.     Verbs.LocalizeActionButton(eLangEN,eGA_Use,     69, 70, 'c');
  1177.    
  1178.  
  1179.   // German - eLangDE
  1180.     // yes/no-keys
  1181.     Verbs.SetKeys(eLangDE,  'j',  'n');
  1182.    
  1183.     Verbs.LocalizeActionButton(eLangDE,eGA_Open,    94, 101, 'q');
  1184.     Verbs.LocalizeActionButton(eLangDE,eGA_Close,   102, 103, 'a');
  1185.     Verbs.LocalizeActionButton(eLangDE,eGA_GiveTo,  104, 105, 'y');
  1186.     Verbs.LocalizeActionButton(eLangDE,eGA_PickUp,  112, 113, 'w');
  1187.     Verbs.LocalizeActionButton(eLangDE,eGA_LookAt,  114, 115, 's');
  1188.     Verbs.LocalizeActionButton(eLangDE,eGA_TalkTo,  116, 117, 'x');
  1189.     Verbs.LocalizeActionButton(eLangDE,eGA_Push,    106, 107, 'e');
  1190.     Verbs.LocalizeActionButton(eLangDE,eGA_Pull,    108, 109, 'd');
  1191.     Verbs.LocalizeActionButton(eLangDE,eGA_Use,     110, 111, 'c');
  1192.  
  1193.   // Spanish - eLangES
  1194.     // yes/no-keys
  1195.     Verbs.SetKeys(eLangES,  's',  'n');
  1196.    
  1197.     Verbs.LocalizeActionButton(eLangES,eGA_Open,    141, 142, 'q');
  1198.     Verbs.LocalizeActionButton(eLangES,eGA_Close,   143, 144, 'a');
  1199.     Verbs.LocalizeActionButton(eLangES,eGA_GiveTo,  145, 146, 'y');
  1200.     Verbs.LocalizeActionButton(eLangES,eGA_PickUp,  153, 154, 'w');
  1201.     Verbs.LocalizeActionButton(eLangES,eGA_LookAt,  155, 156, 's');
  1202.     Verbs.LocalizeActionButton(eLangES,eGA_TalkTo,  157, 158, 'x');
  1203.     Verbs.LocalizeActionButton(eLangES,eGA_Push,    148, 147, 'e');
  1204.     Verbs.LocalizeActionButton(eLangES,eGA_Pull,    149, 150, 'd');
  1205.     Verbs.LocalizeActionButton(eLangES, eGA_Use,    151, 152, 'c');
  1206.  
  1207.   // French - eLangFR
  1208.     // yes/no-keys
  1209.     Verbs.SetKeys(eLangFR,  'o',  'n');
  1210.    
  1211.     Verbs.LocalizeActionButton(eLangFR, eGA_Open,    123, 124, 'q');
  1212.     Verbs.LocalizeActionButton(eLangFR, eGA_Close,   125, 126, 'a');
  1213.     Verbs.LocalizeActionButton(eLangFR, eGA_GiveTo,  127, 128, 'y');
  1214.     Verbs.LocalizeActionButton(eLangFR, eGA_PickUp,  135, 136, 'w');
  1215.     Verbs.LocalizeActionButton(eLangFR, eGA_LookAt,  137, 138, 's');
  1216.     Verbs.LocalizeActionButton(eLangFR, eGA_TalkTo,  139, 140, 'x');
  1217.     Verbs.LocalizeActionButton(eLangFR, eGA_Push,    129, 130, 'e');
  1218.     Verbs.LocalizeActionButton(eLangFR, eGA_Pull,    131, 132, 'd');
  1219.     Verbs.LocalizeActionButton(eLangFR, eGA_Use,     133, 134, 'c');
  1220.  
  1221.   // Italian - eLangIT
  1222.     // yes/no-keys
  1223.     Verbs.SetKeys(eLangIT,  's',  'n');  
  1224.  
  1225.     Verbs.LocalizeActionButton(eLangIT, eGA_Open,    159, 160, 'q');
  1226.     Verbs.LocalizeActionButton(eLangIT, eGA_Close,   161, 162, 'a');
  1227.     Verbs.LocalizeActionButton(eLangIT, eGA_GiveTo,  163, 164, 'y');
  1228.     Verbs.LocalizeActionButton(eLangIT, eGA_PickUp,  171, 172, 'w');
  1229.     Verbs.LocalizeActionButton(eLangIT, eGA_LookAt,  173, 174, 's');
  1230.     Verbs.LocalizeActionButton(eLangIT, eGA_TalkTo,  175, 176, 'x');
  1231.     Verbs.LocalizeActionButton(eLangIT, eGA_Push,    165, 166, 'e');
  1232.     Verbs.LocalizeActionButton(eLangIT, eGA_Pull,    167, 168, 'd');
  1233.     Verbs.LocalizeActionButton(eLangIT, eGA_Use,     169, 170, 'c');
  1234.  
  1235.   // Portuguese -  eLangPT
  1236.     // yes/no-keys
  1237.     Verbs.SetKeys(eLangPT,  's',  'n');  
  1238.  
  1239.     Verbs.LocalizeActionButton(eLangPT, eGA_Open,    177, 178, 'q');
  1240.     Verbs.LocalizeActionButton(eLangPT, eGA_Close,   179, 180, 'a');
  1241.     Verbs.LocalizeActionButton(eLangPT, eGA_GiveTo,  181, 182, 'y');
  1242.     Verbs.LocalizeActionButton(eLangPT, eGA_PickUp,  189, 190, 'w');
  1243.     Verbs.LocalizeActionButton(eLangPT, eGA_LookAt,  191, 192, 's');
  1244.     Verbs.LocalizeActionButton(eLangPT, eGA_TalkTo,  193, 194, 'x');
  1245.     Verbs.LocalizeActionButton(eLangPT, eGA_Push,    183, 184, 'e');
  1246.     Verbs.LocalizeActionButton(eLangPT, eGA_Pull,    185, 186, 'd');
  1247.     Verbs.LocalizeActionButton(eLangPT, eGA_Use,     187, 188, 'c');
  1248.  
  1249.   // Dutch - eLangNL
  1250.     // yes/no-keys
  1251.     Verbs.SetKeys(eLangNL,  'j',  'n');
  1252.    
  1253.     Verbs.LocalizeActionButton(eLangNL, eGA_Open,    195, 196, 'q');
  1254.     Verbs.LocalizeActionButton(eLangNL, eGA_Close,   197, 198, 'a');
  1255.     Verbs.LocalizeActionButton(eLangNL, eGA_GiveTo,  199, 200, 'y');
  1256.     Verbs.LocalizeActionButton(eLangNL, eGA_PickUp,  207, 208, 'w');
  1257.     Verbs.LocalizeActionButton(eLangNL, eGA_LookAt,  209, 210, 's');
  1258.     Verbs.LocalizeActionButton(eLangNL, eGA_TalkTo,  211, 212, 'x');
  1259.     Verbs.LocalizeActionButton(eLangNL, eGA_Push,    201, 202, 'e');
  1260.     Verbs.LocalizeActionButton(eLangNL, eGA_Pull,    203, 204, 'd');
  1261.     Verbs.LocalizeActionButton(eLangNL, eGA_Use,     205, 206, 'c');
  1262.  
  1263.  
  1264. }
  1265.  
  1266.  
  1267. /***********************************************************************
  1268.  * AdjustGUIText()
  1269.  * This sets up the translation for the other GUI elements
  1270.  *
  1271.  ***********************************************************************/
  1272. static void Verbs::AdjustGUIText()
  1273. {
  1274.   bool custom_font;
  1275.   //int fontText    = verbsData.fontText;
  1276.   //int fontTextOut = verbsData.fontTextOut;
  1277.   //int fontSpeech  = verbsData.fontSpeech;
  1278.   //int fontSpeechOut = verbsData.fontOutlineSpeech;
  1279.  
  1280.   // English
  1281.   if (verbsData.lang == eLangEN){
  1282.     // English
  1283.     custom_font = false;
  1284.     /*
  1285.       // Just an example how you would define custom fonts:
  1286.       custom_font = true;
  1287.       fontText    = eFontLucasFan;
  1288.       fontTextOut = eFontLucasFanOut;    
  1289.     */
  1290.     lblOptions.Text        = "Options";
  1291.     lblOptionsMusic.Text   = "Music Volume";
  1292.     lblOptionsSound.Text   = "Sound Effects Volume";
  1293.     lblOptionsStyle.Text   = "Layout";
  1294.     lblOptionsGuiClassic.Text   = "Classic";
  1295.     lblOptionsGuiModern.Text    = "Modern";
  1296.     btnOptionsDefault.Text = "Default";
  1297.     btnOptionsSave.Text    = "Save";
  1298.     btnOptionsLoad.Text    = "Load";
  1299.     btnOptionsQuit.Text    = "Quit";
  1300.     btnOptionsResume.Text  = "Resume";
  1301.     lblPauseHeadline.Text  = "Game Paused";
  1302.     lblPauseMessage.Text   = "Press <SPACE> to continue";
  1303.     lblLoad.Text           = "Load";
  1304.     btnLoadCancel.Text     = "Cancel";
  1305.     lblSave.Text           = "Save";
  1306.     btnSaveCancel.Text     = "Cancel";
  1307.     lblQuitHeadline.Text   = "Quit Game";
  1308.     lblQuitMessage.Text    = "Are you sure you want to quit?";
  1309.     btnQuitYes.Text        = "Yes";
  1310.     btnQuitNo.Text         = "No";
  1311.   }
  1312.  
  1313.  
  1314.   else if (verbsData.lang == eLangDE) {
  1315.     // German
  1316.     custom_font = false;
  1317.  
  1318.     lblOptions.Text        = "Optionen";
  1319.     lblOptionsMusic.Text   = "Musik Lautstärke";
  1320.     lblOptionsSound.Text   = "Sound Effekte";
  1321.     lblOptionsStyle.Text   = "Bedienung";
  1322.     lblOptionsGuiClassic.Text   = "Klassisch";
  1323.     lblOptionsGuiModern.Text    = "Modern";
  1324.     btnOptionsDefault.Text = "Standard";
  1325.     btnOptionsSave.Text    = "Speichern";
  1326.     btnOptionsLoad.Text    = "Laden";
  1327.     btnOptionsQuit.Text    = "Beenden";
  1328.     btnOptionsResume.Text  = "Weiter";
  1329.     lblPauseHeadline.Text  = "Pause";
  1330.     lblPauseMessage.Text   = "Leertaste für weiter";
  1331.     lblLoad.Text           = "Spielstand laden";
  1332.     btnLoadCancel.Text     = "Abbruch";
  1333.     lblSave.Text           = "Spielstand speichern";
  1334.     btnSaveCancel.Text     = "Abbruch";
  1335.     lblQuitHeadline.Text   = "Spiel verlassen";
  1336.     lblQuitMessage.Text    = "Möchten Sie das Spiel beenden?";
  1337.     btnQuitYes.Text        = "Ja";
  1338.     btnQuitNo.Text         = "Nein";
  1339.   }
  1340.   else if (verbsData.lang == eLangES) {
  1341.     // Spanish
  1342.     custom_font = false;
  1343.     lblOptions.Text        = "Opciones";
  1344.     lblOptionsMusic.Text   = "Volumen de la música";
  1345.     lblOptionsSound.Text   = "Efectos de sonido ";
  1346.     lblOptionsStyle.Text   = "Diseño";
  1347.     lblOptionsGuiClassic.Text = "clásico";
  1348.     lblOptionsGuiModern.Text  = "moderno";    
  1349.     btnOptionsDefault.Text = "Restablecer";
  1350.     btnOptionsSave.Text    = "Guardar";
  1351.     btnOptionsLoad.Text    = "Cargar";
  1352.     btnOptionsQuit.Text    = "Salir";
  1353.     btnOptionsResume.Text  = "Volver";
  1354.     lblPauseHeadline.Text  = "Pausa";
  1355.     lblPauseMessage.Text   = "Pulsa Espacio para continuar";
  1356.     lblLoad.Text        = "Por favor, elige el juego a cargar";
  1357.     btnLoadCancel.Text  = "Cancelar";
  1358.     lblSave.Text        = "Por favor, introduce un nombre";
  1359.     btnSaveCancel.Text  = "Cancelar";
  1360.     lblQuitHeadline.Text = "¿Salir del juego?";
  1361.     lblQuitMessage.Text  = "¿Seguro que quieres salir?";
  1362.     btnQuitYes.Text     = "Si";
  1363.     btnQuitNo.Text      = "No";    
  1364.   }
  1365.   else if (verbsData.lang == eLangFR) {
  1366.     // French
  1367.     custom_font = false;
  1368.     lblOptions.Text   = "Paramètres";
  1369.     lblOptionsMusic.Text   = "Volume de la musique";
  1370.     lblOptionsSound.Text   = "Volume des sons";
  1371.     lblOptionsStyle.Text   = "Style";
  1372.     lblOptionsGuiClassic.Text = "classique";
  1373.     lblOptionsGuiModern.Text  = "moderne";    
  1374.     btnOptionsDefault.Text = "Réinitialiser";
  1375.     btnOptionsSave.Text    = "Sauver";
  1376.     btnOptionsLoad.Text    = "Charger";
  1377.     btnOptionsQuit.Text    = "Quitter";
  1378.     btnOptionsResume.Text  = "Reprendre";
  1379.     lblPauseHeadline.Text  = "Pause";
  1380.     lblPauseMessage.Text   = "Appuyez sur la barre d'espacement pour reprendre";
  1381.     lblLoad.Text        = "Choisissez une partie à charger";
  1382.     btnLoadCancel.Text  = "Annuler";
  1383.     lblSave.Text        = "Saisissez un nom";
  1384.     btnSaveCancel.Text  = "Annuler";
  1385.     lblQuitHeadline.Text = "Quitter";
  1386.     lblQuitMessage.Text  = "Voulez-vous vraiment quitter?";
  1387.     btnQuitYes.Text     = "Oui";
  1388.     btnQuitNo.Text      = "No";    
  1389.   }  
  1390.   else if (verbsData.lang == eLangIT) {
  1391.     // Italian
  1392.     custom_font = false;
  1393.     lblOptions.Text   = "Opzioni";
  1394.     lblOptionsMusic.Text   = "Volume della Musica";
  1395.     lblOptionsSound.Text   = "Effetti Sonori";
  1396.     lblOptionsStyle.Text   = "Disposizione";
  1397.     lblOptionsGuiClassic.Text = "classica";
  1398.     lblOptionsGuiModern.Text  = "moderna";    
  1399.     btnOptionsDefault.Text = "Risedersi";
  1400.     btnOptionsSave.Text    = "Salva";
  1401.     btnOptionsLoad.Text    = "Carica";
  1402.     btnOptionsQuit.Text    = "Esci";
  1403.     btnOptionsResume.Text  = "Continua";
  1404.     lblPauseHeadline.Text  = "Partita in Pausa";
  1405.     lblPauseMessage.Text   = "Premi Spazio per Continuare";
  1406.     lblLoad.Text         = "Scegli una partita da caricare";
  1407.     btnLoadCancel.Text   = "Cancella";
  1408.     lblSave.Text         = "Inserisci un nome";
  1409.     btnSaveCancel.Text   = "Cancella";
  1410.     lblQuitHeadline.Text = "Uscire dal gioco";
  1411.     lblQuitMessage.Text  = "Sei sicuro/a che vuoi uscire?";
  1412.     btnQuitYes.Text      = "Si";
  1413.     btnQuitNo.Text       = "No";    
  1414.   }
  1415.   else if (verbsData.lang == eLangPT) {
  1416.     // Portuguese
  1417.     custom_font = false;
  1418.     lblOptions.Text   = "Opções";
  1419.     lblOptionsMusic.Text   = "Volume Música";
  1420.     lblOptionsSound.Text   = "Efeitos Sonoros";
  1421.     lblOptionsStyle.Text   = "Disposição";
  1422.     lblOptionsGuiClassic.Text = "clássica";
  1423.     lblOptionsGuiModern.Text  = "moderna";    
  1424.     btnOptionsDefault.Text    = "Standard";
  1425.     btnOptionsSave.Text    = "Gravar";
  1426.     btnOptionsLoad.Text    = "Restaurar";
  1427.     btnOptionsQuit.Text    = "Desistir";
  1428.     btnOptionsResume.Text  = "Continuar";
  1429.     lblPauseHeadline.Text  = "Pausa";
  1430.     lblPauseMessage.Text   = "Prima Space para continuar";
  1431.     lblLoad.Text           = "Por favor escolha um jogo";
  1432.     btnLoadCancel.Text     = "Cancelar";
  1433.     lblSave.Text         = "Por favor insira um nome";
  1434.     btnSaveCancel.Text   = "Cancelar";
  1435.     lblQuitHeadline.Text = "Desistir";
  1436.     lblQuitMessage.Text  = "De certeza que quer desistir?";
  1437.     btnQuitYes.Text      = "Si";
  1438.     btnQuitNo.Text       = "No";      
  1439.   }
  1440.   else if (verbsData.lang == eLangNL) {
  1441.     // Dutch
  1442.     custom_font = false;
  1443.     lblOptions.Text   = "Opties";
  1444.     lblOptionsMusic.Text   = "Muziek Volume";
  1445.     lblOptionsSound.Text   = "Geluidseffecten";
  1446.     lblOptionsStyle.Text   = "Bediening";
  1447.     lblOptionsGuiClassic.Text   = "klassiek";
  1448.     lblOptionsGuiModern.Text    = "modern";
  1449.     btnOptionsDefault.Text = "Standaard";
  1450.     btnOptionsSave.Text    = "Opslaan";
  1451.     btnOptionsLoad.Text    = "Laden";
  1452.     btnOptionsQuit.Text    = "Stop";
  1453.     btnOptionsResume.Text  = "Ga door";
  1454.     lblPauseHeadline.Text  = "Pauze";
  1455.     lblPauseMessage.Text   = "Druk op de Spatiebalk om door te gaan";
  1456.     lblLoad.Text           = "Kies a.u.b. een spel om te laden";
  1457.     btnLoadCancel.Text     = "Annuleren";
  1458.     lblSave.Text           = "Vul a.u.b. een naam in";
  1459.     btnSaveCancel.Text     = "Annuleren";
  1460.     lblQuitHeadline.Text   = "Sluit spel af";
  1461.     lblQuitMessage.Text    = "Weet u zeker dat u wilt stoppen?";
  1462.     btnQuitYes.Text        = "Ja";
  1463.     btnQuitNo.Text         = "Nee";
  1464.   }  
  1465.  
  1466.   // Apply language dependend custom fonts if needed
  1467.   if (custom_font) {
  1468.     Game.SpeechFont   = verbsData.fontSpeech;
  1469.     Game.NormalFont   = verbsData.fontText;
  1470.     lblAction.Font    = verbsData.fontTextOut;
  1471.     lblOptions.Font   = verbsData.fontText;
  1472.     lblOptionsMusic.Font   = verbsData.fontText;
  1473.     lblOptionsSound.Font   = verbsData.fontText;
  1474.     lblOptionsStyle.Font   = verbsData.fontText;
  1475.     lblOptionsGuiClassic.Font   = verbsData.fontTextOut;
  1476.     lblOptionsGuiModern.Font    = verbsData.fontTextOut;
  1477.     btnOptionsDefault.Font = verbsData.fontText;
  1478.     btnOptionsSave.Font    = verbsData.fontText;
  1479.     btnOptionsLoad.Font    = verbsData.fontText;
  1480.     btnOptionsQuit.Font    = verbsData.fontText;
  1481.     btnOptionsResume.Font  = verbsData.fontText;
  1482.     lblPauseHeadline.Font  = verbsData.fontText;
  1483.     lblPauseMessage.Font   = verbsData.fontText;
  1484.     lblLoad.Font           = verbsData.fontText;
  1485.     btnLoadCancel.Font     = verbsData.fontText;
  1486.     lblSave.Font           = verbsData.fontText;
  1487.     btnSaveCancel.Font     = verbsData.fontText;
  1488.     lblQuitHeadline.Font   = verbsData.fontText;
  1489.     lblQuitMessage.Font    = verbsData.fontText;
  1490.     btnQuitYes.Font        = verbsData.fontText;
  1491.     btnQuitNo.Font         = verbsData.fontText;
  1492.   }
  1493. }
  1494.  
  1495. /***********************************************************************
  1496.  * InitGuiLanguage()
  1497.  * Assigns the buttons graphics to the GUI elements
  1498.  *
  1499.  ***********************************************************************/
  1500. static void Verbs::InitGuiLanguage()
  1501. {
  1502.   int lang = verbsData.lang;
  1503.   //Verbs.AdjustLanguage();
  1504.   int i;
  1505.   GUIControl*gc;
  1506.   Button*b;
  1507.  
  1508.   while (i < ACT_COUNT) {
  1509.     gc = verbsData.guiMain.Controls[actionButtonData[i].button];
  1510.     b =  gc.AsButton;
  1511.     b.NormalGraphic=actionButtonData[i].button_graphic_normal[lang];
  1512.     i++;
  1513.   }
  1514. }
  1515.  
  1516. // ============================= Player function ===========================================
  1517.  
  1518.  
  1519. /***********************************************************************
  1520.  * FreezePlayer()
  1521.  * Use this function to prevent the player from moving by the following movement functions of the template.
  1522.  *
  1523.  ***********************************************************************/
  1524. static void Verbs::FreezePlayer()
  1525. {
  1526.   verbsData.player_frozen = true;
  1527. }
  1528.  
  1529. /***********************************************************************
  1530.  * UnfreezePlayer()
  1531.  * Use this function to undo the freeze_player function and let the characters move again.
  1532.  *
  1533.  ***********************************************************************/
  1534. static void Verbs::UnfreezePlayer()
  1535. {
  1536.   verbsData.player_frozen = false;
  1537. }
  1538.  
  1539. /***********************************************************************
  1540.  * SetPlayer(Character*ch)  
  1541.  * Similar to the AGS function Character.SetAsPlayer(). The difference is, that make the previous character clickable again, whereas the new character gets unclickable.
  1542.  *
  1543.  ***********************************************************************/
  1544. static void Verbs::SetPlayer(Character*ch)
  1545. {
  1546.   // if old and new player character are in the same room then scroll room
  1547.   if (player.Room==ch.Room) {
  1548.     int x = Screen.Viewport.X;
  1549.     int tx = ch.x - 160;
  1550.     if (tx < 0) tx = 0;
  1551.     else if (tx > Room.Width - 320) tx = Room.Width-320;
  1552.     Screen.Viewport.X = x;
  1553.     while (x<tx) {
  1554.       x += verbsData.player_walk_x_speed;
  1555.       if (x > tx) x=tx;
  1556.       Screen.Viewport.X = x;
  1557.       Wait(1);
  1558.     }
  1559.     while (x > tx) {
  1560.       x -= verbsData.player_walk_x_speed;
  1561.       if (x < tx) x=tx;
  1562.       Screen.Viewport.X = x;
  1563.       Wait (1);
  1564.     }
  1565.   }
  1566.   else // if they are in different rooms
  1567.     player.StopMoving();
  1568.     player.Clickable=true;
  1569.     ch.Clickable=false;
  1570.     ch.SetAsPlayer();
  1571. }
  1572.  
  1573. /***********************************************************************
  1574.  * MovePlayerEx(int x, int y, WalkWhere direct)
  1575.  * Move the player character to x,y coords, waiting until he/she gets there,
  1576.  * but allowing to cancel the action by pressing a mouse button.
  1577.  * Return values:
  1578.  * 0 = movement cancelled
  1579.  * 1 = not cancelled
  1580.  * 2 = reached the given coordinates
  1581.  *
  1582.  ***********************************************************************/
  1583. static int Verbs::MovePlayerEx(int x, int y, WalkWhere direct)
  1584. {
  1585.   bool movement_canceled = false;
  1586.   // Move the player character to x,y coords, waiting until he/she gets there,
  1587.   // but allowing to cancel the action by pressing a mouse button.
  1588.   if (verbsData.player_frozen == false) {
  1589.     player.Walk(x, y, eNoBlock, direct);
  1590.     // wait for release of mouse button
  1591.     while (player.Moving && (mouse.IsButtonDown(eMouseLeft) || mouse.IsButtonDown(eMouseRight))) {
  1592.       Wait(1);
  1593.       mouse.Update();
  1594.       Verbs.CheckDefaultAction();
  1595.     }
  1596.     // abort moving on new mouse down
  1597.     while (player.Moving) {
  1598.       int xm = mouse.x;
  1599.       int ym = mouse.y;
  1600.       InventoryItem*ii = InventoryItem.GetAtScreenXY(xm, ym);
  1601.       if (mouse.IsButtonDown(eMouseLeft) && (GUI.GetAtScreenXY(xm, ym)==null || ii!=null)) {
  1602.         player.StopMoving();
  1603.         movement_canceled = true;
  1604.       }
  1605.       else if (mouse.IsButtonDown(eMouseRight) && (GUI.GetAtScreenXY(xm, ym)==null || ii!=null)) {
  1606.         player.StopMoving();
  1607.         movement_canceled = true;
  1608.       }
  1609.       else if (mouse.IsButtonDown(eMouseLeft) && GUI.GetAtScreenXY(xm, ym) == gMain) {
  1610.         player.StopMoving();
  1611.         movement_canceled = true;
  1612.       }
  1613.       else {
  1614.         Wait(1);
  1615.         mouse.Update();
  1616.         Verbs.CheckDefaultAction();
  1617.       }
  1618.     }
  1619.     if (!movement_canceled && player.x == x && player.y == y) return 2;
  1620.     else if (!movement_canceled) return 1;
  1621.     else return 0;
  1622.   }
  1623.   else return 0;
  1624. }
  1625.  
  1626. /***********************************************************************
  1627.  * MovePlayer(int x, int y)
  1628.  * Moves the player character around on walkable areas, a wrapper for MovePlayerEx.
  1629.  * 0 = movement cancelled
  1630.  * 1 = if the character has reached the given coordinates
  1631.  *
  1632.  ***********************************************************************/
  1633. static int Verbs::MovePlayer(int x, int y)
  1634. {
  1635.   //Move the player character to x,y coords, waiting until he/she gets there, but allowing to cancel the action
  1636.   //by pressing a mouse button.
  1637.   return Verbs.MovePlayerEx (x, y, eWalkableAreas);
  1638. }
  1639.  
  1640.  
  1641. /***********************************************************************
  1642.  * GoToCharacterEx(Character*chwhogoes, Character*ch, CharacterDirection dir, int xoffset, int yoffset, bool NPCfacesplayer, int blocking)
  1643.  * Goes to a character staying at the side defined by ‘direction’: 1 up, 2 right, 3 down, 4 left and it stays at x-offset or y-offset from the character.
  1644.  * blocking: 0=non-blocking; 1=blocking; 2=semi-blocking
  1645.  * Returns 1, if the character has reached it’s goal and 0 if the movement has been cancelled before.
  1646.  *
  1647.  ***********************************************************************/
  1648. static int Verbs::GoToCharacterEx(Character*chwhogoes, Character*ch, CharacterDirection dir, int xoffset, int yoffset, bool NPCfacesplayer, int blocking)
  1649. {
  1650.   Character*pl = chwhogoes;
  1651.   int chx, chy;
  1652.   chx = ch.x;
  1653.   chy = ch.y;
  1654.   int arrived=1;
  1655.   if (Geometry.Offset(pl.x, chx) > xoffset || Geometry.Offset(pl.y, chy) > yoffset) {
  1656.     if (dir == 0) {
  1657.       // get the nearest position
  1658.       if (Geometry.Offset (chx, pl.x) >= Geometry.Offset(chy, pl.y)) {
  1659.         // right or left
  1660.         if (pl.x >= chx) dir = eDirectionRight;
  1661.         else dir = eDirectionLeft;
  1662.       }
  1663.       else {
  1664.         if (pl.y >= chy) dir = eDirectionDown;
  1665.         else dir = eDirectionUp;
  1666.       }
  1667.     }
  1668.     // calculate target position
  1669.     if (dir == eDirectionUp)    chy-=yoffset;
  1670.     else if (dir == eDirectionRight) chx+=xoffset;
  1671.     else if (dir == eDirectionDown)  chy+=yoffset;
  1672.     else if (dir == eDirectionLeft)  chx-=xoffset;
  1673.     // move character
  1674.     if (blocking==0) {
  1675.       pl.Walk(chx, chy);
  1676.       arrived = 0;
  1677.     }
  1678.     else if (blocking==1) {
  1679.       pl.Walk(chx, chy, eBlock, eWalkableAreas);
  1680.       arrived=1;
  1681.     }
  1682.     else if (blocking==2) arrived=Verbs.MovePlayer(chx, chy);
  1683.   }
  1684.   if (arrived>0) {
  1685.     // characters only face each other after the moving character arrived at the target point
  1686.     if (NPCfacesplayer) ch.FaceCharacter(pl, eBlock);
  1687.     pl.FaceCharacter(ch, eBlock);
  1688.   }
  1689.   return arrived;
  1690. }
  1691.  
  1692. /***********************************************************************
  1693.  * NPCGoToCharacter(Character*chwhogoes, Character*chtogoto, CharacterDirection dir, bool NPCfacesplayer, int blocking)
  1694.  * The same as GoToCharacterEx, just with an default offset of x=35 and y=20
  1695.  * blocking: 0=non-blocking; 1=blocking; 2=semi-blocking
  1696.  * Returns 1, if the character has reached it’s goal and 0 if the movement has been cancelled before.
  1697.  *
  1698.  ***********************************************************************/
  1699. static int Verbs::NPCGoToCharacter(Character*chwhogoes, Character*chtogoto, CharacterDirection dir, bool NPCfacesplayer, int blocking)
  1700. {
  1701.   // same as above but with default x and y offset.
  1702.   int defaultxoffset = 35;
  1703.   int defaultyoffset = 20;
  1704.   return Verbs.GoToCharacterEx (chwhogoes, chtogoto, dir, defaultxoffset, defaultyoffset, NPCfacesplayer, blocking);
  1705. }
  1706.  
  1707. /***********************************************************************
  1708.  * GoToCharacter(Character*ch, CharacterDirection dir, bool NPCfacesplayer, int blocking)
  1709.  * The same as GoToCharacterEx, just with an default offset of x=35 and y=20 and the player character set as default
  1710.  * blocking: 0=non-blocking; 1=blocking; 2=semi-blocking
  1711.  * Returns 1, if the character has reached it’s goal and 0 if the movement has been cancelled before.
  1712.  *
  1713.  ***********************************************************************/
  1714. static int Verbs::GoToCharacter(Character*ch, CharacterDirection dir, bool NPCfacesplayer, int blocking)
  1715. {
  1716.   // same as above but with default x and y offset.
  1717.   int defaultxoffset = 35;
  1718.   int defaultyoffset = 20;
  1719.   return Verbs.GoToCharacterEx (player, ch, dir, defaultxoffset, defaultyoffset, NPCfacesplayer, blocking);
  1720. }
  1721.  
  1722. /***********************************************************************
  1723.  * GoTo(int blocking)
  1724.  * Go to whatever the player clicked on. This function is used to intercept a walk-to event and check if the player has reached it’s goal.
  1725.  * E.g. this is used in the exit extension processing. blocking: 0=non-blocking; 1=blocking; 2=semi-blocking
  1726.  *
  1727.  ***********************************************************************/
  1728. static int Verbs::GoTo(int blocking)
  1729. {
  1730.   int xtogo, ytogo;
  1731.   int locationtype = GetLocationType(mouse.x, mouse.y);
  1732.   Hotspot* hot_spot = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
  1733.   int arrived=0;
  1734.  
  1735.   if (locationtype==eLocationCharacter) {
  1736.     arrived = Verbs.GoToCharacter(Character.GetAtScreenXY(mouse.x, mouse.y), 0, false, blocking);
  1737.   }
  1738.   else {
  1739.     if (locationtype==eLocationHotspot && hot_spot.ID>0 && (hot_spot.WalkToX >0 || hot_spot.WalkToY > 0) ) {
  1740.       xtogo=hot_spot.WalkToX;
  1741.       ytogo=hot_spot.WalkToY;
  1742.     }
  1743.     else if (locationtype==eLocationObject) {
  1744.       Object*obj=Object.GetAtScreenXY(mouse.x, mouse.y);
  1745.       if (obj.Graphic > 0) xtogo=obj.X + (Game.SpriteWidth[obj.Graphic] / 2);
  1746.       else xtogo = obj.X;
  1747.       ytogo=obj.Y;
  1748.     }
  1749.     else {
  1750.       xtogo=mouse.x;
  1751.       ytogo=mouse.y;
  1752.     }
  1753.     xtogo+=Screen.Viewport.X;
  1754.     ytogo+=Screen.Viewport.Y;
  1755.     if (blocking==0) player.Walk(xtogo, ytogo, eNoBlock);
  1756.    
  1757.     else if (blocking==1) {
  1758.       player.Walk(xtogo, ytogo, eBlock);
  1759.       arrived=1;
  1760.     }
  1761.     else if (blocking==2) arrived=Verbs.MovePlayer(xtogo, ytogo);
  1762.   }
  1763.   return arrived;
  1764. }
  1765.  
  1766. /***********************************************************************
  1767.  * SetApproachingChar(bool enable)
  1768.  * If set to true, the player walks to other chars before talking or giving items.
  1769.  * This behaviour is initially defined in the guiscript, this function is used to change it during runtime.
  1770.  *
  1771.  ***********************************************************************/
  1772. static void Verbs::SetApproachingChar(bool enable)
  1773. {
  1774.   // If set to true, the player walks to other chars before talking or giving items.
  1775.   verbsData.approachCharInteract = enable;
  1776. }
  1777.  
  1778. /***********************************************************************
  1779.  * WalkOffScreen()
  1780.  * Handles the action of hotspots with exit extension ('>e').
  1781.  * double click on hotspots/objects will make the player exit the room instantly
  1782.  *
  1783.  ***********************************************************************/
  1784. static void Verbs::WalkOffScreen()
  1785. {
  1786.  
  1787.   // doubleclick
  1788.   if (Verbs.UsedAction(eGA_WalkTo)) {
  1789.     if ( verbsData.exitExtensionDoubleclick && DoubleClick.Event[eMouseLeft])
  1790.     {
  1791.       if (verbsData.location_type == eLocationHotspot) hotspot[verbsData.location_id].RunInteraction(eModeUsermode1);
  1792.       else if (verbsData.location_type == eLocationObject) object[verbsData.location_id].RunInteraction(eModeUsermode1);
  1793.      
  1794.     }
  1795.     else
  1796.     {
  1797.       if (Verbs.GoTo(2) ){
  1798.         int x = player.x,
  1799.             y = player.y;
  1800.            
  1801.         int offset = verbsData.walkOffScreenOffset;
  1802.         int dir = Verbs.ExtensionEx(2,verbsData.location_clicked);
  1803.        
  1804.         if      (dir=='u') y -= offset;
  1805.         else if (dir=='d') y += offset;
  1806.         else if (dir=='l') x -= offset;
  1807.         else if (dir=='r') x += offset;
  1808.      
  1809.        
  1810.         if (Verbs.MovePlayerEx(x, y, eAnywhere) >0){
  1811.           if (verbsData.location_type == eLocationHotspot) hotspot[verbsData.location_id].RunInteraction(eModeUsermode1);
  1812.           else if (verbsData.location_type == eLocationObject) object[verbsData.location_id].RunInteraction(eModeUsermode1);        
  1813.         }
  1814.        
  1815.       }    
  1816.     }
  1817.   }
  1818. }
  1819.  
  1820. // ============================= Unhandled Events ===========================================
  1821.  
  1822.  
  1823. /***********************************************************************
  1824.  * Unhandled(int door_script)
  1825.  *  Please check this section and replace the boring default values with your own.
  1826.  *  If you courious, how it all works, keep on reading this comment  ;-)
  1827.  *
  1828.  * Check modes with: if(UsedAction(A_???)), check types by if(type==#). types:
  1829.  *  1   a hotspot
  1830.  *  2   a character
  1831.  *  3   an object
  1832.  *  4   an inventory item.
  1833.  *  5   inv. item on hotspot
  1834.  *  6   inv. item on character
  1835.  *  7   inv. item on object
  1836.  *  8   inv. item on inv. item
  1837.  *
  1838.  *  You have the string "locationname" that is the name of
  1839.  *  what you clicked on, and the string "usedinvname" that is
  1840.  *  the name of the item that was used on where you clicked (only for types 5,6,7,8)
  1841.  *
  1842.  ***********************************************************************/
  1843. static void Verbs::Unhandled(int door_script)
  1844. {
  1845.   InventoryItem*ii = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
  1846.   int type=0;
  1847.   if (verbsData.location_type == eLocationHotspot)   type = 1;
  1848.   if (verbsData.location_type == eLocationCharacter) type = 2;
  1849.   if (verbsData.location_type == eLocationObject)    type = 3;
  1850.  
  1851.   String locationname;
  1852.   String usedinvname;
  1853.  
  1854.   verbsData.location = verbsData.location_clicked;
  1855.   Verbs.RemoveExtension();
  1856.   locationname= verbsData.location;
  1857.  
  1858.   if (ii!=null) type = 4;
  1859.  
  1860.   if ( verbsData.AGSCursorMode == eModeUseinv) {
  1861.     if (ii!=null) {
  1862.       usedinvname = ii.Name;
  1863.       verbsData.location = usedinvname;
  1864.       Verbs.RemoveExtension();
  1865.       usedinvname = verbsData.location;
  1866.       if (type>0) type+=4;
  1867.     }
  1868.   }
  1869.   if ( verbsData.AGSCursorMode != eModeUsermode2 && type != 0) {
  1870.     if (type==2 || type==6) player.FaceCharacter(character[verbsData.location_id], eBlock);
  1871.  
  1872.     // unhandled USE
  1873.     if (Verbs.UsedAction(eGA_Use)) {
  1874.       // use inv on inv
  1875.       if (type >= 5) player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledUseInv]);
  1876.       // use
  1877.       else player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledUse]);
  1878.     }
  1879.    
  1880.     // unhandled LOOK AT  
  1881.     else if (Verbs.UsedAction(eGA_LookAt)) {
  1882.       // look at hotspots, objects etc.
  1883.       if (type!=2) player.Say(String.Format(verbsData.unhandled_strings[eVerbGuiUnhandledLook], locationname));
  1884.       // look at characters
  1885.       else player.Say(String.Format(verbsData.unhandled_strings[eVerbGuiUnhandledLookChar], locationname));
  1886.     }
  1887.    
  1888.     // unhandled PUSH
  1889.     else if (Verbs.UsedAction(eGA_Push)) {
  1890.       // push everything except characters
  1891.       if (type!=2) player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledPush]);
  1892.       // push characters
  1893.       else player.Say(String.Format(verbsData.unhandled_strings[eVerbGuiUnhandledPushChar], locationname));
  1894.     }
  1895.    
  1896.     // unhandled PULL
  1897.     else if (Verbs.UsedAction(eGA_Pull)){
  1898.       // pull everything except characters
  1899.       if (type!=2) player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledPull]);
  1900.       // pull characters
  1901.       else player.Say(String.Format(verbsData.unhandled_strings[eVerbGuiUnhandledPullChar], locationname));
  1902.     }
  1903.    
  1904.     // unhandled CLOSE
  1905.     else if (Verbs.UsedAction(eGA_Close)){
  1906.       if (door_script == 1) player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledCloseDoor]);
  1907.       else if (type == 2) player.Say(String.Format(verbsData.unhandled_strings[eVerbGuiUnhandledCloseChar], locationname));
  1908.       else player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledClose]);
  1909.     }
  1910.    
  1911.     // unhandled OPEN
  1912.     else if (Verbs.UsedAction(eGA_Open)) {
  1913.       if (door_script == 1) player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledOpenDoor]);
  1914.       else if (type ==2) player.Say(String.Format(verbsData.unhandled_strings[eVerbGuiUnhandledOpenChar], locationname));
  1915.       else player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledOpen]);
  1916.     }
  1917.    
  1918.     // unhandled PICKUP
  1919.     else if (Verbs.UsedAction(eGA_PickUp)) {
  1920.       if (type!=2) player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledPickup]);
  1921.       else player.Say(String.Format(verbsData.unhandled_strings[eVerbGuiUnhandledPickupChar], locationname) );
  1922.     }
  1923.  
  1924.     // unhandled TALK TO
  1925.     else if (Verbs.UsedAction(eGA_TalkTo)) {
  1926.       if (type==2) player.Say(String.Format(verbsData.unhandled_strings[eVerbGuiUnhandledTalkToChar], locationname));
  1927.       else player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledTalkTo]);
  1928.     }
  1929.    
  1930.     // unhandled USE INV
  1931.     else if (Verbs.UsedAction(eGA_UseInv)) player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledUseInv]);
  1932.    
  1933.     // unhandled GIVE
  1934.     else if (verbsData.ItemGiven != null) player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledGive]);  
  1935.    
  1936.     // unhandled DEFAULT
  1937.     else if (type==4) player.Say(verbsData.unhandled_strings[eVerbGuiUnhandledDefault]);
  1938.  
  1939.   }
  1940. }
  1941.  
  1942. // ============================= interaction functions ===========================================
  1943.  
  1944. /***********************************************************************
  1945.  * EnterRoom(this Character*, int newRoom, int x, int y, CharacterDirection dir)
  1946.  * Similar to the AGS function Character.ChangeRoom. The difference is, that you can also define,
  1947.  * it which direction the character should look. Using this function makes the character turn to the direction, mentioned above.
  1948.  *
  1949.  ***********************************************************************/
  1950. void EnterRoom(this Character*, int newRoom, int x, int y, CharacterDirection dir)
  1951. {
  1952.   this.ChangeRoom(newRoom, x, y);
  1953.   this.FaceDirection(dir);
  1954. }
  1955.  
  1956. /***********************************************************************
  1957.  * AnyClickMove(int x, int y, CharacterDirection dir)
  1958.  * Moves the player character to the coordinates given in the parameters.
  1959.  * If the player reaches the destination, it’s turns to the given direction.
  1960.  * You can use this kind of functions (including the movePlayer function which is called by this function),
  1961.  * to check if the player actually reached it’s destination.
  1962.  * Returns 1, if the character has reached it’s goal and 0 if the movement has been cancelled before.
  1963.  *
  1964.  ***********************************************************************/
  1965. static int Verbs::AnyClickMove(int x, int y, CharacterDirection dir)
  1966. {
  1967.   int result = Verbs.MovePlayer(x, y);
  1968.   if (result) {
  1969.    player.FaceDirection(dir, eBlock);
  1970.   }
  1971.   return result;
  1972. }
  1973.  
  1974. /***********************************************************************
  1975.  * AnyClickWalk(int x, int y, CharacterDirection dir)
  1976.  * This function is almost similar to any_click_move. But it’s only called, if the current action is eMA_WalkTo.
  1977.  *
  1978.  ***********************************************************************/
  1979. static int Verbs::AnyClickWalk(int x, int y, CharacterDirection dir)
  1980. {
  1981.   int result=1;
  1982.   if (Verbs.UsedAction(eGA_WalkTo)) Verbs.AnyClickMove(x, y, dir);
  1983.   else result=0;
  1984.   return result;
  1985. }
  1986.  
  1987. /***********************************************************************
  1988.  * AnyClickWalkLook(int x, int y, CharacterDirection dir, String lookat)
  1989.  * This function moves the player character to the given location, turns it to the given direction and lets it say the message, given in the string.
  1990.  *
  1991.  ***********************************************************************/
  1992. static int Verbs::AnyClickWalkLook(int x, int y, CharacterDirection dir, String lookat)
  1993. {
  1994.   int result=Verbs.AnyClickWalk(x, y, dir);
  1995.   if (result==0 && lookat.Length>0) {
  1996.     result=1;
  1997.     if (Verbs.AnyClickMove(x, y, dir)) {
  1998.       player.Say(lookat);
  1999.     }
  2000.   }
  2001.   return result;
  2002. }
  2003.  
  2004. /***********************************************************************
  2005.  * AnyClickUseInv(InventoryItem*iitem, int x, int y, CharacterDirection dir)
  2006.  * This function moves the player to the given destination.
  2007.  * It returns 0, if the action is unhandled, 1 is returned, if the action is handled, but has been cancelled.
  2008.  * 2 is returned, if everything went fine.
  2009.  *
  2010.  ***********************************************************************/
  2011. static int Verbs::AnyClickUseInv(InventoryItem*iitem, int x, int y, CharacterDirection dir)
  2012. {
  2013.   int result=0;
  2014.   if (Verbs.UsedAction(eGA_UseInv)) {
  2015.     if (player.ActiveInventory == iitem) {
  2016.       if (Verbs.AnyClickMove(x, y, dir)) result = 2;
  2017.       else result = 1;
  2018.     }
  2019.   }
  2020.   return result;
  2021.  
  2022. }
  2023.  
  2024. /***********************************************************************
  2025.  * AnyClickUseInv(InventoryItem*iitem, int x, int y, CharacterDirection dir)
  2026.  * This function starts the same as any_click_walk_look. If an object ID > 0 has been given, this object is set invisible.
  2027.  * Afterwards the inventory item is going to be added to the player’s inventory and if there’s an audioclip in the parameters, that one is played too.
  2028.  * It returns 0, if the action is unhandled, 1 is returned, if the action is handled, but has been cancelled.
  2029.  * 2 is returned, if the item was picked up
  2030.  *
  2031.  ***********************************************************************/
  2032. static int Verbs::AnyClickWalkLookPick(int x, int y, CharacterDirection dir, String lookat, int obj, InventoryItem*iitem, AudioClip *sound)
  2033. {
  2034.   AudioChannel *chan;
  2035.   int result=Verbs.MovePlayer(x, y);
  2036.  
  2037.   if (result>0 && Verbs.UsedAction(eGA_PickUp)) {
  2038.     if (Verbs.AnyClickMove(x, y, dir)) {
  2039.       if (lookat.Length>0) player.Say(lookat);
  2040.       if (sound != null)chan = sound.Play();
  2041.       if (obj>=0) object[obj].Visible=false;
  2042.       if (iitem!=null) player.AddInventory(iitem);
  2043.       result=2;
  2044.     }
  2045.   }
  2046.   return result;
  2047. }
  2048.  
  2049. // ============================= Door functions ==========================================
  2050.  
  2051. /***********************************************************************
  2052.  * AnyClickSpecial(int door_id, int obj, int x, int y, CharacterDirection dir, int nr_room, int nr_x, int nr_y, CharacterDirection nr_dir, AudioClip *opensound, AudioClip *closesound, int key, int closevalue)
  2053.  * This function extends AnyClick with the following parameters:
  2054.  *
  2055.  *   opensound: custom sound to be played, when the door is being opend
  2056.  *   closesound: custom sound to be played, when the door is being closed
  2057.  *   key: the id of the inventory item, that can unlock the door, -1 masterkey, -2 if the door cannot be unlocked
  2058.  *   closevalue: default 0 (closed), but you can also set 2 (locked).
  2059.  ***********************************************************************/
  2060. static int Doors::AnyClickSpecial(int door_id, int obj, int x, int y, CharacterDirection dir, int nr_room, int nr_x, int nr_y, CharacterDirection nr_dir, AudioClip *opensound, AudioClip *closesound, int key, int closevalue) {
  2061.   // key = -1: masterkey - even locked doors will be opened
  2062.   // key = -2: door can't be unlocked (like rusted)
  2063.   AudioChannel *chan;
  2064.   int result=1;
  2065.  
  2066.   if (Verbs.UsedAction(eGA_Close)) {
  2067.     if (Doors.GetDoorState(door_id) == 0 || Doors.GetDoorState(door_id) == 2) Verbs.Unhandled(1);
  2068.     else if (Doors.GetDoorState(door_id) == 1 ) {
  2069.       if (Verbs.AnyClickMove(x, y, dir)) {
  2070.         if (closesound != null) chan = closesound.Play();
  2071.         // Play default sound
  2072.         else if (verbsData.closeDoorSound != null) chan = verbsData.closeDoorSound.Play();
  2073.         object[obj].Visible=false;
  2074.         Doors.SetDoorState(door_id, closevalue);
  2075.       }
  2076.     }
  2077.   }
  2078.   else if (Verbs.UsedAction(eGA_Open)) {
  2079.     if (Doors.GetDoorState(door_id) == 0 || (Doors.GetDoorState(door_id) == 2 && key == -1 ) ) {
  2080.       if (Verbs.AnyClickMove (x, y, dir))
  2081.       {
  2082.         if (opensound != null) chan = opensound.Play();
  2083.         // Play default sound
  2084.         else if (verbsData.openDoorSound != null) chan = verbsData.openDoorSound.Play();    
  2085.        
  2086.         object[obj].Visible=true;
  2087.         Doors.SetDoorState(door_id, 1);
  2088.       }
  2089.     }
  2090.     else if (Doors.GetDoorState(door_id) == 1 ) Verbs.Unhandled(1);
  2091.     else if (Doors.GetDoorState(door_id) == 2 ) {
  2092.       if (Verbs.AnyClickMove(x, y, dir)) if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringLocked])) player.Say(verbsData.door_strings[eDoorStringLocked]);
  2093.     }
  2094.   }
  2095.   else if (Verbs.UsedAction(eGA_WalkTo)) {
  2096.     if (Doors.GetDoorState(door_id) == 1) {
  2097.       if ( verbsData.exitDoorDoubleclick && DoubleClick.Event[eMouseLeft] )
  2098.       {
  2099.         if (Verbs.MovePlayerEx(player.x, player.y, eWalkableAreas) > 0 ) player.EnterRoom(nr_room, nr_x, nr_y, nr_dir);
  2100.         result = 2;
  2101.       }
  2102.       else
  2103.       {
  2104.         if (Verbs.GoTo(2)){
  2105.           player.EnterRoom(nr_room, nr_x, nr_y, nr_dir);
  2106.           result = 2;          
  2107.         }
  2108.        
  2109.       }
  2110.     }
  2111.     else Verbs.AnyClickMove(x, y, dir);
  2112.  
  2113.   }
  2114.   else if (Verbs.UsedAction (eGA_LookAt) && !String.IsNullOrEmpty(verbsData.door_strings[eDoorStringLookAt]) ) {
  2115.     if (Verbs.AnyClickMove (x, y, dir)) player.Say(verbsData.door_strings[eDoorStringLookAt]);
  2116.   }
  2117.   else if (Verbs.UsedAction(eGA_UseInv) && key >= 0) {
  2118.     if (Verbs.AnyClickMove(x, y, dir)) {
  2119.       if (player.ActiveInventory == inventory[key] ) {
  2120.         if (Doors.GetDoorState(door_id) == 1 ) {
  2121.           if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringCloseFirst]) ) player.Say(verbsData.door_strings[eDoorStringCloseFirst]);
  2122.         }
  2123.         else if (Doors.GetDoorState(door_id) == 2 ) {
  2124.           if (verbsData.unlockDoorSound != null) chan = verbsData.unlockDoorSound.Play();
  2125.           if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringUnlock])) player.Say(verbsData.door_strings[eDoorStringUnlock]);
  2126.           Doors.SetDoorState(door_id, closevalue);
  2127.         }
  2128.         else if (Doors.GetDoorState(door_id) == 0 ) {
  2129.           object[obj].Visible=false;
  2130.           Doors.SetDoorState(door_id, 2);
  2131.           if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringRelock])) player.Say(verbsData.door_strings[eDoorStringRelock]);
  2132.         }
  2133.       }
  2134.       else if (!String.IsNullOrEmpty(verbsData.door_strings[eDoorStringWrongItem])) player.Say(verbsData.door_strings[eDoorStringWrongItem]);
  2135.     }
  2136.   }
  2137.   else result=0;
  2138.  
  2139.   return result;
  2140.   // 0 = unhandled
  2141.   // 1 = handled
  2142.   // 2 = NewRoom
  2143. }
  2144.  
  2145. /***********************************************************************
  2146.  * AnyClick(int door_id, int obj, int x, int y, CharacterDirection dir, int nr_room, int nr_x, int nr_y, CharacterDirection nr_dir)
  2147.  * This function is used in the room script in combination with the door hotspot. Parameters:
  2148.  *
  2149.  *   door_id: The door id, you have defined
  2150.  *   verbsData.act_object: The object, containing the open sprite
  2151.  *   x,y: the walk-to point of the door (please don’t use the built in "walk-to coordinates" feature of the room editor.
  2152.  *   dir: the direction, the player’s character should face, after it reached x,y
  2153.  *   nr_room: if the door is opened and walking through it, the player is being send to this room
  2154.  *   nr_x,nr_y: the x,y coordinates of inside of the new room
  2155.  *   nr_dir: after the room change, the player faces this direction
  2156.  *   This is the main function of the door scripts. With this you connect the hotspot with the door and the player’s action.
  2157.  *
  2158.  * If you have defined default door sounds, these are also being called in this function.
  2159.  * Also you can’t unlock a door with this function. You need AnyClickSpecial for that.
  2160.  ***********************************************************************/
  2161. static int Doors::AnyClick(int door_id, int obj, int x, int y, CharacterDirection dir, int nr_room, int nr_x, int nr_y, CharacterDirection nr_dir) {
  2162.   return Doors.AnyClickSpecial (door_id, obj, x, y, dir, nr_room, nr_x, nr_y, nr_dir, null, null, 0, 0);
  2163. }
  2164.  
  2165.  
  2166. // ============================= AGS internal functions ==========================================
  2167.  
  2168. /***********************************************************************
  2169.  * game_start()
  2170.  *
  2171.  ***********************************************************************/
  2172. function game_start()
  2173. {
  2174.   verbsData.runSpeedupRate = 1;
  2175.   verbsData.player_ani_speed =  player.AnimationSpeed;
  2176.   verbsData.player_walk_x_speed = player.WalkSpeedX;
  2177.   verbsData.player_walk_y_speed = player.WalkSpeedY;
  2178.   verbsData.openDoorSound = aKc_basslinetech;
  2179. }
  2180.  
  2181. /***********************************************************************
  2182.  * on_event(EventType event, int data)
  2183.  *
  2184.  ***********************************************************************/
  2185. function on_event(EventType event, int data)
  2186. {
  2187.   if (event == eEventEnterRoomBeforeFadein) {
  2188.     Verbs.CheckDefaultAction();
  2189.     Verbs.UpdateActionBar();
  2190.   }
  2191.  
  2192.   else if (event==eEventRestoreGame) {
  2193.     //Verbs.AdjustLanguage();
  2194.     Verbs.InitGuiLanguage();
  2195.   }
  2196. }
  2197.  
  2198. /***********************************************************************
  2199.  * on_key_press(eKeyCode keycode)
  2200.  *
  2201.  ***********************************************************************/
  2202. function on_key_press(eKeyCode keycode)
  2203. {
  2204.  
  2205.   // Show pause gui on space-key
  2206.   if (keycode == eKeySpace)
  2207.   {
  2208.     if (!IsGamePaused()) {
  2209.       PauseGame();
  2210.       Verbs.AdjustGUIText();
  2211.       verbsData.guiPause.Visible=true;
  2212.     }
  2213.     else {
  2214.       verbsData.guiPause.Visible=false;
  2215.       UnPauseGame();
  2216.       Verbs.SetAction(eGA_Default);
  2217.       lblAction.TextColor=verbsData.actionLabelColorHighlighted;      
  2218.       Verbs.CheckDefaultAction();
  2219.       Verbs.UpdateActionBar();
  2220.     }
  2221.   }
  2222.  
  2223.   if (verbsData.guiQuit.Visible) {
  2224.     if (keycode==verbsData.key_u_no[verbsData.lang] || keycode==verbsData.key_l_no[verbsData.lang]) verbsData.guiQuit.Visible=false;
  2225.     if (keycode==verbsData.key_u_yes[verbsData.lang] || keycode==verbsData.key_l_yes[verbsData.lang]) QuitGame(0);
  2226.   }
  2227.  
  2228.   //  triggering actions by keyboard
  2229.   if (!IsGamePaused()) {
  2230.     int act_i=0;
  2231.     while (act_i < ACT_COUNT) {
  2232.       if (keycode == actionButtonData[act_i].action_l_keycode[verbsData.lang] || keycode==actionButtonData[act_i].action_u_keycode[verbsData.lang]) {
  2233.         Verbs.SetAction(act_i);
  2234.         act_i = ACT_COUNT;
  2235.       }
  2236.       else {
  2237.         act_i++;
  2238.       }
  2239.     }
  2240.   }
  2241. }
  2242.  
  2243. /***********************************************************************
  2244.  * on_mouse_click(MouseButton button)
  2245.  *
  2246.  ***********************************************************************/
  2247. function on_mouse_click(MouseButton button) {
  2248.  
  2249.   if (!Verbs.IsGuiDisabled()) {
  2250.     int x = mouse.x;
  2251.     int y = mouse.y;
  2252.    
  2253.     // get location under mouse cursor
  2254.     verbsData.location_type = GetLocationType(x, y);
  2255.     verbsData.location_clicked = Game.GetLocationName(x, y);
  2256.  
  2257.      verbsData.AGSCursorMode = Mouse.Mode;
  2258.      verbsData.used_action =  verbsData.global_action;
  2259.    
  2260.     InventoryItem*ii = InventoryItem.GetAtScreenXY(x, y);
  2261.     if (verbsData.location_type == eLocationHotspot) {
  2262.       Hotspot*h = Hotspot.GetAtScreenXY(x, y);
  2263.       verbsData.location_id=h.ID;
  2264.      
  2265.     }
  2266.     else if (verbsData.location_type == eLocationCharacter) {
  2267.       Character*c=Character.GetAtScreenXY(x, y);
  2268.       verbsData.location_id=c.ID;
  2269.     }
  2270.     else if (verbsData.location_type==eLocationObject) {
  2271.       Object*o=Object.GetAtScreenXY(x, y);
  2272.       verbsData.location_id=o.ID;
  2273.     }
  2274.     else if (ii!=null) verbsData.location_id=ii.ID;
  2275.    
  2276.     //dont allow endless running
  2277.     if (verbsData.player_is_running) {
  2278.       verbsData.player_is_running = false;
  2279.      
  2280.       player.StopMoving();
  2281.       player.SetWalkSpeed(verbsData.player_walk_x_speed,  verbsData.player_walk_y_speed);
  2282.       player.AnimationSpeed = verbsData.player_ani_speed;          
  2283.     }
  2284.    
  2285.    
  2286.     if (IsGamePaused()) {
  2287.       // Game is paused, so do nothing (ie. don't allow mouse click)
  2288.     }
  2289.     // Mousebutton Left
  2290.     else if (button == eMouseLeft)
  2291.     {
  2292.  
  2293.       if (Verbs.GlobalCondition(eGlob_InvOnInv) || Verbs.GlobalCondition(eGlob_GiveTalkNoChar) || Verbs.GlobalCondition(eGlob_GiveNoInv)) {
  2294.         // Do nothing, if:
  2295.         // the mode is useinv and the mouse is over the active inv (like "use knife on knife")
  2296.         // or the mode is talk, or "Give", and the mouse isnt over a character
  2297.         // or its GIVE and the mouse isnt over a inv.item        
  2298.         if ( verbsData.classicGui) {
  2299.         }
  2300.         // the modern GUI Style turns TalkTo and Give into the Default mode.
  2301.         else {
  2302.           if ( verbsData.AGSCursorMode==eModeTalkto ||  verbsData.AGSCursorMode == eModeInteract ) {
  2303.             Verbs.UpdateActionBar();
  2304.             lblAction.TextColor = verbsData.actionLabelColorHighlighted;
  2305.             Verbs.SetAction(eGA_Default);
  2306.             verbsData.ItemGiven=null;            
  2307.           }
  2308.           else {
  2309.           }
  2310.         }
  2311.       }
  2312.       else if (Verbs.ExtensionEx(1, verbsData.location_clicked)=='e') {
  2313.         Verbs.UpdateActionBar();
  2314.         lblAction.TextColor = verbsData.actionLabelColorHighlighted;
  2315.         Verbs.WalkOffScreen();
  2316.       }
  2317.       // walk to
  2318.       else if ( verbsData.AGSCursorMode == eModeUsermode2) {
  2319.         lblAction.TextColor=verbsData.actionLabelColorHighlighted;
  2320.  
  2321.         // Run on doubleclick
  2322.         if ( verbsData.runOnDoubleClick && DoubleClick.Event[eMouseLeft]) {
  2323.  
  2324.           verbsData.player_is_running = true;
  2325.  
  2326.           if (verbsData.player_ani_speed <  verbsData.runSpeedupRate) player.AnimationSpeed  = 0;
  2327.           else player.AnimationSpeed = verbsData.player_ani_speed /  verbsData.runSpeedupRate;
  2328.           player.StopMoving();
  2329.          
  2330.           player.SetWalkSpeed(verbsData.player_walk_x_speed *  verbsData.runSpeedupRate, verbsData.player_walk_y_speed *  verbsData.runSpeedupRate);
  2331.  
  2332.         }
  2333.  
  2334.         if (IsInteractionAvailable(x, y,  verbsData.AGSCursorMode) ) {
  2335.           Room.ProcessClick (x, y,  verbsData.AGSCursorMode);
  2336.         }
  2337.         else {
  2338.           Room.ProcessClick (x, y, eModeWalkto);
  2339.         }
  2340.  
  2341.       }  
  2342.       // talkto
  2343.       else if ( verbsData.AGSCursorMode==eModeTalkto && IsInteractionAvailable(x, y,  verbsData.AGSCursorMode) && verbsData.location_type==eLocationCharacter) {
  2344.         lblAction.TextColor=verbsData.actionLabelColorHighlighted;
  2345.         Verbs.SetAction(eGA_Default);
  2346.         if (verbsData.approachCharInteract == false) character[verbsData.location_id].RunInteraction( verbsData.AGSCursorMode);
  2347.         else {
  2348.           if (Verbs.GoToCharacter(character[verbsData.location_id], 0, verbsData.NPCfacingPlayer, 2)) character[verbsData.location_id].RunInteraction( verbsData.AGSCursorMode);
  2349.         }
  2350.            
  2351.       }
  2352.       // Giveto
  2353.       else if (( verbsData.AGSCursorMode == eModeUseinv) && verbsData.location_type==eLocationCharacter && Verbs.IsAction(eGA_GiveTo)) {
  2354.         lblAction.TextColor = verbsData.actionLabelColorHighlighted;
  2355.         verbsData.ItemGiven=player.ActiveInventory;
  2356.         Verbs.SetAction (eGA_Default);
  2357.         if (verbsData.approachCharInteract == false) {
  2358.           if (IsInteractionAvailable (x, y, eModeUseinv) == 1) {
  2359.             character[verbsData.location_id].RunInteraction(eModeUseinv);
  2360.           }
  2361.         }
  2362.         else {
  2363.           if (Verbs.GoToCharacter(character[verbsData.location_id], 0, verbsData.NPCfacingPlayer, 2)) {
  2364.             if (IsInteractionAvailable (x, y, eModeUseinv) == 1) {
  2365.               character[verbsData.location_id].RunInteraction(eModeUseinv);        
  2366.             }
  2367.           }
  2368.         }
  2369.        
  2370.       }    
  2371.       else {
  2372.         Verbs.UpdateActionBar();
  2373.         lblAction.TextColor = verbsData.actionLabelColorHighlighted;
  2374.         Room.ProcessClick(x, y,  verbsData.AGSCursorMode);
  2375.         Verbs.SetAction(eGA_Default);
  2376.         verbsData.ItemGiven=null;
  2377.       }
  2378.     }
  2379.     // Mousebutton Right
  2380.     else if (button==eMouseRight) {
  2381.       if ( verbsData.alternative_action==eGA_Default) {
  2382.         Verbs.SetAction(eGA_Default);
  2383.         lblAction.TextColor=verbsData.actionLabelColorHighlighted;
  2384.        
  2385.         if (Mouse.Mode==eModeUsermode2) {
  2386.           if (Verbs.ExtensionEx(1, verbsData.location_clicked)=='e') {
  2387.             Verbs.UpdateActionBar();
  2388.             lblAction.TextColor=verbsData.actionLabelColorHighlighted;
  2389.             Verbs.WalkOffScreen();
  2390.           }          
  2391.           else {
  2392.             Room.ProcessClick(x, y, eModeWalkto);
  2393.           }
  2394.         }
  2395.         else {
  2396.           Room.ProcessClick(x, y, Mouse.Mode);
  2397.  
  2398.         }
  2399.       }
  2400.       else {
  2401.         Verbs.SetAction( verbsData.alternative_action);
  2402.          verbsData.used_action= verbsData.global_action;
  2403.         Verbs.UpdateActionBar();
  2404.         lblAction.TextColor=verbsData.actionLabelColorHighlighted;
  2405.          verbsData.AGSCursorMode=Mouse.Mode;
  2406.         if ( verbsData.AGSCursorMode == eModeTalkto && IsInteractionAvailable(x, y,  verbsData.AGSCursorMode) && verbsData.location_type == eLocationCharacter) {
  2407.           if (verbsData.approachCharInteract == false) {
  2408.             character[verbsData.location_id].RunInteraction( verbsData.AGSCursorMode);
  2409.           }
  2410.           else {
  2411.             if (Verbs.GoToCharacter(character[verbsData.location_id], 0, verbsData.NPCfacingPlayer,2 )) character[verbsData.location_id].RunInteraction( verbsData.AGSCursorMode);  
  2412.           }
  2413.         }
  2414.         else {
  2415.  
  2416.           Room.ProcessClick(x, y,  verbsData.AGSCursorMode);
  2417.         }
  2418.         Verbs.SetAction(eGA_Default);
  2419.       }
  2420.      
  2421.     }
  2422.     //left click in inventory
  2423.     else if (button==eMouseLeftInv) {
  2424.       if (!Verbs.IsAction(eGA_GiveTo))verbsData.ItemGiven= null;
  2425.    
  2426.       if (Verbs.GlobalCondition (eGlob_MouseInvWalk)) {
  2427.         // if the mouse is in the inventory and modes Walk is selected
  2428.         Verbs.SetAction (eGA_Use);
  2429.         verbsData.location = verbsData.inv_ex_location;    
  2430.         if (Verbs.Extension()=='u' && ii.IsInteractionAvailable(eModeInteract)) {
  2431.           // use it immediately (not with anything else)
  2432.            verbsData.used_action =  verbsData.global_action;
  2433.           ii.RunInteraction(eModeInteract);
  2434.           Verbs.SetAction(eGA_Default);
  2435.         }
  2436.         else {
  2437.           player.ActiveInventory=ii;
  2438.         }
  2439.       }
  2440.       else  if (Verbs.GlobalCondition(eGlob_InvOnInv)) {
  2441.         // if the mode is useinv and the mouse is over the active inv (like "use knife on knife")
  2442.         // so do nothing again
  2443.       }
  2444.       else {
  2445.          verbsData.used_action =  verbsData.global_action;
  2446.         if (Mouse.Mode == eModeInteract && ii != null) {
  2447.           if (Verbs.IsAction(eGA_Use) && ii.IsInteractionAvailable(eModeInteract)) {
  2448.             lblAction.TextColor=verbsData.actionLabelColorHighlighted;
  2449.             ii.RunInteraction(eModeInteract);
  2450.             Verbs.SetAction(eGA_Default);
  2451.           }
  2452.           else player.ActiveInventory=ii;
  2453.         }
  2454.         else {
  2455.           if ( (Mouse.Mode >0 && Mouse.Mode <10 )&& ii != null) {
  2456.              verbsData.AGSCursorMode=Mouse.Mode;
  2457.             lblAction.TextColor = verbsData.actionLabelColorHighlighted;
  2458.             ii.RunInteraction(Mouse.Mode);
  2459.             Verbs.SetAction(eGA_Default);
  2460.           }
  2461.         }
  2462.       }
  2463.     }
  2464.     //right click in inventory
  2465.     else if (button==eMouseRightInv) {
  2466.       if ( verbsData.alternative_action==eGA_Default) {
  2467.         Verbs.SetAction(eGA_Default);
  2468.       }
  2469.       else {
  2470.         Verbs.SetAction( verbsData.alternative_action);
  2471.          verbsData.used_action= verbsData.global_action;
  2472.          verbsData.AGSCursorMode=Mouse.Mode;
  2473.         if (Mouse.Mode==eModeInteract && ii != null) {
  2474.           if (Verbs.IsAction(eGA_Use) && ii.IsInteractionAvailable(eModeInteract)) {
  2475.             Verbs.UpdateActionBar();
  2476.             lblAction.TextColor = verbsData.actionLabelColorHighlighted;
  2477.             ii.RunInteraction(eModeInteract);
  2478.             Verbs.SetAction(eGA_Default);
  2479.           }
  2480.           else player.ActiveInventory=ii;
  2481.         }
  2482.         else {
  2483.           Verbs.UpdateActionBar();
  2484.           lblAction.TextColor = verbsData.actionLabelColorHighlighted;
  2485.           inventory[game.inv_activated].RunInteraction(Mouse.Mode);
  2486.           Verbs.SetAction(eGA_Default);
  2487.         }
  2488.       }
  2489.     }
  2490.   }
  2491.   else {
  2492.     Room.ProcessClick(mouse.x, mouse.y, Mouse.Mode);
  2493.   }
  2494. }
  2495.  
  2496. /***********************************************************************
  2497.  * repeatedly_execute()
  2498.  *
  2499.  ***********************************************************************/
  2500.  
  2501. bool was_hovering_exit = false;
  2502. Action prev_action;
  2503.  
  2504. function repeatedly_execute() {
  2505.  
  2506.   if (!IsGamePaused() && !Verbs.IsGuiDisabled())
  2507.   {
  2508.    
  2509.     if ( verbsData.classicGui == true) {
  2510.       Verbs.CheckDefaultAction();
  2511.       Verbs.UpdateActionBar();
  2512.     }
  2513.     Verbs.HandleInvArrows();
  2514.  
  2515.  
  2516.     // Keep running, if mouse is pressed
  2517.     if (verbsData.player_is_running && mouse.IsButtonDown(eMouseLeft)) {
  2518.  
  2519.       int mx = mouse.x + Screen.Viewport.X;
  2520.       int my = mouse.y + Screen.Viewport.Y;
  2521.       int px = player.x;
  2522.       int py = player.y;
  2523.       int dist  = FloatToInt(Geometry.Distance(mx, my, px, py), eRoundDown);
  2524.      
  2525.       if (!player.Moving) {
  2526.         // Running on an exit or door
  2527.         if (dist <=  verbsData.runCursorDistance && (Verbs.ExtensionEx(1,  verbsData.location_ex)=='e' || Verbs.ExtensionEx(1,  verbsData.location_ex)=='v')) {
  2528.           verbsData.player_is_running = false;
  2529.           player.StopMoving();
  2530.           player.SetWalkSpeed(verbsData.player_walk_x_speed,  verbsData.player_walk_y_speed);
  2531.           player.AnimationSpeed = verbsData.player_ani_speed;          
  2532.           Verbs.UpdateActionBar();
  2533.           lblAction.TextColor = verbsData.actionLabelColorHighlighted;
  2534.           Room.ProcessClick(mouse.x, mouse.y, eModeUsermode1);      
  2535.         }
  2536.         // else keep running while left mouse button pressed
  2537.         else if (dist >  verbsData.runCursorDistance ) {
  2538.           player.Walk(mx, my, eNoBlock);
  2539.         }
  2540.       }
  2541.     }
  2542.     // turn off running if player stops walking
  2543.     else if (verbsData.player_is_running && !player.Moving && !mouse.IsButtonDown(eMouseLeft)) {
  2544.       verbsData.player_is_running = false;
  2545.      
  2546.       player.StopMoving();
  2547.       player.SetWalkSpeed(verbsData.player_walk_x_speed,  verbsData.player_walk_y_speed);
  2548.       player.AnimationSpeed = verbsData.player_ani_speed;          
  2549.     }
  2550.    
  2551.     // walk to exit hotspots
  2552.     bool is_hovering_exit = Verbs.ExtensionEx(1,  verbsData.location_ex) == 'e';
  2553.     if (is_hovering_exit && !was_hovering_exit) {
  2554.       prev_action = verbsData.global_action;
  2555.       verbsData.global_action = eGA_WalkTo;
  2556.     }
  2557.     else if (!is_hovering_exit && was_hovering_exit) {
  2558.       verbsData.global_action = prev_action;
  2559.     }
  2560.     was_hovering_exit = is_hovering_exit;
  2561.   }
  2562. }
  2563.  
  2564. /***********************************************************************
  2565.  * repeatedly_execute_always()
  2566.  *
  2567.  ***********************************************************************/
  2568. function repeatedly_execute_always() {
  2569.  
  2570.  
  2571.   if (!IsGamePaused() && !Verbs.IsGuiDisabled()) {
  2572.  
  2573.     // Update Actionbar
  2574.     if ( verbsData.classicGui == false) {
  2575.       Verbs.CheckDefaultAction();
  2576.  
  2577.       // Update Actionbar after command is executed
  2578.       if (verbsData.location_clicked != null && verbsData.location_clicked.Length > 0) {
  2579.         if (verbsData.location_clicked.IndexOf(">") > 0) verbsData.temp_location = verbsData.location_clicked.Truncate(verbsData.location_clicked.IndexOf(">"));
  2580.         else verbsData.temp_location = verbsData.location_clicked;
  2581.       }
  2582.       else verbsData.temp_location = "";
  2583.  
  2584.       if (IsInterfaceEnabled() || verbsData.temp_location != verbsData.location || verbsData.location == "") {
  2585.         Verbs.UpdateActionBar();
  2586.         verbsData.location_clicked = "";
  2587.       }
  2588.       Verbs.AdjustActionBarPosition();
  2589.     }
  2590.   }
  2591. }
  2592.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement