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"
29 #define MAX_TEXTURE_QUALITY 3
42 a preference assignment, name, type and pointer to value
43 we don't store the xmlNodePtr because the document itself can be thrown away upon any LoadPref
44 (see CGameDialog::UpdatePrefTree)
53 CPrefAssignment(const char *name, PrefTypes_t Type, void *Val)
55 mName = name; mType = Type; mVal = Val;
57 CPrefAssignment() { mVal = NULL; }
58 CPrefAssignment(const CPrefAssignment& ass);
59 virtual ~CPrefAssignment() { }
60 virtual CPrefAssignment& operator =(const CPrefAssignment& ass);
65 generic preferences storage class, using xml files
77 prefs assignments (what pref name, what type, what variable)
79 list<CPrefAssignment> mPrefAssignments;
82 name of file to load/save as
87 store assignment in the property list if not already there
89 void PushAssignment(const char *name, PrefTypes_t type, void *pV);
92 find the xmlnode relating to the epair name
94 xmlNodePtr EpairForName(const char *name);
98 virtual ~CXMLPropertyBag()
105 read a pref setting, if doesn't exist, will add it to the xml tree (using default value provided)
106 \arg name the name of the pref
107 \arg pV pointer to the value
109 those functions will fill in the list of preferences assignments
110 (name, type and pointer to value)
111 this is used in UpdatePrefTree
113 void GetPref(const char *name, Str *pV, const char *V);
114 void GetPref(const char *name, int *pV, int V);
115 void GetPref(const char *name, bool *pV, bool V);
116 void GetPref(const char *name, float *pV, float V);
117 void GetPref(const char *name, float *pV, float* V);
118 void GetPref(const char *name, window_position_t* pV, window_position_t V);
121 returns whether or not the property bag is already open
123 qboolean InUse() { return (mpDoc != NULL); };
126 unload the xml doc, and free the tree
131 read data from our XML file
133 void ReadXMLFile(const char* pFilename);
136 write out the property bag to an XML data file
137 return is success/fail
139 qboolean WriteXMLFile(const char* pFilename);
142 update the xml tree with data form the property list, usually in preparation for a write
144 void UpdatePrefTree();
147 did the file have any data or not?
153 holds information for a given game
154 I'm a bit unclear on that still
155 it holds game specific configuration stuff
156 such as base names, engine names, some game specific features to activate in the various modules
157 it is not strictly a prefs thing since the user is not supposed to edit that (unless he is hacking
158 support for a new game)
160 what we do now is fully generate the information for this during the setup. We might want to
161 generate a piece that just says "the game pack is there", but put the rest of the config somwhere
162 else (i.e. not generated, copied over during setup .. for instance in the game tools directory)
164 class CGameDescription
167 xmlDocPtr mpDoc; ///< the game description xml tree
168 Str mGameToolsPath; ///< the explicit path to the game-dependent modules
169 Str mGameName; ///< name of the game used in dialogs
170 Str mGameFile; ///< the .game file that describes this game
171 Str mBaseGame; ///< basegame directory
172 Str mEnginePath; ///< path to the engine
173 Str mEngine; ///< engine name
174 Str mMultiplayerEngine; ///< engine name
175 #if defined (__linux__) || defined (__APPLE__)
176 Str mUserPathPrefix; ///< prefix for ~/.q3a ~/.wolf init, only on *nix
178 Str mShaderPath; ///< the path in which to look for shaders
179 Str mShaderlist; ///< shaderlist file
180 float mTextureDefaultScale; ///< default scale (0.5 in q3, 1.0 in q1/q2, 0.25 in JK2 ..)
181 bool mEClassSingleLoad; ///< only load a single eclass definition file
182 bool mNoPatch; ///< this game doesn't support patch technology
183 Str mCaulkShader; ///< the shader to use for caulking
184 bool quake2; ///< set this to true to get quake2
185 bool noMapsInHome; ///< set this if you want to open the engine path/base dir/maps dir for map open/save dialoges */
187 CGameDescription() { mpDoc = NULL; }
189 \todo parse basic info from the node
190 user-friendly name of the game
191 essential parameters (such as the start dir)
193 CGameDescription(xmlDocPtr pDoc, const Str &GameFile);
194 virtual ~CGameDescription() { xmlFreeDoc(mpDoc); }
200 select games, copy editing assets and write out configuration files
203 #define Q3_PACK "Q3Pack"
204 #define URT_PACK "UrTPack"
205 #define UFOAI_PACK "UFOAIPack"
206 #define Q2W_PACK "Q2WPack"
207 #define WARSOW_PACK "WarsowPack"
208 #define NEXUIZ_PACK "NexuizPack"
209 #define Q2_PACK "Q2Pack"
210 #define TREMULOUS_PACK "TremulousPack"
211 #define JA_PACK "JAPack"
212 #define REACTION_PACK "ReactionPack"
214 class CGameInstall : public Dialog {
221 static void OnBtnBrowseEngine( GtkWidget *widget, gpointer data );
222 static void OnGameSelectChanged( GtkWidget *widget, gpointer data );
245 // maps from m_nComboSelect to the games
246 int m_availGames[GAME_COUNT];
250 standalone dialog for games selection, and more generally global settings
252 class CGameDialog : public Dialog
254 GtkWidget *mFrame; ///< this is built on-demand first time it's used
255 GtkWidget *mTopBox; ///< top level box used to store the dialog frame, must unhook after modal use
257 GtkComboBox *mGameCombo; // combo box holds the selection of available game
262 CXMLPropertyBag mGlobalPrefs;
266 run from a network share
267 this one is not being saved out in prefs, since we need to know before we load prefs
268 we use a dummy file NETRUN_FILENAME as flag
269 all done with static stuff
271 static bool m_bNetRun;
274 bool m_bDoGameInstall;
276 CGameInstall mGameInstall;
280 int m_nComboSelect; ///< intermediate int value for combo in dialog box
285 those settings are saved in the global prefs file
286 I'm too lazy to wrap behind protected access, not sure this needs to be public
287 NOTE: those are preference settings. if you change them it is likely that you would
288 have to restart the editor for them to take effect
292 what game has been selected
293 this is the name of the .game file
297 auto-load the game on startup
298 this is linked to auto-load checkbox
300 bool m_bAutoLoadGame;
302 log console to radiant.log
303 m_bForceLogConsole is an obscure forced latching situation
306 bool m_bForceLogConsole;
310 points somewhere in mGames, set once at startup
312 CGameDescription *m_pCurrentGameDescription;
315 the list of game descriptions we scanned from the game/ dir
317 list<CGameDescription *> mGames;
321 m_pCurrentGameDescription = NULL;
322 m_bLogConsole = false;
323 m_bForceLogConsole = false;
324 m_bDoGameInstall = true; // go through DoModal at least once
327 virtual ~CGameDialog();
329 void AddPacksURL( Str &s );
332 intialize the game dialog, called at CPrefsDlg::Init
333 will scan for games, load prefs, and do game selection dialog if needed
338 reset the global settings by removing the file
343 run the dialog UI for the list of games
348 call out to the game installation dialog
350 void DoGameInstall();
354 this is only called when the dialog is built at startup for main engine select
357 void UpdateData( bool retrieve );
360 construction of the dialog frame
361 this is the part to be re-used in prefs dialog
362 for the standalone dialog, we include this in a modal box
363 for prefs, we hook the frame in the main notebook
364 build the frame on-demand (only once)
366 GtkWidget *GetGlobalFrame();
369 global preferences subsystem
370 XML-based this time, hopefully this will generalize to other prefs
371 LoadPrefs has hardcoded defaults
372 NOTE: it may not be strictly 'CGameDialog' to put the global prefs here
373 could have named the class differently I guess
376 void LoadPrefs(); ///< load from file into variables
377 void SavePrefs(); ///< save pref variables to file
381 read or set netrun (check file)
383 if false, will check if netrun file is present and will set m_bNetRun
384 if true, will create/erase the netrun file depending on m_bNetRun
385 NOTE: this is not backwards, 'retrieve' means 'retrieve from settings dialog' - in terms of UI
387 static void UpdateNetrun(bool retrieve);
389 get current netrun setting
391 static bool GetNetrun();
395 scan for .game files, load them
400 inits g_PrefsDlg.m_global_rc_path
402 void InitGlobalPrefPath();
405 uses m_nComboItem to find the right mGames
407 CGameDescription *GameDescriptionForComboItem();
410 callback for the game install button
412 static void SInstallCallback( GtkWidget *widget, gpointer data );
414 void UpdateGameCombo();
421 window_position_t position;
423 window_position_t posEntityWnd;
424 window_position_t posMapInfoWnd;
425 window_position_t posCamWnd;
426 window_position_t posZWnd;
427 window_position_t posXYWnd;
428 window_position_t posXZWnd;
429 window_position_t posYZWnd;
430 window_position_t posPatchWnd;
431 window_position_t posSurfaceWnd;
432 window_position_t posEntityInfoWnd;
443 class PrefsDlg : public Dialog
450 CXMLPropertyBag mLocalPrefs;
452 // will enable/disable stuff according to the situation
453 void DoSensitivity();
454 void PreModal() { DoSensitivity(); }
456 // enable/disable custom editor entry
457 void DoEditorSensitivity();
460 this holds global level preferences
462 CGameDialog mGamesDialog;
464 // warning about old project files
466 list<CGameDescription *> mGames;
469 // last light intensity used in the CLightPrompt dialog, stored in registry
470 int m_iLastLightIntensity;
471 // these mirror what goes in the combo box
472 // see PrefDlg::m_nShader, tells wether to load NONE / COMMON or ALL shaders at parsing stage
473 enum {SHADER_NONE = 0, SHADER_COMMON, SHADER_ALL};
475 // Gef: updated preferences dialog
476 /*! Preference notebook page numbers */
477 enum {PTAB_FRONT = 0, PTAB_GAME_SETTINGS, PTAB_2D, PTAB_CAMERA, PTAB_TEXTURE, PTAB_LAYOUT, PTAB_MOUSE,
478 PTAB_EDITING, PTAB_STARTUP, PTAB_PATHS, PTAB_BRUSH, PTAB_MISC, PTAB_BSPMONITOR} pref_tabs;
482 void UpdateTextureCompression();
485 void UpdateATIHack();
490 void LoadTexdefPref(texdef_t* pTexdef, char* pName);
495 g_string_free (m_rc_path, true );
496 g_string_free (m_inipath, true );
500 path for global settings
502 linux: ~/.radiant/<version>/
504 GString *m_global_rc_path;
507 path to per-game settings
508 used for various game dependant storage
509 win32: g_strGameToolsPath
510 linux: ~/.radiant/<version>/<gamename>/
515 holds per-game settings
516 m_rc_path+"local.pref"
517 \todo FIXME at some point this should become XML property bag code too
521 // initialize the above paths
525 // DEPRECATED: use engine path from the current game description instead
526 // path to the top-level installation
528 // name of executable
531 // we use this Str to store the full path to the engine: m_strEnginePath + m_strEngine
532 // it's not stored in the registry or anything, just ued for display in prefs
533 Str m_strPrefsDlgEngine;
538 MainFrame::EViewStyle m_nView;
541 // path to the project loaded at startup
542 // if g_PrefsDlg can't find the information in the ini file
543 // it will try to guess and eventually ask the user
544 Str m_strLastProject;
546 version of last loaded project file
547 says -1 if there's no version loaded
548 if it's a manually constructed project file, will be 0
549 otherwise the actual 'version' epair
551 int m_nLastProjectVer;
558 bool m_bTextureWindow;
563 int m_nCamDragMultiSelect;
564 bool m_bCamDragMultiSelect;
566 bool m_bCamFreeLookStrafe;
567 bool m_bCamInverseMouse;
569 bool m_bNewLightDraw;
580 bool m_bDetachableMenus;
581 bool m_bPatchToolbar;
583 bool m_bPluginToolbar;
585 //++timo this is most likely broken, I don't know what it's supposed to do
590 bool m_bTextureScrollbar;
591 bool m_bDisplayLists;
592 bool m_bAntialiasedPointsAndLines; // Fishman - Add antialiazed points and lines support. 09/03/00
603 bool m_bCubicClipping;
605 bool m_bSelectCurves;
606 bool m_bSelectModels;
607 int m_nEntityShowState;
609 bool m_bNormalizeColors;
611 bool m_bSelectWholeEntities;
612 int m_nTextureQuality;
614 bool m_bTexturesShaderlistOnly;
616 float m_fDefTextureScale;
618 bool m_bLatchedFloatingZ;
619 // Gef: Kyro GL_POINT workaround
620 bool m_bGlPtWorkaround;
622 // how many menus in the texture thing before we split?
623 int m_nTextureMenuSplit;
625 // watch the BSP process through network connections
626 // true: trigger the BSP steps one by one and monitor them through the network
627 // false: create a BAT / .sh file and execute it. don't bother monitoring it.
629 // do we stop the compilation process if we come accross a leak?
631 // timeout when beginning a step (in seconds)
632 // if we don't get a connection quick enough we assume something failed and go back to idling
635 // store prefs setting for automatic sleep mode activation
640 // make the texture increments match the grid changes
643 // try to fix the target/targetname conflicts when importing a map (default true)
646 // the increment step we use against the wheel mouse
650 // use the file associations to open files instead of builtin Gtk editor
651 bool m_bUseWin32Editor;
653 // custom shader editor
654 bool m_bUseCustomEditor;
655 Str m_strEditorCommand; // this is the command executed
660 bool m_bStartOnPrimMon;
663 bool m_bPatchBBoxSelect;
665 // RR2DO2: latched data, for settings that require a restart. We don't want to set
666 // these directly in case users set them under preferences and then continue working
668 MainFrame::EViewStyle m_nLatchedView;
670 Str m_strMRUFiles[4];
672 windowPosInfo_t mWindowInfo;
674 bool m_bLatchedDetachableMenus;
675 bool m_bLatchedPatchToolbar;
676 bool m_bLatchedWideToolbar;
677 bool m_bLatchedPluginToolbar;
678 int m_nLatchedShader;
679 int m_nLatchedTextureQuality;
682 // texture compression format
683 int m_nTextureCompressionFormat;
685 int m_nLightRadiuses;
687 bool m_bQ3Map2Texturing;
693 void UpdateData (bool retrieve);
695 /*! Utility function for swapping notebook pages for tree list selections */
696 void showPrefPage(int prefpage);
699 /*! Scan for game description files and build a list */
704 void PostModal (int code);
707 #endif // _PREFERENCES_H_