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
a335b3f6
Commit
a335b3f6
authored
Jun 25, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented export functions;
Choice viewer uses font when rendering text.
parent
eed5eab8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
83 additions
and
25 deletions
+83
-25
src/data/export_template.hpp
src/data/export_template.hpp
+2
-0
src/data/field/choice.cpp
src/data/field/choice.cpp
+1
-0
src/gui/html_export_window.cpp
src/gui/html_export_window.cpp
+2
-0
src/render/value/choice.cpp
src/render/value/choice.cpp
+9
-3
src/script/functions/export.cpp
src/script/functions/export.cpp
+69
-22
No files found.
src/data/export_template.hpp
View file @
a335b3f6
...
...
@@ -14,6 +14,7 @@
#include <script/scriptable.hpp>
DECLARE_POINTER_TYPE
(
Game
);
DECLARE_POINTER_TYPE
(
Set
);
DECLARE_POINTER_TYPE
(
Field
);
DECLARE_POINTER_TYPE
(
Style
);
DECLARE_POINTER_TYPE
(
ExportTemplate
);
...
...
@@ -42,6 +43,7 @@ class ExportTemplate : public Packaged {
/// Information that can be used by export functions
struct
ExportInfo
{
SetP
set
;
///< The set that is being exported
ExportTemplateP
export_template
;
///< The export template used
String
directory_relative
;
///< The directory for storing extra files (or "" if !export->create_directory)
/// This is just the directory name
...
...
src/data/field/choice.cpp
View file @
a335b3f6
...
...
@@ -212,6 +212,7 @@ void ChoiceStyle::initImage() {
bool
ChoiceStyle
::
update
(
Context
&
ctx
)
{
// Don't update the choice images, leave that to invalidate()
bool
change
=
Style
::
update
(
ctx
)
|
font
.
update
(
ctx
)
|
mask_filename
.
update
(
ctx
);
if
(
!
choice_images_initialized
)
{
// we only want to do this once because it is rather slow, other updates are handled by dependencies
...
...
src/gui/html_export_window.cpp
View file @
a335b3f6
...
...
@@ -51,9 +51,11 @@ void HtmlExportWindow::onOk(wxCommandEvent&) {
// get filename
String
name
=
wxFileSelector
(
_TITLE_
(
"save html"
),
_
(
""
),
_
(
""
),
_
(
""
),
exp
->
file_type
,
wxSAVE
|
wxOVERWRITE_PROMPT
);
if
(
name
.
empty
())
return
;
wxBusyCursor
wait
;
// export info for script
ExportInfo
info
;
info
.
export_template
=
exp
;
info
.
set
=
set
;
WITH_DYNAMIC_ARG
(
export_info
,
&
info
);
// create directory?
if
(
exp
->
create_directory
)
{
...
...
src/render/value/choice.cpp
View file @
a335b3f6
...
...
@@ -57,9 +57,15 @@ void ChoiceValueViewer::draw(RotatedDC& dc) {
}
if
(
style
().
render_style
&
RENDER_TEXT
)
{
// draw text
dc
.
DrawText
(
tr
(
*
viewer
.
stylesheet
,
value
().
value
(),
capitalize
(
value
().
value
())),
align_in_rect
(
ALIGN_MIDDLE_LEFT
,
RealSize
(
0
,
dc
.
GetCharHeight
()),
style
().
getRect
())
+
RealSize
(
margin
,
0
)
);
dc
.
SetFont
(
style
().
font
,
1.0
);
String
text
=
tr
(
*
viewer
.
stylesheet
,
value
().
value
(),
capitalize
(
value
().
value
()));
RealPoint
pos
=
align_in_rect
(
ALIGN_MIDDLE_LEFT
,
RealSize
(
0
,
dc
.
GetCharHeight
()),
style
().
getRect
())
+
RealSize
(
margin
,
0
);
if
(
style
().
font
.
hasShadow
())
{
dc
.
SetTextForeground
(
style
().
font
.
shadow_color
);
dc
.
DrawText
(
text
,
pos
+
style
().
font
.
shadow_displacement
);
}
dc
.
SetTextForeground
(
style
().
font
.
color
());
dc
.
DrawText
(
text
,
pos
);
}
}
...
...
src/script/functions/export.cpp
View file @
a335b3f6
...
...
@@ -8,9 +8,17 @@
#include <script/functions/functions.hpp>
#include <script/functions/util.hpp>
#include <script/image.hpp>
#include <data/symbol_font.hpp>
#include <data/set.hpp>
#include <data/card.hpp>
#include <data/export_template.hpp>
#include <data/format/formats.hpp>
#include <util/tagged_string.hpp>
#include <gfx/generated_image.hpp>
#include <util/error.hpp>
#include <wx/wfstream.h>
#include <wx/filename.h>
// ----------------------------------------------------------------------------- : HTML
...
...
@@ -200,37 +208,76 @@ SCRIPT_FUNCTION(to_text) {
// ----------------------------------------------------------------------------- : Files
// copy from source package -> destination package, return new filename (relative)
SCRIPT_FUNCTION
(
copy_file
)
{
throw
InternalError
(
_
(
"TODO: copy_file"
));
// TODO
void
guard_export_info
(
const
String
&
fun
)
{
if
(
!
export_info
())
{
throw
ScriptError
(
_
(
"Can only use "
)
+
fun
+
_
(
" from export templates"
));
}
else
if
(
export_info
()
->
directory_relative
.
empty
())
{
throw
ScriptError
(
_
(
"Can only use "
)
+
fun
+
_
(
" when 'create directory' is set to true"
));
}
}
// write a file to the destination package.
// if 'filename' is not set, writes to the 'main' output file.
SCRIPT_FUNCTION
(
write_file
)
{
throw
InternalError
(
_
(
"TODO: write_file"
));
// TODO
// copy from source package -> destination directory, return new filename (relative)
SCRIPT_FUNCTION
(
copy_file
)
{
guard_export_info
(
_
(
"copy_file"
));
SCRIPT_PARAM
(
String
,
input
);
// file to copy
ExportInfo
&
ei
=
*
export_info
();
wxFileName
fn
(
input
);
fn
.
SetPath
(
ei
.
directory_absolute
);
// copy
InputStreamP
in
=
ei
.
export_template
->
openIn
(
input
);
wxFileOutputStream
out
(
fn
.
GetFullPath
());
if
(
!
out
.
Ok
())
throw
Error
(
_
(
"Unable to open file '"
)
+
fn
.
GetFullPath
()
+
_
(
"' for output"
));
out
.
Write
(
*
in
);
SCRIPT_RETURN
(
fn
.
GetFullName
());
}
// write an ImageValue to a new file, return the filename
// if the image was not written, return nil
// TODO: write a ScriptImage?
SCRIPT_FUNCTION
(
image_to_file
)
{
throw
InternalError
(
_
(
"TODO: image_to_file"
));
// TODO
// write a file to the destination directory
SCRIPT_FUNCTION
(
write_text_file
)
{
guard_export_info
(
_
(
"write_text_file"
));
SCRIPT_PARAM
(
String
,
input
);
// text to write
SCRIPT_PARAM
(
String
,
file
);
// file to write to
// filename
wxFileName
fn
;
fn
.
SetPath
(
export_info
()
->
directory_absolute
);
fn
.
SetFullName
(
file
);
// write
wxFileOutputStream
out
(
fn
.
GetFullPath
());
if
(
!
out
.
Ok
())
throw
Error
(
_
(
"Unable to open file '"
)
+
fn
.
GetFullPath
()
+
_
(
"' for output"
));
wxTextOutputStream
tout
(
out
);
tout
.
WriteString
(
BYTE_ORDER_MARK
);
tout
.
WriteString
(
input
);
SCRIPT_RETURN
(
fn
.
GetFullName
());
}
// render a card, and write the image to a file
SCRIPT_FUNCTION
(
render_to_file
)
{
throw
InternalError
(
_
(
"TODO: render_to_file"
));
// TODO
SCRIPT_FUNCTION
(
write_image_file
)
{
guard_export_info
(
_
(
"write_image_file"
));
ExportInfo
&
ei
=
*
export_info
();
// get image
SCRIPT_PARAM
(
ScriptValueP
,
input
);
ScriptObject
<
CardP
>*
card
=
dynamic_cast
<
ScriptObject
<
CardP
>*>
(
input
.
get
());
// is it a card?
Image
image
;
if
(
card
)
{
image
=
export_bitmap
(
ei
.
set
,
card
->
getValue
()).
ConvertToImage
();
}
else
{
image
=
image_from_script
(
input
)
->
generate
(
GeneratedImage
::
Options
(
0
,
0
,
ei
.
export_template
.
get
(),
ei
.
set
.
get
()));
}
if
(
!
image
.
Ok
())
throw
Error
(
_
(
"Unable to convert .. to image"
));
// filename
SCRIPT_PARAM
(
String
,
file
);
// file to write to
wxFileName
fn
;
fn
.
SetPath
(
ei
.
directory_absolute
);
fn
.
SetFullName
(
file
);
// write
image
.
SaveFile
(
fn
.
GetFullPath
());
SCRIPT_RETURN
(
fn
.
GetFullName
());
}
// ----------------------------------------------------------------------------- : Init
void
init_script_export_functions
(
Context
&
ctx
)
{
ctx
.
setVariable
(
_
(
"to html"
),
script_to_html
);
ctx
.
setVariable
(
_
(
"to text"
),
script_to_text
);
ctx
.
setVariable
(
_
(
"copy file"
),
script_copy_file
);
ctx
.
setVariable
(
_
(
"write file"
),
script_write_file
);
ctx
.
setVariable
(
_
(
"image to file"
),
script_image_to_file
);
ctx
.
setVariable
(
_
(
"write image"
),
script_image_to_file
);
ctx
.
setVariable
(
_
(
"render to file"
),
script_render_to_file
);
ctx
.
setVariable
(
_
(
"to html"
),
script_to_html
);
ctx
.
setVariable
(
_
(
"to text"
),
script_to_text
);
ctx
.
setVariable
(
_
(
"copy file"
),
script_copy_file
);
ctx
.
setVariable
(
_
(
"write text file"
),
script_write_text_file
);
ctx
.
setVariable
(
_
(
"write image file"
),
script_write_image_file
);
}
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