mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Lots of miscellaneous fixes, also added basic VCS framework
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1416 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -168,6 +168,7 @@ ChoiceStyle::ChoiceStyle(const ChoiceFieldP& field)
|
||||
, combine(COMBINE_NORMAL)
|
||||
, alignment(ALIGN_STRETCH)
|
||||
, thumbnails(nullptr)
|
||||
, content_width(0.0), content_height(0.0)
|
||||
{}
|
||||
|
||||
ChoiceStyle::~ChoiceStyle() {
|
||||
|
||||
@@ -276,6 +276,9 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
collapse_notes->SetHelpText(collapse ? _HELP_("collapse notes") : _HELP_("expand notes"));
|
||||
break;
|
||||
}
|
||||
#if 0 //ifdef __WXGTK__ //crashes on GTK
|
||||
case ID_INSERT_SYMBOL: ev.Enable(false); break;
|
||||
#else
|
||||
case ID_INSERT_SYMBOL: {
|
||||
wxMenu* menu = editor->getMenu(ID_INSERT_SYMBOL);
|
||||
ev.Enable(menu);
|
||||
@@ -285,17 +288,21 @@ void CardsPanel::onUpdateUI(wxUpdateUIEvent& ev) {
|
||||
insertSymbolMenu->SetSubMenu(menu);
|
||||
menuFormat->Append(insertSymbolMenu);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void CardsPanel::onCommand(int id) {
|
||||
switch (id) {
|
||||
case ID_CARD_PREV:
|
||||
card_list->selectPrevious();
|
||||
// Note: Forwarded events may cause this to occur even at the top.
|
||||
if (card_list->canSelectPrevious()) card_list->selectPrevious();
|
||||
break;
|
||||
case ID_CARD_NEXT:
|
||||
card_list->selectNext();
|
||||
// Note: Forwarded events may cause this to occur even at the bottom.
|
||||
if (card_list->canSelectNext()) card_list->selectNext();
|
||||
break;
|
||||
case ID_CARD_ADD:
|
||||
set->actions.addAction(new AddCardAction(*set));
|
||||
|
||||
@@ -26,7 +26,8 @@ struct TextViewer::Line {
|
||||
bool justifying; ///< Is the text justified? Only true when *really* justifying.
|
||||
|
||||
Line()
|
||||
: start(0), end_or_soft(0), top(0), line_height(0), break_after(BREAK_NO)
|
||||
: start(0), end_or_soft(0), top(0), line_height(0)
|
||||
, break_after(BREAK_NO), justifying(false)
|
||||
{}
|
||||
|
||||
/// The position (just beyond) the bottom of this line
|
||||
|
||||
+13
-4
@@ -244,6 +244,7 @@ String Package::nameOut(const String& file) {
|
||||
if (it == files.end()) {
|
||||
// new file
|
||||
it = addFile(name);
|
||||
it->second.created = true;
|
||||
}
|
||||
|
||||
// return stream
|
||||
@@ -271,7 +272,8 @@ FileName Package::newFileName(const String& prefix, const String& suffix) {
|
||||
FileInfos::iterator it = files.find(name);
|
||||
if (it == files.end()) {
|
||||
// name doesn't exist yet
|
||||
addFile(name);
|
||||
it = addFile(name);
|
||||
it->second.created = true;
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -320,7 +322,7 @@ InputStreamP Package::openAbsoluteFile(const String& name) {
|
||||
// ----------------------------------------------------------------------------- : Package : private
|
||||
|
||||
Package::FileInfo::FileInfo()
|
||||
: keep(false), zipEntry(nullptr)
|
||||
: keep(false), created(false), zipEntry(nullptr)
|
||||
{}
|
||||
|
||||
Package::FileInfo::~FileInfo() {
|
||||
@@ -379,11 +381,12 @@ void Package::openZipfile() {
|
||||
|
||||
void Package::saveToDirectory(const String& saveAs, bool remove_unused, bool is_copy) {
|
||||
// write to a directory
|
||||
VCSP vcs = getVCS();
|
||||
FOR_EACH(f, files) {
|
||||
if (!f.second.keep && remove_unused) {
|
||||
// remove files that are not to be kept
|
||||
// ignore failure (new file that is not kept)
|
||||
wxRemoveFile(saveAs+_("/")+f.first);
|
||||
vcs->removeFile(saveAs+_("/")+f.first);
|
||||
} else if (f.second.wasWritten()) {
|
||||
// move files that were updated
|
||||
wxRemoveFile(saveAs+_("/")+f.first);
|
||||
@@ -391,11 +394,16 @@ void Package::saveToDirectory(const String& saveAs, bool remove_unused, bool is_
|
||||
: wxRenameFile(f.second.tempName, saveAs+_("/")+f.first))) {
|
||||
throw PackageError(_ERROR_("unable to store file"));
|
||||
}
|
||||
if (f.second.created) {
|
||||
vcs->addFile(saveAs+_("/")+f.first);
|
||||
f.second.created = false;
|
||||
}
|
||||
} else if (filename != saveAs) {
|
||||
// save as, copy old filess
|
||||
if (!wxCopyFile(filename+_("/")+f.first, saveAs+_("/")+f.first)) {
|
||||
throw PackageError(_ERROR_("unable to store file"));
|
||||
}
|
||||
vcs->addFile(saveAs+_("/")+f.first);
|
||||
} else {
|
||||
// old file, just keep it
|
||||
}
|
||||
@@ -462,7 +470,7 @@ DateTime Package::modificationTime(const pair<String, FileInfo>& fi) const {
|
||||
} else if (wxFileExists(filename+_("/")+fi.first)) {
|
||||
return wxFileName(filename+_("/")+fi.first).GetModificationTime();
|
||||
} else {
|
||||
return DateTime();
|
||||
return DateTime((wxLongLong)0ul);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,6 +513,7 @@ IMPLEMENT_REFLECTION(Packaged) {
|
||||
Packaged::Packaged()
|
||||
: position_hint(100000)
|
||||
, fully_loaded(true)
|
||||
, vcs(nullptr)
|
||||
{}
|
||||
|
||||
InputStreamP Packaged::openIconFile() {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <util/dynamic_arg.hpp>
|
||||
#include <util/error.hpp>
|
||||
#include <util/file_utils.hpp>
|
||||
#include <util/io/vcs.hpp>
|
||||
|
||||
class Package;
|
||||
class wxFileInputStream;
|
||||
@@ -141,6 +142,10 @@ class Package : public IntrusivePtrVirtualBase {
|
||||
writer.handle(obj);
|
||||
}
|
||||
|
||||
protected:
|
||||
// TODO: I dislike this very much. There ought to be a better way.
|
||||
virtual VCSP getVCS() { return new_intrusive<VCS>(); }
|
||||
|
||||
// --------------------------------------------------- : Private stuff
|
||||
private:
|
||||
|
||||
@@ -149,6 +154,7 @@ class Package : public IntrusivePtrVirtualBase {
|
||||
FileInfo();
|
||||
~FileInfo();
|
||||
bool keep; ///< Should this file be kept in the package? (as opposed to deleting it)
|
||||
bool created; ///< Was this file just created (e.g. should the VCS add it?)
|
||||
String tempName; ///< Name of the temporary file where new contents of this file are placed
|
||||
wxZipEntry* zipEntry; ///< Entry in the zip file for this file
|
||||
/// Is this file changed, and therefore written to a temporary file?
|
||||
@@ -213,6 +219,7 @@ class Packaged : public Package {
|
||||
String icon_filename; ///< Filename of icon to use in package lists
|
||||
vector<PackageDependencyP> dependencies; ///< Dependencies of this package
|
||||
int position_hint; ///< A hint for the package list
|
||||
VCSP vcs; ///< The version control system to use
|
||||
|
||||
/// Get an input stream for the package icon, if there is any
|
||||
InputStreamP openIconFile();
|
||||
@@ -236,6 +243,10 @@ class Packaged : public Package {
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual VCSP getVCS() {
|
||||
return vcs;
|
||||
}
|
||||
|
||||
/// filename of the data file, and extension of the package file
|
||||
virtual String typeName() const = 0;
|
||||
/// Can be overloaded to do validation after loading
|
||||
|
||||
Reference in New Issue
Block a user