mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
rewrite print logic once again
- move Front Face // Back Face card link to exe level - print front faces and back faces together - use printer dpi instead of stylesheet dpi
This commit is contained in:
+41
-40
@@ -100,7 +100,7 @@ Bitmap export_bitmap(const SetP& set, const vector<CardP>& cards, bool scale_to_
|
||||
if (scale_to_lowest_dpi) {
|
||||
double dpi = max(set->stylesheetFor(card).card_dpi, 150.0);
|
||||
scale *= lowest_dpi / dpi;
|
||||
}
|
||||
}
|
||||
scales_out.push_back(scale);
|
||||
UnzoomedDataViewer viewer = UnzoomedDataViewer(scale, angle_radians);
|
||||
viewer.setSet(set);
|
||||
@@ -124,7 +124,7 @@ Bitmap export_bitmap(const SetP& set, const vector<CardP>& cards, bool scale_to_
|
||||
globalDC.SelectObject(global_bitmap);
|
||||
clearDC(globalDC, *wxWHITE_BRUSH);
|
||||
int offset = 0;
|
||||
FOR_EACH(bitmap, bitmaps) {
|
||||
FOR_EACH(bitmap, bitmaps) {
|
||||
offsets_out.push_back(offset);
|
||||
globalDC.SetDeviceOrigin(offset, 0);
|
||||
globalDC.DrawBitmap(bitmap, 0, 0);
|
||||
@@ -138,57 +138,58 @@ Bitmap export_bitmap(const SetP& set, const vector<CardP>& cards, bool scale_to_
|
||||
|
||||
Image export_image(const SetP& set, const CardP& card, const double zoom, const Radians angle_radians) {
|
||||
Bitmap bitmap = export_bitmap(set, card, zoom, angle_radians);
|
||||
Image img = bitmap.ConvertToImage();
|
||||
String data = _("<mse-data-start>[");
|
||||
IndexMap<FieldP, ValueP>& card_data = card->data;
|
||||
boost::json::object& cardv = mse_to_json(card, set.get());
|
||||
boost::json::object& cardv_data = cardv["data"].as_object();
|
||||
if (!settings.stylesheetSettingsFor(set->stylesheetFor(card)).card_notes_export()) cardv["notes"] = "";
|
||||
for(IndexMap<FieldP, ValueP>::iterator it = card_data.begin() ; it != card_data.end() ; ++it) {
|
||||
Image img = bitmap.ConvertToImage();
|
||||
String data = _("<mse-data-start>[");
|
||||
IndexMap<FieldP, ValueP>& card_data = card->data;
|
||||
boost::json::object& cardv = mse_to_json(card, set.get());
|
||||
boost::json::object& cardv_data = cardv["data"].as_object();
|
||||
StyleSheetP stylesheet = set->stylesheetForP(card);
|
||||
if (!settings.stylesheetSettingsFor(*stylesheet).card_notes_export()) cardv["notes"] = "";
|
||||
for(IndexMap<FieldP, ValueP>::iterator it = card_data.begin() ; it != card_data.end() ; ++it) {
|
||||
ImageValue* value = dynamic_cast<ImageValue*>(it->get());
|
||||
if (value && !value->filename.empty()) {
|
||||
FieldP field = (*it)->fieldP;
|
||||
StyleP style = set->stylesheetFor(card).card_style.at(field->index);
|
||||
if (style) {
|
||||
if (value && !value->filename.empty()) {
|
||||
FieldP field = (*it)->fieldP;
|
||||
StyleP style = stylesheet->card_style.at(field->index);
|
||||
if (style) {
|
||||
style->update(set->getContext(card));
|
||||
std::string rect = style->getExternalRectString(zoom, 0).ToStdString();
|
||||
cardv_data[field->name.ToStdString()] = rect;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string rect = style->getExternalRectString(zoom, 0).ToStdString();
|
||||
cardv_data[field->name.ToStdString()] = rect;
|
||||
}
|
||||
}
|
||||
}
|
||||
data += json_ugly_print(cardv) + _("]<mse-data-end>");
|
||||
img.SetOption(wxIMAGE_OPTION_PNG_DESCRIPTION, data);
|
||||
return img;
|
||||
}
|
||||
|
||||
Image export_image(const SetP& set, const vector<CardP>& cards, bool scale_to_lowest_dpi, int padding, const double zoom, const Radians angle_radians) {
|
||||
vector<double> scales;
|
||||
vector<int> offsets;
|
||||
vector<double> scales;
|
||||
vector<int> offsets;
|
||||
Bitmap bitmap = export_bitmap(set, cards, scale_to_lowest_dpi, padding, zoom, angle_radians, scales, offsets);
|
||||
Image img = bitmap.ConvertToImage();
|
||||
Image img = bitmap.ConvertToImage();
|
||||
String data = _("<mse-data-start>[");
|
||||
for (int i = 0; i < cards.size(); ++i) {
|
||||
if (i > 0) data += _(",");
|
||||
for (int i = 0; i < cards.size(); ++i) {
|
||||
if (i > 0) data += _(",");
|
||||
CardP card = cards[i];
|
||||
IndexMap<FieldP, ValueP>& card_data = card->data;
|
||||
boost::json::object& cardv = mse_to_json(card, set.get());
|
||||
boost::json::object& cardv_data = cardv["data"].as_object();
|
||||
if (!settings.stylesheetSettingsFor(set->stylesheetFor(card)).card_notes_export()) cardv["notes"] = "";
|
||||
for(IndexMap<FieldP, ValueP>::iterator it = card_data.begin() ; it != card_data.end() ; ++it) {
|
||||
IndexMap<FieldP, ValueP>& card_data = card->data;
|
||||
boost::json::object& cardv = mse_to_json(card, set.get());
|
||||
boost::json::object& cardv_data = cardv["data"].as_object();
|
||||
StyleSheetP stylesheet = set->stylesheetForP(card);
|
||||
if (!settings.stylesheetSettingsFor(*stylesheet).card_notes_export()) cardv["notes"] = "";
|
||||
for(IndexMap<FieldP, ValueP>::iterator it = card_data.begin() ; it != card_data.end() ; ++it) {
|
||||
ImageValue* value = dynamic_cast<ImageValue*>(it->get());
|
||||
if (value && !value->filename.empty()) {
|
||||
FieldP field = (*it)->fieldP;
|
||||
StyleSheetP stylesheet = set->stylesheetForP(card);
|
||||
if (value && !value->filename.empty()) {
|
||||
FieldP field = (*it)->fieldP;
|
||||
StyleP style = stylesheet->card_style.at(field->index);
|
||||
if (style) {
|
||||
if (style) {
|
||||
style->update(set->getContext(card));
|
||||
std::string rect = style->getExternalRectString(scales[i], offsets[i]).ToStdString();
|
||||
cardv_data[field->name.ToStdString()] = rect;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string rect = style->getExternalRectString(scales[i], offsets[i]).ToStdString();
|
||||
cardv_data[field->name.ToStdString()] = rect;
|
||||
}
|
||||
}
|
||||
}
|
||||
data += json_ugly_print(cardv);
|
||||
}
|
||||
}
|
||||
data += _("]<mse-data-end>");
|
||||
img.SetOption(wxIMAGE_OPTION_PNG_DESCRIPTION, data);
|
||||
return img;
|
||||
@@ -197,11 +198,11 @@ Image export_image(const SetP& set, const vector<CardP>& cards, bool scale_to_lo
|
||||
void export_image(const SetP& set, const CardP& card, const String& filename) {
|
||||
Image img = export_image(set, card);
|
||||
img.SaveFile(filename); // can't use Bitmap::saveFile, it wants to know the file type
|
||||
// but image.saveFile determines it automagicly
|
||||
// but image.saveFile determines it automagicly
|
||||
}
|
||||
|
||||
void export_image(const SetP& set, const vector<CardP>& cards,
|
||||
const String& path, const String& filename_template, FilenameConflicts conflicts)
|
||||
const String& path, const String& filename_template, FilenameConflicts conflicts)
|
||||
{
|
||||
wxBusyCursor busy;
|
||||
// Script
|
||||
|
||||
Reference in New Issue
Block a user