mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 21:06:59 -04:00
Made it so that update window and set window can't be open simultaneously (don't explode the set by deleting the style, say).
Made update window enforce dependencies Added update button to welcome window (need icon still) git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@756 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+21
-9
@@ -65,7 +65,6 @@ const String& Package::absoluteFilename() const {
|
||||
return filename;
|
||||
}
|
||||
|
||||
|
||||
void Package::open(const String& n) {
|
||||
assert(!isOpened()); // not already opened
|
||||
// get absolute path
|
||||
@@ -86,6 +85,17 @@ void Package::open(const String& n) {
|
||||
}
|
||||
}
|
||||
|
||||
void Package::openZipStream(wxZipInputStream* input) {
|
||||
// close old streams
|
||||
delete fileStream; fileStream = nullptr;
|
||||
delete zipStream;
|
||||
|
||||
zipStream = input;
|
||||
if (!zipStream->IsOk()) throw InternalError(_("Error opening package!"));
|
||||
|
||||
loadZipStream();
|
||||
}
|
||||
|
||||
void Package::save(bool remove_unused) {
|
||||
assert(!needSaveAs());
|
||||
saveAs(filename, remove_unused);
|
||||
@@ -304,6 +314,15 @@ Package::FileInfo::~FileInfo() {
|
||||
delete zipEntry;
|
||||
}
|
||||
|
||||
void Package::loadZipStream() {
|
||||
while (true) {
|
||||
wxZipEntry* entry = zipStream->GetNextEntry();
|
||||
if (!entry) break;
|
||||
String name = toStandardName(entry->GetName());
|
||||
files[name].zipEntry = entry;
|
||||
}
|
||||
zipStream->CloseEntry();
|
||||
}
|
||||
|
||||
void Package::openDirectory() {
|
||||
openSubdir(wxEmptyString);
|
||||
@@ -341,16 +360,9 @@ void Package::openZipfile() {
|
||||
zipStream = new wxZipInputStream(*fileStream);
|
||||
if (!zipStream->IsOk()) throw PackageError(_ERROR_1_("package not found", filename));
|
||||
// read zip entries
|
||||
while (true) {
|
||||
wxZipEntry* entry = zipStream->GetNextEntry();
|
||||
if (!entry) break;
|
||||
String name = toStandardName(entry->GetName());
|
||||
files[name].zipEntry = entry;
|
||||
}
|
||||
zipStream->CloseEntry();
|
||||
loadZipStream();
|
||||
}
|
||||
|
||||
|
||||
void Package::saveToDirectory(const String& saveAs, bool remove_unused) {
|
||||
// write to a directory
|
||||
FOR_EACH(f, files) {
|
||||
|
||||
@@ -71,6 +71,9 @@ class Package : public IntrusivePtrVirtualBase {
|
||||
/// @pre open not called before [TODO]
|
||||
void open(const String& package);
|
||||
|
||||
/// Open a package from a zipstream that doesn't necessarily have a filename (i.e. a URL).
|
||||
void openZipStream(wxZipInputStream* input);
|
||||
|
||||
/// Saves the package, by default saves as a zip file, unless
|
||||
/// it was already a directory
|
||||
/** If remove_unused=true all files that were in the file and
|
||||
@@ -168,6 +171,7 @@ class Package : public IntrusivePtrVirtualBase {
|
||||
/// Filestream for reading zip files
|
||||
wxZipInputStream* zipStream;
|
||||
|
||||
void loadZipStream();
|
||||
void openDirectory();
|
||||
void openSubdir(const String&);
|
||||
void openZipfile();
|
||||
|
||||
@@ -128,13 +128,15 @@ bool PackageManager::checkDependency(const PackageDependency& dep, bool report_e
|
||||
// try global package
|
||||
name = global_data_directory + _("/") + dep.package;
|
||||
if (!wxFileExists(name) && !wxDirExists(name)) {
|
||||
handle_warning(_ERROR_1_("package not found", dep.package),false);
|
||||
if (report_errors)
|
||||
handle_warning(_ERROR_1_("package not found", dep.package),false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
PackagedP package = openAny(dep.package, true);
|
||||
if (package->version < dep.version) {
|
||||
handle_warning(_ERROR_3_("package out of date", dep.package, package->version.toString(), dep.version.toString()),false);
|
||||
if (report_errors)
|
||||
handle_warning(_ERROR_3_("package out of date", dep.package, package->version.toString(), dep.version.toString()),false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user