diff -r 1046eeaf4f0a -r 0567377e89d7 src/settings_gui.cpp --- a/src/settings_gui.cpp Sun Sep 28 14:06:35 2008 +0200 +++ b/src/settings_gui.cpp Sun Sep 28 14:07:05 2008 +0200 @@ -716,6 +716,7 @@ /** Data structure describing a single patch at a tab */ struct PatchEntry { + uint16 ypos; ///< Vertical position of the setting in the option panel const SettingDesc *setting; ///< Setting description of the patch uint index; ///< Index of the setting in the settings table }; @@ -785,13 +786,17 @@ if (patches_max < page->num_entries) patches_max = page->num_entries; page->entries = MallocT(page->num_entries); + uint16 y = config_patch_y_start; for (uint i = 0; i != page->num_entries; i++) { uint index; const SettingDesc *sd = GetPatchFromName(page->names[i], &index); assert(sd != NULL); + page->entries[i].ypos = y; page->entries[i].setting = sd; page->entries[i].index = index; + + y += setting_height; } } first_time = false; @@ -820,8 +825,8 @@ this->DrawWidgets(); int x = config_patch_x_start; - int y = config_patch_y_start; for (uint i = 0; i != page->num_entries; i++) { + int y = page->entries[i].ypos; const SettingDesc *sd = page->entries[i].setting; const SettingDescBase *sdb = &sd->desc; const void *var = GetVariableAddress(patches_ptr, &sd->save); @@ -863,7 +868,6 @@ } } DrawString(25 + x, y, (sdb->str) + disabled, TC_FROMSTRING); - y += setting_height; } } @@ -872,14 +876,16 @@ switch (widget) { case PATCHSEL_OPTIONSPANEL: { const PatchPage *page = &_patches_page[this->page]; - int y = pt.y - config_patch_y_start; // Shift y coordinate - if (y < 0) return; // Clicked above first entry int x = pt.x - config_patch_x_start; // Shift x coordinate if (x < 0) return; // Clicked left of the entry - byte btn = y / setting_height; // Compute which setting is selected - if (y % setting_height > (setting_height -2)) return; // Clicked too low at the setting + byte btn; + for (btn = 0; btn < page->num_entries; btn++) { + uint16 ypos = page->entries[btn].ypos; + if (pt.y >= ypos && pt.y <= ypos + (setting_height - 2)) + break; + } if (btn >= page->num_entries) return; // Clicked below the last setting of the page const SettingDesc *sd = page->entries[btn].setting;