mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
add store_in_metadata image style property
This commit is contained in:
+25
-3
@@ -13,6 +13,7 @@
|
||||
#include <util/error.hpp>
|
||||
#include <util/file_utils.hpp>
|
||||
#include <util/vcs.hpp>
|
||||
#include <data/format/file_to_text.h>
|
||||
|
||||
class Package;
|
||||
class wxFileInputStream;
|
||||
@@ -55,11 +56,11 @@ public:
|
||||
|
||||
/// Retreive a rect from a filename
|
||||
inline static void getExternalRect(const String& filename, wxRect& rect_out, int& degrees_out) {
|
||||
size_t first = filename.find(_("---"));
|
||||
size_t first = filename.find(_("<mse-crop-data>"));
|
||||
if (first == String::npos) return;
|
||||
size_t last = filename.find(_("---"), first+3);
|
||||
size_t last = filename.find(_("</mse-crop-data>"), first + 15);
|
||||
if (last == String::npos) return;
|
||||
String string = filename.substr(first + 3, last - (first + 3));
|
||||
String string = filename.substr(first + 15, last - (first + 15));
|
||||
if (string.empty()) return;
|
||||
|
||||
size_t divider = string.find(_("-"));
|
||||
@@ -96,7 +97,28 @@ public:
|
||||
}
|
||||
inline void getExternalRect(wxRect& rect_out, int& degrees_out) {
|
||||
getExternalRect(fn, rect_out, degrees_out);
|
||||
}
|
||||
|
||||
/// Retreive an image from a filename
|
||||
inline static Image getExternalImage(const String& filename) {
|
||||
Image img;
|
||||
size_t first = filename.find(_("<mse-image-data>"));
|
||||
if (first == String::npos) return img;
|
||||
size_t last = filename.find(_("</mse-image-data>"), first + 16);
|
||||
if (last == String::npos) return img;
|
||||
std::string s = filename.substr(first + 16, last - (first + 16)).ToStdString();
|
||||
if (s.empty()) return img;
|
||||
|
||||
const std::string& temppath = (wxFileName::CreateTempFileName(_("mse")) + _(".png")).ToStdString();
|
||||
UTF8ToFile(temppath, s);
|
||||
img.LoadFile(temppath, wxBITMAP_TYPE_PNG);
|
||||
wxRemoveFile(temppath);
|
||||
wxRemoveFile(temppath.substr(0, temppath.size() - 4));
|
||||
return img;
|
||||
}
|
||||
inline Image getExternalImage() {
|
||||
return getExternalImage(fn);
|
||||
}
|
||||
|
||||
private:
|
||||
LocalFileName(const wxString& fn) : fn(fn) {}
|
||||
|
||||
+1
-1
@@ -25,5 +25,5 @@ static String generate_uid() {
|
||||
for (i = 0; i < 32; i++) {
|
||||
ss << dis(gen);
|
||||
};
|
||||
return String(ss.str().c_str(), wxConvUTF8);
|
||||
return String(ss.str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user