| 21045 | } |
| 21046 | |
| 21047 | void GenericGUIMenu::AlchemyGUI_t::AlchemyRecipes_t::scrollToSlot(int x, int y, bool instantly) |
| 21048 | { |
| 21049 | int lowerY = currentScrollRow; |
| 21050 | int upperY = currentScrollRow + getNumRecipesToDisplayVertical() - 1; |
| 21051 | |
| 21052 | if ( y >= lowerY && y <= upperY ) |
| 21053 | { |
| 21054 | // no work to do. |
| 21055 | return; |
| 21056 | } |
| 21057 | int player = alchemy.parentGUI.getPlayer(); |
| 21058 | int lowestItemY = getNumRecipesToDisplayVertical() - 1; |
| 21059 | const int slotSize = players[player]->inventoryUI.getSlotSize(); |
| 21060 | if ( !recipeList.empty() ) |
| 21061 | { |
| 21062 | for ( auto it = recipeList.rbegin(); it != recipeList.rend(); ++it ) |
| 21063 | { |
| 21064 | if ( !hideRecipeFromList((*it).resultItem.type) ) |
| 21065 | { |
| 21066 | lowestItemY = std::max(lowestItemY, (*it).y); |
| 21067 | break; |
| 21068 | } |
| 21069 | } |
| 21070 | } |
| 21071 | int maxScroll = std::max((lowestItemY + 1) - (getNumRecipesToDisplayVertical()), 0) * slotSize; |
| 21072 | |
| 21073 | int scrollAmount = 0; |
| 21074 | if ( y < lowerY ) |
| 21075 | { |
| 21076 | scrollAmount = (y) * slotSize; |
| 21077 | //scrollAmount += scrollSetpoint; |
| 21078 | } |
| 21079 | else if ( y > upperY ) |
| 21080 | { |
| 21081 | scrollAmount = (y - upperY) * slotSize; |
| 21082 | scrollAmount += scrollSetpoint; |
| 21083 | } |
| 21084 | scrollAmount = std::min(scrollAmount, maxScroll); |
| 21085 | |
| 21086 | scrollSetpoint = scrollAmount; |
| 21087 | if ( instantly ) |
| 21088 | { |
| 21089 | scrollAnimateX = scrollSetpoint; |
| 21090 | } |
| 21091 | currentScrollRow = scrollSetpoint / slotSize; |
| 21092 | if ( abs(scrollSetpoint - scrollAnimateX) > 0.00001 ) |
| 21093 | { |
| 21094 | isInteractable = false; |
| 21095 | } |
| 21096 | } |
| 21097 | |
| 21098 | bool GenericGUIMenu::AlchemyGUI_t::AlchemyRecipes_t::isSlotVisible(int x, int y) const |
| 21099 | { |
no test coverage detected