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
ceb8a53c
Commit
ceb8a53c
authored
Jun 01, 2008
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The keyword reminder text box now tries to run the script to see if it contains errors
parent
981fbedf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
7 deletions
+33
-7
src/data/action/keyword.cpp
src/data/action/keyword.cpp
+26
-5
src/data/action/keyword.hpp
src/data/action/keyword.hpp
+6
-1
src/gui/set/keywords_panel.cpp
src/gui/set/keywords_panel.cpp
+1
-1
No files found.
src/data/action/keyword.cpp
View file @
ceb8a53c
...
@@ -52,8 +52,10 @@ void AddKeywordAction::perform(bool to_undo) {
...
@@ -52,8 +52,10 @@ void AddKeywordAction::perform(bool to_undo) {
// ----------------------------------------------------------------------------- : Changing keywords
// ----------------------------------------------------------------------------- : Changing keywords
KeywordReminderTextValue
::
KeywordReminderTextValue
(
const
TextFieldP
&
field
,
Keyword
*
keyword
,
bool
editable
)
KeywordReminderTextValue
::
KeywordReminderTextValue
(
Set
&
set
,
const
TextFieldP
&
field
,
Keyword
*
keyword
,
bool
editable
)
:
KeywordTextValue
(
field
,
keyword
,
&
keyword
->
reminder
.
getUnparsed
(),
editable
)
:
KeywordTextValue
(
field
,
keyword
,
&
keyword
->
reminder
.
getUnparsed
(),
editable
)
,
set
(
set
)
,
keyword
(
*
keyword
)
{}
{}
void
KeywordReminderTextValue
::
store
()
{
void
KeywordReminderTextValue
::
store
()
{
...
@@ -67,10 +69,12 @@ void KeywordReminderTextValue::store() {
...
@@ -67,10 +69,12 @@ void KeywordReminderTextValue::store() {
vector
<
ScriptParseError
>
parse_errors
;
vector
<
ScriptParseError
>
parse_errors
;
ScriptP
new_script
=
parse
(
new_value
,
nullptr
,
true
,
parse_errors
);
ScriptP
new_script
=
parse
(
new_value
,
nullptr
,
true
,
parse_errors
);
if
(
parse_errors
.
empty
())
{
if
(
parse_errors
.
empty
())
{
// parsed okay, assign
// parsed okay
errors
.
clear
();
if
(
checkScript
(
new_script
))
{
keyword
.
reminder
.
getScriptP
()
=
new_script
;
// also runs okay, assign
keyword
.
reminder
.
getUnparsed
()
=
new_value
;
keyword
.
reminder
.
getScriptP
()
=
new_script
;
keyword
.
reminder
.
getUnparsed
()
=
new_value
;
}
}
else
{
}
else
{
// parse errors, report
// parse errors, report
errors
=
ScriptParseErrors
(
parse_errors
).
what
();
errors
=
ScriptParseErrors
(
parse_errors
).
what
();
...
@@ -172,6 +176,23 @@ void KeywordReminderTextValue::highlight(const String& code, const vector<Script
...
@@ -172,6 +176,23 @@ void KeywordReminderTextValue::highlight(const String& code, const vector<Script
value
=
new_value
;
value
=
new_value
;
}
}
bool
KeywordReminderTextValue
::
checkScript
(
const
ScriptP
&
script
)
{
Context
&
ctx
=
set
.
cards
.
empty
()
?
set
.
getContext
()
:
set
.
getContext
(
set
.
cards
.
front
());
size_t
scope
=
ctx
.
openScope
();
try
{
for
(
size_t
i
=
0
;
i
<
keyword
.
parameters
.
size
()
;
++
i
)
{
String
param
=
String
(
_
(
"param"
))
<<
(
int
)(
i
+
1
);
ctx
.
setVariable
(
param
,
to_script
(
param
));
}
script
->
eval
(
ctx
);
errors
.
clear
();
}
catch
(
const
Error
&
e
)
{
errors
=
e
.
what
();
}
ctx
.
closeScope
(
scope
);
return
errors
.
empty
();
}
// ----------------------------------------------------------------------------- : Changing keywords : mode
// ----------------------------------------------------------------------------- : Changing keywords : mode
ChangeKeywordModeAction
::
ChangeKeywordModeAction
(
Keyword
&
keyword
,
const
String
&
new_mode
)
ChangeKeywordModeAction
::
ChangeKeywordModeAction
(
Keyword
&
keyword
,
const
String
&
new_mode
)
...
...
src/data/action/keyword.hpp
View file @
ceb8a53c
...
@@ -70,9 +70,11 @@ class KeywordTextValue : public FakeTextValue {
...
@@ -70,9 +70,11 @@ class KeywordTextValue : public FakeTextValue {
/// A FakeTextValue that is used to edit reminder text scripts
/// A FakeTextValue that is used to edit reminder text scripts
class
KeywordReminderTextValue
:
public
KeywordTextValue
{
class
KeywordReminderTextValue
:
public
KeywordTextValue
{
public:
public:
KeywordReminderTextValue
(
const
TextFieldP
&
field
,
Keyword
*
keyword
,
bool
editable
);
KeywordReminderTextValue
(
Set
&
set
,
const
TextFieldP
&
field
,
Keyword
*
keyword
,
bool
editable
);
String
errors
;
///< Errors in the script
String
errors
;
///< Errors in the script
Set
&
set
;
///< Set this keyword is in (for script checking)
Keyword
&
keyword
;
///< The keyword we are the reminder text of
/// Try to compile the script
/// Try to compile the script
virtual
void
store
();
virtual
void
store
();
...
@@ -81,6 +83,9 @@ class KeywordReminderTextValue : public KeywordTextValue {
...
@@ -81,6 +83,9 @@ class KeywordReminderTextValue : public KeywordTextValue {
/// Syntax highlight, and store in value
/// Syntax highlight, and store in value
void
highlight
(
const
String
&
code
,
const
vector
<
ScriptParseError
>&
errors
);
void
highlight
(
const
String
&
code
,
const
vector
<
ScriptParseError
>&
errors
);
/// Check the script for errors
bool
checkScript
(
const
ScriptP
&
script
);
};
};
/// Changing the mode of a keyword
/// Changing the mode of a keyword
...
...
src/gui/set/keywords_panel.cpp
View file @
ceb8a53c
...
@@ -313,7 +313,7 @@ void KeywordsPanel::onKeywordSelect(KeywordSelectEvent& ev) {
...
@@ -313,7 +313,7 @@ void KeywordsPanel::onKeywordSelect(KeywordSelectEvent& ev) {
keyword
->
setValue
(
new_intrusive5
<
KeywordTextValue
>
(
keyword
->
getFieldP
(),
&
kw
,
&
kw
.
keyword
,
!
kw
.
fixed
,
true
));
keyword
->
setValue
(
new_intrusive5
<
KeywordTextValue
>
(
keyword
->
getFieldP
(),
&
kw
,
&
kw
.
keyword
,
!
kw
.
fixed
,
true
));
match
->
setValue
(
new_intrusive4
<
KeywordTextValue
>
(
match
->
getFieldP
(),
&
kw
,
&
kw
.
match
,
!
kw
.
fixed
));
match
->
setValue
(
new_intrusive4
<
KeywordTextValue
>
(
match
->
getFieldP
(),
&
kw
,
&
kw
.
match
,
!
kw
.
fixed
));
rules
->
setValue
(
new_intrusive4
<
KeywordTextValue
>
(
rules
->
getFieldP
(),
&
kw
,
&
kw
.
rules
,
!
kw
.
fixed
));
rules
->
setValue
(
new_intrusive4
<
KeywordTextValue
>
(
rules
->
getFieldP
(),
&
kw
,
&
kw
.
rules
,
!
kw
.
fixed
));
intrusive_ptr
<
KeywordReminderTextValue
>
reminder_value
(
new
KeywordReminderTextValue
(
reminder
->
getFieldP
(),
&
kw
,
!
kw
.
fixed
));
intrusive_ptr
<
KeywordReminderTextValue
>
reminder_value
(
new
KeywordReminderTextValue
(
*
set
,
reminder
->
getFieldP
(),
&
kw
,
!
kw
.
fixed
));
reminder
->
setValue
(
reminder_value
);
reminder
->
setValue
(
reminder_value
);
errors
->
SetLabel
(
reminder_value
->
errors
);
errors
->
SetLabel
(
reminder_value
->
errors
);
add_param
->
Enable
(
!
kw
.
fixed
&&
!
set
->
game
->
keyword_parameter_types
.
empty
());
add_param
->
Enable
(
!
kw
.
fixed
&&
!
set
->
game
->
keyword_parameter_types
.
empty
());
...
...
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