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