Reader now warns about invalid UTF-8 files;

Fixed possible hang when reading multiline strings with incorrect indentation;
Warnings from reading are shown also in NewSetWindow;
Script parse errors get reported with the correct line number;

Added support for showing multiple choice fields as a single image;
Added 'line_below' to ChoiceField::Choice, for putting a line below menu items.

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@420 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2007-06-12 19:35:24 +00:00
parent 27833003c8
commit 8b11433cbd
20 changed files with 318 additions and 86 deletions
+12 -4
View File
@@ -14,6 +14,8 @@
Alignment from_string(const String&);
DECLARE_TYPEOF_COLLECTION(ScriptParseError);
// ----------------------------------------------------------------------------- : Store
void store(const ScriptValueP& val, String& var) { var = val->toString(); }
@@ -43,10 +45,16 @@ ScriptValueP OptionalScript::invoke(Context& ctx, bool open_scope) const {
}
void OptionalScript::parse(Reader& reader, bool string_mode) {
try {
script = ::parse(unparsed, string_mode);
} catch (const ParseError& e) {
reader.warning(e.what());
vector<ScriptParseError> errors;
script = ::parse(unparsed, string_mode, errors);
// show parse errors as warnings
FOR_EACH(e, errors) {
// find line number
int line = 0;
for (size_t i = 0 ; i < unparsed.size() && i < e.start ; ++i) {
if (unparsed.GetChar(i) == _('\n')) line++;
}
reader.warning(e.ParseError::what(), line); // use ParseError::what because we don't want e.start in the error message
}
}