/// returns true if command is processed bool CRRecentBooksMenu::onCommand( int command, int params ) { if ( command==MCMD_SCROLL_FORWARD ) { setCurPage( getCurPage()+1 ); return true; } if ( command==MCMD_SCROLL_BACK ) { setCurPage( getCurPage()-1 ); return true; } if ( command>=MCMD_SELECT_1 && command<=MCMD_SELECT_9 ) { int index = command - MCMD_SELECT_1 + getTopItem(); if ( index < 0 || index >= getItems().length() ) { closeMenu( 0 ); return true; } CRMenuItem * item = getItems()[index]; int n = item->getId(); highlightCommandItem( n ); closeMenu( MCMD_OPEN_RECENT_BOOK, n ); return true; } else if ( command>=MCMD_SELECT_1_LONG && command<=MCMD_SELECT_9_LONG ) { int index = command - MCMD_SELECT_1_LONG + getTopItem(); if ( index >=0 && index < _pageItems ) { //TODO: allow removing book from history //closeMenu( MCMD_REMOVE_RECENT_BOOK, index ); removeItem( index ); setDirty(); return true; } } closeMenu( 0 ); return true; }
void Square::getViewIndex(const CreatureView* c, ViewIndex& ret) const { double fireSize = 0; if (creature && (c->canSee(creature) || creature->isPlayer())) { ret.insert(copyOf(creature->getViewObject())); } else if (creature && contains(c->getUnknownAttacker(), creature)) ret.insert(copyOf(ViewObject::unknownMonster())); if (c->canSee(position)) { for (Item* it : inventory.getItems()) fireSize = max(fireSize, it->getFireSize()); fireSize = max(fireSize, fire.getSize()); if (backgroundObject) ret.insert(*backgroundObject); ret.insert(getViewObject()); for (const PTrigger& t : triggers) if (auto obj = t->getViewObject(c)) ret.insert(copyOf(*obj).setAttribute(ViewObject::Attribute::BURNING, fireSize)); if (Item* it = getTopItem()) ret.insert(copyOf(it->getViewObject()).setAttribute(ViewObject::Attribute::BURNING, fireSize)); ret.setHighlight(HighlightType::NIGHT, 1.0 - level->getLight(position)); if (poisonGas.getAmount() > 0) ret.setHighlight(HighlightType::POISON_GAS, min(1.0, poisonGas.getAmount())); if (fog) ret.setHighlight(HighlightType::FOG, fog); } else ret.setHiddenId(getViewObject().id()); }
/// returns true if command is processed bool CRRecentBooksMenu::onCommand( int command, int params ) { if ( command==MCMD_SCROLL_FORWARD ) { setCurPage( getCurPage()+1 ); return true; } if ( command==MCMD_SCROLL_BACK ) { setCurPage( getCurPage()-1 ); return true; } if ( command>=MCMD_SELECT_1 && command<=MCMD_SELECT_9 ) { int index = command - MCMD_SELECT_1 + getTopItem(); if ( index < 0 || index >= getItems().length() ) { closeMenu( 0 ); return true; } CRMenuItem * item = getItems()[index]; int n = item->getId(); highlightCommandItem( n ); closeMenu( MCMD_OPEN_RECENT_BOOK, n ); return true; } else if ( command>=MCMD_SELECT_1_LONG && command<=MCMD_SELECT_9_LONG ) { int index = command - MCMD_SELECT_1_LONG + getTopItem(); if ( index >=0 && index < _pageItems ) { //TODO: allow removing book from history //closeMenu( MCMD_REMOVE_RECENT_BOOK, index ); removeItem( index ); setDirty(); return true; } } else if (command == MCMD_SELECT) { if (_selectedItem >= 0) { CRMenuItem * item = getItems()[_selectedItem]; int n = item->getId(); closeMenu( MCMD_OPEN_RECENT_BOOK, n ); return true; } closeMenu( 0 ); return true; } else if (command == MCMD_SELECT_LONG) { if (_selectedItem >= 0) { #ifdef CR_POCKETBOOK showContextMenu(); #else removeItem( _selectedItem ); setDirty(); #endif return true; } } else if (command == MCMD_PREV_PAGE) { if (_topItem == 0) { closeMenu(0); return true; } } #ifdef CR_POCKETBOOK else if (command == MCMD_OPEN_RECENT_BOOK) { closeMenu( command, _selectedItem + 1 ); return true; } else if (command == PB_CMD_BOOKMARK_REMOVE && _selectedItem >= 0) { removeItem( _selectedItem ); setDirty(); return true; } #endif return CRMenu::onCommand(command, params); //closeMenu( 0 ); //return true; }