2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef _PREFERENCES_H_
23 #define _PREFERENCES_H_
26 #include "gtkr_list.h"
27 //#include "profile.h"
30 #define NVIDIA_AERO_HACK
33 #define MAX_TEXTURE_QUALITY 3
46 a preference assignment, name, type and pointer to value
47 we don't store the xmlNodePtr because the document itself can be thrown away upon any LoadPref
48 (see CGameDialog::UpdatePrefTree)
57 CPrefAssignment(const char *name, PrefTypes_t Type, void *Val)
59 mName = name; mType = Type; mVal = Val;
61 CPrefAssignment() { mVal = NULL; }
62 CPrefAssignment(const CPrefAssignment& ass);
63 virtual ~CPrefAssignment() { }
64 virtual CPrefAssignment& operator =(const CPrefAssignment& ass);
69 generic preferences storage class, using xml files
81 prefs assignments (what pref name, what type, what variable)
83 list<CPrefAssignment> mPrefAssignments;
86 name of file to load/save as
91 store assignment in the property list if not already there
93 void PushAssignment(const char *name, PrefTypes_t type, void *pV);
96 find the xmlnode relating to the epair name
98 xmlNodePtr EpairForName(const char *name);
102 virtual ~CXMLPropertyBag()
109 read a pref setting, if doesn't exist, will add it to the xml tree (using default value provided)
110 \arg name the name of the pref
111 \arg pV pointer to the value
113 those functions will fill in the list of preferences assignments
114 (name, type and pointer to value)
115 this is used in UpdatePrefTree
117 void GetPref(const char *name, Str *pV, const char *V);
118 void GetPref(const char *name, int *pV, int V);
119 void GetPref(const char *name, bool *pV, bool V);
120 void GetPref(const char *name, float *pV, float V);
121 void GetPref(const char *name, float *pV, float* V);
122 void GetPref(const char *name, window_position_t* pV, window_position_t V);
125 returns whether or not the property bag is already open
127 qboolean InUse() { return (mpDoc != NULL); };
130 unload the xml doc, and free the tree
135 read data from our XML file
137 void ReadXMLFile(const char* pFilename);
140 write out the property bag to an XML data file
141 return is success/fail
143 qboolean WriteXMLFile(const char* pFilename);
146 update the xml tree with data form the property list, usually in preparation for a write
148 void UpdatePrefTree();
151 did the file have any data or not?
157 holds information for a given game
158 I'm a bit unclear on that still
159 it holds game specific configuration stuff
160 such as base names, engine names, some game specific features to activate in the various modules
161 it is not strictly a prefs thing since the user is not supposed to edit that (unless he is hacking
162 support for a new game)
164 what we do now is fully generate the information for this during the setup. We might want to
165 generate a piece that just says "the game pack is there", but put the rest of the config somwhere
166 else (i.e. not generated, copied over during setup .. for instance in the game tools directory)
168 class CGameDescription
171 xmlDocPtr mpDoc; ///< the game description xml tree
172 Str mGameToolsPath; ///< the explicit path to the game-dependent modules
173 Str mGameName; ///< name of the game used in dialogs
174 Str mGameFile; ///< the .game file that describes this game
175 Str mBaseGame; ///< basegame directory
176 Str mEnginePath; ///< path to the engine
177 Str mEngine; ///< engine name
178 Str mMultiplayerEngine; ///< engine name
179 #if defined (__linux__) || defined (__APPLE__)
180 Str mUserPathPrefix; ///< prefix for ~/.q3a ~/.wolf init, only on *nix
182 Str mShaderPath; ///< the path in which to look for shaders
183 Str mShaderlist; ///< shaderlist file
184 float mTextureDefaultScale; ///< default scale (0.5 in q3, 1.0 in q1/q2, 0.25 in JK2 ..)
185 bool mEClassSingleLoad; ///< only load a single eclass definition file
186 bool mNoPatch; ///< this game doesn't support patch technology
187 Str mCaulkShader; ///< the shader to use for caulking
188 bool quake2; ///< set this to true to get quake2
189 bool noMapsInHome; ///< set this if you want to open the engine path/base dir/maps dir for map open/save dialoges */
191 CGameDescription() { mpDoc = NULL; }
193 \todo parse basic info from the node
194 user-friendly name of the game
195 essential parameters (such as the start dir)
197 CGameDescription(xmlDocPtr pDoc, const Str &GameFile);
198 virtual ~CGameDescription() { xmlFreeDoc(mpDoc); }
204 select games, copy editing assets and write out configuration files
207 #define Q3_PACK "Q3Pack"
208 #define URT_PACK "UrTPack"
209 #define UFOAI_PACK "UFOAIPack"
210 #define Q2W_PACK "Q2WPack"
211 #define WARSOW_PACK "WarsowPack"
212 #define NEXUIZ_PACK "NexuizPack"
213 #define Q2_PACK "Q2Pack"
214 #define TREMULOUS_PACK "TremulousPack"
215 #define JA_PACK "JAPack"
216 #define REACTION_PACK "ReactionPack"
218 class CGameInstall : public Dialog {
225 static void OnBtnBrowseEngine( GtkWidget *widget, gpointer data );
226 static void OnGameSelectChanged( GtkWidget *widget, gpointer data );
249 // maps from m_nComboSelect to the games
250 int m_availGames[GAME_COUNT];
254 standalone dialog for games selection, and more generally global settings
256 class CGameDialog : public Dialog
258 GtkWidget *mFrame; ///< this is built on-demand first time it's used
259 GtkWidget *mTopBox; ///< top level box used to store the dialog frame, must unhook after modal use
261 GtkComboBox *mGameCombo; // combo box holds the selection of available game
266 CXMLPropertyBag mGlobalPrefs;
270 run from a network share
271 this one is not being saved out in prefs, since we need to know before we load prefs
272 we use a dummy file NETRUN_FILENAME as flag
273 all done with static stuff
275 static bool m_bNetRun;
278 bool m_bDoGameInstall;
280 CGameInstall mGameInstall;
284 int m_nComboSelect; ///< intermediate int value for combo in dialog box
289 those settings are saved in the global prefs file
290 I'm too lazy to wrap behind protected access, not sure this needs to be public
291 NOTE: those are preference settings. if you change them it is likely that you would
292 have to restart the editor for them to take effect
296 what game has been selected
297 this is the name of the .game file
301 auto-load the game on startup
302 this is linked to auto-load checkbox
304 bool m_bAutoLoadGame;
306 log console to radiant.log
307 m_bForceLogConsole is an obscure forced latching situation
310 bool m_bForceLogConsole;
314 points somewhere in mGames, set once at startup
316 CGameDescription *m_pCurrentGameDescription;
319 the list of game descriptions we scanned from the game/ dir
321 list<CGameDescription *> mGames;
325 m_pCurrentGameDescription = NULL;
326 m_bLogConsole = false;
327 m_bForceLogConsole = false;
328 m_bDoGameInstall = true; // go through DoModal at least once
331 virtual ~CGameDialog();
333 void AddPacksURL( Str &s );
336 intialize the game dialog, called at CPrefsDlg::Init
337 will scan for games, load prefs, and do game selection dialog if needed
342 reset the global settings by removing the file
347 run the dialog UI for the list of games
352 call out to the game installation dialog
354 void DoGameInstall();
358 this is only called when the dialog is built at startup for main engine select
361 void UpdateData( bool retrieve );
364 construction of the dialog frame
365 this is the part to be re-used in prefs dialog
366 for the standalone dialog, we include this in a modal box
367 for prefs, we hook the frame in the main notebook
368 build the frame on-demand (only once)
370 GtkWidget *GetGlobalFrame();
373 global preferences subsystem
374 XML-based this time, hopefully this will generalize to other prefs
375 LoadPrefs has hardcoded defaults
376 NOTE: it may not be strictly 'CGameDialog' to put the global prefs here
377 could have named the class differently I guess
380 void LoadPrefs(); ///< load from file into variables
381 void SavePrefs(); ///< save pref variables to file
385 read or set netrun (check file)
387 if false, will check if netrun file is present and will set m_bNetRun
388 if true, will create/erase the netrun file depending on m_bNetRun
389 NOTE: this is not backwards, 'retrieve' means 'retrieve from settings dialog' - in terms of UI
391 static void UpdateNetrun(bool retrieve);
393 get current netrun setting
395 static bool GetNetrun();
399 scan for .game files, load them
404 inits g_PrefsDlg.m_global_rc_path
406 void InitGlobalPrefPath();
409 uses m_nComboItem to find the right mGames
411 CGameDescription *GameDescriptionForComboItem();
414 callback for the game install button
416 static void SInstallCallback( GtkWidget *widget, gpointer data );
418 void UpdateGameCombo();
425 window_position_t position;
427 window_position_t posEntityWnd;
428 window_position_t posMapInfoWnd;
429 window_position_t posCamWnd;
430 window_position_t posZWnd;
431 window_position_t posXYWnd;
432 window_position_t posXZWnd;
433 window_position_t posYZWnd;
434 window_position_t posPatchWnd;
435 window_position_t posSurfaceWnd;
436 window_position_t posEntityInfoWnd;
447 class PrefsDlg : public Dialog
454 CXMLPropertyBag mLocalPrefs;
456 // will enable/disable stuff according to the situation
457 void DoSensitivity();
458 void PreModal() { DoSensitivity(); }
460 // enable/disable custom editor entry
461 void DoEditorSensitivity();
464 this holds global level preferences
466 CGameDialog mGamesDialog;
468 // warning about old project files
470 list<CGameDescription *> mGames;
473 // last light intensity used in the CLightPrompt dialog, stored in registry
474 int m_iLastLightIntensity;
475 // these mirror what goes in the combo box
476 // see PrefDlg::m_nShader, tells wether to load NONE / COMMON or ALL shaders at parsing stage
477 enum {SHADER_NONE = 0, SHADER_COMMON, SHADER_ALL};
479 // Gef: updated preferences dialog
480 /*! Preference notebook page numbers */
481 enum {PTAB_FRONT = 0, PTAB_GAME_SETTINGS, PTAB_2D, PTAB_CAMERA, PTAB_TEXTURE, PTAB_LAYOUT, PTAB_MOUSE,
482 PTAB_EDITING, PTAB_STARTUP, PTAB_PATHS, PTAB_BRUSH, PTAB_MISC, PTAB_BSPMONITOR} pref_tabs;
486 void UpdateTextureCompression();
489 void UpdateATIHack();
492 #ifdef NVIDIA_AERO_HACK
493 void UpdateNvidiaAeroHack();
498 void LoadTexdefPref(texdef_t* pTexdef, char* pName);
503 g_string_free (m_rc_path, true );
504 g_string_free (m_inipath, true );
508 path for global settings
510 linux: ~/.radiant/<version>/
512 GString *m_global_rc_path;
515 path to per-game settings
516 used for various game dependant storage
517 win32: g_strGameToolsPath
518 linux: ~/.radiant/<version>/<gamename>/
523 holds per-game settings
524 m_rc_path+"local.pref"
525 \todo FIXME at some point this should become XML property bag code too
529 // initialize the above paths
533 // DEPRECATED: use engine path from the current game description instead
534 // path to the top-level installation
536 // name of executable
539 // we use this Str to store the full path to the engine: m_strEnginePath + m_strEngine
540 // it's not stored in the registry or anything, just ued for display in prefs
541 Str m_strPrefsDlgEngine;
546 MainFrame::EViewStyle m_nView;
549 // path to the project loaded at startup
550 // if g_PrefsDlg can't find the information in the ini file
551 // it will try to guess and eventually ask the user
552 Str m_strLastProject;
554 version of last loaded project file
555 says -1 if there's no version loaded
556 if it's a manually constructed project file, will be 0
557 otherwise the actual 'version' epair
559 int m_nLastProjectVer;
566 bool m_bTextureWindow;
571 int m_nCamDragMultiSelect;
572 bool m_bCamDragMultiSelect;
574 bool m_bCamFreeLookStrafe;
575 bool m_bCamInverseMouse;
577 bool m_bNewLightDraw;
588 bool m_bDetachableMenus;
589 bool m_bPatchToolbar;
591 bool m_bPluginToolbar;
593 //++timo this is most likely broken, I don't know what it's supposed to do
598 bool m_bTextureScrollbar;
599 bool m_bDisplayLists;
600 bool m_bAntialiasedPointsAndLines; // Fishman - Add antialiazed points and lines support. 09/03/00
611 bool m_bCubicClipping;
613 bool m_bSelectCurves;
614 bool m_bSelectModels;
615 int m_nEntityShowState;
617 bool m_bNormalizeColors;
619 bool m_bSelectWholeEntities;
620 int m_nTextureQuality;
622 bool m_bTexturesShaderlistOnly;
624 float m_fDefTextureScale;
626 bool m_bLatchedFloatingZ;
627 // Gef: Kyro GL_POINT workaround
628 bool m_bGlPtWorkaround;
630 // how many menus in the texture thing before we split?
631 int m_nTextureMenuSplit;
633 // watch the BSP process through network connections
634 // true: trigger the BSP steps one by one and monitor them through the network
635 // false: create a BAT / .sh file and execute it. don't bother monitoring it.
637 // do we stop the compilation process if we come accross a leak?
639 // timeout when beginning a step (in seconds)
640 // if we don't get a connection quick enough we assume something failed and go back to idling
643 // store prefs setting for automatic sleep mode activation
648 // make the texture increments match the grid changes
651 // try to fix the target/targetname conflicts when importing a map (default true)
654 // the increment step we use against the wheel mouse
658 // use the file associations to open files instead of builtin Gtk editor
659 bool m_bUseWin32Editor;
661 // custom shader editor
662 bool m_bUseCustomEditor;
663 Str m_strEditorCommand; // this is the command executed
668 bool m_bStartOnPrimMon;
671 bool m_bPatchBBoxSelect;
673 // RR2DO2: latched data, for settings that require a restart. We don't want to set
674 // these directly in case users set them under preferences and then continue working
676 MainFrame::EViewStyle m_nLatchedView;
678 Str m_strMRUFiles[4];
680 windowPosInfo_t mWindowInfo;
682 bool m_bLatchedDetachableMenus;
683 bool m_bLatchedPatchToolbar;
684 bool m_bLatchedWideToolbar;
685 bool m_bLatchedPluginToolbar;
686 int m_nLatchedShader;
687 int m_nLatchedTextureQuality;
690 // texture compression format
691 int m_nTextureCompressionFormat;
693 int m_nLightRadiuses;
695 bool m_bQ3Map2Texturing;
701 #ifdef NVIDIA_AERO_HACK
702 bool m_bGlNvidiaAeroHack;
703 int m_bGlNvidiaAeroHackPrevState;
706 void UpdateData (bool retrieve);
708 /*! Utility function for swapping notebook pages for tree list selections */
709 void showPrefPage(int prefpage);
712 /*! Scan for game description files and build a list */
717 void PostModal (int code);
720 #endif // _PREFERENCES_H_