]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/preferences.cpp
Adding "Preferences" -> "Other" -> "Brush" tab. This now has
[xonotic/netradiant.git] / radiant / preferences.cpp
index be4cd3ac6ccfa5fa0ffc16e43e9acfbb4c6499ff..44f8bfbfc0486ef7d8a279bdc2910667b7281319 100644 (file)
@@ -39,6 +39,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include "missing.h"
 #include "gtkmisc.h"
 
+#ifdef _WIN32
+       // sanity check - some gtk2 win32 runtimes replace sprintf
+       #if defined( sprintf )
+               #error sprintf is a macro. are you sure?
+       #endif
+#endif
+
 #ifdef _WIN32
 #include <io.h>
 #define X_OK 0
@@ -96,6 +103,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define WIDETOOLBAR_KEY         "WideToolBar"
 #define PLUGINTOOLBAR_KEY "PluginToolBar"
 #define NOCLAMP_KEY             "NoClamp"
+#define SNAP_KEY                "Snap"
 #define PREFAB_KEY              "PrefabPath"
 #define USERINI_KEY             "UserINIPath"
 #define ROTATION_KEY            "Rotation"
@@ -129,6 +137,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #define LEAKSTOP_KEY            "LeakStop"
 #define DOSLEEP_KEY             "SleepMode"
 #define SUBDIVISIONS_KEY        "Subdivisions"
+#define DEFAULTTEXURESCALE_KEY  "DefaultTextureScale"
 #define CLIPCAULK_KEY           "ClipCaulk"
 #define PATCHSHOWBOUNDS_KEY     "PatchShowBounds"
 #define NATIVEGUI_KEY           "NativeGUI"
@@ -635,6 +644,7 @@ PrefsDlg::PrefsDlg ()
   m_bWideToolbar = TRUE;
   m_bPluginToolbar = TRUE;
   m_bNoClamp = FALSE;
+  m_bSnap = TRUE;
   m_strUserPath = "";
   m_nRotation = 0;
   m_bChaseMouse = FALSE;
@@ -1718,6 +1728,11 @@ void PrefsDlg::BuildDialog ()
           gtk_tree_store_append(store, &tab, &group);
           gtk_tree_store_set(store, &tab, 0, _("Paths"), 1, (gpointer)PTAB_PATHS, -1);
         }
