Merge branch 'master' into jgrpp

# Conflicts:
#	.github/workflows/ci-build.yml
#	.github/workflows/codeql.yml
#	.github/workflows/release-linux.yml
#	.github/workflows/release-macos.yml
#	.github/workflows/release-windows.yml
#	src/map.cpp
#	src/music/midifile.hpp
#	src/order_cmd.cpp
#	src/order_gui.cpp
#	src/pathfinder/yapf/yapf_rail.cpp
#	src/pbs.cpp
#	src/saveload/afterload.cpp
#	src/saveload/saveload.h
#	src/saveload/vehicle_sl.cpp
#	src/script/api/script_text.cpp
#	src/ship_cmd.cpp
#	src/train_cmd.cpp
#	src/vehicle.cpp
#	src/vehicle_base.h
#	src/vehicle_func.h
#	src/vehicle_gui.cpp
#	src/vehicle_gui_base.h
#	src/viewport.cpp
#	src/waypoint_cmd.cpp
This commit is contained in:
Jonathan G Rennison
2024-03-12 17:44:28 +00:00
87 changed files with 3648 additions and 2256 deletions

View File

@@ -2077,9 +2077,6 @@ static void HandleMouseOver()
}
}
/** The minimum number of pixels of the title bar must be visible in both the X or Y direction */
static const int MIN_VISIBLE_TITLE_BAR = 13;
/** Direction for moving the window. */
enum PreventHideDirection {
PHD_UP, ///< Above v is a safe position.
@@ -2091,7 +2088,7 @@ enum PreventHideDirection {
* If needed, move the window base coordinates to keep it visible.
* @param nx Base horizontal coordinate of the rectangle.
* @param ny Base vertical coordinate of the rectangle.
* @param rect Rectangle that must stay visible for #MIN_VISIBLE_TITLE_BAR pixels (horizontally, vertically, or both)
* @param rect Rectangle that must stay visible (horizontally, vertically, or both)
* @param v Window lying in front of the rectangle.
* @param px Previous horizontal base coordinate.
* @param dir If no room horizontally, move the rectangle to the indicated position.
@@ -2100,10 +2097,10 @@ static void PreventHiding(int *nx, int *ny, const Rect &rect, const Window *v, i
{
if (v == nullptr) return;
const int min_visible = ScaleGUITrad(MIN_VISIBLE_TITLE_BAR);
const int min_visible = rect.Height();
int v_bottom = v->top + v->height;
int v_right = v->left + v->width;
int v_bottom = v->top + v->height - 1;
int v_right = v->left + v->width - 1;
int safe_y = (dir == PHD_UP) ? (v->top - min_visible - rect.top) : (v_bottom + min_visible - rect.bottom); // Compute safe vertical position.
if (*ny + rect.top <= v->top - min_visible) return; // Above v is enough space
@@ -2139,12 +2136,11 @@ static void PreventHiding(int *nx, int *ny, const Rect &rect, const Window *v, i
static void EnsureVisibleCaption(Window *w, int nx, int ny)
{
/* Search for the title bar rectangle. */
Rect caption_rect;
const NWidgetBase *caption = w->nested_root->GetWidgetOfType(WWT_CAPTION);
if (caption != nullptr) {
caption_rect = caption->GetCurrentRect();
const Rect caption_rect = caption->GetCurrentRect();
const int min_visible = ScaleGUITrad(MIN_VISIBLE_TITLE_BAR);
const int min_visible = caption_rect.Height();
/* Make sure the window doesn't leave the screen */
nx = Clamp(nx, min_visible - caption_rect.right, _screen.width - min_visible - caption_rect.left);