mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: unify the formatting of the game's caption
This commit is contained in:
parent
9fa1984ef0
commit
d5c0d3beb7
|
@ -18,7 +18,6 @@
|
||||||
#include "../openttd.h"
|
#include "../openttd.h"
|
||||||
#include "../error_func.h"
|
#include "../error_func.h"
|
||||||
#include "../gfx_func.h"
|
#include "../gfx_func.h"
|
||||||
#include "../rev.h"
|
|
||||||
#include "../blitter/factory.hpp"
|
#include "../blitter/factory.hpp"
|
||||||
#include "../core/random_func.hpp"
|
#include "../core/random_func.hpp"
|
||||||
#include "../core/math_func.hpp"
|
#include "../core/math_func.hpp"
|
||||||
|
@ -216,9 +215,8 @@ static bool CreateMainSurface(uint w, uint h)
|
||||||
|
|
||||||
InitPalette();
|
InitPalette();
|
||||||
|
|
||||||
char caption[32];
|
std::string caption = VideoDriver::GetCaption();
|
||||||
seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision);
|
set_window_title(caption.c_str());
|
||||||
set_window_title(caption);
|
|
||||||
|
|
||||||
enable_hardware_cursor();
|
enable_hardware_cursor();
|
||||||
select_mouse_cursor(MOUSE_CURSOR_ARROW);
|
select_mouse_cursor(MOUSE_CURSOR_ARROW);
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include "../../openttd.h"
|
#include "../../openttd.h"
|
||||||
#include "../../debug.h"
|
#include "../../debug.h"
|
||||||
#include "../../rev.h"
|
|
||||||
#include "cocoa_v.h"
|
#include "cocoa_v.h"
|
||||||
#include "cocoa_wnd.h"
|
#include "cocoa_wnd.h"
|
||||||
#include "../../settings_type.h"
|
#include "../../settings_type.h"
|
||||||
|
@ -456,7 +455,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel
|
||||||
|
|
||||||
[ self setContentMinSize:NSMakeSize(64.0f, 64.0f) ];
|
[ 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() ];
|
NSString *nsscaption = [ [ NSString alloc ] initWithUTF8String:caption.c_str() ];
|
||||||
[ self setTitle:nsscaption ];
|
[ self setTitle:nsscaption ];
|
||||||
[ self setMiniwindowTitle:nsscaption ];
|
[ self setMiniwindowTitle:nsscaption ];
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "../stdafx.h"
|
#include "../stdafx.h"
|
||||||
#include "../openttd.h"
|
#include "../openttd.h"
|
||||||
#include "../gfx_func.h"
|
#include "../gfx_func.h"
|
||||||
#include "../rev.h"
|
|
||||||
#include "../blitter/factory.hpp"
|
#include "../blitter/factory.hpp"
|
||||||
#include "../thread.h"
|
#include "../thread.h"
|
||||||
#include "../progress.h"
|
#include "../progress.h"
|
||||||
|
@ -149,10 +148,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
|
y = r.y + std::max(0, r.h - static_cast<int>(h)) / 4; // decent desktops have taskbars at the bottom
|
||||||
}
|
}
|
||||||
|
|
||||||
char caption[50];
|
std::string caption = VideoDriver::GetCaption();
|
||||||
seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision);
|
|
||||||
this->sdl_window = SDL_CreateWindow(
|
this->sdl_window = SDL_CreateWindow(
|
||||||
caption,
|
caption.c_str(),
|
||||||
x, y,
|
x, y,
|
||||||
w, h,
|
w, h,
|
||||||
flags);
|
flags);
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "../openttd.h"
|
#include "../openttd.h"
|
||||||
#include "../error_func.h"
|
#include "../error_func.h"
|
||||||
#include "../gfx_func.h"
|
#include "../gfx_func.h"
|
||||||
#include "../rev.h"
|
|
||||||
#include "../blitter/factory.hpp"
|
#include "../blitter/factory.hpp"
|
||||||
#include "../thread.h"
|
#include "../thread.h"
|
||||||
#include "../progress.h"
|
#include "../progress.h"
|
||||||
|
@ -226,7 +225,6 @@ static void GetAvailableVideoMode(uint *w, uint *h)
|
||||||
bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
|
bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
|
||||||
{
|
{
|
||||||
SDL_Surface *newscreen, *icon;
|
SDL_Surface *newscreen, *icon;
|
||||||
char caption[50];
|
|
||||||
int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
|
int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth();
|
||||||
bool want_hwpalette;
|
bool want_hwpalette;
|
||||||
|
|
||||||
|
@ -360,8 +358,8 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h)
|
||||||
|
|
||||||
InitPalette();
|
InitPalette();
|
||||||
|
|
||||||
seprintf(caption, lastof(caption), "OpenTTD %s", _openttd_revision);
|
std::string caption = VideoDriver::GetCaption();
|
||||||
SDL_WM_SetCaption(caption, caption);
|
SDL_WM_SetCaption(caption.c_str(), caption.c_str());
|
||||||
|
|
||||||
GameSizeChanged();
|
GameSizeChanged();
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "../gfx_func.h"
|
#include "../gfx_func.h"
|
||||||
#include "../gfxinit.h"
|
#include "../gfxinit.h"
|
||||||
#include "../progress.h"
|
#include "../progress.h"
|
||||||
|
#include "../rev.h"
|
||||||
#include "../thread.h"
|
#include "../thread.h"
|
||||||
#include "../window_func.h"
|
#include "../window_func.h"
|
||||||
#include "video_driver.hpp"
|
#include "video_driver.hpp"
|
||||||
|
@ -180,3 +181,12 @@ void VideoDriver::SleepTillNextTick()
|
||||||
std::this_thread::sleep_for(next_tick - now);
|
std::this_thread::sleep_for(next_tick - now);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the caption to use for the game's title bar.
|
||||||
|
* @return The caption.
|
||||||
|
*/
|
||||||
|
/* static */ std::string VideoDriver::GetCaption()
|
||||||
|
{
|
||||||
|
return fmt::format("OpenTTD {}", _openttd_revision);
|
||||||
|
}
|
||||||
|
|
|
@ -201,6 +201,8 @@ public:
|
||||||
return static_cast<VideoDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO));
|
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
|
* 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.
|
* will make sure the buffer is unlocked no matter how the scope is exited.
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "../error_func.h"
|
#include "../error_func.h"
|
||||||
#include "../gfx_func.h"
|
#include "../gfx_func.h"
|
||||||
#include "../os/windows/win32.h"
|
#include "../os/windows/win32.h"
|
||||||
#include "../rev.h"
|
|
||||||
#include "../blitter/factory.hpp"
|
#include "../blitter/factory.hpp"
|
||||||
#include "../core/geometry_func.hpp"
|
#include "../core/geometry_func.hpp"
|
||||||
#include "../core/math_func.hpp"
|
#include "../core/math_func.hpp"
|
||||||
|
@ -221,10 +220,8 @@ bool VideoDriver_Win32Base::MakeWindow(bool full_screen, bool resize)
|
||||||
int x = (mi.rcWork.right - mi.rcWork.left - w) / 2;
|
int x = (mi.rcWork.right - mi.rcWork.left - w) / 2;
|
||||||
int y = (mi.rcWork.bottom - mi.rcWork.top - h) / 2;
|
int y = (mi.rcWork.bottom - mi.rcWork.top - h) / 2;
|
||||||
|
|
||||||
char window_title[64];
|
std::string caption = VideoDriver::GetCaption();
|
||||||
seprintf(window_title, lastof(window_title), "OpenTTD %s", _openttd_revision);
|
this->main_wnd = CreateWindow(L"OTTD", OTTD2FS(caption).c_str(), style, x, y, w, h, 0, 0, GetModuleHandle(nullptr), this);
|
||||||
|
|
||||||
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");
|
if (this->main_wnd == nullptr) UserError("CreateWindow failed");
|
||||||
ShowWindow(this->main_wnd, showstyle);
|
ShowWindow(this->main_wnd, showstyle);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue