Advertisement
Rochet2

Untitled

Feb 10th, 2018
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. // This is a globally known value
  6. // we want to substract the "next" button from max items.
  7. const int max_items = 32-1;
  8.  
  9. void ShowPage(int page, vector<int> const & items)
  10. {
  11.     int count = 0; // added items count
  12.     for (int i = page*max_items; i < items.size(); ++i) // go through all items, we want to start from page beginning
  13.     {
  14.         cout << "Item number: " << i << endl;
  15.         ++count; // added an item, increase count of items
  16.         if (count >= max_items)
  17.         {
  18.             // we are at limit, add next button and stop adding items
  19.             cout << "Next page" << endl;
  20.             break;
  21.         }
  22.     }
  23.     // Send menu()
  24. }
  25.  
  26. int main() {
  27.     /*
  28.     Through for loops and such you have gathered all items the player has in a list called "items".
  29.     These items can be for example pointers to the items you get from GetItemByPos or similar.
  30.     These are all the valid items to be shown in the menu.
  31.     */
  32.     vector<int> items = {};
  33.     for (int i = 0; i < 100; ++i)
  34.         items.push_back(i);
  35.  
  36.     ShowPage(0, items);
  37.     ShowPage(1, items);
  38.     ShowPage(100, items);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement