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
8909655c
Commit
8909655c
authored
Dec 21, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
events on script update; fix in cycle_sort; card list updated on value action
parent
adac03f4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
11 deletions
+47
-11
src/data/action/value.cpp
src/data/action/value.cpp
+9
-0
src/data/action/value.hpp
src/data/action/value.hpp
+15
-0
src/data/set.cpp
src/data/set.cpp
+2
-0
src/gui/control/card_list.cpp
src/gui/control/card_list.cpp
+9
-0
src/script/functions.cpp
src/script/functions.cpp
+1
-1
src/script/script_manager.cpp
src/script/script_manager.cpp
+5
-5
src/script/script_manager.hpp
src/script/script_manager.hpp
+6
-5
No files found.
src/data/action/value.cpp
View file @
8909655c
...
@@ -141,3 +141,12 @@ TextValueAction* typing_action(const TextValueP& value, size_t start, size_t end
...
@@ -141,3 +141,12 @@ TextValueAction* typing_action(const TextValueP& value, size_t start, size_t end
}
}
}
}
// ----------------------------------------------------------------------------- : Event
String
ScriptValueEvent
::
getName
(
bool
)
const
{
assert
(
false
);
// this action is just an event, getName shouldn't be called
throw
InternalError
(
_
(
"ScriptValueEvent::getName"
));
}
void
ScriptValueEvent
::
perform
(
bool
)
{
assert
(
false
);
// this action is just an event, it should not be performed
}
src/data/action/value.hpp
View file @
8909655c
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include <util/action_stack.hpp>
#include <util/action_stack.hpp>
#include <util/defaultable.hpp>
#include <util/defaultable.hpp>
class
Card
;
DECLARE_POINTER_TYPE
(
Value
);
DECLARE_POINTER_TYPE
(
Value
);
DECLARE_POINTER_TYPE
(
TextValue
);
DECLARE_POINTER_TYPE
(
TextValue
);
DECLARE_POINTER_TYPE
(
ChoiceValue
);
DECLARE_POINTER_TYPE
(
ChoiceValue
);
...
@@ -72,5 +73,19 @@ TextValueAction* toggle_format_action(const TextValueP& value, const String& tag
...
@@ -72,5 +73,19 @@ TextValueAction* toggle_format_action(const TextValueP& value, const String& tag
/// Typing in a TextValue, replace the selection [start...end) with replacement
/// Typing in a TextValue, replace the selection [start...end) with replacement
TextValueAction
*
typing_action
(
const
TextValueP
&
value
,
size_t
start
,
size_t
end
,
const
String
&
replacement
,
const
String
&
action_name
);
TextValueAction
*
typing_action
(
const
TextValueP
&
value
,
size_t
start
,
size_t
end
,
const
String
&
replacement
,
const
String
&
action_name
);
// ----------------------------------------------------------------------------- : Event
/// Notification that a script caused a value to change
class
ScriptValueEvent
:
public
Action
{
public:
inline
ScriptValueEvent
(
const
Card
*
card
,
const
Value
*
value
)
:
card
(
card
),
value
(
value
)
{}
virtual
String
getName
(
bool
to_undo
)
const
;
virtual
void
perform
(
bool
to_undo
);
const
Card
*
card
;
///< Card the value is on
const
Value
*
value
;
///< The modified value
};
// ----------------------------------------------------------------------------- : EOF
// ----------------------------------------------------------------------------- : EOF
#endif
#endif
src/data/set.cpp
View file @
8909655c
...
@@ -99,6 +99,8 @@ void Set::validate(Version file_app_version) {
...
@@ -99,6 +99,8 @@ void Set::validate(Version file_app_version) {
FOR_EACH(v, s.second->data) fix_value_207(v);
FOR_EACH(v, s.second->data) fix_value_207(v);
}
}
*/
}
*/
}
// update scripts
script_manager
->
updateAll
();
}
}
IMPLEMENT_REFLECTION
(
Set
)
{
IMPLEMENT_REFLECTION
(
Set
)
{
...
...
src/gui/control/card_list.cpp
View file @
8909655c
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
#include <data/stylesheet.hpp>
#include <data/stylesheet.hpp>
#include <data/format/clipboard.hpp>
#include <data/format/clipboard.hpp>
#include <data/action/set.hpp>
#include <data/action/set.hpp>
#include <data/action/value.hpp>
#include <util/window_id.hpp>
#include <util/window_id.hpp>
#include <wx/clipbrd.h>
#include <wx/clipbrd.h>
...
@@ -97,6 +98,14 @@ void CardListBase::onAction(const Action& action, bool undone) {
...
@@ -97,6 +98,14 @@ void CardListBase::onAction(const Action& action, bool undone) {
RefreshItem
((
long
)
action
.
card_id1
);
RefreshItem
((
long
)
action
.
card_id1
);
RefreshItem
((
long
)
action
.
card_id2
);
RefreshItem
((
long
)
action
.
card_id2
);
}
}
TYPE_CASE_
(
action
,
ScriptValueEvent
)
{
// No refresh needed, a ScriptValueEvent is only generated in response to a ValueAction
return
;
}
TYPE_CASE_
(
action
,
ValueAction
)
{
refreshList
();
return
;
}
}
}
const
vector
<
CardP
>&
CardListBase
::
getCards
()
const
{
const
vector
<
CardP
>&
CardListBase
::
getCards
()
const
{
...
...
src/script/functions.cpp
View file @
8909655c
...
@@ -225,7 +225,7 @@ String spec_sort(const String& spec, const String& input) {
...
@@ -225,7 +225,7 @@ String spec_sort(const String& spec, const String& input) {
}
else
if
(
c
==
_
(
'('
))
{
// in a cycle
}
else
if
(
c
==
_
(
'('
))
{
// in a cycle
size_t
end
=
spec
.
find_first_of
(
_
(
')'
));
size_t
end
=
spec
.
find_first_of
(
_
(
')'
));
if
(
end
==
String
::
npos
)
throw
ParseError
(
_
(
"Expected ')' in sort_rule specification"
));
if
(
end
==
String
::
npos
)
throw
ParseError
(
_
(
"Expected ')' in sort_rule specification"
));
ret
+=
cycle_sort
(
spec
.
substr
(
pos
,
end
-
pos
-
1
),
input
);
ret
+=
cycle_sort
(
spec
.
substr
(
pos
+
1
,
end
-
pos
-
1
),
input
);
pos
=
end
;
pos
=
end
;
}
else
{
// single char
}
else
{
// single char
...
...
src/script/script_manager.cpp
View file @
8909655c
...
@@ -98,9 +98,6 @@ void SetScriptManager::onInit(const StyleSheetP& stylesheet, Context* ctx) {
...
@@ -98,9 +98,6 @@ void SetScriptManager::onInit(const StyleSheetP& stylesheet, Context* ctx) {
// find script dependencies
// find script dependencies
initDependencies
(
*
ctx
,
*
set
.
game
);
initDependencies
(
*
ctx
,
*
set
.
game
);
initDependencies
(
*
ctx
,
*
stylesheet
);
initDependencies
(
*
ctx
,
*
stylesheet
);
// apply scripts to everything
// TODO : don't updateAll here, it will be done repeatedly
updateAll
();
}
catch
(
Error
e
)
{
}
catch
(
Error
e
)
{
handle_error
(
e
,
false
,
false
);
handle_error
(
e
,
false
,
false
);
}
}
...
@@ -142,6 +139,9 @@ void SetScriptManager::onAction(const Action& action, bool undone) {
...
@@ -142,6 +139,9 @@ void SetScriptManager::onAction(const Action& action, bool undone) {
}
}
updateValue
(
*
action
.
valueP
,
CardP
());
updateValue
(
*
action
.
valueP
,
CardP
());
}
}
TYPE_CASE_
(
action
,
ScriptValueEvent
)
{
return
;
// Don't go into an infinite loop because of our own events
}
TYPE_CASE_
(
action
,
CardListAction
)
{
TYPE_CASE_
(
action
,
CardListAction
)
{
updateAllDependend
(
set
.
game
->
dependent_scripts_cards
);
updateAllDependend
(
set
.
game
->
dependent_scripts_cards
);
}
}
...
@@ -209,8 +209,8 @@ void SetScriptManager::updateToUpdate(const ToUpdate& u, deque<ToUpdate>& to_upd
...
@@ -209,8 +209,8 @@ void SetScriptManager::updateToUpdate(const ToUpdate& u, deque<ToUpdate>& to_upd
Context
&
ctx
=
getContext
(
u
.
card
);
Context
&
ctx
=
getContext
(
u
.
card
);
if
(
u
.
value
->
update
(
ctx
))
{
if
(
u
.
value
->
update
(
ctx
))
{
// changed, send event
// changed, send event
// ScriptValueEvent change(&*u.card
, u.value);
ScriptValueEvent
change
(
u
.
card
.
get
()
,
u
.
value
);
// set.actions.tellListeners(chang
e);
set
.
actions
.
tellListeners
(
change
,
fals
e
);
// u.value has changed, also update values with a dependency on u.value
// u.value has changed, also update values with a dependency on u.value
alsoUpdate
(
to_update
,
u
.
value
->
fieldP
->
dependent_scripts
,
u
.
card
);
alsoUpdate
(
to_update
,
u
.
value
->
fieldP
->
dependent_scripts
,
u
.
card
);
}
}
...
...
src/script/script_manager.hpp
View file @
8909655c
...
@@ -61,6 +61,12 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
...
@@ -61,6 +61,12 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
// Update all styles for a particular card
// Update all styles for a particular card
void
updateStyles
(
const
CardP
&
card
);
void
updateStyles
(
const
CardP
&
card
);
/// Update all fields of all cards
/** Update all set info fields
* Doesn't update styles
*/
void
updateAll
();
private:
private:
virtual
void
onInit
(
const
StyleSheetP
&
stylesheet
,
Context
*
ctx
);
virtual
void
onInit
(
const
StyleSheetP
&
stylesheet
,
Context
*
ctx
);
...
@@ -70,11 +76,6 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
...
@@ -70,11 +76,6 @@ class SetScriptManager : public SetScriptContext, public ActionListener {
/// Updates scripts, starting at some value
/// Updates scripts, starting at some value
/** 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 fields of all cards
/** Update all set info fields
* Doesn't update styles
*/
void
updateAll
();
// 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
);
...
...
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