From b2bd28d7705dd038ee4f5f37d6801ed6f1785fa9 Mon Sep 17 00:00:00 2001 From: Graham Trott Date: Sat, 6 Jun 2020 15:17:31 +0100 Subject: [PATCH] Start to code parent blocks --- iwsy/iwsy.js | 1 + iwsy/resources/ecs/blocks.txt | 50 +++++++++++--- iwsy/resources/json/demo.json | 4 +- iwsy/resources/json/propertyDefaults.json | 1 + iwsy/resources/json/propertyNames.json | 1 + iwsy/resources/json/test.json | 82 +++++++++++++---------- 6 files changed, 91 insertions(+), 48 deletions(-) diff --git a/iwsy/iwsy.js b/iwsy/iwsy.js index f430adf..fb31b13 100644 --- a/iwsy/iwsy.js +++ b/iwsy/iwsy.js @@ -752,6 +752,7 @@ const IWSY = (player, text) => { block.element = null; } } + player.innerHTML = null; script.steps.forEach((step, index) => { step.index = index; if (typeof step.label !== `undefined`) { diff --git a/iwsy/resources/ecs/blocks.txt b/iwsy/resources/ecs/blocks.txt index d72b6d0..37cfe9a 100644 --- a/iwsy/resources/ecs/blocks.txt +++ b/iwsy/resources/ecs/blocks.txt @@ -10,7 +10,8 @@ div Row div Cell div Empty - input PropertyValue + input PropertyInput + select BlockSelect button EditButton button SaveButton img ShowBlock @@ -21,14 +22,18 @@ variable Blocks variable Block variable Block2 + variable BlockNames + variable ParentBlock variable Defaults variable PropertyDefaults variable PropertyNames variable PropertyName variable SelectedBlock variable SavedIndex + variable Parent variable Message variable N + variable M variable NBlocks put -1 into SelectedBlock @@ -162,7 +167,7 @@ Restart: put element SelectedBlock of Blocks into Block put property `defaults` of Block into Defaults put the json count of PropertyNames into N - set the elements of PropertyValue to N + set the elements of PropertyInput to N put 0 into N while N is less than the json count of PropertyNames begin @@ -172,10 +177,33 @@ Restart: create Cell in Row set the style of Cell to `width:8em;padding-left:0.5em` set the content of Cell to PropertyName - index PropertyValue to N - create PropertyValue in Row - set the style of PropertyValue to `flex:1` - set the text of PropertyValue to property PropertyName of Defaults + if PropertyName is `parent` + begin + put property PropertyName of Defaults into Parent + set BlockNames to array + json add `` to BlockNames + put 0 into M + while M is less than the json count of Blocks + begin + if M is not SelectedBlock + begin + put element M of Blocks into ParentBlock + put property `defaults` of ParentBlock into Defaults + json add property `name` of Defaults to BlockNames + end + add 1 to M + end + create BlockSelect in Row + set the style of BlockSelect to `flex:1;height:1.5em` + set BlockSelect from BlockNames as Parent + end + else + begin + index PropertyInput to N + create PropertyInput in Row + set the style of PropertyInput to `flex:1;height:1.5em` + set the text of PropertyInput to property PropertyName of Defaults + end add 1 to N end create Row in Editor @@ -221,9 +249,13 @@ SaveSelectedBlock: while N is less than the json count of PropertyNames begin put element N of PropertyNames into PropertyName - index PropertyValue to N - set property PropertyName of Defaults to the text of PropertyValue - add 1 to N + if PropertyName is `parent` set property PropertyName of Defaults to BlockSelect + else + begin + index PropertyInput to N + set property PropertyName of Defaults to the text of PropertyInput + end + add 1 to N end set the text of EditButton to property `name` of Defaults set property `defaults` of Block to Defaults diff --git a/iwsy/resources/json/demo.json b/iwsy/resources/json/demo.json index 8837bc8..e34df5c 100644 --- a/iwsy/resources/json/demo.json +++ b/iwsy/resources/json/demo.json @@ -86,7 +86,7 @@ "background": "", "border": "", "borderRadius": "", - "fontColor": "#ffffff", + "fontColor": "#ccffff", "fontFamily": "", "fontSize": 40, "fontStyle": "", @@ -188,7 +188,7 @@ "title": "My demo presentation", "action": "init", "label": "", - "aspect ratio": "16:9", + "aspect ratio": "160:89", "background": "", "border": "" }, diff --git a/iwsy/resources/json/propertyDefaults.json b/iwsy/resources/json/propertyDefaults.json index 46fd312..3a2087c 100644 --- a/iwsy/resources/json/propertyDefaults.json +++ b/iwsy/resources/json/propertyDefaults.json @@ -1,5 +1,6 @@ { "name": "New block", + "parent": "", "left": 0, "top": 0, "width": "100%", diff --git a/iwsy/resources/json/propertyNames.json b/iwsy/resources/json/propertyNames.json index e132838..26c4ec0 100644 --- a/iwsy/resources/json/propertyNames.json +++ b/iwsy/resources/json/propertyNames.json @@ -1,5 +1,6 @@ [ "name", + "parent", "left", "top", "width", diff --git a/iwsy/resources/json/test.json b/iwsy/resources/json/test.json index 1b8f28a..6b25e74 100644 --- a/iwsy/resources/json/test.json +++ b/iwsy/resources/json/test.json @@ -17,7 +17,8 @@ "fontColor": "", "textAlign": "", "textMarginLeft": "", - "textMarginTop": "" + "textMarginTop": "", + "parent": "" } }, { @@ -37,7 +38,8 @@ "fontColor": "", "textAlign": "", "textMarginLeft": "", - "textMarginTop": "" + "textMarginTop": "", + "parent": "" } }, { @@ -57,7 +59,8 @@ "fontColor": "#dddd88", "textAlign": "center", "textMarginLeft": "", - "textMarginTop": "" + "textMarginTop": "", + "parent": "" } }, { @@ -68,7 +71,7 @@ "borderRadius": "", "fontColor": "#dddd88", "fontFamily": "", - "fontSize": 80, + "fontSize": 70, "fontStyle": "", "fontWeight": "", "height": 300, @@ -77,7 +80,8 @@ "textMarginLeft": "", "textMarginTop": "", "top": 300, - "width": "100%" + "width": "100%", + "parent": "" } }, { @@ -86,9 +90,9 @@ "background": "", "border": "", "borderRadius": "", - "fontColor": "#ffffff", + "fontColor": "#ccffff", "fontFamily": "", - "fontSize": 50, + "fontSize": 40, "fontStyle": "", "fontWeight": "", "height": 220, @@ -96,33 +100,35 @@ "textAlign": "center", "textMarginLeft": "", "textMarginTop": "", - "top": 30, - "width": "100%" + "top": 20, + "width": "100%", + "parent": "" } }, { "defaults": { "name": "main content", - "left": 50, - "top": 250, - "width": 900, - "height": 700, - "background": "", - "border": "", + "background": "rgba(80,80,80,0.5)", + "border": "1px solid white", "borderRadius": "", + "fontColor": "yellow", "fontFamily": "", "fontSize": 50, - "fontWeight": "", "fontStyle": "", - "fontColor": "yellow", - "textAlign": "", + "fontWeight": "", + "height": 700, + "left": 50, + "textAlign": "left", "textMarginLeft": 20, - "textMarginTop": 20 + "textMarginTop": 20, + "top": 250, + "width": 900, + "parent": "" } }, { "defaults": { - "name": "left", + "name": "main content left", "background": "rgba(80,80,80,0.5)", "border": "1px solid white", "borderRadius": "", @@ -133,16 +139,17 @@ "fontWeight": "", "height": 700, "left": 50, - "textAlign": "", + "textAlign": "left", "textMarginLeft": 20, "textMarginTop": 20, "top": 250, - "width": 400 + "width": 400, + "parent": "main content" } }, { "defaults": { - "name": "right", + "name": "main content right", "background": "rgba(80,80,80,0.5)", "border": "1px solid white", "borderRadius": "", @@ -153,15 +160,20 @@ "fontWeight": "", "height": 700, "left": 550, - "textAlign": "", + "textAlign": "left", "textMarginLeft": 20, "textMarginTop": 20, "top": 250, - "width": 400 + "width": 400, + "parent": "main content" } } ], "content": [ + { + "name": "blank", + "content": "" + }, { "name": "a new dawn", "content": "# A new dawn is coming..." @@ -172,15 +184,11 @@ }, { "name": "page 1 left", - "content": "### PowerPoint%0a%0a - is slide-based%0a - is a PC application%0a - is hard to embed%0a%0aPowerPoint is organized mainly around static text blocks and tied to the desktop." + "content": "### PowerPoint%0a%0a - is slide-based%0a - is a PC application%0a - is hard to embed%0a%0aPowerPoint is organized mainly around static text blocks and is tied to the desktop." }, { "name": "page 1 right", "content": "### I Wanna Show You%0a - is step based%0a - runs in your browser%0a - is fully embeddable%0a%0aIWannaShowYou is built to handle color, movement and the online environment." - }, - { - "name": "blank", - "content": "" } ], "steps": [ @@ -188,7 +196,7 @@ "title": "My demo presentation", "action": "init", "label": "", - "aspect ratio": "16:9", + "aspect ratio": "160:89", "background": "", "border": "" }, @@ -210,11 +218,11 @@ "content": "a new dawn" }, { - "block": "left", + "block": "main content left", "content": "page 1 left" }, { - "block": "right", + "block": "main content right", "content": "page 1 right" } ] @@ -262,7 +270,7 @@ "title": "Wait 3 seconds", "action": "pause", "label": "", - "duration": 1 + "duration": 3 }, { "title": "Change title", @@ -274,7 +282,7 @@ }, { "title": "Wait 1 second", - "action": "hold", + "action": "pause", "label": "", "duration": 1 }, @@ -297,8 +305,8 @@ "action": "fade up", "label": "", "blocks": [ - "left", - "right" + "main content left", + "main content right" ], "duration": 1 }