Merge branch 'master' into jgrpp

# Conflicts:
#	os/macosx/notarize.sh
#	src/3rdparty/CMakeLists.txt
#	src/3rdparty/squirrel/squirrel/sqcompiler.cpp
#	src/3rdparty/squirrel/squirrel/sqdebug.cpp
#	src/3rdparty/squirrel/squirrel/sqvm.cpp
#	src/console_cmds.cpp
#	src/core/span_type.hpp
#	src/crashlog.cpp
#	src/currency.h
#	src/date_gui.cpp
#	src/driver.cpp
#	src/fios.cpp
#	src/genworld_gui.cpp
#	src/hotkeys.cpp
#	src/misc_gui.cpp
#	src/music/os2_m.cpp
#	src/network/core/os_abstraction.h
#	src/network/network_server.cpp
#	src/newgrf.cpp
#	src/newgrf_config.h
#	src/newgrf_text.cpp
#	src/openttd.cpp
#	src/os/macosx/font_osx.cpp
#	src/os/macosx/misc_osx.cpp
#	src/os/os2/CMakeLists.txt
#	src/os/os2/os2.cpp
#	src/os/unix/CMakeLists.txt
#	src/os/windows/font_win32.cpp
#	src/os/windows/win32_main.cpp
#	src/saveload/saveload.cpp
#	src/script/api/script_text.cpp
#	src/settings.cpp
#	src/settings_gui.cpp
#	src/stdafx.h
#	src/strings.cpp
#	src/timetable_gui.cpp
#	src/town_gui.cpp
#	src/train_cmd.cpp
#	src/video/dedicated_v.cpp
#	src/video/video_driver.cpp
#	src/video/win32_v.cpp
#	src/viewport.cpp
#	src/waypoint_gui.cpp
#	src/widgets/dropdown_type.h
#	src/window.cpp
#	src/window_gui.h
This commit is contained in:
Jonathan G Rennison
2023-09-12 20:06:47 +01:00
242 changed files with 4733 additions and 6402 deletions

View File

@@ -17,7 +17,6 @@
#include "../stdafx.h"
#include "../openttd.h"
#include "../gfx_func.h"
#include "../rev.h"
#include "../blitter/factory.hpp"
#include "../core/random_func.hpp"
#include "../core/math_func.hpp"
@@ -215,9 +214,8 @@ static bool CreateMainSurface(uint w, uint h)
InitPalette();
char caption[32];
seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision);
set_window_title(caption);
std::string caption = VideoDriver::GetCaption();
set_window_title(caption.c_str());
enable_hardware_cursor();
select_mouse_cursor(MOUSE_CURSOR_ARROW);

View File

@@ -24,7 +24,6 @@
#include "../../openttd.h"
#include "../../debug.h"
#include "../../rev.h"
#include "cocoa_v.h"
#include "cocoa_wnd.h"
#include "../../settings_type.h"
@@ -459,7 +458,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
[ self setContentMinSize:NSMakeSize(64.0f, 64.0f) ];
std::string caption = std::string{"OpenTTD "} + _openttd_revision;
std::string caption = VideoDriver::GetCaption();
NSString *nsscaption = [ [ NSString alloc ] initWithUTF8String:caption.c_str() ];
[ self setTitle:nsscaption ];
[ self setMiniwindowTitle:nsscaption ];

View File

@@ -24,33 +24,6 @@
#include "../window_func.h"
#include "dedicated_v.h"
#ifdef __OS2__
# include <sys/time.h> /* gettimeofday */
# include <sys/types.h>
# include <unistd.h>
# include <conio.h>
# define INCL_DOS
# include <os2.h>
# define STDIN 0 /* file descriptor for standard input */
/**
* Switches OpenTTD to a console app at run-time, instead of a PM app
* Necessary to see stdout, etc.
*/
static void OS2_SwitchToConsoleMode()
{
PPIB pib;
PTIB tib;
DosGetInfoBlocks(&tib, &pib);
/* Change flag from PM to VIO */
pib->pib_ultype = 3;
}
#endif
#if defined(UNIX)
# include <sys/time.h> /* gettimeofday */
# include <sys/types.h>
@@ -160,11 +133,6 @@ const char *VideoDriver_Dedicated::Start(const StringList &parm)
_set_error_mode(_OUT_TO_STDERR);
#endif
#ifdef __OS2__
/* For OS/2 we also need to switch to console mode instead of PM mode */
OS2_SwitchToConsoleMode();
#endif
DEBUG(driver, 1, "Loading dedicated server");
return nullptr;
}
@@ -181,7 +149,7 @@ void VideoDriver_Dedicated::MakeDirty(int left, int top, int width, int height)
bool VideoDriver_Dedicated::ChangeResolution(int w, int h) { return false; }
bool VideoDriver_Dedicated::ToggleFullscreen(bool fs) { return false; }
#if defined(UNIX) || defined(__OS2__)
#if defined(UNIX)
static bool InputWaiting()
{
struct timeval tv;
@@ -214,7 +182,7 @@ static void DedicatedHandleKeyInput()
if (_exit_game) return;
#if defined(UNIX) || defined(__OS2__)
#if defined(UNIX)
if (fgets(input_line, lengthof(input_line), stdin) == nullptr) return;
#else
/* Handle console input, and signal console thread, it can accept input again */

View File

@@ -10,7 +10,6 @@
#include "../stdafx.h"
#include "../openttd.h"
#include "../gfx_func.h"
#include "../rev.h"
#include "../blitter/factory.hpp"
#include "../thread.h"
#include "../progress.h"
@@ -367,10 +366,9 @@ bool VideoDriver_SDL_Base::CreateMainWindow(uint w, uint h, uint flags)
y = r.y + std::max(0, r.h - static_cast<int>(h)) / 4; // decent desktops have taskbars at the bottom
}
char caption[50];
seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision);
std::string caption = VideoDriver::GetCaption();
this->sdl_window = SDL_CreateWindow(
caption,
caption.c_str(),
x, y,
w, h,
flags);

