GEOptions.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef GEOPTIONS_H_
  21. #define GEOPTIONS_H_
  22. #ifndef REGISTRYOPTIONS_H_
  23. #include "../common/registryoptions.h"
  24. #endif
  25. class idRectangle;
  26. class rvGEOptions
  27. {
  28. public:
  29. static const int MAX_MRU_SIZE = rvRegistryOptions::MAX_MRU_SIZE;
  30. rvGEOptions();
  31. void Init( void );
  32. // Write the options to the registery
  33. bool Save ( void );
  34. // Read the options from the registry
  35. bool Load ( void );
  36. void SetSelectionColor ( idVec4& color );
  37. void SetSelectionColor ( COLORREF color );
  38. void SetGridColor ( idVec4& color );
  39. void SetGridColor ( COLORREF color );
  40. void SetGridWidth ( int width );
  41. void SetGridHeight ( int height );
  42. void SetGridVisible ( bool vis );
  43. void SetGridSnap ( bool snap );
  44. void SetLastOptionsPage ( int page );
  45. void SetNavigatorVisible ( bool vis );
  46. void SetPropertiesVisible ( bool vis );
  47. void SetTransformerVisible ( bool vis );
  48. void SetIgnoreDesktopSelect ( bool ignore );
  49. void SetStatusBarVisible ( bool vis );
  50. void AddRecentFile ( const char* filename );
  51. int GetRecentFileCount ( void );
  52. const char* GetRecentFile ( int index );
  53. idVec4& GetGridColor ( void );
  54. int GetGridWidth ( void );
  55. int GetGridHeight ( void );
  56. bool GetGridVisible ( void );
  57. bool GetGridSnap ( void );
  58. int GetLastOptionsPage ( void );
  59. idVec4& GetWorkspaceColor ( void );
  60. bool GetNavigatorVisible ( void );
  61. bool GetTransformerVisible ( void );
  62. bool GetPropertiesVisible ( void );
  63. idVec4& GetSelectionColor ( void );
  64. COLORREF* GetCustomColors ( void );
  65. bool GetIgnoreDesktopSelect ( void );
  66. bool GetStatusBarVisible ( void );
  67. void SetWindowPlacement ( const char* name, HWND hwnd );
  68. bool GetWindowPlacement ( const char* name, HWND hwnd );
  69. void SnapRectToGrid ( idRectangle& rect, bool snapLeft = true, bool snapTop = true, bool snapWidth = true, bool snapHeight = true );
  70. protected:
  71. void ConvertColor ( COLORREF src, idVec4& dest );
  72. void SetModified ( bool mod );
  73. bool mModified;
  74. int mLastOptionsPage;
  75. idVec4 mGridColor;
  76. int mGridWidth;
  77. int mGridHeight;
  78. bool mGridSnap;
  79. bool mGridVisible;
  80. idVec4 mWorkspaceColor;
  81. idVec4 mSelectionColor;
  82. bool mNavigatorVisible;
  83. bool mPropertiesVisible;
  84. bool mTransformerVisible;
  85. bool mStatusBarVisible;
  86. bool mIgnoreDesktopSelect;
  87. idList<idStr> mRecentFiles;
  88. COLORREF mCustomColors[16];
  89. rvRegistryOptions mRegistry;
  90. };
  91. ID_INLINE void rvGEOptions::SetModified ( bool mod )
  92. {
  93. mModified = mod;
  94. }
  95. ID_INLINE void rvGEOptions::ConvertColor ( COLORREF src, idVec4& dest )
  96. {
  97. dest[0] = (float)GetRValue ( src ) / 255.0f;
  98. dest[1] = (float)GetGValue ( src ) / 255.0f;
  99. dest[2] = (float)GetBValue ( src ) / 255.0f;
  100. dest[3] = 1.0f;
  101. }
  102. ID_INLINE void rvGEOptions::SetGridWidth ( int width )
  103. {
  104. mGridWidth = width;
  105. SetModified ( true );
  106. }
  107. ID_INLINE void rvGEOptions::SetGridHeight ( int height )
  108. {
  109. mGridHeight = height;
  110. SetModified ( true );
  111. }
  112. ID_INLINE void rvGEOptions::SetGridSnap ( bool snap )
  113. {
  114. mGridSnap = snap;
  115. SetModified ( true );
  116. }
  117. ID_INLINE void rvGEOptions::SetGridVisible ( bool vis )
  118. {
  119. mGridVisible = vis;
  120. SetModified ( true );
  121. }
  122. ID_INLINE void rvGEOptions::SetStatusBarVisible ( bool vis )
  123. {
  124. mStatusBarVisible = vis;
  125. SetModified ( true );
  126. }
  127. ID_INLINE void rvGEOptions::SetGridColor ( COLORREF color )
  128. {
  129. ConvertColor ( color, mGridColor );
  130. SetModified ( true );
  131. }
  132. ID_INLINE void rvGEOptions::SetSelectionColor ( idVec4& color )
  133. {
  134. VectorCopy ( color, mSelectionColor );
  135. SetModified ( true );
  136. }
  137. ID_INLINE void rvGEOptions::SetSelectionColor ( COLORREF color )
  138. {
  139. ConvertColor ( color, mSelectionColor );
  140. SetModified ( true );
  141. }
  142. ID_INLINE void rvGEOptions::SetGridColor ( idVec4& color )
  143. {
  144. VectorCopy ( color, mGridColor );
  145. SetModified ( true );
  146. }
  147. ID_INLINE void rvGEOptions::SetNavigatorVisible ( bool vis )
  148. {
  149. mNavigatorVisible = vis;
  150. SetModified ( true );
  151. }
  152. ID_INLINE void rvGEOptions::SetPropertiesVisible ( bool vis )
  153. {
  154. mPropertiesVisible = vis;
  155. SetModified ( true );
  156. }
  157. ID_INLINE void rvGEOptions::SetTransformerVisible ( bool vis )
  158. {
  159. mTransformerVisible = vis;
  160. SetModified ( true );
  161. }
  162. ID_INLINE idVec4& rvGEOptions::GetGridColor ( void )
  163. {
  164. return mGridColor;
  165. }
  166. ID_INLINE int rvGEOptions::GetGridWidth ( void )
  167. {
  168. return mGridWidth;
  169. }
  170. ID_INLINE int rvGEOptions::GetGridHeight ( void )
  171. {
  172. return mGridHeight;
  173. }
  174. ID_INLINE bool rvGEOptions::GetGridVisible ( void )
  175. {
  176. return mGridVisible;
  177. }
  178. ID_INLINE bool rvGEOptions::GetGridSnap ( void )
  179. {
  180. return mGridSnap;
  181. }
  182. ID_INLINE idVec4& rvGEOptions::GetWorkspaceColor ( void )
  183. {
  184. return mWorkspaceColor;
  185. }
  186. ID_INLINE int rvGEOptions::GetLastOptionsPage ( void )
  187. {
  188. return mLastOptionsPage;
  189. }
  190. ID_INLINE void rvGEOptions::SetLastOptionsPage ( int page )
  191. {
  192. mLastOptionsPage = page;
  193. }
  194. ID_INLINE bool rvGEOptions::GetNavigatorVisible ( void )
  195. {
  196. return mNavigatorVisible;
  197. }
  198. ID_INLINE bool rvGEOptions::GetPropertiesVisible ( void )
  199. {
  200. return mPropertiesVisible;
  201. }
  202. ID_INLINE bool rvGEOptions::GetTransformerVisible ( void )
  203. {
  204. return mTransformerVisible;
  205. }
  206. ID_INLINE bool rvGEOptions::GetStatusBarVisible ( void )
  207. {
  208. return mStatusBarVisible;
  209. }
  210. ID_INLINE idVec4& rvGEOptions::GetSelectionColor ( void )
  211. {
  212. return mSelectionColor;
  213. }
  214. ID_INLINE COLORREF* rvGEOptions::GetCustomColors ( void )
  215. {
  216. return mCustomColors;
  217. }
  218. ID_INLINE void rvGEOptions::SetIgnoreDesktopSelect ( bool ignore )
  219. {
  220. mIgnoreDesktopSelect = ignore;
  221. }
  222. ID_INLINE bool rvGEOptions::GetIgnoreDesktopSelect ( void )
  223. {
  224. return mIgnoreDesktopSelect;
  225. }
  226. ID_INLINE void rvGEOptions::SetWindowPlacement ( const char* name, HWND hwnd )
  227. {
  228. mRegistry.SetWindowPlacement ( name, hwnd );
  229. }
  230. ID_INLINE bool rvGEOptions::GetWindowPlacement ( const char* name, HWND hwnd )
  231. {
  232. return mRegistry.GetWindowPlacement ( name, hwnd );
  233. }
  234. ID_INLINE void rvGEOptions::AddRecentFile ( const char* filename )
  235. {
  236. mRegistry.AddRecentFile ( filename );
  237. }
  238. ID_INLINE int rvGEOptions::GetRecentFileCount ( void )
  239. {
  240. return mRegistry.GetRecentFileCount ( );
  241. }
  242. ID_INLINE const char* rvGEOptions::GetRecentFile ( int index )
  243. {
  244. return mRegistry.GetRecentFile ( index );
  245. }
  246. #endif // _GEOPTIONS_H_