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
1da6fe2b
Commit
1da6fe2b
authored
Jun 05, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow symbol_variation script function to load images from the stylesheet by filename
parent
9edf0ca5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
13 deletions
+27
-13
src/gfx/generated_image.cpp
src/gfx/generated_image.cpp
+7
-5
src/gfx/generated_image.hpp
src/gfx/generated_image.hpp
+4
-3
src/script/functions/image.cpp
src/script/functions/image.cpp
+16
-5
No files found.
src/gfx/generated_image.cpp
View file @
1da6fe2b
...
@@ -385,19 +385,20 @@ bool BuiltInImage::operator == (const GeneratedImage& that) const {
...
@@ -385,19 +385,20 @@ bool BuiltInImage::operator == (const GeneratedImage& that) const {
// ----------------------------------------------------------------------------- : SymbolToImage
// ----------------------------------------------------------------------------- : SymbolToImage
SymbolToImage
::
SymbolToImage
(
const
String
&
filename
,
Age
age
,
const
SymbolVariationP
&
variation
)
SymbolToImage
::
SymbolToImage
(
bool
is_local
,
const
String
&
filename
,
Age
age
,
const
SymbolVariationP
&
variation
)
:
filename
(
filename
),
age
(
age
),
variation
(
variation
)
:
is_local
(
is_local
),
filename
(
filename
),
age
(
age
),
variation
(
variation
)
{}
{}
SymbolToImage
::~
SymbolToImage
()
{}
SymbolToImage
::~
SymbolToImage
()
{}
Image
SymbolToImage
::
generate
(
const
Options
&
opt
)
const
{
Image
SymbolToImage
::
generate
(
const
Options
&
opt
)
const
{
// TODO : use opt.width and opt.height?
// TODO : use opt.width and opt.height?
if
(
!
opt
.
local_package
)
throw
ScriptError
(
_
(
"Can only load images in a context where an image is expected"
));
Package
*
package
=
is_local
?
opt
.
local_package
:
opt
.
package
;
if
(
!
package
)
throw
ScriptError
(
_
(
"Can only load images in a context where an image is expected"
));
SymbolP
the_symbol
;
SymbolP
the_symbol
;
if
(
filename
.
empty
())
{
if
(
filename
.
empty
())
{
the_symbol
=
default_symbol
();
the_symbol
=
default_symbol
();
}
else
{
}
else
{
the_symbol
=
opt
.
local_
package
->
readFile
<
SymbolP
>
(
filename
);
the_symbol
=
package
->
readFile
<
SymbolP
>
(
filename
);
}
}
int
size
=
max
(
100
,
3
*
max
(
opt
.
width
,
opt
.
height
));
int
size
=
max
(
100
,
3
*
max
(
opt
.
width
,
opt
.
height
));
if
(
opt
.
width
<=
1
||
opt
.
height
<=
1
)
{
if
(
opt
.
width
<=
1
||
opt
.
height
<=
1
)
{
...
@@ -410,7 +411,8 @@ Image SymbolToImage::generate(const Options& opt) const {
...
@@ -410,7 +411,8 @@ Image SymbolToImage::generate(const Options& opt) const {
}
}
bool
SymbolToImage
::
operator
==
(
const
GeneratedImage
&
that
)
const
{
bool
SymbolToImage
::
operator
==
(
const
GeneratedImage
&
that
)
const
{
const
SymbolToImage
*
that2
=
dynamic_cast
<
const
SymbolToImage
*>
(
&
that
);
const
SymbolToImage
*
that2
=
dynamic_cast
<
const
SymbolToImage
*>
(
&
that
);
return
that2
&&
filename
==
that2
->
filename
return
that2
&&
is_local
==
that2
->
is_local
&&
filename
==
that2
->
filename
&&
age
==
that2
->
age
&&
age
==
that2
->
age
&&
(
variation
==
that2
->
variation
||
&&
(
variation
==
that2
->
variation
||
*
variation
==
*
that2
->
variation
// custom variation
*
variation
==
*
that2
->
variation
// custom variation
...
...
src/gfx/generated_image.hpp
View file @
1da6fe2b
...
@@ -289,19 +289,20 @@ class BuiltInImage : public GeneratedImage {
...
@@ -289,19 +289,20 @@ class BuiltInImage : public GeneratedImage {
/// Use a symbol as an image
/// Use a symbol as an image
class
SymbolToImage
:
public
GeneratedImage
{
class
SymbolToImage
:
public
GeneratedImage
{
public:
public:
SymbolToImage
(
const
String
&
filename
,
Age
age
,
const
SymbolVariationP
&
variation
);
SymbolToImage
(
bool
is_local
,
const
String
&
filename
,
Age
age
,
const
SymbolVariationP
&
variation
);
~
SymbolToImage
();
~
SymbolToImage
();
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
Image
generate
(
const
Options
&
opt
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
operator
==
(
const
GeneratedImage
&
that
)
const
;
virtual
bool
local
()
const
{
return
true
;
}
virtual
bool
local
()
const
{
return
is_local
;
}
#ifdef __WXGTK__
#ifdef __WXGTK__
virtual
bool
threadSafe
()
const
{
return
false
;
}
virtual
bool
threadSafe
()
const
{
return
false
;
}
#endif
#endif
private:
private:
SymbolToImage
(
const
SymbolToImage
&
);
// copy ctor
SymbolToImage
(
const
SymbolToImage
&
);
// copy ctor
bool
is_local
;
///< Use local package?
String
filename
;
String
filename
;
Age
age
;
///< Age the symbol was last updated
Age
age
;
///< Age the symbol was last updated
SymbolVariationP
variation
;
SymbolVariationP
variation
;
};
};
...
...
src/script/functions/image.cpp
View file @
1da6fe2b
...
@@ -112,9 +112,20 @@ SCRIPT_FUNCTION(drop_shadow) {
...
@@ -112,9 +112,20 @@ SCRIPT_FUNCTION(drop_shadow) {
SCRIPT_FUNCTION
(
symbol_variation
)
{
SCRIPT_FUNCTION
(
symbol_variation
)
{
// find symbol
// find symbol
SCRIPT_PARAM
(
ValueP
,
symbol
);
SCRIPT_PARAM
(
ScriptValueP
,
symbol
);
// TODO: change to input?
SymbolValueP
value
=
dynamic_pointer_cast
<
SymbolValue
>
(
symbol
);
ScriptObject
<
ValueP
>*
valueO
=
dynamic_cast
<
ScriptObject
<
ValueP
>*>
(
symbol
.
get
());
SCRIPT_OPTIONAL_PARAM
(
String
,
variation
)
{
SymbolValue
*
value
=
valueO
?
dynamic_cast
<
SymbolValue
*>
(
valueO
->
getValue
().
get
())
:
nullptr
;
String
filename
;
if
(
value
)
{
filename
=
value
->
filename
;
}
else
if
(
valueO
)
{
throw
ScriptError
(
_ERROR_2_
(
"can't convert"
,
valueO
->
typeName
(),
_TYPE_
(
"symbol"
)));
}
else
{
filename
=
from_script
<
String
>
(
symbol
);
}
// known variation?
SCRIPT_OPTIONAL_PARAM_
(
String
,
variation
)
if
(
value
&&
variation_
)
{
// find style
// find style
SCRIPT_PARAM
(
Set
*
,
set
);
SCRIPT_PARAM
(
Set
*
,
set
);
SCRIPT_OPTIONAL_PARAM_
(
CardP
,
card
);
SCRIPT_OPTIONAL_PARAM_
(
CardP
,
card
);
...
@@ -124,7 +135,7 @@ SCRIPT_FUNCTION(symbol_variation) {
...
@@ -124,7 +135,7 @@ SCRIPT_FUNCTION(symbol_variation) {
FOR_EACH
(
v
,
style
->
variations
)
{
FOR_EACH
(
v
,
style
->
variations
)
{
if
(
v
->
name
==
variation
)
{
if
(
v
->
name
==
variation
)
{
// found it
// found it
return
new_intrusive
3
<
SymbolToImage
>
(
value
->
filename
,
value
->
last_update
,
v
);
return
new_intrusive
4
<
SymbolToImage
>
(
value
,
filename
,
value
->
last_update
,
v
);
}
}
}
}
throw
ScriptError
(
_
(
"Variation of symbol not found ('"
)
+
variation
+
_
(
"')"
));
throw
ScriptError
(
_
(
"Variation of symbol not found ('"
)
+
variation
+
_
(
"')"
));
...
@@ -158,7 +169,7 @@ SCRIPT_FUNCTION(symbol_variation) {
...
@@ -158,7 +169,7 @@ SCRIPT_FUNCTION(symbol_variation) {
}
else
{
}
else
{
throw
ScriptError
(
_
(
"Unknown fill type for symbol_variation: "
)
+
fill_type
);
throw
ScriptError
(
_
(
"Unknown fill type for symbol_variation: "
)
+
fill_type
);
}
}
return
new_intrusive
3
<
SymbolToImage
>
(
value
->
filename
,
value
->
last_update
,
var
);
return
new_intrusive
4
<
SymbolToImage
>
(
value
,
filename
,
value
?
value
->
last_update
:
Age
()
,
var
);
}
}
}
}
...
...
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