X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=radiant%2Fpreferences.cpp;h=3ac20c260da0a3133548a74845aae09c6aaba9cd;hp=6c3af47c470232847618093c0de0aec7e0f841b2;hb=561e062c8724752601cb9f9370321930fd5aeed1;hpb=3138825cde9183d70a9ccd77ea1e2b9bf41b6dde diff --git a/radiant/preferences.cpp b/radiant/preferences.cpp index 6c3af47c..3ac20c26 100644 --- a/radiant/preferences.cpp +++ b/radiant/preferences.cpp @@ -96,6 +96,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 +130,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" @@ -283,7 +285,6 @@ void CXMLPropertyBag::GetPref(const char *name, Str *pV, const char *V) if ( pNode->children && pNode->children->content ) { *pV = pNode->children->content; } else { - // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=427 // means the pref exists, and that the value is "" *pV = ""; } @@ -636,6 +637,7 @@ PrefsDlg::PrefsDlg () m_bWideToolbar = TRUE; m_bPluginToolbar = TRUE; m_bNoClamp = FALSE; + m_bSnap = TRUE; m_strUserPath = ""; m_nRotation = 0; m_bChaseMouse = FALSE; @@ -695,6 +697,25 @@ Games selection dialog ========================================================= */ +#if defined(WIN32) +#define TOOLS_ATTRIBUTE "gametools_win32" +#define ENGINE_ATTRIBUTE "engine_win32" +#define ENGINEPATH_ATTRIBUTE "enginepath_win32" +#define MP_ENGINE_ATTRIBUTE "mp_engine_win32" +#elif defined(__linux__) || defined (__FreeBSD__) +#define TOOLS_ATTRIBUTE "gametools_linux" +#define ENGINE_ATTRIBUTE "engine_linux" +#define ENGINEPATH_ATTRIBUTE "enginepath_linux" +#define MP_ENGINE_ATTRIBUTE "mp_engine_linux" +#elif defined(__APPLE__) +#define TOOLS_ATTRIBUTE "gametools_macos" +#define ENGINE_ATTRIBUTE "engine_macos" +#define ENGINEPATH_ATTRIBUTE "enginepath_macos" +#define MP_ENGINE_ATTRIBUTE "mp_engine_macos" +#else +#error "unsupported platform" +#endif + CGameDescription::CGameDescription(xmlDocPtr pDoc, const Str &GameFile) { char *p, *prop; @@ -709,9 +730,9 @@ CGameDescription::CGameDescription(xmlDocPtr pDoc, const Str &GameFile) Error("Didn't find 'game' node in the game description file '%s'\n", pDoc->URL); } // on win32, game tools path can now be specified relative to the exe's cwd - prop = (char*)xmlGetProp( pNode, (xmlChar*)"gametools" ); + prop = (char*)xmlGetProp( pNode, (xmlChar*)TOOLS_ATTRIBUTE); if ( prop == NULL ) { - Error( "Didn't find 'gametools' node in the game description file '%s'\n", pDoc->URL ); + Error( "Didn't find '"TOOLS_ATTRIBUTE"' node in the game description file '%s'\n", pDoc->URL ); } { char full[PATH_MAX]; @@ -759,6 +780,20 @@ CGameDescription::CGameDescription(xmlDocPtr pDoc, const Str &GameFile) xmlFree(prop); } + // if this is set, the open maps dialoge will open the engine path not the + // home dir for map loading and saving + prop = (char*)xmlGetProp(pNode, (xmlChar*)"no_maps_in_home"); + if (prop == NULL) + { + // default + noMapsInHome = false; + } + else + { + noMapsInHome = true; + xmlFree(prop); + } + prop = (char*)xmlGetProp(pNode, (xmlChar*)"basegame"); if (prop == NULL) { @@ -771,58 +806,78 @@ CGameDescription::CGameDescription(xmlDocPtr pDoc, const Str &GameFile) xmlFree(prop); } - // on win32, engine path can now be specified relative to the exe's cwd - prop = (char*)xmlGetProp(pNode, (const xmlChar *)"enginepath"); - if ( prop != NULL ) { - char full[PATH_MAX]; + + prop = (char*)xmlGetProp(pNode, (const xmlChar*)ENGINE_ATTRIBUTE); + if (prop == NULL) + { #ifdef _WIN32 - _fullpath( full, prop, PATH_MAX ); -#else - strncpy( full, prop, PATH_MAX ); + mEngine = "quake3.exe"; +#elif __linux__ + mEngine = "quake3"; +#elif __APPLE__ + mEngine = "Quake3.app"; #endif - xmlFree( prop ); - prop = NULL; - // process seperators - for ( p = full; *p != '\0'; p++ ) { - if ( *p == '\\' ) { - *p = '/'; - } - } - mEnginePath = full; - if ( p != full && *(p-1) != '/' ) { - mEnginePath += "/"; } - } - else - { - // if engine path was not specified in the .game, it implies we can guess it from the gametools path - // on win32, and for most game package, the gametools are installed with the game - char aux_path[PATH_MAX]; // aux - strcpy( aux_path, mGameToolsPath.GetBuffer() ); - if ( ( aux_path[ strlen(aux_path)-1 ] == '/' ) || ( aux_path[ strlen(aux_path)-1 ] == '\\' ) ) { - aux_path[strlen(aux_path)-1] = '\0'; // strip ending '/' if any + else + { + mEngine = prop; + xmlFree(prop); } - char up_path[PATH_MAX]; // up one level - ExtractFilePath( aux_path, up_path ); - mEnginePath = up_path; - } - prop = (char*)xmlGetProp(pNode, (xmlChar*)"engine"); - if (prop == NULL) - { + prop = (char*)xmlGetProp(pNode, (const xmlChar*)MP_ENGINE_ATTRIBUTE); + if (prop == NULL) + { #ifdef _WIN32 - mEngine = "quake3.exe"; + mMultiplayerEngine = "quake3.exe"; #elif __linux__ - mEngine = "quake3"; + mMultiplayerEngine = "quake3"; #elif __APPLE__ - mEngine = "Quake3.app"; + mMultiplayerEngine = "Quake3.app"; #endif - } - else - { - mEngine = prop; - xmlFree(prop); - } + } + else + { + mMultiplayerEngine = prop; + xmlFree(prop); + } + + { + // on win32, engine path can now be specified relative to the exe's cwd + prop = (char*)xmlGetProp(pNode, (const xmlChar *)ENGINEPATH_ATTRIBUTE); + if ( prop != NULL ) { + char full[PATH_MAX]; + #ifdef _WIN32 + _fullpath( full, prop, PATH_MAX ); + #else + strncpy( full, prop, PATH_MAX ); + #endif + xmlFree( prop ); + prop = NULL; + // process seperators + for ( p = full; *p != '\0'; p++ ) { + if ( *p == '\\' ) { + *p = '/'; + } + } + mEnginePath = full; + if ( p != full && *(p-1) != '/' ) { + mEnginePath += "/"; + } + } + else + { + // if engine path was not specified in the .game, it implies we can guess it from the gametools path + // on win32, and for most game package, the gametools are installed with the game + char aux_path[PATH_MAX]; // aux + strcpy( aux_path, mGameToolsPath.GetBuffer() ); + if ( ( aux_path[ strlen(aux_path)-1 ] == '/' ) || ( aux_path[ strlen(aux_path)-1 ] == '\\' ) ) { + aux_path[strlen(aux_path)-1] = '\0'; // strip ending '/' if any + } + char up_path[PATH_MAX]; // up one level + ExtractFilePath( aux_path, up_path ); + mEnginePath = up_path; + } + } #if defined (__linux__) || defined (__APPLE__) // *nix specific @@ -1361,7 +1416,6 @@ void CGameDialog::UpdateNetrun(bool retrieve) strNetrun = g_strAppPath; strNetrun += NETRUN_FILENAME; if (!retrieve) { - // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=639 // now check if we are running from a network installation // use a dummy file as the flag f_netrun = fopen(strNetrun.GetBuffer(), "r"); @@ -1667,6 +1721,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); @@ -1760,7 +1819,6 @@ void PrefsDlg::BuildDialog () #ifdef ATIHACK_812 // ATI bugs - // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=812 check = gtk_check_button_new_with_label (_("ATI cards with broken drivers - bug #802")); gtk_widget_show(check); gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0); @@ -2166,7 +2224,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); @@ -2286,6 +2344,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); @@ -2446,7 +2510,6 @@ void PrefsDlg::BuildDialog () (GtkAttachOptions) (0), 1, 0); AddDialogData (entry, &m_strPrefabPath, DLG_ENTRY_TEXT); - // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=805 #if 0 // browse button button = gtk_button_new_with_label ("..."); @@ -2485,6 +2548,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); @@ -2857,6 +2961,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); @@ -2874,7 +2979,7 @@ void PrefsDlg::LoadPrefs () // Texture subset on by default (HL specific really, because of halflife.wad's size) mLocalPrefs.GetPref(TEXTURE_KEY, &m_bTextureWindow, TRUE); } - else if ( ( g_pGameDescription->mGameFile == "q2.game" ) || ( g_pGameDescription->mGameFile == "heretic2.game" ) ) + else if (g_pGameDescription->quake2) { // BSP monitoring is implemented in Quake2 and Heretic2 tools mLocalPrefs.GetPref(WATCHBSP_KEY, &m_bWatchBSP, TRUE); @@ -2905,6 +3010,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); @@ -3171,14 +3277,14 @@ void CGameInstall::OnBtnBrowseEngine( GtkWidget *widget, gpointer data ) { Sys_Printf( "OnBtnBrowseEngine\n" ); CGameInstall* i = static_cast( 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 ); } } @@ -3234,6 +3340,15 @@ void CGameInstall::BuildDialog() { case GAME_NEXUIZ: gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), _("Nexuiz") ); break; + 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++; } @@ -3295,6 +3410,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; @@ -3308,16 +3426,16 @@ 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() ); } fprintf( fg, "\n\n" ); fclose( fg ); @@ -3440,6 +3597,17 @@ void CGameInstall::ScanGames() { if ( stricmp( dirname, Q2_PACK ) == 0 ) { m_availGames[ iGame++ ] = GAME_Q2; } + 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() ); }