forked from Mirrors/openclonk
Mac: Put game data into bundle
This makes it possible to ship the bundle stand-alone. Also note that CMake will automatically pack the game data for release builds, but sym-link the game data for debug builds. Note this means you will only see the parts of planet/ that are mentioned in OC_C4GROUPS in CMakeList.txt! This is equivalent to the behaviour of the shipped build, so I don't see this as a problem.
parent
a432f571ea
commit
e8173c224c
|
@ -1298,12 +1298,21 @@ set(OC_C4GROUPS
|
||||||
get_target_property(C4GROUP_LOCATION c4group LOCATION)
|
get_target_property(C4GROUP_LOCATION c4group LOCATION)
|
||||||
get_target_property(CLONK_LOCATION clonk LOCATION)
|
get_target_property(CLONK_LOCATION clonk LOCATION)
|
||||||
foreach(group ${OC_C4GROUPS})
|
foreach(group ${OC_C4GROUPS})
|
||||||
add_custom_command(
|
if (APPLE)
|
||||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${group}
|
add_custom_command(TARGET clonk
|
||||||
COMMAND ${C4GROUP_LOCATION} ${CMAKE_CURRENT_SOURCE_DIR}/planet/${group} -t ${CMAKE_CURRENT_BINARY_DIR}/${group}
|
POST_BUILD COMMAND "/bin/sh" "${CMAKE_CURRENT_SOURCE_DIR}/tools/osx_pack_gamedata.sh"
|
||||||
DEPENDS c4group ${CMAKE_CURRENT_SOURCE_DIR}/planet/${group}
|
"${C4GROUP_LOCATION}"
|
||||||
VERBATIM
|
"${CMAKE_CURRENT_SOURCE_DIR}/planet/${group}"
|
||||||
)
|
DEPENDS c4group
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${group}
|
||||||
|
COMMAND ${C4GROUP_LOCATION} ${CMAKE_CURRENT_SOURCE_DIR}/planet/${group} -t ${CMAKE_CURRENT_BINARY_DIR}/${group}
|
||||||
|
DEPENDS c4group ${CMAKE_CURRENT_SOURCE_DIR}/planet/${group}
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
find_program(MAKENSIS makensis PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS])
|
find_program(MAKENSIS makensis PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS])
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <C4Reloc.h>
|
#include <C4Reloc.h>
|
||||||
|
|
||||||
#include <C4Config.h>
|
#include <C4Config.h>
|
||||||
|
#include <C4Application.h>
|
||||||
|
|
||||||
C4Reloc Reloc; // singleton
|
C4Reloc Reloc; // singleton
|
||||||
|
|
||||||
|
@ -31,9 +32,15 @@ void C4Reloc::Init()
|
||||||
// but for distribution it might make sense to disable it.
|
// but for distribution it might make sense to disable it.
|
||||||
// TODO: We might also want to add ExePath/planet if it exists, so that we don't
|
// TODO: We might also want to add ExePath/planet if it exists, so that we don't
|
||||||
// need to run the engine in planet/.
|
// need to run the engine in planet/.
|
||||||
|
|
||||||
|
#ifdef USE_COCOA
|
||||||
|
AddPath(::Application.GetGameDataPath().getData());
|
||||||
|
#else
|
||||||
AddPath(Config.General.ExePath.getData());
|
AddPath(Config.General.ExePath.getData());
|
||||||
AddPath(Config.General.UserDataPath);
|
|
||||||
AddPath(Config.General.SystemDataPath);
|
AddPath(Config.General.SystemDataPath);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
AddPath(Config.General.UserDataPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool C4Reloc::AddPath(const char* path)
|
bool C4Reloc::AddPath(const char* path)
|
||||||
|
|
|
@ -99,7 +99,6 @@
|
||||||
{
|
{
|
||||||
if (!([self argsLookLikeItShouldBeInstallation] && [self installAddOn]))
|
if (!([self argsLookLikeItShouldBeInstallation] && [self installAddOn]))
|
||||||
{
|
{
|
||||||
[[NSFileManager defaultManager] changeCurrentDirectoryPath:[self clonkDirectory]];
|
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
|
|
||||||
[self makeFakeArgs];
|
[self makeFakeArgs];
|
||||||
|
|
|
@ -177,6 +177,7 @@ protected:
|
||||||
# endif
|
# endif
|
||||||
#ifdef USE_COCOA
|
#ifdef USE_COCOA
|
||||||
void HandleNSEvent(/*NSEvent*/void* event);
|
void HandleNSEvent(/*NSEvent*/void* event);
|
||||||
|
StdStrBuf GetGameDataPath();
|
||||||
#endif
|
#endif
|
||||||
const char * Location;
|
const char * Location;
|
||||||
pthread_t MainThread;
|
pthread_t MainThread;
|
||||||
|
|
|
@ -86,7 +86,7 @@ bool CStdApp::Init(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
// Set locale
|
// Set locale
|
||||||
setlocale(LC_ALL,"");
|
setlocale(LC_ALL,"");
|
||||||
|
|
||||||
// Custom initialization
|
// Custom initialization
|
||||||
return DoInit (argc, argv);
|
return DoInit (argc, argv);
|
||||||
}
|
}
|
||||||
|
@ -161,6 +161,11 @@ void CStdApp::RestoreVideoMode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StdStrBuf CStdApp::GetGameDataPath()
|
||||||
|
{
|
||||||
|
return StdCopyStrBuf([[[NSBundle mainBundle] resourcePath] fileSystemRepresentation]);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool IsGermanSystem()
|
bool IsGermanSystem()
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
C4GROUP=$1
|
||||||
|
SRC_GROUP=$2
|
||||||
|
|
||||||
|
RESOURCES=$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH
|
||||||
|
TARGET_GROUP=$RESOURCES/`basename $SRC_GROUP`
|
||||||
|
|
||||||
|
should_update() {
|
||||||
|
for i in `find $SRC_GROUP`; do
|
||||||
|
if [ $i -nt $TARGET_GROUP ]; then return 0; fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ "$CONFIGURATION" == "Release" ]
|
||||||
|
then if should_update
|
||||||
|
then echo Packing $TARGET_GROUP...
|
||||||
|
rm -f $TARGET_GROUP
|
||||||
|
cd $RESOURCES
|
||||||
|
$C4GROUP $SRC_GROUP -t $TARGET_GROUP
|
||||||
|
else echo No changes found for $TARGET_GROUP, skipping
|
||||||
|
fi
|
||||||
|
else echo Linking $TARGET_GROUP...
|
||||||
|
rm -f $TARGET_GROUP
|
||||||
|
ln -sf $SRC_GROUP $TARGET_GROUP
|
||||||
|
fi
|
Loading…
Reference in New Issue