• R/O
  • SSH
  • HTTPS

magic-rw: Commit


Commit MetaInfo

Revision91 (tree)
Zeit2020-09-17 06:30:16
Autorquiret

Log Message

- added RWLIB_DEFAULT_REPOSITORY_DIR build configuration variable for Win32 building which can be used to reposition the resource file lookup directory relative to the current directory at RenderWare engine late initialization phase
- made the unit test use the latest resource files from the repository instead of the empty output directory that the application starts in

god bless C++11 raw string literals; they saved my ass here!

Ändern Zusammenfassung

Diff

--- rwlib/build/vs2015/customprops.xml (revision 90)
+++ rwlib/build/vs2015/customprops.xml (revision 91)
@@ -1,3 +1,4 @@
1+<?xml version="1.0" encoding="utf-8"?>
12 <!--
23 /*****************************************************************************
34 *
@@ -12,7 +13,6 @@
1213 *****************************************************************************/
1314 -->
1415
15-<?xml version="1.0" encoding="utf-8"?>
1616 <ProjectSchemaDefinitions xmlns="http://schemas.microsoft.com/build/2009/properties"
1717 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
1818 xmlns:sys="clr-namespace:System;assembly=mscorlib">
@@ -221,5 +221,10 @@
221221 <sys:String>Enables PowerVR version 2 native image file format processing by Imagination Technologies.</sys:String>
222222 </BoolProperty.Description>
223223 </BoolProperty>
224+ <StringProperty Name="RWLIB_DEFAULT_REPOSITORY_DIR" Category="RW_Runtime" IsRequired="true"
225+ DisplayName="Default Repository Directory"
226+ Description="Relative directory from the current directory where the resource files of magic-rw are located."
227+ Subtype="Folder"
228+ />
224229 </Rule>
225230 </ProjectSchemaDefinitions>
\ No newline at end of file
--- rwlib/include/renderware.file.h (revision 90)
+++ rwlib/include/renderware.file.h (revision 91)
@@ -44,7 +44,7 @@
4444 typedef rwStaticSet <rwStaticString <wchar_t>, lexical_string_comparator <true>> fileList_t;
4545
4646 virtual bool GetBasedDirectory ( const wchar_t *streamPath, rwStaticString <wchar_t>& fullPathOut ) const = 0;
47- virtual fileList_t GetDirectoryListing ( const wchar_t *listingDir, bool recursive ) const = 0;
47+ virtual fileList_t GetDirectoryListing ( const wchar_t *listingDir, const wchar_t *pattern, bool recursive ) const = 0;
4848 };
4949
5050 // Ability to set the current directory translator.
--- rwlib/src/rwfile.system.cpp (revision 90)
+++ rwlib/src/rwfile.system.cpp (revision 91)
@@ -16,6 +16,15 @@
1616
1717 #include "pluginutil.hxx"
1818
19+// Decide on what directory separator we want to use.
20+#ifdef _WIN32
21+#define PATH_SEP L"\\"
22+#elif defined(__linux__)
23+#define PATH_SEP L"/"
24+#else
25+#error no path separator defined for platform
26+#endif
27+
1928 namespace rw
2029 {
2130
@@ -75,7 +84,13 @@
7584
7685 // This is the fallback, which passes the file request _directly_ to the system.
7786 // We do prepend a directory tho.
78- rwStaticString <wchar_t> prepend_main_dir = L"magic-rw/";
87+ rwStaticString <wchar_t> prepend_main_dir =
88+#ifdef RWLIB_DEFAULT_REPOSITORY_DIR
89+ RWLIB_DEFAULT_REPOSITORY_DIR
90+#else
91+ L"magic-rw"
92+#endif
93+ PATH_SEP;
7994 prepend_main_dir += filePath;
8095
8196 rw::streamConstructionFileParamW_t wFileParam( prepend_main_dir.GetConstString() );
@@ -83,7 +98,7 @@
8398 return engineInterface->CreateStream( rw::RWSTREAMTYPE_FILE_W, mode, &wFileParam );
8499 }
85100
86-FileTranslator::fileList_t GetDirectoryListing( EngineInterface *rwEngine, const wchar_t *dir, bool recursive )
101+FileTranslator::fileList_t GetDirectoryListing( EngineInterface *rwEngine, const wchar_t *dir, const wchar_t *file_pattern, bool recursive )
87102 {
88103 dataRepositoryEnv *repoEnv = dataRepositoryEnvRegister.get().GetPluginStruct( rwEngine );
89104
@@ -93,7 +108,7 @@
93108
94109 if ( fileTrans )
95110 {
96- return fileTrans->GetDirectoryListing( dir, recursive );
111+ return fileTrans->GetDirectoryListing( dir, file_pattern, recursive );
97112 }
98113 }
99114
--- rwlib/src/rwfile.system.hxx (revision 90)
+++ rwlib/src/rwfile.system.hxx (revision 91)
@@ -22,7 +22,7 @@
2222
2323 // RW-wide data access interface.
2424 Stream* OpenDataStream( EngineInterface *engineInterface, const wchar_t *filePath, eStreamMode mode );
25-FileTranslator::fileList_t GetDirectoryListing( EngineInterface *rwEngine, const wchar_t *dir, bool recursive = false );
25+FileTranslator::fileList_t GetDirectoryListing( EngineInterface *rwEngine, const wchar_t *dir, const wchar_t *file_pattern, bool recursive = false );
2626
2727 }
2828
--- rwlib/src/rwlocalization.cpp (revision 90)
+++ rwlib/src/rwlocalization.cpp (revision 91)
@@ -172,11 +172,14 @@
172172 void late_init( EngineInterface *engine )
173173 {
174174 // TODO: load all language files from the engine.
175- FileTranslator::fileList_t language_files = fs::GetDirectoryListing( engine, L"languages/*.lang" );
175+ FileTranslator::fileList_t language_files = fs::GetDirectoryListing( engine, L"languages/", L"*.lang" );
176176
177- // We shall try some special files aswell.
178- language_files.Insert( L"languages/en.lang" );
179- language_files.Insert( L"languages/de.lang" );
177+ if ( language_files.IsEmpty() )
178+ {
179+ // We shall try some special files aswell.
180+ language_files.Insert( L"languages/en.lang" );
181+ language_files.Insert( L"languages/de.lang" );
182+ }
180183
181184 for ( auto filename : language_files )
182185 {
Show on old repository browser