Skip to content

Commit

Permalink
Add game and stylesheet version numbers to set files. Closes #39
Browse files Browse the repository at this point in the history
  • Loading branch information
twanvl committed May 19, 2020
1 parent 0913912 commit 641acff
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/data/card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ void mark_dependency_member(const Card& card, const String& name, const Dependen
mark_dependency_member(card.data, name, dep);
}

void reflect_version_check(Reader& handler, const Char* key, intrusive_ptr<Packaged> const& package);
void reflect_version_check(Writer& handler, const Char* key, intrusive_ptr<Packaged> const& package);
void reflect_version_check(GetMember& handler, const Char* key, intrusive_ptr<Packaged> const& package);
void reflect_version_check(GetDefaultMember& handler, const Char* key, intrusive_ptr<Packaged> const& package);

IMPLEMENT_REFLECTION(Card) {
REFLECT(stylesheet);
reflect_version_check(handler, _("stylesheet_version"), stylesheet);
REFLECT(has_styling);
if (has_styling) {
if (stylesheet) {
Expand Down
16 changes: 16 additions & 0 deletions src/data/set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,31 @@ void Set::validate(Version file_app_version) {
script_manager->updateAll();
}

void reflect_version_check(Reader& handler, const Char* key, intrusive_ptr<Packaged> const& package) {
if (!package) return;
Version v = package->version;
handler.handle(key, v);
if (package->version < v) {
queue_message(MESSAGE_WARNING, "This set file is made with a newer version of the '" + package->name() + "' template. Please update the template files.");
}
}
void reflect_version_check(Writer& handler, const Char* key, intrusive_ptr<Packaged> const& package) {
handler.handle(key, package->version);
}
void reflect_version_check(GetMember& handler, const Char* key, intrusive_ptr<Packaged> const& package) {}
void reflect_version_check(GetDefaultMember& handler, const Char* key, intrusive_ptr<Packaged> const& package) {}

IMPLEMENT_REFLECTION(Set) {
REFLECT(game);
if (game) {
REFLECT_IF_READING {
data.init(game->set_fields);
}
reflect_version_check(handler, _("game_version"), game);
WITH_DYNAMIC_ARG(game_for_reading, game.get());
REFLECT(stylesheet);
REFLECT_COMPAT(<300, "style", stylesheet);
reflect_version_check(handler, _("stylesheet_version"), stylesheet);
WITH_DYNAMIC_ARG(stylesheet_for_reading, stylesheet.get());
REFLECT_N("set_info", data);
if (stylesheet) {
Expand Down
8 changes: 5 additions & 3 deletions src/util/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ const Char* version_suffix = _(" (ascii build)");
* 0.3.0 : port of code to C++
* 0.3.1 : new keyword system, some new style options
* 0.3.2 : package dependencies
* 0.3.3 : keyword separator before/after
* 0.3.3 : keywor
d separator before/after
* 0.3.4 : html export; choice rendering based on scripted 'image'
* 0.3.5 : word lists, symbol font 'as text'
* 0.3.6 : free rotation, rotation behaviour changed.
Expand All @@ -82,14 +83,15 @@ const Char* version_suffix = _(" (ascii build)");
* - store time created,modified for cards -> changes set and clipboard format
* 0.3.9 : bugfix release mostly, a few new script functions
* 2.0.0 : bugfix release mostly, added error console
* 2.0.2 : store game and stylesheet version numbers
*/
const Version file_version_locale = 20002; // 2.0.2
const Version file_version_set = 308; // 0.3.8
const Version file_version_set = 20002; // 2.0.2
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 = 308; // 0.3.8
const Version file_version_clipboard = 20002; // 2.0.2
const Version file_version_script = 307; // 0.3.7

0 comments on commit 641acff

Please sign in to comment.