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