Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Unified Diff: nacltoons/data/res/validate.lua

Issue 15070003: [nacltoons] Add compound shapes. (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « nacltoons/data/res/util.lua ('k') | nacltoons/proj.linux/Makefile » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: nacltoons/data/res/validate.lua
diff --git a/nacltoons/data/res/validate.lua b/nacltoons/data/res/validate.lua
index 8a973e951b1111557063e08304446315a321c270..1ae999f30b1ae643e4257621d74208b4ac59ed59 100644
--- a/nacltoons/data/res/validate.lua
+++ b/nacltoons/data/res/validate.lua
@@ -93,52 +93,46 @@ validate.ValidateLevelDef = function(filename, gamedef, leveldef)
return Err("file does not evaluate to an object of type 'table'")
end
- CheckValidKeys(filename, leveldef, { 'num_stars', 'shapes', 'sprites', 'script' })
+ CheckValidKeys(filename, leveldef, { 'num_stars', 'shapes', 'script' })
if leveldef.shapes then
- local valid_keys = { 'start', 'finish', 'color', 'type', 'anchor', 'tag', 'dynamic' }
- local valid_types = { 'line', 'edge' }
+ local valid_keys = { 'script', 'pos', 'children', 'sensor', 'image', 'start', 'finish', 'color', 'type', 'anchor', 'tag', 'dynamic' }
+ local valid_types = { 'compound', 'line', 'edge', 'image' }
local required_keys = { 'type' }
- for _, shape in pairs(leveldef.shapes) do
- CheckValidKeys(filename, shape, valid_keys)
- CheckRequiredKeys(filename, shape, required_keys, 'shape')
- if not ListContains(valid_types, shape.type) then
- Err('invalid shape type: ' .. shape.type)
- end
- end
- end
- if leveldef.sprites then
- local valid_keys = { 'pos', 'tag', 'image', 'script', 'sensor' }
- local required_keys = { 'pos', 'image' }
- for _, sprite in pairs(leveldef.sprites) do
- CheckValidKeys(filename, sprite, valid_keys)
- CheckRequiredKeys(filename, sprite, required_keys, 'sprite')
- if gamedef.assets[sprite.image] == nil then
- Err('invalid image asset: ' .. sprite.image)
+ local function ValidateShapeList(shapes)
+ for _, shape in pairs(shapes) do
+ if #shape > 0 then
+ ValidateShapeList(shape)
+ else
+ CheckValidKeys(filename, shape, valid_keys)
+ CheckRequiredKeys(filename, shape, required_keys, 'shape')
+ if not ListContains(valid_types, shape.type) then
+ Err('invalid shape type: ' .. shape.type)
+ end
+ end
end
end
- end
+ ValidateShapeList(leveldef.shapes)
+ end
end
-if arg and #arg >= 1 then
+if debug.getinfo(1).what == "main" and debug.getinfo(3) == nil then
-- When run from the command line run validation on passed in game.def file.
local filename = arg[1]
- if string.sub(filename, -4) == '.def' then
- local gamedef = util.LoadYaml(filename)
- gamedef.root = path.dirname(filename)
- validate.ValidateGameDef(filename, gamedef)
-
- -- Now validate all the levels in the game.
- for _, level in ipairs(gamedef.levels) do
- filename = path.join(gamedef.root, level)
- level = util.LoadYaml(filename)
- validate.ValidateLevelDef(filename, gamedef, level)
- end
-
- print("Validation successful!")
+ local gamedef = util.LoadYaml(filename)
+ gamedef.root = path.dirname(filename)
+ validate.ValidateGameDef(filename, gamedef)
+
+ -- Now validate all the levels in the game.
+ for _, level in ipairs(gamedef.levels) do
+ filename = path.join(gamedef.root, level)
+ level = util.LoadYaml(filename)
+ validate.ValidateLevelDef(filename, gamedef, level)
end
+
+ print("Validation successful!")
end
return validate
« no previous file with comments | « nacltoons/data/res/util.lua ('k') | nacltoons/proj.linux/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698