mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-10 08:00:05 +00:00
(svn r27147) -Fix: Scale (non-custom) default window sizes according to GUI zoom.
This commit is contained in:
parent
e113f5e4a1
commit
1cf09f804b
@ -87,12 +87,10 @@ static SmallVector<WindowDesc*, 16> *_window_descs = NULL;
|
||||
char *_windows_file;
|
||||
|
||||
/** Window description constructor. */
|
||||
WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_width, int16 def_height,
|
||||
WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad,
|
||||
WindowClass window_class, WindowClass parent_class, uint32 flags,
|
||||
const NWidgetPart *nwid_parts, int16 nwid_length, HotkeyList *hotkeys) :
|
||||
default_pos(def_pos),
|
||||
default_width(def_width),
|
||||
default_height(def_height),
|
||||
cls(window_class),
|
||||
parent_cls(parent_class),
|
||||
ini_key(ini_key),
|
||||
@ -102,7 +100,9 @@ WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_wi
|
||||
hotkeys(hotkeys),
|
||||
pref_sticky(false),
|
||||
pref_width(0),
|
||||
pref_height(0)
|
||||
pref_height(0),
|
||||
default_width_trad(def_width_trad),
|
||||
default_height_trad(def_height_trad)
|
||||
{
|
||||
if (_window_descs == NULL) _window_descs = new SmallVector<WindowDesc*, 16>();
|
||||
*_window_descs->Append() = this;
|
||||
@ -113,6 +113,26 @@ WindowDesc::~WindowDesc()
|
||||
_window_descs->Erase(_window_descs->Find(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine default width of window.
|
||||
* This is either a stored user preferred size, or the build-in default.
|
||||
* @return Width in pixels.
|
||||
*/
|
||||
int16 WindowDesc::GetDefaultWidth() const
|
||||
{
|
||||
return this->pref_width != 0 ? this->pref_width : ScaleGUITrad(this->default_width_trad);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine default height of window.
|
||||
* This is either a stored user preferred size, or the build-in default.
|
||||
* @return Height in pixels.
|
||||
*/
|
||||
int16 WindowDesc::GetDefaultHeight() const
|
||||
{
|
||||
return this->pref_height != 0 ? this->pref_height : ScaleGUITrad(this->default_height_trad);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all WindowDesc settings from _windows_file.
|
||||
*/
|
||||
|
@ -167,15 +167,13 @@ struct HotkeyList;
|
||||
*/
|
||||
struct WindowDesc : ZeroedMemoryAllocator {
|
||||
|
||||
WindowDesc(WindowPosition default_pos, const char *ini_key, int16 def_width, int16 def_height,
|
||||
WindowDesc(WindowPosition default_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad,
|
||||
WindowClass window_class, WindowClass parent_class, uint32 flags,
|
||||
const NWidgetPart *nwid_parts, int16 nwid_length, HotkeyList *hotkeys = NULL);
|
||||
|
||||
~WindowDesc();
|
||||
|
||||
WindowPosition default_pos; ///< Preferred position of the window. @see WindowPosition()
|
||||
int16 default_width; ///< Preferred initial width of the window.
|
||||
int16 default_height; ///< Preferred initial height of the window.
|
||||
WindowClass cls; ///< Class of the window, @see WindowClass.
|
||||
WindowClass parent_cls; ///< Class of the parent window. @see WindowClass
|
||||
const char *ini_key; ///< Key to store window defaults in openttd.cfg. \c NULL if nothing shall be stored.
|
||||
@ -188,13 +186,16 @@ struct WindowDesc : ZeroedMemoryAllocator {
|
||||
int16 pref_width; ///< User-preferred width of the window. Zero if unset.
|
||||
int16 pref_height; ///< User-preferred height of the window. Zero if unset.
|
||||
|
||||
int16 GetDefaultWidth() const { return this->pref_width != 0 ? this->pref_width : this->default_width; }
|
||||
int16 GetDefaultHeight() const { return this->pref_height != 0 ? this->pref_height : this->default_height; }
|
||||
int16 GetDefaultWidth() const;
|
||||
int16 GetDefaultHeight() const;
|
||||
|
||||
static void LoadFromConfig();
|
||||
static void SaveToConfig();
|
||||
|
||||
private:
|
||||
int16 default_width_trad; ///< Preferred initial width of the window (pixels at 1x zoom).
|
||||
int16 default_height_trad; ///< Preferred initial height of the window (pixels at 1x zoom).
|
||||
|
||||
/**
|
||||
* Dummy private copy constructor to prevent compilers from
|
||||
* copying the structure, which fails due to _window_descs.
|
||||
|
Loading…
Reference in New Issue
Block a user