BOOL FSBlockListCtrl::handleRightMouseDown(S32 x, S32 y, MASK mask) { BOOL handled = LLUICtrl::handleRightMouseDown(x, y, mask); if (mContextMenu) { std::vector<LLScrollListItem*> selected_items = getAllSelected(); if (selected_items.size() > 1) { uuid_vec_t selected_uuids; for (std::vector<LLScrollListItem*>::iterator it = selected_items.begin(); it != selected_items.end(); ++it) { selected_uuids.push_back((*it)->getUUID()); } mContextMenu->show(this, selected_uuids, x, y); } else { LLScrollListItem* hit_item = hitItem(x, y); if (hit_item) { LLUUID val = hit_item->getValue(); selectByID(val); uuid_vec_t selected_uuids; selected_uuids.push_back(val); mContextMenu->show(this, selected_uuids, x, y); } } } return handled; }
//virtual BOOL LLNameListCtrl::handleToolTip(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; S32 column_index = getColumnIndexFromOffset(x); LLNameListItem* hit_item = dynamic_cast<LLNameListItem*>(hitItem(x, y)); if (hit_item && column_index == mNameColumnIndex) { // ...this is the column with the avatar name LLUUID avatar_id = hit_item->getUUID(); if (avatar_id.notNull()) { // ...valid avatar id LLScrollListCell* hit_cell = hit_item->getColumn(column_index); if (hit_cell) { S32 row_index = getItemIndex(hit_item); LLRect cell_rect = getCellRect(row_index, column_index); // Convert rect local to screen coordinates LLRect sticky_rect; localRectToScreen(cell_rect, &sticky_rect); // Spawn at right side of cell LLPointer<LLUIImage> icon = LLUI::getUIImage("Info_Small"); LLCoordGL pos( sticky_rect.mRight - info_icon_size, sticky_rect.mTop - (sticky_rect.getHeight() - icon->getHeight())/2 ); // Should we show a group or an avatar inspector? bool is_group = hit_item->isGroup(); bool is_experience = hit_item->isExperience(); LLToolTip::Params params; params.background_visible( false ); params.click_callback( boost::bind(&LLNameListCtrl::showInspector, this, avatar_id, is_group, is_experience) ); params.delay_time(0.0f); // spawn instantly on hover params.image( icon ); params.message(""); params.padding(0); params.pos(pos); params.sticky_rect(sticky_rect); LLToolTipMgr::getInstance()->show(params); handled = TRUE; } } } if (!handled) { handled = LLScrollListCtrl::handleToolTip(x, y, mask); } return handled; }
RoomElement hitElf(RoomElement element) { //hit by a monster if (element.type < 50) { //check the counter, so hearts are not //removed unless the monster has not been 'hit' //already if (element.counter == 0) { element.counter = COUNTER_START; elf.hearts--; if (elf.hearts < 1) { //game over elf.state = ELFSTATE_DEAD; } } //when the elf and a monster 'bump,' move the monster //in the opposite direction switch (element.state) { case STATE_MOVE_UP: element.state = STATE_MOVE_DOWN; break; case STATE_MOVE_DOWN: element.state = STATE_MOVE_UP; break; case STATE_MOVE_LEFT: element.state = STATE_MOVE_RIGHT; break; case STATE_MOVE_RIGHT: element.state = STATE_MOVE_LEFT; break; } } else { switch (element.type) { case ITEM_HEART: if (elf.hearts < MAX_HEARTS) elf.hearts++; //handle the rest of the item hit element = hitItem(element); play_sfx(5); break; case ITEM_CRYSTAL: case ITEM_ORB: case ITEM_ARMOR: case ITEM_STAFF: addElfItem(element.type); //handle the rest of the item hit element = hitItem(element); break; case ITEM_PORTAL: //handle the rest of the item hit element = hitItem(element); if (getMapCurrentRoom() > 63) { //go to the bottom half of the map (underworld) setMapRoom(0); play_song(0); } else { //back to top half of the map (overworld) setMapRoom(64); play_song(1); } elf.x = 36; elf.y = 24; elf.facing = FACING_DOWN; showElf(); break; } } //update the display updateDisplay(elf); return element; }
void LLNameListCtrl::mouseOverHighlightNthItem( S32 target_index ) { S32 cur_index = getHighlightedItemInx(); if (cur_index != target_index) { bool is_mouse_over_name_cell = false; S32 mouse_x, mouse_y; LLUI::getMousePositionLocal(this, &mouse_x, &mouse_y); S32 column_index = getColumnIndexFromOffset(mouse_x); LLScrollListItem* hit_item = hitItem(mouse_x, mouse_y); if (hit_item && column_index == mNameColumnIndex) { // Get the name cell which is currently under the mouse pointer. LLScrollListCell* hit_cell = hit_item->getColumn(column_index); if (hit_cell) { is_mouse_over_name_cell = getCellRect(cur_index, column_index).pointInRect(mouse_x, mouse_y); } } // If the tool tip is visible and the mouse is over the currently highlighted item's name cell, // we should not reset the highlighted item index i.e. set mHighlightedItem = -1 // and should not increase the width of the text inside the cell because it may // overlap the tool tip icon. if (LLToolTipMgr::getInstance()->toolTipVisible() && is_mouse_over_name_cell) return; if(0 <= cur_index && cur_index < (S32)getItemList().size()) { LLScrollListItem* item = getItemList()[cur_index]; if (item) { LLScrollListText* cell = dynamic_cast<LLScrollListText*>(item->getColumn(mNameColumnIndex)); if (cell) cell->setTextWidth(cell->getTextWidth() + info_icon_size); } else { llwarns << "highlighted name list item is NULL" << llendl; } } if(target_index != -1) { LLScrollListItem* item = getItemList()[target_index]; LLScrollListText* cell = dynamic_cast<LLScrollListText*>(item->getColumn(mNameColumnIndex)); if (item) { if (cell) cell->setTextWidth(cell->getTextWidth() - info_icon_size); } else { llwarns << "target name item is NULL" << llendl; } } } LLScrollListCtrl::mouseOverHighlightNthItem(target_index); }