summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2015-02-13 21:25:48 +0000
committerfrosch <frosch@openttd.org>2015-02-13 21:25:48 +0000
commit1cf09f804be99adbc2a046fd124330f4fc36c731 (patch)
tree47a48fc975f0b639358daba64b1761b0773ca714 /src/window.cpp
parente113f5e4a14c763ed433487f4d21e2f35e205e1b (diff)
downloadopenttd-1cf09f804be99adbc2a046fd124330f4fc36c731.tar.xz
(svn r27147) -Fix: Scale (non-custom) default window sizes according to GUI zoom.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/window.cpp b/src/window.cpp
index e053165f3..ff24dbd3b 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -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;
@@ -114,6 +114,26 @@ WindowDesc::~WindowDesc()
}
/**
+ * 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.
*/
void WindowDesc::LoadFromConfig()