Compare commits

...

4 Commits

Author SHA1 Message Date
Peter Nelson 2c48b1efb9 Change: limit purchase list rows to 1.5x original design height 2026-07-13 23:15:08 +01:00
Peter Nelson e3dfd59df0 Change: clip content in purchase list to each row 2026-07-13 23:15:08 +01:00
Enova 0366278c9d Codechange: Support ID_LIKE in build targeting (#15818) 2026-07-13 23:15:22 +02:00
Rubidium 808ae7f270 Codechange: [Windows] Use SetThreadDescription over magic exception 2026-07-13 18:41:39 +02:00
4 changed files with 38 additions and 46 deletions
+15 -6
View File
@@ -191,17 +191,26 @@ elseif(UNIX)
set(PLATFORM "unknown")
else()
if(EXISTS "/etc/os-release")
file(STRINGS "/etc/os-release" OS_RELEASE_CONTENTS REGEX "^ID=")
string(REGEX MATCH "ID=(.*)" _ ${OS_RELEASE_CONTENTS})
set(DISTRO_ID ${CMAKE_MATCH_1})
if(DISTRO_ID STREQUAL "arch")
file(STRINGS "/etc/os-release" OS_RELEASE_LIKE_CONTENTS REGEX "^ID_LIKE=")
if (OS_RELEASE_LIKE_CONTENTS)
string(REGEX MATCH "ID_LIKE=\\\"?([^\\\"]+)" _ ${OS_RELEASE_LIKE_CONTENTS})
string(REGEX MATCHALL "([^ ]+)" DISTRO_LIKE_IDS ${CMAKE_MATCH_1})
endif()
if (DISTRO_LIKE_IDS)
set(DISTRO_IDS ${DISTRO_LIKE_IDS})
else()
file(STRINGS "/etc/os-release" OS_RELEASE_CONTENTS REGEX "^ID=")
string(REGEX MATCH "ID=(.*)" _ ${OS_RELEASE_CONTENTS})
set(DISTRO_IDS ${CMAKE_MATCH_1})
endif()
if("arch" IN_LIST DISTRO_IDS)
set(PLATFORM "arch")
set(CPACK_GENERATOR "TXZ")
elseif(DISTRO_ID STREQUAL "fedora" OR DISTRO_ID STREQUAL "rhel")
elseif("fedora" IN_LIST DISTRO_IDS OR "rhel" IN_LIST DISTRO_IDS)
set(PLATFORM "fedora")
set(CPACK_GENERATOR "RPM")
include(PackageRPM)
elseif(DISTRO_ID STREQUAL "ubuntu" OR DISTRO_ID STREQUAL "debian" OR DISTRO_ID STREQUAL "linuxmint")
elseif("debian" IN_LIST DISTRO_IDS OR "ubuntu" IN_LIST DISTRO_IDS OR "linuxmint" IN_LIST DISTRO_IDS)
file(STRINGS "/etc/os-release" OS_RELEASE_CODENAME REGEX "^VERSION_CODENAME=")
string(REGEX MATCH "VERSION_CODENAME=(.*)" _ ${OS_RELEASE_CODENAME})
set(RELEASE_CODENAME ${CMAKE_MATCH_1})
+8 -3
View File
@@ -962,7 +962,7 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
const int offset = (rtl ? -circle_width : circle_width) / 2;
const int level_width = rtl ? -WidgetDimensions::scaled.hsep_indent : WidgetDimensions::scaled.hsep_indent;
for (auto it = first; it != last; ++it) {
for (auto it = first; it != last; ++it, ir = ir.Translate(0, step_size)) {
const auto &item = *it;
const Engine *e = Engine::Get(item.engine_id);
@@ -971,6 +971,13 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
bool is_folded = item.flags.Test(EngineDisplayFlag::IsFolded);
bool shaded = item.flags.Test(EngineDisplayFlag::Shaded);
/* Set up clipping area for the row, keeping coordinates relative to the window. */
DrawPixelInfo tmp_dpi;
if (!FillDrawPixelInfo(&tmp_dpi, ir)) continue;
tmp_dpi.left += ir.left;
tmp_dpi.top += ir.top;
AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
Rect textr = ir.Shrink(WidgetDimensions::scaled.matrix);
Rect tr = ir.Indent(indent, rtl);
@@ -1146,8 +1153,6 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li
/* The left/right bounds are adjusted to not overlap with the sort detail that is on the left/right depending on the RTL setting. */
DrawString(tr.left + (rtl ? sort_detail_width : 0), tr.right - (rtl ? 0 : sort_detail_width), textr.top + normal_text_y_offset, name, tc);
ir = ir.Translate(0, step_size);
}
}
+10 -6
View File
@@ -176,7 +176,7 @@ static void InitBlocksizeForVehicles(VehicleType type, EngineImageType image_typ
{
int max_extend_left = 0;
int max_extend_right = 0;
uint max_height = 0;
uint height = 0;
for (const Engine *e : Engine::IterateType(type)) {
if (!e->IsEnabled()) continue;
@@ -192,7 +192,7 @@ static void InitBlocksizeForVehicles(VehicleType type, EngineImageType image_typ
case VehicleType::Ship: GetShipSpriteSize(eid, x, y, x_offs, y_offs, image_type); break;
case VehicleType::Aircraft: GetAircraftSpriteSize(eid, x, y, x_offs, y_offs, image_type); break;
}
if (y > max_height) max_height = y;
if (y > height) height = y;
if (-x_offs > max_extend_left) max_extend_left = -x_offs;
if ((int)x + x_offs > max_extend_right) max_extend_right = x + x_offs;
}
@@ -200,15 +200,19 @@ static void InitBlocksizeForVehicles(VehicleType type, EngineImageType image_typ
int min_extend = ScaleSpriteTrad(16);
int max_extend = ScaleSpriteTrad(98);
/* Limit sprite height to limits based on original design height to prevent window size running away. */
int min_height = ScaleSpriteTrad(GetVehicleHeight(type));
int max_height = min_height + min_height / 2;
switch (image_type) {
case EngineImageType::InDepot:
_base_block_sizes_depot[type].height = std::max<uint>(ScaleSpriteTrad(GetVehicleHeight(type)), max_height);
_base_block_sizes_depot[type].extend_left = Clamp(max_extend_left, min_extend, max_extend);
_base_block_sizes_depot[type].height = Clamp(height, min_height, max_height);
_base_block_sizes_depot[type].extend_left = Clamp(max_extend_left, min_extend, max_extend);
_base_block_sizes_depot[type].extend_right = Clamp(max_extend_right, min_extend, max_extend);
break;
case EngineImageType::Purchase:
_base_block_sizes_purchase[type].height = std::max<uint>(ScaleSpriteTrad(GetVehicleHeight(type)), max_height);
_base_block_sizes_purchase[type].extend_left = Clamp(max_extend_left, min_extend, max_extend);
_base_block_sizes_purchase[type].height = Clamp(height, min_height, max_height);
_base_block_sizes_purchase[type].extend_left = Clamp(max_extend_left, min_extend, max_extend);
_base_block_sizes_purchase[type].extend_right = Clamp(max_extend_right, min_extend, max_extend);
break;
+5 -31
View File
@@ -16,6 +16,7 @@
#include <windows.h>
#include <fcntl.h>
#include <mmsystem.h>
#include <processthreadsapi.h>
#include <regstr.h>
#define NO_SHOBJIDL_SORTDIRECTION /**< Avoid multiple definition of SORT_ASCENDING. */
#include <shlobj.h> /* SHGetFolderPath */
@@ -533,36 +534,9 @@ int Win32StringContains(std::string_view str, std::string_view value, bool case_
return -1; // Failure indication.
}
#ifdef _MSC_VER
/* Based on code from MSDN: https://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx */
const DWORD MS_VC_EXCEPTION = 0x406D1388;
PACK_N(struct THREADNAME_INFO {
DWORD dwType; ///< Must be 0x1000.
LPCSTR szName; ///< Pointer to name (in user addr space).
DWORD dwThreadID; ///< Thread ID (-1=caller thread).
DWORD dwFlags; ///< Reserved for future use, must be zero.
}, 8);
/**
* Signal thread name to any attached debuggers.
*/
void SetCurrentThreadName(const std::string &thread_name)
void SetCurrentThreadName(const std::string &name)
{
THREADNAME_INFO info;
info.dwType = 0x1000;
info.szName = thread_name.c_str();
info.dwThreadID = -1;
info.dwFlags = 0;
#pragma warning(push)
#pragma warning(disable: 6320 6322)
__try {
RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info);
} __except (EXCEPTION_EXECUTE_HANDLER) {
}
#pragma warning(pop)
using SetThreadDescriptionProc = HRESULT(WINAPI *)(HANDLE, PCWSTR);
static const SetThreadDescriptionProc std_proc = GetKernel32Function("SetThreadDescription");
if (std_proc != nullptr) std_proc(GetCurrentThread(), OTTD2FS(name).c_str());
}
#else
void SetCurrentThreadName(const std::string &) {}
#endif