/* * InventoryLButtonUp: User released left mouse button on inventory box. */ void InventoryLButtonUp(HWND hwnd, int x, int y, UINT keyFlags) { int temp_x, temp_y; room_contents_node *r; if (!InventoryReleaseCapture()) return; // See if mouse pointer is in main graphics area if (!MouseToRoom(&temp_x, &temp_y)) { // Drop in inventory. Check if we're still in inventory first. if (x < 0 || y < 0) return; InventoryMoveCurrentItem(x,y); return; } // See if a container is under mouse pointer r = GetObjectByPosition(temp_x, temp_y, CLOSE_DISTANCE, OF_CONTAINER, 0); if (r == NULL) // Drop currently selected object (if any) InventoryDropCurrentItem(NULL); else InventoryDropCurrentItem(r); }
/* * UserStartDrag: User wants to drag object under mouse pointer. If there is no * object there, do nothing. If there is more than one object, ask user which * one to pick up. If there is exactly one, begin dragging object. */ void UserStartDrag(void) { list_type objects, sel_list, l; int x, y; object_node *obj; /* Find out where in the the room the user clicked on, if anywhere */ if (!MouseToRoom(&x, &y)) return; objects = GetObjects3D(x, y, CLOSE_DISTANCE, OF_GETTABLE | OF_CONTAINER, 0); if (objects == NULL) return; if (objects->next == NULL) { SetCapture(hMain); capture = True; obj = (object_node *) objects->data; drag_object = obj->id; SetMainCursor(LoadCursor(hInst, MAKEINTRESOURCE(IDC_GETCURSOR))); } else { sel_list = DisplayLookList(hMain, GetString(hInst, IDS_GET), objects, LD_SINGLEAUTO); for (l = sel_list; l != NULL; l = l->next) RequestPickup(((room_contents_node *) (l->data))->obj.id); ObjectListDestroy(sel_list); } list_delete(objects); }
/* * UserMouseMove: User wants to use mouse to move; check position of mouse * and move user accordingly. */ void UserMouseMove(void) { int x, y, xunit, yunit, i; int stretchfactor = config.large_area ? 2 : 1; if (!MouseToRoom(&x, &y) || view.cx == 0 || view.cy == 0) return; // Find action that corresponds to this part of the graphics area xunit = x * SCREEN_UNIT * stretchfactor / view.cx; yunit = y * SCREEN_UNIT * stretchfactor / view.cy; for (i=0; i < num_move_areas; i++) { if (xunit >= move_areas[i].left && xunit < move_areas[i].right && yunit >= move_areas[i].top && yunit < move_areas[i].bottom) { PerformAction(move_areas[i].action, NULL); break; } } }
Bool WINAPI EventUserAction(int action, void *action_data) { int x, y; list_type objects; char buf[MAX_ADMIN]; object_node *obj; ID id; switch (action) { case A_QEDITOR: debug(("A_QEDITOR\n")); if (GetQEditorDlg() || GetGChannelDlg()) break; ShowQEditorDlg(); break; case A_GCHANNEL: debug(("A_GCHANNEL\n")); if (GetQEditorDlg() || GetGChannelDlg()) break; ShowGChannelDlg(); break; case A_LOOKMOUSE: /* user 'looks' on main window */ if (!GetQEditorDlg() && !GetGChannelDlg()) return True; if (!MouseToRoom(&x, &y)) return True; objects = GetObjects3D(x, y, 0, 0, 0); if (objects == NULL) return True; /* Get details of object */ obj = (object_node *) (objects->data); if (!obj) { debug(("clicked, but nothing\n")); return True; } strcpy(buf, LookupNameRsc(obj->name_res)); if (GetGChannelDlg() && (obj->flags & OF_PLAYER)) { debug(("gchannel needs to hear we clicked on '%s' (flags = 0x08X)\n", buf, obj->flags)); SendMessage(GetGChannelDlg(), DMDLGM_CLICKEDUSER, 0, (LPARAM)buf); return False; } if (GetQEditorDlg()) { debug(("qeditor needs to hear we clicked on '%s'\n", buf)); SendMessage(GetQEditorDlg(), DMDLGM_CLICKEDUSER, 0, (LPARAM)buf); return False; } break; case A_LOOKINVENTORY: /* user 'looks' on inventory window */ if (!GetQEditorDlg() /* && !GetGChannelDlg() */) return True; id = (ID)action_data; if (id == INVALID_ID) return True; break; default: return True; } return False; }