|
1 | 1 | ## Main Options
|
2 | 2 |
|
| 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 | + |
3 | 9 | ### `EJS_player`
|
4 | 10 |
|
5 | 11 | 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
|
483 | 489 |
|
484 | 490 | ### `EJS_Buttons`
|
485 | 491 |
|
| 492 | +#### Version 4.2.1 and earlier |
| 493 | + |
486 | 494 | Shows/hides buttons.
|
487 | 495 |
|
488 | 496 | - Type: `object`
|
@@ -512,6 +520,91 @@ EJS_Buttons = {
|
512 | 520 | }
|
513 | 521 | ```
|
514 | 522 |
|
| 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 | + |
515 | 608 | ### `EJS_defaultOptions`
|
516 | 609 |
|
517 | 610 | Sets the default settings menu options.
|
|
0 commit comments