Skip to content

Commit 41528e4

Browse files
committed
Development
1 parent ff7258a commit 41528e4

File tree

5 files changed

+101
-35
lines changed

5 files changed

+101
-35
lines changed

dist/plugins/iwsy.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const EasyCoder_IWSY = {
2929
}
3030
}
3131
break;
32-
default:
32+
case `init`:
3333
compiler.next();
3434
compiler.addCommand({
3535
domain: `iwsy`,
@@ -38,6 +38,18 @@ const EasyCoder_IWSY = {
3838
action
3939
});
4040
return true;
41+
case `goto`:
42+
const target = compiler.getNextValue();
43+
compiler.addCommand({
44+
domain: `iwsy`,
45+
keyword: `iwsy`,
46+
lino,
47+
action,
48+
target
49+
});
50+
return true;
51+
default:
52+
break;
4153
}
4254
return false;
4355
},
@@ -55,10 +67,14 @@ const EasyCoder_IWSY = {
5567
case `load`:
5668
const playerRecord = program.getSymbolRecord(command.player);
5769
const player = playerRecord.element[playerRecord.index];
70+
player.innerHTML = ``;
71+
player.style.background = `none`;
72+
player.style.border = `none`;
5873
const script = program.getValue(command.script);
59-
IWSY(player, JSON.parse(script));
74+
EasyCoder.iwsyGotoStep = IWSY(player, JSON.parse(script));
6075
break;
61-
case `show`:
76+
case `goto`:
77+
EasyCoder.iwsyGotoStep(program.getValue(command.target));
6278
break;
6379
}
6480
return command.pc + 1;

