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
eca74a16
Commit
eca74a16
authored
Jun 24, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added clone() function to Value.
Added support for per-card styling
parent
fa4d91f2
Changes
25
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
147 additions
and
21 deletions
+147
-21
src/data/action/set.cpp
src/data/action/set.cpp
+24
-2
src/data/action/set.hpp
src/data/action/set.hpp
+21
-2
src/data/card.cpp
src/data/card.cpp
+16
-2
src/data/card.hpp
src/data/card.hpp
+5
-0
src/data/field.hpp
src/data/field.hpp
+6
-0
src/data/field/boolean.hpp
src/data/field/boolean.hpp
+1
-0
src/data/field/choice.hpp
src/data/field/choice.hpp
+1
-0
src/data/field/color.hpp
src/data/field/color.hpp
+1
-0
src/data/field/image.hpp
src/data/field/image.hpp
+1
-0
src/data/field/information.hpp
src/data/field/information.hpp
+1
-0
src/data/field/multiple_choice.hpp
src/data/field/multiple_choice.hpp
+1
-0
src/data/field/symbol.hpp
src/data/field/symbol.hpp
+1
-0
src/data/field/text.hpp
src/data/field/text.hpp
+1
-0
src/data/set.cpp
src/data/set.cpp
+9
-6
src/data/set.hpp
src/data/set.hpp
+2
-0
src/data/stylesheet.cpp
src/data/stylesheet.cpp
+2
-0
src/data/stylesheet.hpp
src/data/stylesheet.hpp
+3
-0
src/gui/control/native_look_editor.cpp
src/gui/control/native_look_editor.cpp
+5
-0
src/gui/control/native_look_editor.hpp
src/gui/control/native_look_editor.hpp
+3
-1
src/gui/set/style_panel.cpp
src/gui/set/style_panel.cpp
+24
-7
src/gui/set/style_panel.hpp
src/gui/set/style_panel.hpp
+2
-0
src/script/script_manager.cpp
src/script/script_manager.cpp
+4
-1
src/util/index_map.hpp
src/util/index_map.hpp
+9
-0
src/util/locale.hpp
src/util/locale.hpp
+3
-0
src/util/window_id.hpp
src/util/window_id.hpp
+1
-0
No files found.
src/data/action/set.cpp
View file @
eca74a16
...
@@ -12,6 +12,8 @@
...
@@ -12,6 +12,8 @@
#include <data/stylesheet.hpp>
#include <data/stylesheet.hpp>
#include <util/error.hpp>
#include <util/error.hpp>
DECLARE_TYPEOF_COLLECTION
(
IndexMap
<
FieldP
COMMA
ValueP
>
);
// ----------------------------------------------------------------------------- : Add card
// ----------------------------------------------------------------------------- : Add card
AddCardAction
::
AddCardAction
(
Set
&
set
)
AddCardAction
::
AddCardAction
(
Set
&
set
)
...
@@ -91,13 +93,15 @@ void DisplayChangeAction::perform(bool to_undo) {
...
@@ -91,13 +93,15 @@ void DisplayChangeAction::perform(bool to_undo) {
ChangeCardStyleAction
::
ChangeCardStyleAction
(
const
CardP
&
card
,
const
StyleSheetP
&
stylesheet
)
ChangeCardStyleAction
::
ChangeCardStyleAction
(
const
CardP
&
card
,
const
StyleSheetP
&
stylesheet
)
:
card
(
card
),
stylesheet
(
stylesheet
)
:
card
(
card
),
stylesheet
(
stylesheet
)
,
has_styling
(
false
)
// styling_data(empty)
{}
{}
String
ChangeCardStyleAction
::
getName
(
bool
to_undo
)
const
{
String
ChangeCardStyleAction
::
getName
(
bool
to_undo
)
const
{
return
_
(
"Change style"
);
return
_
(
"Change style"
);
}
}
void
ChangeCardStyleAction
::
perform
(
bool
to_undo
)
{
void
ChangeCardStyleAction
::
perform
(
bool
to_undo
)
{
swap
(
card
->
stylesheet
,
stylesheet
);
swap
(
card
->
stylesheet
,
stylesheet
);
swap
(
card
->
has_styling
,
has_styling
);
swap
(
card
->
styling_data
,
styling_data
);
}
}
...
@@ -117,3 +121,21 @@ void ChangeSetStyleAction::perform(bool to_undo) {
...
@@ -117,3 +121,21 @@ void ChangeSetStyleAction::perform(bool to_undo) {
set
.
stylesheet
=
stylesheet
;
set
.
stylesheet
=
stylesheet
;
}
}
}
}
ChangeCardHasStylingAction
::
ChangeCardHasStylingAction
(
Set
&
set
,
const
CardP
&
card
)
:
set
(
set
),
card
(
card
)
{
if
(
!
card
->
has_styling
)
{
// copy of the set's styling data
styling_data
.
cloneFrom
(
set
.
stylingDataFor
(
set
.
stylesheetFor
(
card
))
);
}
else
{
// the new styling data is empty
}
}
String
ChangeCardHasStylingAction
::
getName
(
bool
to_undo
)
const
{
return
_
(
"Use custom style"
);
}
void
ChangeCardHasStylingAction
::
perform
(
bool
to_undo
)
{
card
->
has_styling
=
!
card
->
has_styling
;
swap
(
card
->
styling_data
,
styling_data
);
}
src/data/action/set.hpp
View file @
eca74a16
...
@@ -20,6 +20,8 @@
...
@@ -20,6 +20,8 @@
class
Set
;
class
Set
;
DECLARE_POINTER_TYPE
(
Card
);
DECLARE_POINTER_TYPE
(
Card
);
DECLARE_POINTER_TYPE
(
StyleSheet
);
DECLARE_POINTER_TYPE
(
StyleSheet
);
DECLARE_POINTER_TYPE
(
Field
);
DECLARE_POINTER_TYPE
(
Value
);
// ----------------------------------------------------------------------------- : Add card
// ----------------------------------------------------------------------------- : Add card
...
@@ -93,8 +95,10 @@ class ChangeCardStyleAction : public DisplayChangeAction {
...
@@ -93,8 +95,10 @@ class ChangeCardStyleAction : public DisplayChangeAction {
virtual
void
perform
(
bool
to_undo
);
virtual
void
perform
(
bool
to_undo
);
//private:
//private:
CardP
card
;
///< The affected card
CardP
card
;
///< The affected card
StyleSheetP
stylesheet
;
///< Its new stylesheet
StyleSheetP
stylesheet
;
///< Its old stylesheet
bool
has_styling
;
///< Its old has_styling
IndexMap
<
FieldP
,
ValueP
>
styling_data
;
///< Its old styling data
};
};
/// Changing the style of a set to that of a card
/// Changing the style of a set to that of a card
...
@@ -111,5 +115,20 @@ class ChangeSetStyleAction : public DisplayChangeAction {
...
@@ -111,5 +115,20 @@ class ChangeSetStyleAction : public DisplayChangeAction {
StyleSheetP
stylesheet
;
///< The old stylesheet of the set
StyleSheetP
stylesheet
;
///< The old stylesheet of the set
};
};
/// Changing the styling of a card to become custom/non-custom
/** i.e. toggle card->has_styling */
class
ChangeCardHasStylingAction
:
public
DisplayChangeAction
{
public:
ChangeCardHasStylingAction
(
Set
&
set
,
const
CardP
&
card
);
virtual
String
getName
(
bool
to_undo
)
const
;
virtual
void
perform
(
bool
to_undo
);
//private:
Set
&
set
;
///< The set to copy styling from
CardP
card
;
///< The affected card
IndexMap
<
FieldP
,
ValueP
>
styling_data
;
///< The old styling of the card
};
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
#endif
#endif
src/data/card.cpp
View file @
eca74a16
...
@@ -19,14 +19,18 @@ DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA ValueP>);
...
@@ -19,14 +19,18 @@ DECLARE_TYPEOF_NO_REV(IndexMap<FieldP COMMA ValueP>);
// ----------------------------------------------------------------------------- : Card
// ----------------------------------------------------------------------------- : Card
Card
::
Card
()
{
Card
::
Card
()
:
has_styling
(
false
)
{
if
(
!
game_for_reading
())
{
if
(
!
game_for_reading
())
{
throw
InternalError
(
_
(
"game_for_reading not set"
));
throw
InternalError
(
_
(
"game_for_reading not set"
));
}
}
data
.
init
(
game_for_reading
()
->
card_fields
);
data
.
init
(
game_for_reading
()
->
card_fields
);
}
}
Card
::
Card
(
const
Game
&
game
)
{
Card
::
Card
(
const
Game
&
game
)
:
has_styling
(
false
)
{
data
.
init
(
game
.
card_fields
);
data
.
init
(
game
.
card_fields
);
}
}
...
@@ -55,6 +59,16 @@ void mark_dependency_member(const Card& card, const String& name, const Dependen
...
@@ -55,6 +59,16 @@ void mark_dependency_member(const Card& card, const String& name, const Dependen
IMPLEMENT_REFLECTION
(
Card
)
{
IMPLEMENT_REFLECTION
(
Card
)
{
REFLECT
(
stylesheet
);
REFLECT
(
stylesheet
);
REFLECT
(
has_styling
);
if
(
has_styling
)
{
if
(
stylesheet
)
{
REFLECT_IF_READING
styling_data
.
init
(
stylesheet
->
styling_fields
);
REFLECT
(
styling_data
);
}
else
if
(
stylesheet_for_reading
())
{
REFLECT_IF_READING
styling_data
.
init
(
stylesheet_for_reading
()
->
styling_fields
);
REFLECT
(
styling_data
);
}
}
REFLECT
(
notes
);
REFLECT
(
notes
);
REFLECT_NO_SCRIPT
(
extra_data
);
// don't allow scripts to depend on style specific data
REFLECT_NO_SCRIPT
(
extra_data
);
// don't allow scripts to depend on style specific data
REFLECT_NAMELESS
(
data
);
REFLECT_NAMELESS
(
data
);
...
...
src/data/card.hpp
View file @
eca74a16
...
@@ -39,6 +39,11 @@ class Card : public IntrusivePtrVirtualBase {
...
@@ -39,6 +39,11 @@ class Card : public IntrusivePtrVirtualBase {
/// Alternative style to use for this card
/// Alternative style to use for this card
/** Optional; if not set use the card style from the set */
/** Optional; if not set use the card style from the set */
StyleSheetP
stylesheet
;
StyleSheetP
stylesheet
;
/// Alternative options to use for this card, for this card's stylesheet
/** Optional; if not set use the styling data from the set */
IndexMap
<
FieldP
,
ValueP
>
styling_data
;
/// Is the styling_data set?
bool
has_styling
;
/// Extra values for specitic stylesheets, indexed by stylesheet name
/// Extra values for specitic stylesheets, indexed by stylesheet name
DelayedIndexMaps
<
FieldP
,
ValueP
>
extra_data
;
DelayedIndexMaps
<
FieldP
,
ValueP
>
extra_data
;
...
...
src/data/field.hpp
View file @
eca74a16
...
@@ -172,6 +172,9 @@ class Value : public IntrusivePtrVirtualBase {
...
@@ -172,6 +172,9 @@ class Value : public IntrusivePtrVirtualBase {
const
FieldP
fieldP
;
///< Field this value is for, should have the right type!
const
FieldP
fieldP
;
///< Field this value is for, should have the right type!
Age
last_script_update
;
///< When where the scripts last updated? (by calling update)
Age
last_script_update
;
///< When where the scripts last updated? (by calling update)
/// Get a copy of this value
virtual
ValueP
clone
()
const
=
0
;
/// Convert this value to a string for use in tables
/// Convert this value to a string for use in tables
virtual
String
toString
()
const
=
0
;
virtual
String
toString
()
const
=
0
;
/// Apply scripts to this value, return true if the value has changed
/// Apply scripts to this value, return true if the value has changed
...
@@ -213,6 +216,9 @@ template <> ValueP read_new<Value>(Reader&);
...
@@ -213,6 +216,9 @@ template <> ValueP read_new<Value>(Reader&);
}
\
}
\
StyleP
Type
##
Style
::
clone
()
const
{
\
StyleP
Type
##
Style
::
clone
()
const
{
\
return
new_intrusive1
<
Type
##
Style
>
(
*
this
);
\
return
new_intrusive1
<
Type
##
Style
>
(
*
this
);
\
}
\
ValueP
Type
##
Value
::
clone
()
const
{
\
return
new_intrusive1
<
Type
##
Value
>
(
*
this
);
\
}
}
#define DECLARE_STYLE_TYPE(Type) \
#define DECLARE_STYLE_TYPE(Type) \
...
...
src/data/field/boolean.hpp
View file @
eca74a16
...
@@ -52,6 +52,7 @@ class BooleanValue : public ChoiceValue {
...
@@ -52,6 +52,7 @@ class BooleanValue : public ChoiceValue {
public:
public:
inline
BooleanValue
(
const
ChoiceFieldP
&
field
)
:
ChoiceValue
(
field
)
{}
inline
BooleanValue
(
const
ChoiceFieldP
&
field
)
:
ChoiceValue
(
field
)
{}
DECLARE_HAS_FIELD
(
Boolean
);
DECLARE_HAS_FIELD
(
Boolean
);
virtual
ValueP
clone
()
const
;
// no extra data
// no extra data
...
...
src/data/field/choice.hpp
View file @
eca74a16
...
@@ -177,6 +177,7 @@ class ChoiceValue : public Value {
...
@@ -177,6 +177,7 @@ class ChoiceValue : public Value {
typedef
Defaultable
<
String
>
ValueType
;
typedef
Defaultable
<
String
>
ValueType
;
ValueType
value
;
/// The name of the selected choice
ValueType
value
;
/// The name of the selected choice
virtual
ValueP
clone
()
const
;
virtual
String
toString
()
const
;
virtual
String
toString
()
const
;
virtual
bool
update
(
Context
&
);
virtual
bool
update
(
Context
&
);
...
...
src/data/field/color.hpp
View file @
eca74a16
...
@@ -83,6 +83,7 @@ class ColorValue : public Value {
...
@@ -83,6 +83,7 @@ class ColorValue : public Value {
typedef
Defaultable
<
Color
>
ValueType
;
typedef
Defaultable
<
Color
>
ValueType
;
ValueType
value
;
///< The value
ValueType
value
;
///< The value
virtual
ValueP
clone
()
const
;
virtual
String
toString
()
const
;
virtual
String
toString
()
const
;
virtual
bool
update
(
Context
&
);
virtual
bool
update
(
Context
&
);
...
...
src/data/field/image.hpp
View file @
eca74a16
...
@@ -58,6 +58,7 @@ class ImageValue : public Value {
...
@@ -58,6 +58,7 @@ class ImageValue : public Value {
ValueType
filename
;
///< Filename of the image (in the current package), or ""
ValueType
filename
;
///< Filename of the image (in the current package), or ""
Age
last_update
;
///< When was the image last changed?
Age
last_update
;
///< When was the image last changed?
virtual
ValueP
clone
()
const
;
virtual
String
toString
()
const
;
virtual
String
toString
()
const
;
private:
private:
...
...
src/data/field/information.hpp
View file @
eca74a16
...
@@ -68,6 +68,7 @@ class InfoValue : public Value {
...
@@ -68,6 +68,7 @@ class InfoValue : public Value {
String
value
;
String
value
;
virtual
ValueP
clone
()
const
;
virtual
String
toString
()
const
;
virtual
String
toString
()
const
;
virtual
bool
update
(
Context
&
);
virtual
bool
update
(
Context
&
);
...
...
src/data/field/multiple_choice.hpp
View file @
eca74a16
...
@@ -56,6 +56,7 @@ class MultipleChoiceValue : public ChoiceValue {
...
@@ -56,6 +56,7 @@ class MultipleChoiceValue : public ChoiceValue {
public:
public:
inline
MultipleChoiceValue
(
const
MultipleChoiceFieldP
&
field
)
:
ChoiceValue
(
field
,
false
)
{}
inline
MultipleChoiceValue
(
const
MultipleChoiceFieldP
&
field
)
:
ChoiceValue
(
field
,
false
)
{}
DECLARE_HAS_FIELD
(
MultipleChoice
);
DECLARE_HAS_FIELD
(
MultipleChoice
);
virtual
ValueP
clone
()
const
;
String
last_change
;
///< Which of the choices was selected/deselected last?
String
last_change
;
///< Which of the choices was selected/deselected last?
...
...
src/data/field/symbol.hpp
View file @
eca74a16
...
@@ -69,6 +69,7 @@ class SymbolValue : public Value {
...
@@ -69,6 +69,7 @@ class SymbolValue : public Value {
ValueType
filename
;
///< Filename of the symbol (in the current package)
ValueType
filename
;
///< Filename of the symbol (in the current package)
Age
last_update
;
///< When was the symbol last changed?
Age
last_update
;
///< When was the symbol last changed?
virtual
ValueP
clone
()
const
;
virtual
String
toString
()
const
;
virtual
String
toString
()
const
;
private:
private:
...
...
src/data/field/text.hpp
View file @
eca74a16
...
@@ -110,6 +110,7 @@ class TextValue : public Value {
...
@@ -110,6 +110,7 @@ class TextValue : public Value {
ValueType
value
;
///< The text of this value
ValueType
value
;
///< The text of this value
Age
last_update
;
///< When was the text last changed?
Age
last_update
;
///< When was the text last changed?
virtual
ValueP
clone
()
const
;
virtual
String
toString
()
const
;
virtual
String
toString
()
const
;
virtual
bool
update
(
Context
&
);
virtual
bool
update
(
Context
&
);
...
...
src/data/set.cpp
View file @
eca74a16
...
@@ -91,6 +91,14 @@ StyleSheetP Set::stylesheetForP(const CardP& card) {
...
@@ -91,6 +91,14 @@ StyleSheetP Set::stylesheetForP(const CardP& card) {
else
return
stylesheet
;
else
return
stylesheet
;
}
}
IndexMap
<
FieldP
,
ValueP
>&
Set
::
stylingDataFor
(
const
StyleSheet
&
stylesheet
)
{
return
styling_data
.
get
(
stylesheet
.
name
(),
stylesheet
.
styling_fields
);
}
IndexMap
<
FieldP
,
ValueP
>&
Set
::
stylingDataFor
(
const
CardP
&
card
)
{
if
(
card
&&
card
->
has_styling
)
return
card
->
styling_data
;
else
return
stylingDataFor
(
stylesheetFor
(
card
));
}
String
Set
::
typeName
()
const
{
return
_
(
"set"
);
}
String
Set
::
typeName
()
const
{
return
_
(
"set"
);
}
// fix values for versions < 0.2.7
// fix values for versions < 0.2.7
...
@@ -144,6 +152,7 @@ IMPLEMENT_REFLECTION(Set) {
...
@@ -144,6 +152,7 @@ IMPLEMENT_REFLECTION(Set) {
}
}
WITH_DYNAMIC_ARG
(
game_for_reading
,
game
.
get
());
WITH_DYNAMIC_ARG
(
game_for_reading
,
game
.
get
());
REFLECT
(
stylesheet
);
REFLECT
(
stylesheet
);
WITH_DYNAMIC_ARG
(
stylesheet_for_reading
,
stylesheet
.
get
());
REFLECT_N
(
"set_info"
,
data
);
REFLECT_N
(
"set_info"
,
data
);
if
(
stylesheet
)
{
if
(
stylesheet
)
{
REFLECT_N
(
"styling"
,
styling_data
);
REFLECT_N
(
"styling"
,
styling_data
);
...
@@ -202,12 +211,6 @@ void Set::clearOrderCache() {
...
@@ -202,12 +211,6 @@ void Set::clearOrderCache() {
order_cache
.
clear
();
order_cache
.
clear
();
}
}
// ----------------------------------------------------------------------------- : Styling
IndexMap
<
FieldP
,
ValueP
>&
Set
::
stylingDataFor
(
const
StyleSheet
&
stylesheet
)
{
return
styling_data
.
get
(
stylesheet
.
name
(),
stylesheet
.
styling_fields
);
}
// ----------------------------------------------------------------------------- : SetView
// ----------------------------------------------------------------------------- : SetView
SetView
::
SetView
()
{}
SetView
::
SetView
()
{}
...
...
src/data/set.hpp
View file @
eca74a16
...
@@ -86,6 +86,8 @@ class Set : public Packaged {
...
@@ -86,6 +86,8 @@ class Set : public Packaged {
/// Styling information for a particular stylesheet
/// Styling information for a particular stylesheet
IndexMap
<
FieldP
,
ValueP
>&
stylingDataFor
(
const
StyleSheet
&
);
IndexMap
<
FieldP
,
ValueP
>&
stylingDataFor
(
const
StyleSheet
&
);
/// Styling information for a particular card
IndexMap
<
FieldP
,
ValueP
>&
stylingDataFor
(
const
CardP
&
card
);
/// Find a value in the data by name and type
/// Find a value in the data by name and type
template
<
typename
T
>
T
&
value
(
const
String
&
name
)
{
template
<
typename
T
>
T
&
value
(
const
String
&
name
)
{
...
...
src/data/stylesheet.cpp
View file @
eca74a16
...
@@ -16,6 +16,8 @@ DECLARE_TYPEOF_COLLECTION(FieldP);
...
@@ -16,6 +16,8 @@ DECLARE_TYPEOF_COLLECTION(FieldP);
// ----------------------------------------------------------------------------- : StyleSheet
// ----------------------------------------------------------------------------- : StyleSheet
IMPLEMENT_DYNAMIC_ARG
(
StyleSheet
*
,
stylesheet_for_reading
,
nullptr
);
StyleSheet
::
StyleSheet
()
StyleSheet
::
StyleSheet
()
:
card_width
(
100
),
card_height
(
100
)
:
card_width
(
100
),
card_height
(
100
)
,
card_dpi
(
96
),
card_background
(
*
wxWHITE
)
,
card_dpi
(
96
),
card_background
(
*
wxWHITE
)
...
...
src/data/stylesheet.hpp
View file @
eca74a16
...
@@ -21,6 +21,9 @@ DECLARE_POINTER_TYPE(Style);
...
@@ -21,6 +21,9 @@ DECLARE_POINTER_TYPE(Style);
// ----------------------------------------------------------------------------- : StyleSheet
// ----------------------------------------------------------------------------- : StyleSheet
/// Stylesheet of the set that is currently being read/written
DECLARE_DYNAMIC_ARG
(
StyleSheet
*
,
stylesheet_for_reading
);
/// A collection of style information for card and set fields
/// A collection of style information for card and set fields
class
StyleSheet
:
public
Packaged
{
class
StyleSheet
:
public
Packaged
{
public:
public:
...
...
src/gui/control/native_look_editor.cpp
View file @
eca74a16
...
@@ -197,6 +197,11 @@ void StylingEditor::showStylesheet(const StyleSheetP& stylesheet) {
...
@@ -197,6 +197,11 @@ void StylingEditor::showStylesheet(const StyleSheetP& stylesheet) {
setStyles
(
stylesheet
,
stylesheet
->
styling_style
);
setStyles
(
stylesheet
,
stylesheet
->
styling_style
);
setData
(
set
->
stylingDataFor
(
*
stylesheet
));
setData
(
set
->
stylingDataFor
(
*
stylesheet
));
}
}
void
StylingEditor
::
showCard
(
const
CardP
&
card
)
{
StyleSheetP
stylesheet
=
set
->
stylesheetForP
(
card
);
setStyles
(
stylesheet
,
stylesheet
->
styling_style
);
setData
(
set
->
stylingDataFor
(
card
));
}
void
StylingEditor
::
onChangeSet
()
{
void
StylingEditor
::
onChangeSet
()
{
showStylesheet
(
set
->
stylesheet
);
showStylesheet
(
set
->
stylesheet
);
...
...
src/gui/control/native_look_editor.hpp
View file @
eca74a16
...
@@ -68,8 +68,10 @@ class StylingEditor : public NativeLookEditor {
...
@@ -68,8 +68,10 @@ class StylingEditor : public NativeLookEditor {
public:
public:
StylingEditor
(
Window
*
parent
,
int
id
,
long
style
=
0
);
StylingEditor
(
Window
*
parent
,
int
id
,
long
style
=
0
);
/// Show the styling for given stylesheet in the editor
/// Show the styling for given stylesheet in the editor
void
showStylesheet
(
const
StyleSheetP
&
stylesheet
);
void
showStylesheet
(
const
StyleSheetP
&
stylesheet
);
/// Show the styling for given card
void
showCard
(
const
CardP
&
card
);
protected:
protected:
virtual
void
onChangeSet
();
virtual
void
onChangeSet
();
...
...
src/gui/set/style_panel.cpp
View file @
eca74a16
...
@@ -23,10 +23,11 @@ StylePanel::StylePanel(Window* parent, int id)
...
@@ -23,10 +23,11 @@ StylePanel::StylePanel(Window* parent, int id)
:
SetWindowPanel
(
parent
,
id
)
:
SetWindowPanel
(
parent
,
id
)
{
{
// init controls
// init controls
preview
=
new
CardViewer
(
this
,
wxID_ANY
);
preview
=
new
CardViewer
(
this
,
wxID_ANY
);
editor
=
new
StylingEditor
(
this
,
wxID_ANY
,
wxNO_BORDER
);
editor
=
new
StylingEditor
(
this
,
wxID_ANY
,
wxNO_BORDER
);
list
=
new
PackageList
(
this
,
wxID_ANY
);
list
=
new
PackageList
(
this
,
wxID_ANY
);
use_for_all
=
new
wxButton
(
this
,
ID_STYLE_USE_FOR_ALL
,
_BUTTON_
(
"use for all cards"
));
use_for_all
=
new
wxButton
(
this
,
ID_STYLE_USE_FOR_ALL
,
_BUTTON_
(
"use for all cards"
));
use_custom_options
=
new
wxCheckBox
(
this
,
ID_STYLE_USE_CUSTOM
,
_BUTTON_
(
"use custom styling options"
));
// init sizer
// init sizer
wxSizer
*
s
=
new
wxBoxSizer
(
wxHORIZONTAL
);
wxSizer
*
s
=
new
wxBoxSizer
(
wxHORIZONTAL
);
s
->
Add
(
preview
,
0
,
wxRIGHT
,
2
);
s
->
Add
(
preview
,
0
,
wxRIGHT
,
2
);
...
@@ -34,7 +35,8 @@ StylePanel::StylePanel(Window* parent, int id)
...
@@ -34,7 +35,8 @@ StylePanel::StylePanel(Window* parent, int id)
s2
->
Add
(
list
,
0
,
wxEXPAND
|
wxBOTTOM
,
4
);
s2
->
Add
(
list
,
0
,
wxEXPAND
|
wxBOTTOM
,
4
);
s2
->
Add
(
use_for_all
,
0
,
wxRIGHT
|
wxBOTTOM
|
wxALIGN_RIGHT
,
4
);
s2
->
Add
(
use_for_all
,
0
,
wxRIGHT
|
wxBOTTOM
|
wxALIGN_RIGHT
,
4
);
wxSizer
*
s3
=
new
wxStaticBoxSizer
(
wxVERTICAL
,
this
,
_LABEL_
(
"styling options"
));
wxSizer
*
s3
=
new
wxStaticBoxSizer
(
wxVERTICAL
,
this
,
_LABEL_
(
"styling options"
));
s3
->
Add
(
editor
,
2
,
wxEXPAND
,
0
);
s3
->
Add
(
use_custom_options
,
0
,
wxEXPAND
,
0
);
s3
->
Add
(
editor
,
2
,
wxEXPAND
,
0
);
s2
->
Add
(
s3
,
1
,
wxEXPAND
|
wxALL
,
2
);
s2
->
Add
(
s3
,
1
,
wxEXPAND
|
wxALL
,
2
);
s
->
Add
(
s2
,
1
,
wxEXPAND
,
8
);
s
->
Add
(
s2
,
1
,
wxEXPAND
,
8
);
s
->
SetSizeHints
(
this
);
s
->
SetSizeHints
(
this
);
...
@@ -53,15 +55,22 @@ void StylePanel::onChangeSet() {
...
@@ -53,15 +55,22 @@ void StylePanel::onChangeSet() {
void
StylePanel
::
onAction
(
const
Action
&
action
,
bool
undone
)
{
void
StylePanel
::
onAction
(
const
Action
&
action
,
bool
undone
)
{
TYPE_CASE_
(
action
,
ChangeSetStyleAction
)
{
TYPE_CASE_
(
action
,
ChangeSetStyleAction
)
{
list
->
select
(
set
->
stylesheetFor
(
card
).
name
(),
false
);
list
->
select
(
set
->
stylesheetFor
(
card
).
name
(),
false
);
editor
->
show
Stylesheet
(
set
->
stylesheetForP
(
card
)
);
editor
->
show
Card
(
card
);
}
}
TYPE_CASE
(
action
,
ChangeCardStyleAction
)
{
TYPE_CASE
(
action
,
ChangeCardStyleAction
)
{
if
(
action
.
card
==
card
)
{
if
(
action
.
card
==
card
)
{
list
->
select
(
set
->
stylesheetFor
(
card
).
name
(),
false
);
list
->
select
(
set
->
stylesheetFor
(
card
).
name
(),
false
);
editor
->
showStylesheet
(
set
->
stylesheetForP
(
card
));
editor
->
showCard
(
card
);
}
}
TYPE_CASE
(
action
,
ChangeCardHasStylingAction
)
{
if
(
action
.
card
==
card
)
{
editor
->
showCard
(
card
);
}
}
}
}
use_for_all
->
Enable
(
card
&&
card
->
stylesheet
);
use_for_all
->
Enable
(
card
&&
card
->
stylesheet
);
use_custom_options
->
Enable
(
card
);
use_custom_options
->
SetValue
(
card
->
has_styling
);
}
}
// ----------------------------------------------------------------------------- : Selection
// ----------------------------------------------------------------------------- : Selection
...
@@ -70,8 +79,11 @@ void StylePanel::selectCard(const CardP& card) {
...
@@ -70,8 +79,11 @@ void StylePanel::selectCard(const CardP& card) {
this
->
card
=
card
;
this
->
card
=
card
;
preview
->
setCard
(
card
);
preview
->
setCard
(
card
);
editor
->
showStylesheet
(
set
->
stylesheetForP
(
card
));
editor
->
showStylesheet
(
set
->
stylesheetForP
(
card
));
editor
->
showCard
(
card
);
list
->
select
(
set
->
stylesheetFor
(
card
).
name
(),
false
);
list
->
select
(
set
->
stylesheetFor
(
card
).
name
(),
false
);
use_for_all
->
Enable
(
card
&&
card
->
stylesheet
);
use_for_all
->
Enable
(
card
&&
card
->
stylesheet
);
use_custom_options
->
Enable
(
card
);
use_custom_options
->
SetValue
(
card
->
has_styling
);
}
}
// ----------------------------------------------------------------------------- : Events
// ----------------------------------------------------------------------------- : Events
...
@@ -93,7 +105,12 @@ void StylePanel::onUseForAll(wxCommandEvent&) {
...
@@ -93,7 +105,12 @@ void StylePanel::onUseForAll(wxCommandEvent&) {
Layout
();
Layout
();
}
}
void
StylePanel
::
onUseCustom
(
wxCommandEvent
&
)
{
set
->
actions
.
add
(
new
ChangeCardHasStylingAction
(
*
set
,
card
));
}
BEGIN_EVENT_TABLE
(
StylePanel
,
wxPanel
)
BEGIN_EVENT_TABLE
(
StylePanel
,
wxPanel
)
EVT_GALLERY_SELECT
(
wxID_ANY
,
StylePanel
::
onStyleSelect
)
EVT_GALLERY_SELECT
(
wxID_ANY
,
StylePanel
::
onStyleSelect
)
EVT_BUTTON
(
ID_STYLE_USE_FOR_ALL
,
StylePanel
::
onUseForAll
)
EVT_BUTTON
(
ID_STYLE_USE_FOR_ALL
,
StylePanel
::
onUseForAll
)
EVT_CHECKBOX
(
ID_STYLE_USE_CUSTOM
,
StylePanel
::
onUseCustom
)
END_EVENT_TABLE
()
END_EVENT_TABLE
()
src/gui/set/style_panel.hpp
View file @
eca74a16
...
@@ -36,10 +36,12 @@ class StylePanel : public SetWindowPanel {
...
@@ -36,10 +36,12 @@ class StylePanel : public SetWindowPanel {
PackageList
*
list
;
///< List of stylesheets
PackageList
*
list
;
///< List of stylesheets
StylingEditor
*
editor
;
///< Editor for styling information
StylingEditor
*
editor
;
///< Editor for styling information
wxButton
*
use_for_all
;
wxButton
*
use_for_all
;
wxCheckBox
*
use_custom_options
;
CardP
card
;
///< Card we are working on
CardP
card
;
///< Card we are working on
void
onStyleSelect
(
wxCommandEvent
&
);
void
onStyleSelect
(
wxCommandEvent
&
);
void
onUseForAll
(
wxCommandEvent
&
);
void
onUseForAll
(
wxCommandEvent
&
);
void
onUseCustom
(
wxCommandEvent
&
);
};
};
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
...
...
src/script/script_manager.cpp
View file @
eca74a16
...
@@ -72,11 +72,14 @@ Context& SetScriptContext::getContext(const StyleSheetP& stylesheet) {
...
@@ -72,11 +72,14 @@ Context& SetScriptContext::getContext(const StyleSheetP& stylesheet) {
}
}
}
}
Context
&
SetScriptContext
::
getContext
(
const
CardP
&
card
)
{
Context
&
SetScriptContext
::
getContext
(
const
CardP
&
card
)
{
Context
&
ctx
=
getContext
(
set
.
stylesheetForP
(
card
));
StyleSheetP
stylesheet
=
set
.
stylesheetForP
(
card
);
Context
&
ctx
=
getContext
(
stylesheet
);
if
(
card
)
{
if
(
card
)
{
ctx
.
setVariable
(
_
(
"card"
),
to_script
(
card
));
ctx
.
setVariable
(
_
(
"card"
),
to_script
(
card
));
ctx
.
setVariable
(
_
(
"styling"
),
to_script
(
&
set
.
stylingDataFor
(
card
)));
}
else
{
}
else
{
ctx
.
setVariable
(
_
(
"card"
),
ScriptValueP
());
ctx
.
setVariable
(
_
(
"card"
),
ScriptValueP
());
ctx
.
setVariable
(
_
(
"styling"
),
to_script
(
&
set
.
stylingDataFor
(
*
stylesheet
)));
}
}
return
ctx
;
return
ctx
;
}
}
...
...
src/util/index_map.hpp
View file @
eca74a16
...
@@ -114,10 +114,19 @@ class IndexMap : private vector<Value> {
...
@@ -114,10 +114,19 @@ class IndexMap : private vector<Value> {
return
end
();
return
end
();
}
}
inline
void
swap
(
IndexMap
&
b
)
{
vector
<
Value
>::
swap
(
b
);
}
private:
private:
using
vector
<
Value
>::
operator
[];
using
vector
<
Value
>::
operator
[];
};
};
template
<
typename
Key
,
typename
Value
>
inline
void
swap
(
IndexMap
<
Key
,
Value
>&
a
,
IndexMap
<
Key
,
Value
>&
b
)
{
a
.
swap
(
b
);
}
// ----------------------------------------------------------------------------- : DelayedIndexMaps
// ----------------------------------------------------------------------------- : DelayedIndexMaps
...
...
src/util/locale.hpp
View file @
eca74a16
...
@@ -92,6 +92,9 @@ String tr(const SymbolFont&, const String& key, const String& def);
...
@@ -92,6 +92,9 @@ String tr(const SymbolFont&, const String& key, const String& def);
/// A localized string for tooltip text, with 1 argument (printf style)
/// A localized string for tooltip text, with 1 argument (printf style)
#define _TOOLTIP_1_(s,a) format_string(_TOOLTIP_(s), a)
#define _TOOLTIP_1_(s,a) format_string(_TOOLTIP_(s), a)
/// A localized string for button text, with 1 argument (printf style)
#define _BUTTON_1_(s,a) format_string(_BUTTON_(s), a)
/// A localized string for error messages, with 1 argument (printf style)
/// A localized string for error messages, with 1 argument (printf style)
#define _ERROR_1_(s,a) format_string(_ERROR_(s), a)
#define _ERROR_1_(s,a) format_string(_ERROR_(s), a)
/// A localized string for error messages, with 2 argument (printf style)
/// A localized string for error messages, with 2 argument (printf style)
...
...
src/util/window_id.hpp
View file @
eca74a16
...
@@ -154,6 +154,7 @@ enum ChildMenuID {
...
@@ -154,6 +154,7 @@ enum ChildMenuID {
// Style panel
// Style panel
,
ID_STYLE_USE_FOR_ALL
=
3011
,
ID_STYLE_USE_FOR_ALL
=
3011
,
ID_STYLE_USE_CUSTOM
// Keywords panel
// Keywords panel
,
ID_KEYWORD_ADD_PARAM
=
3021
,
ID_KEYWORD_ADD_PARAM
=
3021
...
...
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