diff --git a/distribution/changelog.txt b/distribution/changelog.txt index e7258ae73a..686171df05 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -72,9 +72,10 @@ - Fix: [#18009] Visual glitch with litter at edge of sloped path. - Fix: [#18025] Fix land ownership in Six Holland, Six Flags Magic Mountain, North America - Grand Canyon and Asia - Great Wall of China Tourism Enhancement scenarios. - Fix: [#18026] Park rating drops to 0 with more than 32k guests, total ride excitement or intensity. -- Fix: [#18051] Visual glitch with Mine Ride's large unbanked turn. - Fix: [#18032] All non-interactive widgets (labels, groupboxes) produce sound when clicked. - Fix: [#18035] Favourited servers don’t get their online status updated. +- Fix: [#18051] Visual glitch with Mine Ride's large unbanked turn. +- Fix: [#18059] [Plugin] Width and height of custom window not changeable via script. 0.4.1 (2022-07-04) ------------------------------------------------------------------------ diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index ceb687adf6..be3f141b22 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -2666,20 +2666,29 @@ declare global { } interface Window { - classification: number; - number: number; + readonly classification: number; + readonly number: number; x: number; y: number; + /** + * The window is resizable (by the user) if and only if minWidth !== maxWidth or minHeight !== maxHeight. + * In that case, the window displays a small widget in the lower right corner that the user can use to resize the window by clicking and dragging. + * + * When writing to width (or height), if the window is resizable, the new value will be clamped to fit the corresponding min/max values. + * Otherwise, if the window is not resizable, both the width (or height) and the corresponding min/max values are set to the new value. + * + * For the default min/max values, see {@link WindowDesc}. + */ width: number; height: number; minWidth: number; maxWidth: number; minHeight: number; maxHeight: number; - isSticky: boolean; + readonly isSticky: boolean; colours: number[]; title: string; - widgets: Widget[]; + readonly widgets: Widget[]; tabIndex: number; close(): void; @@ -2695,6 +2704,14 @@ declare global { height: number; title: string; id?: number; + /** + * See {@link Window} for information about the behaviour of min/max width/height after window creation. + * + * Behaviour during window creation: + * If at least one of the parameters min/max width/height is present, the window is considered to be resizable. + * In that case, the min values default to zero (if unspecified) and the max values default to 0xFFFF (if unspecified). + * Otherwise, the min/max width values default to width and the min/max height values default to height. + */ minWidth?: number; minHeight?: number; maxWidth?: number; diff --git a/src/openrct2-ui/scripting/ScWindow.hpp b/src/openrct2-ui/scripting/ScWindow.hpp index 7b596ec33f..8b47391334 100644 --- a/src/openrct2-ui/scripting/ScWindow.hpp +++ b/src/openrct2-ui/scripting/ScWindow.hpp @@ -99,7 +99,14 @@ namespace OpenRCT2::Scripting auto w = GetWindow(); if (w != nullptr) { - window_resize(*w, value - w->width, 0); + if (window_can_resize(*w)) + { + window_resize(*w, value - w->width, 0); + } + else + { + window_set_resize(*w, value, w->min_height, value, w->max_height); + } } } int32_t height_get() const @@ -116,7 +123,14 @@ namespace OpenRCT2::Scripting auto w = GetWindow(); if (w != nullptr) { - window_resize(*w, 0, value - w->height); + if (window_can_resize(*w)) + { + window_resize(*w, 0, value - w->height); + } + else + { + window_set_resize(*w, w->min_width, value, w->max_width, value); + } } } int32_t minWidth_get() const diff --git a/src/openrct2/scripting/ScriptEngine.h b/src/openrct2/scripting/ScriptEngine.h index b11cabd1b7..1c7bec8c5f 100644 --- a/src/openrct2/scripting/ScriptEngine.h +++ b/src/openrct2/scripting/ScriptEngine.h @@ -46,7 +46,7 @@ namespace OpenRCT2 namespace OpenRCT2::Scripting { - static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 60; + static constexpr int32_t OPENRCT2_PLUGIN_API_VERSION = 61; // Versions marking breaking changes. static constexpr int32_t API_VERSION_33_PEEP_DEPRECATION = 33;