Loading

Paste #ptibr0ltx

  1. Index: src/window.cpp
  2. ===================================================================
  3. --- src/window.cpp  (revision 27146)
  4. +++ src/window.cpp  (working copy)
  5. @@ -87,12 +87,10 @@
  6.  char *_windows_file;
  7.  
  8.  /** Window description constructor. */
  9. -WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_width, int16 def_height,
  10. +WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad,
  11.             WindowClass window_class, WindowClass parent_class, uint32 flags,
  12.             const NWidgetPart *nwid_parts, int16 nwid_length, HotkeyList *hotkeys) :
  13.     default_pos(def_pos),
  14. -   default_width(def_width),
  15. -   default_height(def_height),
  16.     cls(window_class),
  17.     parent_cls(parent_class),
  18.     ini_key(ini_key),
  19. @@ -102,7 +100,9 @@
  20.     hotkeys(hotkeys),
  21.     pref_sticky(false),
  22.     pref_width(0),
  23. -   pref_height(0)
  24. +   pref_height(0),
  25. +   default_width_trad(def_width_trad),
  26. +   default_height_trad(def_height_trad)
  27.  {
  28.     if (_window_descs == NULL) _window_descs = new SmallVector<WindowDesc*, 16>();
  29.     *_window_descs->Append() = this;
  30. @@ -113,6 +113,16 @@
  31.     _window_descs->Erase(_window_descs->Find(this));
  32.  }
  33.  
  34. +int16 WindowDesc::GetDefaultWidth() const
  35. +{
  36. +   return this->pref_width != 0 ? this->pref_width : ScaleGUITrad(this->default_width_trad);
  37. +}
  38. +
  39. +int16 WindowDesc::GetDefaultHeight() const
  40. +{
  41. +   return this->pref_height != 0 ? this->pref_height : ScaleGUITrad(this->default_height_trad);
  42. +}
  43. +
  44.  /**
  45.   * Load all WindowDesc settings from _windows_file.
  46.   */
  47. Index: src/window_gui.h
  48. ===================================================================
  49. --- src/window_gui.h    (revision 27146)
  50. +++ src/window_gui.h    (working copy)
  51. @@ -167,15 +167,13 @@
  52.   */
  53.  struct WindowDesc : ZeroedMemoryAllocator {
  54.  
  55. -   WindowDesc(WindowPosition default_pos, const char *ini_key, int16 def_width, int16 def_height,
  56. +   WindowDesc(WindowPosition default_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad,
  57.             WindowClass window_class, WindowClass parent_class, uint32 flags,
  58.             const NWidgetPart *nwid_parts, int16 nwid_length, HotkeyList *hotkeys = NULL);
  59.  
  60.     ~WindowDesc();
  61.  
  62.     WindowPosition default_pos;    ///< Preferred position of the window. @see WindowPosition()
  63. -   int16 default_width;           ///< Preferred initial width of the window.
  64. -   int16 default_height;          ///< Preferred initial height of the window.
  65.     WindowClass cls;               ///< Class of the window, @see WindowClass.
  66.     WindowClass parent_cls;        ///< Class of the parent window. @see WindowClass
  67.     const char *ini_key;           ///< Key to store window defaults in openttd.cfg. \c NULL if nothing shall be stored.
  68. @@ -188,13 +186,16 @@
  69.     int16 pref_width;              ///< User-preferred width of the window. Zero if unset.
  70.     int16 pref_height;             ///< User-preferred height of the window. Zero if unset.
  71.  
  72. -   int16 GetDefaultWidth() const { return this->pref_width != 0 ? this->pref_width : this->default_width; }
  73. -   int16 GetDefaultHeight() const { return this->pref_height != 0 ? this->pref_height : this->default_height; }
  74. +   int16 GetDefaultWidth() const;
  75. +   int16 GetDefaultHeight() const;
  76.  
  77.     static void LoadFromConfig();
  78.     static void SaveToConfig();
  79.  
  80.  private:
  81. +   int16 default_width_trad;      ///< Preferred initial width of the window (pixels at 1x zoom).
  82. +   int16 default_height_trad;     ///< Preferred initial height of the window (pixels at 1x zoom).
  83. +
  84.     /**
  85.      * Dummy private copy constructor to prevent compilers from
  86.      * copying the structure, which fails due to _window_descs.
  87.  

Comments