mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 13:06:59 -04:00
Added image export, tested mtgeditor import
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@119 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <data/format/clipboard.hpp>
|
||||
#include <data/format/formats.hpp>
|
||||
#include <data/card.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/game.hpp>
|
||||
@@ -77,7 +78,7 @@ CardOnClipboard::CardOnClipboard(const SetP& set, const CardP& card) {
|
||||
// TODO
|
||||
//Add( new TextDataObject(_("card")))
|
||||
// Conversion to bitmap format
|
||||
// Add(new BitmapDataObject(exportImageBmp(set, card)));
|
||||
Add(new wxBitmapDataObject(export_bitmap(set, card)));
|
||||
// Conversion to serialized card format
|
||||
Add(new CardDataObject(set, card), true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
//+----------------------------------------------------------------------------+
|
||||
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
|
||||
//| Copyright: (C) 2001 - 2006 Twan van Laarhoven |
|
||||
//| License: GNU General Public License 2 or later (see file COPYING) |
|
||||
//+----------------------------------------------------------------------------+
|
||||
|
||||
// ----------------------------------------------------------------------------- : Includes
|
||||
|
||||
#include <data/format/formats.hpp>
|
||||
#include <data/set.hpp>
|
||||
#include <data/settings.hpp>
|
||||
#include <render/card/viewer.hpp>
|
||||
|
||||
// ----------------------------------------------------------------------------- : Single card export
|
||||
|
||||
void export_image(const SetP& set, const CardP& card, const String& filename) {
|
||||
Image img = export_bitmap(set, card).ConvertToImage();
|
||||
img.SaveFile(filename); // can't use Bitmap::saveFile, it wants to know the file type
|
||||
// but image.saveFile determines it automagicly
|
||||
}
|
||||
|
||||
Bitmap export_bitmap(const SetP& set, const CardP& card) {
|
||||
// create viewer
|
||||
DataViewer viewer;
|
||||
viewer.setSet(set);
|
||||
viewer.setCard(card);
|
||||
// style to use
|
||||
StyleSheetP style = set->stylesheetFor(card);
|
||||
// size of cards
|
||||
if (settings.stylesheetSettingsFor(*style).card_normal_export()) {
|
||||
// TODO
|
||||
// viewer.rotation.angle = 0;
|
||||
// viewer.rotation.zoom = 1.0;
|
||||
}
|
||||
RealSize size = viewer.getRotation().getExternalRect().size();
|
||||
// create bitmap & dc
|
||||
Bitmap bitmap(size.width, size.height);
|
||||
if (!bitmap.Ok()) throw InternalError(_("Unable to create bitmap"));
|
||||
wxMemoryDC dc;
|
||||
dc.SelectObject(bitmap);
|
||||
// draw
|
||||
viewer.draw(dc);
|
||||
dc.SelectObject(wxNullBitmap);
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------- : Multiple card export
|
||||
@@ -192,7 +192,12 @@ SetP MtgEditorFileFormat::importSet(const String& filename) {
|
||||
|
||||
// Load stylesheet
|
||||
if (layout != _("8e")) {
|
||||
set->stylesheet = StyleSheet::byGameAndName(*set->game, _("old"));
|
||||
try {
|
||||
set->stylesheet = StyleSheet::byGameAndName(*set->game, _("old"));
|
||||
} catch (const Error&) {
|
||||
// If old style doesn't work try the new one
|
||||
set->stylesheet = StyleSheet::byGameAndName(*set->game, _("new"));
|
||||
}
|
||||
} else {
|
||||
set->stylesheet = StyleSheet::byGameAndName(*set->game, _("new"));
|
||||
}
|
||||
|
||||
@@ -1503,6 +1503,45 @@
|
||||
<File
|
||||
RelativePath=".\data\format\html.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\data\format\image.cpp">
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug Unicode|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release Unicode|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release Profile Unicode|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release Unicode fast build|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)/$(InputName)4.obj"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\data\format\mse1.cpp">
|
||||
</File>
|
||||
|
||||
Reference in New Issue
Block a user