mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
defines yaml schemas for robust generic attribution files and mapfiles (#3089)
Co-authored-by: ike709 <ike709@users.noreply.github.com> Co-authored-by: Paul <ritter.paul1@gmail.com>
This commit is contained in:
87
Schemas/mapfile.yml
Normal file
87
Schemas/mapfile.yml
Normal file
@@ -0,0 +1,87 @@
|
||||
# schema file for Yamale
|
||||
meta:
|
||||
format: int()
|
||||
name: str()
|
||||
author: str()
|
||||
postmapinit: bool()
|
||||
tilemap: map(str(), key=int())
|
||||
grids:
|
||||
- settings:
|
||||
chunksize: int()
|
||||
tilesize: int()
|
||||
chunks: list(include('chunk'), min=1)
|
||||
entities: list(include('entity'), min=1)
|
||||
---
|
||||
chunk:
|
||||
- ind: str() #todo regex
|
||||
tiles: str()
|
||||
entity:
|
||||
- uid: int()
|
||||
type: str(required=False)
|
||||
components: list(comp())
|
||||
|
||||
# Example
|
||||
# meta:
|
||||
# format: 2
|
||||
# name: DemoStation
|
||||
# author: Space-Wizards
|
||||
# postmapinit: false
|
||||
# tilemap:
|
||||
# 0: space
|
||||
# 1: floor_asteroid_coarse_sand0
|
||||
# 2: floor_asteroid_coarse_sand1
|
||||
# 3: floor_asteroid_coarse_sand2
|
||||
# 4: floor_asteroid_coarse_sand_dug
|
||||
# 5: floor_asteroid_sand
|
||||
# 6: floor_asteroid_tile
|
||||
# 7: floor_blue
|
||||
# 8: floor_dark
|
||||
# 9: floor_elevator_shaft
|
||||
# 10: floor_freezer
|
||||
# 11: floor_glass
|
||||
# 12: floor_gold
|
||||
# 13: floor_green_circuit
|
||||
# 14: floor_hydro
|
||||
# 15: floor_lino
|
||||
# 16: floor_mono
|
||||
# 17: floor_reinforced
|
||||
# 18: floor_rglass
|
||||
# 19: floor_rock_vault
|
||||
# 20: floor_showroom
|
||||
# 21: floor_snow
|
||||
# 22: floor_steel
|
||||
# 23: floor_steel_dirty
|
||||
# 24: floor_techmaint
|
||||
# 25: floor_warning1
|
||||
# 26: floor_warning2
|
||||
# 27: floor_white
|
||||
# 28: floor_white_warning1
|
||||
# 29: floor_white_warning2
|
||||
# 30: floor_wood
|
||||
# 31: lattice
|
||||
# 32: plating
|
||||
# 33: plating
|
||||
# grids:
|
||||
# - settings:
|
||||
# chunksize: 16
|
||||
# tilesize: 1
|
||||
# chunks:
|
||||
# - ind: "-1,-1"
|
||||
# tiles: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFgAAAA==
|
||||
# entities:
|
||||
# - uid: 0
|
||||
# components:
|
||||
# - parent: null
|
||||
# type: Transform
|
||||
# - index: 0
|
||||
# type: MapGrid
|
||||
# - linearDamping: 0.05
|
||||
# fixtures: []
|
||||
# bodyType: Dynamic
|
||||
# type: Physics
|
||||
# - uid: 1
|
||||
# type: SpawnPointLatejoin
|
||||
# components:
|
||||
# - parent: 0
|
||||
# pos: 0,0
|
||||
# type: Transform
|
||||
1
Schemas/mapfile_requirements.txt
Normal file
1
Schemas/mapfile_requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
pyyaml
|
||||
11
Schemas/mapfile_validators.py
Normal file
11
Schemas/mapfile_validators.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from yamale.validators import Validator
|
||||
import yaml
|
||||
|
||||
class Component(Validator):
|
||||
tag = "comp"
|
||||
|
||||
def _is_valid(self, value):
|
||||
data = yaml.safe_load(value)
|
||||
if data["type"]:
|
||||
return True
|
||||
return False
|
||||
18
Schemas/rga.yml
Normal file
18
Schemas/rga.yml
Normal file
@@ -0,0 +1,18 @@
|
||||
list(include('attribution'), min=1)
|
||||
---
|
||||
attribution:
|
||||
files: list(str())
|
||||
license: license()
|
||||
copyright: str()
|
||||
source: url()
|
||||
|
||||
# Example
|
||||
# - files: ["deprecated.png"]
|
||||
# license: "MIT"
|
||||
# copyright: "created by 20kdc"
|
||||
# source: "https://github.com/ParadiseSS13/Paradise"
|
||||
#
|
||||
# - files: ["arcadeblue2.png", "boxing.png", "carpetclown.png", "carpetoffice.png", "gym.png", "metaldiamond.png"]
|
||||
# license: "CC-BY-NC-SA-3.0"
|
||||
# copyright: "by WALPVRGIS for Goonstation, taken at commit 236551b95a5b24917c72f3069223026b2dc4e690 from floors.dmi"
|
||||
# source: "https://github.com/goonstation/goonstation"
|
||||
1
Schemas/rga_requirements.txt
Normal file
1
Schemas/rga_requirements.txt
Normal file
@@ -0,0 +1 @@
|
||||
validators
|
||||
24
Schemas/rga_validators.py
Normal file
24
Schemas/rga_validators.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from yamale.validators import Validator
|
||||
import validators
|
||||
|
||||
class License(Validator):
|
||||
tag = "license"
|
||||
licenses = [
|
||||
"CC-BY-SA-3.0",
|
||||
"CC-BY-SA-4.0",
|
||||
"CC-BY-NC-3.0",
|
||||
"CC-BY-NC-4.0",
|
||||
"CC-BY-NC-SA-3.0",
|
||||
"CC-BY-NC-SA-4.0",
|
||||
"CC0-1.0",
|
||||
"MIT"
|
||||
]
|
||||
|
||||
def _is_valid(self, value):
|
||||
return value in self.licenses
|
||||
|
||||
class Url(Validator):
|
||||
tag = "url"
|
||||
|
||||
def _is_valid(self, value):
|
||||
return validators.url(value)
|
||||
184
Schemas/rsi.json
Normal file
184
Schemas/rsi.json
Normal file
@@ -0,0 +1,184 @@
|
||||
{
|
||||
"$schema":"http://json-schema.org/draft-07/schema",
|
||||
"default":{},
|
||||
"description":"JSON Schema for SS14 RSI validation.",
|
||||
"examples":[
|
||||
{
|
||||
"version":1,
|
||||
"license":"CC-BY-SA-3.0",
|
||||
"copyright":"Taken from CODEBASE at COMMIT PERMALINK",
|
||||
"size":{
|
||||
"x":32,
|
||||
"y":32
|
||||
},
|
||||
"states":[
|
||||
{
|
||||
"name":"basic"
|
||||
},
|
||||
{
|
||||
"name":"basic-directions",
|
||||
"directions":4
|
||||
},
|
||||
{
|
||||
"name":"basic-delays",
|
||||
"delays":[
|
||||
[
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name":"basic-delays-directions",
|
||||
"directions":4,
|
||||
"delays":[
|
||||
[
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1
|
||||
],
|
||||
[
|
||||
0.1,
|
||||
0.1
|
||||
]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"required":[
|
||||
"version",
|
||||
"license",
|
||||
"copyright",
|
||||
"size",
|
||||
"states"
|
||||
],
|
||||
"title":"RSI Schema",
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"version":{
|
||||
"$id":"#/properties/version",
|
||||
"default":"",
|
||||
"description":"RSI version integer.",
|
||||
"title":"The version schema",
|
||||
"type":"integer"
|
||||
},
|
||||
"license":{
|
||||
"$id":"#/properties/license",
|
||||
"default":"",
|
||||
"description":"The license for the associated icon states. Restricted to SS14-compatible asset licenses.",
|
||||
"enum":[
|
||||
"CC-BY-SA-3.0",
|
||||
"CC-BY-SA-4.0",
|
||||
"CC-BY-NC-3.0",
|
||||
"CC-BY-NC-4.0",
|
||||
"CC-BY-NC-SA-3.0",
|
||||
"CC-BY-NC-SA-4.0",
|
||||
"CC0-1.0"
|
||||
],
|
||||
"examples":[
|
||||
"CC-BY-SA-3.0"
|
||||
],
|
||||
"title":"License",
|
||||
"type":"string"
|
||||
},
|
||||
"copyright":{
|
||||
"$id":"#/properties/copyright",
|
||||
"type":"string",
|
||||
"title":"Copyright Info",
|
||||
"description":"The copyright holder. This is typically a link to the commit of the codebase that the icon is pulled from.",
|
||||
"default":"",
|
||||
"examples":[
|
||||
"Taken from CODEBASE at COMMIT LINK"
|
||||
]
|
||||
},
|
||||
"size":{
|
||||
"$id":"#/properties/size",
|
||||
"default":{
|
||||
|
||||
},
|
||||
"description":"The dimensions of the sprites inside the RSI. This is not the size of the PNG files that store the sprite sheet.",
|
||||
"examples":[
|
||||
{
|
||||
"x":32,
|
||||
"y":32
|
||||
}
|
||||
],
|
||||
"title":"Sprite Dimensions",
|
||||
"required":[
|
||||
"x",
|
||||
"y"
|
||||
],
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"x":{
|
||||
"$id":"#/properties/size/properties/x",
|
||||
"type":"integer",
|
||||
"default":32,
|
||||
"examples":[
|
||||
32
|
||||
]
|
||||
},
|
||||
"y":{
|
||||
"$id":"#/properties/size/properties/y",
|
||||
"type":"integer",
|
||||
"default":32,
|
||||
"examples":[
|
||||
32
|
||||
]
|
||||
}
|
||||
},
|
||||
"additionalProperties":true
|
||||
},
|
||||
"states":{
|
||||
"$id":"#/properties/states",
|
||||
"type":"array",
|
||||
"title":"Icon States",
|
||||
"description":"Metadata for icon states. Includes name, directions, delays, etc.",
|
||||
"default":[
|
||||
|
||||
],
|
||||
"examples":[
|
||||
[
|
||||
{
|
||||
"name":"basic"
|
||||
},
|
||||
{
|
||||
"name":"basic-directions",
|
||||
"directions":4
|
||||
}
|
||||
]
|
||||
],
|
||||
"additionalItems":true,
|
||||
"items":{
|
||||
"$id":"#/properties/states/items",
|
||||
"type":"object",
|
||||
"required":[
|
||||
"name"
|
||||
],
|
||||
"properties":{
|
||||
"name":{
|
||||
"type":"string"
|
||||
},
|
||||
"directions":{
|
||||
"type":"integer",
|
||||
"enum":[
|
||||
1,
|
||||
4,
|
||||
8
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties":true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user