From ec63e3b18b749e0718503182bfadf9f9dde1f14e Mon Sep 17 00:00:00 2001 From: coppro Date: Thu, 21 Aug 2008 04:06:50 +0000 Subject: [PATCH] More workingness, now accepts locally-stored resources! git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1158 0fc631ac-6414-0410-93d0-97cfa31319b6 --- Makefile.am | 2 + Makefile.in | 23 +++++-- Resources.sh | 16 +++-- configure | 116 +++++++++++++++++++++++++++++++--- src/data/locale.cpp | 6 +- src/gui/util.cpp | 13 +++- src/script/value.cpp | 2 +- src/util/atomic.hpp | 2 +- tools/linux-installer/install | 8 +-- 9 files changed, 155 insertions(+), 33 deletions(-) diff --git a/Makefile.am b/Makefile.am index 6539c18b..6df29620 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,6 +65,7 @@ magicseteditor_SOURCES += ./src/script/scriptable.cpp magicseteditor_SOURCES += ./src/script/script_manager.cpp magicseteditor_SOURCES += ./src/script/functions/english.cpp magicseteditor_SOURCES += ./src/script/functions/basic.cpp +magicseteditor_SOURCES += ./src/script/functions/construction.cpp magicseteditor_SOURCES += ./src/script/functions/regex.cpp magicseteditor_SOURCES += ./src/script/functions/editor.cpp magicseteditor_SOURCES += ./src/script/functions/image.cpp @@ -76,6 +77,7 @@ magicseteditor_SOURCES += ./src/script/script.cpp magicseteditor_SOURCES += ./src/script/parser.cpp magicseteditor_SOURCES += ./src/script/image.cpp magicseteditor_SOURCES += ./src/data/statistics.cpp +magicseteditor_SOURCES += ./src/data/add_cards_script.cpp magicseteditor_SOURCES += ./src/data/locale.cpp magicseteditor_SOURCES += ./src/data/card.cpp magicseteditor_SOURCES += ./src/data/symbol.cpp diff --git a/Makefile.in b/Makefile.in index c0a7fa05..4a53395c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -98,6 +98,7 @@ am_magicseteditor_OBJECTS = ./src/util/version.$(OBJEXT) \ ./src/script/script_manager.$(OBJEXT) \ ./src/script/functions/english.$(OBJEXT) \ ./src/script/functions/basic.$(OBJEXT) \ + ./src/script/functions/construction.$(OBJEXT) \ ./src/script/functions/regex.$(OBJEXT) \ ./src/script/functions/editor.$(OBJEXT) \ ./src/script/functions/image.$(OBJEXT) \ @@ -106,6 +107,7 @@ am_magicseteditor_OBJECTS = ./src/util/version.$(OBJEXT) \ ./src/script/dependency.$(OBJEXT) ./src/script/value.$(OBJEXT) \ ./src/script/script.$(OBJEXT) ./src/script/parser.$(OBJEXT) \ ./src/script/image.$(OBJEXT) ./src/data/statistics.$(OBJEXT) \ + ./src/data/add_cards_script.$(OBJEXT) \ ./src/data/locale.$(OBJEXT) ./src/data/card.$(OBJEXT) \ ./src/data/symbol.$(OBJEXT) ./src/data/game.$(OBJEXT) \ ./src/data/font.$(OBJEXT) ./src/data/symbol_font.$(OBJEXT) \ @@ -356,6 +358,7 @@ magicseteditor_SOURCES = ./src/util/version.cpp \ ./src/script/scriptable.cpp ./src/script/script_manager.cpp \ ./src/script/functions/english.cpp \ ./src/script/functions/basic.cpp \ + ./src/script/functions/construction.cpp \ ./src/script/functions/regex.cpp \ ./src/script/functions/editor.cpp \ ./src/script/functions/image.cpp \ @@ -363,11 +366,12 @@ magicseteditor_SOURCES = ./src/util/version.cpp \ ./src/script/dependency.cpp ./src/script/value.cpp \ ./src/script/script.cpp ./src/script/parser.cpp \ ./src/script/image.cpp ./src/data/statistics.cpp \ - ./src/data/locale.cpp ./src/data/card.cpp \ - ./src/data/symbol.cpp ./src/data/game.cpp ./src/data/font.cpp \ - ./src/data/symbol_font.cpp ./src/data/stylesheet.cpp \ - ./src/data/format/html.cpp ./src/data/format/mse1.cpp \ - ./src/data/format/mse2.cpp ./src/data/format/apprentice.cpp \ + ./src/data/add_cards_script.cpp ./src/data/locale.cpp \ + ./src/data/card.cpp ./src/data/symbol.cpp ./src/data/game.cpp \ + ./src/data/font.cpp ./src/data/symbol_font.cpp \ + ./src/data/stylesheet.cpp ./src/data/format/html.cpp \ + ./src/data/format/mse1.cpp ./src/data/format/mse2.cpp \ + ./src/data/format/apprentice.cpp \ ./src/data/format/clipboard.cpp \ ./src/data/format/image_to_symbol.cpp \ ./src/data/format/mws.cpp ./src/data/format/image.cpp \ @@ -664,6 +668,9 @@ src/script/functions/$(DEPDIR)/$(am__dirstamp): ./src/script/functions/basic.$(OBJEXT): \ src/script/functions/$(am__dirstamp) \ src/script/functions/$(DEPDIR)/$(am__dirstamp) +./src/script/functions/construction.$(OBJEXT): \ + src/script/functions/$(am__dirstamp) \ + src/script/functions/$(DEPDIR)/$(am__dirstamp) ./src/script/functions/regex.$(OBJEXT): \ src/script/functions/$(am__dirstamp) \ src/script/functions/$(DEPDIR)/$(am__dirstamp) @@ -696,6 +703,8 @@ src/data/$(DEPDIR)/$(am__dirstamp): @: > src/data/$(DEPDIR)/$(am__dirstamp) ./src/data/statistics.$(OBJEXT): src/data/$(am__dirstamp) \ src/data/$(DEPDIR)/$(am__dirstamp) +./src/data/add_cards_script.$(OBJEXT): src/data/$(am__dirstamp) \ + src/data/$(DEPDIR)/$(am__dirstamp) ./src/data/locale.$(OBJEXT): src/data/$(am__dirstamp) \ src/data/$(DEPDIR)/$(am__dirstamp) ./src/data/card.$(OBJEXT): src/data/$(am__dirstamp) \ @@ -996,6 +1005,7 @@ mostlyclean-compile: -rm -f ./src/data/action/symbol.$(OBJEXT) -rm -f ./src/data/action/symbol_part.$(OBJEXT) -rm -f ./src/data/action/value.$(OBJEXT) + -rm -f ./src/data/add_cards_script.$(OBJEXT) -rm -f ./src/data/card.$(OBJEXT) -rm -f ./src/data/export_template.$(OBJEXT) -rm -f ./src/data/field.$(OBJEXT) @@ -1121,6 +1131,7 @@ mostlyclean-compile: -rm -f ./src/script/context.$(OBJEXT) -rm -f ./src/script/dependency.$(OBJEXT) -rm -f ./src/script/functions/basic.$(OBJEXT) + -rm -f ./src/script/functions/construction.$(OBJEXT) -rm -f ./src/script/functions/editor.$(OBJEXT) -rm -f ./src/script/functions/english.$(OBJEXT) -rm -f ./src/script/functions/export.$(OBJEXT) @@ -1156,6 +1167,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./src/cli/$(DEPDIR)/cli_main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./src/cli/$(DEPDIR)/text_io_handler.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./src/cli/$(DEPDIR)/win32_cli_wrapper.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./src/data/$(DEPDIR)/add_cards_script.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./src/data/$(DEPDIR)/card.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./src/data/$(DEPDIR)/export_template.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./src/data/$(DEPDIR)/field.Po@am__quote@ @@ -1291,6 +1303,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./src/script/$(DEPDIR)/scriptable.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./src/script/$(DEPDIR)/value.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./src/script/functions/$(DEPDIR)/basic.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./src/script/functions/$(DEPDIR)/construction.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./src/script/functions/$(DEPDIR)/editor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./src/script/functions/$(DEPDIR)/english.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./src/script/functions/$(DEPDIR)/export.Po@am__quote@ diff --git a/Resources.sh b/Resources.sh index 677f9db8..2278808a 100755 --- a/Resources.sh +++ b/Resources.sh @@ -1,8 +1,10 @@ #! /bin/bash -rm -r /usr/local/share/magicseteditor/resource +BASEDIR=~/.magicseteditor/resource -for DIR in /usr/local/share/magicseteditor /usr/local/share/magicseteditor/resource /usr/local/share/magicseteditor/resource/icon /usr/local/share/magicseteditor/resource/tool /usr/local/share/magicseteditor/resource/cursor +rm -r $BASEDIR/resource + +for DIR in $BASEDIR $BASEDIR/icon $BASEDIR/tool $BASEDIR/cursor do if [ -d $DIR ]; then : ; @@ -14,8 +16,8 @@ mkdir $DIR; fi done -cp src/resource/common/* /usr/local/share/magicseteditor/resource; -cp src/resource/msw/tool/* /usr/local/share/magicseteditor/resource/tool; -cp src/resource/msw/icon/* /usr/local/share/magicseteditor/resource/icon; -cp src/resource/msw/cursor/* /usr/local/share/magicseteditor/resource/cursor; -cp src/resource/msw/other/* /usr/local/share/magicseteditor/resource; \ No newline at end of file +cp src/resource/common/* $BASEDIR; +cp src/resource/msw/tool/* $BASEDIR/tool; +cp src/resource/msw/icon/* $BASEDIR/icon; +cp src/resource/msw/cursor/* $BASEDIR/cursor; +cp src/resource/msw/other/* $BASEDIR; diff --git a/configure b/configure index b20d1168..9a176567 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for magicseteditor 0.3.4. +# Generated by GNU Autoconf 2.61 for magicseteditor 0.3.7b. # # Report bugs to . # @@ -574,8 +574,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='magicseteditor' PACKAGE_TARNAME='magicseteditor' -PACKAGE_VERSION='0.3.4' -PACKAGE_STRING='magicseteditor 0.3.4' +PACKAGE_VERSION='0.3.7b' +PACKAGE_STRING='magicseteditor 0.3.7b' PACKAGE_BUGREPORT='twanvl@users.sourceforge.net' ac_unique_file="src/main.cpp" @@ -1226,7 +1226,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures magicseteditor 0.3.4 to adapt to many kinds of systems. +\`configure' configures magicseteditor 0.3.7b to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1292,7 +1292,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of magicseteditor 0.3.4:";; + short | recursive ) echo "Configuration of magicseteditor 0.3.7b:";; esac cat <<\_ACEOF @@ -1387,7 +1387,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -magicseteditor configure 0.3.4 +magicseteditor configure 0.3.7b generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1401,7 +1401,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by magicseteditor $as_me 0.3.4, which was +It was created by magicseteditor $as_me 0.3.7b, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -2096,7 +2096,7 @@ fi # Define the identity of the package. PACKAGE='magicseteditor' - VERSION='0.3.4' + VERSION='0.3.7b' cat >>confdefs.h <<_ACEOF @@ -5604,6 +5604,102 @@ fi done +{ echo "$as_me:$LINENO: checking whether the compiler provides atomic builtins" >&5 +echo $ECHO_N "checking whether the compiler provides atomic builtins... $ECHO_C" >&6; } +if test "${ap_cv_atomic_builtins+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ap_cv_atomic_builtins=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int main() +{ + unsigned long val = 1010, tmp, *mem = &val; + + if (__sync_fetch_and_add(&val, 1010) != 1010 || val != 2020) + return 1; + + tmp = val; + + if (__sync_fetch_and_sub(mem, 1010) != tmp || val != 1010) + return 1; + + if (__sync_sub_and_fetch(&val, 1010) != 0 || val != 0) + return 1; + + tmp = 3030; + + if (__sync_val_compare_and_swap(mem, 0, tmp) != 0 || val != tmp) + return 1; + + if (__sync_lock_test_and_set(&val, 4040) != 3030) + return 1; + + mem = &tmp; + + if (__sync_val_compare_and_swap(&mem, &tmp, &val) != &tmp) + return 1; + + __sync_synchronize(); + + if (mem != &val) + return 1; + + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ap_cv_atomic_builtins=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ap_cv_atomic_builtins=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ap_cv_atomic_builtins" >&5 +echo "${ECHO_T}$ap_cv_atomic_builtins" >&6; } + +if test "$ap_cv_atomic_builtins" = "yes"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_GCC_ATOMIC_BUILTINS 1 +_ACEOF + +fi + ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF @@ -6023,7 +6119,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by magicseteditor $as_me 0.3.4, which was +This file was extended by magicseteditor $as_me 0.3.7b, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6076,7 +6172,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -magicseteditor config.status 0.3.4 +magicseteditor config.status 0.3.7b configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/src/data/locale.cpp b/src/data/locale.cpp index fe7aac96..156b15d6 100644 --- a/src/data/locale.cpp +++ b/src/data/locale.cpp @@ -210,8 +210,10 @@ InputStreamP load_resource_text(const String& name) { int len = ::SizeofResource(wxGetInstance(), hResource); return new_shared2(data, len); #else - static String path = wxStandardPaths::Get().GetDataDir() + _("/resource/") + name; - return new_shared1(path); + static String path = wxStandardPaths::Get().GetDataDir() + _("/resource/"); + static String local_path = wxStandardPaths::Get().GetUserDataDir() + _("/resource/"); + if (wxFileExists(path + name)) return new_shared1(path + name); + else return new_shared1(local_path + name); #endif } diff --git a/src/gui/util.cpp b/src/gui/util.cpp index 8f484eff..6b17d51e 100644 --- a/src/gui/util.cpp +++ b/src/gui/util.cpp @@ -98,7 +98,14 @@ Image load_resource_image(const String& name) { else if (wxFileExists(file + _(".bmp"))) resource.LoadFile(file + _(".bmp")); else if (wxFileExists(file + _(".ico"))) resource.LoadFile(file + _(".ico")); else if (wxFileExists(file + _(".cur"))) resource.LoadFile(file + _(".cur")); - if (!resource.Ok()) handle_error(InternalError(String(_("Cannot find resource file at ")) + file)); + if (resource.Ok()) return resource; + static String local_path = wxStandardPaths::Get().GetUserDataDir() + _("/resource/"); + file = local_path + name; + if (wxFileExists(file + _(".png"))) resource.LoadFile(file + _(".png")); + else if (wxFileExists(file + _(".bmp"))) resource.LoadFile(file + _(".bmp")); + else if (wxFileExists(file + _(".ico"))) resource.LoadFile(file + _(".ico")); + else if (wxFileExists(file + _(".cur"))) resource.LoadFile(file + _(".cur")); + if (!resource.Ok()) handle_error(InternalError(String(_("Cannot find resource file at ")) + path + name + _(" or ") + file)); return resource; #else #error Handling of resource loading needs to be declared. @@ -118,7 +125,9 @@ wxIcon load_resource_icon(const String& name) { return wxIcon(_("icon/") + name); #else static String path = wxStandardPaths::Get().GetDataDir() + _("/resource/icon/"); - return wxIcon(path + name + _(".ico"), wxBITMAP_TYPE_ICO); + static String local_path = wxStandardPaths::Get().GetUserDataDir() + _("/resource/icon/"); + if (wxFileExists(path + name + _(".ico"))) return wxIcon(path + name + _(".ico"), wxBITMAP_TYPE_ICO); + else return wxIcon(local_path + name + _(".ico"), wxBITMAP_TYPE_ICO); #endif } diff --git a/src/script/value.cpp b/src/script/value.cpp index 06ed87b5..9aa76d79 100644 --- a/src/script/value.cpp +++ b/src/script/value.cpp @@ -353,7 +353,7 @@ String ScriptCollectionBase::toCode() const { #ifdef USE_INTRUSIVE_PTR // we can just turn this into a ScriptValueP // TODO: remove thisP alltogether - ScriptValueP it = makeIterator(ScriptValueP(const_cast((ScriptValue*)this))); + ScriptValueP it = makeIterator(ScriptValueP(const_cast(static_cast(this)))); #else #error "makeIterator needs a ScriptValueP :(" #endif diff --git a/src/util/atomic.hpp b/src/util/atomic.hpp index 4838555c..f50335cd 100644 --- a/src/util/atomic.hpp +++ b/src/util/atomic.hpp @@ -54,7 +54,7 @@ #define HAVE_FAST_ATOMIC // ----------------------------------------------------------------------------- : AtomicInt : GCC -#elif defined(__GNUC__) && defined(HAVE_GCC_ATOMIC_BUILTINS) +#elif defined(__GNUC__) && !defined(HAVE_GCC_ATOMIC_BUILTINS) /// An integer which is equivalent to an AtomicInt, but which doesn't support attomic operations typedef unsigned int AtomicIntEquiv; diff --git a/tools/linux-installer/install b/tools/linux-installer/install index f0227cf1..0741eaec 100755 --- a/tools/linux-installer/install +++ b/tools/linux-installer/install @@ -6,17 +6,15 @@ # This script installs Magic Set Editor onto your system. # If executed as root (including via sudo), it is installed to /usr/local/share/magicseteditor. (with an executable symlink in /usr/local/bin) -# If executed as any other user, it will fail. +# If executed as any other user, it will install to ~/.magicseteditor with a symlink in ~/bin. case $UID in 0) INSTALL_DIR='/usr/local/share/magicseteditor/'; EXEC_SYMLINK='/usr/local/bin/magicseteditor';; *) - echo -"Unfortunately, our installer system currently does not support installation -except as root. This is because the program currently requires a specific data -directory. Our apologies." && exit;; + INSTALL_DIR=~'/.magicseteditor/'; + EXEC_SYMLINK=~'/bin/magicseteditor'; esac if [ \"$MSE_INSTALL_DIR\" != "" ] then