Skip to content

Commit

Permalink
add info to menu
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewbauer committed Nov 8, 2015
1 parent 7c99f91 commit ac36450
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
34 changes: 23 additions & 11 deletions index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ settings = require './settings.json!'
utils = require './utils'

draghint = document.getElementById 'draghint'
menu = document.getElementById 'menu'
chooser = document.getElementById 'chooser'
savechooser = document.getElementById 'savechooser'

if location.search? and location.search.substr(1)
window.url = location.search.substr(1)
Expand Down Expand Up @@ -48,6 +45,8 @@ stop = ->
window.removeEventListener 'keydown', onkey
window.clearInterval autosaver

gain = null

play = (rom, extension) ->
Promise.resolve()
.then ->
Expand All @@ -59,6 +58,8 @@ play = (rom, extension) ->
localForage.getItem retro.md5
]).then ([core, save]) ->
stop() if retro.running
document.getElementById('core-name').textContent = settings.extensions[extension]
document.getElementById('system-info').textContent = JSON.stringify core.get_system_info(), null, ' '
retro.core = core
core.load_game rom if rom
core.unserialize new Uint8Array save if save?
Expand All @@ -68,6 +69,7 @@ play = (rom, extension) ->
retro.player.inputs = [
buttons: {}
]
document.getElementById('av-info').textContent = JSON.stringify retro.player.av_info, null, ' '
autosaver = setInterval ->
localForage.setItem retro.md5, new Uint8Array core.serialize()
, 1000
Expand Down Expand Up @@ -120,14 +122,10 @@ window.addEventListener 'dragleave', (event) ->
draghint.classList.remove 'hover'
false

window.addEventListener 'click', (event) ->
if not draghint.classList.contains 'hidden'
draghint.classList.add 'hover'
chooser.click()

window.addEventListener 'focus', ->
draghint.classList.remove 'hover'

menu = document.getElementById 'menu'
window.addEventListener 'contextmenu', (event) ->
if draghint.classList.contains 'hidden'
if retro.classList.contains 'hidden'
Expand All @@ -148,6 +146,15 @@ window.reset = ->
retro.core.reset()
window.resume()

window.mute = ->
if retro.player.destination.gain.value == 0
retro.player.destination.gain.value = 1
document.getElementById('mute').textContent = 'mute'
else
retro.player.destination.gain.value = 0
document.getElementById('mute').textContent = 'unmute'
window.resume()

window.save = ->
a = document.createElement 'a'
document.body.appendChild a
Expand All @@ -160,9 +167,7 @@ window.save = ->
a.click()
URL.revokeObjectURL url

window.load = ->
savechooser.click()

savechooser = document.getElementById 'savechooser'
savechooser.addEventListener 'change', ->
file = this.files[0]
return if not file instanceof Blob
Expand All @@ -172,7 +177,14 @@ savechooser.addEventListener 'change', ->
retro.core.unserialize new Uint8Array reader.result
window.resume()
reader.readAsArrayBuffer file
window.load = ->
savechooser.click()

chooser = document.getElementById 'chooser'
chooser.addEventListener 'change', ->
draghint.classList.remove 'hover'
load this.files[0]
window.addEventListener 'click', (event) ->
if not draghint.classList.contains 'hidden'
draghint.classList.add 'hover'
chooser.click()
1 change: 0 additions & 1 deletion index.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ html, body, canvas {
}
.menu {
width: 50%;
height: 100%;
margin: 0 auto;
}
.hidden {
Expand Down
9 changes: 8 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ <h1>drag a game here to play</h1>
<div class="options">
<h1>Your game is paused.</h1>
<button class="resume" onclick="resume()">resume</button>
<button class="reset" onclick="reset()">reset</button>
<button class="<re></re>set" onclick="reset()">reset</button>
<button class="save" onclick="save()">save game</button>
<button class="load" onclick="load()">load save</button>
<button id="mute" onclick="mute()">mute</button>
</div>
<div>
<h1>Controls:</h1>
Expand All @@ -32,6 +33,12 @@ <h1>Controls:</h1>
<div>R button = R key</div>
<div>D-pad = arrow keys</div>
</div>
<div>
<h1>Core Info:</h1>
<pre id="core-name"></pre>
<pre id="system-info"></pre>
<pre id="av-info"></pre>
</div>
</div>
<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
Expand Down

0 comments on commit ac36450

Please sign in to comment.