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
34c503c7
Commit
34c503c7
authored
Apr 18, 2007
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dependency handling for keywords
parent
40d167bf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
9 deletions
+54
-9
src/gui/value/text.cpp
src/gui/value/text.cpp
+14
-4
src/script/functions/basic.cpp
src/script/functions/basic.cpp
+9
-3
src/script/functions/util.hpp
src/script/functions/util.hpp
+11
-0
src/script/script_manager.cpp
src/script/script_manager.cpp
+16
-0
src/util/action_stack.cpp
src/util/action_stack.cpp
+4
-2
No files found.
src/gui/value/text.cpp
View file @
34c503c7
...
...
@@ -124,6 +124,7 @@ bool TextValueEditor::onRightDown(const RealPoint& pos, wxMouseEvent& ev) {
// ----------------------------------------------------------------------------- : Keyboard
bool
TextValueEditor
::
onChar
(
wxKeyEvent
&
ev
)
{
if
(
ev
.
AltDown
())
return
false
;
fixSelection
();
switch
(
ev
.
GetKeyCode
())
{
case
WXK_LEFT
:
...
...
@@ -198,6 +199,8 @@ bool TextValueEditor::onChar(wxKeyEvent& ev) {
// this might not work for internationalized input.
// It might also not be portable!
replaceSelection
(
escape
(
String
(
ev
.
GetUnicodeKey
(),
1
)),
_
(
"Typing"
));
}
else
{
return
false
;
}
}
return
true
;
...
...
@@ -365,7 +368,8 @@ bool TextValueEditor::canFormat(int type) const {
case
ID_FORMAT_SYMBOL
:
return
!
style
().
always_symbol
&&
style
().
allow_formating
&&
style
().
symbol_font
.
valid
();
case
ID_FORMAT_REMINDER
:
return
false
;
// TODO
return
!
style
().
always_symbol
&&
style
().
allow_formating
&&
in_tag
(
value
().
value
(),
_
(
"<kw"
),
selection_start_i
,
selection_end_i
)
!=
String
::
npos
;
default:
return
false
;
}
...
...
@@ -379,9 +383,15 @@ bool TextValueEditor::hasFormat(int type) const {
return
in_tag
(
value
().
value
(),
_
(
"<i"
),
selection_start_i
,
selection_end_i
)
!=
String
::
npos
;
case
ID_FORMAT_SYMBOL
:
return
in_tag
(
value
().
value
(),
_
(
"<sym"
),
selection_start_i
,
selection_end_i
)
!=
String
::
npos
;
case
ID_FORMAT_REMINDER
:
return
false
;
// TODO
default:
case
ID_FORMAT_REMINDER
:
{
const
String
&
v
=
value
().
value
();
size_t
tag
=
in_tag
(
v
,
_
(
"<kw"
),
selection_start_i
,
selection_end_i
);
if
(
tag
!=
String
::
npos
&&
tag
+
4
<
v
.
size
())
{
Char
c
=
v
.
GetChar
(
tag
+
4
);
return
c
==
_
(
'1'
)
||
c
==
_
(
'A'
);
}
return
false
;
}
default
:
return
false
;
}
}
...
...
src/script/functions/basic.cpp
View file @
34c503c7
...
...
@@ -219,8 +219,8 @@ SCRIPT_FUNCTION(number_of_items) {
// ----------------------------------------------------------------------------- : Keywords
SCRIPT_RULE_2_N
(
expand_keywords
,
ScriptValueP
,
_
(
"default expand"
),
default_expand
,
ScriptValueP
,
_
(
"combine"
),
combine
)
{
SCRIPT_RULE_2_N
_DEP
(
expand_keywords
,
ScriptValueP
,
_
(
"default expand"
),
default_expand
,
ScriptValueP
,
_
(
"combine"
),
combine
)
{
SCRIPT_PARAM
(
String
,
input
);
SCRIPT_PARAM
(
Set
*
,
set
);
KeywordDatabase
&
db
=
set
->
keyword_db
;
...
...
@@ -232,7 +232,13 @@ SCRIPT_RULE_2_N(expand_keywords, ScriptValueP, _("default expand"), default_exp
}
SCRIPT_RETURN
(
db
.
expand
(
input
,
default_expand
,
combine
,
ctx
));
}
SCRIPT_RULE_2_DEPENDENCIES
(
expand_keywords
)
{
default_expand
->
dependencies
(
ctx
,
dep
);
combine
->
dependencies
(
ctx
,
dep
);
SCRIPT_PARAM
(
Set
*
,
set
);
set
->
game
->
dependent_scripts_keywords
.
add
(
dep
);
// this depends on the set's keywords
SCRIPT_RETURN
(
_
(
""
));
}
// ----------------------------------------------------------------------------- : Rules : regex replace
...
...
src/script/functions/util.hpp
View file @
34c503c7
...
...
@@ -143,6 +143,13 @@
SCRIPT_RULE_2_N
(
funname
,
type1
,
_
(
#
name1
),
name1
,
type2
,
_
(
#
name2
),
name2
)
/// Utility for defining a script rule with two named parameters
#define SCRIPT_RULE_2_N(funname, type1, str1, name1, type2, str2, name2) \
SCRIPT_RULE_2_N_AUX
(
funname
,
type1
,
str1
,
name1
,
type2
,
str2
,
name2
,
;)
/// Utility for defining a script rule with two named parameters, with dependencies
#define SCRIPT_RULE_2_N_DEP(funname, type1, str1, name1, type2, str2, name2)\
SCRIPT_RULE_2_N_AUX
(
funname
,
type1
,
str1
,
name1
,
type2
,
str2
,
name2
,
\
virtual
ScriptValueP
dependencies
(
Context
&
,
const
Dependency
&
)
const
;)
#define SCRIPT_RULE_2_N_AUX(funname, type1, str1, name1, type2, str2, name2, dep) \
class
ScriptRule_
##
funname
:
public
ScriptValue
{
\
public:
\
inline
ScriptRule_
##
funname
(
const
type1
&
name1
,
const
type2
&
name2
)
\
...
...
@@ -150,6 +157,7 @@
virtual
ScriptType
type
()
const
{
return
SCRIPT_FUNCTION
;
}
\
virtual
String
typeName
()
const
{
return
_
(
#
funname
)
_
(
"_rule"
);
}
\
virtual
ScriptValueP
eval
(
Context
&
ctx
)
const
;
\
dep
\
private:
\
type1
name1
;
\
type2
name2
;
\
...
...
@@ -166,6 +174,9 @@
}
\
ScriptValueP
ScriptRule_
##
funname
::
eval
(
Context
&
ctx
)
const
#define SCRIPT_RULE_2_DEPENDENCIES(name) \
ScriptValueP
ScriptRule_
##
name
::
dependencies
(
Context
&
ctx
,
const
Dependency
&
dep
)
const
// ----------------------------------------------------------------------------- : EOF
#endif
src/script/script_manager.cpp
View file @
34c503c7
...
...
@@ -16,6 +16,7 @@
#include <data/field.hpp>
#include <data/action/set.hpp>
#include <data/action/value.hpp>
#include <data/action/keyword.hpp>
#include <util/error.hpp>
typedef
map
<
const
StyleSheet
*
,
Context
*>
Contexts
;
...
...
@@ -131,6 +132,12 @@ void SetScriptManager::initDependencies(Context& ctx, StyleSheet& stylesheet) {
void
SetScriptManager
::
onAction
(
const
Action
&
action
,
bool
undone
)
{
TYPE_CASE
(
action
,
ValueAction
)
{
// is it a keyword's fake value?
KeywordTextValue
*
value
=
dynamic_cast
<
KeywordTextValue
*>
(
action
.
valueP
.
get
());
if
(
value
)
{
updateAllDependend
(
set
.
game
->
dependent_scripts_keywords
);
return
;
}
// find the affected card
FOR_EACH
(
card
,
set
.
cards
)
{
if
(
card
->
data
.
contains
(
action
.
valueP
))
{
...
...
@@ -138,6 +145,7 @@ void SetScriptManager::onAction(const Action& action, bool undone) {
return
;
}
}
// not a card value
updateValue
(
*
action
.
valueP
,
CardP
());
}
TYPE_CASE_
(
action
,
ScriptValueEvent
)
{
...
...
@@ -160,6 +168,14 @@ void SetScriptManager::onAction(const Action& action, bool undone) {
wxLogDebug
(
_
(
"-------------------------------
\n
"
));
#endif
}
TYPE_CASE_
(
action
,
KeywordListAction
)
{
updateAllDependend
(
set
.
game
->
dependent_scripts_keywords
);
return
;
}
TYPE_CASE_
(
action
,
ChangeKeywordModeAction
)
{
updateAllDependend
(
set
.
game
->
dependent_scripts_keywords
);
return
;
}
}
void
SetScriptManager
::
updateStyles
(
const
CardP
&
card
)
{
...
...
src/util/action_stack.cpp
View file @
34c503c7
...
...
@@ -33,8 +33,10 @@ void ActionStack::add(Action* action, bool allow_merge) {
FOR_EACH
(
a
,
redo_actions
)
delete
a
;
redo_actions
.
clear
();
// try to merge?
if
(
allow_merge
&&
!
undo_actions
.
empty
()
&&
undo_actions
.
back
()
->
merge
(
*
action
))
{
// merged with top undo action
if
(
allow_merge
&&
!
undo_actions
.
empty
()
&&
undo_actions
.
back
()
!=
save_point
&&
// never merge with the save point
undo_actions
.
back
()
->
merge
(
*
action
)
// merged with top undo action
)
{
delete
action
;
}
else
{
undo_actions
.
push_back
(
action
);
...
...
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