diff -r c7b95e939bb7 src/settings_gui.cpp --- a/src/settings_gui.cpp Sun Nov 16 14:29:37 2008 +0100 +++ b/src/settings_gui.cpp Sun Nov 16 14:45:52 2008 +0100 @@ -611,6 +611,7 @@ PatchEntry(const char *nm); void Init(); + PatchEntry *FindEntry(uint row, uint *cur_row); uint Draw(GameSettings *patches_ptr, int x, int y, uint first_row, uint max_row, uint cur_row = 0); void SetButtons(uint16 new_value); @@ -624,7 +625,7 @@ byte num; ///< Number of entries on the page (statically filled). void Init(); - PatchEntry *FindEntry(uint row) const; + PatchEntry *FindEntry(uint row, uint *cur_row) const; byte Length() const; uint Draw(GameSettings *patches_ptr, int base_x, int base_y, uint first_row, uint max_row, uint cur_row = 0) const; @@ -651,6 +652,25 @@ break; default: NOT_REACHED(); } +} + +/** + * Find patch entry \a row + * @param row Index of entry to return + * @param cur_row Current row number + * @return The requested patch entry or \c NULL if it not found + */ +PatchEntry *PatchEntry::FindEntry(uint row, uint *cur_row) +{ + if (row == *cur_row) return this; + + switch(flags & PEF_KIND_MASK) { + case PEF_SETTING_KIND: + (*cur_row)++; + break; + default: NOT_REACHED(); + } + return NULL; } /** @@ -760,15 +780,19 @@ /** * Find the patch entry at row-number \a row - * @param row Index of setting to return + * @param row Index of entry to return + * @param cur_row Variable used for keeping track of the current row number. Should point to memory initialized to \c 0. * @return The requested patch entry or \c NULL if it does not exist */ -PatchEntry *PatchPage::FindEntry(uint row) const +PatchEntry *PatchPage::FindEntry(uint row, uint *cur_row) const { - if (row >= num) - return NULL; - - return &entries[row]; + PatchEntry *pe = NULL; + for (uint fld = 0; fld < num; fld++) { + pe = entries[fld].FindEntry(row, cur_row); + if (pe != NULL) + break; + } + return pe; } byte PatchPage::Length() const @@ -1018,7 +1042,8 @@ if (y % SETTING_HEIGHT > SETTING_HEIGHT - 2) return; // Clicked too low at the setting const PatchPage *page = &_patches_page[this->page]; - PatchEntry *pe = page->FindEntry(btn); + uint cur_row = 0; + PatchEntry *pe = page->FindEntry(btn, &cur_row); if (pe == NULL) return; // Clicked below the last setting of the page