Skip to content

Commit

Permalink
macOS version 1.6.002
Browse files Browse the repository at this point in the history
  • Loading branch information
drodin committed Sep 8, 2020
1 parent d36cf8b commit 0887ea9
Show file tree
Hide file tree
Showing 11 changed files with 140 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
/mapc.exe
/contrib/curve.exe
/*.dll

/assets

.DS_Store
70 changes: 61 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ HunterGate(

project(neverball)

if(NOT ANDROID)
find_package(OpenGL)
find_package(intl)
else()
if(ANDROID)
set(OPENGL_LIBRARIES -lGLESv1_CM)
else()
find_package(OpenGL MODULE REQUIRED)
if (NOT APPLE)
find_package(intl)
endif()
endif()

hunter_add_package(SDL2)
Expand Down Expand Up @@ -204,11 +206,7 @@ elseif(ENABLE_FS STREQUAL "physfs")
list(APPEND PUTT_SRC share/fs_physfs.c)
endif()

if(NOT ANDROID)
add_executable(mapc ${MAPC_SRC})
add_executable(neverball ${BALL_SRC})
add_executable(neverputt ${PUTT_SRC})
else()
if(ANDROID)
add_library(neverball SHARED ${BALL_SRC})
add_library(neverputt SHARED ${PUTT_SRC})

Expand All @@ -223,6 +221,58 @@ else()
set(ENABLE_NLS OFF)

set_target_properties(neverball neverputt PROPERTIES DEBUG_POSTFIX "")
elseif(APPLE)
file(GLOB SHARE_DATA RELATIVE ${CMAKE_CURRENT_LIST_DIR} assets/share/data/*)
file(GLOB BALL_DATA RELATIVE ${CMAKE_CURRENT_LIST_DIR} assets/ball/data/*)
file(GLOB PUTT_DATA RELATIVE ${CMAKE_CURRENT_LIST_DIR} assets/putt/data/*)

add_executable(neverball MACOSX_BUNDLE ${BALL_SRC} ${BALL_DATA} ${SHARE_DATA} apple/macos/neverball.icns apple/macos/neverball.entitlements)
add_executable(neverputt MACOSX_BUNDLE ${PUTT_SRC} ${PUTT_DATA} ${SHARE_DATA} apple/macos/neverputt.icns apple/macos/neverputt.entitlements)

set(MACOSX_BUNDLE_APP_CATEGORY "public.app-category.action-games")

set(VERSION_NAME "1.6.002")
target_compile_definitions(neverball PRIVATE VERSION=\"${VERSION_NAME}\")
target_compile_definitions(neverputt PRIVATE VERSION=\"${VERSION_NAME}\")

set(ENABLE_NLS OFF)

set_target_properties(neverball neverputt PROPERTIES
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_LIST_DIR}/cmake/template/MacOSXBundleInfo.plist.in"
MACOSX_BUNDLE_SHORT_VERSION_STRING "${VERSION_NAME}"
MACOSX_BUNDLE_BUNDLE_VERSION "2"
MACOSX_BUNDLE_COPYRIGHT "Copyright © 2020 Dmitry Rodin. All rights reserved."
XCODE_ATTRIBUTE_INSTALL_PATH "$(LOCAL_APPS_DIR)"
XCODE_ATTRIBUTE_SKIP_INSTALL "No"
XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "Mac Developer"
XCODE_ATTRIBUTE_DEVELOPMENT_TEAM "$ENV{CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM}"
XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES
)

set_target_properties(neverball PROPERTIES
OUTPUT_NAME "Neverball"
#MACOSX_BUNDLE_BUNDLE_NAME "Neverball"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.drodin.neverball"
MACOSX_BUNDLE_ICON_FILE "neverball"
XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "apple/macos/neverball.entitlements"
)

set_target_properties(neverputt PROPERTIES
OUTPUT_NAME "Neverputt"
#MACOSX_BUNDLE_BUNDLE_NAME "Neverputt"
MACOSX_BUNDLE_GUI_IDENTIFIER "com.drodin.neverputt"
MACOSX_BUNDLE_ICON_FILE "neverputt"
XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "apple/macos/neverputt.entitlements"
)

set_source_files_properties(${SHARE_DATA} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/data")
set_source_files_properties(${BALL_DATA} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/data")
set_source_files_properties(${PUTT_DATA} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources/data")
set_source_files_properties(apple/macos/neverball.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set_source_files_properties(apple/macos/neverputt.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
else()
add_executable(neverball ${BALL_SRC})
add_executable(neverputt ${PUTT_SRC})
endif()

set_property(GLOBAL PROPERTY C_STANDARD 99)
Expand Down Expand Up @@ -274,6 +324,8 @@ include_directories(
)

if(NOT ANDROID)
add_executable(mapc ${MAPC_SRC})

target_link_libraries(mapc
SDL2::SDL2
JPEG::jpeg
Expand Down
8 changes: 8 additions & 0 deletions apple/macos/neverball.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>
Binary file added apple/macos/neverball.icns
Binary file not shown.
8 changes: 8 additions & 0 deletions apple/macos/neverputt.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
</dict>
</plist>
Binary file added apple/macos/neverputt.icns
Binary file not shown.
2 changes: 1 addition & 1 deletion ball/st_help.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static int page_rules(int id)

gui_filler(jd);
}
#ifdef __MOBILE__
#if defined(__MOBILE__) || defined(__APPLE__)
gui_space(id);
gui_multi(id, "This game is distributed under the GPLv2 license.\\"
"For source code, visit drodin.com/neverball", GUI_SML, gui_yel, gui_wht);
Expand Down
5 changes: 5 additions & 0 deletions cmake/Hunter/config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ hunter_config(
SDL2
VERSION 2.0.7-p3
)
elseif(APPLE)
hunter_config(
SDL2
VERSION 2.0.12-p0
)
endif()
36 changes: 36 additions & 0 deletions cmake/template/MacOSXBundleInfo.plist.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleGetInfoString</key>
<string>${MACOSX_BUNDLE_INFO_STRING}</string>
<key>CFBundleIconFile</key>
<string>${MACOSX_BUNDLE_ICON_FILE}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleLongVersionString</key>
<string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
<key>CSResourcesFileMapped</key>
<true/>
<key>LSApplicationCategoryType</key>
<string>@MACOSX_BUNDLE_APP_CATEGORY@</string>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion putt/st_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static int title_enter(struct state *st, struct state *prev)
{
gui_start(kd, gt_prefix("menu^Play"), GUI_MED, TITLE_PLAY, 1);
gui_state(kd, gt_prefix("menu^Options"), GUI_MED, TITLE_CONF, 0);
#ifdef __MOBILE__
#if defined(__MOBILE__) || defined (__APPLE__)
gui_state(kd, gt_prefix("menu^Help"), GUI_MED, TITLE_HELP, 0);
#endif
#ifndef __MOBILE__
Expand Down
16 changes: 16 additions & 0 deletions share/base_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,27 @@
#include <shlobj.h>
#endif

#ifdef __APPLE__
#include <CoreServices/CoreServices.h>
#endif

/*---------------------------------------------------------------------------*/

static const char *pick_data_path(const char *arg_data_path)
{
static char dir[MAXSTR];
#ifdef __APPLE__
CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
const char *data_dir = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding());
CFRelease(appUrlRef);
CFRelease(macPath);

SAFECPY(dir, data_dir);
SAFECAT(dir, "/Contents/Resources/data");

return dir;
#endif
char *env;

if (arg_data_path)
Expand Down

0 comments on commit 0887ea9

Please sign in to comment.