View File

@@ -12,7 +12,6 @@
#include "../stdafx.h"
#include "../openttd.h"
#include "../gfx_func.h"
#include "../rev.h"
#include "../blitter/factory.hpp"
#include "../thread.h"
#include "../progress.h"
@@ -231,7 +230,6 @@ static void GetAvailableVideoMode(uint *w, uint *h)
bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
{
SDL_Surface *newscreen, *icon;
char caption[50];
int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
bool want_hwpalette;
@@ -365,8 +363,8 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
InitPalette();
seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision);
SDL_WM_SetCaption(caption, caption);
std::string caption = VideoDriver::GetCaption();
SDL_WM_SetCaption(caption.c_str(), caption.c_str());
GameSizeChanged();
@@ -454,7 +452,7 @@ static uint ConvertSdlKeyIntoMy(SDL_keysym *sym, WChar *character)
}
/* check scancode for BACKQUOTE key, because we want the key left of "1", not anything else (on non-US keyboards) */
#if defined(_WIN32) || defined(__OS2__)
#if defined(_WIN32)
if (sym->scancode == 41) key = WKC_BACKQUOTE;
#elif defined(__APPLE__)
if (sym->scancode == 10) key = WKC_BACKQUOTE;

View File

@@ -17,6 +17,7 @@
#include "../gfx_func.h"
#include "../gfxinit.h"
#include "../progress.h"
#include "../rev.h"
#include "../thread.h"
#include "../window_func.h"
#include "video_driver.hpp"
@@ -207,3 +208,12 @@ void VideoDriver::InvalidateGameOptionsWindow()
{
InvalidateWindowClassesData(WC_GAME_OPTIONS, 3);
}
/**
* Get the caption to use for the game's title bar.
* @return The caption.
*/
/* static */ std::string VideoDriver::GetCaption()
{
return stdstr_fmt("OpenTTD %s", _openttd_revision);
}

View File

@@ -208,6 +208,8 @@ public:
return static_cast<VideoDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO));
}
static std::string GetCaption();
/**
* Helper struct to ensure the video buffer is locked and ready for drawing. The destructor
* will make sure the buffer is unlocked no matter how the scope is exited.

View File

@@ -11,7 +11,6 @@
#include "../openttd.h"
#include "../gfx_func.h"
#include "../os/windows/win32.h"
#include "../rev.h"
#include "../blitter/factory.hpp"
#include "../core/geometry_func.hpp"
#include "../core/math_func.hpp"
@@ -214,16 +213,20 @@ bool VideoDriver_Win32Base::MakeWindow(bool full_screen, bool resize)
if (this->main_wnd != nullptr) {
if (!_window_maximize && resize) SetWindowPos(this->main_wnd, 0, 0, 0, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
} else {
/* Center on the workspace of the primary display. */
MONITORINFO mi;
mi.cbSize = sizeof(mi);
GetMonitorInfo(MonitorFromWindow(0, MONITOR_DEFAULTTOPRIMARY), &mi);
int x = 0;
int y = 0;
int x = (mi.rcWork.right - mi.rcWork.left - w) / 2;
int y = (mi.rcWork.bottom - mi.rcWork.top - h) / 2;
/* For windowed mode, center on the workspace of the primary display. */
if (!this->fullscreen) {
MONITORINFO mi;
mi.cbSize = sizeof(mi);
GetMonitorInfo(MonitorFromWindow(0, MONITOR_DEFAULTTOPRIMARY), &mi);
char window_title[64];
seprintf(window_title, lastof(window_title), "OpenTTD %s", _openttd_revision);
x = (mi.rcWork.right - mi.rcWork.left - w) / 2;
y = (mi.rcWork.bottom - mi.rcWork.top - h) / 2;
}
std::string window_title = VideoDriver::GetCaption();
this->main_wnd = CreateWindow(L"OTTD", OTTD2FS(window_title).c_str(), style, x, y, w, h, 0, 0, GetModuleHandle(nullptr), this);
if (this->main_wnd == nullptr) usererror("CreateWindow failed");