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
5f847c04
Commit
5f847c04
authored
Feb 16, 2011
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
put export template exporting into a separate function
TODO: move this function to another file
parent
af8486b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
src/gui/html_export_window.cpp
src/gui/html_export_window.cpp
+18
-10
No files found.
src/gui/html_export_window.cpp
View file @
5f847c04
...
@@ -52,12 +52,7 @@ HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set, const Export
...
@@ -52,12 +52,7 @@ HtmlExportWindow::HtmlExportWindow(Window* parent, const SetP& set, const Export
list
->
select
(
settings
.
gameSettingsFor
(
*
set
->
game
).
default_export
);
list
->
select
(
settings
.
gameSettingsFor
(
*
set
->
game
).
default_export
);
}
}
void
HtmlExportWindow
::
onOk
(
wxCommandEvent
&
)
{
ScriptValueP
export_set
(
SetP
const
&
set
,
vector
<
CardP
>
const
&
cards
,
ExportTemplateP
const
&
exp
,
String
const
&
outname
)
{
ExportTemplateP
exp
=
list
->
getSelection
<
ExportTemplate
>
();
// get filename
String
name
=
wxFileSelector
(
_TITLE_
(
"save html"
),
settings
.
default_export_dir
,
_
(
""
),
_
(
""
),
exp
->
file_type
,
wxFD_SAVE
|
wxFD_OVERWRITE_PROMPT
);
if
(
name
.
empty
())
return
;
settings
.
default_export_dir
=
wxPathOnly
(
name
);
wxBusyCursor
wait
;
wxBusyCursor
wait
;
// export info for script
// export info for script
ExportInfo
info
;
ExportInfo
info
;
...
@@ -66,7 +61,8 @@ void HtmlExportWindow::onOk(wxCommandEvent&) {
...
@@ -66,7 +61,8 @@ void HtmlExportWindow::onOk(wxCommandEvent&) {
WITH_DYNAMIC_ARG
(
export_info
,
&
info
);
WITH_DYNAMIC_ARG
(
export_info
,
&
info
);
// create directory?
// create directory?
if
(
exp
->
create_directory
)
{
if
(
exp
->
create_directory
)
{
wxFileName
fn
(
name
);
if
(
outname
.
empty
())
throw
Error
(
_
(
"No output filename specified for export"
));
wxFileName
fn
(
outname
);
info
.
directory_relative
=
fn
.
GetName
()
+
_
(
"-files"
);
info
.
directory_relative
=
fn
.
GetName
()
+
_
(
"-files"
);
fn
.
SetFullName
(
info
.
directory_relative
);
fn
.
SetFullName
(
info
.
directory_relative
);
info
.
directory_absolute
=
fn
.
GetFullPath
();
info
.
directory_absolute
=
fn
.
GetFullPath
();
...
@@ -77,17 +73,29 @@ void HtmlExportWindow::onOk(wxCommandEvent&) {
...
@@ -77,17 +73,29 @@ void HtmlExportWindow::onOk(wxCommandEvent&) {
// run export script
// run export script
Context
&
ctx
=
set
->
getContext
();
Context
&
ctx
=
set
->
getContext
();
LocalScope
scope
(
ctx
);
LocalScope
scope
(
ctx
);
ctx
.
setVariable
(
_
(
"cards"
),
to_script
(
&
getSelection
()
));
ctx
.
setVariable
(
_
(
"cards"
),
to_script
(
&
cards
));
ctx
.
setVariable
(
_
(
"options"
),
to_script
(
&
settings
.
exportOptionsFor
(
*
exp
)));
ctx
.
setVariable
(
_
(
"options"
),
to_script
(
&
settings
.
exportOptionsFor
(
*
exp
)));
ctx
.
setVariable
(
_
(
"directory"
),
to_script
(
info
.
directory_relative
));
ctx
.
setVariable
(
_
(
"directory"
),
to_script
(
info
.
directory_relative
));
ScriptValueP
result
=
exp
->
script
.
invoke
(
ctx
);
ScriptValueP
result
=
exp
->
script
.
invoke
(
ctx
);
// Save to file
// Save to file
wxFileOutputStream
file
(
name
);
if
(
!
outname
.
empty
())
{
{
// TODO: write as image?
// TODO: write as image?
// write as string
// write as string
wxFileOutputStream
file
(
outname
);
wxTextOutputStream
stream
(
file
);
wxTextOutputStream
stream
(
file
);
stream
.
WriteString
(
*
result
);
stream
.
WriteString
(
*
result
);
}
}
return
result
;
}
void
HtmlExportWindow
::
onOk
(
wxCommandEvent
&
)
{
ExportTemplateP
exp
=
list
->
getSelection
<
ExportTemplate
>
();
// get filename
String
name
=
wxFileSelector
(
_TITLE_
(
"save html"
),
settings
.
default_export_dir
,
_
(
""
),
_
(
""
),
exp
->
file_type
,
wxFD_SAVE
|
wxFD_OVERWRITE_PROMPT
);
if
(
name
.
empty
())
return
;
settings
.
default_export_dir
=
wxPathOnly
(
name
);
// export
export_set
(
set
,
getSelection
(),
exp
,
name
);
// Done
// Done
EndModal
(
wxID_OK
);
EndModal
(
wxID_OK
);
}
}
...
...
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