diff --git a/.hgignore b/.hgignore
index 1de44aa..8156970 100644
--- a/.hgignore
+++ b/.hgignore
@@ -1,6 +1,6 @@
syntax: glob
-aee
+mappy
recursos/*
bin/*
obj/*
@@ -13,4 +13,7 @@ data/*
*.user
*.dll
.DS_Store
-trick.ini
\ No newline at end of file
+trick.ini
+*.xcuserstate
+project.xcworkspace/
+xcuserdata/
\ No newline at end of file
diff --git a/Info.plist b/Info.plist
new file mode 100644
index 0000000..08c7d01
--- /dev/null
+++ b/Info.plist
@@ -0,0 +1,34 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIconFile
+
+ CFBundleIdentifier
+ $(PRODUCT_BUNDLE_IDENTIFIER)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ $(PRODUCT_NAME)
+ CFBundlePackageType
+ APPL
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ 1
+ LSApplicationCategoryType
+ public.app-category.developer-tools
+ LSMinimumSystemVersion
+ $(MACOSX_DEPLOYMENT_TARGET)
+ NSHumanReadableCopyright
+ Copyright © 2016 Raimon Zamora. All rights reserved.
+ NSPrincipalClass
+ NSApplication
+
+
diff --git a/main.cpp b/main.cpp
index 7407707..0ed30c6 100644
--- a/main.cpp
+++ b/main.cpp
@@ -50,6 +50,8 @@ char map_filename[100] = { 0 };
int tilemap_width = 0;
int tilemap_height = 0;
+char path[400] = {0};
+
unsigned char* map = nullptr;
int map_x = 0;
int map_y = 0;
@@ -57,6 +59,13 @@ int map_y = 0;
int tile_sel = 0;
int tile_back = 0;
+const char* GetPath(const char* filename) {
+ static char fullpath[400];
+ strcpy(fullpath, path);
+ strcat(fullpath, filename);
+ return fullpath;
+}
+
int StrToInt(const char* str) {
int val = 0;
int size = strlen(str);
@@ -68,7 +77,7 @@ int StrToInt(const char* str) {
}
void LoadConfig() {
- FILE* f = fopen("config.ini", "r");
+ FILE* f = fopen(GetPath("config.ini"), "r");
if (!f) { error = 1; return; }
char key[50];
char val[255];
@@ -121,7 +130,7 @@ void Init() {
free(pixels);
int c;
- FILE* f = fopen(tiles_filename, "rb");
+ FILE* f = fopen(GetPath(tiles_filename), "rb");
if (!f) { error = 2; return; }
buffer = stbi_load_from_file(f, &tilemap_width, &tilemap_height, &c, 4);
sdlTilesTexture = SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STATIC, tilemap_width, tilemap_height);
@@ -153,7 +162,7 @@ void Init() {
}
stbi_image_free(buffer);
- f = fopen(map_filename, "rb");
+ f = fopen(GetPath(map_filename), "rb");
map = (unsigned char*)malloc(map_width*map_height);
if (f) {
int old_map_width = 0, old_map_height = 0;
@@ -176,7 +185,7 @@ void Init() {
}
fclose(f);
} else {
- f = fopen(map_filename, "wb");
+ f = fopen(GetPath(map_filename), "wb");
if (!f) { error = 3; return; }
fwrite(&map_width, 1, 1, f);
fwrite(&map_height, 1, 1, f);
@@ -368,7 +377,7 @@ void DoTileMap() {
if (keyJustPressed == SDL_SCANCODE_TAB) { menu = false; return; }
FillRect(0, 0, screen_width, screen_height, 0, 0, 0, 192);
if (Button(6, 6, "Save")) {
- FILE* f = fopen(map_filename, "wb");
+ FILE* f = fopen(GetPath(map_filename), "wb");
fwrite(&map_width, 1, 1, f);
fwrite(&map_height, 1, 1, f);
fwrite(map, map_width*map_height, 1, f);
@@ -454,6 +463,9 @@ void DoMiniMap() {
}
int main(int argc, char* argv[]) {
+ const int len = strlen(argv[0])-30;
+ memcpy(path, argv[0], len);
+ path[len] = '\0';
Init();
while (!Update()) {
diff --git a/mappy.xcodeproj/project.pbxproj b/mappy.xcodeproj/project.pbxproj
new file mode 100644
index 0000000..b1db118
--- /dev/null
+++ b/mappy.xcodeproj/project.pbxproj
@@ -0,0 +1,284 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 02252FB81C764D2E002D1DA1 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 02252FB71C764D2E002D1DA1 /* main.cpp */; };
+ 02B01D591C767C1700CD186D /* SDL2_image.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02B01D581C767C1700CD186D /* SDL2_image.framework */; };
+ 02B01D5B1C767C2C00CD186D /* SDL2_mixer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02B01D5A1C767C2C00CD186D /* SDL2_mixer.framework */; };
+ 02EA2BEF1C764B3800E5A247 /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 02EA2BEE1C764B3800E5A247 /* SDL2.framework */; };
+ 02F8248B1C772310007AAE83 /* gif.c in Sources */ = {isa = PBXBuildFile; fileRef = 02F8248A1C772310007AAE83 /* gif.c */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ 02252FB71C764D2E002D1DA1 /* main.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = main.cpp; sourceTree = ""; };
+ 02B01D581C767C1700CD186D /* SDL2_image.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2_image.framework; path = ../../../../../Library/Frameworks/SDL2_image.framework; sourceTree = ""; };
+ 02B01D5A1C767C2C00CD186D /* SDL2_mixer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2_mixer.framework; path = ../../../../../Library/Frameworks/SDL2_mixer.framework; sourceTree = ""; };
+ 02CF35B91C7649C300180C9F /* mappy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = mappy.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 02CF35C71C7649C300180C9F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
+ 02EA2BEE1C764B3800E5A247 /* SDL2.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDL2.framework; path = ../../../../../Library/Frameworks/SDL2.framework; sourceTree = ""; };
+ 02F23A4E1CEE2D460005FAE2 /* font.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = font.h; sourceTree = ""; };
+ 02F23A4F1CEE2D460005FAE2 /* stb_image.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = stb_image.h; sourceTree = ""; };
+ 02F8248A1C772310007AAE83 /* gif.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gif.c; sourceTree = ""; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 02CF35B61C7649C300180C9F /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 02B01D5B1C767C2C00CD186D /* SDL2_mixer.framework in Frameworks */,
+ 02B01D591C767C1700CD186D /* SDL2_image.framework in Frameworks */,
+ 02EA2BEF1C764B3800E5A247 /* SDL2.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 02CF35B01C7649C300180C9F = {
+ isa = PBXGroup;
+ children = (
+ 02F23A4E1CEE2D460005FAE2 /* font.h */,
+ 02F23A4F1CEE2D460005FAE2 /* stb_image.h */,
+ 02F8248A1C772310007AAE83 /* gif.c */,
+ 02252FB71C764D2E002D1DA1 /* main.cpp */,
+ 02CF35C71C7649C300180C9F /* Info.plist */,
+ 02EA2BEE1C764B3800E5A247 /* SDL2.framework */,
+ 02B01D581C767C1700CD186D /* SDL2_image.framework */,
+ 02B01D5A1C767C2C00CD186D /* SDL2_mixer.framework */,
+ 02CF35BA1C7649C300180C9F /* Products */,
+ );
+ sourceTree = "";
+ };
+ 02CF35BA1C7649C300180C9F /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 02CF35B91C7649C300180C9F /* mappy.app */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 02CF35B81C7649C300180C9F /* mappy */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 02CF35CA1C7649C300180C9F /* Build configuration list for PBXNativeTarget "mappy" */;
+ buildPhases = (
+ 02CF35B51C7649C300180C9F /* Sources */,
+ 02CF35B61C7649C300180C9F /* Frameworks */,
+ 02CF35B71C7649C300180C9F /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = mappy;
+ productName = mappy;
+ productReference = 02CF35B91C7649C300180C9F /* mappy.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 02CF35B11C7649C300180C9F /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0720;
+ ORGANIZATIONNAME = "Raimon Zamora";
+ TargetAttributes = {
+ 02CF35B81C7649C300180C9F = {
+ CreatedOnToolsVersion = 7.2;
+ };
+ };
+ };
+ buildConfigurationList = 02CF35B41C7649C300180C9F /* Build configuration list for PBXProject "mappy" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ Base,
+ );
+ mainGroup = 02CF35B01C7649C300180C9F;
+ productRefGroup = 02CF35BA1C7649C300180C9F /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 02CF35B81C7649C300180C9F /* mappy */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ 02CF35B71C7649C300180C9F /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 02CF35B51C7649C300180C9F /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 02252FB81C764D2E002D1DA1 /* main.cpp in Sources */,
+ 02F8248B1C772310007AAE83 /* gif.c in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 02CF35C81C7649C300180C9F /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = macosx;
+ };
+ name = Debug;
+ };
+ 02CF35C91C7649C300180C9F /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CODE_SIGN_IDENTITY = "-";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = macosx;
+ };
+ name = Release;
+ };
+ 02CF35CB1C7649C300180C9F /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(LOCAL_LIBRARY_DIR)/Frameworks",
+ );
+ HEADER_SEARCH_PATHS = (
+ "$(LOCAL_LIBRARY_DIR)/Frameworks/SDL2.framework/headers",
+ "$(LOCAL_LIBRARY_DIR)/Frameworks/SDL2_image.framework/headers",
+ "$(LOCAL_LIBRARY_DIR)/Frameworks/SDL2_mixer.framework/headers",
+ );
+ INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = net.jailers.mappy;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ 02CF35CC1C7649C300180C9F /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ COMBINE_HIDPI_IMAGES = YES;
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(LOCAL_LIBRARY_DIR)/Frameworks",
+ );
+ HEADER_SEARCH_PATHS = (
+ "$(LOCAL_LIBRARY_DIR)/Frameworks/SDL2.framework/headers",
+ "$(LOCAL_LIBRARY_DIR)/Frameworks/SDL2_image.framework/headers",
+ "$(LOCAL_LIBRARY_DIR)/Frameworks/SDL2_mixer.framework/headers",
+ );
+ INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = net.jailers.mappy;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 02CF35B41C7649C300180C9F /* Build configuration list for PBXProject "mappy" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 02CF35C81C7649C300180C9F /* Debug */,
+ 02CF35C91C7649C300180C9F /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 02CF35CA1C7649C300180C9F /* Build configuration list for PBXNativeTarget "mappy" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 02CF35CB1C7649C300180C9F /* Debug */,
+ 02CF35CC1C7649C300180C9F /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 02CF35B11C7649C300180C9F /* Project object */;
+}