configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
+# convert list into pascal array
+list(LENGTH FONTS_DIRS ndirs)
+set(FONTS_DIRS_ARRAY "array [0..${ndirs}] of PChar = (")
+foreach(fontdir ${FONTS_DIRS})
+ set(FONTS_DIRS_ARRAY "${FONTS_DIRS_ARRAY}\n'${fontdir}',")
+endforeach(fontdir)
+set(FONTS_DIRS_ARRAY "${FONTS_DIRS_ARRAY}\nnil);\n")
+
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
#set the sources with the correct order of dependencies so that cmake won't be confused
set(engine_sources
interface
uses SDLh, LuaPas;
+{$INCLUDE "config.inc"}
+
const PhysfsLibName = {$IFDEF PHYSFS_INTERNAL}'libhwphysfs'{$ELSE}'libphysfs'{$ENDIF};
const PhyslayerLibName = 'libphyslayer';
function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl ; external PhyslayerLibName;
function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external PhyslayerLibName;
-function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external PhysfsLibName;
+function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongBool; cdecl; external PhysfsLibName;
function PHYSFS_openRead(fname: PChar): PFSFile; cdecl; external PhysfsLibName;
function PHYSFS_eof(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
function PHYSFS_readBytes(f: PFSFile; buffer: pointer; len: Int64): Int64; cdecl; external PhysfsLibName;
function PHYSFS_close(f: PFSFile): LongBool; cdecl; external PhysfsLibName;
function PHYSFS_exists(fname: PChar): LongBool; cdecl; external PhysfsLibName;
+function PHYSFS_getLastError(): PChar; cdecl; external PhysfsLibName;
procedure hedgewarsMountPackages(); cdecl; external PhyslayerLibName;
pfsBlockRead:= r
end;
+procedure pfsMount(path: AnsiString; mountpoint: PChar);
+begin
+ if PHYSFS_mount(Str2PChar(path), mountpoint, false) then
+ AddFileLog('[PhysFS] mount ' + path + ' at ' + mountpoint + ' : ok')
+ else
+ AddFileLog('[PhysFS] mount ' + path + ' at ' + mountpoint + ' : FAILED ("' + PHYSFS_getLastError() + '")');
+end;
+
+procedure pfsMountAtRoot(path: AnsiString);
+begin
+ pfsMount(path, '/');
+end;
+
procedure initModule;
var i: LongInt;
cPhysfsId: shortstring;
+ fp: PChar;
begin
{$IFDEF HWLIBRARY}
//TODO: http://icculus.org/pipermail/physfs/2011-August/001006.html
i:= PHYSFS_init(Str2PChar(cPhysfsId));
AddFileLog('[PhysFS] init: ' + inttostr(i));
- i:= PHYSFS_mount(Str2PChar(PathPrefix), nil, false);
- AddFileLog('[PhysFS] mount ' + PathPrefix + ': ' + inttostr(i));
- i:= PHYSFS_mount(Str2PChar(UserPathPrefix + '/Data'), nil, false);
- AddFileLog('[PhysFS] mount ' + UserPathPrefix + '/Data: ' + inttostr(i));
+ // mount system fonts paths first
+ for i:= low(cFontsPaths) to high(cFontsPaths) do
+ begin
+ fp := cFontsPaths[i];
+ if fp <> nil then
+ pfsMount(fp, '/Fonts');
+ end;
+
+ pfsMountAtRoot(PathPrefix);
+ pfsMountAtRoot(UserPathPrefix + '/Data');
hedgewarsMountPackages;
- i:= PHYSFS_mount(Str2PChar(UserPathPrefix), nil, false);
// need access to teams and frontend configs (for bindings)
- AddFileLog('[PhysFS] mount ' + UserPathPrefix + ': ' + inttostr(i));
+ pfsMountAtRoot(UserPathPrefix);
end;
procedure freeModule;
-install(FILES
+set(FONTFILES
DejaVuSans-Bold.ttf
- wqy-zenhei.ttc
- DESTINATION ${SHAREPATH}Data/Fonts)
+ wqy-zenhei.ttc)
+
+if (FONTS_DIRS)
+ foreach(fontfile ${FONTFILES})
+ set(missing 1)
+ foreach(fontdir ${FONTS_DIRS})
+ if (EXISTS "${fontdir}/${fontfile}")
+ message(STATUS "Fonts: Found ${fontfile} in ${fontdir}")
+ set(missing 0)
+ break()
+ endif()
+ endforeach(fontdir)
+ if(missing)
+ set(MISSINGFONTFILES ${MISSINGFONTFILES} ${fontfile})
+ message(STATUS "Fonts: Could not find ${fontfile}, it will be installed")
+ endif()
+ endforeach(fontfile)
+else()
+ set(MISSINGFONTFILES ${FONTFILES})
+endif()
+
+if (MISSINGFONTFILES)
+ install(FILES ${MISSINGFONTFILES} DESTINATION ${SHAREPATH}Data/Fonts)
+endif()