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.
Peter Wortmann 2011-10-09 17:09:48 +01:00
parent c0a1e343c6
commit ad79ece074
6 changed files with 56 additions and 8 deletions

View File

@ -1297,12 +1297,21 @@ set(OC_C4GROUPS
get_target_property(C4GROUP_LOCATION c4group LOCATION)
get_target_property(CLONK_LOCATION clonk LOCATION)
foreach(group ${OC_C4GROUPS})
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
)
if (APPLE)
add_custom_command(TARGET clonk
POST_BUILD COMMAND "/bin/sh" "${CMAKE_CURRENT_SOURCE_DIR}/tools/osx_pack_gamedata.sh"
"${C4GROUP_LOCATION}"
"${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()
find_program(MAKENSIS makensis PATHS [HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS])

View File

@ -19,6 +19,7 @@
#include <C4Reloc.h>
#include <C4Config.h>
#include <C4Application.h>
C4Reloc Reloc; // singleton
@ -31,9 +32,15 @@ void C4Reloc::Init()
// 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
// need to run the engine in planet/.
#ifdef USE_COCOA
AddPath(::Application.GetGameDataPath().getData());
#else
AddPath(Config.General.ExePath.getData());
AddPath(Config.General.UserDataPath);
AddPath(Config.General.SystemDataPath);
#endif
AddPath(Config.General.UserDataPath);
}
bool C4Reloc::AddPath(const char* path)

View File

@ -177,6 +177,7 @@ protected:
# endif
#ifdef USE_COCOA
void HandleNSEvent(/*NSEvent*/void* event);
StdStrBuf GetGameDataPath();
#endif
const char * Location;
pthread_t MainThread;

View File

@ -161,6 +161,11 @@ void CStdApp::RestoreVideoMode()
{
}
StdStrBuf CStdApp::GetGameDataPath()
{
return StdCopyStrBuf([[[NSBundle mainBundle] resourcePath] fileSystemRepresentation]);
}
#endif
bool IsGermanSystem()

View File

@ -99,7 +99,6 @@
{
if (!([self argsLookLikeItShouldBeInstallation] && [self installAddOn]))
{
[[NSFileManager defaultManager] changeCurrentDirectoryPath:[self clonkDirectory]];
[NSApp activateIgnoringOtherApps:YES];
[self makeFakeArgs];

View File

@ -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