+        {
+          GtkTreeIter tab;
+          gtk_tree_store_append(store, &tab, &group);
+          gtk_tree_store_set(store, &tab, 0, _("Brush"), 1, (gpointer)PTAB_BRUSH, -1);
+        }
         {
           GtkTreeIter tab;
           gtk_tree_store_append(store, &tab, &group);
@@ -2216,7 +2231,7 @@ void PrefsDlg::BuildDialog ()
 
 #ifdef _WIN32
   // win32 file dialog
-  check = gtk_check_button_new_with_label (_("Use win32 file load dialog"));
+  check = gtk_check_button_new_with_label (_("Use win32 file dialog (hacky)"));
   gtk_widget_show (check);
   // gtk_container_add (GTK_CONTAINER (vbox), check);
   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
@@ -2336,6 +2351,12 @@ void PrefsDlg::BuildDialog ()
   gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
   AddDialogData (check, &m_bNoClamp, DLG_CHECK_BOOL);
 
+  // Snap to grid
+  check = gtk_check_button_new_with_label (_("Snap to grid"));
+  gtk_widget_show (check);
+  gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
+  AddDialogData (check, &m_bSnap, DLG_CHECK_BOOL);
+
   // Select patch by bounding box
   check = gtk_check_button_new_with_label (_("Select patches by bounding box"));
   gtk_widget_show (check);
@@ -2534,6 +2555,47 @@ void PrefsDlg::BuildDialog ()
   // Add the page to the notebook
   gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
 
+  /******** Brush group ********/
+  preflabel = gtk_label_new(_("Brush"));
+  gtk_widget_show(preflabel);
+  pageframe = gtk_frame_new(_("Brush"));
+  gtk_container_set_border_width(GTK_CONTAINER(pageframe), 5);
+  gtk_widget_show(pageframe);
+  vbox = gtk_vbox_new(FALSE, 5);
+  gtk_widget_show(vbox);
+  gtk_container_set_border_width(GTK_CONTAINER(vbox), 5);
+  gtk_container_add(GTK_CONTAINER(pageframe), vbox);
+
+  // default texture scale
+  // table
+  table = gtk_table_new(2, 1, FALSE); // I believe that the 2 and 1 are switched here, and this is
+                                      // intentional to be consistent with other calls to gtk_table_new()
+                                      // [that are probably also switched].
+  gtk_widget_show(table);
+  gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, TRUE, 0);
+  gtk_table_set_row_spacings(GTK_TABLE(table), 5);
+  gtk_table_set_col_spacings(GTK_TABLE(table), 5);
+
+  // label
+  label = gtk_label_new(_("Default texture scale:"));
+  gtk_widget_show(label);
+  gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+  gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
+                   (GtkAttachOptions) (0),
+                   (GtkAttachOptions) (0), 0, 0);
+
+  // scale entry
+  entry = gtk_entry_new();
+  gtk_widget_show(entry);
+  gtk_widget_set_usize(GTK_WIDGET(entry), 60, -2);
+  gtk_table_attach(GTK_TABLE(table), entry, 1, 2, 0, 1,
+                   (GtkAttachOptions) (GTK_FILL),
+                   (GtkAttachOptions) (0), 0, 0);
+  AddDialogData(entry, &m_fDefTextureScale, DLG_ENTRY_FLOAT);
+
+  // Add the page to the notebook
+  gtk_notebook_append_page(GTK_NOTEBOOK(notebook), pageframe, preflabel);
+
   /******** Misc group *********/
   preflabel = gtk_label_new(_("Misc"));
   gtk_widget_show(preflabel);
@@ -2906,6 +2968,7 @@ void PrefsDlg::LoadPrefs ()
   m_nShader = m_nLatchedShader;
 
   mLocalPrefs.GetPref(NOCLAMP_KEY,            &m_bNoClamp,                    FALSE);
+  mLocalPrefs.GetPref(SNAP_KEY,               &m_bSnap,                       TRUE);
   mLocalPrefs.GetPref(USERINI_KEY,            &m_strUserPath,                 "");
   mLocalPrefs.GetPref(ROTATION_KEY,           &m_nRotation,                   45);
   mLocalPrefs.GetPref(CHASEMOUSE_KEY,         &m_bChaseMouse,                 TRUE);
@@ -2954,6 +3017,7 @@ void PrefsDlg::LoadPrefs ()
   mLocalPrefs.GetPref(SELECTCURVES_KEY,       &m_bSelectCurves,               TRUE);
   mLocalPrefs.GetPref(SELECTMODELS_KEY,       &m_bSelectModels,               TRUE);
   mLocalPrefs.GetPref(SHADERLISTONLY_KEY,     &m_bTexturesShaderlistOnly,     FALSE);
+  mLocalPrefs.GetPref(DEFAULTTEXURESCALE_KEY, &m_fDefTextureScale,            g_pGameDescription->mTextureDefaultScale);
   mLocalPrefs.GetPref(SUBDIVISIONS_KEY,       &m_nSubdivisions,               SUBDIVISIONS_DEF);
   mLocalPrefs.GetPref(CLIPCAULK_KEY,          &m_bClipCaulk,                  FALSE);
   mLocalPrefs.GetPref(SNAPTTOGRID_KEY,        &m_bSnapTToGrid,                FALSE);
@@ -3220,14 +3284,14 @@ void CGameInstall::OnBtnBrowseEngine( GtkWidget *widget, gpointer data ) {
        Sys_Printf( "OnBtnBrowseEngine\n" );
 
        CGameInstall* i = static_cast<CGameInstall*>( data );
-       char *dir = dir_dialog( widget, _("Select game directory"), NULL );
+       char *dir = dir_dialog( i->m_pWidget, _("Select game directory"), NULL );
 
        i->UpdateData( TRUE );
 
        if ( dir != NULL ) {
                i->m_strEngine = dir;
                i->UpdateData( FALSE );
-               free( dir );
+               g_free( dir );
        }
 }
 
