about summary refs log tree commit diff
path: root/src/game/editor
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2010-09-16 12:48:32 +0200
committeroy <Tom_Adams@web.de>2010-09-16 12:48:32 +0200
commita2083b31e3692c97c3f74291d94b4fbb32a36cc6 (patch)
treed8348cb53203a8c5d02f0c4b099e77bd43bac1fe /src/game/editor
parent582763bc2148138e7da310268b58fdde4e6a6c43 (diff)
downloadzcatch-a2083b31e3692c97c3f74291d94b4fbb32a36cc6.tar.gz
zcatch-a2083b31e3692c97c3f74291d94b4fbb32a36cc6.zip
fixed last commit
Diffstat (limited to 'src/game/editor')
-rw-r--r--src/game/editor/ed_editor.cpp36
-rw-r--r--src/game/editor/ed_editor.h6
2 files changed, 35 insertions, 7 deletions
diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp
index 9a997ce9..a8e3b832 100644
--- a/src/game/editor/ed_editor.cpp
+++ b/src/game/editor/ed_editor.cpp
@@ -567,13 +567,12 @@ static void CallbackOpenDir(const char *pFileName, void *pUser)
 	{
 		if(str_comp(pEditor->m_aFileDialogPath, "maps") == 0 || str_comp(pEditor->m_aFileDialogPath, "mapres") == 0)
 			return;
-		char aParentFolder[512];
-		fs_parent_dir(pEditor->m_aFileDialogPath, aParentFolder);
-		str_copy(pEditor->m_aFileDialogPath, aParentFolder, sizeof(pEditor->m_aFileDialogPath));
+		fs_parent_dir(pEditor->m_aFileDialogPath);
 	}
 	else
 		str_copy(pEditor->m_aFileDialogPath, pFileName, sizeof(pEditor->m_aFileDialogPath));
 	
+	pEditor->m_aFileDialogFileName[0] = 0;
 	pEditor->FilelistPopulate();
 }
 
@@ -604,6 +603,19 @@ static void CallbackOpenMap(const char *pFileName, void *pUser)
 static void CallbackAppendMap(const char *pFileName, void *pUser)
 {
 	CEditor *pEditor = (CEditor*)pUser;
+	if(str_comp(pEditor->m_aFileDialogFileName, "..") == 0)
+	{
+		CallbackOpenDir("..", pUser);
+		return;
+	}
+	char aCompleteFilename[512];
+	str_format(aCompleteFilename, sizeof(aCompleteFilename), "%s/%s", pEditor->Client()->UserDirectory(), pFileName);
+	if(fs_is_dir(aCompleteFilename))
+	{
+		CallbackOpenDir(pFileName, pUser);
+		return;
+	}
+
 	if(pEditor->Append(pFileName))
 		pEditor->m_aFileName[0] = 0;
 	else
@@ -613,6 +625,20 @@ static void CallbackAppendMap(const char *pFileName, void *pUser)
 }
 static void CallbackSaveMap(const char *pFileName, void *pUser)
 {
+	CEditor *pEditor = static_cast<CEditor*>(pUser);
+	if(str_comp(pEditor->m_aFileDialogFileName, "..") == 0)
+	{
+		CallbackOpenDir("..", pUser);
+		return;
+	}
+	char aCompleteFilename[512];
+	str_format(aCompleteFilename, sizeof(aCompleteFilename), "%s/%s", pEditor->Client()->UserDirectory(), pFileName);
+	if(fs_is_dir(aCompleteFilename))
+	{
+		CallbackOpenDir(pFileName, pUser);
+		return;
+	}
+
 	char aBuf[1024];
 	const int Length = str_length(pFileName);
 	// add map extension
@@ -622,7 +648,6 @@ static void CallbackSaveMap(const char *pFileName, void *pUser)
 		pFileName = aBuf;
 	}
 
-	CEditor *pEditor = static_cast<CEditor*>(pUser);
 	if(pEditor->Save(pFileName))
 		str_copy(pEditor->m_aFileName, pFileName, sizeof(pEditor->m_aFileName));
 	
@@ -2123,6 +2148,9 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View)
 
 static void EditorListdirCallback(const char *pName, int IsDir, void *pUser)
 {
+	if(pName[0] == '.' && pName[1] == 0)

+		return;
+
 	CEditor *pEditor = (CEditor*)pUser;
 	pEditor->m_FileList.add(string(pName));
 }
diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h
index f7d6d15f..30ec7203 100644
--- a/src/game/editor/ed_editor.h
+++ b/src/game/editor/ed_editor.h
@@ -460,9 +460,9 @@ public:
 		m_aFileName[0] = 0;
 		
 		m_FileDialogDirTypes = 0;
-		m_pFileDialogTitle = NULL;
-		m_pFileDialogButtonText = NULL;
-		m_pFileDialogUser = NULL;
+		m_pFileDialogTitle = 0;
+		m_pFileDialogButtonText = 0;
+		m_pFileDialogUser = 0;
 		m_aFileDialogFileName[0] = 0;
 		m_aFileDialogPath[0] = 0;
 		m_aFileDialogCompleteFilename[0] = 0;