Skip to content

Commit dffdaf1

Browse files
authored
Merge pull request #55 from SpringRoll/chore/container-plugin-tidying
Chore/container plugin tidying
2 parents 8bbd2bd + 994ea85 commit dffdaf1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1510
-1162
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ local.log
88
.DS_Store
99
index.html
1010
frame.html
11-
test.html
12-
paused.html

README.md

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -96,28 +96,29 @@ container.openPath('game.html');
9696
```
9797
PausePlugin sets a className of 'paused' or 'unpaused' on individual pause buttons.
9898

99-
### CaptionsPlugin:
100-
The captions plugin allows users to show or hide captions, and control the size and placement of captions.
99+
### Captions:
100+
There are two plugins that interact with captions: CaptionsTogglePlugin, and CaptionsStylePlugin.
101+
CaptionsTogglePlugin allows the user to hide or show the captions in the game.
102+
CaptionsStylePlugin allows the user to control the size, placement, and color of the captions.
101103

102104
```javascript
103-
import { CaptionsPlugin, Container } from 'springroll-container';
105+
import { CaptionsStylePlugin, CaptionsToggleplugin, Container } from 'springroll-container';
104106

105107
const container = new springroll.Container('#game', {
106108
plugins: [
107-
new CaptionsPlugin({
108-
captionsButtons: '#captions',
109-
109+
new CaptionsTogglePlugin('#captions'),
110+
new CaptionsStylePlugin(
110111
// expects exactly three(3) radio buttons with values "small", "medium", and "large" indicating caption font sizes.
111-
fontSizeRadios: 'input[name=captions-font-size]',
112+
'input[name=captions-font-size]',
112113

113114
// expects exactly two(2) radio buttons with values "default" (black background, white text),
114115
// and "inverted" (black text, white background) for caption color schemes
115-
colorRadios: 'input[name=captions-font-color]',
116+
'input[name=captions-font-color]',
116117

117118
// expects exactly two(2) radio buttons values "top" and "bottom".
118119
// Indicating that captions should be placed at the top or bottom of the screen.
119-
alignmentRadios: 'input[name=captions-alignment]',
120-
})
120+
'input[name=captions-alignment]',
121+
),
121122
]
122123
});
123124
container.openPath('game.html');
@@ -180,43 +181,31 @@ container.openPath('game.html');
180181
```
181182
SoundPlugin will set a class of `muted` or `unmuted` on each button as they are toggled
182183

183-
### MechanicsPlugin:
184-
The mechanics plugin allows integrators to provide users the ability to control various mechanical aspects of the game (see the table below for details).
184+
### Mechanics:
185+
Mechanics are various aspects of the game that the determine how a user plays the game (see table below for details).
185186
Some games will support many of these features, some none at all. We doubt one game will use all of them though.
186187

187-
Each controllable mechanic should be provided a [HTML range input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range),
188-
and an optional default value. Each mechanic's value will range between 0 to 1, and the default initial value is aways 0.5.
188+
Each plugin is responsible for one of the listed mechanics and should be provided a
189+
[HTML range input](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range), and an optional default value.
190+
Each mechanic's value will range between 0 to 1, and the default initial value is aways 0.5.
189191

190192
```javascript
191-
import { MechanicsPlugin, Container } from 'springroll-container';
193+
import {
194+
HitAreaScalePlugin, DragThresholdScalePlugin, HealtPlugin, ObjectCountPlugin,
195+
CompletionPercentagePlugin, SpeedScalePlugin, TimersScalePlugin, InputCountPlugin,
196+
Container
197+
} from 'springroll-container';
192198