@@ -3286,6 +3350,12 @@ void CGameInstall::BuildDialog() {
                case GAME_TREMULOUS:
                        gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("Tremulous") );
                        break;
+               case GAME_JA:
+                       gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("Jedi Academy and mods") );
+                       break;
+               case GAME_REACTION:
+                       gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("Reaction Quake 3") );
+                       break;
                }
                iGame++;
        }
@@ -3347,6 +3417,9 @@ void CGameInstall::BuildDialog() {
 
 void CGameInstall::Run() {
        ScanGames();
+       if ( m_availGames[0] == GAME_NONE ) {
+               return;
+       }
        if ( DoModal() == IDCANCEL ) {
                Sys_Printf( "game dialog cancelled\n" );
                return;
@@ -3360,7 +3433,7 @@ void CGameInstall::Run() {
        gameFilePath += ".game";
        Sys_Printf( "game file: %s\n", gameFilePath.GetBuffer() );
 
-       FILE *fg = fopen( gameFilePath.GetBuffer(), "w" );
+       FILE * fg = fopen( gameFilePath.GetBuffer(), "w" );
        if ( fg == NULL ) {
                Error( "Failed to open %s for writing\n", gameFilePath.GetBuffer() );
        }
@@ -3464,6 +3537,33 @@ void CGameInstall::Run() {
                fprintf( fg, "  basegame=\"base\"\n" );
                break;
        }
+       case GAME_JA: {
+               fprintf( fg, "  "TOOLS_ATTRIBUTE"=\"%sinstalls/JAPack/game\"\n", g_strAppPath.GetBuffer() );
+               fprintf( fg, "  prefix=\".ja\"\n" );
+               Str source = g_strAppPath.GetBuffer();
+               source += "installs/";
+               source += JA_PACK;
+               source += "/install/";
+               Str dest = m_strEngine.GetBuffer();
+               CopyTree( source.GetBuffer(), dest.GetBuffer() );
+               fprintf( fg, "  basegame=\"base\"\n" );
+               break;
+       }
+       case GAME_REACTION: {
+               fprintf( fg, "  "TOOLS_ATTRIBUTE"=\"%sinstalls/"REACTION_PACK"/game\"\n", g_strAppPath.GetBuffer() );
+               fprintf( fg, "  prefix=\".Reaction\"\n" );
+               Str source = g_strAppPath.GetBuffer();
+               source += "installs/";
+               source += REACTION_PACK;
+               source += "/install/";
+               Str dest = m_strEngine.GetBuffer();
+               CopyTree( source.GetBuffer(), dest.GetBuffer() );
+               fprintf( fg, "  basegame=\"Boomstick\"\n" );
+               fprintf( fg, "  default_scale=\"0.5\"\n" ); // Superfluous because the default is already 0.5,
+                                                       // but demonstrates how to set the default texture scale
+                                                       // for a specific game.
+               break;
+       }
        }
        fprintf( fg, "/>\n" );
        fclose( fg );
@@ -3507,6 +3607,14 @@ void CGameInstall::ScanGames() {
                if ( stricmp( dirname, TREMULOUS_PACK ) == 0 ) {
                        m_availGames[ iGame++ ] = GAME_TREMULOUS;
                }
+               if ( stricmp( dirname, JA_PACK ) == 0 ) {
+                       m_availGames[ iGame++ ] = GAME_JA;
+               }
+               if ( stricmp( dirname, REACTION_PACK ) == 0 ) {
+                       m_availGames[ iGame++ ] = GAME_REACTION;
+               }
        }
+       Sys_Printf("No installable games found in: %s\n",
+               pakPaths.GetBuffer() );
 }