mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
Add: parameter for ReInit() to reposition window to default.
This commit is contained in:
parent
55d981aec3
commit
e8df28d7f3
@ -1010,9 +1010,10 @@ void Window::SetDirty() const
|
||||
* Re-initialize a window, and optionally change its size.
|
||||
* @param rx Horizontal resize of the window.
|
||||
* @param ry Vertical resize of the window.
|
||||
* @param reposition If set, reposition the window to default location.
|
||||
* @note For just resizing the window, use #ResizeWindow instead.
|
||||
*/
|
||||
void Window::ReInit(int rx, int ry)
|
||||
void Window::ReInit(int rx, int ry, bool reposition)
|
||||
{
|
||||
this->SetDirty(); // Mark whole current window as dirty.
|
||||
|
||||
@ -1039,6 +1040,12 @@ void Window::ReInit(int rx, int ry)
|
||||
if (this->resize.step_width > 1) dx -= dx % (int)this->resize.step_width;
|
||||
if (this->resize.step_height > 1) dy -= dy % (int)this->resize.step_height;
|
||||
|
||||
if (reposition) {
|
||||
Point pt = this->OnInitialPosition(this->nested_root->smallest_x, this->nested_root->smallest_y, window_number);
|
||||
this->InitializePositionSize(pt.x, pt.y, this->nested_root->smallest_x, this->nested_root->smallest_y);
|
||||
this->FindWindowPlacementAndResize(this->window_desc->GetDefaultWidth(), this->window_desc->GetDefaultHeight());
|
||||
}
|
||||
|
||||
ResizeWindow(this, dx, dy);
|
||||
/* ResizeWindow() does this->SetDirty() already, no need to do it again here. */
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ public:
|
||||
static void DeleteClosedWindows();
|
||||
|
||||
void SetDirty() const;
|
||||
void ReInit(int rx = 0, int ry = 0);
|
||||
void ReInit(int rx = 0, int ry = 0, bool reposition = false);
|
||||
|
||||
/** Is window shaded currently? */
|
||||
inline bool IsShaded() const
|
||||
|
Loading…
Reference in New Issue
Block a user