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
e156e051
Commit
e156e051
authored
Oct 26, 2006
by
twanvl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improved handling of aliasses and warnings
parent
1d8af552
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
10 deletions
+41
-10
src/data/stylesheet.cpp
src/data/stylesheet.cpp
+1
-0
src/script/scriptable.cpp
src/script/scriptable.cpp
+10
-2
src/script/scriptable.hpp
src/script/scriptable.hpp
+5
-2
src/util/io/reader.cpp
src/util/io/reader.cpp
+18
-5
src/util/io/reader.hpp
src/util/io/reader.hpp
+7
-1
No files found.
src/data/stylesheet.cpp
View file @
e156e051
...
@@ -40,6 +40,7 @@ IMPLEMENT_REFLECTION(StyleSheet) {
...
@@ -40,6 +40,7 @@ IMPLEMENT_REFLECTION(StyleSheet) {
tag
.
addAlias
(
300
,
_
(
"dpi"
),
_
(
"card_dpi"
));
tag
.
addAlias
(
300
,
_
(
"dpi"
),
_
(
"card_dpi"
));
tag
.
addAlias
(
300
,
_
(
"background"
),
_
(
"card_background"
));
tag
.
addAlias
(
300
,
_
(
"background"
),
_
(
"card_background"
));
tag
.
addAlias
(
300
,
_
(
"info_style"
),
_
(
"set_info_style"
));
tag
.
addAlias
(
300
,
_
(
"info_style"
),
_
(
"set_info_style"
));
tag
.
addAlias
(
300
,
_
(
"align"
),
_
(
"alignment"
));
REFLECT
(
game
);
REFLECT
(
game
);
REFLECT
(
full_name
);
REFLECT
(
full_name
);
...
...
src/script/scriptable.cpp
View file @
e156e051
...
@@ -32,12 +32,20 @@ ScriptValueP OptionalScript::invoke(Context& ctx) const {
...
@@ -32,12 +32,20 @@ ScriptValueP OptionalScript::invoke(Context& ctx) const {
}
}
}
}
void
OptionalScript
::
parse
(
Reader
&
reader
)
{
try
{
script
=
::
parse
(
unparsed
);
}
catch
(
const
ParseError
&
e
)
{
reader
.
warning
(
e
.
what
());
}
}
// custom reflection, different for each type
// custom reflection, different for each type
template
<>
void
Reader
::
handle
(
OptionalScript
&
os
)
{
template
<>
void
Reader
::
handle
(
OptionalScript
&
os
)
{
handle
(
os
.
unparsed
);
handle
(
os
.
unparsed
);
// read the script
os
.
parse
(
*
this
);
os
.
script
=
parse
(
os
.
unparsed
);
}
}
template
<>
void
Writer
::
handle
(
const
OptionalScript
&
os
)
{
template
<>
void
Writer
::
handle
(
const
OptionalScript
&
os
)
{
...
...
src/script/scriptable.hpp
View file @
e156e051
...
@@ -59,6 +59,8 @@ class OptionalScript {
...
@@ -59,6 +59,8 @@ class OptionalScript {
private:
private:
ScriptP
script
;
///< The script, may be null if there is no script
ScriptP
script
;
///< The script, may be null if there is no script
String
unparsed
;
///< Unparsed script, for writing back to a file
String
unparsed
;
///< Unparsed script, for writing back to a file
// parse the unparsed string, while reading
void
parse
(
Reader
&
);
DECLARE_REFLECTION
();
DECLARE_REFLECTION
();
template
<
typename
T
>
friend
class
Scriptable
;
template
<
typename
T
>
friend
class
Scriptable
;
};
};
...
@@ -95,7 +97,8 @@ template <typename T>
...
@@ -95,7 +97,8 @@ template <typename T>
void
Reader
::
handle
(
Scriptable
<
T
>&
s
)
{
void
Reader
::
handle
(
Scriptable
<
T
>&
s
)
{
handle
(
s
.
script
.
unparsed
);
handle
(
s
.
script
.
unparsed
);
if
(
starts_with
(
s
.
script
.
unparsed
,
_
(
"script:"
)))
{
if
(
starts_with
(
s
.
script
.
unparsed
,
_
(
"script:"
)))
{
s
.
script
.
script
=
parse
(
s
.
script
.
unparsed
);
s
.
script
.
unparsed
=
s
.
script
.
unparsed
.
substr
(
7
);
s
.
script
.
parse
(
*
this
);
}
else
{
}
else
{
handle
(
value
);
handle
(
value
);
}
}
...
...
src/util/io/reader.cpp
View file @
e156e051
...
@@ -52,7 +52,14 @@ void Reader::handleAppVersion() {
...
@@ -52,7 +52,14 @@ void Reader::handleAppVersion() {
}
}
void
Reader
::
warning
(
const
String
&
msg
)
{
void
Reader
::
warning
(
const
String
&
msg
)
{
wxMessageBox
((
msg
+
_
(
"
\n
On line: "
))
<<
line_number
<<
_
(
"
\n
In file: "
)
<<
filename
,
_
(
"Warning"
),
wxOK
|
wxICON_EXCLAMATION
);
warnings
+=
String
(
_
(
"
\n
On line "
))
<<
line_number
<<
_
(
":
\t
"
)
<<
msg
;
}
void
Reader
::
showWarnings
()
{
if
(
!
warnings
.
empty
())
{
wxMessageBox
(
_
(
"Warnings while reading file:
\n
"
)
+
filename
+
_
(
"
\n
"
)
+
warnings
,
_
(
"Warning"
),
wxOK
|
wxICON_EXCLAMATION
);
warnings
.
clear
();
}
}
}
bool
Reader
::
enterBlock
(
const
Char
*
name
)
{
bool
Reader
::
enterBlock
(
const
Char
*
name
)
{
...
@@ -118,14 +125,20 @@ void Reader::readLine() {
...
@@ -118,14 +125,20 @@ void Reader::readLine() {
}
}
key
=
cannocial_name_form
(
trim
(
line
.
substr
(
indent
,
pos
-
indent
)));
key
=
cannocial_name_form
(
trim
(
line
.
substr
(
indent
,
pos
-
indent
)));
value
=
pos
==
String
::
npos
?
_
(
""
)
:
trim_left
(
line
.
substr
(
pos
+
1
));
value
=
pos
==
String
::
npos
?
_
(
""
)
:
trim_left
(
line
.
substr
(
pos
+
1
));
}
void
Reader
::
unknownKey
()
{
// aliasses?
// aliasses?
map
<
String
,
String
>::
const_iterator
it
=
aliasses
.
find
(
key
);
map
<
String
,
String
>::
const_iterator
it
=
aliasses
.
find
(
key
);
if
(
it
!=
aliasses
.
end
())
{
if
(
it
!=
aliasses
.
end
())
{
if
(
aliasses
.
find
(
it
->
second
)
!=
aliasses
.
end
())
{
// alias points to another alias, don't follow it, there is the risk of infinite loops
}
else
{
// try this key instead
key
=
it
->
second
;
key
=
it
->
second
;
return
;
}
}
}
}
void
Reader
::
unknownKey
()
{
if
(
indent
==
expected_indent
)
{
if
(
indent
==
expected_indent
)
{
warning
(
_
(
"Unexpected key: '"
)
+
key
+
_
(
"'"
));
warning
(
_
(
"Unexpected key: '"
)
+
key
+
_
(
"'"
));
do
{
do
{
...
...
src/util/io/reader.hpp
View file @
e156e051
...
@@ -42,6 +42,8 @@ class Reader {
...
@@ -42,6 +42,8 @@ class Reader {
/** Used for "include file" keys. */
/** Used for "include file" keys. */
Reader
(
const
String
&
filename
);
Reader
(
const
String
&
filename
);
~
Reader
()
{
showWarnings
();
}
/// Tell the reflection code we are reading
/// Tell the reflection code we are reading
inline
bool
reading
()
const
{
return
true
;
}
inline
bool
reading
()
const
{
return
true
;
}
/// Is the thing currently being read 'complex', i.e. does it have children
/// Is the thing currently being read 'complex', i.e. does it have children
...
@@ -52,8 +54,10 @@ class Reader {
...
@@ -52,8 +54,10 @@ class Reader {
/// Read and check the application version
/// Read and check the application version
void
handleAppVersion
();
void
handleAppVersion
();
///
Show
a warning message, but continue reading
///
Add
a warning message, but continue reading
void
warning
(
const
String
&
msg
);
void
warning
(
const
String
&
msg
);
/// Show all warning messages, but continue reading
void
showWarnings
();
// --------------------------------------------------- : Handling objects
// --------------------------------------------------- : Handling objects
/// Handle an object: read it if it's name matches
/// Handle an object: read it if it's name matches
...
@@ -111,6 +115,8 @@ class Reader {
...
@@ -111,6 +115,8 @@ class Reader {
InputStreamP
input
;
InputStreamP
input
;
/// Text stream wrapping the input stream
/// Text stream wrapping the input stream
wxTextInputStream
stream
;
wxTextInputStream
stream
;
/// Accumulated warning messages
String
warnings
;
// --------------------------------------------------- : Reading the stream
// --------------------------------------------------- : Reading the stream
...
...
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