Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
magicseteditor
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
magicseteditor
Commits
18110496
Commit
18110496
authored
Dec 20, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added --export command line flag
parent
161efd59
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
19 deletions
+67
-19
src/gui/images_export_window.cpp
src/gui/images_export_window.cpp
+26
-17
src/gui/images_export_window.hpp
src/gui/images_export_window.hpp
+15
-1
src/main.cpp
src/main.cpp
+26
-1
No files found.
src/gui/images_export_window.cpp
View file @
18110496
...
@@ -56,26 +56,13 @@ ImagesExportWindow::ImagesExportWindow(Window* parent, const SetP& set)
...
@@ -56,26 +56,13 @@ ImagesExportWindow::ImagesExportWindow(Window* parent, const SetP& set)
// ----------------------------------------------------------------------------- : Exporting the images
// ----------------------------------------------------------------------------- : Exporting the images
void
ImagesExportWindow
::
onOk
(
wxCommandEvent
&
)
{
void
ExportCardImages
::
export
(
const
SetP
&
set
,
wxFileName
&
fn
,
const
String
&
filename_template
,
FilenameConflicts
conflicts
)
{
// Update settings
GameSettings
&
gs
=
settings
.
gameSettingsFor
(
*
set
->
game
);
gs
.
images_export_filename
=
format
->
GetValue
();
int
sel
=
conflicts
->
GetSelection
();
if
(
sel
==
0
)
gs
.
images_export_conflicts
=
CONFLICT_KEEP_OLD
;
else
if
(
sel
==
1
)
gs
.
images_export_conflicts
=
CONFLICT_OVERWRITE
;
else
if
(
sel
==
2
)
gs
.
images_export_conflicts
=
CONFLICT_NUMBER
;
else
gs
.
images_export_conflicts
=
CONFLICT_NUMBER_OVERWRITE
;
// Script
// Script
ScriptP
filename_script
=
parse
(
gs
.
images_export_filename
,
nullptr
,
true
);
ScriptP
filename_script
=
parse
(
filename_template
,
nullptr
,
true
);
// Select filename
String
name
=
wxFileSelector
(
_TITLE_
(
"export images"
),
_
(
""
),
_LABEL_
(
"filename is ignored"
),
_
(
""
),
_LABEL_
(
"filename is ignored"
)
+
_
(
"|*"
),
wxSAVE
,
this
);
if
(
name
.
empty
())
return
;
wxFileName
fn
(
name
);
// Export
// Export
std
::
set
<
String
>
used
;
// for CONFLICT_NUMBER_OVERWRITE
std
::
set
<
String
>
used
;
// for CONFLICT_NUMBER_OVERWRITE
FOR_EACH
(
card
,
set
->
cards
)
{
FOR_EACH
(
card
,
set
->
cards
)
{
if
(
isSelecte
d
(
card
))
{
if
(
exportCar
d
(
card
))
{
// filename for this card
// filename for this card
Context
&
ctx
=
set
->
getContext
(
card
);
Context
&
ctx
=
set
->
getContext
(
card
);
String
filename
=
untag
(
ctx
.
eval
(
*
filename_script
)
->
toString
());
String
filename
=
untag
(
ctx
.
eval
(
*
filename_script
)
->
toString
());
...
@@ -85,7 +72,7 @@ void ImagesExportWindow::onOk(wxCommandEvent&) {
...
@@ -85,7 +72,7 @@ void ImagesExportWindow::onOk(wxCommandEvent&) {
// does the file exist?
// does the file exist?
if
(
fn
.
FileExists
())
{
if
(
fn
.
FileExists
())
{
// file exists, what to do?
// file exists, what to do?
switch
(
gs
.
images_export_
conflicts
)
{
switch
(
conflicts
)
{
case
CONFLICT_KEEP_OLD
:
goto
next_card
;
case
CONFLICT_KEEP_OLD
:
goto
next_card
;
case
CONFLICT_OVERWRITE
:
break
;
case
CONFLICT_OVERWRITE
:
break
;
case
CONFLICT_NUMBER
:
{
case
CONFLICT_NUMBER
:
{
...
@@ -111,10 +98,32 @@ void ImagesExportWindow::onOk(wxCommandEvent&) {
...
@@ -111,10 +98,32 @@ void ImagesExportWindow::onOk(wxCommandEvent&) {
}
}
next_card:
;
next_card:
;
}
}
}
void
ImagesExportWindow
::
onOk
(
wxCommandEvent
&
)
{
// Update settings
GameSettings
&
gs
=
settings
.
gameSettingsFor
(
*
set
->
game
);
gs
.
images_export_filename
=
format
->
GetValue
();
int
sel
=
conflicts
->
GetSelection
();
if
(
sel
==
0
)
gs
.
images_export_conflicts
=
CONFLICT_KEEP_OLD
;
else
if
(
sel
==
1
)
gs
.
images_export_conflicts
=
CONFLICT_OVERWRITE
;
else
if
(
sel
==
2
)
gs
.
images_export_conflicts
=
CONFLICT_NUMBER
;
else
gs
.
images_export_conflicts
=
CONFLICT_NUMBER_OVERWRITE
;
// Select filename
String
name
=
wxFileSelector
(
_TITLE_
(
"export images"
),
_
(
""
),
_LABEL_
(
"filename is ignored"
),
_
(
""
),
_LABEL_
(
"filename is ignored"
)
+
_
(
"|*"
),
wxSAVE
,
this
);
if
(
name
.
empty
())
return
;
wxFileName
fn
(
name
);
// Export
export
(
set
,
fn
,
gs
.
images_export_filename
,
gs
.
images_export_conflicts
);
// Done
// Done
EndModal
(
wxID_OK
);
EndModal
(
wxID_OK
);
}
}
bool
ImagesExportWindow
::
exportCard
(
const
CardP
&
card
)
const
{
return
isSelected
(
card
);
}
BEGIN_EVENT_TABLE
(
ImagesExportWindow
,
CardSelectWindow
)
BEGIN_EVENT_TABLE
(
ImagesExportWindow
,
CardSelectWindow
)
EVT_BUTTON
(
wxID_OK
,
ImagesExportWindow
::
onOk
)
EVT_BUTTON
(
wxID_OK
,
ImagesExportWindow
::
onOk
)
...
...
src/gui/images_export_window.hpp
View file @
18110496
...
@@ -11,11 +11,23 @@
...
@@ -11,11 +11,23 @@
#include <util/prec.hpp>
#include <util/prec.hpp>
#include <gui/card_select_window.hpp>
#include <gui/card_select_window.hpp>
#include <data/settings.hpp>
class
wxFileName
;
// ----------------------------------------------------------------------------- : ImagesExportWindow
/// Export the cards in a set
class
ExportCardImages
{
public:
void
export
(
const
SetP
&
set
,
wxFileName
&
filename
,
const
String
&
filename_template
,
FilenameConflicts
conflicts
);
protected:
virtual
bool
exportCard
(
const
CardP
&
card
)
const
{
return
true
;
}
};
// ----------------------------------------------------------------------------- : ImagesExportWindow
// ----------------------------------------------------------------------------- : ImagesExportWindow
/// A window for selecting a subset of the cards from a set to export to images
/// A window for selecting a subset of the cards from a set to export to images
class
ImagesExportWindow
:
public
CardSelectWindow
{
class
ImagesExportWindow
:
public
CardSelectWindow
,
private
ExportCardImages
{
public:
public:
ImagesExportWindow
(
Window
*
parent
,
const
SetP
&
set
);
ImagesExportWindow
(
Window
*
parent
,
const
SetP
&
set
);
...
@@ -24,6 +36,8 @@ class ImagesExportWindow : public CardSelectWindow {
...
@@ -24,6 +36,8 @@ class ImagesExportWindow : public CardSelectWindow {
void
onOk
(
wxCommandEvent
&
);
void
onOk
(
wxCommandEvent
&
);
virtual
bool
exportCard
(
const
CardP
&
card
)
const
;
wxTextCtrl
*
format
;
wxTextCtrl
*
format
;
wxChoice
*
conflicts
;
wxChoice
*
conflicts
;
};
};
...
...
src/main.cpp
View file @
18110496
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include <data/format/formats.hpp>
#include <data/format/formats.hpp>
#include <gui/welcome_window.hpp>
#include <gui/welcome_window.hpp>
#include <gui/update_checker.hpp>
#include <gui/update_checker.hpp>
#include <gui/images_export_window.hpp>
#include <gui/set/window.hpp>
#include <gui/set/window.hpp>
#include <gui/symbol/window.hpp>
#include <gui/symbol/window.hpp>
#include <gui/thumbnail_thread.hpp>
#include <gui/thumbnail_thread.hpp>
...
@@ -139,12 +140,36 @@ int MSE::OnRun() {
...
@@ -139,12 +140,36 @@ int MSE::OnRun() {
+
_
(
" -v --version
\t
Show version information.
\n
"
)
+
_
(
" -v --version
\t
Show version information.
\n
"
)
+
_
(
" --symbol-editor
\t
Show the symbol editor instead of the welcome window.
\n
"
)
+
_
(
" --symbol-editor
\t
Show the symbol editor instead of the welcome window.
\n
"
)
+
_
(
" --create-installer
\n
"
)
+
_
(
" --create-installer
\n
"
)
+
_
(
" FILE [FILE]...
\t
Create an instaler named FILE, containing the listed packges.
\n
"
)
);
+
_
(
" FILE [FILE]...
\t
Create an instaler named FILE, containing the listed packges.
\n
"
)
+
_
(
" --export
\n
"
)
+
_
(
" FILE IMAGE
\t
Export the cards in a set to image files,
\n
"
)
+
_
(
"
\t
IMAGE is the same format as for 'export all card images'.
\n
"
)
);
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
else
if
(
arg
==
_
(
"--version"
)
||
arg
==
_
(
"-v"
))
{
}
else
if
(
arg
==
_
(
"--version"
)
||
arg
==
_
(
"-v"
))
{
// dump version
// dump version
write_stdout
(
_
(
"Magic Set Editor
\n
Version "
)
+
app_version
.
toString
()
+
version_suffix
);
write_stdout
(
_
(
"Magic Set Editor
\n
Version "
)
+
app_version
.
toString
()
+
version_suffix
);
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
else
if
(
arg
==
_
(
"--export"
))
{
if
(
argc
<=
2
)
{
handle_error
(
Error
(
_
(
"No input file specified for --export"
)));
return
EXIT_FAILURE
;
}
SetP
set
=
import_set
(
argv
[
2
]);
// path
String
out
=
argc
>=
3
?
argv
[
3
]
:
settings
.
gameSettingsFor
(
*
set
->
game
).
images_export_filename
;
String
path
=
_
(
"."
);
size_t
pos
=
out
.
find_last_of
(
_
(
"/
\\
"
));
if
(
pos
!=
String
::
npos
)
{
path
=
out
.
substr
(
0
,
pos
);
if
(
!
wxDirExists
(
path
))
wxMkdir
(
path
);
path
+=
_
(
"/x"
);
out
=
out
.
substr
(
pos
+
1
);
}
wxFileName
fn
(
path
);
// export
ExportCardImages
export
;
export
.
export
(
set
,
fn
,
out
,
CONFLICT_NUMBER_OVERWRITE
);
return
EXIT_SUCCESS
;
}
else
{
}
else
{
handle_error
(
_
(
"Invalid command line argument:
\n
"
)
+
String
(
argv
[
1
]));
handle_error
(
_
(
"Invalid command line argument:
\n
"
)
+
String
(
argv
[
1
]));
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment