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
b9b1279f
Commit
b9b1279f
authored
Dec 26, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Added 'package list' field type
- Some refactoring of the other field types
parent
2122c383
Changes
32
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
573 additions
and
94 deletions
+573
-94
src/data/action/value.cpp
src/data/action/value.cpp
+3
-0
src/data/action/value.hpp
src/data/action/value.hpp
+2
-0
src/data/field.cpp
src/data/field.cpp
+2
-0
src/data/field.hpp
src/data/field.hpp
+4
-1
src/data/field/boolean.cpp
src/data/field/boolean.cpp
+1
-5
src/data/field/choice.cpp
src/data/field/choice.cpp
+1
-5
src/data/field/color.cpp
src/data/field/color.cpp
+1
-5
src/data/field/image.cpp
src/data/field/image.cpp
+1
-5
src/data/field/information.cpp
src/data/field/information.cpp
+1
-5
src/data/field/multiple_choice.cpp
src/data/field/multiple_choice.cpp
+1
-5
src/data/field/package_choice.cpp
src/data/field/package_choice.cpp
+83
-0
src/data/field/package_choice.hpp
src/data/field/package_choice.hpp
+69
-0
src/data/field/symbol.cpp
src/data/field/symbol.cpp
+1
-5
src/data/field/text.cpp
src/data/field/text.cpp
+1
-5
src/data/symbol_font.cpp
src/data/symbol_font.cpp
+11
-5
src/gui/value/editor.cpp
src/gui/value/editor.cpp
+1
-24
src/gui/value/editor.hpp
src/gui/value/editor.hpp
+4
-0
src/gui/value/package_choice.cpp
src/gui/value/package_choice.cpp
+119
-0
src/gui/value/package_choice.hpp
src/gui/value/package_choice.hpp
+42
-0
src/mse.vcproj
src/mse.vcproj
+102
-0
src/render/value/choice.cpp
src/render/value/choice.cpp
+3
-1
src/render/value/color.cpp
src/render/value/color.cpp
+2
-0
src/render/value/image.cpp
src/render/value/image.cpp
+2
-0
src/render/value/information.cpp
src/render/value/information.cpp
+2
-0
src/render/value/multiple_choice.cpp
src/render/value/multiple_choice.cpp
+2
-0
src/render/value/package_choice.cpp
src/render/value/package_choice.cpp
+62
-0
src/render/value/package_choice.hpp
src/render/value/package_choice.hpp
+38
-0
src/render/value/symbol.cpp
src/render/value/symbol.cpp
+2
-0
src/render/value/text.cpp
src/render/value/text.cpp
+2
-0
src/render/value/viewer.cpp
src/render/value/viewer.cpp
+0
-23
src/render/value/viewer.hpp
src/render/value/viewer.hpp
+6
-0
src/util/string.cpp
src/util/string.cpp
+2
-0
No files found.
src/data/action/value.cpp
View file @
b9b1279f
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
#include <data/field/color.hpp>
#include <data/field/color.hpp>
#include <data/field/image.hpp>
#include <data/field/image.hpp>
#include <data/field/symbol.hpp>
#include <data/field/symbol.hpp>
#include <data/field/package_choice.hpp>
#include <util/tagged_string.hpp>
#include <util/tagged_string.hpp>
// ----------------------------------------------------------------------------- : ValueAction
// ----------------------------------------------------------------------------- : ValueAction
...
@@ -30,6 +31,7 @@ inline void swap_value(ColorValue& a, ColorValue ::ValueType& b
...
@@ -30,6 +31,7 @@ inline void swap_value(ColorValue& a, ColorValue ::ValueType& b
inline
void
swap_value
(
ImageValue
&
a
,
ImageValue
::
ValueType
&
b
)
{
swap
(
a
.
filename
,
b
);
a
.
last_update
.
update
();
}
inline
void
swap_value
(
ImageValue
&
a
,
ImageValue
::
ValueType
&
b
)
{
swap
(
a
.
filename
,
b
);
a
.
last_update
.
update
();
}
inline
void
swap_value
(
SymbolValue
&
a
,
SymbolValue
::
ValueType
&
b
)
{
swap
(
a
.
filename
,
b
);
a
.
last_update
.
update
();
}
inline
void
swap_value
(
SymbolValue
&
a
,
SymbolValue
::
ValueType
&
b
)
{
swap
(
a
.
filename
,
b
);
a
.
last_update
.
update
();
}
inline
void
swap_value
(
TextValue
&
a
,
TextValue
::
ValueType
&
b
)
{
swap
(
a
.
value
,
b
);
a
.
last_update
.
update
();
}
inline
void
swap_value
(
TextValue
&
a
,
TextValue
::
ValueType
&
b
)
{
swap
(
a
.
value
,
b
);
a
.
last_update
.
update
();
}
inline
void
swap_value
(
PackageChoiceValue
&
a
,
PackageChoiceValue
::
ValueType
&
b
)
{
swap
(
a
.
package_name
,
b
);
}
inline
void
swap_value
(
MultipleChoiceValue
&
a
,
MultipleChoiceValue
::
ValueType
&
b
)
{
inline
void
swap_value
(
MultipleChoiceValue
&
a
,
MultipleChoiceValue
::
ValueType
&
b
)
{
swap
(
a
.
value
,
b
.
value
);
swap
(
a
.
value
,
b
.
value
);
swap
(
a
.
last_change
,
b
.
last_change
);
swap
(
a
.
last_change
,
b
.
last_change
);
...
@@ -68,6 +70,7 @@ ValueAction* value_action(const Card* card, const ChoiceValueP& value, c
...
@@ -68,6 +70,7 @@ ValueAction* value_action(const Card* card, const ChoiceValueP& value, c
ValueAction
*
value_action
(
const
Card
*
card
,
const
ColorValueP
&
value
,
const
Defaultable
<
Color
>&
new_value
)
{
return
new
SimpleValueAction
<
ColorValue
,
true
>
(
card
,
value
,
new_value
);
}
ValueAction
*
value_action
(
const
Card
*
card
,
const
ColorValueP
&
value
,
const
Defaultable
<
Color
>&
new_value
)
{
return
new
SimpleValueAction
<
ColorValue
,
true
>
(
card
,
value
,
new_value
);
}
ValueAction
*
value_action
(
const
Card
*
card
,
const
ImageValueP
&
value
,
const
FileName
&
new_value
)
{
return
new
SimpleValueAction
<
ImageValue
,
false
>
(
card
,
value
,
new_value
);
}
ValueAction
*
value_action
(
const
Card
*
card
,
const
ImageValueP
&
value
,
const
FileName
&
new_value
)
{
return
new
SimpleValueAction
<
ImageValue
,
false
>
(
card
,
value
,
new_value
);
}
ValueAction
*
value_action
(
const
Card
*
card
,
const
SymbolValueP
&
value
,
const
FileName
&
new_value
)
{
return
new
SimpleValueAction
<
SymbolValue
,
false
>
(
card
,
value
,
new_value
);
}
ValueAction
*
value_action
(
const
Card
*
card
,
const
SymbolValueP
&
value
,
const
FileName
&
new_value
)
{
return
new
SimpleValueAction
<
SymbolValue
,
false
>
(
card
,
value
,
new_value
);
}
ValueAction
*
value_action
(
const
Card
*
card
,
const
PackageChoiceValueP
&
value
,
const
String
&
new_value
)
{
return
new
SimpleValueAction
<
PackageChoiceValue
,
false
>
(
card
,
value
,
new_value
);
}
ValueAction
*
value_action
(
const
Card
*
card
,
const
MultipleChoiceValueP
&
value
,
const
Defaultable
<
String
>&
new_value
,
const
String
&
last_change
)
{
ValueAction
*
value_action
(
const
Card
*
card
,
const
MultipleChoiceValueP
&
value
,
const
Defaultable
<
String
>&
new_value
,
const
String
&
last_change
)
{
MultipleChoiceValue
::
ValueType
v
=
{
new_value
,
last_change
};
MultipleChoiceValue
::
ValueType
v
=
{
new_value
,
last_change
};
return
new
SimpleValueAction
<
MultipleChoiceValue
,
false
>
(
card
,
value
,
v
);
return
new
SimpleValueAction
<
MultipleChoiceValue
,
false
>
(
card
,
value
,
v
);
...
...
src/data/action/value.hpp
View file @
b9b1279f
...
@@ -28,6 +28,7 @@ DECLARE_POINTER_TYPE(MultipleChoiceValue);
...
@@ -28,6 +28,7 @@ DECLARE_POINTER_TYPE(MultipleChoiceValue);
DECLARE_POINTER_TYPE
(
ColorValue
);
DECLARE_POINTER_TYPE
(
ColorValue
);
DECLARE_POINTER_TYPE
(
ImageValue
);
DECLARE_POINTER_TYPE
(
ImageValue
);
DECLARE_POINTER_TYPE
(
SymbolValue
);
DECLARE_POINTER_TYPE
(
SymbolValue
);
DECLARE_POINTER_TYPE
(
PackageChoiceValue
);
// ----------------------------------------------------------------------------- : ValueAction (based class)
// ----------------------------------------------------------------------------- : ValueAction (based class)
...
@@ -50,6 +51,7 @@ ValueAction* value_action(const Card* card, const MultipleChoiceValueP& value, c
...
@@ -50,6 +51,7 @@ ValueAction* value_action(const Card* card, const MultipleChoiceValueP& value, c
ValueAction
*
value_action
(
const
Card
*
card
,
const
ColorValueP
&
value
,
const
Defaultable
<
Color
>&
new_value
);
ValueAction
*
value_action
(
const
Card
*
card
,
const
ColorValueP
&
value
,
const
Defaultable
<
Color
>&
new_value
);
ValueAction
*
value_action
(
const
Card
*
card
,
const
ImageValueP
&
value
,
const
FileName
&
new_value
);
ValueAction
*
value_action
(
const
Card
*
card
,
const
ImageValueP
&
value
,
const
FileName
&
new_value
);
ValueAction
*
value_action
(
const
Card
*
card
,
const
SymbolValueP
&
value
,
const
FileName
&
new_value
);
ValueAction
*
value_action
(
const
Card
*
card
,
const
SymbolValueP
&
value
,
const
FileName
&
new_value
);
ValueAction
*
value_action
(
const
Card
*
card
,
const
PackageChoiceValueP
&
value
,
const
String
&
new_value
);
// ----------------------------------------------------------------------------- : Text
// ----------------------------------------------------------------------------- : Text
...
...
src/data/field.cpp
View file @
b9b1279f
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include <data/field/symbol.hpp>
#include <data/field/symbol.hpp>
#include <data/field/color.hpp>
#include <data/field/color.hpp>
#include <data/field/information.hpp>
#include <data/field/information.hpp>
#include <data/field/package_choice.hpp>
#include <util/error.hpp>
#include <util/error.hpp>
DECLARE_TYPEOF_COLLECTION
(
StyleListener
*
);
DECLARE_TYPEOF_COLLECTION
(
StyleListener
*
);
...
@@ -80,6 +81,7 @@ intrusive_ptr<Field> read_new<Field>(Reader& reader) {
...
@@ -80,6 +81,7 @@ intrusive_ptr<Field> read_new<Field>(Reader& reader) {
else
if
(
type
==
_
(
"symbol"
))
return
new_intrusive
<
SymbolField
>
();
else
if
(
type
==
_
(
"symbol"
))
return
new_intrusive
<
SymbolField
>
();
else
if
(
type
==
_
(
"color"
))
return
new_intrusive
<
ColorField
>
();
else
if
(
type
==
_
(
"color"
))
return
new_intrusive
<
ColorField
>
();
else
if
(
type
==
_
(
"info"
))
return
new_intrusive
<
InfoField
>
();
else
if
(
type
==
_
(
"info"
))
return
new_intrusive
<
InfoField
>
();
else
if
(
type
==
_
(
"package choice"
))
return
new_intrusive
<
PackageChoiceField
>
();
else
if
(
type
.
empty
())
{
else
if
(
type
.
empty
())
{
reader
.
warning
(
_ERROR_1_
(
"expected key"
,
_
(
"type"
)));
reader
.
warning
(
_ERROR_1_
(
"expected key"
,
_
(
"type"
)));
throw
ParseError
(
_ERROR_
(
"aborting parsing"
));
throw
ParseError
(
_ERROR_
(
"aborting parsing"
));
...
...
src/data/field.hpp
View file @
b9b1279f
...
@@ -253,7 +253,7 @@ inline String type_name(const Value&) {
...
@@ -253,7 +253,7 @@ inline String type_name(const Value&) {
virtual
String
typeName
()
const
virtual
String
typeName
()
const
// implement newStyle and newValue
// implement newStyle and newValue
#define IMPLEMENT_FIELD_TYPE(Type
)
\
#define IMPLEMENT_FIELD_TYPE(Type
, NAME)
\
StyleP
Type
##
Field
::
newStyle
(
const
FieldP
&
thisP
)
const
{
\
StyleP
Type
##
Field
::
newStyle
(
const
FieldP
&
thisP
)
const
{
\
assert
(
thisP
.
get
()
==
this
);
\
assert
(
thisP
.
get
()
==
this
);
\
return
new_intrusive1
<
Type
##
Style
>
(
static_pointer_cast
<
Type
##
Field
>
(
thisP
));
\
return
new_intrusive1
<
Type
##
Style
>
(
static_pointer_cast
<
Type
##
Field
>
(
thisP
));
\
...
@@ -267,6 +267,9 @@ inline String type_name(const Value&) {
...
@@ -267,6 +267,9 @@ inline String type_name(const Value&) {
}
\
}
\
ValueP
Type
##
Value
::
clone
()
const
{
\
ValueP
Type
##
Value
::
clone
()
const
{
\
return
new_intrusive1
<
Type
##
Value
>
(
*
this
);
\
return
new_intrusive1
<
Type
##
Value
>
(
*
this
);
\
}
\
String
Type
##
Field
::
typeName
()
const
{
\
return
_
(
NAME
);
\
}
}
#define DECLARE_STYLE_TYPE(Type) \
#define DECLARE_STYLE_TYPE(Type) \
...
...
src/data/field/boolean.cpp
View file @
b9b1279f
...
@@ -16,11 +16,7 @@ BooleanField::BooleanField() {
...
@@ -16,11 +16,7 @@ BooleanField::BooleanField() {
choices
->
initIds
();
choices
->
initIds
();
}
}
IMPLEMENT_FIELD_TYPE
(
Boolean
)
IMPLEMENT_FIELD_TYPE
(
Boolean
,
"boolean"
);
String
BooleanField
::
typeName
()
const
{
return
_
(
"boolean"
);
}
IMPLEMENT_REFLECTION
(
BooleanField
)
{
IMPLEMENT_REFLECTION
(
BooleanField
)
{
REFLECT_BASE
(
Field
);
// NOTE: don't reflect as a ChoiceField
REFLECT_BASE
(
Field
);
// NOTE: don't reflect as a ChoiceField
...
...
src/data/field/choice.cpp
View file @
b9b1279f
...
@@ -20,11 +20,7 @@ ChoiceField::ChoiceField()
...
@@ -20,11 +20,7 @@ ChoiceField::ChoiceField()
,
default_name
(
_
(
"Default"
))
,
default_name
(
_
(
"Default"
))
{}
{}
IMPLEMENT_FIELD_TYPE
(
Choice
)
IMPLEMENT_FIELD_TYPE
(
Choice
,
"choice"
);
String
ChoiceField
::
typeName
()
const
{
return
_
(
"choice"
);
}
void
ChoiceField
::
initDependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
{
void
ChoiceField
::
initDependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
{
Field
::
initDependencies
(
ctx
,
dep
);
Field
::
initDependencies
(
ctx
,
dep
);
...
...
src/data/field/color.cpp
View file @
b9b1279f
...
@@ -18,11 +18,7 @@ ColorField::ColorField()
...
@@ -18,11 +18,7 @@ ColorField::ColorField()
,
default_name
(
_
(
"Default"
))
,
default_name
(
_
(
"Default"
))
{}
{}
IMPLEMENT_FIELD_TYPE
(
Color
)
IMPLEMENT_FIELD_TYPE
(
Color
,
"color"
);
String
ColorField
::
typeName
()
const
{
return
_
(
"color"
);
}
void
ColorField
::
initDependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
{
void
ColorField
::
initDependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
{
Field
::
initDependencies
(
ctx
,
dep
);
Field
::
initDependencies
(
ctx
,
dep
);
...
...
src/data/field/image.cpp
View file @
b9b1279f
...
@@ -10,11 +10,7 @@
...
@@ -10,11 +10,7 @@
// ----------------------------------------------------------------------------- : ImageField
// ----------------------------------------------------------------------------- : ImageField
IMPLEMENT_FIELD_TYPE
(
Image
)
IMPLEMENT_FIELD_TYPE
(
Image
,
"image"
);
String
ImageField
::
typeName
()
const
{
return
_
(
"image"
);
}
IMPLEMENT_REFLECTION
(
ImageField
)
{
IMPLEMENT_REFLECTION
(
ImageField
)
{
REFLECT_BASE
(
Field
);
REFLECT_BASE
(
Field
);
...
...
src/data/field/information.cpp
View file @
b9b1279f
...
@@ -11,11 +11,7 @@
...
@@ -11,11 +11,7 @@
// ----------------------------------------------------------------------------- : InfoField
// ----------------------------------------------------------------------------- : InfoField
IMPLEMENT_FIELD_TYPE
(
Info
)
IMPLEMENT_FIELD_TYPE
(
Info
,
"info"
);
String
InfoField
::
typeName
()
const
{
return
_
(
"info"
);
}
void
InfoField
::
initDependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
{
void
InfoField
::
initDependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
{
Field
::
initDependencies
(
ctx
,
dep
);
Field
::
initDependencies
(
ctx
,
dep
);
...
...
src/data/field/multiple_choice.cpp
View file @
b9b1279f
...
@@ -15,11 +15,7 @@ MultipleChoiceField::MultipleChoiceField()
...
@@ -15,11 +15,7 @@ MultipleChoiceField::MultipleChoiceField()
,
maximum_selection
(
1000000
)
,
maximum_selection
(
1000000
)
{}
{}
IMPLEMENT_FIELD_TYPE
(
MultipleChoice
)
IMPLEMENT_FIELD_TYPE
(
MultipleChoice
,
"multiple choice"
);
String
MultipleChoiceField
::
typeName
()
const
{
return
_
(
"multiple choice"
);
}
IMPLEMENT_REFLECTION
(
MultipleChoiceField
)
{
IMPLEMENT_REFLECTION
(
MultipleChoiceField
)
{
REFLECT_BASE
(
ChoiceField
);
REFLECT_BASE
(
ChoiceField
);
...
...
src/data/field/package_choice.cpp
0 → 100644
View file @
b9b1279f
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <data/field/package_choice.hpp>
#include <util/io/package_manager.hpp>
// ----------------------------------------------------------------------------- : PackageChoiceField
IMPLEMENT_FIELD_TYPE
(
PackageChoice
,
"package choice"
);
void
PackageChoiceField
::
initDependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
{
Field
::
initDependencies
(
ctx
,
dep
);
script
.
initDependencies
(
ctx
,
dep
);
}
IMPLEMENT_REFLECTION
(
PackageChoiceField
)
{
REFLECT_BASE
(
Field
);
REFLECT
(
script
);
REFLECT
(
match
);
REFLECT
(
initial
);
REFLECT
(
required
);
}
// ----------------------------------------------------------------------------- : PackageChoiceStyle
PackageChoiceStyle
::
PackageChoiceStyle
(
const
PackageChoiceFieldP
&
field
)
:
Style
(
field
)
{}
int
PackageChoiceStyle
::
update
(
Context
&
ctx
)
{
return
Style
::
update
(
ctx
)
|
font
.
update
(
ctx
)
*
CHANGE_OTHER
;
}
/*void PackageChoiceStyle::initDependencies(Context& ctx, const Dependency& dep) const {
Style ::initDependencies(ctx, dep);
// font .initDependencies(ctx, dep);
}*/
IMPLEMENT_REFLECTION
(
PackageChoiceStyle
)
{
REFLECT_BASE
(
Style
);
REFLECT
(
font
);
}
// ----------------------------------------------------------------------------- : PackageChoiceValue
String
PackageChoiceValue
::
toString
()
const
{
PackagedP
pack
=
getPackage
();
if
(
pack
)
return
pack
->
short_name
;
else
return
_
(
""
);
}
PackagedP
PackageChoiceValue
::
getPackage
()
const
{
if
(
package_name
.
empty
())
return
nullptr
;
else
return
packages
.
openAny
(
package_name
,
true
);
}
bool
PackageChoiceValue
::
update
(
Context
&
ctx
)
{
bool
change
=
field
().
script
.
invokeOn
(
ctx
,
package_name
);
Value
::
update
(
ctx
);
return
change
;
}
void
PackageChoiceValue
::
reflect
(
Reader
&
tag
)
{
REFLECT_NAMELESS
(
package_name
);
}
void
PackageChoiceValue
::
reflect
(
Writer
&
tag
)
{
REFLECT_NAMELESS
(
package_name
);
}
void
PackageChoiceValue
::
reflect
(
GetDefaultMember
&
tag
)
{
if
(
!
package_name
.
empty
()
&&
package_name
!=
field
().
initial
)
{
// add a space to the name, to indicate the dependency doesn't have to be marked
// see also SymbolFontRef::loadFont
REFLECT_NAMELESS
(
_
(
" "
)
+
package_name
);
}
else
{
REFLECT_NAMELESS
(
package_name
);
}
}
void
PackageChoiceValue
::
reflect
(
GetMember
&
tag
)
{}
src/data/field/package_choice.hpp
0 → 100644
View file @
b9b1279f
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_DATA_FIELD_PACKAGE_CHOICE
#define HEADER_DATA_FIELD_PACKAGE_CHOICE
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <data/field.hpp>
#include <data/font.hpp>
#include <script/scriptable.hpp>
DECLARE_POINTER_TYPE
(
Packaged
);
// ----------------------------------------------------------------------------- : PackageChoiceField
DECLARE_POINTER_TYPE
(
PackageChoiceField
);
DECLARE_POINTER_TYPE
(
PackageChoiceStyle
);
DECLARE_POINTER_TYPE
(
PackageChoiceValue
);
/// A field for PackageChoice values, it contains a list of choices for PackageChoices
class
PackageChoiceField
:
public
Field
{
public:
PackageChoiceField
()
:
required
(
true
)
{}
DECLARE_FIELD_TYPE
(
PackageChoice
);
OptionalScript
script
;
///< Script to apply to all values
String
match
;
///< Package filenames to match
String
initial
;
///< Initial value
bool
required
;
///< Is selecting a package required?
virtual
void
initDependencies
(
Context
&
,
const
Dependency
&
)
const
;
};
// ----------------------------------------------------------------------------- : PackageChoiceStyle
/// The Style for a PackageChoiceField
class
PackageChoiceStyle
:
public
Style
{
public:
PackageChoiceStyle
(
const
PackageChoiceFieldP
&
field
);
DECLARE_STYLE_TYPE
(
PackageChoice
);
Font
font
;
///< Font to use for the text
virtual
int
update
(
Context
&
);
};
// ----------------------------------------------------------------------------- : PackageChoiceValue
/// The Value in a PackageChoiceField
class
PackageChoiceValue
:
public
Value
{
public:
PackageChoiceValue
(
const
PackageChoiceFieldP
&
field
)
:
Value
(
field
),
package_name
(
field
->
initial
)
{}
DECLARE_VALUE_TYPE
(
PackageChoice
,
String
);
ValueType
package_name
;
///< The selected package
/// Get the package (if it is set)
PackagedP
getPackage
()
const
;
virtual
bool
update
(
Context
&
);
};
// ----------------------------------------------------------------------------- : EOF
#endif
src/data/field/symbol.cpp
View file @
b9b1279f
...
@@ -11,11 +11,7 @@
...
@@ -11,11 +11,7 @@
// ----------------------------------------------------------------------------- : SymbolField
// ----------------------------------------------------------------------------- : SymbolField
IMPLEMENT_FIELD_TYPE
(
Symbol
)
IMPLEMENT_FIELD_TYPE
(
Symbol
,
"symbol"
);
String
SymbolField
::
typeName
()
const
{
return
_
(
"symbol"
);
}
IMPLEMENT_REFLECTION
(
SymbolField
)
{
IMPLEMENT_REFLECTION
(
SymbolField
)
{
REFLECT_BASE
(
Field
);
REFLECT_BASE
(
Field
);
...
...
src/data/field/text.cpp
View file @
b9b1279f
...
@@ -17,11 +17,7 @@ TextField::TextField()
...
@@ -17,11 +17,7 @@ TextField::TextField()
,
default_name
(
_
(
"Default"
))
,
default_name
(
_
(
"Default"
))
{}
{}
IMPLEMENT_FIELD_TYPE
(
Text
)
IMPLEMENT_FIELD_TYPE
(
Text
,
"text"
);
String
TextField
::
typeName
()
const
{
return
_
(
"text"
);
}
void
TextField
::
initDependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
{
void
TextField
::
initDependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
{
Field
::
initDependencies
(
ctx
,
dep
);
Field
::
initDependencies
(
ctx
,
dep
);
...
...
src/data/symbol_font.cpp
View file @
b9b1279f
...
@@ -45,7 +45,9 @@ String SymbolFont::typeNameStatic() { return _("symbol-font"); }
...
@@ -45,7 +45,9 @@ String SymbolFont::typeNameStatic() { return _("symbol-font"); }
String
SymbolFont
::
typeName
()
const
{
return
_
(
"symbol-font"
);
}
String
SymbolFont
::
typeName
()
const
{
return
_
(
"symbol-font"
);
}
SymbolFontP
SymbolFont
::
byName
(
const
String
&
name
)
{
SymbolFontP
SymbolFont
::
byName
(
const
String
&
name
)
{
return
packages
.
open
<
SymbolFont
>
(
name
+
_
(
".mse-symbol-font"
));
return
packages
.
open
<
SymbolFont
>
(
name
.
size
()
>
16
&&
is_substr
(
name
,
name
.
size
()
-
16
,
_
(
".mse-symbol-font"
))
?
name
:
name
+
_
(
".mse-symbol-font"
));
}
}
IMPLEMENT_REFLECTION
(
SymbolFont
)
{
IMPLEMENT_REFLECTION
(
SymbolFont
)
{
...
@@ -588,10 +590,14 @@ void SymbolFontRef::loadFont(Context& ctx) {
...
@@ -588,10 +590,14 @@ void SymbolFontRef::loadFont(Context& ctx) {
font
=
SymbolFontP
();
font
=
SymbolFontP
();
}
else
{
}
else
{
font
=
SymbolFont
::
byName
(
name
);
font
=
SymbolFont
::
byName
(
name
);
// ensure the dependency on the font is present in the stylesheet this ref is in
if
(
name
().
GetChar
(
0
)
!=
_
(
' '
))
{
// Getting this stylesheet from the context is a bit of a hack
// ensure the dependency on the font is present in the stylesheet this ref is in
StyleSheetP
stylesheet
=
from_script
<
StyleSheetP
>
(
ctx
.
getVariable
(
_
(
"stylesheet"
)));
// Getting this stylesheet from the context is a bit of a hack
stylesheet
->
requireDependency
(
font
.
get
());
// If the name starts with a ' ', no dependency is needed;
// this is for packages selected with a PackageChoiceList
StyleSheetP
stylesheet
=
from_script
<
StyleSheetP
>
(
ctx
.
getVariable
(
_
(
"stylesheet"
)));
stylesheet
->
requireDependency
(
font
.
get
());
}
}
}
}
}
...
...
src/gui/value/editor.cpp
View file @
b9b1279f
...
@@ -6,29 +6,6 @@
...
@@ -6,29 +6,6 @@
// ----------------------------------------------------------------------------- : Includes
// ----------------------------------------------------------------------------- : Includes
#include <gui/value/editor.hpp>
//#include <gui/value/editor.hpp>
#include <gui/value/text.hpp>
#include <gui/value/choice.hpp>
#include <gui/value/multiple_choice.hpp>
#include <gui/value/image.hpp>
#include <gui/value/symbol.hpp>
#include <gui/value/color.hpp>
#include <gui/value/information.hpp>
// ----------------------------------------------------------------------------- : ValueEditor
// ----------------------------------------------------------------------------- : ValueEditor
// ----------------------------------------------------------------------------- : Type dispatch
#define IMPLEMENT_MAKE_EDITOR(Type) \
ValueViewerP
Type
##
Style
::
makeEditor
(
DataEditor
&
parent
,
const
StyleP
&
thisP
)
{
\
assert
(
thisP
.
get
()
==
this
);
\
return
ValueViewerP
(
new
Type
##
ValueEditor
(
parent
,
static_pointer_cast
<
Type
##
Style
>
(
thisP
)));
\
}
IMPLEMENT_MAKE_EDITOR
(
Text
);
IMPLEMENT_MAKE_EDITOR
(
Choice
);
IMPLEMENT_MAKE_EDITOR
(
MultipleChoice
);
IMPLEMENT_MAKE_EDITOR
(
Color
);
IMPLEMENT_MAKE_EDITOR
(
Image
);
IMPLEMENT_MAKE_EDITOR
(
Symbol
);
IMPLEMENT_MAKE_EDITOR
(
Info
);
src/gui/value/editor.hpp
View file @
b9b1279f
...
@@ -147,6 +147,10 @@ class ValueEditor {
...
@@ -147,6 +147,10 @@ class ValueEditor {
void
Type
##
ValueEditor
::
redraw
()
{
\
void
Type
##
ValueEditor
::
redraw
()
{
\
editor
().
redraw
(
*
this
);
\
editor
().
redraw
(
*
this
);
\
}
\
}
\
ValueViewerP
Type
##
Style
::
makeEditor
(
DataEditor
&
parent
,
const
StyleP
&
thisP
)
{
\
assert
(
thisP
.
get
()
==
this
);
\
return
ValueViewerP
(
new
Type
##
ValueEditor
(
parent
,
static_pointer_cast
<
Type
##
Style
>
(
thisP
)));
\
}
\
Type
##
ValueEditor
::
Type
##
ValueEditor
(
DataEditor
&
parent
,
const
Type
##
StyleP
&
style
)
\
Type
##
ValueEditor
::
Type
##
ValueEditor
(
DataEditor
&
parent
,
const
Type
##
StyleP
&
style
)
\
:
Type
##
ValueViewer
(
parent
,
style
)
:
Type
##
ValueViewer
(
parent
,
style
)
...
...
src/gui/value/package_choice.cpp
0 → 100644
View file @
b9b1279f
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <gui/value/package_choice.hpp>
#include <gui/drop_down_list.hpp>
#include <gui/util.hpp>
#include <data/action/value.hpp>
DECLARE_TYPEOF_COLLECTION
(
PackageChoiceValueViewer
::
Item
);
// ----------------------------------------------------------------------------- : DropDownPackageChoiceList
/// A drop down list of color choices
class
DropDownPackageChoiceList
:
public
DropDownList
{
public:
DropDownPackageChoiceList
(
Window
*
parent
,
PackageChoiceValueEditor
*
editor
);
protected:
virtual
size_t
itemCount
()
const
;
virtual
String
itemText
(
size_t
item
)
const
;
virtual
bool
lineBelow
(
size_t
item
)
const
;
virtual
void
drawIcon
(
DC
&
dc
,
int
x
,
int
y
,
size_t
item
,
bool
selected
)
const
;
virtual
void
select
(
size_t
selection
);
virtual
size_t
selection
()
const
;
private:
PackageChoiceValueEditor
&
editor
;
};
DropDownPackageChoiceList
::
DropDownPackageChoiceList
(
Window
*
parent
,
PackageChoiceValueEditor
*
editor
)
:
DropDownList
(
parent
,
false
,
editor
)
,
editor
(
*
editor
)
{
icon_size
.
width
=
16
;
icon_size
.
height
=
16
;
item_size
.
height
=
max
(
16.
,
item_size
.
height
);
}
size_t
DropDownPackageChoiceList
::
itemCount
()
const
{
return
editor
.
items
.
size
()
+
(
editor
.
field
().
required
?
0
:
1
);
}
String
DropDownPackageChoiceList
::
itemText
(
size_t
item
)
const
{
if
(
item
==
0
&&
!
editor
.
field
().
required
)
return
_
(
""
);
else
{
size_t
i
=
item
-
!
editor
.
field
().
required
;
return
editor
.
items
[
i
].
name
;
}
}
bool
DropDownPackageChoiceList
::
lineBelow
(
size_t
item
)
const
{
return
item
==
0
&&
!
editor
.
field
().
required
;
}
void
DropDownPackageChoiceList
::
drawIcon
(
DC
&
dc
,
int
x
,
int
y
,
size_t
item
,
bool
selected
)
const
{
if
(
item
==
0
&&
!
editor
.
field
().
required
)
return
;
size_t
i
=
item
-
!
editor
.
field
().
required
;
const
Bitmap
&
bmp
=
editor
.
items
[
i
].
image
;
if
(
bmp
.
Ok
())
dc
.
DrawBitmap
(
bmp
,
x
,
y
);
}
void
DropDownPackageChoiceList
::
select
(
size_t
item
)
{
String
new_value
;
if
(
item
!=
0
||
editor
.
field
().
required
)
{
size_t
i
=
item
-
!
editor
.
field
().
required
;
new_value
=
editor
.
items
[
i
].
package_name
;
}
editor
.
change
(
new_value
);
}
size_t
DropDownPackageChoiceList
::
selection
()
const
{
size_t
n
=
0
;
FOR_EACH
(
i
,
editor
.
items
)
{
if
(
editor
.
value
().
package_name
==
i
.
package_name
)
{
return
n
+
!
editor
.
field
().
required
;
}
++
n
;
}
return
editor
.
field
().
required
?
NO_SELECTION
:
0
;
}
// ----------------------------------------------------------------------------- : PackageChoiceValueEditor
IMPLEMENT_VALUE_EDITOR
(
PackageChoice
)
{}
bool
PackageChoiceValueEditor
::
onLeftDown
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
)
{
if
(
!
drop_down
)
initDropDown
();
return
drop_down
->
onMouseInParent
(
ev
,
false
);
}
bool
PackageChoiceValueEditor
::
onChar
(
wxKeyEvent
&
ev
)
{
if
(
!
drop_down
)
initDropDown
();
return
drop_down
->
onCharInParent
(
ev
);
}
void
PackageChoiceValueEditor
::
onLoseFocus
()
{
if
(
drop_down
)
drop_down
->
hide
(
false
);
}
void
PackageChoiceValueEditor
::
draw
(
RotatedDC
&
dc
)
{
PackageChoiceValueViewer
::
draw
(
dc
);
if
(
nativeLook
())
{
draw_drop_down_arrow
(
&
editor
(),
dc
.
getDC
(),
dc
.
trRectStraight
(
style
().
getInternalRect
().
grow
(
1
)),
drop_down
&&
drop_down
->
IsShown
());
}
}
void
PackageChoiceValueEditor
::
determineSize
(
bool
)
{
style
().
height
=
max
(
style
().
height
(),
16.
);
}
void
PackageChoiceValueEditor
::
change
(
const
String
&
c
)
{
perform
(
value_action
(
card
(),
valueP
(),
c
));
}
void
PackageChoiceValueEditor
::
initDropDown
()
{
if
(
drop_down
)
return
;
drop_down
=
new_shared2
<
DropDownPackageChoiceList
>
(
&
editor
(),
this
);
}
\ No newline at end of file
src/gui/value/package_choice.hpp
0 → 100644
View file @
b9b1279f
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_GUI_VALUE_PACKAGE_CHOICE
#define HEADER_GUI_VALUE_PACKAGE_CHOICE
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <gui/value/editor.hpp>
#include <render/value/package_choice.hpp>
DECLARE_SHARED_POINTER_TYPE
(
DropDownList
);
// ----------------------------------------------------------------------------- : PackageChoiceValueEditor
/// An editor 'control' for editing PackageChoiceValues
class
PackageChoiceValueEditor
:
public
PackageChoiceValueViewer
,
public
ValueEditor
{
public:
DECLARE_VALUE_EDITOR
(
PackageChoice
);
virtual
void
draw
(
RotatedDC
&
dc
);
virtual
void
determineSize
(
bool
force_fit
);
virtual
bool
onLeftDown
(
const
RealPoint
&
pos
,
wxMouseEvent
&
ev
);
virtual
bool
onChar
(
wxKeyEvent
&
ev
);
virtual
void
onLoseFocus
();
private:
DropDownListP
drop_down
;
friend
class
DropDownPackageChoiceList
;
/// Change the choice
void
change
(
const
String
&
c
);
/// Initialize the drop down list
void
initDropDown
();
};
// ----------------------------------------------------------------------------- : EOF
#endif
src/mse.vcproj
View file @
b9b1279f
...
@@ -1261,6 +1261,54 @@
...
@@ -1261,6 +1261,54 @@
<File
<File
RelativePath=
".\gui\value\multiple_choice.hpp"
>
RelativePath=
".\gui\value\multiple_choice.hpp"
>
</File>
</File>
<File
RelativePath=
".\gui\value\package_choice.cpp"
>
<FileConfiguration
Name=
"Debug|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)2.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)2.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Debug Unicode|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)2.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release Unicode|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)2.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release Profile Unicode|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)2.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release Unicode fast build|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)2.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Debug Unicode NoInit|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)2.obj"
/>
</FileConfiguration>
</File>
<File
RelativePath=
".\gui\value\package_choice.hpp"
>
</File>
<File
<File
RelativePath=
".\gui\value\symbol.cpp"
>
RelativePath=
".\gui\value\symbol.cpp"
>
<FileConfiguration
<FileConfiguration
...
@@ -1744,6 +1792,12 @@
...
@@ -1744,6 +1792,12 @@
<File
<File
RelativePath=
".\data\field\multiple_choice.hpp"
>
RelativePath=
".\data\field\multiple_choice.hpp"
>
</File>
</File>
<File
RelativePath=
".\data\field\package_choice.cpp"
>
</File>
<File
RelativePath=
".\data\field\package_choice.hpp"
>
</File>
<File
<File
RelativePath=
".\data\field\symbol.cpp"
>
RelativePath=
".\data\field\symbol.cpp"
>
<FileConfiguration
<FileConfiguration
...
@@ -2914,6 +2968,54 @@
...
@@ -2914,6 +2968,54 @@
<File
<File
RelativePath=
".\render\value\multiple_choice.hpp"
>
RelativePath=
".\render\value\multiple_choice.hpp"
>
</File>
</File>
<File
RelativePath=
".\render\value\package_choice.cpp"
>
<FileConfiguration
Name=
"Debug|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Debug Unicode|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release Unicode|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release Profile Unicode|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Release Unicode fast build|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
<FileConfiguration
Name=
"Debug Unicode NoInit|Win32"
>
<Tool
Name=
"VCCLCompilerTool"
ObjectFile=
"$(IntDir)/$(InputName)1.obj"
/>
</FileConfiguration>
</File>
<File
RelativePath=
".\render\value\package_choice.hpp"
>
</File>
<File
<File
RelativePath=
".\render\value\symbol.cpp"
>
RelativePath=
".\render\value\symbol.cpp"
>
<FileConfiguration
<FileConfiguration
...
...
src/render/value/choice.cpp
View file @
b9b1279f
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
// ----------------------------------------------------------------------------- : ChoiceValueViewer
// ----------------------------------------------------------------------------- : ChoiceValueViewer
IMPLEMENT_VALUE_VIEWER
(
Choice
);
void
get_options
(
Rotation
&
rot
,
DataViewer
&
viewer
,
const
ChoiceStyle
&
style
,
GeneratedImage
::
Options
&
opts
);
void
get_options
(
Rotation
&
rot
,
DataViewer
&
viewer
,
const
ChoiceStyle
&
style
,
GeneratedImage
::
Options
&
opts
);
bool
ChoiceValueViewer
::
prepare
(
RotatedDC
&
dc
)
{
bool
ChoiceValueViewer
::
prepare
(
RotatedDC
&
dc
)
{
...
@@ -108,4 +110,4 @@ void get_options(Rotation& rot, DataViewer& viewer, const ChoiceStyle& style, Ge
...
@@ -108,4 +110,4 @@ void get_options(Rotation& rot, DataViewer& viewer, const ChoiceStyle& style, Ge
void
ChoiceValueViewer
::
onStyleChange
(
int
changes
)
{
void
ChoiceValueViewer
::
onStyleChange
(
int
changes
)
{
if
(
changes
&
CHANGE_MASK
)
style
().
image
.
clearCache
();
if
(
changes
&
CHANGE_MASK
)
style
().
image
.
clearCache
();
ValueViewer
::
onStyleChange
(
changes
);
ValueViewer
::
onStyleChange
(
changes
);
}
}
\ No newline at end of file
src/render/value/color.cpp
View file @
b9b1279f
...
@@ -14,6 +14,8 @@ DECLARE_TYPEOF_COLLECTION(ColorField::ChoiceP);
...
@@ -14,6 +14,8 @@ DECLARE_TYPEOF_COLLECTION(ColorField::ChoiceP);
// ----------------------------------------------------------------------------- : ColorValueViewer
// ----------------------------------------------------------------------------- : ColorValueViewer
IMPLEMENT_VALUE_VIEWER
(
Color
);
void
ColorValueViewer
::
draw
(
RotatedDC
&
dc
)
{
void
ColorValueViewer
::
draw
(
RotatedDC
&
dc
)
{
// draw in the value color
// draw in the value color
dc
.
SetPen
(
*
wxTRANSPARENT_PEN
);
dc
.
SetPen
(
*
wxTRANSPARENT_PEN
);
...
...
src/render/value/image.cpp
View file @
b9b1279f
...
@@ -16,6 +16,8 @@ DECLARE_TYPEOF_COLLECTION(wxPoint);
...
@@ -16,6 +16,8 @@ DECLARE_TYPEOF_COLLECTION(wxPoint);
// ----------------------------------------------------------------------------- : ImageValueViewer
// ----------------------------------------------------------------------------- : ImageValueViewer
IMPLEMENT_VALUE_VIEWER
(
Image
);
void
ImageValueViewer
::
draw
(
RotatedDC
&
dc
)
{
void
ImageValueViewer
::
draw
(
RotatedDC
&
dc
)
{
// reset?
// reset?
int
w
=
(
int
)
dc
.
trX
(
style
().
width
),
h
=
(
int
)
dc
.
trY
(
style
().
height
);
int
w
=
(
int
)
dc
.
trX
(
style
().
width
),
h
=
(
int
)
dc
.
trY
(
style
().
height
);
...
...
src/render/value/information.cpp
View file @
b9b1279f
...
@@ -11,6 +11,8 @@
...
@@ -11,6 +11,8 @@
// ----------------------------------------------------------------------------- : InfoValueViewer
// ----------------------------------------------------------------------------- : InfoValueViewer
IMPLEMENT_VALUE_VIEWER
(
Info
);
void
InfoValueViewer
::
draw
(
RotatedDC
&
dc
)
{
void
InfoValueViewer
::
draw
(
RotatedDC
&
dc
)
{
dc
.
SetPen
(
*
wxTRANSPARENT_PEN
);
dc
.
SetPen
(
*
wxTRANSPARENT_PEN
);
if
(
nativeLook
())
{
if
(
nativeLook
())
{
...
...
src/render/value/multiple_choice.cpp
View file @
b9b1279f
...
@@ -16,6 +16,8 @@ DECLARE_TYPEOF_COLLECTION(String);
...
@@ -16,6 +16,8 @@ DECLARE_TYPEOF_COLLECTION(String);
// ----------------------------------------------------------------------------- : MultipleChoiceValueViewer
// ----------------------------------------------------------------------------- : MultipleChoiceValueViewer
IMPLEMENT_VALUE_VIEWER
(
MultipleChoice
);
bool
MultipleChoiceValueViewer
::
prepare
(
RotatedDC
&
dc
)
{
bool
MultipleChoiceValueViewer
::
prepare
(
RotatedDC
&
dc
)
{
if
(
style
().
render_style
&
(
RENDER_CHECKLIST
|
RENDER_LIST
))
return
false
;
if
(
style
().
render_style
&
(
RENDER_CHECKLIST
|
RENDER_LIST
))
return
false
;
return
prepare_choice_viewer
(
dc
,
viewer
,
style
(),
value
().
value
());
return
prepare_choice_viewer
(
dc
,
viewer
,
style
(),
value
().
value
());
...
...
src/render/value/package_choice.cpp
0 → 100644
View file @
b9b1279f
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
// ----------------------------------------------------------------------------- : Includes
#include <render/value/package_choice.hpp>
#include <util/io/package_manager.hpp>
DECLARE_TYPEOF_COLLECTION
(
PackagedP
);
DECLARE_TYPEOF_COLLECTION
(
PackageChoiceValueViewer
::
Item
);
// ----------------------------------------------------------------------------- : PackageChoiceValueViewer
IMPLEMENT_VALUE_VIEWER
(
PackageChoice
);
struct
PackageChoiceValueViewer
::
ComparePackagePosHint
{
bool
operator
()
(
const
PackagedP
&
a
,
const
PackagedP
&
b
)
{
// use position_hints to determine order
if
(
a
->
position_hint
<
b
->
position_hint
)
return
true
;
if
(
a
->
position_hint
>
b
->
position_hint
)
return
false
;
// ensure a deterministic order: use the names
return
a
->
name
()
<
b
->
name
();
}
};
void
PackageChoiceValueViewer
::
initItems
()
{
vector
<
PackagedP
>
choices
;
packages
.
findMatching
(
field
().
match
,
choices
);
sort
(
choices
.
begin
(),
choices
.
end
(),
ComparePackagePosHint
());
FOR_EACH
(
p
,
choices
)
{
Item
i
;
i
.
package_name
=
p
->
relativeFilename
();
i
.
name
=
capitalize_sentence
(
p
->
short_name
);
Image
image
;
InputStreamP
stream
=
p
->
openIconFile
();
if
(
stream
&&
image
.
LoadFile
(
*
stream
))
{
Image
resampled
(
16
,
16
,
false
);
resample
(
image
,
resampled
);
i
.
image
=
Bitmap
(
resampled
);
}
items
.
push_back
(
i
);
}
}
void
PackageChoiceValueViewer
::
draw
(
RotatedDC
&
dc
)
{
drawFieldBorder
(
dc
);
// find item
FOR_EACH
(
i
,
items
)
{
if
(
i
.
package_name
!=
value
().
package_name
)
continue
;
// draw image
if
(
i
.
image
.
Ok
())
{
dc
.
DrawBitmap
(
i
.
image
,
RealPoint
(
0
,
0
));
}
// draw text
dc
.
SetFont
(
style
().
font
,
1.0
);
RealPoint
pos
=
align_in_rect
(
ALIGN_MIDDLE_LEFT
,
RealSize
(
0
,
dc
.
GetCharHeight
()),
dc
.
getInternalRect
())
+
RealSize
(
17.
,
0
);
dc
.
DrawTextWithShadow
(
i
.
name
,
style
().
font
,
pos
);
}
}
src/render/value/package_choice.hpp
0 → 100644
View file @
b9b1279f
//+----------------------------------------------------------------------------+
//| Description: Magic Set Editor - Program to make Magic (tm) cards |
//| Copyright: (C) 2001 - 2007 Twan van Laarhoven |
//| License: GNU General Public License 2 or later (see file COPYING) |
//+----------------------------------------------------------------------------+
#ifndef HEADER_RENDER_VALUE_PACKAGE_CHOICE
#define HEADER_RENDER_VALUE_PACKAGE_CHOICE
// ----------------------------------------------------------------------------- : Includes
#include <util/prec.hpp>
#include <render/value/viewer.hpp>
#include <data/field/package_choice.hpp>
// ----------------------------------------------------------------------------- : PackageChoiceValueViewer
/// Viewer that displays a package choice value
class
PackageChoiceValueViewer
:
public
ValueViewer
{
public:
DECLARE_VALUE_VIEWER
(
PackageChoice
)
:
ValueViewer
(
parent
,
style
)
{
initItems
();
}
virtual
void
draw
(
RotatedDC
&
dc
);
struct
Item
{
String
package_name
;
String
name
;
Bitmap
image
;
};
protected:
vector
<
Item
>
items
;
private:
void
initItems
();
struct
ComparePackagePosHint
;
};
// ----------------------------------------------------------------------------- : EOF
#endif
src/render/value/symbol.cpp
View file @
b9b1279f
...
@@ -17,6 +17,8 @@ DECLARE_TYPEOF_COLLECTION(SymbolVariationP);
...
@@ -17,6 +17,8 @@ DECLARE_TYPEOF_COLLECTION(SymbolVariationP);
// ----------------------------------------------------------------------------- : SymbolValueViewer
// ----------------------------------------------------------------------------- : SymbolValueViewer
IMPLEMENT_VALUE_VIEWER
(
Symbol
);
void
SymbolValueViewer
::
draw
(
RotatedDC
&
dc
)
{
void
SymbolValueViewer
::
draw
(
RotatedDC
&
dc
)
{
drawFieldBorder
(
dc
);
drawFieldBorder
(
dc
);
// draw checker background
// draw checker background
...
...
src/render/value/text.cpp
View file @
b9b1279f
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
// ----------------------------------------------------------------------------- : TextValueViewer
// ----------------------------------------------------------------------------- : TextValueViewer
IMPLEMENT_VALUE_VIEWER
(
Text
);
bool
TextValueViewer
::
prepare
(
RotatedDC
&
dc
)
{
bool
TextValueViewer
::
prepare
(
RotatedDC
&
dc
)
{
if
(
!
style
().
mask_filename
.
empty
()
&&
!
style
().
mask
.
ok
())
{
if
(
!
style
().
mask_filename
.
empty
()
&&
!
style
().
mask
.
ok
())
{
// load contour mask
// load contour mask
...
...
src/render/value/viewer.cpp
View file @
b9b1279f
...
@@ -7,13 +7,6 @@
...
@@ -7,13 +7,6 @@
// ----------------------------------------------------------------------------- : Includes
// ----------------------------------------------------------------------------- : Includes
#include <render/value/viewer.hpp>
#include <render/value/viewer.hpp>
#include <render/value/text.hpp>
#include <render/value/choice.hpp>
#include <render/value/multiple_choice.hpp>
#include <render/value/image.hpp>
#include <render/value/symbol.hpp>
#include <render/value/color.hpp>
#include <render/value/information.hpp>
#include <render/card/viewer.hpp>
#include <render/card/viewer.hpp>
// ----------------------------------------------------------------------------- : ValueViewer
// ----------------------------------------------------------------------------- : ValueViewer
...
@@ -65,19 +58,3 @@ void ValueViewer::onStyleChange(int changes) {
...
@@ -65,19 +58,3 @@ void ValueViewer::onStyleChange(int changes) {
viewer
.
redraw
(
*
this
);
viewer
.
redraw
(
*
this
);
}
}
}
}
// ----------------------------------------------------------------------------- : Type dispatch
#define IMPLEMENT_MAKE_VIEWER(Type) \
ValueViewerP
Type
##
Style
::
makeViewer
(
DataViewer
&
parent
,
const
StyleP
&
thisP
)
{
\
assert
(
thisP
.
get
()
==
this
);
\
return
ValueViewerP
(
new
Type
##
ValueViewer
(
parent
,
static_pointer_cast
<
Type
##
Style
>
(
thisP
)));
\
}
IMPLEMENT_MAKE_VIEWER
(
Text
);
IMPLEMENT_MAKE_VIEWER
(
Choice
);
IMPLEMENT_MAKE_VIEWER
(
MultipleChoice
);
IMPLEMENT_MAKE_VIEWER
(
Color
);
IMPLEMENT_MAKE_VIEWER
(
Image
);
IMPLEMENT_MAKE_VIEWER
(
Symbol
);
IMPLEMENT_MAKE_VIEWER
(
Info
);
src/render/value/viewer.hpp
View file @
b9b1279f
...
@@ -99,6 +99,12 @@ class ValueViewer : public StyleListener {
...
@@ -99,6 +99,12 @@ class ValueViewer : public StyleListener {
public
:
\
public
:
\
Type
##
ValueViewer
(
DataViewer
&
parent
,
const
Type
##
StyleP
&
style
)
Type
##
ValueViewer
(
DataViewer
&
parent
,
const
Type
##
StyleP
&
style
)
#define IMPLEMENT_VALUE_VIEWER(Type) \
ValueViewerP
Type
##
Style
::
makeViewer
(
DataViewer
&
parent
,
const
StyleP
&
thisP
)
{
\
assert
(
thisP
.
get
()
==
this
);
\
return
ValueViewerP
(
new
Type
##
ValueViewer
(
parent
,
static_pointer_cast
<
Type
##
Style
>
(
thisP
)));
\
}
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
#endif
#endif
src/util/string.cpp
View file @
b9b1279f
...
@@ -72,6 +72,8 @@ String trim(const String& s){
...
@@ -72,6 +72,8 @@ String trim(const String& s){
size_t
end
=
s
.
find_last_not_of
(
_
(
"
\t
"
));
size_t
end
=
s
.
find_last_not_of
(
_
(
"
\t
"
));
if
(
start
==
String
::
npos
)
{
if
(
start
==
String
::
npos
)
{
return
String
();
return
String
();
}
else
if
(
start
==
0
&&
end
==
s
.
size
()
-
1
)
{
return
s
;
}
else
{
}
else
{
return
s
.
substr
(
start
,
end
-
start
+
1
);
return
s
.
substr
(
start
,
end
-
start
+
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