]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - radiant/preferences.cpp
Backing out r347 and r345. Keeping r346.
[xonotic/netradiant.git] / radiant / preferences.cpp
1 /*
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
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.
11
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.
16
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
20 */
21
22 //
23 // User preferences
24 //
25 // Leonardo Zide (leo@lokigames.com)
26 //
27
28 #include "stdafx.h"
29 #include <glib.h>
30 #include <glib/gi18n.h>
31 #include <assert.h>
32 #if defined (__linux__) || defined (__APPLE__)
33 #include <sys/stat.h>
34 #include <sys/types.h>
35 #include <fcntl.h>
36 #include <unistd.h>
37 #include <dirent.h>
38 #endif
39 #include "missing.h"
40 #include "gtkmisc.h"
41
42 #ifdef _WIN32
43 #include <io.h>
44 #define X_OK 0
45 #include <sys/stat.h>
46 #endif
47
48 #define PREF_SECTION            "Prefs"
49 #define INTERNAL_SECTION        "Internals"
50 #define MOUSE_KEY               "MouseButtons"
51 #define WINDOW_KEY              "QE4StyleWindows"
52 #define LAYOUT_KEY              "WindowLayout"
53 #define RUNQ2_KEY               "RunQuake2Run"
54 #define TLOCK_KEY               "TextureLock"
55 #define RLOCK_KEY               "RotateLock"
56 #define LOADLAST_KEY            "LoadLast"
57 #define LOADLASTMAP_KEY         "LoadLastMap"
58 #define LASTPROJ_KEY            "LastProject"
59 #define LASTPROJVER_KEY         "LastProjectKey"
60 #define LASTMAP_KEY             "LastMap"
61 #define FACE_KEY                "NewFaceGrab"
62 #define BSP_KEY                 "InternalBSP"
63 #define RCLICK_KEY              "NewRightClick"
64 #define VERTEX_KEY              "NewVertex"
65 #define AUTOSAVE_KEY            "Autosave"
66 #define AUTOSAVETIME_KEY        "AutosaveMinutes"
67 #define PAK_KEY                 "UsePAK"
68 #define NEWAPPLY_KEY            "ApplyDismissesSurface"
69 #define HACK_KEY                "Gatewayescapehack"
70 #define TEXTURE_KEY             "NewTextureWindowStuff"
71 #define TINYBRUSH_KEY           "CleanTinyBrushes"
72 #define TINYSIZE_KEY            "CleanTinyBrusheSize"
73 #define SNAPSHOT_KEY            "Snapshots"
74 #define MOVESPEED_KEY           "MoveSpeed"
75 #define ANGLESPEED_KEY          "AngleSpeed"
76 #define SETGAME_KEY             "UseSetGame"
77 #define CAMXYUPDATE_KEY         "CamXYUpdate"
78 #define CAMDRAGMULTISELECT_KEY  "CamDragMultiSelect"
79 #define CAMFREELOOK_KEY         "CamFreeLook"
80 #define CAMINVERSEMOUSE_KEY         "CamInverseMouse"
81 #define CAMDISCRETE_KEY         "CamDiscrete"
82 #define LIGHTDRAW_KEY           "NewLightStyle"
83 #define WHATGAME_KEY            "WhichGame"
84 #define CUBICCLIP_KEY           "CubicClipping"
85 #define CUBICSCALE_KEY          "CubicScale"
86 #define ALTEDGE_KEY             "ALTEdgeDrag"
87 #define FACECOLORS_KEY          "FaceColors"
88 #define SNAPT_KEY               "SnapT"
89 #define XZVIS_KEY               "XZVIS"
90 #define YZVIS_KEY               "YZVIS"
91 #define ZVIS_KEY                "ZVIS"
92 #define SIZEPAINT_KEY           "SizePainting"
93 #define DLLENTITIES_KEY         "DLLEntities"
94 #define DETACHABLEMENUS_KEY     "DetachableMenus"
95 #define PATCHTOOLBAR_KEY        "PatchToolBar"
96 #define WIDETOOLBAR_KEY         "WideToolBar"
97 #define PLUGINTOOLBAR_KEY "PluginToolBar"
98 #define NOCLAMP_KEY             "NoClamp"
99 #define SNAP_KEY                "Snap"
100 #define PREFAB_KEY              "PrefabPath"
101 #define USERINI_KEY             "UserINIPath"
102 #define ROTATION_KEY            "Rotation"
103 #define BUGGYICD_KEY            "BuggyICD"
104 #define CHASEMOUSE_KEY          "ChaseMouse"
105 #define ENTITYSHOW_KEY          "EntityShow"
106 #define TEXTURESCALE_KEY        "TextureScale"
107 #define TEXTURESCROLLBAR_KEY    "TextureScrollbar"
108 #define DISPLAYLISTS_KEY        "UseDisplayLists"
109 #define ANTIALIASEDLINES_KEY    "UseAntialiasedPointsAndLines" // Fishman - Add antialiazed points and lines support. 09/03/00
110 #define NORMALIZECOLORS_KEY     "NormalizeColors"
111 #define SHADERS_KEY             "UseShaders"
112 #define SWITCHCLIP_KEY          "SwitchClipKey"
113 #define SELWHOLEENTS_KEY                    "SelectWholeEntitiesKey"
114 #define TEXTURESUBSET_KEY                 "UseTextureSubsetLoading"
115 #define TEXTUREQUALITY_KEY          "TextureQuality"
116 #define SHOWSHADERS_KEY               "ShowShaders"
117 #define SHADERTEST_KEY          "ShaderTest"
118 #define GLLIGHTING_KEY          "UseGLLighting"
119 #define LOADSHADERS_KEY         "LoadShaders"
120 #define NOSTIPPLE_KEY           "NoStipple"
121 #define UNDOLEVELS_KEY          "UndoLevels"
122 #define VERTEXMODE_KEY          "VertexSplit"
123 #define ENGINEPATH_KEY          "EnginePath"
124 #define ENGINE_KEY              "Engine"
125 #define LOGCONSOLE_KEY          "LogConsole"
126 #define SELECTCURVES_KEY        "SelectCurves"
127 #define SELECTMODELS_KEY        "SelectModels"
128 #define SHADERLISTONLY_KEY      "ShowShaderlistOnly"
129 #define WATCHBSP_KEY            "WatchBSP"
130 #define LEAKSTOP_KEY            "LeakStop"
131 #define DOSLEEP_KEY             "SleepMode"
132 #define SUBDIVISIONS_KEY        "Subdivisions"
133 #define CLIPCAULK_KEY           "ClipCaulk"
134 #define PATCHSHOWBOUNDS_KEY     "PatchShowBounds"
135 #define NATIVEGUI_KEY           "NativeGUI"
136 #define STARTONPRIMMON_KEY      "StartOnPrimMon"
137 #define NOSYSMENUPOPUPS_KEY     "NoSysMenuPopups"
138 #define SNAPTTOGRID_KEY         "SnapTToGrid"
139 #define FLOATINGZ_KEY           "FloatingZ"
140 #define TARGETFIX_KEY           "TargetFix"
141 #define GLPOINTWORKAROUND_KEY   "GlPointWorkaround"             // Gef: Workaround for broken Kyro * gl driver 25-aug-2001
142 #define WHEELINC_KEY            "WheelMouseInc"
143 #define PATCHBBOXSEL_KEY        "PatchBBoxSel"
144 #define LASTLIGHTINTENSITY_KEY  "LastLightIntensity"
145 #define CUSTOMSHADEREDITOR_KEY        "UseCustomShaderEditor"
146 #define CUSTOMSHADEREDITORCOMMAND_KEY "CustomShaderEditorCommand"
147 #define TEXTURECOMPRESSIONFORMAT_KEY "TextureCompressionFormat"
148 #define LIGHTRADIUS_KEY "LightRadiuses"
149 #define Q3MAP2TEX_KEY "Q3Map2Tex"
150 #define ATIHACK_KEY "ATIHack"
151
152 // window stuff
153 #define ENTITYSPLIT1_KEY  "EntitySplit1"
154 #define ENTITYSPLIT2_KEY  "EntitySplit2"
155 #define POSITIONX_KEY     "PositionX"
156 #define POSITIONY_KEY     "PositionY"
157 #define ENTITYWND_KEY     "EntityWnd"
158 #define MAPINFOWND_KEY    "MapInfoDlg"
159 #define CAMWND_KEY        "CamWnd"
160 #define ZWND_KEY          "ZWnd"
161 #define XYWND_KEY         "XYWnd"
162 #define XZWND_KEY         "XZWnd"
163 #define YZWND_KEY         "YZWnd"
164 #define PATCHWND_KEY      "PatchWnd"
165 #define SURFACEWND_KEY    "SurfaceWnd"
166 #define ENTITYINFOWND_KEY "EntityInfoDlg"
167 #define WIDTH_KEY         "Width"
168 #define HEIGHT_KEY        "Height"
169 #define ZWIDTH_KEY        "ZWidth"
170 #define XYHEIGHT_KEY      "XYHeight"
171 #define XYWIDTH_KEY       "XYWidth"
172 #define CAMWIDTH_KEY      "CamWidth"
173 #define CAMHEIGHT_KEY     "CamHeight"
174 #define ZFLOATWIDTH_KEY   "ZWidthFloating"
175 #define STATE_KEY         "State"
176
177 // menu stuff
178 #define COUNT_KEY         "Count"
179 #define FILE_KEY          "File"
180
181 //saved info
182 #define SI_TEXMENU_KEY          "SI_TexMenu"
183 #define SI_GAMMA_KEY            "SI_Gamma"
184 #define SI_COLORS_KEY           "SI_Colors"
185 #define SI_EXCLUDE_KEY          "SI_Exclude"
186 #define SI_INCLUDE_KEY          "SI_Include"
187 #define SI_SURFACE_TEXDEF_KEY   "SI_SurfaceTexdef"
188 #define SI_PATCH_TEXDEF_KEY     "SI_PatchTexdef"
189 #define SI_AXISCOLORS_KEY       "SI_AxisColors"
190 #define SI_SHOWNAMES_KEY        "SI_ShowNames"
191 #define SI_SHOWCOORDS_KEY       "SI_ShowCoords"
192 #define SI_SHOWANGLES_KEY       "SI_ShowAngles"
193 #define SI_SHOWOUTLINES_KEY     "SI_ShowOutlines"
194 #define SI_SHOWAXIS_KEY         "SI_ShowAxis"
195 #define SI_NOSELOUTLINES_KEY    "SI_NoSelectedOutlines"
196 #define SI_OUTLINESTYLE_KEY "SI_OutLineStyle"
197
198 //for texdefs
199 #define TD_SCALE1_KEY           "_Scale1"
200 #define TD_SCALE2_KEY           "_Scale2"
201 #define TD_SHIFT1_KEY           "_Shift1"
202 #define TD_SHIFT2_KEY           "_Shift2"
203 #define TD_ROTATE_KEY           "_Rotate"
204
205 #define MOUSE_DEF 1
206 #define WINDOW_DEF 0
207 #define RUNQ2_DEF 0
208 #define WATCHBSP_DEF 1
209 #define TLOCK_DEF 1
210 #define LOADLAST_DEF 1
211 #define RUN_DEF 0
212 #define SUBDIVISIONS_DEF 4
213
214 void WindowPosition_Parse(window_position_t& m_value, const CString& value)
215 {
216   if(sscanf(value.GetBuffer(), "%d %d %d %d", &m_value.x, &m_value.y, &m_value.w, &m_value.h) != 4)
217     m_value.x = m_value.y = m_value.w = m_value.h = -1;
218 }
219
220 void WindowPosition_Write(const window_position_t& m_value, CString& value)
221 {
222   char buffer[64];
223   sprintf(buffer, "%d %d %d %d", m_value.x, m_value.y, m_value.w, m_value.h);
224   value = buffer;
225 }
226
227
228 CXMLPropertyBag::CXMLPropertyBag() {
229   mStrFilename = "";
230   mpDoc = NULL;
231   mbEmpty = false;
232 }
233
234 // generic preference functions
235
236 void CXMLPropertyBag::PushAssignment(const char *name, PrefTypes_t type, void *pV)
237 {
238   list<CPrefAssignment>::iterator iAssign;
239   for(iAssign=mPrefAssignments.begin(); iAssign!=mPrefAssignments.end(); iAssign++)
240   {
241     if ((*iAssign).mName == name)
242     {
243       // we have it already, check anyway
244       if (pV != (*iAssign).mVal)
245       {
246         Sys_FPrintf(SYS_ERR, "PushAssignment, '%s' has different mVal\n", name);
247         return;
248       }
249     }
250   }
251   // ok, it's not in our list yet
252   mPrefAssignments.push_front(CPrefAssignment(name, type, pV));
253 }
254
255 xmlNodePtr CXMLPropertyBag::EpairForName(const char *name)
256 {
257   xmlNodePtr ret = NULL;
258
259   xmlNodePtr pNode = mpDocNode->children;
260   while (pNode != NULL)
261   {
262     if(pNode->type == XML_ELEMENT_NODE)
263     {
264       xmlAttrPtr tmp_attr_ptr = xmlHasProp(pNode, (xmlChar *)"name");
265       if (tmp_attr_ptr != NULL && !strcmp(name, (char *)tmp_attr_ptr->children->content))
266       {
267         if ( ret ) {
268           Sys_FPrintf( SYS_WRN, "WARNING: dupe property in CXMLPropertyBag::EpairForName '%s'\n", name );
269         } else {
270           ret = pNode;
271         }
272       }
273     }
274     pNode = pNode->next;
275   }
276   return ret;
277 }
278
279 void CXMLPropertyBag::GetPref(const char *name, Str *pV, const char *V)
280 {
281   xmlNodePtr pNode = EpairForName( name );
282   if ( pNode )
283   {
284     if ( pNode->children && pNode->children->content ) {
285       *pV = pNode->children->content;
286     } else {
287       // means the pref exists, and that the value is ""
288       *pV = "";
289     }
290   }
291   else
292   {
293     pNode = xmlNewChild(mpDocNode, NULL, (xmlChar *)"epair", (xmlChar *)V);
294     xmlSetProp(pNode, (xmlChar *)"name", (xmlChar *)name);
295   }
296   // push the pref assignment if needed
297   PushAssignment(name, PREF_STR, pV);
298 }
299
300 void CXMLPropertyBag::GetPref(const char *name, int *pV, int V)
301 {
302   xmlNodePtr pNode;
303   if ((pNode = EpairForName(name)) && pNode->children && pNode->children->content)
304   {
305     *pV = atoi((char *)pNode->children->content);
306   }
307   else
308   {
309     char s[10];
310     sprintf(s, "%d", V);
311     pNode = xmlNewChild(mpDocNode, NULL, (xmlChar *)"epair", (xmlChar *)s);
312     xmlSetProp(pNode, (xmlChar *)"name", (xmlChar *)name);
313     *pV=V;
314   }
315   // push the pref assignment if needed
316   PushAssignment(name, PREF_INT, pV);
317 }
318
319 void CXMLPropertyBag::GetPref(const char *name, bool *pV, bool V)
320 {
321   xmlNodePtr pNode;
322   if ((pNode = EpairForName(name)) && pNode->children && pNode->children->content)
323   {
324     if (!strcmp((char *)pNode->children->content, "true"))
325     {
326       *pV = true;
327     }
328     else
329     {
330       *pV = false;
331     }
332   }
333   else
334   {
335     char s[10];
336     V ? strcpy(s, "true") : strcpy(s, "false");
337     pNode = xmlNewChild(mpDocNode, NULL, (xmlChar *)"epair", (xmlChar *)s);
338     xmlSetProp(pNode, (xmlChar *)"name", (xmlChar *)name);
339     *pV=V;
340   }
341   // push the pref assignment
342   PushAssignment(name, PREF_BOOL, pV);
343 }
344
345 void CXMLPropertyBag::GetPref(const char *name, float *pV, float V)
346 {
347   xmlNodePtr pNode;
348   if ((pNode = EpairForName(name)) && pNode->children && pNode->children->content)
349   {
350     *pV = atof((char *)pNode->children->content);
351   }
352   else
353   {
354     char s[10];
355     sprintf(s, "%f", V);
356     pNode = xmlNewChild(mpDocNode, NULL, (xmlChar *)"epair", (xmlChar *)s);
357     xmlSetProp(pNode, (xmlChar *)"name", (xmlChar *)name);
358     *pV=V;
359   }
360   // push the pref assignment if needed
361   PushAssignment(name, PREF_FLOAT, pV);
362 }
363
364 void CXMLPropertyBag::GetPref(const char *name, float* pV, float* V)
365 {
366   xmlNodePtr pNode;
367   if ((pNode = EpairForName(name)) && pNode->children && pNode->children->content)
368   {
369     sscanf((char *)pNode->children->content, "%f %f %f", &pV[0], &pV[1], &pV[2]);
370   }
371   else
372   {
373     char s[128];
374     sprintf(s, "%f %f %f", V[0], V[1], V[2]);
375     pNode = xmlNewChild(mpDocNode, NULL, (xmlChar *)"epair", (xmlChar *)s);
376     xmlSetProp(pNode, (xmlChar *)"name", (xmlChar *)name);
377     pV[0] = V[0];
378     pV[1] = V[1];
379     pV[2] = V[2];
380   }
381   // push the pref assignment if needed
382   PushAssignment(name, PREF_VEC3, pV);
383 }
384
385 void CXMLPropertyBag::GetPref(const char *name, window_position_t* pV, window_position_t V)
386 {
387   xmlNodePtr pNode;
388   if ((pNode = EpairForName(name)) && pNode->children && pNode->children->content)
389   {
390     WindowPosition_Parse(*pV, CString((xmlChar *)pNode->children->content));
391   }
392   else
393   {
394     CString str;
395     WindowPosition_Write(V, str);
396     pNode = xmlNewChild(mpDocNode, NULL, (xmlChar *)"epair", (xmlChar *)str.GetBuffer());
397     xmlSetProp(pNode, (xmlChar *)"name", (xmlChar *)name);
398     *pV = V;
399   }
400   // push the pref assignment if needed
401   PushAssignment(name, PREF_WNDPOS, pV);
402 }
403
404 void CXMLPropertyBag::UpdatePrefTree()
405 {
406   // read the assignments and update the tree
407   list<CPrefAssignment>::iterator iPref;
408   for(iPref = mPrefAssignments.begin(); iPref != mPrefAssignments.end(); iPref++)
409   {
410     CPrefAssignment *pPref = &(*iPref);
411     // look for the node
412     xmlNodePtr pNode;
413     char s[64];
414
415     pNode = EpairForName(pPref->mName.GetBuffer());
416     // we never expect that the node could not be found, because this is supposed to happen
417     // after the tree was built with GetPref calls, never on a blank tree
418     if (!pNode)
419     {
420       Sys_FPrintf(SYS_ERR, "Unexpected EpairForName '%s' not found in UpdatePrefTree\n", pPref->mName.GetBuffer());
421       return;
422     }
423     switch ((*iPref).mType)
424     {
425     case PREF_STR:
426       xmlNodeSetContent(pNode, (const xmlChar *)((Str *)pPref->mVal)->GetBuffer());
427       break;
428     case PREF_INT:
429       sprintf(s, "%d", *(int *)pPref->mVal);
430       xmlNodeSetContent(pNode, (xmlChar *)s);
431       break;
432     case PREF_FLOAT:
433       sprintf(s, "%f", *(float *)pPref->mVal);
434       xmlNodeSetContent(pNode, (xmlChar *)s);
435       break;
436     case PREF_BOOL:
437       *(bool *)pPref->mVal ? strcpy(s, "true") : strcpy(s, "false");
438       xmlNodeSetContent(pNode, (xmlChar *)s);
439       break;
440     case PREF_VEC3:
441       {
442         float* v = (float*)pPref->mVal;
443         sprintf(s, "%f %f %f", v[0], v[1], v[2]);
444         xmlNodeSetContent(pNode, (xmlChar *)s);
445       }
446       break;
447     case PREF_WNDPOS:
448       {
449         CString str;
450         WindowPosition_Write(*(window_position_t*)pPref->mVal, str);
451         xmlNodeSetContent(pNode, (xmlChar*)str.GetBuffer());
452       }
453       break;
454     }
455   }
456 }
457
458 void CXMLPropertyBag::Clear()
459 {
460   if(!InUse())
461     return;
462
463   xmlFreeDoc(mpDoc);
464   mpDoc = NULL;
465   mpDocNode = NULL;
466   mbEmpty = false;
467 }
468
469 void CXMLPropertyBag::ReadXMLFile(const char* pFilename)
470 {
471   mpDoc = xmlParseFile(pFilename);
472
473   // basic checks
474   if (mpDoc)
475   {
476     mpDocNode = mpDoc->children;
477     xmlAttrPtr tmp_attr_ptr = xmlHasProp(mpDocNode, (xmlChar *)"version");
478     if (strcmp((char *)mpDocNode->name, "qpref"))
479     {
480       Sys_FPrintf(SYS_ERR, "Unrecognized node '%s' in '%s'\n", mpDocNode->name, mpDoc->URL);
481       xmlFreeDoc(mpDoc);
482       mpDoc = NULL;
483     }
484     else if (tmp_attr_ptr != NULL && strcmp((char*)tmp_attr_ptr->children->content, "1"))
485     {
486       Sys_FPrintf(SYS_ERR, "Wrong version '%s' in <qpref> node for '%s'\n", (char*)tmp_attr_ptr->children->content, mpDoc->URL);
487       xmlFreeDoc(mpDoc);
488       mpDoc = NULL;
489     }
490     Sys_Printf("Opened XML property file: '%s'\n", pFilename);
491   }
492
493   if (!mpDoc)
494   {
495     mbEmpty = true;
496     // no document, create one
497     mpDoc = xmlNewDoc((xmlChar *)"1.0");
498     mpDocNode = xmlNewDocNode(mpDoc, NULL, (xmlChar *)"qpref", NULL);
499     xmlDocSetRootElement(mpDoc, mpDocNode);
500     xmlSetProp(mpDocNode, (xmlChar *)"version", (xmlChar *)"1");
501     Sys_Printf("XML property file '%s' invalid/not found, creating blank properties tree\n", pFilename);
502   }
503 }
504
505 qboolean CXMLPropertyBag::WriteXMLFile(const char* pFilename)
506 {
507   int res = xmlSaveFormatFile(pFilename, mpDoc, 1);
508
509   if(res == -1)
510     return false;
511
512   Sys_Printf("Wrote XML property file '%s'\n", pFilename);
513   return true;
514 }
515
516 // =============================================================================
517 // Widget callbacks for PrefsDlg
518
519 #if !defined(WIN32)
520 // browse for custom editor executable
521 static void OnBtnBrowseEditor (GtkWidget *widget, gpointer data)
522 {
523   PrefsDlg *dlg = (PrefsDlg*)data;
524
525   const char *filename = file_dialog(g_PrefsDlg.GetWidget(), TRUE, _("Executable for Custom Editor"));
526
527   if(filename != NULL)
528   {
529     dlg->m_strEditorCommand = filename;
530     dlg->UpdateData(FALSE);
531   }
532 }
533 #endif
534
535 static void OnBtnBrowseprefab (GtkWidget *widget, gpointer data)
536 {
537   PrefsDlg *dlg = (PrefsDlg*)data;
538   char *path = dlg->m_strPrefabPath;
539   if (strlen (path) == 0)
540     path = g_strGameToolsPath;
541   char *dir = dir_dialog (g_PrefsDlg.GetWidget (), _("Set prefab path"), path);
542   dlg->UpdateData(TRUE);
543
544   if (dir != NULL)
545   {
546     CString strPath;
547     strPath = dir;
548     AddSlash(strPath);
549     dlg->m_strPrefabPath = strPath;
550     dlg->UpdateData(FALSE);
551     free (dir);
552   }
553 }
554
555 static void OnBtnBrowseuserini (GtkWidget *widget, gpointer data)
556 {
557   PrefsDlg *dlg = (PrefsDlg*)data;
558   char *path = dlg->m_strUserPath;
559   if (strlen (path) == 0)
560     path = g_strGameToolsPath;
561   // TODO: INI filter?
562   const char *filename = file_dialog (g_PrefsDlg.GetWidget(), TRUE, _("Find INI file"), path);
563
564   if (filename != NULL)
565   {
566     dlg->UpdateData(TRUE);
567     dlg->m_strUserPath = filename;
568     dlg->UpdateData(FALSE);
569   }
570 }
571
572 static void OnButtonClean (GtkWidget *widget, gpointer data)
573 {
574   // make sure this is what the user wants
575   if (gtk_MessageBox (g_PrefsDlg.GetWidget (), _("This will close Radiant and clean the corresponding registry entries.\n"
576                   "Next time you start Radiant it will be good as new. Do you wish to continue?"),
577                   _("Reset Registry"), MB_YESNO) == IDYES)
578   {
579     PrefsDlg *dlg = (PrefsDlg*)data;
580     dlg->EndModal (IDCANCEL);
581
582     g_qeglobals.disable_ini = true;
583     remove (dlg->m_inipath->str);
584     char buf[PATH_MAX];
585     sprintf(buf, "%sSavedInfo.bin", dlg->m_rc_path->str);
586     remove(buf);
587     HandleCommand (NULL, GINT_TO_POINTER (ID_FILE_EXIT));
588     _exit (0);
589   }
590 }
591
592 // =============================================================================
593 // PrefsDlg class
594
595 // IMPORTANT NOTE: the values here don't matter very much
596 // the actual intialization if you start with an empty .ini is done when loading the prefs for the first time
597 // profile_load_int takes an argument to use if the value is not found
598 PrefsDlg::PrefsDlg ()
599 {
600   m_bWarn = TRUE;
601   m_nMouse = 1;
602   m_nView = MainFrame::eRegular;
603   m_bLoadLast = FALSE;
604   m_bInternalBSP = FALSE;
605   m_bRightClick = FALSE;
606   m_bSetGame = FALSE;
607   m_bAutoSave = TRUE;
608   m_nAutoSave = 5;
609   m_bLoadLastMap = FALSE;
610   m_bTextureWindow = FALSE;
611   m_bSnapShots = FALSE;
612   m_fTinySize = 0.5;
613   m_bCleanTiny = FALSE;
614   m_bCamXYUpdate = TRUE;
615   m_bCamDragMultiSelect = FALSE;
616   m_bCamFreeLook = TRUE;
617   m_bCamFreeLookStrafe = FALSE;
618   m_bCamInverseMouse = FALSE;
619   m_bCamDiscrete = TRUE;
620   m_bNewLightDraw = FALSE;
621   m_strPrefabPath = "";
622   m_nWhatGame = 0;
623   m_bALTEdge = FALSE;
624   m_bFaceColors = FALSE;
625   m_bXZVis = FALSE;
626   m_bYZVis = FALSE;
627   m_bZVis = FALSE;
628   m_bSizePaint = FALSE;
629   m_bDLLEntities = FALSE;
630 #ifdef _WIN32
631   m_bDetachableMenus = FALSE;   // Most win32 users will find detachable menus annoying
632 #else
633   m_bDetachableMenus = TRUE;    // Linux/Apple users are used to them...
634 #endif
635   m_bPatchToolbar = TRUE;
636   m_bWideToolbar = TRUE;
637   m_bPluginToolbar = TRUE;
638   m_bNoClamp = FALSE;
639   m_bSnap = TRUE;
640   m_strUserPath = "";
641   m_nRotation = 0;
642   m_bChaseMouse = FALSE;
643   m_bTextureScrollbar = TRUE;
644   m_bDisplayLists = TRUE;
645   m_bAntialiasedPointsAndLines = FALSE; // Fishman - Add antialiazed points and lines support. 09/03/00
646   m_bShowShaders = FALSE;
647   m_nShader = -1;
648   m_bNoStipple = FALSE;
649   m_bVertexSplit = FALSE;
650   m_bSelectCurves = TRUE;
651   m_bSelectModels = TRUE;
652   m_nEntityShowState = ENTITY_SKINNED_BOXED;
653   m_nTextureScale = 2;
654   m_bSwitchClip = FALSE;
655   m_bSelectWholeEntities = TRUE;
656   m_nTextureQuality = 3;
657   m_bShowShaders = TRUE;
658   m_bGLLighting = FALSE;
659   m_nShader = 0;
660   m_nUndoLevels = 30;
661   m_bTexturesShaderlistOnly = FALSE;
662   // paths to ini files
663   m_rc_path = NULL;
664   m_inipath = NULL;
665   m_bWatchBSP = TRUE;
666   m_bLeakStop = TRUE;
667   m_iTimeout = 15;
668   m_bRunQuake = TRUE;
669   m_bDoSleep = FALSE;
670   m_nSubdivisions = 4;
671   // not prefs
672   m_bFloatingZ = FALSE;
673   m_bGlPtWorkaround = FALSE;    // Gef: Kyro/GL_POINTS workaround 25-aug-2001
674 #ifdef _WIN32
675   m_bNativeGUI = FALSE;
676   m_bStartOnPrimMon = FALSE;
677 #endif
678   m_global_rc_path = NULL;
679 #ifdef _WIN32
680   m_bUseWin32Editor = TRUE;
681 #else
682   // custom shader editor options
683   m_bUseCustomEditor = FALSE;
684   m_strEditorCommand = "";
685 #endif
686   m_nLightRadiuses = 1;
687   m_bQ3Map2Texturing = TRUE;
688 #ifdef ATIHACK_812
689         m_bGlATIHack = FALSE;
690 #endif
691 }
692
693 /*!
694 =========================================================
695 Games selection dialog
696 =========================================================
697 */
698
699 #if defined(WIN32)
700 #define TOOLS_ATTRIBUTE "gametools_win32"
701 #define ENGINE_ATTRIBUTE "engine_win32"
702 #define ENGINEPATH_ATTRIBUTE "enginepath_win32"
703 #define MP_ENGINE_ATTRIBUTE "mp_engine_win32"
704 #elif defined(__linux__) || defined (__FreeBSD__)
705 #define TOOLS_ATTRIBUTE "gametools_linux"
706 #define ENGINE_ATTRIBUTE "engine_linux"
707 #define ENGINEPATH_ATTRIBUTE "enginepath_linux"
708 #define MP_ENGINE_ATTRIBUTE "mp_engine_linux"
709 #elif defined(__APPLE__)
710 #define TOOLS_ATTRIBUTE "gametools_macos"
711 #define ENGINE_ATTRIBUTE "engine_macos"
712 #define ENGINEPATH_ATTRIBUTE "enginepath_macos"
713 #define MP_ENGINE_ATTRIBUTE "mp_engine_macos"
714 #else
715 #error "unsupported platform"
716 #endif
717
718 CGameDescription::CGameDescription(xmlDocPtr pDoc, const Str &GameFile)
719 {
720   char *p, *prop;
721   mpDoc = pDoc;
722   // read the user-friendly game name
723   xmlNodePtr pNode = mpDoc->children;
724
725   while (strcmp((const char*)pNode->name, "game") && pNode != NULL) pNode=pNode->next;
726   if (!pNode)
727   {
728     ///< \todo add the file name (this node and gametools should all be part of CGameDescription anyway)
729     Error("Didn't find 'game' node in the game description file '%s'\n", pDoc->URL);
730   }
731   // on win32, game tools path can now be specified relative to the exe's cwd
732   prop = (char*)xmlGetProp( pNode, (xmlChar*)TOOLS_ATTRIBUTE);
733   if ( prop == NULL ) {
734         Error( "Didn't find '"TOOLS_ATTRIBUTE"' node in the game description file '%s'\n", pDoc->URL );
735   }
736   {
737         char full[PATH_MAX];
738 #ifdef _WIN32
739         _fullpath( full, prop, PATH_MAX );
740 #else
741     strncpy( full, prop, PATH_MAX );
742 #endif
743     xmlFree( prop );
744     prop = NULL;
745     for ( p = full; *p != '\0'; p++ ) {
746           if ( *p == '\\' ) {
747             *p = '/';
748           }
749           mGameToolsPath = full;
750           if ( p != full && *(p-1) != '/' ) {
751             mGameToolsPath += "/";
752           }
753     }
754   }
755
756   prop = (char*)xmlGetProp(pNode, (xmlChar*)"name");
757   if (prop == NULL)
758   {
759     Sys_FPrintf(SYS_WRN, "Warning, 'name' attribute not found in '%s'\n", pDoc->URL);
760     mGameName = pDoc->URL;
761   }
762   else
763   {
764     mGameName = prop;
765     xmlFree(prop);
766   }
767
768   mGameFile = GameFile;
769
770   prop = (char*)xmlGetProp(pNode, (xmlChar*)"quake2");
771   if (prop == NULL)
772   {
773     // default
774     quake2 = false;
775   }
776   else
777   {
778     quake2 = true;
779     xmlFree(prop);
780   }
781
782   // if this is set, the open maps dialoge will open the engine path not the
783   // home dir for map loading and saving
784   prop = (char*)xmlGetProp(pNode, (xmlChar*)"no_maps_in_home");
785   if (prop == NULL)
786   {
787     // default
788     noMapsInHome = false;
789   }
790   else
791   {
792     noMapsInHome = true;
793     xmlFree(prop);
794   }
795
796   prop = (char*)xmlGetProp(pNode, (xmlChar*)"basegame");
797   if (prop == NULL)
798   {
799     // default
800     mBaseGame = "baseq3";
801   }
802   else
803   {
804     mBaseGame = prop;
805     xmlFree(prop);
806   }
807
808
809         prop = (char*)xmlGetProp(pNode, (const xmlChar*)ENGINE_ATTRIBUTE);
810         if (prop == NULL)
811         {
812 #ifdef _WIN32
813                 mEngine = "quake3.exe";
814 #elif __linux__
815                 mEngine = "quake3";
816 #elif __APPLE__
817                 mEngine = "Quake3.app";
818 #endif
819         }
820         else
821         {
822                 mEngine = prop;
823                 xmlFree(prop);
824         }
825
826         prop = (char*)xmlGetProp(pNode, (const xmlChar*)MP_ENGINE_ATTRIBUTE);
827         if (prop == NULL)
828         {
829 #ifdef _WIN32
830                 mMultiplayerEngine = "quake3.exe";
831 #elif __linux__
832                 mMultiplayerEngine = "quake3";
833 #elif __APPLE__
834                 mMultiplayerEngine = "Quake3.app";
835 #endif
836         }
837         else
838         {
839                 mMultiplayerEngine = prop;
840                 xmlFree(prop);
841         }
842
843         {
844                 // on win32, engine path can now be specified relative to the exe's cwd
845                 prop = (char*)xmlGetProp(pNode, (const xmlChar *)ENGINEPATH_ATTRIBUTE);
846                 if ( prop != NULL ) {
847                         char full[PATH_MAX];
848                 #ifdef _WIN32
849                         _fullpath( full, prop, PATH_MAX );
850                 #else
851                         strncpy( full, prop, PATH_MAX );
852                 #endif
853                         xmlFree( prop );
854                         prop = NULL;
855                         // process seperators
856                         for ( p = full; *p != '\0'; p++ ) {
857                                 if ( *p == '\\' ) {
858                                         *p = '/';
859                                 }
860                         }
861                         mEnginePath = full;
862                         if ( p != full && *(p-1) != '/' ) {
863                                 mEnginePath += "/";
864                         }
865                 }
866                 else
867                 {
868                         // if engine path was not specified in the .game, it implies we can guess it from the gametools path
869                         // on win32, and for most game package, the gametools are installed with the game
870                         char aux_path[PATH_MAX]; // aux
871                         strcpy( aux_path, mGameToolsPath.GetBuffer() );
872                         if ( ( aux_path[ strlen(aux_path)-1 ] == '/' ) || ( aux_path[ strlen(aux_path)-1 ] == '\\' ) ) {
873                                 aux_path[strlen(aux_path)-1] = '\0'; // strip ending '/' if any
874                         }
875                         char up_path[PATH_MAX]; // up one level
876                         ExtractFilePath( aux_path, up_path );
877                         mEnginePath = up_path;
878                 }
879         }
880
881 #if defined (__linux__) || defined (__APPLE__)
882   // *nix specific
883   prop = (char*)xmlGetProp(pNode, (const xmlChar *)"prefix");
884   if(prop != NULL)
885   {
886     mUserPathPrefix = prop;
887     xmlFree(prop);
888   }
889 #endif
890   mShaderPath = xmlGetProp(pNode, (const xmlChar *)"shaderpath");
891   if (!mShaderPath.GetLength())
892   {
893     mShaderPath = "scripts/";
894     mShaderlist = "scripts/shaderlist.txt";
895   }
896   else
897   {
898     AddSlash(mShaderPath);
899     mShaderlist = mShaderPath;
900     mShaderlist += "shaderlist.txt";
901   }
902   xmlChar* default_scale = xmlGetProp(pNode, (const xmlChar *)"default_scale");
903   if (default_scale)
904   {
905     mTextureDefaultScale = atof((const char *)default_scale);
906     xmlFree(default_scale);
907   }
908   else
909     mTextureDefaultScale = 0.5f;
910   xmlChar* eclass_singleload = xmlGetProp(pNode, (const xmlChar*)"eclass_singleload");
911   if (eclass_singleload)
912   {
913     mEClassSingleLoad = true;
914     xmlFree(eclass_singleload);
915   }
916   else
917     mEClassSingleLoad = false;
918   xmlChar* no_patch = xmlGetProp(pNode, (const xmlChar *)"no_patch");
919   if (no_patch)
920   {
921     mNoPatch = true;
922     xmlFree(no_patch);
923   }
924   else
925     mNoPatch = false;
926   xmlChar* caulk_shader = xmlGetProp(pNode, (const xmlChar *)"caulk_shader");
927   if (caulk_shader)
928   {
929     mCaulkShader = caulk_shader;
930     xmlFree(caulk_shader);
931   }
932   else
933     mCaulkShader = "textures/common/caulk";
934 }
935
936 void CGameDescription::Dump()
937 {
938 #ifdef _WIN32
939   if (CGameDialog::GetNetrun())
940     Sys_Printf("Running in network mode, prefs path set to '%s'\n", g_strTempPath.GetBuffer());
941 #endif
942   Sys_Printf("game name            : '%s'\n", mGameName.GetBuffer());
943   Sys_Printf("game file            : '%s'\n", mGameFile.GetBuffer());
944   Sys_Printf("game path            : '%s'\n", mGameToolsPath.GetBuffer());
945   Sys_Printf("base game            : '%s'\n", mBaseGame.GetBuffer());
946   Sys_Printf("engine path          : '%s'\n", mEnginePath.GetBuffer());
947   Sys_Printf("engine               : '%s'\n", mEngine.GetBuffer());
948   Sys_Printf("shaderlist           : '%s'\n", mShaderlist.GetBuffer());
949   Sys_Printf("caulk shader: '%s'\n", mCaulkShader.GetBuffer());
950 #if defined (__linux__) || defined (__APPLE__)
951   Sys_Printf("prefix               : '%s'\n", mUserPathPrefix.GetBuffer());
952 #endif
953   Sys_Printf("default texture scale: %g\n", mTextureDefaultScale);
954   Sys_Printf("single eclass load   : %s\n", mEClassSingleLoad ? "Yes" : "No");
955   Sys_Printf("patches supported    : %s\n", mNoPatch ? "No" : "Yes");
956 }
957
958 CPrefAssignment& CPrefAssignment::operator = (const CPrefAssignment& ass)
959 {
960   if (&ass != this)
961   {
962     mName = ass.mName;
963     mType = ass.mType;
964     mVal = ass.mVal;
965   }
966   return *this;
967 }
968
969 CPrefAssignment::CPrefAssignment(const CPrefAssignment& ass)
970 {
971   *this = ass;
972 }
973
974 void CGameDialog::LoadPrefs()
975 {
976   // if we already have a document loaded, we will free and reload from file
977   if (mGlobalPrefs.InUse())
978   {
979     Sys_Printf("Reloading global prefs from file\n");
980     mGlobalPrefs.Clear();
981   }
982
983   // load global .pref file
984   CString strGlobalPref = g_PrefsDlg.m_global_rc_path->str;
985   strGlobalPref += "global.pref";
986
987   mGlobalPrefs.ReadXMLFile(strGlobalPref.GetBuffer());
988
989   mGlobalPrefs.GetPref("gamefile", &m_sGameFile, ""); // NOTE: there's no default, user HAS to select something
990   mGlobalPrefs.GetPref("autoload", &m_bAutoLoadGame, false);
991   mGlobalPrefs.GetPref("log console", &m_bLogConsole, false);
992   // in a very particular post-.pid startup
993   // we may have the console turned on and want to keep it that way
994   // so we use a latching system
995   if (m_bForceLogConsole)
996   {
997     m_bLogConsole = true;
998     Sys_Printf("console logging has been latched on, saving prefs\n");
999     SavePrefs();
1000     m_bForceLogConsole = false;
1001   }
1002
1003   // console logging: call Sys_LogConsole to check console logging status
1004   // it is important that we would log console as early as possible to make it useful
1005   Sys_LogFile();
1006
1007   if (mGlobalPrefs.mbEmpty)
1008   {
1009     Sys_Printf("Saving global.pref with default pref values\n");
1010     SavePrefs();
1011   }
1012 }
1013
1014 void CGameDialog::SavePrefs()
1015 {
1016   // update the tree and save it
1017   mGlobalPrefs.UpdatePrefTree();
1018
1019   CString strGlobalPref = g_PrefsDlg.m_global_rc_path->str;
1020   strGlobalPref += "global.pref";
1021
1022   if ( !mGlobalPrefs.WriteXMLFile( strGlobalPref.GetBuffer() ) ) {
1023     Sys_FPrintf(SYS_ERR, "Error occured while saving global prefs file '%s'\n", strGlobalPref.GetBuffer());
1024   }
1025 }
1026
1027 void CGameDialog::DoGameInstall() {
1028         // make sure console logging is on whenever we enter the installation loop
1029     g_PrefsDlg.mGamesDialog.m_bLogConsole = true;
1030         Sys_LogFile();
1031         mGameInstall.Run();
1032 }
1033
1034 void CGameDialog::DoGameDialog() {
1035         // allow looping the game selection dialog with calls to the game configure dialog in between
1036         while ( m_bDoGameInstall ) {
1037
1038                 m_bDoGameInstall = false;
1039
1040                 if ( DoModal() == IDCANCEL ) {
1041                         Error( "game selection dialog canceled, cannot continue" );
1042                         return;
1043                 }
1044
1045                 if ( m_bDoGameInstall ) {
1046                         DoGameInstall();
1047                         ScanForGames();
1048                         // and we will loop to do another DoModal dialog
1049                 }
1050         }
1051
1052         // unhook so we can use in other places
1053         // we manually incref'ed it when creating, it won't be freed (destructor)
1054         gtk_container_remove( GTK_CONTAINER( mTopBox ), GetGlobalFrame() );
1055
1056         // we save the prefs file
1057         SavePrefs();
1058 }
1059
1060 GtkWidget* CGameDialog::GetGlobalFrame()
1061 {
1062   GtkWidget *vbox, *text, *combo, *check;
1063
1064   if ( mFrame != NULL ) {
1065           return mFrame;
1066   }
1067
1068   mFrame = gtk_frame_new( NULL );
1069   gtk_container_set_border_width( GTK_CONTAINER( mFrame ), 5 );
1070   gtk_widget_show( mFrame );
1071
1072   vbox = gtk_vbox_new( FALSE, 6 );
1073   gtk_widget_show( vbox );
1074   gtk_container_add( GTK_CONTAINER( mFrame ), vbox );
1075   gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 );
1076
1077   text = gtk_label_new( _("Select the game:") );
1078   gtk_widget_show( text );
1079   gtk_box_pack_start( GTK_BOX( vbox ), text, FALSE, FALSE, 0 );
1080
1081   combo = gtk_combo_box_new_text();
1082   gtk_widget_show( combo );
1083   gtk_box_pack_start( GTK_BOX( vbox ), combo, FALSE, FALSE, 0 );
1084   AddDialogData( combo, &m_nComboSelect, DLG_COMBO_BOX_INT );
1085   mGameCombo = GTK_COMBO_BOX( combo );
1086
1087   UpdateGameCombo();
1088
1089   check = gtk_check_button_new_with_label( _("Auto load selected game on startup") );
1090   gtk_widget_show(check);
1091   gtk_box_pack_start (GTK_BOX(vbox), check, FALSE, FALSE, 0);
1092   AddDialogData (check, &m_bAutoLoadGame, DLG_CHECK_BOOL);
1093
1094   text = gtk_label_new(_("(this frame is available in the prefs menu if you set auto-select)"));
1095   gtk_widget_show(text);
1096   gtk_box_pack_start (GTK_BOX(vbox), text, FALSE, FALSE, 0);
1097
1098 #ifdef _WIN32
1099   check = gtk_check_button_new_with_label( _("Networked install - per-user settings") );
1100   gtk_widget_show( check );
1101   gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 );
1102   AddDialogData( check, &m_bNetRun, DLG_CHECK_BOOL );
1103 #endif
1104
1105   check = gtk_check_button_new_with_label( _("Log the console to radiant.log") );
1106   gtk_widget_show( check );
1107   gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 );
1108   AddDialogData( check, &m_bLogConsole, DLG_CHECK_BOOL );
1109
1110   // incref it so we can pass it around
1111   gtk_widget_ref( GTK_WIDGET( mFrame ) );
1112
1113   return mFrame;
1114 }
1115
1116 void CGameDialog::UpdateData( bool retrieve ) {
1117   if (!retrieve)
1118   {
1119     // use m_sGameFile to set m_nComboSelect
1120     list<CGameDescription *>::iterator iGame;
1121     int i = 0;
1122     for(iGame=mGames.begin(); iGame!=mGames.end(); iGame++)
1123     {
1124       if ((*iGame)->mGameFile == m_sGameFile)
1125       {
1126         m_nComboSelect = i;
1127         break;
1128       }
1129       i++;
1130     }
1131 #ifdef _WIN32
1132     UpdateNetrun(false);
1133 #endif
1134   }
1135   Dialog::UpdateData(retrieve);
1136   if (retrieve)
1137   {
1138     // use m_nComboSelect to set m_sGameFile
1139     list<CGameDescription *>::iterator iGame = mGames.begin();
1140     int i;
1141     for(i=0; i<m_nComboSelect; i++)
1142     {
1143       iGame++;
1144     }
1145     m_sGameFile = (*iGame)->mGameFile;
1146 #ifdef _WIN32
1147     UpdateNetrun(true);
1148 #endif
1149   }
1150 }
1151
1152 void CGameDialog::SInstallCallback( GtkWidget *widget, gpointer data ) {
1153         CGameDialog *d = static_cast< CGameDialog* >( data );
1154         d->m_bDoGameInstall = true;
1155         d->EndModal( 0 );
1156 }
1157
1158 void CGameDialog::BuildDialog() {
1159         GtkWidget *dlg, *vbox1, *button, *setup_button;
1160
1161         dlg = m_pWidget;
1162         gtk_window_set_title( GTK_WINDOW( dlg ), _("Select Game") );
1163
1164         vbox1 = gtk_vbox_new( FALSE, 0 );
1165         gtk_widget_show( vbox1 );
1166         gtk_container_add( GTK_CONTAINER( dlg ), vbox1 );
1167
1168         gtk_container_add( GTK_CONTAINER( vbox1 ), GetGlobalFrame() );
1169         mTopBox = vbox1;
1170
1171         setup_button = gtk_button_new_with_label( _("Configure more games") );
1172         gtk_widget_show( setup_button );
1173         gtk_box_pack_start( GTK_BOX( vbox1 ), setup_button, FALSE, FALSE, 0 );
1174         gtk_signal_connect( GTK_OBJECT( setup_button ), "clicked",
1175                                                 GTK_SIGNAL_FUNC( SInstallCallback ), this );
1176
1177         button = gtk_button_new_with_label( _("OK") );
1178         gtk_widget_show( button );
1179         gtk_box_pack_start( GTK_BOX( vbox1 ), button, FALSE, FALSE, 0 );
1180         AddModalButton( button, IDOK );
1181
1182         button = gtk_button_new_with_label( _("Cancel") );
1183         gtk_widget_show( button );
1184         gtk_box_pack_start( GTK_BOX( vbox1 ), button, FALSE, FALSE, 0 );
1185         AddModalButton( button, IDCANCEL );
1186
1187         gtk_widget_set_usize( button, 60, -2 );
1188 }
1189
1190 void CGameDialog::UpdateGameCombo() {
1191   // fill in with the game descriptions
1192   list<CGameDescription *>::iterator iGame;
1193
1194   if ( mGameCombo == NULL ) {
1195           Sys_Printf( "mGameCombo == NULL\n" );
1196           return;
1197   }
1198
1199   // clear whatever is in - wtf no way to know how many text entries?
1200   // use set/get active to track
1201   gtk_combo_box_set_active( mGameCombo, 0 );
1202   while ( gtk_combo_box_get_active( mGameCombo ) == 0 ) {
1203           gtk_combo_box_remove_text( mGameCombo, 0 );
1204           gtk_combo_box_set_active( mGameCombo, 0 );
1205   }
1206
1207   for ( iGame = mGames.begin(); iGame != mGames.end(); iGame++ ) {
1208           gtk_combo_box_append_text( mGameCombo, (*iGame)->mGameName.GetBuffer() );
1209   }
1210   gtk_combo_box_set_active( mGameCombo, 0 );
1211 }
1212
1213 void CGameDialog::ScanForGames()
1214 {
1215   CString strPath;
1216   char *dirlist;
1217   GDir *dir;
1218   CString strGamesPath = g_strAppPath.GetBuffer();
1219   strGamesPath += "games";
1220   const char *path = strGamesPath.GetBuffer();
1221
1222   if ( !mGames.empty() ) {
1223           Sys_Printf( "Clearing game list\n" );
1224           list<CGameDescription*>::iterator iGame;
1225           for ( iGame = mGames.begin(); iGame != mGames.end(); iGame++ ) {
1226                   delete (*iGame);
1227           }
1228           mGames.clear();
1229   }
1230
1231   Sys_Printf( "Scanning for game description files: %s\n", path );
1232
1233   /*!
1234   \todo FIXME LINUX:
1235   do we put game description files below g_strAppPath, or in ~/.radiant
1236   i.e. read only or read/write?
1237   my guess .. readonly cause it's an install
1238   we will probably want to add ~/.radiant/<version>/games/ scanning on top of that for developers
1239   (if that's really needed)
1240   */
1241
1242   // FIXME need to catch the 'no game description' situation and exit with a clean error
1243
1244   dir = g_dir_open(path, 0, NULL);
1245
1246   if (dir != NULL)
1247   {
1248     while (1)
1249     {
1250       const gchar* name = g_dir_read_name(dir);
1251       if(name == NULL)
1252         break;
1253
1254       dirlist = g_strdup(name);
1255 #ifdef _WIN32
1256       strlwr (dirlist);
1257 #endif
1258       char *ext = strrchr (dirlist, '.');
1259       if ((ext == NULL) || (strcmp (ext, ".game") != 0))
1260         continue;
1261       strPath.Format("%s/%s", path, dirlist);
1262       Sys_Printf("%s\n", strPath.GetBuffer());
1263       // got one, load it
1264       xmlDocPtr pDoc = xmlParseFile(strPath.GetBuffer());
1265       if (pDoc)
1266       {
1267         mGames.push_front( new CGameDescription( pDoc, dirlist ) );
1268       }
1269       else
1270       {
1271         Sys_FPrintf(SYS_ERR, "XML parser failed on '%s'\n", strPath.GetBuffer());
1272       }
1273
1274       g_free( dirlist );
1275     }
1276     g_dir_close( dir );
1277   }
1278
1279   // entries in the combo need to be updated
1280   UpdateGameCombo();
1281 }
1282
1283 CGameDescription* CGameDialog::GameDescriptionForComboItem()
1284 {
1285   list<CGameDescription *>::iterator iGame;
1286   int i=0;
1287   for( iGame = mGames.begin(); iGame != mGames.end(); iGame++,i++ ) {
1288     if ( i == m_nComboSelect ) {
1289       return (*iGame);
1290     }
1291   }
1292   return NULL; // not found
1293 }
1294
1295 void CGameDialog::InitGlobalPrefPath()
1296 {
1297   GString *global_rc_path;
1298   // configure m_global_rc_path
1299   // this is the g_strTempPath, and it has already been mkdir'ed
1300   global_rc_path = g_string_new(g_strTempPath.GetBuffer());
1301   g_PrefsDlg.m_global_rc_path = global_rc_path;
1302 }
1303
1304 void CGameDialog::Reset()
1305 {
1306   if (!g_PrefsDlg.m_global_rc_path)
1307     InitGlobalPrefPath();
1308   CString strGlobalPref = g_PrefsDlg.m_global_rc_path->str;
1309   strGlobalPref += "global.pref";
1310   remove(strGlobalPref.GetBuffer());
1311 }
1312
1313 void CGameDialog::Init()
1314 {
1315   InitGlobalPrefPath();
1316   ScanForGames();
1317   if ( mGames.empty() ) {
1318           DoGameInstall();
1319           ScanForGames();
1320           if ( mGames.empty() ) {
1321                   Error( "No games setup, aborting\n" );
1322           }
1323   }
1324   LoadPrefs();
1325   if ( m_bAutoLoadGame ) {
1326     // search by .game name
1327     list<CGameDescription *>::iterator iGame;
1328     for(iGame=mGames.begin(); iGame!=mGames.end(); iGame++)
1329     {
1330       if ((*iGame)->mGameFile == m_sGameFile)
1331       {
1332         m_pCurrentGameDescription = (*iGame);
1333         break;
1334       }
1335     }
1336   }
1337   if ( !m_bAutoLoadGame || !m_pCurrentGameDescription ) {
1338     DoGameDialog();
1339     // use m_nComboSelect to identify the game to run as and set the globals
1340     m_pCurrentGameDescription = GameDescriptionForComboItem();
1341     if ( !m_pCurrentGameDescription ) {
1342                 Error("Lookup of game description object failed, can't continue\n");
1343         }
1344   }
1345   g_pGameDescription = m_pCurrentGameDescription;
1346
1347   g_strGameToolsPath = g_pGameDescription->mGameToolsPath;
1348
1349         // NOTE TTimo: this is moved from QE_LoadProject in 1.2
1350         // (probably broken)
1351   // NOTE Hydra: was broken for win32, we don't use m_strHomeGame or m_strFSBasePath
1352 #if defined (__linux__) || defined (__APPLE__)
1353   g_qeglobals.m_strHomeGame = g_get_home_dir();
1354   g_qeglobals.m_strHomeGame += "/";
1355   g_qeglobals.m_strHomeGame += m_pCurrentGameDescription->mUserPathPrefix.GetBuffer();
1356   g_qeglobals.m_strHomeGame += "/";
1357 #else
1358   g_qeglobals.m_strHomeGame = g_pGameDescription->mEnginePath.GetBuffer();
1359 #endif
1360
1361   g_pGameDescription->Dump();
1362 }
1363
1364 CGameDialog::~CGameDialog()
1365 {
1366   if (mFrame)
1367   {
1368     // NOTE I'm not too sure how reliable this is
1369     gtk_widget_unref(GTK_WIDGET(mFrame));
1370   }
1371   // free all the game descriptions
1372   list<CGameDescription *>::iterator iGame;
1373   for(iGame=mGames.begin(); iGame!=mGames.end(); iGame++)
1374   {
1375     delete (*iGame);
1376     *iGame = NULL;
1377   }
1378 }
1379
1380 void CGameDialog::AddPacksURL(Str &URL)
1381 {
1382   // add the URLs for the list of game packs installed
1383   // FIXME: this is kinda hardcoded for now..
1384   list<CGameDescription *>::iterator iGame;
1385   for(iGame=mGames.begin(); iGame!=mGames.end(); iGame++)
1386   {
1387     if ((*iGame)->mGameFile == "q3.game")
1388       URL += "&Games_dlup%5B%5D=1";
1389     else if ((*iGame)->mGameFile == "wolf.game")
1390       URL += "&Games_dlup%5B%5D=2";
1391         // FIXME: double entry
1392     else if ((*iGame)->mGameFile == "wolf.game")
1393       URL += "&Games_dlup%5B%5D=3";
1394     else if ((*iGame)->mGameFile == "jk2.game")
1395       URL += "&Games_dlup%5B%5D=4";
1396     else if ((*iGame)->mGameFile == "stvef.game")
1397       URL += "&Games_dlup%5B%5D=5";
1398     else if ((*iGame)->mGameFile == "sof2.game")
1399       URL += "&Games_dlup%5B%5D=6";
1400     else if ((*iGame)->mGameFile == "ja.game")
1401       URL += "&Games_dlup%5B%5D=7";
1402   }
1403 }
1404
1405 #ifdef _WIN32
1406
1407 #define NETRUN_FILENAME "netrun.conf"
1408
1409 bool CGameDialog::m_bNetRun;
1410
1411 void CGameDialog::UpdateNetrun(bool retrieve)
1412 {
1413   FILE *f_netrun;
1414   CString strNetrun;
1415   strNetrun = g_strAppPath; strNetrun += NETRUN_FILENAME;
1416   if (!retrieve)
1417   {
1418     // now check if we are running from a network installation
1419     // use a dummy file as the flag
1420     f_netrun = fopen(strNetrun.GetBuffer(), "r");
1421     if (f_netrun)
1422     {
1423       fclose(f_netrun);
1424       m_bNetRun = true;
1425     }
1426     else
1427       m_bNetRun = false;
1428   }
1429   else
1430   {
1431     if (m_bNetRun)
1432     {
1433       f_netrun = fopen(strNetrun.GetBuffer(), "w");
1434       if (!f_netrun)
1435       {
1436         Sys_FPrintf(SYS_ERR, "ERROR: Failed to create netrun file '%s'\n", strNetrun.GetBuffer());
1437         m_bNetRun = false;
1438       }
1439       else
1440       {
1441         fclose(f_netrun);
1442         Sys_Printf("Created/Checked '%s'\n", strNetrun.GetBuffer());
1443       }
1444     }
1445     else
1446     {
1447       if (remove(strNetrun.GetBuffer()) == -1)
1448       {
1449         if (errno != ENOENT)
1450           Sys_FPrintf(SYS_ERR, "Failed to remove netrun file '%s'\n", strNetrun.GetBuffer());
1451         m_bNetRun = true;
1452       }
1453       else
1454       {
1455         Sys_Printf("Netrun mode is disabled\n");
1456       }
1457     }
1458   }
1459 }
1460
1461 bool CGameDialog::GetNetrun()
1462 {
1463   return m_bNetRun;
1464 }
1465 #endif
1466
1467 /*
1468 ========
1469
1470 very first prefs init deals with selecting the game and the game tools path
1471 then we can load .ini stuff
1472
1473 using prefs / ini settings:
1474 those are per-game
1475
1476 win32:
1477 look in g_strGameToolsPath for .ini
1478
1479 linux:
1480 look in ~/.radiant/<version>/gamename
1481 ========
1482 */
1483
1484 #define PREFS_LOCAL_FILENAME "local.pref"
1485
1486 void PrefsDlg::Init()
1487 {
1488   mGamesDialog.Init();
1489
1490   // m_global_rc_path has been set above, do m_rc_path with game specific stuff now
1491   // the win32 and linux versions have been unified for network mode
1492 #ifdef _WIN32
1493   if (!CGameDialog::GetNetrun())
1494   {
1495     // legacy prefs settings, this goes where the game pack is installed
1496     m_rc_path = g_string_new (g_strGameToolsPath.GetBuffer() );
1497     m_inipath = g_string_new (m_rc_path->str);
1498     g_string_append (m_inipath, PREFS_LOCAL_FILENAME);
1499     return;
1500   }
1501 #endif
1502   // this is common to win32 and Linux init now
1503   m_rc_path = g_string_new (m_global_rc_path->str);
1504
1505   // game sub-dir
1506   g_string_append (m_rc_path, g_pGameDescription->mGameFile.GetBuffer());
1507   g_string_append (m_rc_path, "/");
1508   Q_mkdir (m_rc_path->str, 0775);
1509
1510   // then the ini file
1511   m_inipath = g_string_new (m_rc_path->str);
1512   g_string_append (m_inipath, PREFS_LOCAL_FILENAME);
1513
1514 }
1515
1516 void PrefsDlg::UpdateData (bool retrieve)
1517 {
1518   // leo: the "changed" signal confuses the update function
1519   if (m_pWidget == NULL)
1520     return;
1521   mGamesDialog.UpdateData (retrieve);
1522   Dialog::UpdateData (retrieve);
1523 }
1524
1525 #ifdef _WIN32
1526 #define PREFSHSPACE 5
1527 #else
1528 #define PREFSHSPACE 0
1529 #endif
1530
1531 static void UpdateSensitivity( GtkWidget *widget, gpointer data )
1532 {
1533   PrefsDlg *dlg = (PrefsDlg*)data;
1534   dlg->DoSensitivity();
1535 }
1536
1537 static void UpdateEditorSensitivity(GtkWidget *widget, gpointer data)
1538 {
1539   PrefsDlg *dlg = (PrefsDlg*)data;
1540   dlg->DoEditorSensitivity();
1541 }
1542
1543 // start new prefs dialog
1544
1545 /*! Utility function for swapping notebook pages for tree list selections */
1546 void PrefsDlg::showPrefPage(int prefpage)
1547 {
1548   if(gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook)) != prefpage)
1549     gtk_notebook_set_page(GTK_NOTEBOOK(notebook), prefpage);
1550
1551   return;
1552 }
1553
1554 static void treeSelection(GtkTreeSelection* selection, gpointer data)
1555 {
1556   PrefsDlg *dlg = (PrefsDlg*)data;
1557
1558   GtkTreeModel* model;
1559   GtkTreeIter selected;
1560   if(gtk_tree_selection_get_selected(selection, &model, &selected))
1561   {
1562     int prefpage;
1563     gtk_tree_model_get(model, &selected, 1, (gpointer*)&prefpage, -1);
1564     dlg->showPrefPage(prefpage);
1565   }
1566 }
1567
1568 void PrefsDlg::BuildDialog ()
1569 {
1570   // Main Preferences dialog
1571   GtkWidget *dialog, *mainvbox, *hbox, *sc_win, *preflabel;
1572
1573   // Widgets on notebook pages
1574   GtkWidget *check, *label, *scale, *hbox2, *combo,
1575             *table, *spin,  *entry, *pixmap,
1576             *radio, *button, *pageframe, *vbox;
1577
1578   GList *combo_list = (GList*)NULL;
1579
1580   GtkObject *adj;
1581
1582   dialog = m_pWidget;
1583   gtk_window_set_title(GTK_WINDOW(dialog), _("GtkRadiant Preferences"));
1584   gtk_widget_realize(dialog);
1585
1586   mainvbox = gtk_vbox_new(FALSE, 5);
1587   gtk_container_add(GTK_CONTAINER(dialog), mainvbox);
1588   gtk_container_set_border_width(GTK_CONTAINER(mainvbox), 5);
1589   gtk_widget_show(mainvbox);
1590
1591   hbox = gtk_hbox_new(FALSE, 5);
1592   gtk_widget_show(hbox);
1593   gtk_box_pack_end(GTK_BOX(mainvbox), hbox, FALSE, TRUE, 0);
1594
1595   button = gtk_button_new_with_label(_("OK"));
1596   gtk_widget_show(button);
1597   gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1598   gtk_widget_set_usize(button, 60, -2);
1599   AddModalButton(button, IDOK);
1600
1601   button = gtk_button_new_with_label(_("Cancel"));
1602   gtk_widget_show(button);
1603   gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1604   gtk_widget_set_usize(button, 60, -2);
1605   AddModalButton(button, IDCANCEL);
1606
1607   button = gtk_button_new_with_label (_("Clean"));
1608   gtk_widget_show(button);
1609   gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(OnButtonClean), this);
1610   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1611   gtk_widget_set_usize (button, 60, -2);
1612
1613   hbox = gtk_hbox_new(FALSE, 5);
1614   gtk_box_pack_start(GTK_BOX(mainvbox), hbox, TRUE, TRUE, 0);
1615   gtk_widget_show(hbox);
1616
1617   sc_win = gtk_scrolled_window_new(NULL, NULL);
1618   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sc_win), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
1619   gtk_box_pack_start(GTK_BOX(hbox), sc_win, FALSE, FALSE, 0);
1620   gtk_widget_show(sc_win);
1621
1622   // prefs pages notebook
1623   notebook = gtk_notebook_new();
1624   // hide the notebook tabs since its not supposed to look like a notebook
1625   gtk_notebook_set_show_tabs(GTK_NOTEBOOK(notebook), FALSE);
1626   gtk_box_pack_start(GTK_BOX(hbox), notebook, TRUE, TRUE, 0);
1627   gtk_widget_show(notebook);
1628
1629   gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sc_win), GTK_SHADOW_IN);
1630
1631   {
1632     GtkTreeStore* store = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
1633
1634     GtkWidget* view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
1635     gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
1636
1637     {
1638       GtkCellRenderer* renderer = gtk_cell_renderer_text_new();
1639       GtkTreeViewColumn* column = gtk_tree_view_column_new_with_attributes(_("Preferences"), renderer, "text", 0, NULL);
1640       gtk_tree_view_append_column(GTK_TREE_VIEW(view), column);
1641     }
1642
1643     {
1644       GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
1645       g_signal_connect(G_OBJECT(selection), "changed", G_CALLBACK(treeSelection), this);
1646     }
1647
1648     gtk_widget_show(view);
1649
1650     gtk_container_add(GTK_CONTAINER (sc_win), view);
1651
1652     {
1653       /********************************************************************/
1654       /* Add preference tree options                                      */
1655       /********************************************************************/
1656       {
1657         GtkTreeIter group;
1658         gtk_tree_store_append(store, &group, NULL);
1659         gtk_tree_store_set(store, &group, 0, _("Globals"), 1, PTAB_FRONT, -1);
1660         {
1661           GtkTreeIter tab;
1662           gtk_tree_store_append(store, &tab, &group);
1663           gtk_tree_store_set(store, &tab, 0, _("Game settings"), 1, (gpointer)PTAB_GAME_SETTINGS, -1);
1664         }
1665       }
1666
1667       {
1668         GtkTreeIter group;
1669         gtk_tree_store_append(store, &group, NULL);
1670         gtk_tree_store_set(store, &group, 0, _("Display"), 1, PTAB_FRONT, -1);
1671         {
1672           GtkTreeIter tab;
1673           gtk_tree_store_append(store, &tab, &group);
1674           gtk_tree_store_set(store, &tab, 0, _("2D Display/Rendering"), 1, (gpointer)PTAB_2D, -1);
1675         }
1676         {
1677           GtkTreeIter tab;
1678           gtk_tree_store_append(store, &tab, &group);
1679           gtk_tree_store_set(store, &tab, 0, _("3D View"), 1, (gpointer)PTAB_CAMERA, -1);
1680         }
1681         {
1682           GtkTreeIter tab;
1683           gtk_tree_store_append(store, &tab, &group);
1684           gtk_tree_store_set(store, &tab, 0, _("Texture Settings"), 1, (gpointer)PTAB_TEXTURE, -1);
1685         }
1686       }
1687
1688       {
1689         GtkTreeIter group;
1690         gtk_tree_store_append(store, &group, NULL);
1691         gtk_tree_store_set(store, &group, 0, _("Interface"), 1, PTAB_FRONT, -1);
1692         {
1693           GtkTreeIter tab;
1694           gtk_tree_store_append(store, &tab, &group);
1695           gtk_tree_store_set(store, &tab, 0, _("Layout"), 1, (gpointer)PTAB_LAYOUT, -1);
1696         }
1697         {
1698           GtkTreeIter tab;
1699           gtk_tree_store_append(store, &tab, &group);
1700           gtk_tree_store_set(store, &tab, 0, _("Mouse"), 1, (gpointer)PTAB_MOUSE, -1);
1701         }
1702         {
1703           GtkTreeIter tab;
1704           gtk_tree_store_append(store, &tab, &group);
1705           gtk_tree_store_set(store, &tab, 0, _("Editing"), 1, (gpointer)PTAB_EDITING, -1);
1706         }
1707       }
1708
1709       {
1710         GtkTreeIter group;
1711         gtk_tree_store_append(store, &group, NULL);
1712         gtk_tree_store_set(store, &group, 0, _("Other"), 1, PTAB_FRONT, -1);
1713         {
1714           GtkTreeIter tab;
1715           gtk_tree_store_append(store, &tab, &group);
1716           gtk_tree_store_set(store, &tab, 0, _("Startup/Auto save"), 1, (gpointer)PTAB_STARTUP, -1);
1717         }
1718         {
1719           GtkTreeIter tab;
1720           gtk_tree_store_append(store, &tab, &group);
1721           gtk_tree_store_set(store, &tab, 0, _("Paths"), 1, (gpointer)PTAB_PATHS, -1);
1722         }
1723         {
1724           GtkTreeIter tab;
1725           gtk_tree_store_append(store, &tab, &group);
1726           gtk_tree_store_set(store, &tab, 0, _("Misc"), 1, (gpointer)PTAB_MISC, -1);
1727         }
1728         if (!g_qeglobals.bBSPFrontendPlugin)
1729         {
1730           GtkTreeIter tab;
1731           gtk_tree_store_append(store, &tab, &group);
1732           gtk_tree_store_set(store, &tab, 0, _("BSP Monitoring"), 1, (gpointer)PTAB_BSPMONITOR, -1);
1733         }
1734       }
1735     }
1736
1737     gtk_tree_view_expand_all(GTK_TREE_VIEW(view));
1738
1739     g_object_unref(G_OBJECT(store));
1740   }
1741
1742   /**********************************************************************/
1743   /* build the prefs pages                                              */
1744   /**********************************************************************/
1745
1746   // Front page...
1747   // todo : add something interesting here
1748   // NOTE TTimo: tip of the day? or a logo?
1749   preflabel = gtk_label_new(_("Front Page"));
1750   gtk_widget_show(preflabel);
1751   pageframe = gtk_frame_new(NULL);
1752   gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5);
1753   gtk_widget_show(pageframe);
1754   vbox = gtk_vbox_new(FALSE, 5);
1755   gtk_widget_show(vbox);
1756   gtk_widget_set_usize(GTK_WIDGET(vbox), 350, -2);
1757   gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
1758   gtk_container_add(GTK_CONTAINER(pageframe), vbox);
1759
1760   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
1761
1762   /******** global preferences group ****************************/
1763   preflabel = gtk_label_new(_("Globals"));
1764   gtk_widget_show(preflabel);
1765
1766   pageframe = mGamesDialog.GetGlobalFrame();
1767   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
1768
1769   /******** 2D prefs group (xy views/rendering options) *********/
1770   preflabel = gtk_label_new(_("2D Display"));
1771   gtk_widget_show(preflabel);
1772   pageframe = gtk_frame_new(_("2D Display"));
1773   gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5);
1774   gtk_widget_show(pageframe);
1775   vbox = gtk_vbox_new(FALSE, 5);
1776   gtk_widget_show(vbox);
1777   gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
1778   gtk_container_add(GTK_CONTAINER(pageframe), vbox);
1779
1780   // OpenGL Display Lists
1781   check = gtk_check_button_new_with_label(_("OpenGL Display Lists"));
1782   gtk_widget_show(check);
1783   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
1784   AddDialogData(check, &m_bDisplayLists, DLG_CHECK_BOOL);
1785
1786   // Antialiased points & lines
1787   // Fishman - Add antialiazed points and lines support. 09/03/00
1788   check = gtk_check_button_new_with_label (_("OpenGL antialiased points and lines"));
1789   gtk_widget_show (check);
1790   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
1791   AddDialogData (check, &m_bAntialiasedPointsAndLines, DLG_CHECK_BOOL);
1792
1793   // Solid selection boxes
1794   check = gtk_check_button_new_with_label (_("Solid selection boxes"));
1795   gtk_widget_show (check);
1796   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
1797   AddDialogData (check, &m_bNoStipple, DLG_CHECK_BOOL);
1798
1799   // Display size info
1800   check = gtk_check_button_new_with_label (_("Display size info"));
1801   gtk_widget_show (check);
1802   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
1803   AddDialogData (check, &m_bSizePaint, DLG_CHECK_BOOL);
1804
1805   // Alternate vertex/edge handles
1806   // Gef: Kyro GL_POINT work around 25-aug-2001
1807   check = gtk_check_button_new_with_label (_("Alternate vertex/edge handles"));
1808   gtk_widget_show(check);
1809   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
1810   AddDialogData(check, &m_bGlPtWorkaround, DLG_CHECK_BOOL);
1811
1812   g_list_free (combo_list);
1813
1814 #ifdef ATIHACK_812
1815         // ATI bugs
1816         check = gtk_check_button_new_with_label (_("ATI cards with broken drivers - bug #802"));
1817         gtk_widget_show(check);
1818         gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
1819         AddDialogData(check, &m_bGlATIHack, DLG_CHECK_BOOL);
1820 #endif
1821
1822   // Add the page to the notebook
1823   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
1824
1825   /******** 3D Camera view group *********/
1826   preflabel = gtk_label_new(_("3D View"));
1827   gtk_widget_show(preflabel);
1828   pageframe = gtk_frame_new(_("3D View"));
1829   gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5);
1830   gtk_widget_show(pageframe);
1831   vbox = gtk_vbox_new(FALSE, 5);
1832   gtk_widget_show(vbox);
1833   gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
1834   gtk_container_add(GTK_CONTAINER(pageframe), vbox);
1835
1836   // Directional velocity (Movement Velocity)
1837   // label container
1838   hbox2 = gtk_hbox_new (FALSE, 0);
1839   gtk_widget_show (hbox2);
1840   gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
1841
1842   // label
1843   label = gtk_label_new(_("Movement Velocity"));
1844   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1845   gtk_widget_show(label);
1846   gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
1847
1848   // adjustment
1849   adj = gtk_adjustment_new(100, 50, 300, 1, 10, 10);
1850   AddDialogData(adj, &m_nMoveSpeed, DLG_ADJ_INT);
1851
1852   // scale
1853   scale = gtk_hscale_new(GTK_ADJUSTMENT(adj));
1854   gtk_widget_show(scale);
1855   gtk_box_pack_start(GTK_BOX (vbox), scale, FALSE, TRUE, 2);
1856
1857   gtk_scale_set_draw_value (GTK_SCALE (scale), TRUE);
1858
1859   // Angular velocity (Rotational Velocity)
1860   // label container
1861   hbox2 = gtk_hbox_new (FALSE, 0);
1862   gtk_widget_show (hbox2);
1863   gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
1864
1865   // label
1866   label = gtk_label_new (_("Rotational Velocity"));
1867   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1868   gtk_widget_show (label);
1869   gtk_box_pack_start(GTK_BOX(hbox2), label, FALSE, FALSE, 0);
1870
1871   // adjustment
1872   adj = gtk_adjustment_new (3, 1, 180, 1, 10, 10); // value, low, high, step, page_step, page_size
1873   AddDialogData (adj, &m_nAngleSpeed, DLG_ADJ_INT);
1874
1875   // scale
1876   scale = gtk_hscale_new (GTK_ADJUSTMENT (adj));
1877   gtk_widget_show (scale);
1878   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, TRUE, 2);
1879   gtk_scale_set_draw_value (GTK_SCALE (scale), TRUE);
1880
1881   // Text under the velocity sliders
1882   // container
1883   hbox2 = gtk_hbox_new (FALSE, 0);
1884   gtk_widget_show (hbox2);
1885   gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
1886
1887   // label
1888   label = gtk_label_new (_("slow"));
1889   gtk_widget_show (label);
1890   gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
1891
1892   // label
1893   label = gtk_label_new (_("fast"));
1894   gtk_widget_show (label);
1895   gtk_box_pack_end (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
1896
1897   // Allow drag to select multiple faces/brushes
1898   // container
1899   table = gtk_table_new(2, 1, FALSE);
1900   gtk_widget_show(table);
1901   gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0);
1902   gtk_table_set_row_spacings (GTK_TABLE (table), 5);
1903   gtk_table_set_col_spacings (GTK_TABLE (table), 5);
1904
1905   label = gtk_label_new (_("Use paint-select in camera view:"));
1906   gtk_widget_show (label);
1907   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1908   gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
1909                   (GtkAttachOptions) (0),
1910                   (GtkAttachOptions) (0), 0, 0);
1911
1912   combo_list = NULL;
1913   combo_list = g_list_append (combo_list, (void *)_("No"));
1914   combo_list = g_list_append (combo_list, (void *)_("Yes"));
1915   combo_list = g_list_append (combo_list, (void *)_("Yes (Classic Key Setup)"));
1916
1917   combo = gtk_combo_new ();
1918   gtk_combo_set_popdown_strings (GTK_COMBO (combo), combo_list);
1919   gtk_widget_show (combo);
1920   gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1,
1921                   (GtkAttachOptions) (GTK_FILL),
1922                   (GtkAttachOptions) (0), 0, 0);
1923   gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (combo)->entry), FALSE);
1924   AddDialogData (combo, &m_nCamDragMultiSelect, DLG_COMBO_INT);
1925
1926   // Freelook in Camera view
1927   check = gtk_check_button_new_with_label (_("Freelook in Camera view"));
1928   gtk_widget_show (check);
1929   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
1930   gtk_label_set_justify (GTK_LABEL (GTK_BIN (check)->child), GTK_JUSTIFY_LEFT);
1931   AddDialogData (check, &m_bCamFreeLook, DLG_CHECK_BOOL);
1932
1933   // Freelook in Camera view w/ forward & back strafing instead of up and down looking
1934   check = gtk_check_button_new_with_label (_("Freelook strafes Forward and Back"));
1935   gtk_widget_show (check);
1936   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
1937   gtk_label_set_justify (GTK_LABEL (GTK_BIN (check)->child), GTK_JUSTIFY_LEFT);
1938   AddDialogData (check, &m_bCamFreeLookStrafe, DLG_CHECK_BOOL);
1939
1940   // Invert mouse in freelook
1941   check = gtk_check_button_new_with_label (_("Invert mouse in freelook"));
1942   gtk_widget_show (check);
1943   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
1944   gtk_label_set_justify (GTK_LABEL (GTK_BIN (check)->child), GTK_JUSTIFY_LEFT);
1945   AddDialogData (check, &m_bCamInverseMouse, DLG_CHECK_BOOL);
1946
1947   // Discrete movement
1948   check = gtk_check_button_new_with_label (_("Discrete movement"));
1949   gtk_widget_show (check);
1950   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
1951   gtk_label_set_justify (GTK_LABEL (GTK_BIN (check)->child), GTK_JUSTIFY_LEFT);
1952   AddDialogData (check, &m_bCamDiscrete, DLG_CHECK_BOOL);
1953
1954   // Update XY views on camera move
1955   check = gtk_check_button_new_with_label (_("Update XY views on camera move"));
1956   gtk_widget_show (check);
1957   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
1958   gtk_label_set_justify (GTK_LABEL (GTK_BIN (check)->child), GTK_JUSTIFY_LEFT);
1959   AddDialogData (check, &m_bCamXYUpdate, DLG_CHECK_BOOL);
1960
1961   // Add the page to the notebook
1962   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
1963
1964   /******** Texture group *********/
1965   preflabel = gtk_label_new(_("Textures"));
1966   gtk_widget_show(preflabel);
1967   pageframe = gtk_frame_new(_("Textures"));
1968   gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5);
1969   gtk_widget_show(pageframe);
1970   vbox = gtk_vbox_new(FALSE, 6);
1971   gtk_widget_show(vbox);
1972   gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
1973   gtk_container_add(GTK_CONTAINER(pageframe), vbox);
1974
1975   // Texture quality slider
1976   // label
1977   label = gtk_label_new (_("Texture quality"));
1978   gtk_widget_show (label);
1979   gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
1980   gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
1981   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
1982
1983   // adjustment
1984   adj = gtk_adjustment_new (0, 0, 4, 1, 1, 1);
1985   AddDialogData (adj, &m_nLatchedTextureQuality, DLG_ADJ_INT);
1986
1987   // scale
1988   scale = gtk_hscale_new (GTK_ADJUSTMENT (adj));
1989   gtk_widget_show (scale);
1990   gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
1991   gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
1992
1993   // text under the texture slider
1994   hbox2 = gtk_hbox_new (FALSE, 0);
1995   gtk_widget_show (hbox2);
1996   gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
1997   label = gtk_label_new (_("low"));
1998   gtk_widget_show (label);
1999   gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
2000   label = gtk_label_new (_("high"));
2001   gtk_widget_show (label);
2002   gtk_box_pack_end (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
2003
2004   // texture subsets
2005   check = gtk_check_button_new_with_label (_("Texture subsets"));
2006   gtk_widget_show (check);
2007   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2008   AddDialogData (check, &m_bTextureWindow, DLG_CHECK_BOOL);
2009
2010   // texture scrollbar
2011   check = gtk_check_button_new_with_label (_("Texture scrollbar"));
2012   gtk_widget_show (check);
2013   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2014   AddDialogData (check, &m_bTextureScrollbar, DLG_CHECK_BOOL);
2015
2016   // texture increment matches grid
2017   check = gtk_check_button_new_with_label (_("Tex increment matches grid"));
2018   gtk_widget_show (check);
2019   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
2020   AddDialogData (check, &m_bSnapTToGrid, DLG_CHECK_BOOL);
2021
2022   // RIANT
2023   // Texture compression choice label
2024   // container
2025   table = gtk_table_new(2, 1, FALSE);
2026   gtk_widget_show(table);
2027   gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0);
2028   gtk_table_set_row_spacings (GTK_TABLE (table), 5);
2029   gtk_table_set_col_spacings (GTK_TABLE (table), 5);
2030
2031   label = gtk_label_new (_("Texture Compression (if available):"));
2032   gtk_widget_show (label);
2033   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2034   gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
2035                   (GtkAttachOptions) (0),
2036                   (GtkAttachOptions) (0), 0, 0);
2037   gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2038
2039   // Texture compression choice label
2040   combo_list = NULL;
2041   // NONE will always be in pos 0
2042   combo_list = g_list_append (combo_list, (void *)_("None"));
2043
2044   // if OpenGL compression is enabled it will always be
2045   // in pos 1
2046   if (g_qeglobals.m_bOpenGLCompressionSupported)
2047   {
2048     combo_list = g_list_append (combo_list, (void *)_("OpenGL ARB"));
2049   }
2050
2051   // If S3 is enabled offer all 3 valid compression schemes in RGBA
2052   if (g_qeglobals.m_bS3CompressionSupported)
2053   {
2054     combo_list = g_list_append (combo_list, (void *)_("S3TC DXT1"));
2055     combo_list = g_list_append (combo_list, (void *)_("S3TC DXT3"));
2056     combo_list = g_list_append (combo_list, (void *)_("S3TC DXT5"));
2057   }
2058
2059   combo = gtk_combo_new ();
2060   gtk_combo_set_popdown_strings (GTK_COMBO (combo), combo_list);
2061   gtk_widget_show (combo);
2062   gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1,
2063                   (GtkAttachOptions) (GTK_FILL),
2064                   (GtkAttachOptions) (0), 0, 0);
2065   gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (combo)->entry), FALSE);
2066   AddDialogData (combo, &m_nTextureCompressionFormat, DLG_COMBO_INT);
2067   g_list_free (combo_list);
2068
2069   // container
2070   table = gtk_table_new(2, 1, FALSE);
2071   gtk_widget_show(table);
2072   gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0);
2073   gtk_table_set_row_spacings (GTK_TABLE (table), 5);
2074   gtk_table_set_col_spacings (GTK_TABLE (table), 5);
2075
2076   // Startup shaders
2077   // label
2078   label = gtk_label_new (_("Startup Shaders:"));
2079   gtk_widget_show (label);
2080   gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
2081   gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
2082                   (GtkAttachOptions) (0),
2083                   (GtkAttachOptions) (0), 0, 0);
2084   gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
2085
2086   // combo list
2087   combo_list = NULL;
2088   combo_list = g_list_append (combo_list, (void *)_("None"));
2089   if (g_pGameDescription->mGameFile == "jk2.game" || g_pGameDescription->mGameFile == "ja.game")
2090     combo_list = g_list_append (combo_list, (void *)_("System"));
2091   else if (g_pGameDescription->mGameFile == "sof2.game")
2092     combo_list = g_list_append (combo_list, (void *)("Tools"));
2093   else
2094     combo_list = g_list_append (combo_list, (void *)_("Common"));
2095   combo_list = g_list_append (combo_list, (void *)_("All"));
2096   combo = gtk_combo_new ();
2097   gtk_combo_set_popdown_strings (GTK_COMBO (combo), combo_list);
2098   gtk_widget_show (combo);
2099   gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1,
2100                   (GtkAttachOptions) (GTK_FILL),
2101                   (GtkAttachOptions) (0), 0, 0);
2102   gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (combo)->entry), FALSE);
2103   AddDialogData (combo, &m_nLatchedShader, DLG_COMBO_INT);
2104   g_list_free (combo_list);
2105
2106   // Add the page to the notebook
2107   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
2108
2109   /******** Layout group *********/
2110   preflabel = gtk_label_new(_("Layout"));
2111   gtk_widget_show(preflabel);
2112   pageframe = gtk_frame_new(_("Layout"));
2113   gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5);
2114   gtk_widget_show(pageframe);
2115   vbox = gtk_vbox_new(FALSE, 5);
2116   gtk_widget_show(vbox);
2117   gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
2118   gtk_container_add(GTK_CONTAINER(pageframe), vbox);
2119
2120   // View types
2121   // table
2122   table = gtk_table_new (2, 4, FALSE);
2123   gtk_widget_show (table);
2124   gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0);
2125   gtk_table_set_row_spacings (GTK_TABLE (table), 5);
2126   gtk_table_set_col_spacings (GTK_TABLE (table), 5);
2127
2128   // view type 1
2129   pixmap = new_pixmap (g_pParentWnd->m_pWidget, "window1.bmp");
2130   gtk_widget_show (pixmap);
2131   gtk_table_attach (GTK_TABLE (table), pixmap, 0, 1, 0, 1,
2132                     (GtkAttachOptions) (0),
2133                     (GtkAttachOptions) (0), 0, 0);
2134
2135   // view type 2
2136   pixmap = new_pixmap (g_pParentWnd->m_pWidget, "window2.bmp");
2137   gtk_widget_show (pixmap);
2138   gtk_table_attach (GTK_TABLE (table), pixmap, 1, 2, 0, 1,
2139                     (GtkAttachOptions) (0),
2140                     (GtkAttachOptions) (0), 0, 0);
2141
2142   // view type 3
2143   pixmap = new_pixmap (g_pParentWnd->m_pWidget, "window3.bmp");
2144   gtk_widget_show (pixmap);
2145   gtk_table_attach (GTK_TABLE (table), pixmap, 2, 3, 0, 1,
2146                     (GtkAttachOptions) (0),
2147                     (GtkAttachOptions) (0), 0, 0);
2148
2149   // view type 4
2150   pixmap = new_pixmap (g_pParentWnd->m_pWidget, "window4.bmp");
2151   gtk_widget_show (pixmap);
2152   gtk_table_attach (GTK_TABLE (table), pixmap, 3, 4, 0, 1,
2153                     (GtkAttachOptions) (0),
2154                     (GtkAttachOptions) (0), 0, 0);
2155
2156   // view type 1 selector
2157   radio = gtk_radio_button_new (NULL);
2158   gtk_widget_show (radio);
2159   gtk_table_attach (GTK_TABLE (table), radio, 0, 1, 1, 2,
2160                     (GtkAttachOptions) (0),
2161                     (GtkAttachOptions) (0), 0, 0);
2162
2163   // view type 2 selector
2164   radio = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio));
2165   gtk_widget_show (radio);
2166   gtk_table_attach (GTK_TABLE (table), radio, 1, 2, 1, 2,
2167                     (GtkAttachOptions) (0),
2168                     (GtkAttachOptions) (0), 0, 0);
2169
2170   // view type 3 selector
2171   radio = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio));
2172   gtk_widget_show (radio);
2173   gtk_table_attach (GTK_TABLE (table), radio, 2, 3, 1, 2,
2174                     (GtkAttachOptions) (0),
2175                     (GtkAttachOptions) (0), 0, 0);
2176
2177   // view type 4 selector
2178   radio = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio));
2179   gtk_widget_show (radio);
2180   gtk_table_attach (GTK_TABLE (table), radio, 3, 4, 1, 2,
2181                     (GtkAttachOptions) (0),
2182                     (GtkAttachOptions) (0), 0, 0);
2183   AddDialogData (radio, &m_nLatchedView, DLG_RADIO_INT);
2184
2185   // Floating Z window
2186   check = gtk_check_button_new_with_label (_("Floating Z Window"));
2187   gtk_widget_show (check);
2188   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2189   AddDialogData (check, &m_bLatchedFloatingZ, DLG_CHECK_BOOL);
2190
2191   // show menu tear-off seperators
2192   check = gtk_check_button_new_with_label (_("Detachable Menus"));
2193   gtk_widget_show (check);
2194   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2195   AddDialogData (check, &m_bLatchedDetachableMenus, DLG_CHECK_BOOL);
2196
2197   if (!g_pGameDescription->mNoPatch)
2198   {
2199     // show patch toolbar
2200     check = gtk_check_button_new_with_label (_("Patch Toolbar"));
2201     gtk_widget_show (check);
2202     gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2203     g_object_set_data (G_OBJECT (dialog), "check_patchtoolbar", check); // Allow to be disabled for Q1/Q2
2204     AddDialogData (check, &m_bLatchedPatchToolbar, DLG_CHECK_BOOL);
2205   }
2206
2207   // use wide toolbar
2208   check = gtk_check_button_new_with_label (_("Wide Toolbar"));
2209   gtk_widget_show (check);
2210   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2211   AddDialogData (check, &m_bLatchedWideToolbar, DLG_CHECK_BOOL);
2212
2213   // use plugin toolbar
2214   check = gtk_check_button_new_with_label (_("Plugin Toolbar"));
2215   gtk_widget_show (check);
2216   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2217   AddDialogData (check, &m_bLatchedPluginToolbar, DLG_CHECK_BOOL);
2218
2219 #ifdef _WIN32
2220   // win32 file dialog
2221   check = gtk_check_button_new_with_label (_("Use win32 file load dialog"));
2222   gtk_widget_show (check);
2223   // gtk_container_add (GTK_CONTAINER (vbox), check);
2224   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
2225   AddDialogData (check, &m_bNativeGUI, DLG_CHECK_BOOL);
2226
2227   // position on primary monitor
2228   check = gtk_check_button_new_with_label (_("Start on Primary Monitor"));
2229   gtk_widget_show (check);
2230   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2231   g_object_set_data (G_OBJECT (dialog), "check_startonprimary", check);
2232   gtk_signal_connect( GTK_OBJECT (check), "clicked", GTK_SIGNAL_FUNC(UpdateSensitivity), this );
2233   AddDialogData (check, &m_bStartOnPrimMon, DLG_CHECK_BOOL);
2234 #endif
2235
2236   // Add the page to the notebook
2237   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
2238
2239   /******** Mouse group *********/
2240   preflabel = gtk_label_new(_("Mouse"));
2241   gtk_widget_show(preflabel);
2242   pageframe = gtk_frame_new(_("Mouse"));
2243   gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5);
2244   gtk_widget_show(pageframe);
2245   vbox = gtk_vbox_new(FALSE, 5);
2246   gtk_widget_show(vbox);
2247   gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
2248   gtk_container_add(GTK_CONTAINER(pageframe), vbox);
2249
2250   // Buttons
2251   // container
2252   hbox2 = gtk_hbox_new (FALSE, 5);
2253   gtk_widget_show (hbox2);
2254   gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0);
2255
2256   // 2 button radio
2257   radio = gtk_radio_button_new_with_label (NULL, _("2 button"));
2258   gtk_widget_show (radio);
2259   gtk_box_pack_start (GTK_BOX (hbox2), radio, FALSE, FALSE, 0);
2260
2261   // 3 button radio
2262   radio = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio), _("3 button"));
2263   gtk_widget_show (radio);
2264   gtk_box_pack_start (GTK_BOX (hbox2), radio, FALSE, FALSE, 0);
2265   AddDialogData (radio, &m_nMouse, DLG_RADIO_INT);
2266
2267   // right click to drop entity
2268   check = gtk_check_button_new_with_label (_("Right click to drop entities"));
2269   gtk_widget_show (check);
2270   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
2271   AddDialogData (check, &m_bRightClick, DLG_CHECK_BOOL);
2272
2273   // Mouse chaser (and this does what?)
2274   check = gtk_check_button_new_with_label (_("Mouse chaser"));
2275   gtk_widget_show (check);
2276   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
2277   AddDialogData (check, &m_bChaseMouse, DLG_CHECK_BOOL);
2278
2279   // Alt + multi-drag
2280   check = gtk_check_button_new_with_label (_("ALT + multi-drag"));
2281   gtk_widget_show (check);
2282   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
2283   AddDialogData (check, &m_bALTEdge, DLG_CHECK_BOOL);
2284
2285   // Mouse wheel increments
2286   // container
2287   hbox2 = gtk_hbox_new (FALSE, 5);
2288   gtk_widget_show (hbox2);
2289   gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0);
2290
2291   // label
2292   label = gtk_label_new (_("Wheel Mouse inc:"));
2293   gtk_widget_show (label);
2294   gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
2295
2296   // entry
2297   entry = gtk_entry_new ();
2298   gtk_widget_show (entry);
2299   gtk_widget_set_usize (entry, 40, -2);
2300   gtk_box_pack_start (GTK_BOX (hbox2), entry, FALSE, FALSE, 0);
2301   AddDialogData (entry, &m_nWheelInc, DLG_ENTRY_INT);
2302
2303   // Add the page to the notebook
2304   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
2305
2306   /******** Editing group *********/
2307   preflabel = gtk_label_new(_("Editing"));
2308   gtk_widget_show(preflabel);
2309   pageframe = gtk_frame_new(_("Editing"));
2310   gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5);
2311   gtk_widget_show(pageframe);
2312   vbox = gtk_vbox_new(FALSE, 5);
2313   gtk_widget_show(vbox);
2314   gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
2315   gtk_container_add(GTK_CONTAINER(pageframe), vbox);
2316
2317   // Vertex editing splits faces
2318   check = gtk_check_button_new_with_label (_("Vertex editing splits face"));
2319   gtk_widget_show (check);
2320   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
2321   AddDialogData (check, &m_bVertexSplit, DLG_CHECK_BOOL);
2322
2323   // Fix target/targetname collisions
2324   check = gtk_check_button_new_with_label (_("Fix target/targetname collisions"));
2325   gtk_widget_show (check);
2326   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
2327   AddDialogData (check, &m_bDoTargetFix, DLG_CHECK_BOOL);
2328
2329   // Clipper tool uses caulk
2330   check = gtk_check_button_new_with_label (_("Clipper tool uses caulk"));
2331   gtk_widget_show (check);
2332   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
2333   AddDialogData (check, &m_bClipCaulk, DLG_CHECK_BOOL);
2334
2335   // Don't clamp plane points
2336   check = gtk_check_button_new_with_label (_("Don't clamp plane points"));
2337   gtk_widget_show (check);
2338   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
2339   AddDialogData (check, &m_bNoClamp, DLG_CHECK_BOOL);
2340
2341   // Snap to grid
2342   check = gtk_check_button_new_with_label (_("Snap to grid"));
2343   gtk_widget_show (check);
2344   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
2345   AddDialogData (check, &m_bSnap, DLG_CHECK_BOOL);
2346
2347   // Select patch by bounding box
2348   check = gtk_check_button_new_with_label (_("Select patches by bounding box"));
2349   gtk_widget_show (check);
2350   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2351   AddDialogData (check, &m_bPatchBBoxSelect, DLG_CHECK_BOOL);
2352
2353   // Rotation increment
2354   // container
2355   table = gtk_table_new (2, 3, FALSE);
2356   gtk_widget_show (table);
2357   gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0);
2358   gtk_table_set_row_spacings (GTK_TABLE (table), 5);
2359   gtk_table_set_col_spacings (GTK_TABLE (table), 5);
2360
2361   // label
2362   label = gtk_label_new (_("Rotation increment:"));
2363   gtk_widget_show (label);
2364   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
2365                    (GtkAttachOptions) (0),
2366                    (GtkAttachOptions) (0), 0, 0);
2367
2368   // entry
2369   entry = gtk_entry_new ();
2370   gtk_widget_show (entry);
2371   gtk_widget_set_usize (entry, 60, -2);
2372   gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1,
2373                    (GtkAttachOptions) (GTK_FILL),
2374                    (GtkAttachOptions) (0), 0, 0);
2375   AddDialogData (entry, &m_nRotation, DLG_ENTRY_INT);
2376
2377   // Undo levels
2378   // label
2379   label = gtk_label_new (_("Undo Levels:"));
2380   gtk_widget_show (label);
2381   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
2382                    (GtkAttachOptions) (0),
2383                    (GtkAttachOptions) (0), 0, 0);
2384
2385   // spinner (allows undo levels to be set to zero)
2386   spin = gtk_spin_button_new (GTK_ADJUSTMENT (gtk_adjustment_new (1, 0, 64, 1, 10, 10)), 1, 0);
2387   gtk_widget_show (spin);
2388   gtk_table_attach (GTK_TABLE (table), spin, 1, 2, 1, 2,
2389                    (GtkAttachOptions) (GTK_FILL),
2390                    (GtkAttachOptions) (0), 0, 0);
2391   gtk_widget_set_usize (spin, 60, -2);
2392   AddDialogData (spin, &m_nUndoLevels, DLG_SPIN_INT);
2393
2394   // Patch subdivisions
2395   // label
2396   label = gtk_label_new (_("Patch subdivisions:"));
2397   gtk_widget_show (label);
2398   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
2399                    (GtkAttachOptions) (0),
2400                    (GtkAttachOptions) (0), 0, 0);
2401
2402   // entry (spinner perhaps? [2-16])
2403   entry = gtk_entry_new ();
2404   gtk_widget_show (entry);
2405   gtk_widget_set_usize (entry, 60, -2);
2406   gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 2, 3,
2407                    (GtkAttachOptions) (GTK_FILL),
2408                    (GtkAttachOptions) (0), 0, 0);
2409   AddDialogData (entry, &m_nSubdivisions, DLG_ENTRY_INT);
2410
2411   // Add the page to the notebook
2412   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
2413
2414   /******** Save/Load group *********/
2415   preflabel = gtk_label_new(_("Startup/Auto save"));
2416   gtk_widget_show(preflabel);
2417   pageframe = gtk_frame_new(_("Startup/Auto save"));
2418   gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5);
2419   gtk_widget_show(pageframe);
2420   vbox = gtk_vbox_new(FALSE, 5);
2421   gtk_widget_show(vbox);
2422   gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
2423   gtk_container_add(GTK_CONTAINER(pageframe), vbox);
2424
2425   // Snapshots
2426   check = gtk_check_button_new_with_label (_("Snapshots"));
2427   gtk_widget_show (check);
2428   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2429   AddDialogData (check, &m_bSnapShots, DLG_CHECK_BOOL);
2430
2431   // load last project on open
2432   check = gtk_check_button_new_with_label (_("Load last project on open"));
2433   gtk_widget_show (check);
2434   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2435   AddDialogData (check, &m_bLoadLast, DLG_CHECK_BOOL);
2436
2437   // load last map on open
2438   check = gtk_check_button_new_with_label (_("Load last map on open"));
2439   gtk_widget_show (check);
2440   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2441   AddDialogData (check, &m_bLoadLastMap, DLG_CHECK_BOOL);
2442
2443   // Auto save..
2444   // container
2445   hbox2 = gtk_hbox_new (FALSE, 5);
2446   gtk_widget_show (hbox2);
2447   gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0);
2448   gtk_container_set_border_width (GTK_CONTAINER (hbox2), 0);
2449
2450   // label
2451   check = gtk_check_button_new_with_label (_("Auto save every"));
2452   gtk_widget_show (check);
2453   gtk_box_pack_start (GTK_BOX (hbox2), check, FALSE, FALSE, 0);
2454   AddDialogData (check, &m_bAutoSave, DLG_CHECK_BOOL);
2455
2456   // spinner
2457   spin = gtk_spin_button_new (GTK_ADJUSTMENT (gtk_adjustment_new (1, 1, 60, 1, 10, 10)), 1, 0);
2458   gtk_widget_show (spin);
2459   gtk_box_pack_start (GTK_BOX (hbox2), spin, FALSE, FALSE, 0);
2460   gtk_widget_set_usize (spin, 60, -2);
2461   AddDialogData (spin, &m_nAutoSave, DLG_SPIN_INT);
2462
2463   // label
2464   label = gtk_label_new (_("minutes"));
2465   gtk_widget_show (label);
2466   gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
2467
2468   // Add the page to the notebook
2469   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
2470
2471   /******** Paths group *********/
2472   preflabel = gtk_label_new(_("Paths"));
2473   gtk_widget_show(preflabel);
2474   pageframe = gtk_frame_new(_("Paths"));
2475   gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5);
2476   gtk_widget_show(pageframe);
2477   vbox = gtk_vbox_new(FALSE, 5);
2478   gtk_widget_show(vbox);
2479   gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
2480   gtk_container_add(GTK_CONTAINER(pageframe), vbox);
2481
2482   // prefab path
2483   // table
2484   table = gtk_table_new (3, 3, FALSE);
2485   gtk_widget_show (table);
2486   gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0);
2487   gtk_table_set_row_spacings (GTK_TABLE (table), 5);
2488   gtk_table_set_col_spacings (GTK_TABLE (table), 5);
2489
2490   // label
2491   label = gtk_label_new (_("Prefab path:"));
2492   gtk_widget_show (label);
2493   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
2494                    (GtkAttachOptions) (0),
2495                    (GtkAttachOptions) (0), 0, 0);
2496   gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
2497
2498   // path entry
2499   entry = gtk_entry_new ();
2500   gtk_widget_show (entry);
2501   gtk_widget_set_usize(GTK_WIDGET(entry), 240, -2);
2502   gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1,
2503                    (GtkAttachOptions) (GTK_FILL),
2504                    (GtkAttachOptions) (0), 1, 0);
2505   AddDialogData (entry, &m_strPrefabPath, DLG_ENTRY_TEXT);
2506
2507 #if 0
2508   // browse button
2509   button = gtk_button_new_with_label ("...");
2510   gtk_widget_show (button);
2511   gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (OnBtnBrowseprefab), this);
2512   gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
2513                    (GtkAttachOptions) (0),
2514                    (GtkAttachOptions) (0), 0, 0);
2515 #endif
2516
2517   // User ini path
2518   // label
2519   label = gtk_label_new (_("User INI path:"));
2520   gtk_widget_show (label);
2521   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
2522                    (GtkAttachOptions) (0),
2523                    (GtkAttachOptions) (0), 0, 0);
2524   gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
2525
2526   // user ini path entry
2527   entry = gtk_entry_new ();
2528   gtk_widget_show (entry);
2529   gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 1, 2,
2530                    (GtkAttachOptions) (GTK_FILL),
2531                    (GtkAttachOptions) (0), 1, 0);
2532   AddDialogData (entry, &m_strUserPath, DLG_ENTRY_TEXT);
2533
2534   // user ini browse button
2535   button = gtk_button_new_with_label ("...");
2536   gtk_widget_show (button);
2537   gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (OnBtnBrowseuserini), this);
2538   gtk_table_attach (GTK_TABLE (table), button, 2, 3, 1, 2,
2539                    (GtkAttachOptions) (0),
2540                    (GtkAttachOptions) (0), 0, 0);
2541
2542   // Add the page to the notebook
2543   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
2544
2545   /******** Misc group *********/
2546   preflabel = gtk_label_new(_("Misc"));
2547   gtk_widget_show(preflabel);
2548   pageframe = gtk_frame_new(_("Misc"));
2549   gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5);
2550   gtk_widget_show(pageframe);
2551   vbox = gtk_vbox_new(FALSE, 5);
2552   gtk_widget_show(vbox);
2553   gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
2554   gtk_container_add(GTK_CONTAINER(pageframe), vbox);
2555
2556   // Light drawing
2557   check = gtk_check_button_new_with_label (_("Light drawing"));
2558   gtk_widget_show (check);
2559   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2560   AddDialogData (check, &m_bNewLightDraw, DLG_CHECK_BOOL);
2561
2562   // Light radiuses
2563   // container
2564   table = gtk_table_new(2, 1, FALSE);
2565   gtk_widget_show(table);
2566   gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0);
2567   gtk_table_set_row_spacings (GTK_TABLE (table), 5);
2568   gtk_table_set_col_spacings (GTK_TABLE (table), 5);
2569
2570   label = gtk_label_new (_("Light radiuses:"));
2571   gtk_widget_show (label);
2572   gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
2573   gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
2574                   (GtkAttachOptions) (0),
2575                   (GtkAttachOptions) (0), 0, 0);
2576
2577   combo_list = NULL;
2578   combo_list = g_list_append (combo_list, (void *)_("Disabled"));
2579   combo_list = g_list_append (combo_list, (void *)_("True Q3Map2 Style"));
2580   combo_list = g_list_append (combo_list, (void *)_("Classic Style"));
2581
2582   combo = gtk_combo_new ();
2583   gtk_combo_set_popdown_strings (GTK_COMBO (combo), combo_list);
2584   gtk_widget_show (combo);
2585   gtk_table_attach(GTK_TABLE(table), combo, 1, 2, 0, 1,
2586                   (GtkAttachOptions) (GTK_FILL),
2587                   (GtkAttachOptions) (0), 0, 0);
2588   gtk_entry_set_editable (GTK_ENTRY (GTK_COMBO (combo)->entry), FALSE);
2589   AddDialogData (combo, &m_nLightRadiuses, DLG_COMBO_INT);
2590
2591 #ifdef _WIN32
2592   check = gtk_check_button_new_with_label (_("Use win32 file associations to open text files instead of builtin editor"));
2593   gtk_widget_show(check);
2594   gtk_box_pack_start(GTK_BOX (vbox), check, FALSE, FALSE, 0);
2595   AddDialogData (check, &g_PrefsDlg.m_bUseWin32Editor, DLG_CHECK_BOOL);
2596 #else
2597   // use custom shader editor
2598   check = gtk_check_button_new_with_label (_("Use Custom Shader Editor"));
2599   gtk_widget_show(check);
2600   gtk_box_pack_start(GTK_BOX (vbox), check, FALSE, FALSE, 0);
2601   gtk_signal_connect( GTK_OBJECT (check), "clicked", GTK_SIGNAL_FUNC(UpdateEditorSensitivity), this);
2602   g_object_set_data (G_OBJECT(dialog), "check_customeditor", check);
2603   AddDialogData (check, &g_PrefsDlg.m_bUseCustomEditor, DLG_CHECK_BOOL);
2604
2605   // custom shader editor executable
2606   // table
2607   table = gtk_table_new (3, 1, FALSE);
2608   gtk_widget_show (table);
2609   gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, TRUE, 0);
2610   gtk_table_set_row_spacings (GTK_TABLE (table), 5);
2611   gtk_table_set_col_spacings (GTK_TABLE (table), 5);
2612
2613   // label
2614   label = gtk_label_new(_("Custom Editor Command"));
2615   gtk_widget_show(label);
2616   gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
2617                    (GtkAttachOptions) (0),
2618                    (GtkAttachOptions) (0), 0, 0);
2619   gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
2620   g_object_set_data (G_OBJECT(dialog), "label_customeditor", label);
2621   gtk_widget_set_sensitive (label, g_PrefsDlg.m_bUseCustomEditor);
2622
2623   // custom editor command entry
2624   entry = gtk_entry_new ();
2625   gtk_widget_show (entry);
2626   gtk_widget_set_usize(GTK_WIDGET(entry), 240, -2);
2627   gtk_table_attach (GTK_TABLE (table), entry, 1, 2, 0, 1,
2628                    (GtkAttachOptions) (GTK_FILL),
2629                    (GtkAttachOptions) (0), 1, 0);
2630   AddDialogData (entry, &m_strEditorCommand, DLG_ENTRY_TEXT);
2631   gtk_widget_set_sensitive (entry, g_PrefsDlg.m_bUseCustomEditor);
2632   g_object_set_data (G_OBJECT(dialog), "entry_customeditor", entry);
2633
2634   // browse button
2635   button = gtk_button_new_with_label (_("..."));
2636   gtk_widget_show (button);
2637   gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (OnBtnBrowseEditor), this);
2638   gtk_table_attach (GTK_TABLE (table), button, 2, 3, 0, 1,
2639                    (GtkAttachOptions) (0),
2640                    (GtkAttachOptions) (0), 0, 0);
2641   g_object_set_data (G_OBJECT(dialog), "button_customeditor", button);
2642   gtk_widget_set_sensitive (button, g_PrefsDlg.m_bUseCustomEditor);
2643 #endif
2644
2645   // Add the page to the notebook
2646   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
2647
2648   /******** BSP Monitoring group *********/
2649   // this is never displayed if the plugin isn't available
2650   preflabel = gtk_label_new(_("BSP Monitoring"));
2651   gtk_widget_show(preflabel);
2652   pageframe = gtk_frame_new(_("BSP Monitoring"));
2653   gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5);
2654   gtk_widget_show(pageframe);
2655   vbox = gtk_vbox_new(FALSE, 5);
2656   gtk_widget_show(vbox);
2657   gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
2658   gtk_container_add(GTK_CONTAINER(pageframe), vbox);
2659
2660   // Enable BSP process monitoring
2661   check = gtk_check_button_new_with_label (_("Enable BSP process monitoring"));
2662   gtk_widget_show (check);
2663   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2664   g_object_set_data (G_OBJECT (dialog), "check_monitorbsp", check);
2665   gtk_signal_connect( GTK_OBJECT (check), "clicked", GTK_SIGNAL_FUNC(UpdateSensitivity), this );
2666   AddDialogData (check, &g_PrefsDlg.m_bWatchBSP, DLG_CHECK_BOOL);
2667
2668   // Stop on leak
2669   check = gtk_check_button_new_with_label (_("Stop compilation on leak"));
2670   gtk_widget_show (check);
2671   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2672   g_object_set_data (G_OBJECT (dialog), "check_leakstop", check);
2673   AddDialogData (check, &g_PrefsDlg.m_bLeakStop, DLG_CHECK_BOOL);
2674
2675   // engine after compile
2676   check = gtk_check_button_new_with_label (_("Run engine after compile"));
2677   gtk_widget_show (check);
2678   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2679   g_object_set_data (G_OBJECT (dialog), "check_runengine", check);
2680   gtk_signal_connect( GTK_OBJECT (check), "clicked", GTK_SIGNAL_FUNC(UpdateSensitivity), this );
2681   AddDialogData( check, &g_PrefsDlg.m_bRunQuake, DLG_CHECK_BOOL );
2682
2683   // sleep mode when running engine
2684   check = gtk_check_button_new_with_label (_("Activate sleep mode when running the engine"));
2685   gtk_widget_show (check);
2686   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2687   g_object_set_data (G_OBJECT (dialog), "check_sleep", check);
2688   AddDialogData( check, &g_PrefsDlg.m_bDoSleep, DLG_CHECK_BOOL );
2689
2690   // use q3map2's texture projection
2691   check = gtk_check_button_new_with_label (_("Texturing compatible with q3map2"));
2692   gtk_widget_show (check);
2693   gtk_box_pack_start (GTK_BOX (vbox), check, FALSE, FALSE, 0);
2694   g_object_set_data (G_OBJECT (dialog), "check_q3map2", check);
2695   AddDialogData( check, &g_PrefsDlg.m_bQ3Map2Texturing, DLG_CHECK_BOOL );
2696
2697   // Add the page to the notebook
2698   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
2699
2700   gtk_notebook_set_page(GTK_NOTEBOOK(notebook), PTAB_FRONT);
2701
2702   return;
2703 }
2704
2705 // end new prefs dialog
2706
2707 void PrefsDlg::LoadTexdefPref(texdef_t* pTexdef, char* pName)
2708 {
2709   char buffer[256];
2710
2711   memset(pTexdef, 0, sizeof(texdef_t));
2712
2713   sprintf(buffer, "%s%s", pName, TD_SCALE1_KEY);
2714   mLocalPrefs.GetPref(buffer, &pTexdef->scale[0],   0.5f);
2715
2716   sprintf(buffer, "%s%s", pName, TD_SCALE2_KEY);
2717   mLocalPrefs.GetPref(buffer, &pTexdef->scale[1],   0.5f);
2718
2719   sprintf(buffer, "%s%s", pName, TD_SHIFT1_KEY);
2720   mLocalPrefs.GetPref(buffer, &pTexdef->shift[0],   8.f);
2721
2722   sprintf(buffer, "%s%s", pName, TD_SHIFT2_KEY);
2723   mLocalPrefs.GetPref(buffer, &pTexdef->shift[1],   8.f);
2724
2725   sprintf(buffer, "%s%s", pName, TD_ROTATE_KEY);
2726   mLocalPrefs.GetPref(buffer, &pTexdef->rotate,     45);
2727 }
2728
2729 void PrefsDlg::UpdateTextureCompression()
2730 {
2731   // if OpenGL is not ready yet, don't do anything
2732   if (!g_qeglobals.m_bOpenGLReady) {
2733     Sys_Printf("OpenGL not ready - postpone texture compression capability check\n");
2734     return;
2735   }
2736
2737   if (g_qeglobals.bTextureCompressionSupported)
2738   {
2739     if (m_nTextureCompressionFormat >= 2 && !g_qeglobals.m_bS3CompressionSupported)
2740     {
2741       Sys_Printf("Inconsistant pref setting for texture compression (%d), rolling back\n", m_nTextureCompressionFormat);
2742       m_nTextureCompressionFormat = 1; // if this is not supported either, see below
2743     }
2744     if (m_nTextureCompressionFormat == 1 && !g_qeglobals.m_bOpenGLCompressionSupported)
2745     {
2746       Sys_Printf("Inconsistant pref setting for texture compression (GL_COMPRESSED_RGBA), rolling back\n");
2747       m_nTextureCompressionFormat = 0;
2748     }
2749     switch (m_nTextureCompressionFormat)
2750     {
2751     case (0):
2752       {
2753         g_qeglobals.texture_components = GL_RGBA;
2754         Sys_Printf("texture compression disabled by preferences settings\n");
2755         break;
2756       }
2757     case (1):
2758       {
2759         g_qeglobals.texture_components = GL_COMPRESSED_RGBA;
2760         Sys_Printf("OpenGL texture compression enabled\n");
2761         break;
2762       }
2763     case (2):
2764       {
2765         g_qeglobals.texture_components = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
2766         Sys_Printf("S3TC DXT1 texture compression enabled\n");
2767         break;
2768       }
2769     case (3):
2770       {
2771         g_qeglobals.texture_components = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
2772         Sys_Printf("S3TC DXT3 texture compression enabled\n");
2773         break;
2774       }
2775     case (4):
2776       {
2777         g_qeglobals.texture_components = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
2778         Sys_Printf("S3TC DXT5 texture compression enabled\n");
2779         break;
2780       }
2781     }
2782   }
2783   else
2784   {
2785     Sys_Printf("texture compression is not supported by your current graphic card/drivers\n");
2786     g_qeglobals.texture_components = GL_RGBA;
2787     m_nTextureCompressionFormat = 0;
2788   }
2789 }
2790
2791 #ifdef ATIHACK_812
2792 void PrefsDlg::UpdateATIHack() {
2793   // if OpenGL is not ready yet, don't do anything
2794   if (!g_qeglobals.m_bOpenGLReady) {
2795     Sys_Printf("OpenGL not ready - postpone ATI bug workaround setup\n");
2796     return;
2797   }
2798
2799   if (m_bGlATIHack) {
2800     qglCullFace = &qglCullFace_ATIHack;
2801     qglDisable = &qglDisable_ATIHack;
2802     qglEnable = &qglEnable_ATIHack;
2803     qglPolygonMode = &qglPolygonMode_ATIHack;
2804     Sys_Printf("ATI bug workaround enabled\n");
2805   } else {
2806     qglCullFace = qglCullFace_real;
2807     qglDisable = qglDisable_real;
2808     qglEnable = qglEnable_real;
2809     qglPolygonMode = qglPolygonMode_real;
2810     Sys_Printf("ATI bug workaround disabled\n");
2811   }
2812 }
2813 #endif
2814
2815 // TTimo: m_strEnginePath has a special status, if not found in registry we need to
2816 // initiliaze it for sure. It is not totally failsafe but we can use the same
2817 // code than in q3map, expecting to find some "quake" above us. If not, we prompt
2818 // for the engine executable path
2819 void PrefsDlg::LoadPrefs ()
2820 {
2821   int i;
2822
2823   // first things first, load prefs from global prefs
2824   mGamesDialog.LoadPrefs();
2825
2826   // if we already have a document loaded, we will free and reload from file
2827   if (mLocalPrefs.InUse()) {
2828     mLocalPrefs.Clear();
2829   }
2830
2831   // load local.pref file
2832   mLocalPrefs.ReadXMLFile(m_inipath->str);
2833
2834   mLocalPrefs.GetPref(PATCHSHOWBOUNDS_KEY,  &g_bPatchShowBounds,  FALSE);
2835   mLocalPrefs.GetPref(MOUSE_KEY,            &m_nMouse,            MOUSE_DEF);
2836   m_nMouseButtons = m_nMouse ? 3 : 2;
2837
2838         // project file
2839         // if it's not found here, mainframe.cpp will take care of finding one
2840   mLocalPrefs.GetPref(LASTPROJ_KEY, &m_strLastProject, "");
2841   mLocalPrefs.GetPref(LASTPROJVER_KEY, &m_nLastProjectVer, -1);
2842
2843         // prefab path
2844   // NOTE TTimo: I'm not sure why this is in prefs
2845   // should probably be a project setting
2846   // and I'm not sure that we really have a way to set this reliably either
2847   CString strPrefab;
2848   strPrefab = g_qeglobals.m_strHomeGame.GetBuffer();
2849   strPrefab += g_pGameDescription->mBaseGame.GetBuffer();
2850   strPrefab += "/prefabs/";
2851   mLocalPrefs.GetPref(PREFAB_KEY, &m_strPrefabPath, strPrefab);
2852
2853   mLocalPrefs.GetPref(LASTLIGHTINTENSITY_KEY, &m_iLastLightIntensity, 300);
2854   mLocalPrefs.GetPref(TLOCK_KEY,              &m_bTextureLock,        TLOCK_DEF);
2855   mLocalPrefs.GetPref(RLOCK_KEY,              &m_bRotateLock,         TLOCK_DEF);
2856   mLocalPrefs.GetPref(LASTMAP_KEY,            &m_strLastMap,          "");
2857   mLocalPrefs.GetPref(LOADLAST_KEY,           &m_bLoadLast,           LOADLAST_DEF);
2858   mLocalPrefs.GetPref(BSP_KEY,                &m_bInternalBSP,        FALSE);
2859   mLocalPrefs.GetPref(RCLICK_KEY,             &m_bRightClick,         TRUE);
2860   mLocalPrefs.GetPref(AUTOSAVE_KEY,           &m_bAutoSave,           TRUE);
2861   mLocalPrefs.GetPref(LOADLASTMAP_KEY,        &m_bLoadLastMap,        FALSE);
2862   mLocalPrefs.GetPref(TINYBRUSH_KEY,          &m_bCleanTiny,          FALSE);
2863   mLocalPrefs.GetPref(TINYSIZE_KEY,           &m_fTinySize,           0.5f);
2864   mLocalPrefs.GetPref(AUTOSAVETIME_KEY,       &m_nAutoSave,           5);
2865   mLocalPrefs.GetPref(SNAPSHOT_KEY,           &m_bSnapShots,          FALSE);
2866   mLocalPrefs.GetPref(MOVESPEED_KEY,          &m_nMoveSpeed,          100);
2867   mLocalPrefs.GetPref(ANGLESPEED_KEY,         &m_nAngleSpeed,         3);
2868   mLocalPrefs.GetPref(SETGAME_KEY,            &m_bSetGame,            FALSE);
2869   mLocalPrefs.GetPref(CAMXYUPDATE_KEY,        &m_bCamXYUpdate,        TRUE);
2870   mLocalPrefs.GetPref(CAMDRAGMULTISELECT_KEY, &m_nCamDragMultiSelect, TRUE);
2871   mLocalPrefs.GetPref(CAMFREELOOK_KEY,        &m_bCamFreeLook,        TRUE);
2872   mLocalPrefs.GetPref(CAMINVERSEMOUSE_KEY,    &m_bCamInverseMouse,    FALSE);
2873   mLocalPrefs.GetPref(CAMDISCRETE_KEY,        &m_bCamDiscrete,        TRUE);
2874   mLocalPrefs.GetPref(LIGHTDRAW_KEY,          &m_bNewLightDraw,       TRUE);
2875   mLocalPrefs.GetPref(CUBICCLIP_KEY,          &m_bCubicClipping,      TRUE);
2876   mLocalPrefs.GetPref(CUBICSCALE_KEY,         &m_nCubicScale,         13);
2877   mLocalPrefs.GetPref(ALTEDGE_KEY,            &m_bALTEdge,            FALSE);
2878   mLocalPrefs.GetPref(FACECOLORS_KEY,         &m_bFaceColors,         FALSE);
2879   mLocalPrefs.GetPref(XZVIS_KEY,              &m_bXZVis,              FALSE);
2880   mLocalPrefs.GetPref(YZVIS_KEY,              &m_bYZVis,              FALSE);
2881   mLocalPrefs.GetPref(ZVIS_KEY,               &m_bZVis,               FALSE);
2882   mLocalPrefs.GetPref(SIZEPAINT_KEY,          &m_bSizePaint,                  FALSE);
2883   mLocalPrefs.GetPref(DLLENTITIES_KEY,        &m_bDLLEntities,                FALSE);
2884
2885   mLocalPrefs.GetPref(DETACHABLEMENUS_KEY,    &m_bLatchedDetachableMenus,            TRUE);
2886   m_bDetachableMenus = m_bLatchedDetachableMenus;
2887
2888   if (g_pGameDescription->mNoPatch)
2889   {
2890     m_bPatchToolbar = false;
2891   }
2892   else
2893   {
2894     mLocalPrefs.GetPref(PATCHTOOLBAR_KEY,       &m_bLatchedPatchToolbar,               TRUE);
2895     m_bPatchToolbar = m_bLatchedPatchToolbar;
2896   }
2897
2898   mLocalPrefs.GetPref(WIDETOOLBAR_KEY,        &m_bLatchedWideToolbar,                TRUE);
2899   m_bWideToolbar = m_bLatchedWideToolbar;
2900
2901   mLocalPrefs.GetPref(PLUGINTOOLBAR_KEY, &m_bLatchedPluginToolbar, TRUE);
2902   m_bPluginToolbar = m_bLatchedPluginToolbar;
2903
2904   mLocalPrefs.GetPref(WINDOW_KEY,             (int*)&m_nLatchedView,  WINDOW_DEF);
2905   m_nView = m_nLatchedView;
2906
2907   mLocalPrefs.GetPref(FLOATINGZ_KEY,          &m_bLatchedFloatingZ,           FALSE);
2908   m_bFloatingZ = m_bLatchedFloatingZ;
2909
2910   mLocalPrefs.GetPref(TEXTUREQUALITY_KEY,     &m_nLatchedTextureQuality,             3);
2911   m_nTextureQuality = m_nLatchedTextureQuality;
2912
2913   mLocalPrefs.GetPref(LOADSHADERS_KEY,        &m_nLatchedShader,                     0);
2914   m_nShader = m_nLatchedShader;
2915
2916   mLocalPrefs.GetPref(NOCLAMP_KEY,            &m_bNoClamp,                    FALSE);
2917   mLocalPrefs.GetPref(SNAP_KEY,               &m_bSnap,                       TRUE);
2918   mLocalPrefs.GetPref(USERINI_KEY,            &m_strUserPath,                 "");
2919   mLocalPrefs.GetPref(ROTATION_KEY,           &m_nRotation,                   45);
2920   mLocalPrefs.GetPref(CHASEMOUSE_KEY,         &m_bChaseMouse,                 TRUE);
2921   mLocalPrefs.GetPref(ENTITYSHOW_KEY,         &m_nEntityShowState,            ENTITY_SKINNED_BOXED);
2922
2923   // this will probably need to be 75 or 100 for Q1.
2924   mLocalPrefs.GetPref(TEXTURESCALE_KEY,       &m_nTextureScale,               50);
2925
2926   // FIXME: Hydra - actually, this stuff is Q1,Q2 and HL specific.
2927   if ( (g_pGameDescription->mGameFile == "hl.game") )
2928   {
2929     // No BSP monitoring in the default compiler tools for Half-life (yet)
2930     mLocalPrefs.GetPref(WATCHBSP_KEY,           &m_bWatchBSP,                   FALSE);
2931
2932     // Texture subset on by default (HL specific really, because of halflife.wad's size)
2933     mLocalPrefs.GetPref(TEXTURE_KEY,            &m_bTextureWindow,              TRUE);
2934   }
2935   else if (g_pGameDescription->quake2)
2936   {
2937     // BSP monitoring is implemented in Quake2 and Heretic2 tools
2938     mLocalPrefs.GetPref(WATCHBSP_KEY,           &m_bWatchBSP,                   TRUE);
2939
2940     // Texture subset on by default (HL specific really, because of halflife.wad's size)
2941     mLocalPrefs.GetPref(TEXTURE_KEY,            &m_bTextureWindow,              TRUE);
2942   }
2943   else
2944   {
2945     mLocalPrefs.GetPref(WATCHBSP_KEY,           &m_bWatchBSP,                   WATCHBSP_DEF);
2946     mLocalPrefs.GetPref(TEXTURE_KEY,            &m_bTextureWindow,              FALSE);
2947   }
2948
2949
2950   mLocalPrefs.GetPref(TEXTURESCROLLBAR_KEY,   &m_bTextureScrollbar,           TRUE);
2951   mLocalPrefs.GetPref(DISPLAYLISTS_KEY,       &m_bDisplayLists,               TRUE);
2952   mLocalPrefs.GetPref(ANTIALIASEDLINES_KEY,   &m_bAntialiasedPointsAndLines,  FALSE);
2953   mLocalPrefs.GetPref(SWITCHCLIP_KEY,         &m_bSwitchClip,                 TRUE);
2954   mLocalPrefs.GetPref(SELWHOLEENTS_KEY,       &m_bSelectWholeEntities,        TRUE);
2955   mLocalPrefs.GetPref(SHOWSHADERS_KEY,        &m_bShowShaders,                TRUE);
2956   mLocalPrefs.GetPref(GLLIGHTING_KEY,         &m_bGLLighting,                 FALSE);
2957   mLocalPrefs.GetPref(NOSTIPPLE_KEY,          &m_bNoStipple,                  FALSE);
2958   mLocalPrefs.GetPref(UNDOLEVELS_KEY,         &m_nUndoLevels,                 30);
2959   mLocalPrefs.GetPref(VERTEXMODE_KEY,         &m_bVertexSplit,                TRUE);
2960   mLocalPrefs.GetPref(RUNQ2_KEY,              &m_bRunQuake,                   RUNQ2_DEF);
2961   mLocalPrefs.GetPref(LEAKSTOP_KEY,           &m_bLeakStop,                   TRUE);
2962   mLocalPrefs.GetPref(DOSLEEP_KEY,            &m_bDoSleep,                    FALSE);
2963   mLocalPrefs.GetPref(SELECTCURVES_KEY,       &m_bSelectCurves,               TRUE);
2964   mLocalPrefs.GetPref(SELECTMODELS_KEY,       &m_bSelectModels,               TRUE);
2965   mLocalPrefs.GetPref(SHADERLISTONLY_KEY,     &m_bTexturesShaderlistOnly,     FALSE);
2966   mLocalPrefs.GetPref(SUBDIVISIONS_KEY,       &m_nSubdivisions,               SUBDIVISIONS_DEF);
2967   mLocalPrefs.GetPref(CLIPCAULK_KEY,          &m_bClipCaulk,                  FALSE);
2968   mLocalPrefs.GetPref(SNAPTTOGRID_KEY,        &m_bSnapTToGrid,                FALSE);
2969   mLocalPrefs.GetPref(TARGETFIX_KEY,          &m_bDoTargetFix,                TRUE);
2970   mLocalPrefs.GetPref(WHEELINC_KEY,           &m_nWheelInc,                   64);
2971   mLocalPrefs.GetPref(PATCHBBOXSEL_KEY,       &m_bPatchBBoxSelect,            FALSE);
2972
2973   // Gef: Kyro GL_POINT workaround
2974   mLocalPrefs.GetPref(GLPOINTWORKAROUND_KEY,  &m_bGlPtWorkaround,             FALSE);
2975
2976   // window positioning
2977   mLocalPrefs.GetPref(ENTITYSPLIT1_KEY,       &mWindowInfo.nEntitySplit1,     -1);
2978   mLocalPrefs.GetPref(ENTITYSPLIT2_KEY,       &mWindowInfo.nEntitySplit2,     -1);
2979
2980   mLocalPrefs.GetPref(POSITIONX_KEY,          &mWindowInfo.position.x,        -1);
2981   mLocalPrefs.GetPref(POSITIONY_KEY,          &mWindowInfo.position.y,        -1);
2982   mLocalPrefs.GetPref(WIDTH_KEY,              &mWindowInfo.position.w,        -1);
2983   mLocalPrefs.GetPref(HEIGHT_KEY,             &mWindowInfo.position.h,        450);
2984
2985   const window_position_t default_window_pos = { 0, 0, 200, 200, };
2986
2987   mLocalPrefs.GetPref(ENTITYWND_KEY,          &mWindowInfo.posEntityWnd,      default_window_pos);
2988   mLocalPrefs.GetPref(MAPINFOWND_KEY,         &mWindowInfo.posMapInfoWnd,     default_window_pos);
2989   mLocalPrefs.GetPref(CAMWND_KEY,             &mWindowInfo.posCamWnd,         default_window_pos);
2990   mLocalPrefs.GetPref(ZWND_KEY,               &mWindowInfo.posZWnd,           default_window_pos);
2991   mLocalPrefs.GetPref(XYWND_KEY,              &mWindowInfo.posXYWnd,          default_window_pos);
2992   mLocalPrefs.GetPref(YZWND_KEY,              &mWindowInfo.posYZWnd,          default_window_pos);
2993   mLocalPrefs.GetPref(XZWND_KEY,              &mWindowInfo.posXZWnd,          default_window_pos);
2994   mLocalPrefs.GetPref(PATCHWND_KEY,           &mWindowInfo.posPatchWnd,       default_window_pos);
2995   mLocalPrefs.GetPref(SURFACEWND_KEY,         &mWindowInfo.posSurfaceWnd,     default_window_pos);
2996   mLocalPrefs.GetPref(ENTITYINFOWND_KEY,      &mWindowInfo.posEntityInfoWnd,  default_window_pos);
2997
2998   mLocalPrefs.GetPref(ZWIDTH_KEY,             &mWindowInfo.nZWidth,           30);
2999   mLocalPrefs.GetPref(XYHEIGHT_KEY,           &mWindowInfo.nXYHeight,         300);
3000   mLocalPrefs.GetPref(XYWIDTH_KEY,            &mWindowInfo.nXYWidth,          300);
3001   mLocalPrefs.GetPref(CAMWIDTH_KEY,           &mWindowInfo.nCamWidth,         200);
3002   mLocalPrefs.GetPref(CAMHEIGHT_KEY,          &mWindowInfo.nCamHeight,        200);
3003   mLocalPrefs.GetPref(ZFLOATWIDTH_KEY,        &mWindowInfo.nZFloatWidth,      300);
3004 #ifdef _WIN32
3005   mLocalPrefs.GetPref(STATE_KEY,              &mWindowInfo.nState,            SW_SHOW);
3006 #endif
3007
3008   // menu stuff
3009   mLocalPrefs.GetPref(COUNT_KEY,              &m_nMRUCount,                   0);
3010   for(i = 0; i < 4; i++)
3011   {
3012     char buf[64];
3013     sprintf (buf, "%s%d", FILE_KEY, i);
3014     mLocalPrefs.GetPref(buf,                  &m_strMRUFiles[i],              "");
3015   }
3016
3017   // some platform specific prefs
3018 #ifdef _WIN32
3019   mLocalPrefs.GetPref(NATIVEGUI_KEY,          &m_bNativeGUI,                  TRUE);
3020   mLocalPrefs.GetPref(STARTONPRIMMON_KEY,     &m_bStartOnPrimMon,             FALSE);
3021 #endif
3022
3023   mLocalPrefs.GetPref(SI_TEXMENU_KEY,         &g_qeglobals.d_savedinfo.iTexMenu,                ID_VIEW_BILINEARMIPMAP);
3024   mLocalPrefs.GetPref(SI_GAMMA_KEY,           &g_qeglobals.d_savedinfo.fGamma,                  1.0f);
3025   mLocalPrefs.GetPref(SI_EXCLUDE_KEY,         &g_qeglobals.d_savedinfo.exclude,                 0); // nothing filtered by default
3026   mLocalPrefs.GetPref(SI_INCLUDE_KEY,         &g_qeglobals.d_savedinfo.include,                 INCLUDE_NAMES | INCLUDE_COORDS | INCLUDE_ANGLES | INCLUDE_CAMERATINT);
3027   mLocalPrefs.GetPref(SI_SHOWNAMES_KEY,       &g_qeglobals.d_savedinfo.show_names,              FALSE);
3028   mLocalPrefs.GetPref(SI_SHOWCOORDS_KEY,      &g_qeglobals.d_savedinfo.show_coordinates,        TRUE);
3029   mLocalPrefs.GetPref(SI_SHOWANGLES_KEY,      &g_qeglobals.d_savedinfo.show_angles,             TRUE);
3030   mLocalPrefs.GetPref(SI_SHOWOUTLINES_KEY,    &g_qeglobals.d_savedinfo.show_outline,            FALSE);
3031   mLocalPrefs.GetPref(SI_SHOWAXIS_KEY,        &g_qeglobals.d_savedinfo.show_axis,               TRUE);
3032   mLocalPrefs.GetPref(SI_NOSELOUTLINES_KEY,   &g_qeglobals.d_savedinfo.bNoSelectedOutlines,     FALSE);
3033
3034   mLocalPrefs.GetPref(SI_OUTLINESTYLE_KEY,   &g_qeglobals.d_savedinfo.iSelectedOutlinesStyle,  OUTLINE_ZBUF|OUTLINE_BSEL);
3035
3036   LoadTexdefPref(&g_qeglobals.d_savedinfo.m_SIIncrement, SI_SURFACE_TEXDEF_KEY);
3037   LoadTexdefPref(&g_qeglobals.d_savedinfo.m_PIIncrement, SI_PATCH_TEXDEF_KEY);
3038
3039   // text editor binding
3040 #ifdef _WIN32
3041   mLocalPrefs.GetPref(CUSTOMSHADEREDITOR_KEY, &m_bUseWin32Editor, TRUE);
3042 #else
3043   mLocalPrefs.GetPref(CUSTOMSHADEREDITOR_KEY, &m_bUseCustomEditor, FALSE);
3044   mLocalPrefs.GetPref(CUSTOMSHADEREDITORCOMMAND_KEY, &m_strEditorCommand, "");
3045 #endif
3046
3047
3048   vec3_t vDefaultAxisColours[3] = {
3049     {0.f, 0.5f, 0.f},
3050     {0.f, 0.f, 1.f},
3051     {1.f, 0.f, 0.f},
3052   };
3053
3054   for(i = 0; i < 3; i++) {
3055     char buf[64];
3056     sprintf(buf, "%s%d", SI_AXISCOLORS_KEY, i);
3057     mLocalPrefs.GetPref(buf,   g_qeglobals.d_savedinfo.AxisColors[i], vDefaultAxisColours[i]);
3058   }
3059
3060   vec3_t vDefaultColours[COLOR_LAST] = {
3061     {0.25f, 0.25f,  0.25f},
3062     {1.f,   1.f,    1.f},
3063     {0.75f, 0.75f,  0.75f},
3064     {0.5f,  0.5f,   0.5f},
3065     {0.25f, 0.25f,  0.25f},
3066     {0.0f,  0.0f,   0.0f},
3067     {0.f,   0.f,    1.f},
3068     {0.f,   0.f,    0.f},
3069     {0.f,   0.f,    0.f},
3070     {1.f,   0.f,    0.f},
3071     {0.f,   0.f,    1.f},
3072     {0.5f,  0.f,    0.75f},
3073     {1.0f,  0.f,    0.f},
3074     {0.f,   0.f,    0.f},
3075     {0.f,   0.f,    0.f},
3076   };
3077
3078   for(i = 0; i < COLOR_LAST; i++) {
3079     char buf[64];
3080     sprintf(buf, "%s%d", SI_COLORS_KEY, i);
3081     mLocalPrefs.GetPref(buf,   g_qeglobals.d_savedinfo.colors[i], vDefaultColours[i]);
3082   }
3083
3084   mLocalPrefs.GetPref(TEXTURECOMPRESSIONFORMAT_KEY, &m_nTextureCompressionFormat, 1);
3085
3086   mLocalPrefs.GetPref(LIGHTRADIUS_KEY, &m_nLightRadiuses, TRUE);
3087
3088   mLocalPrefs.GetPref(Q3MAP2TEX_KEY, &m_bQ3Map2Texturing, TRUE);
3089
3090 #ifdef ATIHACK_812
3091         mLocalPrefs.GetPref(ATIHACK_KEY, &m_bGlATIHack, FALSE);
3092 #endif
3093
3094   Undo_SetMaxSize(m_nUndoLevels); // set it internally as well / FIXME: why not just have one global value?
3095
3096   UpdateTextureCompression();
3097
3098 #ifdef ATIHACK_812
3099   UpdateATIHack();
3100 #endif
3101
3102   if (mLocalPrefs.mbEmpty)
3103   {
3104     mLocalPrefs.mbEmpty = false;
3105     Sys_Printf("Saving local.pref with default pref values\n");
3106     SavePrefs();
3107   }
3108 }
3109
3110 void PrefsDlg::SavePrefs ()
3111 {
3112   if (g_qeglobals.disable_ini)
3113     return;
3114
3115 #ifdef _DEBUG
3116   Sys_Printf("PrefsDlg::SavePrefs\n");
3117 #endif
3118
3119   // this will take care of copying back from the dialog to the variables
3120   // NOTE: it may be overkill to call systematically before a SavePrefs, but it's safer
3121   // this will also cause an UpdateData for the mGamesDialog
3122   UpdateData(TRUE);
3123
3124   mGamesDialog.SavePrefs();
3125
3126   // update the tree and save it
3127   mLocalPrefs.UpdatePrefTree();
3128   if (!mLocalPrefs.WriteXMLFile(m_inipath->str))
3129     Sys_FPrintf(SYS_ERR, "Error occured while saving local prefs file '%s'\n", m_inipath->str);
3130
3131   if ( m_nMouse == 0 ) {
3132           m_nMouseButtons = 2;
3133   } else {
3134           m_nMouseButtons = 3;
3135   }
3136
3137 }
3138
3139 void PrefsDlg::PostModal (int code)
3140 {
3141   if (code == IDOK)
3142   {
3143     SavePrefs();
3144     // make sure the logfile is ok
3145     Sys_LogFile();
3146     #ifdef ATIHACK_812
3147       UpdateATIHack();
3148     #endif
3149     if (g_pParentWnd)
3150       g_pParentWnd->SetGridStatus();
3151     Sys_UpdateWindows(W_ALL);
3152     if (m_nUndoLevels != 0)
3153                 Undo_SetMaxSize(m_nUndoLevels);
3154   }
3155 }
3156
3157 void PrefsDlg::DoEditorSensitivity()
3158 {
3159   if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(g_object_get_data (G_OBJECT(m_pWidget), "check_customeditor"))))
3160   {
3161     gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data (G_OBJECT(m_pWidget), "label_customeditor")), TRUE);
3162     gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data (G_OBJECT(m_pWidget), "entry_customeditor")), TRUE);
3163     gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data (G_OBJECT(m_pWidget), "button_customeditor")), TRUE);
3164   }
3165   else
3166   {
3167     gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data (G_OBJECT(m_pWidget), "label_customeditor")), FALSE);
3168     gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data (G_OBJECT(m_pWidget), "entry_customeditor")), FALSE);
3169     gtk_widget_set_sensitive(GTK_WIDGET(g_object_get_data (G_OBJECT(m_pWidget), "button_customeditor")), FALSE);
3170   }
3171 }
3172
3173 void PrefsDlg::DoSensitivity()
3174 {
3175 #if 0
3176   // first, look at the project file version ... will monitoring work?
3177   // project files now XML, guaranteed to be at least version 2
3178   if (0)//IntForKey( g_qeglobals.d_project_entity, "version" ) < 2)
3179   {
3180     if (m_bWarn)
3181     {
3182       Str Msg;
3183       Msg = "The current project file (";
3184       Msg += g_PrefsDlg.m_strLastProject;
3185       Msg += ") is not at least version 2.\nI need version 2 or above to setup BSP monitoring correctly.";
3186       gtk_MessageBox(m_pWidget, Msg.GetBuffer(), MB_OK );
3187
3188       m_bWarn = false;
3189     }
3190
3191     // go ahead, disable everybuddy
3192     gtk_widget_set_sensitive( GTK_WIDGET(g_object_get_data( G_OBJECT(m_pWidget), "check_leakstop" )), FALSE );
3193     gtk_widget_set_sensitive( GTK_WIDGET(g_object_get_data( G_OBJECT(m_pWidget), "check_monitorbsp" )), FALSE );
3194     gtk_widget_set_sensitive( GTK_WIDGET(g_object_get_data( G_OBJECT(m_pWidget), "check_runengine" )), FALSE );
3195     gtk_widget_set_sensitive( GTK_WIDGET(g_object_get_data( G_OBJECT(m_pWidget), "check_sleep" )), FALSE );
3196   }
3197   else
3198   {
3199 #endif
3200 //    m_bWarn = true;
3201
3202     gtk_widget_set_sensitive( GTK_WIDGET(g_object_get_data( G_OBJECT(m_pWidget), "check_leakstop" )), TRUE );
3203     gtk_widget_set_sensitive( GTK_WIDGET(g_object_get_data( G_OBJECT(m_pWidget), "check_monitorbsp" )), TRUE );
3204     gtk_widget_set_sensitive( GTK_WIDGET(g_object_get_data( G_OBJECT(m_pWidget), "check_runengine" )), TRUE );
3205     gtk_widget_set_sensitive( GTK_WIDGET(g_object_get_data( G_OBJECT(m_pWidget), "check_sleep" )), TRUE );
3206
3207     if ( ! gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( g_object_get_data( G_OBJECT(m_pWidget), "check_monitorbsp" ) ) ) )
3208     {
3209       gtk_widget_set_sensitive( GTK_WIDGET(g_object_get_data( G_OBJECT(m_pWidget), "check_leakstop" )), FALSE );
3210       gtk_widget_set_sensitive( GTK_WIDGET(g_object_get_data( G_OBJECT(m_pWidget), "check_runengine" )), FALSE );
3211       gtk_widget_set_sensitive( GTK_WIDGET(g_object_get_data( G_OBJECT(m_pWidget), "check_sleep" )), FALSE );
3212     } else if (! gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( g_object_get_data( G_OBJECT(m_pWidget), "check_runengine" ) ) ) )
3213     {
3214       gtk_widget_set_sensitive( GTK_WIDGET(g_object_get_data( G_OBJECT(m_pWidget), "check_sleep" )), FALSE );
3215     }
3216 }
3217
3218 /*
3219 ============================================================
3220 CGameInstall
3221 ============================================================
3222 */
3223
3224 CGameInstall::CGameInstall() {
3225         memset( m_availGames, 0, sizeof( m_availGames ) );
3226 }
3227
3228 void CGameInstall::OnBtnBrowseEngine( GtkWidget *widget, gpointer data ) {
3229         Sys_Printf( "OnBtnBrowseEngine\n" );
3230
3231         CGameInstall* i = static_cast<CGameInstall*>( data );
3232         char *dir = dir_dialog( i->m_pWidget, _("Select game directory"), NULL );
3233
3234         i->UpdateData( TRUE );
3235
3236         if ( dir != NULL ) {
3237                 i->m_strEngine = dir;
3238                 i->UpdateData( FALSE );
3239                 g_free( dir );
3240         }
3241 }
3242
3243 void CGameInstall::OnGameSelectChanged( GtkWidget *widget, gpointer data ) {
3244         Sys_Printf( "OnGameSelectChanged\n" );
3245
3246         CGameInstall* i = static_cast<CGameInstall*>( data );
3247         i->UpdateData( TRUE );
3248         i->m_strName = gtk_combo_box_get_active_text( GTK_COMBO_BOX( widget ) );
3249         i->UpdateData( FALSE );
3250 }
3251
3252 void CGameInstall::BuildDialog() {
3253         GtkWidget *dlg, *vbox1, *button, *text, *combo, *entry, *hbox;
3254
3255         dlg = m_pWidget;
3256         gtk_window_set_title( GTK_WINDOW( dlg ), _("Configure games") );
3257
3258         vbox1 = gtk_vbox_new( FALSE, 0 );
3259         gtk_widget_show( vbox1 );
3260         gtk_container_add( GTK_CONTAINER( dlg ), vbox1 );
3261
3262         text = gtk_label_new( _("Select the game to configure") );
3263         gtk_widget_show( text );
3264         gtk_box_pack_start( GTK_BOX( vbox1 ), text, FALSE, FALSE, 0 );
3265
3266         combo = gtk_combo_box_new_text();
3267         gtk_widget_show( combo );
3268         gtk_box_pack_start( GTK_BOX( vbox1 ), combo, FALSE, FALSE, 0 );
3269
3270         //      GList *combo_list = NULL;
3271         int iGame = 0;
3272         while ( m_availGames[ iGame ] != GAME_NONE ) {
3273                 switch ( m_availGames[ iGame ] ) {
3274                 case GAME_Q2:
3275                         gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("Quake II") );
3276                         break;
3277                 case GAME_Q3:
3278                         gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("Quake III Arena and mods") );
3279                         break;
3280                 case GAME_URT:
3281                         gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("Urban Terror (standalone)") );
3282                         break;
3283                 case GAME_UFOAI:
3284                         gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("UFO: Alien Invasion") );
3285                         break;
3286                 case GAME_Q2W:
3287                         gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("Quake2World") );
3288                         break;
3289                 case GAME_WARSOW:
3290                         gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("Warsow") );
3291                         break;
3292                 case GAME_NEXUIZ:
3293                         gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("Nexuiz") );
3294                         break;
3295                 case GAME_TREMULOUS:
3296                         gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("Tremulous") );
3297                         break;
3298                 case GAME_JA:
3299                         gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("Jedi Academy and mods") );
3300                         break;
3301                 }
3302                 iGame++;
3303         }
3304         AddDialogData( combo, &m_nComboSelect, DLG_COMBO_BOX_INT );
3305         gtk_signal_connect( GTK_OBJECT( combo ), "changed", G_CALLBACK( OnGameSelectChanged ), this );
3306         gtk_combo_box_set_active( GTK_COMBO_BOX( combo ), 0 );  // NOTE: will trigger signal
3307
3308         text = gtk_label_new( _("Name:") );
3309         gtk_widget_show( text );
3310         gtk_box_pack_start( GTK_BOX( vbox1 ), text, FALSE, FALSE, 0 );
3311
3312         entry = gtk_entry_new();
3313         gtk_widget_show( entry );
3314         gtk_box_pack_start( GTK_BOX( vbox1 ), entry, FALSE, FALSE, 0 );
3315         AddDialogData( entry, &m_strName, DLG_ENTRY_TEXT );
3316
3317         text = gtk_label_new( _("Engine directory:") );
3318         gtk_widget_show( text );
3319         gtk_box_pack_start( GTK_BOX( vbox1 ), text, FALSE, FALSE, 0 );
3320
3321         hbox = gtk_hbox_new( FALSE, 0 );
3322         gtk_widget_show( hbox );
3323         gtk_box_pack_start( GTK_BOX( vbox1 ), hbox, FALSE, FALSE, 0 );
3324
3325         entry = gtk_entry_new();
3326         gtk_widget_show( entry );
3327         gtk_box_pack_start( GTK_BOX( hbox ), entry, FALSE, FALSE, 0 );
3328         AddDialogData( entry, &m_strEngine, DLG_ENTRY_TEXT );
3329
3330         button = gtk_button_new_with_label (_("..."));
3331         gtk_widget_show( button );
3332         gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnBtnBrowseEngine ), this );
3333         gtk_box_pack_start( GTK_BOX( hbox ), button, FALSE, FALSE, 0 );
3334
3335         // this gets done in the project stuff atm
3336 #if 0
3337         text = gtk_label_new( _("Mod subdirectory:") );
3338         gtk_widget_show( text );
3339         gtk_box_pack_start( GTK_BOX( vbox1 ), text, FALSE, FALSE, 0 );
3340
3341         entry = gtk_entry_new();
3342         gtk_widget_show( entry );
3343         gtk_box_pack_start( GTK_BOX( vbox1 ), entry, FALSE, FALSE, 0 );
3344         AddDialogData( entry, &m_strMod, DLG_ENTRY_TEXT );
3345 #endif
3346
3347         button = gtk_button_new_with_label( _("OK") );
3348         gtk_widget_show( button );
3349         gtk_box_pack_start( GTK_BOX( vbox1 ), button, FALSE, FALSE, 0 );
3350         AddModalButton( button, IDOK );
3351
3352         button = gtk_button_new_with_label( _("Cancel") );
3353         gtk_widget_show( button );
3354         gtk_box_pack_start( GTK_BOX( vbox1 ), button, FALSE, FALSE, 0 );
3355         AddModalButton( button, IDCANCEL );
3356
3357         gtk_widget_set_usize( button, 60, -2 );
3358 }
3359
3360 void CGameInstall::Run() {
3361         ScanGames();
3362         if (m_availGames[0] == GAME_NONE) {
3363                 return;
3364         }
3365         if ( DoModal() == IDCANCEL ) {
3366                 Sys_Printf( "game dialog cancelled\n" );
3367                 return;
3368         }
3369         Sys_Printf( "combo: %d name: %s engine: %s mod: %s\n", m_nComboSelect, m_strName.GetBuffer(), m_strEngine.GetBuffer(), m_strMod.GetBuffer() );
3370
3371         // write out the game file
3372         Str gameFilePath = g_strAppPath.GetBuffer();
3373         gameFilePath += "games/";
3374         gameFilePath += m_strName.GetBuffer();
3375         gameFilePath += ".game";
3376         Sys_Printf( "game file: %s\n", gameFilePath.GetBuffer() );
3377
3378         FILE *fg = fopen( gameFilePath.GetBuffer(), "w" );
3379         if ( fg == NULL || ferror( fg ) ) {
3380                 Error( "Failed to open %s for writing\n", gameFilePath.GetBuffer() );
3381         }
3382         fprintf( fg, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>\n<game\n" );
3383         fprintf( fg, "  name=\"%s\"\n", m_strName.GetBuffer() );
3384         fprintf( fg, "  "ENGINEPATH_ATTRIBUTE"=\"%s\"\n", m_strEngine.GetBuffer() );
3385         switch ( m_availGames[ m_nComboSelect ] ) {
3386         case GAME_Q2: {
3387                 fprintf( fg, "  "TOOLS_ATTRIBUTE"=\"%sinstalls/Quake2Pack/game\"\n", g_strAppPath.GetBuffer() );
3388                 fprintf( fg, "  prefix=\".quake2\"\n" );
3389                 Str source = g_strAppPath.GetBuffer();
3390                 source += "installs/";
3391                 source += Q2_PACK;
3392                 source += "/install/";
3393                 Str dest = m_strEngine.GetBuffer();
3394                 CopyTree( source.GetBuffer(), dest.GetBuffer() );
3395                 fprintf( fg, "  basegame=\"baseq2\"\n" );
3396                 break;
3397         }
3398         case GAME_Q3: {
3399                 fprintf( fg, "  "TOOLS_ATTRIBUTE"=\"%sinstalls/Q3Pack/game\"\n", g_strAppPath.GetBuffer() );
3400                 fprintf( fg, "  prefix=\".q3a\"\n" );
3401                 Str source = g_strAppPath.GetBuffer();
3402                 source += "installs/";
3403                 source += Q3_PACK;
3404                 source += "/install/";
3405                 Str dest = m_strEngine.GetBuffer();
3406                 CopyTree( source.GetBuffer(), dest.GetBuffer() );
3407                 fprintf( fg, "  basegame=\"baseq3\"\n" );
3408                 break;
3409         }
3410         case GAME_URT: {
3411                 fprintf( fg, "  "TOOLS_ATTRIBUTE"=\"%sinstalls/UrTPack/game\"\n", g_strAppPath.GetBuffer() );
3412                 fprintf( fg, "  prefix=\".q3a\"\n" );
3413                 Str source = g_strAppPath.GetBuffer();
3414                 source += "installs/";
3415                 source += URT_PACK;
3416                 source += "/install/";
3417                 Str dest = m_strEngine.GetBuffer();
3418                 CopyTree( source.GetBuffer(), dest.GetBuffer() );
3419                 fprintf( fg, "  basegame=\"q3ut4\"\n" );
3420                 break;
3421         }
3422         case GAME_UFOAI: {
3423                 fprintf( fg, "  "TOOLS_ATTRIBUTE"=\"%sinstalls/UFOAIPack/game\"\n", g_strAppPath.GetBuffer() );
3424                 fprintf( fg, "  prefix=\".ufoai\"\n" );
3425                 Str source = g_strAppPath.GetBuffer();
3426                 source += "installs/";
3427                 source += UFOAI_PACK;
3428                 source += "/install/";
3429                 Str dest = m_strEngine.GetBuffer();
3430                 CopyTree( source.GetBuffer(), dest.GetBuffer() );
3431                 fprintf( fg, "  basegame=\"base\"\n" );
3432                 break;
3433         }
3434         case GAME_Q2W: {
3435                 fprintf( fg, "  "TOOLS_ATTRIBUTE"=\"%sinstalls/Q2WPack/game\"\n", g_strAppPath.GetBuffer() );
3436                 fprintf( fg, "  prefix=\".quake2world\"\n" );
3437                 Str source = g_strAppPath.GetBuffer();
3438                 source += "installs/";
3439                 source += Q2W_PACK;
3440                 source += "/install/";
3441                 Str dest = m_strEngine.GetBuffer();
3442                 CopyTree( source.GetBuffer(), dest.GetBuffer() );
3443                 fprintf( fg, "  basegame=\"default\"\n" );
3444                 break;
3445         }
3446         case GAME_WARSOW: {
3447                 fprintf( fg, "  "TOOLS_ATTRIBUTE"=\"%sinstalls/WarsowPack/game\"\n", g_strAppPath.GetBuffer() );
3448                 fprintf( fg, "  prefix=\".warsow\"\n" );
3449                 Str source = g_strAppPath.GetBuffer();
3450                 source += "installs/";
3451                 source += WARSOW_PACK;
3452                 source += "/install/";
3453                 Str dest = m_strEngine.GetBuffer();
3454                 CopyTree( source.GetBuffer(), dest.GetBuffer() );
3455                 fprintf( fg, "  basegame=\"basewsw\"\n" );
3456                 break;
3457         }
3458         case GAME_NEXUIZ: {
3459                 fprintf( fg, "  "TOOLS_ATTRIBUTE"=\"%sinstalls/NexuizPack/game\"\n", g_strAppPath.GetBuffer() );
3460                 fprintf( fg, "  prefix=\".nexuiz\"\n" );
3461                 Str source = g_strAppPath.GetBuffer();
3462                 source += "installs/";
3463                 source += NEXUIZ_PACK;
3464                 source += "/install/";
3465                 Str dest = m_strEngine.GetBuffer();
3466                 CopyTree( source.GetBuffer(), dest.GetBuffer() );
3467                 fprintf( fg, "  basegame=\"data\"\n" );
3468                 break;
3469         }
3470         case GAME_TREMULOUS: {
3471                 fprintf( fg, "  "TOOLS_ATTRIBUTE"=\"%sinstalls/TremulousPack/game\"\n", g_strAppPath.GetBuffer() );
3472                 fprintf( fg, "  prefix=\".tremulous\"\n" );
3473                 Str source = g_strAppPath.GetBuffer();
3474                 source += "installs/";
3475                 source += TREMULOUS_PACK;
3476                 source += "/install/";
3477                 Str dest = m_strEngine.GetBuffer();
3478                 CopyTree( source.GetBuffer(), dest.GetBuffer() );
3479                 fprintf( fg, "  basegame=\"base\"\n" );
3480                 break;
3481         }
3482         case GAME_JA: {
3483                 fprintf( fg, "  "TOOLS_ATTRIBUTE"=\"%sinstalls/JAPack/game\"\n", g_strAppPath.GetBuffer() );
3484                 fprintf( fg, "  prefix=\".ja\"\n" );
3485                 Str source = g_strAppPath.GetBuffer();
3486                 source += "installs/";
3487                 source += JA_PACK;
3488                 source += "/install/";
3489                 Str dest = m_strEngine.GetBuffer();
3490                 CopyTree( source.GetBuffer(), dest.GetBuffer() );
3491                 fprintf( fg, "  basegame=\"base\"\n" );
3492                 break;
3493         }
3494         }
3495         fprintf( fg, "/>\n" );
3496         fclose( fg );
3497 }
3498
3499 /*
3500 ===============
3501 CGameInstall::ScanGames
3502 scan for active games that can be installed, based on the presence
3503 ===============
3504 */
3505 void CGameInstall::ScanGames() {
3506         Str                             pakPaths = g_strAppPath.GetBuffer();
3507         int                             iGame = 0;
3508         const char              *dirname;
3509
3510         pakPaths +=     "installs/";
3511         FindFiles fileScan( pakPaths.GetBuffer() );
3512         while ( ( dirname = fileScan.NextFile() ) != NULL ) {
3513                 if ( stricmp( dirname, Q3_PACK ) == 0 ) {
3514                         m_availGames[ iGame++ ] = GAME_Q3;
3515                 }
3516                 if ( stricmp( dirname, URT_PACK ) == 0 ) {
3517                         m_availGames[ iGame++ ] = GAME_URT;
3518                 }
3519                 if ( stricmp( dirname, UFOAI_PACK ) == 0 ) {
3520                         m_availGames[ iGame++ ] = GAME_UFOAI;
3521                 }
3522                 if ( stricmp( dirname, Q2W_PACK ) == 0 ) {
3523                         m_availGames[ iGame++ ] = GAME_Q2W;
3524                 }
3525                 if ( stricmp( dirname, WARSOW_PACK ) == 0 ) {
3526                         m_availGames[ iGame++ ] = GAME_WARSOW;
3527                 }
3528                 if ( stricmp( dirname, NEXUIZ_PACK ) == 0 ) {
3529                         m_availGames[ iGame++ ] = GAME_NEXUIZ;
3530                 }
3531                 if ( stricmp( dirname, Q2_PACK ) == 0 ) {
3532                         m_availGames[ iGame++ ] = GAME_Q2;
3533                 }
3534                 if ( stricmp( dirname, TREMULOUS_PACK ) == 0 ) {
3535                         m_availGames[ iGame++ ] = GAME_TREMULOUS;
3536                 }
3537                 if ( stricmp( dirname, JA_PACK ) == 0 ) {
3538                         m_availGames[ iGame++ ] = GAME_JA;
3539                 }
3540         }
3541         Sys_Printf("No installable games found in: %s\n",
3542                 pakPaths.GetBuffer() );
3543 }
3544