Gulix / geckos

An online Card Editor with Templates
http://gulix.github.io/geckos/
Other
48 stars 18 forks source link

Multiple Inheritance #104

Open Gulix opened 8 years ago

Gulix commented 8 years ago

Thinking if multiple inheritance is possible, and how to do it.

Example ! I have a default template. A textbox and a label.

"fields":[
    {
      "name":"name",
      "label":"Name",
      "default":"Captain Wolf"
    }
],
"canvasFields":[
    {
      "id":"name",
      "type":"textbox",
      "text":"$name$"
    },
    {
      "id":"label",
      "type":"textbox",
      "text":"My label content"
    }
]

I create a translated version of this template : only the content of the label changes.

"basedOn": "default",
"canvasFields":[
    {
      "id":"label",
      "text":"Contenu du label"
    },
]

Now, I create a colored version on my template :

"basedOn": "default",
"fields":[
    {
      "name":"color",
      "label":"color",
      "default":"#FF0000",
      "type": "color"
    }
],
"canvasFields":[
    {
      "id":"label",
      "fill": "$color.hexa$"
    },
    {
      "id":"name",
      "fill": "$color.hexa$"
    },
]

If I want to have a colored version translated, I need to base my new template on the colored version, and translate again my label. With many fields to translate, it will become uneasy. I should be able to base my template on several other templates, indicating an order :

"basedOn": [ "colored", "translated" ]