mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
added time_created and time_modified to Card. This changes the file format
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1321 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+9
-2
@@ -21,7 +21,10 @@ DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA ValueP>);
|
||||
// ----------------------------------------------------------------------------- : Card
|
||||
|
||||
Card::Card()
|
||||
: has_styling(false)
|
||||
// for files made before we saved these times, set the time to 'yesterday'
|
||||
: time_created (wxDateTime::Now().Subtract(wxDateSpan::Day()).ResetTime())
|
||||
, time_modified(wxDateTime::Now().Subtract(wxDateSpan::Day()).ResetTime())
|
||||
, has_styling(false)
|
||||
{
|
||||
if (!game_for_reading()) {
|
||||
throw InternalError(_("game_for_reading not set"));
|
||||
@@ -30,7 +33,9 @@ Card::Card()
|
||||
}
|
||||
|
||||
Card::Card(const Game& game)
|
||||
: has_styling(false)
|
||||
: time_created (wxDateTime::Now())
|
||||
, time_modified(wxDateTime::Now())
|
||||
, has_styling(false)
|
||||
{
|
||||
data.init(game.card_fields);
|
||||
}
|
||||
@@ -73,6 +78,8 @@ IMPLEMENT_REFLECTION(Card) {
|
||||
}
|
||||
}
|
||||
REFLECT(notes);
|
||||
REFLECT_NO_SCRIPT(time_created);
|
||||
REFLECT_NO_SCRIPT(time_modified);
|
||||
REFLECT(extra_data); // don't allow scripts to depend on style specific data
|
||||
REFLECT_NAMELESS(data);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ class Card : public IntrusivePtrVirtualBase {
|
||||
IndexMap<FieldP, ValueP> data;
|
||||
/// Notes for this card
|
||||
String notes;
|
||||
/// Time the card was created/last modified
|
||||
wxDateTime time_created, time_modified;
|
||||
/// Alternative style to use for this card
|
||||
/** Optional; if not set use the card style from the set */
|
||||
StyleSheetP stylesheet;
|
||||
|
||||
@@ -371,8 +371,15 @@ template <> void Reader::handle(tribool& b) {
|
||||
const String& v = getValue();
|
||||
b = (v==_("true") || v==_("1") || v==_("yes"));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Handling less basic util types
|
||||
|
||||
template <> void Reader::handle(wxDateTime& date) {
|
||||
if (!date.ParseDateTime(getValue().c_str())) {
|
||||
throw ParseError(_("Expected a date and time"));
|
||||
}
|
||||
}
|
||||
|
||||
template <> void Reader::handle(Vector2D& vec) {
|
||||
if (!wxSscanf(getValue().c_str(), _("(%lf,%lf)"), &vec.x, &vec.y)) {
|
||||
throw ParseError(_("Expected (x,y)"));
|
||||
|
||||
@@ -113,6 +113,11 @@ template <> void Writer::handle(const tribool& value) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Handling less basic util types
|
||||
|
||||
template <> void Writer::handle(const wxDateTime& date) {
|
||||
if (date.IsValid()) {
|
||||
handle(date.Format(_("%Y-%m-%d %H:%M:%S")));
|
||||
}
|
||||
}
|
||||
template <> void Writer::handle(const Vector2D& vec) {
|
||||
handle(String::Format(_("(%.10lf,%.10lf)"), vec.x, vec.y));
|
||||
}
|
||||
|
||||
@@ -78,14 +78,15 @@ const Char* version_suffix = _(" (beta, ascii build)");
|
||||
* - tag_contents function fixed
|
||||
* - alignment:justify behavior changed
|
||||
* - more scriptable fields.
|
||||
* - store time created,modified for cards -> changes set and clipboard format
|
||||
*/
|
||||
const Version file_version_locale = 308; // 0.3.8
|
||||
const Version file_version_set = 306; // 0.3.6
|
||||
const Version file_version_set = 308; // 0.3.8
|
||||
const Version file_version_game = 308; // 0.3.8
|
||||
const Version file_version_stylesheet = 308; // 0.3.8
|
||||
const Version file_version_symbol_font = 306; // 0.3.6
|
||||
const Version file_version_export_template = 307; // 0.3.7
|
||||
const Version file_version_installer = 307; // 0.3.7
|
||||
const Version file_version_symbol = 305; // 0.3.5
|
||||
const Version file_version_clipboard = 306; // 0.3.6
|
||||
const Version file_version_clipboard = 308; // 0.3.8
|
||||
const Version file_version_script = 307; // 0.3.7
|
||||
|
||||
Reference in New Issue
Block a user