1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2024-12-16 10:21:15 +01:00

Mac build changes.

This commit is contained in:
gyboth 2009-05-01 12:19:16 +00:00
parent fbba2fb4ef
commit 9060069235
5 changed files with 66 additions and 30 deletions

View File

@ -746,7 +746,8 @@ file_get_first_support_dir(void)
while (elem) while (elem)
{ {
if(g_str_has_suffix((gchar*)elem->data, HOMEDIRNAME) || if(g_str_has_suffix((gchar*)elem->data, HOMEDIRNAME) ||
g_str_has_suffix((gchar*)elem->data, "support_files")) g_str_has_suffix((gchar*)elem->data, "support_files") ||
g_str_has_suffix((gchar*)elem->data, "support_files" G_DIR_SEPARATOR_S))
return (const gchar*)elem->data; return (const gchar*)elem->data;
elem = elem->next; elem = elem->next;
@ -1007,3 +1008,25 @@ file_load_text_from_saves(const gchar *filename)
return g_strdup(buf); return g_strdup(buf);
} }
/** Return the path to a resource in the Mac OS X bundle. */
gchar*
file_get_mac_resource_path(const gchar *resource)
{
#ifndef MAC_BUILD
return NULL;
#else
gchar buf[SMALL];
CFURLRef newurlref;
CFStringRef newstring = CFStringCreateWithCString(NULL, resource, kCFStringEncodingASCII);
newurlref = CFBundleCopyResourceURL(CFBundleGetMainBundle(), newstring, NULL, NULL);
CFRelease(newstring);
newstring = CFURLCopyPath(newurlref);
CFStringGetCString(newstring, buf, SMALL + 1, kCFStringEncodingASCII);
CFRelease(newurlref);
CFRelease(newstring);
return g_strdup(buf);
#endif
}

View File

@ -115,4 +115,7 @@ file_load_text_from_saves(const gchar *filename);
void void
file_store_text_in_saves(const gchar *filename, const gchar *text); file_store_text_in_saves(const gchar *filename, const gchar *text);
gchar*
file_get_mac_resource_path(const gchar *resource);
#endif #endif

View File

