diff --git a/CMakeLists.txt b/CMakeLists.txt index eae9df7..93c35b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,11 +107,11 @@ elseif(APPLE) # see http://cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29 # set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx") - set(CPACK_PACKAGE_ICON "") + set(CPACK_PACKAGE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/misc/mac/voxelands.icns) set(CPACK_BUNDLE_NAME ${PROJECT_NAME}) - set(CPACK_BUNDLE_ICON "") - set(CPACK_BUNDLE_PLIST "") - set(CPACK_BUNDLE_STARTUP_COMMAND "Contents/MacOS/${PROJECT_NAME}") + set(CPACK_BUNDLE_ICON ${CPACK_PACKAGE_ICON}) + set(CPACK_BUNDLE_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/misc/mac/Info.plist) + set(CPACK_BUNDLE_STARTUP_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bin/Debug/voxelands) set(CPACK_GENERATOR "Bundle") else() set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux") diff --git a/README.txt b/README.txt index bd7df77..298b97b 100644 --- a/README.txt +++ b/README.txt @@ -88,6 +88,21 @@ $ ./voxelands - You can select between Release and Debug build by -DCMAKE_BUILD_TYPE= - Debug build is slower, but gives much more useful output in a debugger +Compiling on Mac OS X +--------------------- +- You need: + * XCode 5 - https://developer.apple.com/xcode/downloads/ + * XCode commandline tools - https://developer.apple.com/downloads/ + * homebrew - http://brew.sh/ + +- Steps: + * Install dependencies + - brew install jpeg-turbo irrlicht + * make XCode project for client only + - cmake -DJPEG_INCLUDE_LIBRARY=/usr/local/Cellar/jpeg-turbo//include -DJPEG_LIBRARY=/usr/local/Cellar/jpeg-turbo/lib/libturbojpeg.a -DBUILD_SERVER=0 -DRUN_IN_PLACE=0 -G Xcode . + * build XCode project from commandline (If you're using the GUI, make sure to select "package" as build target) + - xcodebuild -project voxelands.xcodeproj -target package + Compiling on Windows: --------------------- diff --git a/misc/mac/Info.plist b/misc/mac/Info.plist new file mode 100644 index 0000000..7e460e0 --- /dev/null +++ b/misc/mac/Info.plist @@ -0,0 +1,34 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + voxelands + CFBundleIconFile + voxelands.icns + CFBundleIdentifier + darkrose.voxelands + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + voxelands + CFBundlePackageType + APPL + CFBundleShortVersionString + GIT_VERSION + CFBundleSignature + x86_64 + CFBundleVersion + GIT_VERSION + LSApplicationCategoryType + public.app-category.games + LSMinimumSystemVersion + ${MACOSX_DEPLOYMENT_TARGET} + NSMainNibFile + MainMenu + NSPrincipalClass + NSApplication + + diff --git a/misc/mac/MainMenu.xib b/misc/mac/MainMenu.xib new file mode 100644 index 0000000..c20f4d8 --- /dev/null +++ b/misc/mac/MainMenu.xib @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/misc/mac/voxelands.icns b/misc/mac/voxelands.icns new file mode 100644 index 0000000..14731c2 Binary files /dev/null and b/misc/mac/voxelands.icns differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b9435e..42469f0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -103,12 +103,15 @@ else() FIND_LIBRARY(CARBON_LIB Carbon) FIND_LIBRARY(COCOA_LIB Cocoa) FIND_LIBRARY(IOKIT_LIB IOKit) + FIND_LIBRARY(COREFOUNDATION_LIB CoreFoundation) mark_as_advanced( CARBON_LIB COCOA_LIB IOKIT_LIB + COREFOUNDATION_LIB ) - SET(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${CARBON_LIB} ${COCOA_LIB} ${IOKIT_LIB}) + SET(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${CARBON_LIB} ${COCOA_LIB} ${IOKIT_LIB} ${COREFOUNDATION_LIB}) + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework Cocoa") endif(APPLE) endif(BUILD_CLIENT) find_package(ZLIB REQUIRED) @@ -315,8 +318,8 @@ else() endif() if(APPLE) - set(CMAKE_OSX_ARCHITECTURES i386 CACHE STRING "do not build for 64-bit" FORCE) - set(ARCH i386) + set(CMAKE_OSX_ARCHITECTURES x86_64 FORCE) + set(ARCH x86_64) endif() set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops") @@ -397,6 +400,31 @@ if(BUILD_CLIENT) endif() endif(USE_GETTEXT) endif() + if(APPLE) + # TODO: install Irrlicht.framework into app bundle! + # it should be in Contents/Resources/Frameworks/Irrlicht.framework + + # Compile .xib files + # should be in Contents/Resources/MainMenu.nib at the end + set (VoxelandsMac_XIBS + MainMenu + ) + # Make sure the 'Resources' Directory is correctly created before we build + add_custom_command (TARGET ${PROJECT_NAME} PRE_BUILD + COMMAND mkdir -p ${EXECUTABLE_OUTPUT_PATH}/\${CONFIGURATION}/Contents/Resources) + find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin") + if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND") + message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin") + endif() + # Compile the .xib files using the 'ibtool' program with the destination being the app package + foreach(xib ${VoxelandsMac_XIBS}) + add_custom_command (TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text + --compile ${EXECUTABLE_OUTPUT_PATH}/\${CONFIGURATION}/Contents/Resources/${xib}.nib + ${CMAKE_SOURCE_DIR}/misc/mac/${xib}.xib + COMMENT "Compiling ${CMAKE_SOURCE_DIR}/${xib}.xib") + endforeach() + endif(APPLE) endif(BUILD_CLIENT) if(BUILD_SERVER) diff --git a/src/client.cpp b/src/client.cpp index a438224..95ed5df 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2000,9 +2000,9 @@ Inventory* Client::getInventory(InventoryContext *c, std::string id) if(id0 == "nodemeta") { v3s16 p; - p.X = stoi(fn.next(",")); - p.Y = stoi(fn.next(",")); - p.Z = stoi(fn.next(",")); + p.X = mystoi(fn.next(",")); + p.Y = mystoi(fn.next(",")); + p.Z = mystoi(fn.next(",")); NodeMetadata* meta = getNodeMetadata(p); if(meta) return meta->getInventory(); diff --git a/src/common_irrlicht.h b/src/common_irrlicht.h index fd07639..e816d53 100644 --- a/src/common_irrlicht.h +++ b/src/common_irrlicht.h @@ -63,6 +63,8 @@ typedef core::vector2d v2f32; typedef core::aabbox3d aabb3f; +// irrlicht 1.8+ has it's own irr::u64 +#if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2 #ifdef _MSC_VER // Windows typedef unsigned long long u64; @@ -70,7 +72,7 @@ typedef core::aabbox3d aabb3f; // Posix #include typedef uint64_t u64; - //typedef unsigned long long u64; +#endif #endif #endif diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index ce033ce..b0fca72 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -171,13 +171,13 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize) if(type == "invsize" || type == "size") { v2f invsize; - invsize.X = stof(f.next(",")); + invsize.X = mystof(f.next(",")); if(type == "size") { - invsize.Y = stof(f.next("]")); + invsize.Y = mystof(f.next("]")); } else{ - invsize.Y = stof(f.next(";")); + invsize.Y = mystof(f.next(";")); errorstream<<"WARNING: invsize is deprecated, use size"< 1.0) { - geom.Y = (stof(flabel.substr(flabel.find(",")+1)) * (float)spacing.Y)-(spacing.Y-imgsize.Y); + geom.X = (mystof(flabel.substr(0,flabel.find(","))) * (float)spacing.X)-(spacing.X-imgsize.X); + if (mystof(flabel.substr(flabel.find(",")+1)) > 1.0) { + geom.Y = (mystof(flabel.substr(flabel.find(",")+1)) * (float)spacing.Y)-(spacing.Y-imgsize.Y); multi = true; }else{ geom.Y = 30; } - pos.Y += ((stof(flabel.substr(flabel.find(",")+1)) * (float)imgsize.Y)/2)-15; + pos.Y += ((mystof(flabel.substr(flabel.find(",")+1)) * (float)imgsize.Y)/2)-15; rect = core::rect(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y); @@ -360,8 +360,8 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize) else if(type == "label") { v2s32 pos; - pos.X = stof(f.next(",")) * (float)spacing.X; - pos.Y = stof(f.next(";")) * (float)spacing.Y; + pos.X = mystof(f.next(",")) * (float)spacing.X; + pos.Y = mystof(f.next(";")) * (float)spacing.Y; rect = core::rect(pos.X, pos.Y+((imgsize.Y/2)-15), pos.X+300, pos.Y+((imgsize.Y/2)+15)); @@ -381,11 +381,11 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize) else if(type == "button" || type == "button_exit") { v2s32 pos; - pos.X = stof(f.next(",")) * (float)spacing.X; - pos.Y = stof(f.next(";")) * (float)spacing.Y; + pos.X = mystof(f.next(",")) * (float)spacing.X; + pos.Y = mystof(f.next(";")) * (float)spacing.Y; v2s32 geom; - geom.X = (stof(f.next(",")) * (float)spacing.X)-(spacing.X-imgsize.X); - pos.Y += (stof(f.next(";")) * (float)imgsize.Y)/2; + geom.X = (mystof(f.next(",")) * (float)spacing.X)-(spacing.X-imgsize.X); + pos.Y += (mystof(f.next(";")) * (float)imgsize.Y)/2; rect = core::rect(pos.X, pos.Y-15, pos.X+geom.X, pos.Y+15); @@ -409,11 +409,11 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize) else if(type == "image_button" || type == "image_button_exit") { v2s32 pos; - pos.X = stof(f.next(",")) * (float)spacing.X; - pos.Y = stof(f.next(";")) * (float)spacing.Y; + pos.X = mystof(f.next(",")) * (float)spacing.X; + pos.Y = mystof(f.next(";")) * (float)spacing.Y; v2s32 geom; - geom.X = (stof(f.next(",")) * (float)spacing.X)-(spacing.X-imgsize.X); - geom.Y = (stof(f.next(";")) * (float)spacing.Y)-(spacing.Y-imgsize.Y); + geom.X = (mystof(f.next(",")) * (float)spacing.X)-(spacing.X-imgsize.X); + geom.Y = (mystof(f.next(";")) * (float)spacing.Y)-(spacing.Y-imgsize.Y); rect = core::rect(pos.X, pos.Y, pos.X+geom.X, pos.Y+geom.Y); diff --git a/src/inventory.cpp b/src/inventory.cpp index 78330f4..44f0ba5 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -1004,9 +1004,9 @@ void InventoryLocation::deSerialize(std::istream &is) std::string pos; std::getline(is, pos, '\n'); Strfnd fn(pos); - p.X = stoi(fn.next(",")); - p.Y = stoi(fn.next(",")); - p.Z = stoi(fn.next(",")); + p.X = mystoi(fn.next(",")); + p.Y = mystoi(fn.next(",")); + p.Z = mystoi(fn.next(",")); }else{ infostream<<"Unknown InventoryLocation type=\""<set("new_style_leaves", itos(menudata.fancy_trees)); diff --git a/src/porting.cpp b/src/porting.cpp index 7c185ff..e894bd4 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -274,7 +274,7 @@ void initializePaths() { dstream<<"Bundle resource path: "<typeId() == CONTENT_LOCKABLE_CHEST) { @@ -4261,9 +4261,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) if(id0 == "nodemeta") { v3s16 p; - p.X = stoi(fn.next(",")); - p.Y = stoi(fn.next(",")); - p.Z = stoi(fn.next(",")); + p.X = mystoi(fn.next(",")); + p.Y = mystoi(fn.next(",")); + p.Z = mystoi(fn.next(",")); NodeMetadata *meta = m_env.getMap().getNodeMetadata(p); if (meta) { if (meta->typeId() == CONTENT_LOCKABLE_CHEST) { @@ -4611,9 +4611,9 @@ Inventory* Server::getInventory(InventoryContext *c, std::string id) if(id0 == "nodemeta") { v3s16 p; - p.X = stoi(fn.next(",")); - p.Y = stoi(fn.next(",")); - p.Z = stoi(fn.next(",")); + p.X = mystoi(fn.next(",")); + p.Y = mystoi(fn.next(",")); + p.Z = mystoi(fn.next(",")); NodeMetadata *meta = m_env.getMap().getNodeMetadata(p); if(meta) return meta->getInventory(); @@ -4642,9 +4642,9 @@ void Server::inventoryModified(InventoryContext *c, std::string id) if(id0 == "nodemeta") { v3s16 p; - p.X = stoi(fn.next(",")); - p.Y = stoi(fn.next(",")); - p.Z = stoi(fn.next(",")); + p.X = mystoi(fn.next(",")); + p.Y = mystoi(fn.next(",")); + p.Z = mystoi(fn.next(",")); v3s16 blockpos = getNodeBlockPos(p); NodeMetadata *meta = m_env.getMap().getNodeMetadata(p); diff --git a/src/servercommand.cpp b/src/servercommand.cpp index 083b907..74976a6 100644 --- a/src/servercommand.cpp +++ b/src/servercommand.cpp @@ -140,7 +140,7 @@ void cmd_time(std::wostringstream &os, return; } - u32 time = stoi(wide_to_narrow(ctx->parms[1])); + u32 time = mystoi(wide_to_narrow(ctx->parms[1])); ctx->server->setTimeOfDay(time); os<player->getName()<<" teleports from " <player->getPosition()/BS)<<" to " diff --git a/src/settings.h b/src/settings.h index d7e5143..9217500 100644 --- a/src/settings.h +++ b/src/settings.h @@ -453,12 +453,12 @@ public: float getFloat(std::string name) { - return stof(get(name)); + return mystof(get(name)); } u16 getU16(std::string name) { - return stoi(get(name), 0, 65535); + return mystoi(get(name), 0, 65535); } u16 getU16Ask(std::string name, std::string question, u16 def) @@ -476,17 +476,17 @@ public: if(s == "") return def; - return stoi(s, 0, 65535); + return mystoi(s, 0, 65535); } s16 getS16(std::string name) { - return stoi(get(name), -32768, 32767); + return mystoi(get(name), -32768, 32767); } s32 getS32(std::string name) { - return stoi(get(name)); + return mystoi(get(name)); } v3f getV3F(std::string name) @@ -494,9 +494,9 @@ public: v3f value; Strfnd f(get(name)); f.next("("); - value.X = stof(f.next(",")); - value.Y = stof(f.next(",")); - value.Z = stof(f.next(")")); + value.X = mystof(f.next(",")); + value.Y = mystof(f.next(",")); + value.Z = mystof(f.next(")")); return value; } @@ -505,8 +505,8 @@ public: v2f value; Strfnd f(get(name)); f.next("("); - value.X = stof(f.next(",")); - value.Y = stof(f.next(")")); + value.X = mystof(f.next(",")); + value.Y = mystof(f.next(")")); return value; } diff --git a/src/sound_openal.cpp b/src/sound_openal.cpp index 73050ce..5db36ab 100644 --- a/src/sound_openal.cpp +++ b/src/sound_openal.cpp @@ -32,7 +32,6 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #elif defined(__APPLE__) #include #include - #include #else #include #include diff --git a/src/tile.cpp b/src/tile.cpp index 3e54ddc..a28212d 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -801,7 +801,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg, } // Crack image number - u16 progression = stoi(part_of_name.substr(6)); + u16 progression = mystoi(part_of_name.substr(6)); // Size of the base image core::dimension2d dim_base = baseimg->getDimension(); @@ -886,15 +886,15 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg, { Strfnd sf(part_of_name); sf.next(":"); - u32 w0 = stoi(sf.next("x")); - u32 h0 = stoi(sf.next(":")); + u32 w0 = mystoi(sf.next("x")); + u32 h0 = mystoi(sf.next(":")); infostream<<"combined w="< max) @@ -914,21 +916,19 @@ inline s32 stoi(const std::string &s, s32 min, s32 max) return i; } - -// MSVC2010 includes it's own versions of these -#if !defined(_MSC_VER) || _MSC_VER < 1600 - -inline s32 stoi(std::string s) +inline s32 mywstoi(const std::wstring &s, s32 min=0, s32 max=0) { - return atoi(s.c_str()); + s32 i = atoi(wide_to_narrow(s).c_str()); + if (min == max) + return i; + if(i < min) + i = min; + if(i > max) + i = max; + return i; } -inline s32 stoi(std::wstring s) -{ - return atoi(wide_to_narrow(s).c_str()); -} - -inline float stof(std::string s) +inline float mystof(std::string s) { float f; std::istringstream ss(s); @@ -936,8 +936,6 @@ inline float stof(std::string s) return f; } -#endif - inline std::string itos(s32 i) { std::ostringstream o;