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

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
Index: nacltoons/data/res/validate.lua
diff --git a/nacltoons/data/res/validate.lua b/nacltoons/data/res/validate.lua
index 8a973e951b1111557063e08304446315a321c270..bd1cedd91701d473329bb58318c9d89aae121f6c 100644
--- a/nacltoons/data/res/validate.lua
+++ b/nacltoons/data/res/validate.lua
@@ -93,33 +93,29 @@ 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

Powered by Google App Engine
This is Rietveld 408576698