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(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(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(char *name, Str *pV, char *V);
114 void GetPref(char *name, int *pV, int V);
115 void GetPref(char *name, bool *pV, bool V);
116 void GetPref(char *name, float *pV, float V);
117 void GetPref(char *name, float *pV, float* V);
118 void GetPref(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 #if defined (__linux__) || defined (__APPLE__)
175 Str mUserPathPrefix; ///< prefix for ~/.q3a ~/.wolf init, only on *nix
177 Str mShaderPath; ///< the path in which to look for shaders
178 Str mShaderlist; ///< shaderlist file
179 float mTextureDefaultScale; ///< default scale (0.5 in q3, 1.0 in q1/q2, 0.25 in JK2 ..)
180 bool mEClassSingleLoad; ///< only load a single eclass definition file
181 bool mNoPatch; ///< this game doesn't support patch technology
182 Str mCaulkShader; ///< the shader to use for caulking
184 CGameDescription() { mpDoc = NULL; }
186 \todo parse basic info from the node
187 user-friendly name of the game
188 essential parameters (such as the start dir)
190 CGameDescription(xmlDocPtr pDoc, const Str &GameFile);
191 virtual ~CGameDescription() { xmlFreeDoc(mpDoc); }
197 select games, copy editing assets and write out configuration files
199 class CGameInstall : public Dialog {
218 standalone dialog for games selection, and more generally global settings
220 class CGameDialog : public Dialog
222 GtkWidget *mFrame; ///< this is built on-demand first time it's used
223 GtkWidget *mTopBox; ///< top level box used to store the dialog frame, must unhook after modal use
229 CXMLPropertyBag mGlobalPrefs;
233 run from a network share
234 this one is not being saved out in prefs, since we need to know before we load prefs
235 we use a dummy file NETRUN_FILENAME as flag
236 all done with static stuff
238 static bool m_bNetRun;
241 bool m_bDoGameInstall;
243 CGameInstall mGameInstall;
247 int m_nComboSelect; ///< intermediate int value for combo in dialog box
252 those settings are saved in the global prefs file
253 I'm too lazy to wrap behind protected access, not sure this needs to be public
254 NOTE: those are preference settings. if you change them it is likely that you would
255 have to restart the editor for them to take effect
259 what game has been selected
260 this is the name of the .game file
264 auto-load the game on startup
265 this is linked to auto-load checkbox
267 bool m_bAutoLoadGame;
269 log console to radiant.log
270 m_bForceLogConsole is an obscure forced latching situation
273 bool m_bForceLogConsole;
277 points somewhere in mGames, set once at startup
279 CGameDescription *m_pCurrentGameDescription;
282 the list of game descriptions we scanned from the game/ dir
284 list<CGameDescription *> mGames;
288 m_pCurrentGameDescription = NULL;
289 m_bLogConsole = false;
290 m_bForceLogConsole = false;
291 m_bDoGameInstall = true; // go through DoModal at least once
293 virtual ~CGameDialog();
295 void AddPacksURL( Str &s );
298 intialize the game dialog, called at CPrefsDlg::Init
299 will scan for games, load prefs, and do game selection dialog if needed
304 reset the global settings by removing the file
309 run the dialog UI for the list of games
314 call out to the game installation dialog
316 void DoGameInstall();
320 this is only called when the dialog is built at startup for main engine select
323 void UpdateData( bool retrieve );
326 construction of the dialog frame
327 this is the part to be re-used in prefs dialog
328 for the standalone dialog, we include this in a modal box
329 for prefs, we hook the frame in the main notebook
330 build the frame on-demand (only once)
332 GtkWidget *GetGlobalFrame();
335 global preferences subsystem
336 XML-based this time, hopefully this will generalize to other prefs
337 LoadPrefs has hardcoded defaults
338 NOTE: it may not be strictly 'CGameDialog' to put the global prefs here
339 could have named the class differently I guess
342 void LoadPrefs(); ///< load from file into variables
343 void SavePrefs(); ///< save pref variables to file
347 read or set netrun (check file)
349 if false, will check if netrun file is present and will set m_bNetRun
350 if true, will create/erase the netrun file depending on m_bNetRun
351 NOTE: this is not backwards, 'retrieve' means 'retrieve from settings dialog' - in terms of UI
353 static void UpdateNetrun(bool retrieve);
355 get current netrun setting
357 static bool GetNetrun();
361 scan for .game files, load them
366 inits g_PrefsDlg.m_global_rc_path
368 void InitGlobalPrefPath();
371 uses m_nComboItem to find the right mGames
373 CGameDescription *GameDescriptionForComboItem();
376 callback for the game install button
378 static void SInstallCallback( GtkWidget *widget, gpointer data );
385 window_position_t position;
387 window_position_t posEntityWnd;
388 window_position_t posMapInfoWnd;
389 window_position_t posCamWnd;
390 window_position_t posZWnd;
391 window_position_t posXYWnd;
392 window_position_t posXZWnd;
393 window_position_t posYZWnd;
394 window_position_t posPatchWnd;
395 window_position_t posSurfaceWnd;
396 window_position_t posEntityInfoWnd;
407 class PrefsDlg : public Dialog
414 CXMLPropertyBag mLocalPrefs;
416 // will enable/disable stuff according to the situation
417 void DoSensitivity();
418 void PreModal() { DoSensitivity(); }
420 // enable/disable custom editor entry
421 void DoEditorSensitivity();
424 this holds global level preferences
426 CGameDialog mGamesDialog;
428 // warning about old project files
430 list<CGameDescription *> mGames;
433 // last light intensity used in the CLightPrompt dialog, stored in registry
434 int m_iLastLightIntensity;
435 // these mirror what goes in the combo box
436 // see PrefDlg::m_nShader, tells wether to load NONE / COMMON or ALL shaders at parsing stage
437 enum {SHADER_NONE = 0, SHADER_COMMON, SHADER_ALL};
439 // Gef: updated preferences dialog
440 /*! Preference notebook page numbers */
441 enum {PTAB_FRONT = 0, PTAB_GAME_SETTINGS, PTAB_2D, PTAB_CAMERA, PTAB_TEXTURE, PTAB_LAYOUT, PTAB_MOUSE,
442 PTAB_EDITING, PTAB_STARTUP, PTAB_PATHS, PTAB_MISC, PTAB_BSPMONITOR} pref_tabs;
446 void UpdateTextureCompression();
449 void UpdateATIHack();
454 void LoadTexdefPref(texdef_t* pTexdef, char* pName);
459 g_string_free (m_rc_path, true );
460 g_string_free (m_inipath, true );
464 path for global settings
466 linux: ~/.radiant/<version>/
468 GString *m_global_rc_path;
471 path to per-game settings
472 used for various game dependant storage
473 win32: g_strGameToolsPath
474 linux: ~/.radiant/<version>/<gamename>/
479 holds per-game settings
480 m_rc_path+"local.pref"
481 \todo FIXME at some point this should become XML property bag code too
485 // initialize the above paths
489 // DEPRECATED: use engine path from the current game description instead
490 // path to the top-level installation
492 // name of executable
495 // we use this Str to store the full path to the engine: m_strEnginePath + m_strEngine
496 // it's not stored in the registry or anything, just ued for display in prefs
497 Str m_strPrefsDlgEngine;
502 MainFrame::EViewStyle m_nView;
505 // path to the project loaded at startup
506 // if g_PrefsDlg can't find the information in the ini file
507 // it will try to guess and eventually ask the user
508 Str m_strLastProject;
510 version of last loaded project file
511 says -1 if there's no version loaded
512 if it's a manually constructed project file, will be 0
513 otherwise the actual 'version' epair
515 int m_nLastProjectVer;
522 bool m_bTextureWindow;
527 int m_nCamDragMultiSelect;
528 bool m_bCamDragMultiSelect;
530 bool m_bCamFreeLookStrafe;
531 bool m_bCamInverseMouse;
533 bool m_bNewLightDraw;
544 bool m_bDetachableMenus;
545 bool m_bPatchToolbar;
547 bool m_bPluginToolbar;
549 //++timo this is most likely broken, I don't know what it's supposed to do
553 bool m_bTextureScrollbar;
554 bool m_bDisplayLists;
555 bool m_bAntialiasedPointsAndLines; // Fishman - Add antialiazed points and lines support. 09/03/00
566 bool m_bCubicClipping;
568 bool m_bSelectCurves;
569 bool m_bSelectModels;
570 int m_nEntityShowState;
572 bool m_bNormalizeColors;
574 bool m_bSelectWholeEntities;
575 int m_nTextureQuality;
577 bool m_bTexturesShaderlistOnly;
580 bool m_bLatchedFloatingZ;
581 // Gef: Kyro GL_POINT workaround
582 bool m_bGlPtWorkaround;
584 // how many menus in the texture thing before we split?
585 int m_nTextureMenuSplit;
587 // watch the BSP process through network connections
588 // true: trigger the BSP steps one by one and monitor them through the network
589 // false: create a BAT / .sh file and execute it. don't bother monitoring it.
591 // do we stop the compilation process if we come accross a leak?
593 // timeout when beginning a step (in seconds)
594 // if we don't get a connection quick enough we assume something failed and go back to idling
597 // store prefs setting for automatic sleep mode activation
602 // make the texture increments match the grid changes
605 // try to fix the target/targetname conflicts when importing a map (default true)
608 // the increment step we use against the wheel mouse
612 // use the file associations to open files instead of builtin Gtk editor
613 bool m_bUseWin32Editor;
615 // custom shader editor
616 bool m_bUseCustomEditor;
617 Str m_strEditorCommand; // this is the command executed
622 bool m_bStartOnPrimMon;
625 bool m_bPatchBBoxSelect;
627 // RR2DO2: latched data, for settings that require a restart. We don't want to set
628 // these directly in case users set them under preferences and then continue working
630 MainFrame::EViewStyle m_nLatchedView;
632 Str m_strMRUFiles[4];
634 windowPosInfo_t mWindowInfo;
636 bool m_bLatchedDetachableMenus;
637 bool m_bLatchedPatchToolbar;
638 bool m_bLatchedWideToolbar;
639 bool m_bLatchedPluginToolbar;
640 int m_nLatchedShader;
641 int m_nLatchedTextureQuality;
644 // texture compression format
645 int m_nTextureCompressionFormat;
647 int m_nLightRadiuses;
649 bool m_bQ3Map2Texturing;
655 void UpdateData (bool retrieve);
657 /*! Utility function for swapping notebook pages for tree list selections */
658 void showPrefPage(int prefpage);
661 /*! Scan for game description files and build a list */
666 void PostModal (int code);
669 #endif // _PREFERENCES_H_