193199
const container = new springroll.Container('#game', {
194200
plugins: [
195-
new MechanicsPlugin({
196-
hitAreaScaleSliders: '#hitAreaScaleSlider',
197-
defaultHitAreaScale = 0.5,
198-
199-
dragThresholdScaleSliders: '#dragThresholdScaleSlider',
200-
defaultDragThresholdScale = 0.5,
201-
202-
healthSliders: '#healthSlider',
203-
defaultHealth = 0.5,
204-
205-
objectCountSliders: '#objectCountSlider',
206-
defaultObjectCount = 0.5,
207-
208-
completionPercentageSliders: '#completionPercentageSlider',
209-
defaultCompletionPercentage = 0.5,
210-
211-
speedScaleSliders: '#speedScaleSlider',
212-
defaultSpeedScale = 0.5,
213-
214-
timersScaleSliders: '#timersScaleSlider',
215-
defaultTimersScale = 0.5,
216-
217-
inputCountSliders: '#inputCountSlider',
218-
defaultInputCount = 0.5,
219-
}),
201+
new HitAreaScalePlugin('#hitAreaScaleSlider', {defaultHitAreaScale = 0.5}),
202+
new DragThresholdScalePlugin('#dragThresholdScaleSlider', {defaultDragThresholdScale = 0.5}),
203+
new HealthPlugin('#healthSlider', {defaultHealth = 0.5}),
204+
new ObjectCountPlugin('#objectCountSlider', {defaultObjectCount = 0.5}),
205+
new CompletionPercentagePlugin('#completionPercentageSlider', {defaultCompletionPercentage = 0.5}),
206+
new SpeedScalePlugin('#speedScaleSlider', {defaultSpeedScale = 0.5}),
207+
new TimersScalePlugin('#timersScaleSlider', {defaultTimersScale = 0.5}),
208+
new InputCountPlugin('#inputCountSlider', {defaultInputCount = 0.5}),
220209
]
221210
});
222211
container.openPath('game.html');

dist/SpringRoll-Container-umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/SpringRoll-Container-umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/base-plugins/SliderPlugin.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { BasePlugin } from '.';
1+
import { BasePlugin } from './BasePlugin';
22
import { Slider } from '../ui-elements';
33

44
/**
@@ -32,7 +32,7 @@ export class SliderPlugin extends BasePlugin {
3232
this.slidersLength = this.sliders.length;
3333
this.sendAllProperties = this.sendAllProperties.bind(this);
3434

35-
if (0 >= this.buttonSlidersLength) {
35+
if (0 >= this.slidersLength) {
3636
this.warn('Plugin was not provided any valid HTML Elements');
3737
return;
3838
}
@@ -69,6 +69,24 @@ export class SliderPlugin extends BasePlugin {
6969
return sliders;
7070
}
7171

72+
/**
73+
* @memberof SliderPlugin
74+
*/
75+
init() {
76+
this.client.on(
77+
'features',
78+
function(features) {
79+
if (!features.data) {
80+
return;
81+
}
82+
83+
for (let i = 0; i < this.slidersLength; i++) {
84+
this.sliders[i].displaySlider(features.data);
85+
}
86+
}.bind(this)
87+
);
88+
}
89+
7290
/**
7391
* @memberof SliderPlugin
7492
*/

src/base-plugins/SliderPlugin.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ describe('SliderPlugin', () => {
2020

2121
it('construct', () => {
2222
const iframe = document.createElement('iframe');
23-
iframe.id = 'radio-group-plugin-iframe';
23+
iframe.id = 'slider-plugin-iframe';
2424
document.body.appendChild(iframe);
25-
new Container('#radio-group-plugin-iframe').client.trigger(
25+
new Container('#slider-plugin-iframe').client.trigger(
2626
'features'
2727
);
2828

src/plugins/ButtonSizePlugin.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,6 @@ export class ButtonSizePlugin extends SliderPlugin {
3131
this.sendProperty(ButtonSizePlugin.buttonSizeKey, this.currentValue);
3232
}
3333

34-
/**
35-
* @memberof ButtonSizePlugin
36-
*/
37-
init() {
38-
this.client.on(
39-
'features',
40-
function(features) {
41-
if (!features.data) {
42-
return;
43-
}
44-
for (let i = 0; i < this.slidersLength; i++) {
45-
this.sliders[i].displaySlider(features.data);
46-
}
47-
}.bind(this)
48-
);
49-
}
50-
5134
/**
5235
* @readonly
5336
* @static

0 commit comments

Comments
 (0)