Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //----------------------------------------------------------------------------------------------------
- // game_start()
- //----------------------------------------------------------------------------------------------------
- function game_start()
- {
- lblActionText.Text = "";
- }
- //----------------------------------------------------------------------------------------------------
- // double clicks
- //--------------------
- #define DCDELAY 7
- int lastclick, mx, my;
- function left_click(bool single) {
- if (single) {
- // single-click code
- ProcessClick(mx, my, eModeInteract );
- }
- else {
- // double-click code
- ProcessClick(mx, my, eModeChRoom);
- }
- }
- //----------------------------------------------------------------------------------------------------
- // on_mouse_click()
- //----------------------------------------------------------------------------------------------------
- function on_mouse_click(MouseButton button)
- {
- // when mouse is clicked, text label is cleared
- lblActionText.Text = "";
- // when game is paused, clicks aren't processed
- if (IsGamePaused())
- {
- return;
- }
- // Left Mouse Button on Object/Character/Hotspot/Location
- // when no inventory is selected:
- // - INTERACT with target
- // - walk to location
- // else
- // - USE inventory on target
- else if (button == eMouseLeft)
- {
- if (GetLocationType(mouse.x, mouse.y) != eLocationNothing)
- {
- if (player.ActiveInventory == null)
- {
- if (lastclick && mouse.x==mx && mouse.y==my) {
- lastclick=0;
- left_click(false);
- }
- else {
- lastclick=1;
- mx=mouse.x;
- my=mouse.y;
- }
- }
- else
- {
- ProcessClick(mouse.x, mouse.y, eModeUseinv);
- }
- }
- else
- {
- if (player.ActiveInventory == null)
- {
- ProcessClick(mouse.x, mouse.y, eModeWalkto);
- }
- else
- {
- player.ActiveInventory = null;
- }
- }
- }
- // Right Mouse Button on Object/Character/Hotspot/Location
- // when no inventory is selected:
- // - EXAMINE target
- // else
- // - DESELECT inventory
- else if (button == eMouseRight)
- {
- if (player.ActiveInventory != null)
- {
- player.ActiveInventory = null;
- }
- else if (GetLocationType(mouse.x, mouse.y) != eLocationNothing)
- {
- ProcessClick(mouse.x, mouse.y, eModeLookat);
- }
- }
- // Left Mouse Button on Inventory Item
- // when no inventory is selected:
- // - INTERACT with target
- // - SELECT target
- // else
- // - USE inventory on target
- else if (button == eMouseLeftInv)
- {
- InventoryItem *i = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
- if (i != null)
- {
- if (i.GetProperty("propInstantUse") == true)
- {
- if (player.ActiveInventory == null)
- {
- i.RunInteraction(eModeInteract);
- }
- else
- {
- i.RunInteraction(eModeUseinv);
- }
- }
- else
- {
- if (player.ActiveInventory == null)
- {
- player.ActiveInventory = i;
- }
- else
- {
- if (i.ID != player.ActiveInventory.ID)
- {
- i.RunInteraction(eModeUseinv);
- }
- }
- }
- }
- }
- // Right Mouse Button on Inventory Item
- // when no inventory is selected:
- // - EXAMINE target
- // else
- // - DESELECT INVENTORY
- else if (button == eMouseRightInv)
- {
- if (player.ActiveInventory != null)
- {
- player.ActiveInventory = null;
- return;
- }
- InventoryItem *i = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
- if (i != null)
- {
- i.RunInteraction(eModeLookat);
- }
- }
- }
- //----------------------------------------------------------------------------------------------------
- // repeatedly_execute()
- //----------------------------------------------------------------------------------------------------
- function repeatedly_execute()
- {
- // double clicks
- if (lastclick>0 && lastclick<=DCDELAY) lastclick++;
- else if (lastclick>DCDELAY) {
- lastclick=0;
- left_click(true);
- }
- // Inventory GUI:
- // - make visible if mouse "touches" trigger zone
- // - make invisible if mouse leaves inventory GUI
- if (!gInventoryBar.Visible && mouse.y <= INVENTORY_POPUP_POSITION)
- {
- gInventoryBar.Visible = true;
- }
- if (gInventoryBar.Visible && mouse.y > gInventoryBar.Height)
- {
- gInventoryBar.Visible = false;
- }
- // Action Text
- // We always display the name of what is under the mouse, with one exception:
- // IF the player has an inventory item selected and hovers over the same inventory item,
- // we display nothing to indicate that an item can not be used on itself
- if (player.ActiveInventory == null)
- {
- lblActionText.Text = Game.GetLocationName(mouse.x, mouse.y);
- }
- else
- {
- InventoryItem *i = InventoryItem.GetAtScreenXY(mouse.x, mouse.y);
- if (i != null && (i.ID == player.ActiveInventory.ID))
- {
- lblActionText.Text = "";
- }
- else
- {
- lblActionText.Text = Game.GetLocationName(mouse.x, mouse.y);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement