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
6bcda032
Commit
6bcda032
authored
Aug 24, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Symbol resizing using aspect ratio;
TODO: copy code for rarity box to other styles
parent
e575df6c
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
69 additions
and
30 deletions
+69
-30
data/magic-new.mse-style/style
data/magic-new.mse-style/style
+5
-4
src/data/field.cpp
src/data/field.cpp
+5
-1
src/data/field/choice.cpp
src/data/field/choice.cpp
+7
-0
src/data/field/choice.hpp
src/data/field/choice.hpp
+2
-0
src/data/field/text.cpp
src/data/field/text.cpp
+0
-8
src/data/field/text.hpp
src/data/field/text.hpp
+0
-1
src/gfx/generated_image.cpp
src/gfx/generated_image.cpp
+7
-1
src/render/symbol/filter.cpp
src/render/symbol/filter.cpp
+2
-2
src/render/symbol/filter.hpp
src/render/symbol/filter.hpp
+1
-1
src/render/symbol/viewer.cpp
src/render/symbol/viewer.cpp
+3
-3
src/render/symbol/viewer.hpp
src/render/symbol/viewer.hpp
+1
-1
src/render/value/choice.cpp
src/render/value/choice.cpp
+34
-7
src/render/value/choice.hpp
src/render/value/choice.hpp
+1
-0
src/render/value/symbol.cpp
src/render/value/symbol.cpp
+1
-1
No files found.
data/magic-new.mse-style/style
View file @
6bcda032
...
...
@@ -199,10 +199,10 @@ card style:
type:
left: 35
top : 298
width:
286
width:
{ 308 - max(22,card_style.rarity.content_width) }
height: 20
alignment: top shrink-overflow
z index:
1
z index:
2
padding top: 2
font:
name: Matrix
...
...
@@ -211,12 +211,13 @@ card style:
separator color: rgb(128,128,128)
rarity:
left: 320
right: 342
top : 297
width:
22
width:
44
height: 22
z index: 1
render style: image
alignment: middle right
choice images:
# Images based on the set symbol
basic land: script: symbol_variation(symbol: set.symbol, variation: "common")
...
...
src/data/field.cpp
View file @
6bcda032
...
...
@@ -170,7 +170,11 @@ void Style::checkContentDependencies(Context& ctx, const Dependency& dep) const
}
void
Style
::
markDependencyMember
(
const
String
&
name
,
const
Dependency
&
dep
)
const
{
// no content specific properties here
// mark dependencies on content
if
(
dep
.
type
==
DEP_DUMMY
&&
dep
.
index
==
false
&&
starts_with
(
name
,
_
(
"content "
)))
{
// anything that starts with "content_" is a content property
const_cast
<
Dependency
&>
(
dep
).
index
=
true
;
}
}
void
mark_dependency_member
(
const
Style
&
style
,
const
String
&
name
,
const
Dependency
&
dep
)
{
...
...
src/data/field/choice.cpp
View file @
6bcda032
...
...
@@ -283,6 +283,12 @@ IMPLEMENT_REFLECTION_ENUM(ChoiceRenderStyle) {
VALUE_N
(
"both list"
,
RENDER_BOTH_LIST
);
}
template
<
typename
T
>
void
reflect_content
(
T
&
tag
,
const
ChoiceStyle
&
cs
)
{}
template
<>
void
reflect_content
(
GetMember
&
tag
,
const
ChoiceStyle
&
cs
)
{
REFLECT_N
(
"content_width"
,
cs
.
content_width
);
REFLECT_N
(
"content_height"
,
cs
.
content_height
);
}
IMPLEMENT_REFLECTION
(
ChoiceStyle
)
{
REFLECT_ALIAS
(
300
,
"card list colors"
,
"colors card list"
);
REFLECT_BASE
(
Style
);
...
...
@@ -295,6 +301,7 @@ IMPLEMENT_REFLECTION(ChoiceStyle) {
REFLECT
(
font
);
REFLECT
(
image
);
REFLECT
(
choice_images
);
reflect_content
(
tag
,
*
this
);
}
// ----------------------------------------------------------------------------- : ChoiceValue
...
...
src/data/field/choice.hpp
View file @
6bcda032
...
...
@@ -155,6 +155,8 @@ class ChoiceStyle : public Style {
int
angle
;
///< Angle by which the images are rotated
wxImageList
*
thumbnails
;
///< Thumbnails for the choices
vector
<
ThumbnailStatus
>
thumbnails_status
;
///< Which thumbnails are up to date?
// information from image rendering
double
content_width
,
content_height
;
///< Size of the rendered image/text
/// Load the mask image, if it's not already done
void
loadMask
(
Package
&
pkg
);
...
...
src/data/field/text.cpp
View file @
6bcda032
...
...
@@ -81,14 +81,6 @@ void TextStyle::checkContentDependencies(Context& ctx, const Dependency& dep) co
Style
::
checkContentDependencies
(
ctx
,
dep
);
alignment
.
initDependencies
(
ctx
,
dep
);
}
void
TextStyle
::
markDependencyMember
(
const
String
&
name
,
const
Dependency
&
dep
)
const
{
Style
::
markDependencyMember
(
name
,
dep
);
// mark dependencies on content
if
(
dep
.
type
==
DEP_DUMMY
&&
dep
.
index
==
false
&&
(
name
==
_
(
"content width"
)
||
name
==
_
(
"content height"
)
||
name
==
_
(
"content lines"
)))
{
const_cast
<
Dependency
&>
(
dep
).
index
=
true
;
}
}
template
<
typename
T
>
void
reflect_content
(
T
&
tag
,
const
TextStyle
&
ts
)
{}
template
<>
void
reflect_content
(
GetMember
&
tag
,
const
TextStyle
&
ts
)
{
...
...
src/data/field/text.hpp
View file @
6bcda032
...
...
@@ -75,7 +75,6 @@ class TextStyle : public Style {
virtual
bool
update
(
Context
&
);
virtual
void
initDependencies
(
Context
&
,
const
Dependency
&
)
const
;
virtual
void
checkContentDependencies
(
Context
&
,
const
Dependency
&
)
const
;
virtual
void
markDependencyMember
(
const
String
&
name
,
const
Dependency
&
)
const
;
/// The rotation to use when drawing
inline
Rotation
getRotation
()
const
{
...
...
src/gfx/generated_image.cpp
View file @
6bcda032
...
...
@@ -387,7 +387,13 @@ Image SymbolToImage::generate(const Options& opt) const {
the_symbol
=
opt
.
local_package
->
readFile
<
SymbolP
>
(
filename
);
}
int
size
=
max
(
100
,
3
*
max
(
opt
.
width
,
opt
.
height
));
return
render_symbol
(
the_symbol
,
*
variation
->
filter
,
variation
->
border_radius
,
size
,
size
);
if
(
opt
.
width
<=
1
||
opt
.
height
<=
1
)
{
return
render_symbol
(
the_symbol
,
*
variation
->
filter
,
variation
->
border_radius
,
size
,
size
);
}
else
{
int
width
=
size
*
opt
.
width
/
max
(
opt
.
width
,
opt
.
height
);
int
height
=
size
*
opt
.
height
/
max
(
opt
.
width
,
opt
.
height
);
return
render_symbol
(
the_symbol
,
*
variation
->
filter
,
variation
->
border_radius
,
width
,
height
,
false
,
true
);
}
}
bool
SymbolToImage
::
operator
==
(
const
GeneratedImage
&
that
)
const
{
const
SymbolToImage
*
that2
=
dynamic_cast
<
const
SymbolToImage
*>
(
&
that
);
...
...
src/render/symbol/filter.cpp
View file @
6bcda032
...
...
@@ -71,8 +71,8 @@ void filter_symbol(Image& symbol, const SymbolFilter& filter) {
}
}
Image
render_symbol
(
const
SymbolP
&
symbol
,
const
SymbolFilter
&
filter
,
double
border_radius
,
int
width
,
int
height
,
bool
edit_hints
)
{
Image
i
=
render_symbol
(
symbol
,
border_radius
,
width
,
height
,
edit_hints
);
Image
render_symbol
(
const
SymbolP
&
symbol
,
const
SymbolFilter
&
filter
,
double
border_radius
,
int
width
,
int
height
,
bool
edit_hints
,
bool
allow_smaller
)
{
Image
i
=
render_symbol
(
symbol
,
border_radius
,
width
,
height
,
edit_hints
,
allow_smaller
);
filter_symbol
(
i
,
filter
);
return
i
;
}
...
...
src/render/symbol/filter.hpp
View file @
6bcda032
...
...
@@ -35,7 +35,7 @@ class AColor : public Color {
void
filter_symbol
(
Image
&
symbol
,
const
SymbolFilter
&
filter
);
/// Render a Symbol to an Image and filter it
Image
render_symbol
(
const
SymbolP
&
symbol
,
const
SymbolFilter
&
filter
,
double
border_radius
=
0.05
,
int
width
=
100
,
int
height
=
100
,
bool
edit_hints
=
false
);
Image
render_symbol
(
const
SymbolP
&
symbol
,
const
SymbolFilter
&
filter
,
double
border_radius
=
0.05
,
int
width
=
100
,
int
height
=
100
,
bool
edit_hints
=
false
,
bool
allow_smaller
=
false
);
/// Is a point inside a symbol?
enum
SymbolSet
...
...
src/render/symbol/viewer.cpp
View file @
6bcda032
...
...
@@ -14,14 +14,14 @@ DECLARE_TYPEOF_COLLECTION(SymbolPartP);
// ----------------------------------------------------------------------------- : Simple rendering
Image
render_symbol
(
const
SymbolP
&
symbol
,
double
border_radius
,
int
width
,
int
height
,
bool
editing_hints
)
{
Image
render_symbol
(
const
SymbolP
&
symbol
,
double
border_radius
,
int
width
,
int
height
,
bool
editing_hints
,
bool
allow_smaller
)
{
SymbolViewer
viewer
(
symbol
,
editing_hints
,
width
,
border_radius
);
// limit width/height ratio to aspect ratio of symbol
double
ar
=
symbol
->
aspectRatio
();
double
par
=
(
double
)
width
/
height
;
if
(
par
>
ar
&&
ar
>
1
)
{
if
(
par
>
ar
&&
(
ar
>
1
||
(
allow_smaller
&&
height
<
width
))
)
{
width
=
height
*
ar
;
}
else
if
(
par
<
ar
&&
ar
<
1
)
{
}
else
if
(
par
<
ar
&&
(
ar
<
1
||
(
allow_smaller
&&
width
<
height
))
)
{
height
=
width
/
ar
;
}
if
(
width
>
height
)
{
...
...
src/render/symbol/viewer.hpp
View file @
6bcda032
...
...
@@ -17,7 +17,7 @@
// ----------------------------------------------------------------------------- : Simple rendering
/// Render a Symbol to an Image
Image
render_symbol
(
const
SymbolP
&
symbol
,
double
border_radius
=
0.05
,
int
width
=
100
,
int
height
=
100
,
bool
editing_hints
=
false
);
Image
render_symbol
(
const
SymbolP
&
symbol
,
double
border_radius
=
0.05
,
int
width
=
100
,
int
height
=
100
,
bool
editing_hints
=
false
,
bool
allow_smaller
=
false
);
// ----------------------------------------------------------------------------- : Symbol Viewer
...
...
src/render/value/choice.cpp
View file @
6bcda032
...
...
@@ -12,6 +12,40 @@
// ----------------------------------------------------------------------------- : ChoiceValueViewer
bool
ChoiceValueViewer
::
prepare
(
RotatedDC
&
dc
)
{
if
(
style
().
render_style
&
RENDER_IMAGE
)
{
style
().
initImage
();
ScriptableImage
&
img
=
style
().
image
;
Context
&
ctx
=
viewer
.
getContext
();
ctx
.
setVariable
(
_
(
"input"
),
to_script
(
value
().
value
()));
img
.
update
(
ctx
);
//generate
if
(
img
.
isReady
())
{
GeneratedImage
::
Options
img_options
(
0
,
0
,
viewer
.
stylesheet
.
get
(),
&
getSet
());
if
(
nativeLook
())
{
img_options
.
width
=
img_options
.
height
=
16
;
img_options
.
preserve_aspect
=
ASPECT_BORDER
;
}
else
if
(
style
().
render_style
&
RENDER_TEXT
)
{
// also drawing text, use original size
}
else
{
img_options
.
width
=
(
int
)
dc
.
trX
(
style
().
width
);
img_options
.
height
=
(
int
)
dc
.
trY
(
style
().
height
);
img_options
.
preserve_aspect
=
(
style
().
alignment
&
ALIGN_STRETCH
)
?
ASPECT_STRETCH
:
ASPECT_FIT
;
}
// don't worry we cache the image
Image
image
=
img
.
generate
(
img_options
,
true
);
// store content properties
if
(
style
().
content_width
!=
image
.
GetWidth
()
||
style
().
content_height
!=
image
.
GetHeight
())
{
style
().
content_width
=
image
.
GetWidth
();
style
().
content_height
=
image
.
GetHeight
();
return
true
;
}
}
}
return
false
;
}
void
ChoiceValueViewer
::
draw
(
RotatedDC
&
dc
)
{
drawFieldBorder
(
dc
);
if
(
style
().
render_style
&
RENDER_HIDDEN
)
return
;
...
...
@@ -19,14 +53,7 @@ void ChoiceValueViewer::draw(RotatedDC& dc) {
double
margin
=
0
;
if
(
style
().
render_style
&
RENDER_IMAGE
)
{
// draw image
// map<String,ScriptableImage>::iterator it = style().choice_images.find(cannocial_name_form(value().value()));
// if (it != style().choice_images.end() && it->second.isReady()) {
// ScriptableImage& img = it->second;
style
().
initImage
();
ScriptableImage
&
img
=
style
().
image
;
Context
&
ctx
=
viewer
.
getContext
();
ctx
.
setVariable
(
_
(
"input"
),
to_script
(
value
().
value
()));
img
.
update
(
ctx
);
if
(
img
.
isReady
())
{
GeneratedImage
::
Options
img_options
(
0
,
0
,
viewer
.
stylesheet
.
get
(),
&
getSet
());
if
(
nativeLook
())
{
...
...
src/render/value/choice.hpp
View file @
6bcda032
...
...
@@ -20,6 +20,7 @@ class ChoiceValueViewer : public ValueViewer {
public:
DECLARE_VALUE_VIEWER
(
Choice
)
:
ValueViewer
(
parent
,
style
)
{}
virtual
bool
prepare
(
RotatedDC
&
dc
);
virtual
void
draw
(
RotatedDC
&
dc
);
virtual
void
onStyleChange
(
bool
);
};
...
...
src/render/value/symbol.cpp
View file @
6bcda032
...
...
@@ -32,7 +32,7 @@ void SymbolValueViewer::draw(RotatedDC& dc) {
ar
=
min
(
style
().
max_aspect_ratio
,
max
(
style
().
min_aspect_ratio
,
ar
));
// render and filter variations
FOR_EACH
(
variation
,
style
().
variations
)
{
Image
img
=
render_symbol
(
symbol
,
*
variation
->
filter
,
variation
->
border_radius
,
100
*
ar
,
1
00
);
Image
img
=
render_symbol
(
symbol
,
*
variation
->
filter
,
variation
->
border_radius
,
200
*
ar
,
2
00
);
Image
resampled
((
int
)
(
wh
*
ar
),
(
int
)
wh
,
false
);
resample
(
img
,
resampled
);
symbols
.
push_back
(
Bitmap
(
resampled
));
...
...
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