Skip to content

Commit 4938332

Browse files
committed
Merge branch 'origin/main' into translate
2 parents fc3bd89 + 512dc07 commit 4938332

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed

.github/workflows/newlines.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Check for Newline at End of Files
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
10+
jobs:
11+
check-newlines:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v2
17+
18+
- name: Check for missing newlines
19+
run: |
20+
files=$(git ls-files)
21+
22+
newline_error=0
23+
24+
for file in $files; do
25+
if file --mime "$file" | grep -q "binary"; then
26+
#echo "Skipping binary file: $file"
27+
continue
28+
fi
29+
30+
last_char=$(tail -c 1 "$file" | xxd -p)
31+
if [[ "$last_char" != "0a" ]]; then
32+
echo "File $file does not end with a newline!"
33+
newline_error=1
34+
fi
35+
done
36+
37+
if [[ $newline_error -eq 1 ]]; then
38+
echo "One or more files do not end with a newline."
39+
exit 1
40+
else
41+
echo "All files end with a newline."
42+
fi

content/1.docs/7.options.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Main Options
22

3+
::alert{type="info"}
4+
::list{type="info"}
5+
- **Note**: Some projects have been using internal API's not documented here. As these internal API's are undocumented, they are not guarrenteed to function the same between EmulatorJS versions. We *highly* recommend not using internal API's. If they are something your project relies upon, consider raising a Pull Request or Feature Request to have the API exposed public and documented here.
6+
::
7+
::
8+
39
### `EJS_player`
410

511
The selector of the element you want the emulator to be placed in.
@@ -483,6 +489,8 @@ Available control schemes: `nes` `gb` `gba` `snes` `n64` `gba` `nds` `vb` `sega
483489

484490
### `EJS_Buttons`
485491

492+
#### Version 4.2.1 and earlier
493+
486494
Shows/hides buttons.
487495

488496
- Type: `object`
@@ -512,6 +520,91 @@ EJS_Buttons = {
512520
}
513521
```
514522

523+
#### Version 4.2.2 and later
524+
525+
Configures toolbar button icons, visibility, and custom call back functions to execute a custom action on the host page when a button is pressed (for example, automation of handling save files).
526+
527+
Configurable buttons:
528+
| Name | Notes |
529+
| ------------- | ------------- |
530+
| `playPause`<br />`play`<br />`pause` | `playPause` is an alias for two buttons named `play` and `pause`.<br /><br />Setting the visible attribute of `playPause` will set the visibility of `play` and `pause`, however `icon`, `displayName`, and `callback` need be configured individually for the `play` and `pause` buttons if different behaviour is required. |
531+
| `restart` | |
532+
| `mute`<br />`unmute` | `mute` is an alias for two buttons named `mute` and `unmute`.<br /><br />Setting the visible attribute of `mute` will also set the visibility of `unmute`. The `icon`, `displayName` and `callback` attributes should be configured for `unmute` if different behaviour is required. |
533+
| `settings` | |
534+
| `fullscreen`<br />`enterFullscreen`<br />`exitFullscreen` | `fullscreen` is an alias for two buttons named `enterFullscreen` and `exitFullscreen`.<br /><br />Setting the visible attribute of `fullscreen` will set the visibility of `enterFullscreen` and `exitFullscreen`, however `icon`, `displayName`, and `callback` will need to be configured individually for the `enterFullscreen` and `exitFullscreen` buttons if different behaviour is required. |
535+
| `saveState` | |
536+
| `loadState` | |
537+
| `screenRecord` | |
538+
| `gamepad` | |
539+
| `cheat` | |
540+
| `volume ` | |
541+
| `saveSavFiles` | |
542+
| `loadSavFiles` | |
543+
| `quickSave` | |
544+
| `quickLoad` | |
545+
| `screenshot` | |
546+
| `cacheManager` | |
547+
| `exitEmulation` | |
548+
549+
Each button can accept either a boolean which controls the buttons visibility (as per behaviour in version 4.2.1 and earlier), or an array with the following elements:
550+
```js
551+
{
552+
buttonName: {
553+
visible: true,
554+
icon: '<svg xml>',
555+
displayName: "Button Name",
556+
callback: () => {
557+
console.log('Button clicked');
558+
}
559+
}
560+
}
561+
```
562+
563+
Any undefined element will use the default behaviour for that button - for example, if `visible` is ommited, the button will be visibile.
564+
565+
Custom buttons can be added by adding button elements with a unique name that's not on the above list. Custom buttons appear at the end of the toolbar, and require a name, icon, displayName, and callback to be provided.
566+
567+
::alert{type="info"}
568+
::list{type="info"}
569+
- Note that while the `displayName` value is localized using the EJS language files, if a `displayName` is used that's not available it will be displayed as provided. It is up to the developer to provide localized values for `displayName`.
570+
::
571+
::
572+
573+
- Type: `object`
574+
- Default: `{}`
575+
- Examples:
576+
```js
577+
// show the saveState button, set the display name, and print a message to the console when clicked
578+
{
579+
saveState: {
580+
visible: true,
581+
displayName: "Save State",
582+
callback: () => {
583+
console.log("The save state button was clicked");
584+
}
585+
}
586+
}
587+
```
588+
```js
589+
// hide the button
590+
{
591+
saveState: false
592+
}
593+
```
594+
```js
595+
// Custom button
596+
{
597+
customButton: {
598+
visible: true,
599+
displayName: "Custom Button",
600+
icon: '<svg xml/>',
601+
callback: () => {
602+
console.log("The custom button was clicked");
603+
}
604+
}
605+
}
606+
```
607+
515608
### `EJS_defaultOptions`
516609

517610
Sets the default settings menu options.

0 commit comments

Comments
 (0)