};
-const char* file_dialog (void *parent, gboolean open, const char* title, const char* path, const char* pattern)
+/**
+ * @param[in] baseSubDir should have a trailing slash if not @c NULL
+ */
+const char* file_dialog (void *parent, gboolean open, const char* title, const char* path, const char* pattern, const char *baseSubDir)
{
// Gtk dialog
GtkWidget* file_sel;
else
{
#endif
+ char buf[PATH_MAX];
// do that the Gtk way
if (title == NULL)
title = open ? _("Open File") : _("Save File");
// we expect an actual path below, if the path is NULL we might crash
if (!path || path[0] == '\0')
{
-#ifdef _WIN32
- path = "C:\\";
-#elif defined (__linux__) || defined (__APPLE__)
- path = "/";
-#else
- path = "/";
-#endif
- }
+ strcpy(buf, g_pGameDescription->mEnginePath.GetBuffer());
+ strcat(buf, g_pGameDescription->mBaseGame.GetBuffer());
+ strcat(buf, "/");
+ if (baseSubDir)
+ strcat(buf, baseSubDir);
+ path = buf;
+ }
// alloc new path with extra char for dir separator
new_path = new char[strlen(path)+1+1];
*w = '\0';
#ifdef FILEDLG_DBG
- Sys_Printf("Done.\n");
- Sys_Printf("Calling gtk_file_selection_new with title: %s...", title);
+ Sys_Printf("Done.\n");
+ Sys_Printf("Calling gtk_file_selection_new with title: %s...", title);
#endif
-
file_sel = gtk_file_selection_new (title);
- gtk_file_selection_set_filename(GTK_FILE_SELECTION(file_sel), "/home/mattn/dev/ufoai/trunk/base/maps/");
-
#ifdef FILEDLG_DBG
- Sys_Printf("Done.\n");
- Sys_Printf("Set the masks...");
+ Sys_Printf("Done.\n");
+ Sys_Printf("Set the masks...");
#endif
#if 0 //!\todo Add masks to GtkFileSelection in gtk-2.0
if (new_path != NULL)
{
#ifdef FILEDLG_DBG
- Sys_Printf("gtk_file_selection_set_filename... %p", file_sel);
+ Sys_Printf("gtk_file_selection_set_filename... %p (%s)", file_sel, new_path);
#endif
gtk_file_selection_set_filename (GTK_FILE_SELECTION (file_sel), new_path);
delete[] new_path;
item = create_menu_item_with_mnemonic (menu, _("Previous leak spot"),
GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_PREVIOUSLEAKSPOT);
// http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=394
-// create_menu_item_with_mnemonic (menu, "_Print XY View", GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_PRINTXY);
+// create_menu_item_with_mnemonic (menu, _("_Print XY View"), GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_PRINTXY);
item = create_menu_item_with_mnemonic (menu, _("_Select Entity Color..."),
GTK_SIGNAL_FUNC (HandleCommand), ID_MISC_SELECTENTITYCOLOR);
g_object_set_data (G_OBJECT (window), "menu_misc_selectentitycolor", item);
const char *str;
char buf[NAME_MAX];
- strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer());
- strcat(buf, "maps/");
+ if (!g_pGameDescription->noMapsInHome) {
+ strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer());
+ strcat(buf, "maps/");
+ } else {
+ buf[0] = '\0';
+ }
- str = file_dialog (m_pWidget, TRUE, _("Open Map"), buf, MAP_MAJOR);
+ str = file_dialog (m_pWidget, TRUE, _("Open Map"), buf, MAP_MAJOR, "maps/");
if (str != NULL)
{
const char *str;
char buf[NAME_MAX];
- strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer());
- strcat(buf, "maps/");
+ if (!g_pGameDescription->noMapsInHome) {
+ strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer());
+ strcat(buf, "maps/");
+ } else {
+ buf[0] = '\0';
+ }
- str = file_dialog (m_pWidget, TRUE, _("Import Map"), buf, MAP_MAJOR);
+ str = file_dialog (m_pWidget, TRUE, _("Import Map"), buf, MAP_MAJOR, "maps/");
if (str != NULL)
{
const char* str;
char buf[NAME_MAX];
- strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer());
- strcat(buf, "maps/");
+ if (!g_pGameDescription->noMapsInHome) {
+ strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer());
+ strcat(buf, "maps/");
+ } else {
+ buf[0] = '\0';
+ }
- str = file_dialog (g_pParentWnd->m_pWidget, FALSE, _("Save Map"), buf, MAP_MAJOR);
+ str = file_dialog (g_pParentWnd->m_pWidget, FALSE, _("Save Map"), buf, MAP_MAJOR, "maps/");
if (str != NULL)
{
const char* str;
char buf[NAME_MAX];
- strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer());
- strcat(buf, "maps/");
+ if (!g_pGameDescription->noMapsInHome) {
+ strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer());
+ strcat(buf, "maps/");
+ } else {
+ buf[0] = '\0';
+ }
- str = file_dialog (m_pWidget, FALSE, _("Export Selection"), buf, MAP_MAJOR);
+ str = file_dialog (m_pWidget, FALSE, _("Export Selection"), buf, MAP_MAJOR, "maps/");
if (str != NULL)
{
const char* str;
char buf[NAME_MAX];
- strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer());
- strcat(buf, "maps/");
+ if (!g_pGameDescription->noMapsInHome) {
+ strcpy(buf, g_qeglobals.m_strHomeMaps.GetBuffer());
+ strcat(buf, "maps/");
+ } else {
+ buf[0] = '\0';
+ }
- str = file_dialog (g_pParentWnd->m_pWidget, FALSE, _("Export Region"), buf, MAP_MAJOR);
+ str = file_dialog (g_pParentWnd->m_pWidget, FALSE, _("Export Region"), buf, MAP_MAJOR, "maps/");
if (str != NULL)
{
AddSlash (CurPath);
}
- filename = file_dialog (m_pWidget, TRUE, _("Import Prefab"), CurPath.GetBuffer(), MAP_MAJOR);
+ filename = file_dialog (m_pWidget, TRUE, _("Import Prefab"), CurPath.GetBuffer(), MAP_MAJOR, "prefabs/");
if (filename != NULL)
{
}
AddSlash (CurPath);
- filename = file_dialog (m_pWidget, FALSE, _("Export Prefab"), CurPath.GetBuffer(), MAP_MAJOR);
+ filename = file_dialog (m_pWidget, FALSE, _("Export Prefab"), CurPath.GetBuffer(), MAP_MAJOR, "prefabs/");
if (filename != NULL)
{
Map_SaveSelected(filename);