Changeset 286

Show
Ignore:
Timestamp:
06/26/08 13:50:18 (2 months ago)
Author:
mattn
Message:

* introduced a new config variable to be able to load maps directly from the enginePath/basePath/maps directory

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • GtkRadiant/trunk/radiant/gtkmisc.cpp

    r285 r286  
    11981198}; 
    11991199 
    1200 const char* file_dialog (void *parent, gboolean open, const char* title, const char* path, const char* pattern) 
     1200/** 
     1201 * @param[in] baseSubDir should have a trailing slash if not @c NULL 
     1202 */ 
     1203const char* file_dialog (void *parent, gboolean open, const char* title, const char* path, const char* pattern, const char *baseSubDir) 
    12011204{ 
    12021205  // Gtk dialog 
     
    12911294  { 
    12921295#endif 
     1296        char buf[PATH_MAX]; 
    12931297    // do that the Gtk way 
    12941298    if (title == NULL) 
     
    13011305    if (!path || path[0] == '\0') 
    13021306    { 
    1303 #ifdef _WIN32 
    1304       path = "C:\\"; 
    1305 #elif defined (__linux__) || defined (__APPLE__) 
    1306       path = "/"; 
    1307 #else 
    1308       path = "/"; 
    1309 #endif 
    1310     } 
     1307                strcpy(buf, g_pGameDescription->mEnginePath.GetBuffer()); 
     1308                strcat(buf, g_pGameDescription->mBaseGame.GetBuffer()); 
     1309                strcat(buf, "/"); 
     1310                if (baseSubDir) 
     1311                        strcat(buf, baseSubDir); 
     1312                path = buf; 
     1313        } 
    13111314 
    13121315    // alloc new path with extra char for dir separator 
     
    13211324 
    13221325#ifdef FILEDLG_DBG 
    1323     Sys_Printf("Done.\n"); 
    1324     Sys_Printf("Calling gtk_file_selection_new with title: %s...", title); 
    1325 #endif 
    1326  
     1326        Sys_Printf("Done.\n"); 
     1327        Sys_Printf("Calling gtk_file_selection_new with title: %s...", title); 
     1328#endif 
    13271329    file_sel = gtk_file_selection_new (title); 
    1328         gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_sel), "/home/mattn/dev/ufoai/trunk/base/maps/"); 
    1329  
    1330 #ifdef FILEDLG_DBG 
    1331     Sys_Printf("Done.\n"); 
    1332     Sys_Printf("Set the masks..."); 
     1330#ifdef FILEDLG_DBG 
     1331        Sys_Printf("Done.\n"); 
     1332        Sys_Printf("Set the masks..."); 
    13331333#endif 
    13341334 
     
    13811381    { 
    13821382#ifdef FILEDLG_DBG 
    1383       Sys_Printf("gtk_file_selection_set_filename... %p", file_sel); 
     1383      Sys_Printf("gtk_file_selection_set_filename... %p (%s)", file_sel, new_path); 
    13841384#endif 
    13851385      gtk_file_selection_set_filename (GTK_FILE_SELECTION (file_sel), new_path); 
  • GtkRadiant/trunk/radiant/gtkmisc.h

    r264 r286  
    8282// NOTE: the returned filename is allocated with g_malloc and MUST be freed with g_free (both for win32 and Gtk dialogs) 
    8383// GtkWidget *parent 
    84 const char* file_dialog (void *parent, gboolean open, const char* title, const char* path = (char*)NULL, const char* pattern = NULL); 
     84const char* file_dialog (void *parent, gboolean open, const char* title, const char* path = (char*)NULL, const char* pattern = NULL, const char *baseSubDir = NULL); 
    8585 
    8686/*! 
  • GtkRadiant/trunk/radiant/mainframe.cpp

    r275 r286  
    14261426                           GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_PREVIOUSLEAKSPOT); 
    14271427  // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394 
    1428 //  create_menu_item_with_mnemonic (menu, "_Print XY View", GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_PRINTXY); 
     1428//  create_menu_item_with_mnemonic (menu, _("_Print XY View"), GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_PRINTXY); 
    14291429  item = create_menu_item_with_mnemonic (menu, _("_Select Entity Color..."), 
    14301430                           GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_SELECTENTITYCOLOR); 
     
    42654265        char buf[NAME_MAX]; 
    42664266 
    4267   strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); 
    4268   strcat(buf, "maps/"); 
    4269  
    4270   str = file_dialog (m_pWidget, TRUE, _("Open Map"), buf, MAP_MAJOR); 
     4267        if (!g_pGameDescription->noMapsInHome) { 
     4268                strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); 
     4269                strcat(buf, "maps/"); 
     4270        } else { 
     4271                buf[0] = '\0'; 
     4272        } 
     4273 
     4274  str = file_dialog (m_pWidget, TRUE, _("Open Map"), buf, MAP_MAJOR, "maps/"); 
    42714275 
    42724276  if (str != NULL) 
     
    42834287        char buf[NAME_MAX]; 
    42844288 
    4285   strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); 
    4286   strcat(buf, "maps/"); 
    4287  
    4288   str = file_dialog (m_pWidget, TRUE, _("Import Map"), buf, MAP_MAJOR); 
     4289        if (!g_pGameDescription->noMapsInHome) { 
     4290                strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); 
     4291                strcat(buf, "maps/"); 
     4292        } else { 
     4293                buf[0] = '\0'; 
     4294        } 
     4295 
     4296  str = file_dialog (m_pWidget, TRUE, _("Import Map"), buf, MAP_MAJOR, "maps/"); 
    42894297 
    42904298  if (str != NULL) 
     
    43074315        char buf[NAME_MAX]; 
    43084316 
    4309   strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); 
    4310   strcat(buf, "maps/"); 
    4311  
    4312   str = file_dialog (g_pParentWnd->m_pWidget, FALSE, _("Save Map"), buf, MAP_MAJOR); 
     4317        if (!g_pGameDescription->noMapsInHome) { 
     4318                strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); 
     4319                strcat(buf, "maps/"); 
     4320        } else { 
     4321                buf[0] = '\0'; 
     4322        } 
     4323 
     4324  str = file_dialog (g_pParentWnd->m_pWidget, FALSE, _("Save Map"), buf, MAP_MAJOR, "maps/"); 
    43134325 
    43144326  if (str != NULL) 
     
    43254337        char buf[NAME_MAX]; 
    43264338 
    4327   strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); 
    4328   strcat(buf, "maps/"); 
    4329  
    4330   str = file_dialog (m_pWidget, FALSE, _("Export Selection"), buf, MAP_MAJOR); 
     4339        if (!g_pGameDescription->noMapsInHome) { 
     4340                strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); 
     4341                strcat(buf, "maps/"); 
     4342        } else { 
     4343                buf[0] = '\0'; 
     4344        } 
     4345 
     4346  str = file_dialog (m_pWidget, FALSE, _("Export Selection"), buf, MAP_MAJOR, "maps/"); 
    43314347 
    43324348  if (str != NULL) 
     
    43414357        char buf[NAME_MAX]; 
    43424358 
    4343   strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); 
    4344   strcat(buf, "maps/"); 
    4345  
    4346   str = file_dialog (g_pParentWnd->m_pWidget, FALSE, _("Export Region"), buf, MAP_MAJOR); 
     4359        if (!g_pGameDescription->noMapsInHome) { 
     4360                strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer()); 
     4361                strcat(buf, "maps/"); 
     4362        } else { 
     4363                buf[0] = '\0'; 
     4364        } 
     4365 
     4366  str = file_dialog (g_pParentWnd->m_pWidget, FALSE, _("Export Region"), buf, MAP_MAJOR, "maps/"); 
    43474367 
    43484368  if (str != NULL) 
     
    45774597  } 
    45784598 
    4579   filename = file_dialog (m_pWidget, TRUE, _("Import Prefab"), CurPath.GetBuffer(), MAP_MAJOR); 
     4599  filename = file_dialog (m_pWidget, TRUE, _("Import Prefab"), CurPath.GetBuffer(), MAP_MAJOR, "prefabs/"); 
    45804600 
    45814601  if (filename != NULL) 
     
    46014621  AddSlash (CurPath); 
    46024622 
    4603   filename = file_dialog (m_pWidget, FALSE, _("Export Prefab"), CurPath.GetBuffer(), MAP_MAJOR); 
     4623  filename = file_dialog (m_pWidget, FALSE, _("Export Prefab"), CurPath.GetBuffer(), MAP_MAJOR, "prefabs/"); 
    46044624  if (filename != NULL) 
    46054625  { 
  • GtkRadiant/trunk/radiant/preferences.cpp

    r285 r286  
    760760  } 
    761761 
     762  // if this is set, the open maps dialoge will open the engine path not the 
     763  // home dir for map loading and saving 
     764  prop = (char*)xmlGetProp(pNode, (xmlChar*)"no_maps_in_home"); 
     765  if (prop == NULL) 
     766  { 
     767    // default 
     768    noMapsInHome = false; 
     769  } 
     770  else 
     771  { 
     772    noMapsInHome = true; 
     773    xmlFree(prop); 
     774  } 
     775 
    762776  prop = (char*)xmlGetProp(pNode, (xmlChar*)"basegame"); 
    763777  if (prop == NULL) 
  • GtkRadiant/trunk/radiant/preferences.h

    r264 r286  
    182182  Str mCaulkShader; ///< the shader to use for caulking 
    183183  bool quake2; ///< set this to true to get quake2 
     184  bool noMapsInHome; ///< set this if you want to open the engine path/base dir/maps dir for map open/save dialoges */ 
    184185 
    185186  CGameDescription() { mpDoc = NULL; }