|
1 | 1 | <script> |
2 | | - import {isPlaying, setStatus, status, triggerSaveState, showLoadState, showAbout} from '../stores.js'; |
| 2 | + import { |
| 3 | + isPlaying, |
| 4 | + setStatus, |
| 5 | + status, |
| 6 | + triggerSaveState, |
| 7 | + showLoadState, |
| 8 | + showAbout, |
| 9 | + isTouchPadVisible, |
| 10 | + isFullScreen |
| 11 | + } from '../stores.js'; |
3 | 12 | import PlayIcon from './icons/PlayIcon.svelte'; |
4 | 13 | import PauseIcon from './icons/PauseIcon.svelte'; |
5 | 14 | import SaveIcon from './icons/SaveIcon.svelte'; |
6 | 15 | import LoadIcon from './icons/LoadIcon.svelte'; |
7 | 16 | import AboutIcon from './icons/AboutIcon.svelte'; |
| 17 | + import ShowGamePadIcon from './icons/ShowGamePadIcon.svelte'; |
| 18 | + import HideGamePadIcon from './icons/HideGamePadIcon.svelte'; |
| 19 | + import FullScreenIcon from './icons/FullScreenIcon.svelte'; |
| 20 | + import ExitFullScreenIcon from './icons/ExitFullScreenIcon.svelte'; |
8 | 21 |
|
9 | 22 | // Subscribe to our current status |
10 | 23 | let displayStatus = false; |
|
47 | 60 | showLoadState(); |
48 | 61 | }; |
49 | 62 |
|
| 63 | + const handleGamePad = () => { |
| 64 | + if ($isTouchPadVisible) { |
| 65 | + isTouchPadVisible.set(false); |
| 66 | + } else { |
| 67 | + isTouchPadVisible.set(true); |
| 68 | + } |
| 69 | + }; |
| 70 | +
|
50 | 71 | const handleAbout = () => { |
51 | 72 | showAbout(); |
52 | 73 | }; |
| 74 | +
|
| 75 | + const handleFullScreen = async () => { |
| 76 | + if ($isFullScreen) { |
| 77 | + isFullScreen.set(false); |
| 78 | + document.exitFullscreen(); |
| 79 | + } else { |
| 80 | + try { |
| 81 | + await document.documentElement.requestFullscreen(); |
| 82 | + isFullScreen.set(true); |
| 83 | + } catch(e) { |
| 84 | + console.error(e); |
| 85 | + setStatus('Error, could not fullscreen!'); |
| 86 | + } |
| 87 | + } |
| 88 | + }; |
53 | 89 | </script> |
54 | 90 |
|
55 | 91 | <footer class="controls-bar"> |
|
80 | 116 | </button> |
81 | 117 | </li> |
82 | 118 |
|
| 119 | + <li> |
| 120 | + <button class="icon-button" on:click={handleGamePad}> |
| 121 | + {#if $isTouchPadVisible} |
| 122 | + <HideGamePadIcon /> |
| 123 | + {:else} |
| 124 | + <ShowGamePadIcon /> |
| 125 | + {/if} |
| 126 | + </button> |
| 127 | + </li> |
| 128 | + |
83 | 129 | <li> |
84 | 130 | <button class="icon-button" on:click={handleAbout}> |
85 | 131 | <AboutIcon /> |
86 | 132 | </button> |
87 | 133 | </li> |
| 134 | + |
| 135 | + <li> |
| 136 | + <button class="icon-button" on:click={handleFullScreen}> |
| 137 | + {#if $isFullScreen} |
| 138 | + <FullScreenIcon /> |
| 139 | + {:else} |
| 140 | + <ExitFullScreenIcon /> |
| 141 | + {/if} |
| 142 | + </button> |
| 143 | + </li> |
88 | 144 | </ul> |
89 | 145 | </footer> |
90 | 146 |
|
|
101 | 157 | transition: transform 0.5s; |
102 | 158 | } |
103 | 159 |
|
104 | | - :global(html):hover .controls-bar, :global(body):hover .controls-bar { |
| 160 | + :global(html):hover .controls-bar, |
| 161 | + :global(body):hover .controls-bar, |
| 162 | + :global(.touchpad-visible) .controls-bar { |
105 | 163 | transform: translateY(-50px); |
106 | 164 | } |
107 | 165 |
|
|
0 commit comments