mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
fixed duplicate set writing bug + enforced unicode strings
This commit is contained in:
@@ -522,6 +522,10 @@ bool ImageValueToImage::operator == (const GeneratedImage& that) const {
|
|||||||
Image ExternalImage::generate(const Options& opt) const {
|
Image ExternalImage::generate(const Options& opt) const {
|
||||||
wxFileName fname(filepath, wxPATH_UNIX);
|
wxFileName fname(filepath, wxPATH_UNIX);
|
||||||
|
|
||||||
|
// has a pre-existing .mse-set file been loaded?
|
||||||
|
if (opt.local_package->needSaveAs())
|
||||||
|
throw ScriptError(_("Cannot import an image without first saving/loading a set file."));
|
||||||
|
|
||||||
// does the file pointed to by filepath exist?
|
// does the file pointed to by filepath exist?
|
||||||
if (!fname.FileExists()) {
|
if (!fname.FileExists()) {
|
||||||
String filePathString = fname.GetAbsolutePath().ToStdString();
|
String filePathString = fname.GetAbsolutePath().ToStdString();
|
||||||
@@ -542,19 +546,19 @@ Image ExternalImage::generate(const Options& opt) const {
|
|||||||
if (!opt.local_package->existsIn(fileNameNoExtension)) {
|
if (!opt.local_package->existsIn(fileNameNoExtension)) {
|
||||||
auto outStream = opt.local_package->openOut(fileNameNoExtension);
|
auto outStream = opt.local_package->openOut(fileNameNoExtension);
|
||||||
wxFileInputStream inStream = wxFileInputStream(filepath.ToStdString());
|
wxFileInputStream inStream = wxFileInputStream(filepath.ToStdString());
|
||||||
if (!inStream.IsOk()) throw ScriptError("Failed to create file stream.");
|
if (!inStream.IsOk()) throw ScriptError(_("Failed to create file stream."));
|
||||||
outStream->Write(inStream);
|
outStream->Write(inStream);
|
||||||
if (!outStream->IsOk()) throw ScriptError("Failed to write image to set.");
|
if (!outStream->IsOk()) throw ScriptError(_("Failed to write image to set."));
|
||||||
outStream->Close();
|
outStream->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// save the package with the new image
|
// save the package with the new image
|
||||||
opt.local_package->saveAs(opt.local_package->relativeFilename(), false, false);
|
opt.local_package->save(false);
|
||||||
|
|
||||||
auto imageInputStream = opt.local_package->openIn(fileNameNoExtension);
|
auto imageInputStream = opt.local_package->openIn(fileNameNoExtension);
|
||||||
Image img(*imageInputStream.get(), bitmapType);
|
Image img(*imageInputStream.get(), bitmapType);
|
||||||
|
|
||||||
if (!img.IsOk()) throw ScriptError("The image could not be created.");
|
if (!img.IsOk()) throw ScriptError(_("The image could not be created."));
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ public:
|
|||||||
Image generate(const Options&) const override;
|
Image generate(const Options&) const override;
|
||||||
bool operator == (const GeneratedImage& that) const override;
|
bool operator == (const GeneratedImage& that) const override;
|
||||||
inline String toString() { return filepath; }
|
inline String toString() { return filepath; }
|
||||||
inline String ExternalImage::toCode() const override { return "<image>"; }
|
inline String toCode() const override { return _("<image>"); }
|
||||||
private:
|
private:
|
||||||
String filepath;
|
String filepath;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user