mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Moved clean_filename to file_utils.cpp where it belongs;
Split up images exporting, and moved it to data/formats/image git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1085 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <util/error.hpp>
|
||||
#include <data/settings.hpp>
|
||||
|
||||
class Game;
|
||||
DECLARE_POINTER_TYPE(Set);
|
||||
@@ -85,6 +86,10 @@ FileFormatP mtg_editor_file_format();
|
||||
/// Export images for each card in a set to a list of files
|
||||
void export_images(Window* parent, const SetP& set);
|
||||
|
||||
/// Export the image for each card in a list of cards
|
||||
void export_images(const SetP& set, vector<CardP>& cards,
|
||||
const String& path, const String& filename_template, FilenameConflicts conflicts);
|
||||
|
||||
/// Export the image of a single card
|
||||
void export_image(const SetP& set, const CardP& card, const String& filename);
|
||||
|
||||
|
||||
@@ -7,11 +7,16 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <util/prec.hpp>
|
||||
#include <util/tagged_string.hpp>
|
||||
#include <data/format/formats.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/card.hpp>
|
||||
#include <data/stylesheet.hpp>
|
||||
#include <data/settings.hpp>
|
||||
#include <render/card/viewer.hpp>
|
||||
#include <wx/filename.h>
|
||||
|
||||
DECLARE_TYPEOF_COLLECTION(CardP);
|
||||
|
||||
// ----------------------------------------------------------------------------- : Single card export
|
||||
|
||||
@@ -59,3 +64,30 @@ Bitmap export_bitmap(const SetP& set, const CardP& card) {
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Multiple card export
|
||||
|
||||
|
||||
void export_images(const SetP& set, vector<CardP>& cards,
|
||||
const String& path, const String& filename_template, FilenameConflicts conflicts)
|
||||
{
|
||||
wxBusyCursor busy;
|
||||
// Script
|
||||
ScriptP filename_script = parse(filename_template, nullptr, true);
|
||||
// Path
|
||||
wxFileName fn(path);
|
||||
// Export
|
||||
std::set<String> used; // for CONFLICT_NUMBER_OVERWRITE
|
||||
FOR_EACH_CONST(card, cards) {
|
||||
// filename for this card
|
||||
Context& ctx = set->getContext(card);
|
||||
String filename = clean_filename(untag(ctx.eval(*filename_script)->toString()));
|
||||
if (!filename) continue; // no filename -> no saving
|
||||
// full path
|
||||
fn.SetFullName(filename);
|
||||
// does the file exist?
|
||||
if (!resolve_filename_conflicts(fn, conflicts, used)) continue;
|
||||
// write image
|
||||
filename = fn.GetFullPath();
|
||||
used.insert(filename);
|
||||
export_image(set, card, filename);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user