Subversion Repositories spk

Rev

Rev 160 | Rev 180 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 160 Rev 170
Line 2... Line 2...
2
 
2
 
3
namespace SPK {
3
namespace SPK {
4
	s_int GetAutomaticFiletype(CyString file, CyString *extradir, bool bUseSpecial)
4
	s_int GetAutomaticFiletype(const Utils::String &file, Utils::String *extradir, bool bUseSpecial)
5
	{
5
	{
6
		CFileIO File(file);
6
		CFileIO File(file);
7
		Utils::String dir = File.GetDirIO().topDir();
7
		Utils::String dir = File.GetDirIO().topDir();
8
 
8
 
9
		CyString basename = File.baseName();
9
		Utils::String basename = File.baseName();
10
		// could be a script, text file or map
10
		// could be a script, text file or map
11
		s_int type = -1;
11
		s_int type = -1;
12
		if ( dir.Compare("types") || dir.Compare("mov") || dir.Compare("s") )
12
		if ( dir.Compare("types") || dir.Compare("mov") || dir.Compare("s") )
13
		{
13
		{
14
			type = FILETYPE_EXTRA;
14
			type = FILETYPE_EXTRA;
Line 22... Line 22...
22
			if ( File.filename().isin("-L") && ((int)File.filename().left(4)) )
22
			if ( File.filename().isin("-L") && ((int)File.filename().left(4)) )
23
				type = FILETYPE_TEXT;
23
				type = FILETYPE_TEXT;
24
			if ( File.baseName().Compare("conversations") )
24
			if ( File.baseName().Compare("conversations") )
25
				type = FILETYPE_TEXT;
25
				type = FILETYPE_TEXT;
26
			// X2/X3 text file
26
			// X2/X3 text file
27
			else if ( basename.Length() >= 5 && basename.Length() <= 8 && ((int)File.baseName()) )
27
			else if ( basename.length() >= 5 && basename.length() <= 8 && ((int)File.baseName()) )
28
				type = FILETYPE_TEXT;
28
				type = FILETYPE_TEXT;
29
			else if ( dir.Compare("maps") )
29
			else if ( dir.Compare("maps") )
30
				type = FILETYPE_MAP;
30
				type = FILETYPE_MAP;
31
			else if ( dir.Compare("t") )
31
			else if ( dir.Compare("t") )
32
				type = FILETYPE_TEXT;
32
				type = FILETYPE_TEXT;
33
			else if ( (bUseSpecial) && (dir.Compare("scripts") && basename.IsIn("uninstall")) )
33
			else if ( (bUseSpecial) && (dir.Compare("scripts") && basename.contains("uninstall")) )
34
				type = FILETYPE_SCRIPT_UNINSTALL;
34
				type = FILETYPE_SCRIPT_UNINSTALL;
35
			else if ( dir.Compare("uninstall") || basename.IsIn("uninstall") )
35
			else if ( dir.Compare("uninstall") || basename.contains("uninstall") )
36
				type = FILETYPE_UNINSTALL;
36
				type = FILETYPE_UNINSTALL;
37
			else if ( dir.isin("uninstall") )
37
			else if ( dir.isin("uninstall") )
38
				type = FILETYPE_UNINSTALL;
38
				type = FILETYPE_UNINSTALL;
39
			else if ( dir.Compare("director") )
39
			else if ( dir.Compare("director") )
40
				type = FILETYPE_MISSION;
40
				type = FILETYPE_MISSION;
41
		}
41
		}
42
		// could be a model file or scene file
42
		// could be a model file or scene file
43
		else if ( File.isFileExtension("pbd") || File.isFileExtension("bod") )
43
		else if ( File.isFileExtension("pbd") || File.isFileExtension("bod") )
44
		{
44
		{
45
			if ( dir.isin("cockpit") || basename.IsIn("cockpit") )
45
			if ( dir.isin("cockpit") || basename.contains("cockpit") )
46
				type = FILETYPE_COCKPITSCENE;
46
				type = FILETYPE_COCKPITSCENE;
47
			else
47
			else
48
				type = FILETYPE_SHIPSCENE;
48
				type = FILETYPE_SHIPSCENE;
49
		}
49
		}
50
		// can only be a model
50
		// can only be a model
Line 74... Line 74...
74
	//TODO: check for special types
74
	//TODO: check for special types
75
	void AssignAutomaticFiletypes(CyStringList *list)
75
	void AssignAutomaticFiletypes(CyStringList *list)
76
	{
76
	{
77
		for ( SStringList *str = list->Head(); str; str = str->next )
77
		for ( SStringList *str = list->Head(); str; str = str->next )
78
		{
78
		{
79
			CyString extradir;
79
			Utils::String extradir;
80
			s_int type = SPK::GetAutomaticFiletype(str->str, &extradir, false);
80
			s_int type = SPK::GetAutomaticFiletype(str->str.ToString(), &extradir, false);
81
 
81
 
82
			if ( type == FILETYPE_EXTRA && !extradir.Empty() )
82
			if ( type == FILETYPE_EXTRA && !extradir.empty() )
83
				str->data = CyString::Number(type) + " " + extradir;
83
				str->data = CyString::Number(type) + " " + extradir;
84
			else
84
			else
85
				str->data = CyString::Number(type);
85
				str->data = CyString::Number(type);
86
		}
86
		}
87
	}
87
	}
Line 125... Line 125...
125
				break;
125
				break;
126
		}
126
		}
127
		return s;
127
		return s;
128
	}
128
	}
129
 
129
 
130
	bool WriteScriptStyleSheet(CyString dest)
130
	bool WriteScriptStyleSheet(const Utils::String &dest)
131
	{
131
	{
132
		Utils::CStringList list;
132
		Utils::CStringList list;
133
		list.pushBack("<?xml version=\"1.0\" ?>");
133
		list.pushBack("<?xml version=\"1.0\" ?>");
134
		list.pushBack("<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" >");
134
		list.pushBack("<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" >");
135
		list.pushBack("<xsl:template match=\"/\">");
135
		list.pushBack("<xsl:template match=\"/\">");