Fix #12368: Incorrect offset for click position within industry chain window. (#12370)

(cherry picked from commit 97c173854106b7e901146d6f15ef155aefac81f5)
tmp-jgrpp
Peter Nelson 1 month ago committed by Jonathan G Rennison
parent b919c412b9
commit 5c345f55e2

@ -3087,7 +3087,7 @@ struct IndustryCargoesWindow : public Window {
pt.x -= nw->pos_x;
pt.y -= nw->pos_y;
int vpos = WidgetDimensions::scaled.framerect.top + CargoesField::small_height - this->vscroll->GetPosition() * nw->resize_y;
int vpos = WidgetDimensions::scaled.frametext.top + CargoesField::small_height - this->vscroll->GetPosition() * nw->resize_y;
if (pt.y < vpos) return false;
int row = (pt.y - vpos) / CargoesField::normal_height; // row is relative to row 1.
@ -3095,7 +3095,7 @@ struct IndustryCargoesWindow : public Window {
vpos = pt.y - vpos - row * CargoesField::normal_height; // Position in the row + 1 field
row++; // rebase row to match index of this->fields.
int xpos = 2 * WidgetDimensions::scaled.framerect.left + ((this->ind_cargo < NUM_INDUSTRYTYPES) ? 0 : (CargoesField::industry_width + CargoesField::cargo_field_width) / 2);
int xpos = 2 * WidgetDimensions::scaled.frametext.left + ((this->ind_cargo < NUM_INDUSTRYTYPES) ? 0 : (CargoesField::industry_width + CargoesField::cargo_field_width) / 2);
if (pt.x < xpos) return false;
int column;
for (column = 0; column <= 5; column++) {

Loading…
Cancel
Save