Skip to content

Commit c363249

Browse files
authored
Merge pull request #38 from ChapelR/v2.6.0
v2.6.0
2 parents 99cd80a + 8d6635b commit c363249

Some content is hidden

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

49 files changed

+499
-73
lines changed

.gitignore

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ Network Trash Folder
4646
Temporary Items
4747
.apdisk
4848

49-
/old
50-
/node_modules
51-
build.bat
49+
old/
50+
node_modules/
51+
**.bat
5252
**.sublime-*
53-
54-
test/
53+
**.log
54+
test/
55+
proto/

.jshintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scripts/minified/

build.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
1-
// build me
1+
// jshint esversion: 6, node: true
22

3-
var jetpack = require('fs-jetpack'),
3+
const jetpack = require('fs-jetpack'),
44
Terser = require('terser');
55

6+
7+
8+
const buildDate = new Date().toISOString().split('T')[0],
9+
buildID = require('git-commit-id')();
10+
611
function build () {
7-
var jsFiles = jetpack.find('./scripts', {
12+
const jsFiles = jetpack.find('./scripts', {
813
matching : '*.js',
914
recursive : false
1015
});
1116

12-
jsFiles.forEach( function (file) {
13-
var source = jetpack.read(file),
14-
path = file.split(/[\\\/]/g),
15-
name = path.pop().split('.').join('.min.'),
16-
result, ret;
17+
jsFiles.forEach( file => {
18+
const source = jetpack.read(file);
19+
let path = file.split(/[\\\/]/g);
20+
21+
const name = path.pop().split('.').join('.min.');
22+
23+
let version = source.match(/(v|version\s+)(\d+\.\d+.\d+)/);
24+
if (version == null) {
25+
version = '0.0.0';
26+
console.log(`missing version info: ${file}`);
27+
} else {
28+
version = version[2];
29+
}
1730

18-
result = Terser.minify(source);
31+
const result = Terser.minify(source);
1932

2033
console.log(result.error);
2134

@@ -24,7 +37,7 @@ function build () {
2437
path.push(name);
2538
path = path.join('/');
2639

27-
ret = '// ' + name + ', for SugarCube 2, by Chapel\n;' + result.code + '\n// end ' + name;
40+
const ret = `// ${name}, for SugarCube 2, by Chapel\n// v${version}, ${buildDate}, ${buildID}\n;${result.code}\n// end ${name}`;
2841

2942
jetpack.write(path, ret, {atomic : true});
3043
});

docs/README.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
1-
## Chapel's Custom Macro Collection (v2.5.5)
1+
## Chapel's Custom Macro Collection (v2.6.0)
22

3-
- [Try the demo!](https://macros.twinelab.net/demo)
3+
- [Try the demo!](https://macros.twinelab.net/demo) ([Sausage](https://github.com/ChapelR/custom-macros-demo))
44
- [Downloads](./download ':ignore')
5-
- [Changelog](./changelog.md)
5+
- [Changelog](changelog.md)
66
- [Release Notes](https://twinelab.net/blog/tags/macros/)
77

88
### Documentation
99
- **Gameplay Systems and Mechanics**
10-
- [The Simple Inventory System](./simple-inventory.md)
11-
- [The Cycles System](./cycles-system.md)
12-
- [The Playtime System](./playtime-system.md)
10+
- [The Simple Inventory System](simple-inventory.md)
11+
- Updated [The Cycles System](cycles-system.md)
12+
- [The Playtime System](playtime-system.md)
1313
- **Interface and Style**
14-
- [The Dialog API Macro Set](./dialog-api-macro-set.md)
15-
- [The UI Macro](./ui-macro.md)
16-
- [The Fading Macro Set](./fading-macros.md)
17-
- [The CSS Macro](./css-macro.md)
18-
- [The Notify Macro](./notify-macro.md)
19-
- [The Meter Macro Set](./meter-macros.md)
20-
- [The Speech Box System](./speech-box-system.md)
14+
- [The Dialog API Macro Set](dialog-api-macro-set.md)
15+
- New [The Popover Macro](popover.md)
16+
- [The UI Macro](ui-macro.md)
17+
- [The Fading Macro Set](fading-macros.md)
18+
- [The CSS Macro](css-macro.md)
19+
- [The Notify Macro](notify-macro.md)
20+
- [The Meter Macro Set](meter-macros.md)
21+
- [The Speech Box System](speech-box-system.md)
2122
- **User Interaction and Events**
22-
- [The Event Macros](./event-macros.md)
23-
- [The Continue Macro Set](./continue-macro.md)
24-
- [The Swap Macro Set](./swap-macro-set.md)
25-
- [The Mouseover Macro](./mouseover-macro.md)
26-
- [The Message Macro](./message-macro.md)
27-
- [The Typing Simulation Macro](./type-sim.md)
23+
- [The Event Macros](event-macros.md)
24+
- [The Continue Macro Set](continue-macro.md)
25+
- [The Swap Macro Set](swap-macro-set.md)
26+
- [The Mouseover Macro](mouseover-macro.md)
27+
- [The Message Macro](message-macro.md)
28+
- [The Typing Simulation Macro](type-sim.md)
2829
- **Grammar and Language**
29-
- [The Pronoun Templates](./pronoun-templates.md)
30-
- [The Articles (A/An) Macros](./articles.md)
30+
- [The Pronoun Templates](pronoun-templates.md)
31+
- [The Articles (A/An) Macros](articles.md)
3132
- **Utilities and Other**
32-
- [The Done Macro](./done-macro.md)
33-
- [The File System Macro Set](./file-system-macros.md)
34-
- [The First Macro](./first-macro.md)
35-
- [Dice Roller and Fairmath Functions](./operations-api.md)
33+
- New [The Preload Macro](preload.md)
34+
- [The Done Macro](done-macro.md)
35+
- [The File System Macro Set](file-system-macros.md)
36+
- [The First Macro](first-macro.md)
37+
- [Dice Roller and Fairmath Functions](operations-api.md)
3638

3739
### Installation Guide
3840

docs/changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
[Back to the main page](./README.md).
44

5+
### July 24, 2020 (v2.6.0)
6+
7+
- **[New]** New macros.
8+
- Added the preload macro for preloading images.
9+
- Added the popover macro for creating special transparent dialogs and splash screens.
10+
- **[Meta]** Repository changes.
11+
- Overhauled build and code quality check processes.
12+
- Spun out demo project into its own repo.
13+
514
### June 28, 2020 (v2.5.5)
615

716
- **[Update]** Updated `Cycle.check()` and `cycle#check()` to accept multiple phases to check.

docs/demo/index.html

Lines changed: 68 additions & 16 deletions
Large diffs are not rendered by default.

docs/dialog-api-macro-set.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The `<<dialog>>` macro creates a new dialog box, with an optional title and an o
1818

1919
* **title**: (optional) A title to appear at the top of the dialog box. If you want to omit a title but include classes, this argument can be an empty string (`''`).
2020
* **classList**: (optional) A list of CSS classes to add to the dialog, for styling. The classes should be a space-separated list of quoted class names (i.e. `'class-a' 'class-b' 'class-c'`), a quoted list of space-separated class names (i.e. `'class-a class-b class-c'`), or one or more string arrays (i.e. `['class-a', 'class-b', 'class-c']`), or any combination of thereof.
21-
21+
2222
**Usage**:
2323
```
2424
/% creates a link that opens a dialog box called 'Character Sheet' with the classes .char-sheet and .stats %/
@@ -90,8 +90,9 @@ The `<<popup>>` macro provides a similar result to what you might get by pairing
9090
* **passageName**: The name of one of your passages. The indicated passage's content will be rendered into the dialog box's body.
9191
* **title**: (optional) A title to appear at the top of the dialog box. If you want to omit a title but include classes, this argument can be an empty string (`''`).
9292
* **classList**: (optional) A list of CSS classes to add to the dialog, for styling. The classes should be a space-separated list of quoted class names (i.e. `'class-a' 'class-b' 'class-c'`), a quoted list of space-separated class names (i.e. `'class-a class-b class-c'`), or one or more string arrays (i.e. `['class-a', 'class-b', 'class-c']`), or any combination of thereof.
93-
93+
9494
**Usage**:
95+
9596
```
9697
/%
9798
creates a link that opens a dialog box called 'Character Sheet'
@@ -106,4 +107,26 @@ The `<<popup>>` macro provides a similar result to what you might get by pairing
106107
<<button 'About'>>
107108
<<popup 'credits-passage' 'Credits'>>
108109
<</button>>
109-
```
110+
```
111+
112+
### Macro: `<<dialogclose>>`
113+
114+
**Syntax**: `<<dialogclose>>`
115+
116+
Closes the dialog.
117+
118+
**Usage**:
119+
120+
```
121+
<<link 'View Character Sheet'>>
122+
<<dialog 'Character Sheet' 'char-sheet stats'>>\
123+
|Strength|$str|
124+
|Dexterity|$dex|
125+
|Wisdom|$wis|\
126+
@@float:right;
127+
<<button "Close">><<dialogclose>><</button>>
128+
@@
129+
<</dialog>>
130+
<</link>>
131+
```
132+

docs/download/fetch.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
'The Fading Macro Set' : 'fading-macro-set',
1717
'The First Macro' : 'first-macro',
1818
'File System Macros' : 'fs',
19-
// 'Fullscreen Macros' : 'fullscreen',
2019
'The Message Macro' : 'message-macro',
2120
'The Meters Macro Set' : 'meters',
2221
'The Mouseover Macro' : 'mouseover',
22+
'The Popover Macro' : 'popover+css',
2323
'The Notify Macro' : 'notify+css',
2424
'Dice Roller and Fairmath Functions' : 'operations',
2525
'Playtime System' : 'playtime',
@@ -28,7 +28,8 @@
2828
'The Speech Box System' : 'speech+css',
2929
'Swap Macro Set' : 'swap-macro-set',
3030
'The Typesim Macro' : 'type-sim',
31-
'The UI Macro' : 'ui-macro'
31+
'The UI Macro' : 'ui-macro',
32+
'The Preload Macro' : 'preload'
3233
};
3334

3435
var macros = Object.keys(fileNameMap);

docs/popover.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
## The Popover Macro
2+
3+
[Back to the main readme](./README.md).
4+
5+
Creates a special transparent dialog modal for images and text.
6+
7+
![The Popover Macro](https://i.imgur.com/vW7soRX.png)
8+
9+
**THE CODE:** [Minified](https://github.com/ChapelR/custom-macros-for-sugarcube-2/blob/master/scripts/minified/popover.min.js). [Pretty](https://github.com/ChapelR/custom-macros-for-sugarcube-2/blob/master/scripts/popover.js).
10+
**DEMO:** [Available](http://macros.twinelab.net/demo?macro=popover).
11+
**GUIDE:** Not available.
12+
13+
### Macro: `<<popover>>`
14+
15+
**Syntax**: `<<popover [flags] [classList]>><</popover>>`
16+
17+
The `<<popover>>` macro creates a special transparent dialog modal for images and text, rendering the content between its tags into this special dialog element. Like a normal dialog, clicking on the overlay closes the popover, but this behavior may be suppressed. There are also a few additional options and you may add custom classes as well.
18+
19+
**Arguments**:
20+
21+
* **flags**: (optional) A list of options for the popover. Valid options are:
22+
* `opaque`: makes the overlay opaque (alpha: 1). By default it's alpha is 0.8.
23+
* `transparent`: makes the overlay totally transparent (alpha: 0). By default it's alpha is 0.8. The overlay will still block user interaction from occurring on whatever is behind it, and will still, by default, dismiss the popover when clicked.
24+
* `noclick`: by default, clicks on the overlay close the popover. This option suppresses this behavior, meaning users will only be able to close the popover with the `X` button at the top right of the screen.
25+
* `invert`: inverts the colors of the overlay and it's default text color. By default the overlay is dark and the text is light. This does not effect the opacity of the overlay.
26+
* **classList**: (optional) A list of CSS classes to add to the popover, for styling. These classes are added to `#ui-overlay`, `#ui-dialog`, and `#ui-dialog-body`. The classes should be a space-separated list of quoted class names (i.e. `'class-a' 'class-b' 'class-c'`), a quoted list of space-separated class names (i.e. `'class-a class-b class-c'`), or one or more string arrays (i.e. `['class-a', 'class-b', 'class-c']`), or any combination of thereof.
27+
28+
**Usage**:
29+
30+
```
31+
<<popover 'invert' 'opaque'>>Hi there!<</popover>>
32+
33+
<<popover 'transparent' 'my-class'>>[img[assets/my-img.png]]<</popover>>
34+
35+
<<popover 'my-class'>>[img[assets/my-img.png]]<</popover>>
36+
37+
<<popover 'noclick'>>[[Move on]]<</popover>>
38+
39+
<<popover>>Welcome!<</popover>>
40+
```
41+
42+
### Macro: `<<dismisspopover>>`
43+
44+
**Syntax**: `<<dismisspopover>>`
45+
46+
Closes the popover dialog. Can't be used to close other dialogs, but functions, methods, or macros that close other dialogs should generally also be able to close popovers, so `Dialog.close()` should work fine if you prefer.
47+
48+
**Usage**:
49+
50+
```
51+
<<popover>>\
52+
Hi there! Welcome to my game!
53+
54+
<<button "Continue">><<dismisspopover>><</button>>
55+
<</popover>>
56+
```
57+
58+
### Function: `setup.popover()`
59+
60+
**Syntax**: `setup.popover(content [, flagsAndClasses])`
61+
62+
A JavaScript function that is essentially the same as the `<<popover>>` macro
63+
64+
**Arguments**:
65+
66+
* **content**: the content to render in the popover.
67+
* **flags**: (optional) A list of options for the popover. Valid options are:
68+
* `opaque`: makes the overlay opaque (alpha: 1). By default it's alpha is 0.8.
69+
* `transparent`: makes the overlay totally transparent (alpha: 0). By default it's alpha is 0.8.
70+
* `noclick`: by default, clicks on the overlay close the popover. This option suppresses this behavior, meaning users will only be able to close the popover with the `X` button at the top right of the screen.
71+
* `invert`: inverts the colors of the overlay and it's default text color. By default the overlay is dark and the text is light. This does not effect the opacity of the overlay.
72+
* **classList**: (optional) A list of CSS classes to add to the popover, for styling. These classes are added to `#ui-overlay`, `#ui-dialog`, and `#ui-dialog-body`. The classes should be a space-separated list of quoted class names (i.e. `'class-a' 'class-b' 'class-c'`), a quoted list of space-separated class names (i.e. `'class-a class-b class-c'`), or one or more string arrays (i.e. `['class-a', 'class-b', 'class-c']`), or any combination of thereof.

docs/preload.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
## The Preload Macro
2+
3+
[Back to the main readme](./README.md).
4+
5+
This macro allows you to preload image resources.
6+
7+
**THE CODE:** [Minified](https://github.com/ChapelR/custom-macros-for-sugarcube-2/blob/master/scripts/minified/preload.min.js). [Pretty](https://github.com/ChapelR/custom-macros-for-sugarcube-2/blob/master/scripts/preload.js).
8+
**DEMO:** [Available](http://macros.twinelab.net/demo?macro=preload).
9+
**GUIDE:** Not available.
10+
11+
### Macro: `<<preload>>`
12+
13+
**Syntax:** `<<preload urls>>`
14+
15+
This macro will preload a list of image resources so that they will be available and not have to take time to download as they are encountered during play. In general, only important or necessary images should be preloaded, and because the process of preloading merely moves the downloads to startup rather than eliminating them, preloading too many images or extremely large images can cause startup times to become excessive. Still, judicious use of this macro can help a game feel snappier and more performant.
16+
17+
> [!DANGER]
18+
> The `<<preload>>` macro will throw an error if used outside of the `StoryInit` special passage (or equivalent). If you absolutely need to preload at some other time, set `setup.preload.force` to `true`. This is not recommended, and only included as an option for bizarre use-cases.
19+
20+
**Arguments:**
21+
22+
- `urls` ( *`string`* | *`string array`* ) A list of URL paths to image resources to preload. You may pass individual URLs as separate arguments, or as an array, or as any combination of the two.
23+
24+
**Usage:**
25+
26+
```
27+
<<preload 'assets/lisa/jpg' 'assets/bob.jgp'>>
28+
29+
/* you can also provide the arguments as an array if you prefer */
30+
<<preload `['assets/lisa/jpg', 'assets/bob.jgp']`>>
31+
```
32+
33+
### Function: `setup.preload()`
34+
35+
**Syntax:** `setup.preload(urls)`
36+
37+
This function does exactly the same thing as `<<preload>>` and is subject to the exact same restrictions.
38+
39+
**Arguments:**
40+
41+
- `urls` ( *`string`* | *`string array`* ) A list of URL paths to image resources to preload. You may pass individual URLs as separate arguments, or as an array, or as any combination of the two.
42+
43+
**Usage:**
44+
45+
```
46+
setup.preload('assets/lisa/jpg', 'assets/bob.jgp');
47+
48+
// you can also provide the arguments as an array if you prefer
49+
setup.preload(['assets/lisa/jpg', 'assets/bob.jgp'])
50+
```

0 commit comments

Comments
 (0)