iwsy/iwsy.js

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -105,38 +105,40 @@ const IWSY = (container, script) => {
105105
block.element = element;
106106
element.style[`position`] = `absolute`;
107107
element.style[`opacity`] = `0.0`;
108-
let val = properties.blockLeft;
108+
let val = properties.left;
109109
if (!isNaN(val)) {
110110
val *= w;
111111
}
112112
element.style[`left`] = val;
113-
val = properties.blockTop;
113+
val = properties.top;
114114
if (!isNaN(val)) {
115115
val *= h;
116116
}
117117
element.style[`top`] = val;
118-
val = properties.blockWidth;
118+
val = properties.width;
119119
if (!isNaN(val)) {
120-
val *= w;
120+
val = `${val * w}px`;
121121
}
122-
element.style[`width`] = `${val}px`;
123-
val = properties.blockHeight;
122+
element.style[`width`] = val;
123+
val = properties.height;
124124
if (!isNaN(val)) {
125-
val *= h;
125+
val = `${val * h}px`;
126126
}
127-
element.style[`height`] = `${val}px`;
128-
element.style[`background`] = properties.blockBackground;
129-
element.style[`border`] = properties.blockBorder;
127+
element.style[`height`] = val;
128+
element.style[`background`] = properties.background;
129+
element.style[`border`] = properties.border;
130130
container.appendChild(element);
131131
val = properties.textMarginLeft;
132132
if (!isNaN(val)) {
133-
val *= w;
133+
val = `${val * w}px`;
134134
}
135+
element.style[`width`] = val;
135136
const marginLeft = val;
136137
val = properties.textMarginTop;
137138
if (!isNaN(val)) {
138-
val *= h;
139+
val = `${val * h}px`;
139140
}
141+
element.style[`height`] = val;
140142
const marginTop = val;
141143
const inner = document.createElement(`div`);
142144
inner.style[`position`] = `absolute`;
@@ -176,30 +178,30 @@ const IWSY = (container, script) => {
176178
block.element = element;
177179
element.style[`position`] = `absolute`;
178180
element.style[`opacity`] = `0.0`;
179-
let val = properties.blockLeft;
181+
let val = properties.left;
180182
if (!isNaN(val)) {
181183
val *= w;
182184
}
183185
element.style[`left`] = val;
184-
val = properties.blockTop;
186+
val = properties.top;
185187
if (!isNaN(val)) {
186188
val *= h;
187189
}
188190
element.style[`top`] = val;
189191
element.style[`top`] = val;
190-
val = properties.blockWidth;
192+
val = properties.width;
191193
if (!isNaN(val)) {
192-
val *= w;
194+
val = `${val * w}px`;
193195
}
194-
element.style[`width`] = `${val}px`;
195-
val = properties.blockHeight;
196+
element.style[`width`] = val;
197+
val = properties.height;
196198
if (!isNaN(val)) {
197-
val *= h;
199+
val = `${val * h}px`;
198200
}
199-
element.style[`height`] = `${val}px`;
200-
element.style[`background`] = properties.blockBackground;
201-
element.style[`border`] = properties.blockBorder;
202-
element.style[`border-radius`] = properties.blockBorderRadius;
201+
element.style[`height`] = val;
202+
element.style[`background`] = properties.background;
203+
element.style[`border`] = properties.border;
204+
element.style[`border-radius`] = properties.borderRadius;
203205
container.appendChild(element);
204206
if (script.speed === `scan`) {
205207
element.style.opacity = 0;
@@ -634,6 +636,13 @@ const IWSY = (container, script) => {
634636
}
635637
};
636638

639+
// Go to a specified step number
640+
const gotoStep = (target) => {
641+
script.scanTarget = target;
642+
script.singleStep = true;
643+
scan();
644+
};
645+
637646
// Load a plugin action
638647
const load = step => {
639648
if (script.speed === `scan`) {
@@ -652,7 +661,7 @@ const IWSY = (container, script) => {
652661
}
653662
};
654663

655-
// Initialize the presenttion
664+
// Initialize the presentation
656665
const init = step => {
657666
if (step.title) {
658667
document.title = step.title;
@@ -677,6 +686,16 @@ const IWSY = (container, script) => {
677686
step.next();
678687
};
679688

689+
// Chain to another presentation
690+
const chain = step => {
691+
step.next()
692+
};
693+
694+
// Embed another presentation
695+
const embed = step => {
696+
step.next()
697+
};
698+
680699
const actions = {
681700
init,
682701
setcontent,
@@ -689,7 +708,9 @@ const IWSY = (container, script) => {
689708
crossfade,
690709
transition,
691710
goto,
692-
load
711+
load,
712+
chain,
713+
embed
693714
};
694715

695716
// Process a single step
@@ -734,6 +755,7 @@ const IWSY = (container, script) => {
734755
container.style.cursor = 'none';
735756
container.style[`background-size`] = `cover`;
736757
script.speed = `normal`;
758+
script.singleStep = true;
737759
script.labels = {};
738760
for (const [index, step] of script.steps.entries()) {
739761
step.index = index;
@@ -743,10 +765,14 @@ const IWSY = (container, script) => {
743765
}
744766
if (index < script.steps.length - 1) {
745767
step.next = () => {
746-
const next = step.index + 1;
747-
setTimeout(() => {
748-
doStep(script.steps[next]);
749-
}, 0);
768+
if (script.singleStep && script.speed != `scan`) {
769+
console.log(`Single-step`);
770+
} else {
771+
const next = step.index + 1;
772+
setTimeout(() => {
773+
doStep(script.steps[next]);
774+
}, 0);
775+
}
750776
}
751777
}
752778
else {
@@ -760,4 +786,5 @@ const IWSY = (container, script) => {
760786
initBlocks();
761787
preloadImages();
762788
doStep(script.steps[0]);
789+
return gotoStep;
763790
};

iwsy/resources/ecs/main.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ L2:
311311
gosub to SetupContent
312312
put 0 into N
313313
gosub to SelectSection
314+
315+
on message iwsy goto the message
314316
stop
315317

316318
CreateNewPresentation:

iwsy/resources/ecs/steps.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,11 @@ Restart:
184184
set property `steps` of Presentation to Steps
185185
go to Restart
186186
end
187+
on click ShowStep
188+
begin
189+
put the index of ShowStep into N
190+
send N to parent
191+
end
187192

188193
! Set up the fixed lists
189194
set ActionNames to array

js/plugins/iwsy.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const EasyCoder_IWSY = {
2929
}
3030
}
3131
break;
32-
default:
32+
case `init`:
3333
compiler.next();
3434
compiler.addCommand({
3535
domain: `iwsy`,
@@ -38,6 +38,18 @@ const EasyCoder_IWSY = {
3838
action
3939
});
4040
return true;
41+
case `goto`:
42+
const target = compiler.getNextValue();
43+
compiler.addCommand({
44+
domain: `iwsy`,
45+
keyword: `iwsy`,
46+
lino,
47+
action,
48+
target
49+
});
50+
return true;
51+
default:
52+
break;
4153
}
4254
return false;
4355
},
@@ -55,10 +67,14 @@ const EasyCoder_IWSY = {
5567
case `load`:
5668
const playerRecord = program.getSymbolRecord(command.player);
5769
const player = playerRecord.element[playerRecord.index];
70+
player.innerHTML = ``;
71+
player.style.background = `none`;
72+
player.style.border = `none`;
5873
const script = program.getValue(command.script);
59-
IWSY(player, JSON.parse(script));
74+
EasyCoder.iwsyGotoStep = IWSY(player, JSON.parse(script));
6075
break;
61-
case `show`:
76+
case `goto`:
77+
EasyCoder.iwsyGotoStep(program.getValue(command.target));
6278
break;
6379
}
6480
return command.pc + 1;

0 commit comments

Comments
 (0)