mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Use SetPosition() to clamp after changing count/capacity.
parent
6202eae9d5
commit
878c5d8d85
|
@ -721,9 +721,8 @@ public:
|
||||||
assert(num <= MAX_UVALUE(uint16));
|
assert(num <= MAX_UVALUE(uint16));
|
||||||
|
|
||||||
this->count = ClampTo<uint16_t>(num);
|
this->count = ClampTo<uint16_t>(num);
|
||||||
num -= this->cap;
|
/* Ensure position is within bounds */
|
||||||
if (num < 0) num = 0;
|
this->SetPosition(this->pos);
|
||||||
if (num < this->pos) this->pos = num;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -736,7 +735,8 @@ public:
|
||||||
assert(capacity <= MAX_UVALUE(uint16));
|
assert(capacity <= MAX_UVALUE(uint16));
|
||||||
|
|
||||||
this->cap = ClampTo<uint16_t>(capacity);
|
this->cap = ClampTo<uint16_t>(capacity);
|
||||||
if (this->cap + this->pos > this->count) this->pos = std::max(0, this->count - this->cap);
|
/* Ensure position is within bounds */
|
||||||
|
this->SetPosition(this->pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetCapacityFromWidget(Window *w, int widget, int padding = 0);
|
void SetCapacityFromWidget(Window *w, int widget, int padding = 0);
|
||||||
|
|
Loading…
Reference in New Issue