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
22aae45c
Commit
22aae45c
authored
Aug 07, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dependencies on stylesheet are marked, and updated when the stylesheet changes
parent
2442c585
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
34 additions
and
6 deletions
+34
-6
src/data/game.hpp
src/data/game.hpp
+1
-0
src/data/stylesheet.cpp
src/data/stylesheet.cpp
+5
-0
src/data/stylesheet.hpp
src/data/stylesheet.hpp
+2
-0
src/script/dependency.cpp
src/script/dependency.cpp
+1
-0
src/script/dependency.hpp
src/script/dependency.hpp
+1
-1
src/script/script_manager.cpp
src/script/script_manager.cpp
+12
-4
src/script/script_manager.hpp
src/script/script_manager.hpp
+1
-1
src/script/to_value.hpp
src/script/to_value.hpp
+7
-0
src/script/value.cpp
src/script/value.cpp
+1
-0
src/script/value.hpp
src/script/value.hpp
+3
-0
No files found.
src/data/game.hpp
View file @
22aae45c
...
@@ -58,6 +58,7 @@ class Game : public Packaged {
...
@@ -58,6 +58,7 @@ class Game : public Packaged {
Dependencies
dependent_scripts_cards
;
///< scripts that depend on the card list
Dependencies
dependent_scripts_cards
;
///< scripts that depend on the card list
Dependencies
dependent_scripts_keywords
;
///< scripts that depend on the keywords
Dependencies
dependent_scripts_keywords
;
///< scripts that depend on the keywords
Dependencies
dependent_scripts_stylesheet
;
///< scripts that depend on the card's stylesheet
bool
dependencies_initialized
;
///< are the script dependencies comming from this game all initialized?
bool
dependencies_initialized
;
///< are the script dependencies comming from this game all initialized?
/// Loads the game with a particular name, for example "magic"
/// Loads the game with a particular name, for example "magic"
...
...
src/data/stylesheet.cpp
View file @
22aae45c
...
@@ -88,6 +88,11 @@ StyleP StyleSheet::styleFor(const FieldP& field) {
...
@@ -88,6 +88,11 @@ StyleP StyleSheet::styleFor(const FieldP& field) {
}
}
void
mark_dependency_value
(
const
StyleSheet
&
stylesheet
,
const
Dependency
&
dep
)
{
stylesheet
.
game
->
dependent_scripts_stylesheet
.
add
(
dep
);
}
IMPLEMENT_REFLECTION
(
StyleSheet
)
{
IMPLEMENT_REFLECTION
(
StyleSheet
)
{
// < 0.3.0 didn't use card_ prefix
// < 0.3.0 didn't use card_ prefix
REFLECT_ALIAS
(
300
,
"width"
,
"card width"
);
REFLECT_ALIAS
(
300
,
"width"
,
"card width"
);
...
...
src/data/stylesheet.hpp
View file @
22aae45c
...
@@ -77,5 +77,7 @@ inline String type_name(const StyleSheet&) {
...
@@ -77,5 +77,7 @@ inline String type_name(const StyleSheet&) {
return
_TYPE_
(
"stylesheet"
);
return
_TYPE_
(
"stylesheet"
);
}
}
void
mark_dependency_value
(
const
StyleSheet
&
value
,
const
Dependency
&
dep
);
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
#endif
#endif
src/script/dependency.cpp
View file @
22aae45c
...
@@ -269,6 +269,7 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script)
...
@@ -269,6 +269,7 @@ ScriptValueP Context::dependencies(const Dependency& dep, const Script& script)
if
(
!
value
)
{
if
(
!
value
)
{
value
=
new_intrusive1
<
ScriptMissingVariable
>
(
variable_to_string
((
Variable
)
i
.
data
));
// no errors here
value
=
new_intrusive1
<
ScriptMissingVariable
>
(
variable_to_string
((
Variable
)
i
.
data
));
// no errors here
}
}
value
->
dependencyThis
(
dep
);
stack
.
push_back
(
value
);
stack
.
push_back
(
value
);
break
;
break
;
}
}
...
...
src/script/dependency.hpp
View file @
22aae45c
...
@@ -18,7 +18,7 @@ enum DependencyType
...
@@ -18,7 +18,7 @@ enum DependencyType
{
DEP_CARD_FIELD
///< dependency of a script in a "card" field
{
DEP_CARD_FIELD
///< dependency of a script in a "card" field
,
DEP_CARDS_FIELD
///< dependency of a script in a "card" field for all cards
,
DEP_CARDS_FIELD
///< dependency of a script in a "card" field for all cards
,
DEP_SET_FIELD
///< dependency of a script in a "set" field
,
DEP_SET_FIELD
///< dependency of a script in a "set" field
,
DEP_
STYLE
///< dependency of a script in a "style" property, data gives the stylesheet
,
DEP_
CARD_STYLE
///< dependency of a script in a "style" property, data gives the stylesheet
,
DEP_EXTRA_CARD_FIELD
///< dependency of a script in an extra stylesheet specific card field
,
DEP_EXTRA_CARD_FIELD
///< dependency of a script in an extra stylesheet specific card field
,
DEP_CARD_COPY_DEP
///< copy the dependencies from a card field
,
DEP_CARD_COPY_DEP
///< copy the dependencies from a card field
,
DEP_SET_COPY_DEP
///< copy the dependencies from a set field
,
DEP_SET_COPY_DEP
///< copy the dependencies from a set field
...
...
src/script/script_manager.cpp
View file @
22aae45c
...
@@ -134,7 +134,7 @@ void SetScriptManager::initDependencies(Context& ctx, StyleSheet& stylesheet) {
...
@@ -134,7 +134,7 @@ void SetScriptManager::initDependencies(Context& ctx, StyleSheet& stylesheet) {
}
}
// find dependencies of choice images and other style stuff
// find dependencies of choice images and other style stuff
FOR_EACH
(
s
,
stylesheet
.
card_style
)
{
FOR_EACH
(
s
,
stylesheet
.
card_style
)
{
s
->
initDependencies
(
ctx
,
Dependency
(
DEP_STYLE
,
s
->
fieldP
->
index
,
&
stylesheet
));
s
->
initDependencies
(
ctx
,
Dependency
(
DEP_
CARD_
STYLE
,
s
->
fieldP
->
index
,
&
stylesheet
));
// are there dependencies of this style on other style properties?
// are there dependencies of this style on other style properties?
Dependency
test
(
DEP_DUMMY
,
false
);
Dependency
test
(
DEP_DUMMY
,
false
);
s
->
checkContentDependencies
(
ctx
,
test
);
s
->
checkContentDependencies
(
ctx
,
test
);
...
@@ -219,6 +219,13 @@ void SetScriptManager::onAction(const Action& action, bool undone) {
...
@@ -219,6 +219,13 @@ void SetScriptManager::onAction(const Action& action, bool undone) {
updateAllDependend
(
set
.
game
->
dependent_scripts_keywords
);
updateAllDependend
(
set
.
game
->
dependent_scripts_keywords
);
return
;
return
;
}
}
TYPE_CASE
(
action
,
ChangeCardStyleAction
)
{
updateAllDependend
(
set
.
game
->
dependent_scripts_stylesheet
,
action
.
card
);
}
TYPE_CASE_
(
action
,
ChangeSetStyleAction
)
{
updateAllDependend
(
set
.
game
->
dependent_scripts_stylesheet
);
return
;
}
}
}
void
SetScriptManager
::
updateStyles
(
const
CardP
&
card
,
bool
only_content_dependent
)
{
void
SetScriptManager
::
updateStyles
(
const
CardP
&
card
,
bool
only_content_dependent
)
{
...
@@ -310,14 +317,15 @@ void SetScriptManager::updateAll() {
...
@@ -310,14 +317,15 @@ void SetScriptManager::updateAll() {
#endif
#endif
}
}
void
SetScriptManager
::
updateAllDependend
(
const
vector
<
Dependency
>&
dependent_scripts
)
{
void
SetScriptManager
::
updateAllDependend
(
const
vector
<
Dependency
>&
dependent_scripts
,
const
CardP
&
card
)
{
deque
<
ToUpdate
>
to_update
;
deque
<
ToUpdate
>
to_update
;
Age
starting_age
;
Age
starting_age
;
alsoUpdate
(
to_update
,
dependent_scripts
,
CardP
()
);
alsoUpdate
(
to_update
,
dependent_scripts
,
card
);
updateRecursive
(
to_update
,
starting_age
);
updateRecursive
(
to_update
,
starting_age
);
}
}
void
SetScriptManager
::
updateRecursive
(
deque
<
ToUpdate
>&
to_update
,
Age
starting_age
)
{
void
SetScriptManager
::
updateRecursive
(
deque
<
ToUpdate
>&
to_update
,
Age
starting_age
)
{
if
(
to_update
.
empty
())
return
;
set
.
clearOrderCache
();
// clear caches before evaluating a round of scripts
set
.
clearOrderCache
();
// clear caches before evaluating a round of scripts
while
(
!
to_update
.
empty
())
{
while
(
!
to_update
.
empty
())
{
updateToUpdate
(
to_update
.
front
(),
to_update
,
starting_age
);
updateToUpdate
(
to_update
.
front
(),
to_update
,
starting_age
);
...
@@ -373,7 +381,7 @@ void SetScriptManager::alsoUpdate(deque<ToUpdate>& to_update, const vector<Depen
...
@@ -373,7 +381,7 @@ void SetScriptManager::alsoUpdate(deque<ToUpdate>& to_update, const vector<Depen
to_update
.
push_back
(
ToUpdate
(
value
.
get
(),
card
));
to_update
.
push_back
(
ToUpdate
(
value
.
get
(),
card
));
}
}
break
;
break
;
}
case
DEP_STYLE
:
{
}
case
DEP_
CARD_
STYLE
:
{
// a generated image has become invalid, there is not much we can do
// a generated image has become invalid, there is not much we can do
// because the index is not exact enough, it only gives the field
// because the index is not exact enough, it only gives the field
StyleSheet
*
stylesheet
=
reinterpret_cast
<
StyleSheet
*>
(
d
.
data
);
StyleSheet
*
stylesheet
=
reinterpret_cast
<
StyleSheet
*>
(
d
.
data
);
...
...
src/script/script_manager.hpp
View file @
22aae45c
...
@@ -84,7 +84,7 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
...
@@ -84,7 +84,7 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
/** if the value changes any dependend values are updated as well */
/** if the value changes any dependend values are updated as well */
void
updateValue
(
Value
&
value
,
const
CardP
&
card
);
void
updateValue
(
Value
&
value
,
const
CardP
&
card
);
// Update all values with a specific dependency
// Update all values with a specific dependency
void
updateAllDependend
(
const
vector
<
Dependency
>&
dependent_scripts
);
void
updateAllDependend
(
const
vector
<
Dependency
>&
dependent_scripts
,
const
CardP
&
card
=
CardP
()
);
// Something that needs to be updated
// Something that needs to be updated
struct
ToUpdate
{
struct
ToUpdate
{
...
...
src/script/to_value.hpp
View file @
22aae45c
...
@@ -33,6 +33,10 @@ ScriptValueP make_iterator(const T& v) {
...
@@ -33,6 +33,10 @@ ScriptValueP make_iterator(const T& v) {
template
<
typename
T
>
template
<
typename
T
>
void
mark_dependency_member
(
const
T
&
value
,
const
String
&
name
,
const
Dependency
&
dep
)
{}
void
mark_dependency_member
(
const
T
&
value
,
const
String
&
name
,
const
Dependency
&
dep
)
{}
/// Mark a dependency on an object, can be overloaded
template
<
typename
T
>
void
mark_dependency_value
(
const
T
&
value
,
const
Dependency
&
dep
)
{}
/// Type name of an object, for error messages
/// Type name of an object, for error messages
template
<
typename
T
>
inline
String
type_name
(
const
T
&
)
{
template
<
typename
T
>
inline
String
type_name
(
const
T
&
)
{
return
_TYPE_
(
"object"
);
return
_TYPE_
(
"object"
);
...
@@ -276,6 +280,9 @@ class ScriptObject : public ScriptValue {
...
@@ -276,6 +280,9 @@ class ScriptObject : public ScriptValue {
mark_dependency_member
(
*
value
,
name
,
dep
);
mark_dependency_member
(
*
value
,
name
,
dep
);
return
getMember
(
name
);
return
getMember
(
name
);
}
}
virtual
void
dependencyThis
(
const
Dependency
&
dep
)
{
mark_dependency_value
(
*
value
,
dep
);
}
virtual
ScriptValueP
makeIterator
(
const
ScriptValueP
&
thisP
)
const
{
virtual
ScriptValueP
makeIterator
(
const
ScriptValueP
&
thisP
)
const
{
ScriptValueP
it
=
make_iterator
(
*
value
);
ScriptValueP
it
=
make_iterator
(
*
value
);
if
(
it
)
return
it
;
if
(
it
)
return
it
;
...
...
src/script/value.cpp
View file @
22aae45c
...
@@ -54,6 +54,7 @@ ScriptValueP ScriptValue::dependencyName(const ScriptValue& container, const Dep
...
@@ -54,6 +54,7 @@ ScriptValueP ScriptValue::dependencyName(const ScriptValue& container, const Dep
return
container
.
dependencyMember
(
toString
(),
dep
);
return
container
.
dependencyMember
(
toString
(),
dep
);
}
}
ScriptValueP
ScriptValue
::
dependencies
(
Context
&
,
const
Dependency
&
)
const
{
return
dependency_dummy
;
}
ScriptValueP
ScriptValue
::
dependencies
(
Context
&
,
const
Dependency
&
)
const
{
return
dependency_dummy
;
}
void
ScriptValue
::
dependencyThis
(
const
Dependency
&
dep
)
{}
bool
approx_equal
(
double
a
,
double
b
)
{
bool
approx_equal
(
double
a
,
double
b
)
{
return
a
==
b
||
fabs
(
a
-
b
)
<
1e-14
;
return
a
==
b
||
fabs
(
a
-
b
)
<
1e-14
;
...
...
src/script/value.hpp
View file @
22aae45c
...
@@ -80,6 +80,9 @@ class ScriptValue : public IntrusivePtrBaseWithDelete {
...
@@ -80,6 +80,9 @@ class ScriptValue : public IntrusivePtrBaseWithDelete {
/// Get a member variable from this value
/// Get a member variable from this value
virtual
ScriptValueP
getMember
(
const
String
&
name
)
const
;
virtual
ScriptValueP
getMember
(
const
String
&
name
)
const
;
/// Signal that a script depends on this value itself
virtual
void
dependencyThis
(
const
Dependency
&
dep
);
/// Signal that a script depends on a member of this value
/// Signal that a script depends on a member of this value
/** It is the abstract version of getMember*/
/** It is the abstract version of getMember*/
virtual
ScriptValueP
dependencyMember
(
const
String
&
name
,
const
Dependency
&
)
const
;
virtual
ScriptValueP
dependencyMember
(
const
String
&
name
,
const
Dependency
&
)
const
;
...
...
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