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
This commit is contained in:
coppro
2008-08-21 04:06:50 +00:00
parent d13b721b41
commit ec63e3b18b
9 changed files with 155 additions and 33 deletions
+4 -2
View File
@@ -210,8 +210,10 @@ InputStreamP load_resource_text(const String& name) {
int len = ::SizeofResource(wxGetInstance(), hResource);
return new_shared2<wxMemoryInputStream>(data, len);
#else
static String path = wxStandardPaths::Get().GetDataDir() + _("/resource/") + name;
return new_shared1<wxFileInputStream>(path);
static String path = wxStandardPaths::Get().GetDataDir() + _("/resource/");
static String local_path = wxStandardPaths::Get().GetUserDataDir() + _("/resource/");
if (wxFileExists(path + name)) return new_shared1<wxFileInputStream>(path + name);
else return new_shared1<wxFileInputStream>(local_path + name);
#endif
}
+11 -2
View File
@@ -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
}
+1 -1
View File
@@ -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*>((ScriptValue*)this)));
ScriptValueP it = makeIterator(ScriptValueP(const_cast<ScriptValue*>(static_cast<const ScriptValue*>(this))));
#else
#error "makeIterator needs a ScriptValueP :("
#endif
+1 -1
View File
@@ -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;