mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
convert to CRLF line endings
This commit is contained in:
@@ -106,8 +106,8 @@ public:
|
||||
/// Actions to be undone.
|
||||
vector<unique_ptr<Action>> undo_actions;
|
||||
/// Actions to be redone
|
||||
vector<unique_ptr<Action>> redo_actions;
|
||||
|
||||
vector<unique_ptr<Action>> redo_actions;
|
||||
|
||||
private:
|
||||
/// Point at which the file was saved, corresponds to the top of the undo stack at that point
|
||||
const Action* save_point;
|
||||
|
||||
+16
-16
@@ -20,7 +20,7 @@
|
||||
// ----------------------------------------------------------------------------- : Package : outside
|
||||
|
||||
IMPLEMENT_DYNAMIC_ARG(Package*, writing_package, nullptr);
|
||||
IMPLEMENT_DYNAMIC_ARG(Package*, clipboard_package, nullptr);
|
||||
IMPLEMENT_DYNAMIC_ARG(Package*, clipboard_package, nullptr);
|
||||
|
||||
Package::Package()
|
||||
: zipStream (nullptr)
|
||||
@@ -98,8 +98,8 @@ void Package::save(bool remove_unused) {
|
||||
saveAs(filename, remove_unused);
|
||||
}
|
||||
|
||||
void Package::saveAs(const String& name, bool remove_unused, bool as_directory) {
|
||||
if (Set* s = dynamic_cast<Set*>(this)) s->referenceActionStackFiles();
|
||||
void Package::saveAs(const String& name, bool remove_unused, bool as_directory) {
|
||||
if (Set* s = dynamic_cast<Set*>(this)) s->referenceActionStackFiles();
|
||||
// type of package
|
||||
if (wxDirExists(name) || as_directory) {
|
||||
saveToDirectory(name, remove_unused, false);
|
||||
@@ -111,7 +111,7 @@ void Package::saveAs(const String& name, bool remove_unused, bool as_directory)
|
||||
reopen();
|
||||
}
|
||||
|
||||
void Package::saveCopy(const String& name) {
|
||||
void Package::saveCopy(const String& name) {
|
||||
if (Set* s = dynamic_cast<Set*>(this)) s->referenceActionStackFiles();
|
||||
saveToZipfile(name, true, true);
|
||||
clearKeepFlag();
|
||||
@@ -227,15 +227,15 @@ unique_ptr<wxInputStream> Package::openIn(const String& file) {
|
||||
FileInfos::iterator it = files.find(normalize_internal_filename(file));
|
||||
if (it == files.end()) {
|
||||
// does it look like a relative filename?
|
||||
if (size_t pos = filename.find(_(".mse-")) != String::npos) {
|
||||
// check for nested folder
|
||||
pos = filename.find_last_of(_("/\\"));
|
||||
String nestedFilename = filename + filename.SubString(pos, filename.size()) + wxFileName::GetPathSeparator() + file;
|
||||
if (size_t pos = filename.find(_(".mse-")) != String::npos) {
|
||||
// check for nested folder
|
||||
pos = filename.find_last_of(_("/\\"));
|
||||
String nestedFilename = filename + filename.SubString(pos, filename.size()) + wxFileName::GetPathSeparator() + file;
|
||||
if (wxFileExists(nestedFilename)) {
|
||||
throw PackageError(_ERROR_1_("nested folder", filename));
|
||||
}
|
||||
else {
|
||||
throw PackageError(_ERROR_2_("file not found package like", file, filename));
|
||||
else {
|
||||
throw PackageError(_ERROR_2_("file not found package like", file, filename));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -593,14 +593,14 @@ Packaged::Packaged()
|
||||
, fully_loaded(true)
|
||||
{}
|
||||
|
||||
unique_ptr<wxInputStream> Packaged::openIconFile() {
|
||||
String filename = icon_filename;
|
||||
unique_ptr<wxInputStream> Packaged::openIconFile() {
|
||||
String filename = icon_filename;
|
||||
if (!dark_icon_filename.empty()) {
|
||||
if (settings.darkMode()) {
|
||||
wxFileName fn (dark_icon_filename);
|
||||
if (settings.darkMode()) {
|
||||
wxFileName fn (dark_icon_filename);
|
||||
String extension = fn.GetExt();
|
||||
filename = dark_icon_filename.Replace(extension, _("")) + "_dark" + extension;
|
||||
}
|
||||
filename = dark_icon_filename.Replace(extension, _("")) + "_dark" + extension;
|
||||
}
|
||||
else filename = dark_icon_filename;
|
||||
}
|
||||
if (!filename.empty()) {
|
||||
|
||||
+44
-44
@@ -13,7 +13,7 @@
|
||||
#include <util/error.hpp>
|
||||
#include <util/file_utils.hpp>
|
||||
#include <util/vcs.hpp>
|
||||
#include <data/format/file_to_text.h>
|
||||
#include <data/format/file_to_text.h>
|
||||
|
||||
class Package;
|
||||
class wxFileInputStream;
|
||||
@@ -55,70 +55,70 @@ public:
|
||||
inline String const& toStringForKey() const { return fn; }
|
||||
|
||||
/// Retreive a rect from a filename
|
||||
inline static void getExternalRect(const String& filename, wxRect& rect_out, int& degrees_out) {
|
||||
inline static void getExternalRect(const String& filename, wxRect& rect_out, int& degrees_out) {
|
||||
size_t first = filename.find(_("<mse-crop-data>"));
|
||||
if (first == String::npos) return;
|
||||
size_t last = filename.find(_("</mse-crop-data>"), first + 15);
|
||||
if (last == String::npos) return;
|
||||
String string = filename.substr(first + 15, last - (first + 15));
|
||||
if (string.empty()) return;
|
||||
|
||||
size_t last = filename.find(_("</mse-crop-data>"), first + 15);
|
||||
if (last == String::npos) return;
|
||||
String string = filename.substr(first + 15, last - (first + 15));
|
||||
if (string.empty()) return;
|
||||
|
||||
size_t divider = string.find(_("-"));
|
||||
if (divider == String::npos) return;
|
||||
if (divider == 0) return;
|
||||
int x;
|
||||
if(!string.substr(0, divider).ToInt(&x)) return;
|
||||
string = string.substr(divider + 1);
|
||||
|
||||
int x;
|
||||
if(!string.substr(0, divider).ToInt(&x)) return;
|
||||
string = string.substr(divider + 1);
|
||||
|
||||
divider = string.find(_("-"));
|
||||
if (divider == String::npos) return;
|
||||
if (divider == 0) return;
|
||||
int y;
|
||||
if(!string.substr(0, divider).ToInt(&y)) return;
|
||||
string = string.substr(divider + 1);
|
||||
|
||||
int y;
|
||||
if(!string.substr(0, divider).ToInt(&y)) return;
|
||||
string = string.substr(divider + 1);
|
||||
|
||||
divider = string.find(_("-"));
|
||||
if (divider == String::npos) return;
|
||||
if (divider == 0) return;
|
||||
int width;
|
||||
if(!string.substr(0, divider).ToInt(&width)) return;
|
||||
string = string.substr(divider + 1);
|
||||
|
||||
int width;
|
||||
if(!string.substr(0, divider).ToInt(&width)) return;
|
||||
string = string.substr(divider + 1);
|
||||
|
||||
divider = string.find(_("-"));
|
||||
if (divider == String::npos) return;
|
||||
if (divider == 0) return;
|
||||
int height;
|
||||
if(!string.substr(0, divider).ToInt(&height)) return;
|
||||
string = string.substr(divider + 1);
|
||||
|
||||
if(!string.ToInt(°rees_out)) return;
|
||||
|
||||
int height;
|
||||
if(!string.substr(0, divider).ToInt(&height)) return;
|
||||
string = string.substr(divider + 1);
|
||||
|
||||
if(!string.ToInt(°rees_out)) return;
|
||||
|
||||
rect_out = wxRect(x, y, width, height);
|
||||
}
|
||||
inline void getExternalRect(wxRect& rect_out, int& degrees_out) {
|
||||
getExternalRect(fn, rect_out, degrees_out);
|
||||
}
|
||||
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;
|
||||
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;
|
||||
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);
|
||||
}
|
||||
inline Image getExternalImage() {
|
||||
return getExternalImage(fn);
|
||||
}
|
||||
|
||||
private:
|
||||
LocalFileName(const wxString& fn) : fn(fn) {}
|
||||
|
||||
@@ -357,14 +357,14 @@ template <> void Reader::handle(Vector2D& vec) {
|
||||
template <> void Reader::handle(LocalFileName& f) {
|
||||
f = LocalFileName::fromReadString(this->getValue());
|
||||
}
|
||||
|
||||
String Reader::addLocale(String filename) {
|
||||
return filename + _("_") + settings.locale;
|
||||
}
|
||||
|
||||
String Reader::addDark(String filename) {
|
||||
return filename + (settings.darkMode() ? _("_dark") : _(""));
|
||||
}
|
||||
|
||||
String Reader::addLocale(String filename) {
|
||||
return filename + _("_") + settings.locale;
|
||||
}
|
||||
|
||||
String Reader::addDark(String filename) {
|
||||
return filename + (settings.darkMode() ? _("_dark") : _(""));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : EnumReader
|
||||
|
||||
|
||||
@@ -116,10 +116,10 @@ public:
|
||||
|
||||
/// The package being read from
|
||||
inline Packaged* getPackage() const { return package; }
|
||||
|
||||
String addLocale(String);
|
||||
String addDark(String);
|
||||
|
||||
|
||||
String addLocale(String);
|
||||
String addDark(String);
|
||||
|
||||
/// Set the value that will be returned by the next getValue() call (may mess up the state of the reader)
|
||||
inline void setValue(const String& value) { state = UNHANDLED; previous_value = value; };
|
||||
|
||||
@@ -181,7 +181,7 @@ private:
|
||||
/** Maybe the key is "include file" */
|
||||
template <typename T>
|
||||
void unknownKey(T& v) {
|
||||
if (key == _("include_file") || key == _("include_localized_file") || key == _("include_dark_file")) {
|
||||
if (key == _("include_file") || key == _("include_localized_file") || key == _("include_dark_file")) {
|
||||
value = key == _("include_localized_file") ? addLocale(value) : key == _("include_dark_file") ? addDark(value) : value;
|
||||
auto [stream, include_package] = openFileFromPackage(package, value);
|
||||
Reader sub_reader(*stream, include_package, value, ignore_invalid);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
using boost::tribool;
|
||||
|
||||
// ----------------------------------------------------------------------------- : Writer
|
||||
|
||||
|
||||
Writer::Writer(OutputStream& output)
|
||||
: indentation(0)
|
||||
, output(output)
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
// special behaviour
|
||||
void handle(const GameP&);
|
||||
void handle(const StyleSheetP&);
|
||||
|
||||
|
||||
/// Indentation of the current block
|
||||
int indentation;
|
||||
private:
|
||||
|
||||
@@ -115,7 +115,7 @@ enum ChildMenuID {
|
||||
ID_CARD_ADD_CSV_BROWSE,
|
||||
ID_CARD_ADD_JSON,
|
||||
ID_CARD_ADD_JSON_ARRAY,
|
||||
ID_CARD_ADD_JSON_BROWSE,
|
||||
ID_CARD_ADD_JSON_BROWSE,
|
||||
ID_CARD_BULK,
|
||||
ID_CARD_BULK_TYPE,
|
||||
ID_CARD_BULK_FIELD,
|
||||
|
||||
Reference in New Issue
Block a user