@ -26,6 +26,7 @@
#include <locale.h> #include <locale.h>
#include "callbacks.h" #include "callbacks.h"
#include "file.h"
#include "free.h" #include "free.h"
#include "language.h" #include "language.h"
#include "lg_commentary.h" #include "lg_commentary.h"
@ -48,7 +49,7 @@ language_set(gint index)
#endif #endif
gchar buf[SMALL], buf2[SMALL]; gchar buf[SMALL], buf2[SMALL];
gchar *pwd = g_get_current_dir(); gchar *dir;
GPtrArray *codes = GPtrArray *codes =
misc_separate_strings(const_str("string_language_codes")); misc_separate_strings(const_str("string_language_codes"));
@ -60,7 +61,15 @@ language_set(gint index)
if(strcmp(buf, opt_str("string_opt_language_code")) != 0 || if(strcmp(buf, opt_str("string_opt_language_code")) != 0 ||
window.main == NULL) window.main == NULL)
{ {
sprintf(buf2, "%s%slocale", pwd, G_DIR_SEPARATOR_S); #ifndef MAC_BUILD
dir = g_get_current_dir();
sprintf(buf2, "%s%slocale", dir, G_DIR_SEPARATOR_S);
#else
dir = file_get_mac_resource_path("locale");
strcpy(buf2, dir);
#endif
g_free(dir);
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
if(g_file_test(buf2, G_FILE_TEST_EXISTS)) if(g_file_test(buf2, G_FILE_TEST_EXISTS))
{ {
@ -88,7 +97,6 @@ language_set(gint index)
lg_commentary_load_commentary_file_from_option(); lg_commentary_load_commentary_file_from_option();
news_load_news_file_from_option(); news_load_news_file_from_option();
g_free(pwd);
free_gchar_array(&codes); free_gchar_array(&codes);
} }

View File

@ -61,6 +61,14 @@
#include "window.h" #include "window.h"
#include "xml_strategy.h" #include "xml_strategy.h"
#define DEBUG_LEVEL_DEFAULT 0
#if defined(MAC_BUILD) || defined(G_OS_WIN32)
#define DEBUG_OUTPUT_DEFAULT 2
#else
#define DEBUG_OUTPUT_DEFAULT 0
#endif
/** Whether the last save gets loaded at startup /** Whether the last save gets loaded at startup
(cl switch -l). */ (cl switch -l). */
gboolean load_last_save; gboolean load_last_save;
@ -129,7 +137,11 @@ main_parse_cl_arguments(gint *argc, gchar ***argv)
g_option_context_parse(context, argc, argv, &error); g_option_context_parse(context, argc, argv, &error);
g_option_context_free(context); g_option_context_free(context);
misc_print_error(&error, TRUE); if(error != NULL)
{
misc_print_error(&error, FALSE);
return;
}
if(calodds) if(calodds)
{ {
@ -188,6 +200,9 @@ main_parse_debug_cl_arguments(gint *argc, gchar ***argv)
"[developer] A debug command like 'deb100 to set the debug level'; see the debug window and debug.c", "STRING" }, "[developer] A debug command like 'deb100 to set the debug level'; see the debug window and debug.c", "STRING" },
{NULL}}; {NULL}};
debug_level = DEBUG_LEVEL_DEFAULT;
debug_output = DEBUG_OUTPUT_DEFAULT;
if(argc == NULL || argv == NULL) if(argc == NULL || argv == NULL)
return; return;
@ -200,19 +215,16 @@ main_parse_debug_cl_arguments(gint *argc, gchar ***argv)
if(error != NULL) if(error != NULL)
{ {
debug_print_message("error message: %s\n", error->message); misc_print_error(&error, FALSE);
g_error_free(error);
return; return;
} }
debug_level = 0;
if(deb_level != -1) if(deb_level != -1)
{ {
debug_level = deb_level; debug_level = deb_level;
window_create(WINDOW_DEBUG); window_create(WINDOW_DEBUG);
} }
debug_output = DEBUG_OUT_STDOUT;
if(deb_output != -1) if(deb_output != -1)
debug_output = deb_output; debug_output = deb_output;
@ -326,6 +338,7 @@ main_init(gint *argc, gchar ***argv)
#endif #endif
gchar buf[SMALL]; gchar buf[SMALL];
gchar *dir;
support_directories = NULL; support_directories = NULL;
rand_generator = g_rand_new(); rand_generator = g_rand_new();
@ -337,31 +350,23 @@ main_init(gint *argc, gchar ***argv)
os_is_unix = TRUE; os_is_unix = TRUE;
#endif #endif
#ifdef G_OS_UNIX #if defined(G_OS_UNIX) && !defined(MAC_BUILD)
#ifndef MAC_BUILD
file_add_support_directory_recursive(PACKAGE_DATA_DIR "/" PACKAGE "/support_files"); file_add_support_directory_recursive(PACKAGE_DATA_DIR "/" PACKAGE "/support_files");
sprintf(buf, "%s%s%s", g_get_home_dir(), G_DIR_SEPARATOR_S, HOMEDIRNAME); sprintf(buf, "%s%s%s", g_get_home_dir(), G_DIR_SEPARATOR_S, HOMEDIRNAME);
file_add_support_directory_recursive(buf); file_add_support_directory_recursive(buf);
#endif #endif
#endif
#ifndef MAC_BUILD #ifndef MAC_BUILD
gchar *pwd = g_get_current_dir(); dir = g_get_current_dir();
sprintf(buf, "%s%ssupport_files", pwd, G_DIR_SEPARATOR_S); sprintf(buf, "%s%ssupport_files", dir, G_DIR_SEPARATOR_S);
file_add_support_directory_recursive(buf); file_add_support_directory_recursive(buf);
sprintf(buf, "%s%ssaves", pwd, G_DIR_SEPARATOR_S);
sprintf(buf, "%s%ssaves", dir, G_DIR_SEPARATOR_S);
file_add_support_directory_recursive(buf); file_add_support_directory_recursive(buf);
g_free(pwd); g_free(dir);
#else #else
CFURLRef newurlref; dir = file_get_mac_resource_path("support_files");
CFStringRef newstring = CFSTR("support_files"); file_add_support_directory_recursive(dir);
newurlref = CFBundleCopyResourceURL(CFBundleGetMainBundle(), newstring, NULL, NULL);
newstring = CFURLCopyPath(newurlref);
CFStringGetCString(newstring, buf, SMALL + 1, kCFStringEncodingASCII);
file_add_support_directory_recursive(buf);
CFRelease(newurlref);
CFRelease(newstring);
#endif #endif
main_init_variables(); main_init_variables();
@ -383,13 +388,11 @@ main (gint argc, gchar *argv[])
printf("main\n"); printf("main\n");
#endif #endif
#ifdef ENABLE_NLS #if defined(ENABLE_NLS) && !defined(MAC_BUILD)
#ifndef MAC_BUILD
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE); textdomain (GETTEXT_PACKAGE);
#endif #endif
#endif
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
int fd1 = open ("stdout.log", O_CREAT|O_WRONLY|O_TRUNC, 0666); int fd1 = open ("stdout.log", O_CREAT|O_WRONLY|O_TRUNC, 0666);
dup2 (fd1, 1); dup2 (fd1, 1);

View File

@ -9,7 +9,6 @@ string_contrib_title Definitions team
string_contrib_entry Mihai Floran (mihai@bygfoot.com) string_contrib_entry Mihai Floran (mihai@bygfoot.com)
string_contrib_entry Christopher Hunter (chris@bygfoot.com) string_contrib_entry Christopher Hunter (chris@bygfoot.com)
string_contrib_entry Ivan Ramirez (ircarrascal@bygfoot.com) string_contrib_entry Ivan Ramirez (ircarrascal@bygfoot.com)
string_contrib_entry Tommasi (tommasi@bygfoot.com)
string_contrib_title Artwork string_contrib_title Artwork
string_contrib_entry Mark D. Symonds, Marcelo Garrone string_contrib_entry Mark D. Symonds, Marcelo Garrone