Skip to content

Commit

Permalink
ucfopen#30 Added buttons to reach the keyboard instructions and intro…
Browse files Browse the repository at this point in the history
… screen in the sidebar. Refreshed icomoon files and renamed 'tutorial' to 'instructions'.
  • Loading branch information
FrenjaminBanklin committed Aug 1, 2023
1 parent 147abd4 commit a59f3c5
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 32 deletions.
Binary file modified src/assets/font/icomoon.eot
100755 → 100644
Binary file not shown.
10 changes: 6 additions & 4 deletions src/assets/font/icomoon.svg
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/font/icomoon.ttf
100755 → 100644
Binary file not shown.
Binary file modified src/assets/font/icomoon.woff
100755 → 100644
Binary file not shown.
10 changes: 5 additions & 5 deletions src/creator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ body {
content: ' ';
}
&:after {
content: "\e600";
content: "\e984";
font-family: 'icomoon';
position:absolute;
top: 50%;
Expand Down Expand Up @@ -221,11 +221,11 @@ h1 {
}

.icon-spinner2:before {
content: "\e600";
content: "\e984";
}
.icon-close {
&:before {
content: "\e602";
content: "\ea0f";
font-size: 20px;
}

Expand All @@ -237,7 +237,7 @@ h1 {
}
}
.icon-plus:before {
content: "\e601";
content: "\ea0a";
}

div.criticism {
Expand Down Expand Up @@ -608,4 +608,4 @@ input[type=checkbox]:checked + label.checktoggle {
100% {
transform: translate(0px,0px);
}
}
}
52 changes: 33 additions & 19 deletions src/player.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,33 +84,42 @@ Namespace('WordSearch').Engine = do ->

document.getElementById('intro-instructions').addEventListener 'keypress', ->
_showKeyboardInstructions()
document.getElementById('tutorial-dismiss').focus()
document.getElementById('instructions-dismiss').focus()
document.getElementById('intro-instructions').addEventListener 'click', _showKeyboardInstructions

document.getElementById('intro-dismiss').addEventListener 'keypress', (e) ->
e.preventDefault()
e.stopPropagation()
document.getElementById('intro-dismiss').addEventListener 'keypress', ->
_introDismissed = true
_makeBoardUsable()
# questionable timeout to avoid this keypress being picked up by the board after it receives focus
setTimeout (->
document.getElementById('board').focus()
), 100

document.getElementById('intro-dismiss').addEventListener 'click', () ->
document.getElementById('intro-dismiss').addEventListener 'click', ->
_introDismissed = true
_makeBoardUsable()

document.getElementById('tutorial-dismiss').addEventListener 'keypress', (e) ->
e.preventDefault()
e.stopPropagation()
document.getElementById('instructions-dismiss').addEventListener 'keypress', ->
_hideKeyboardInstructions()
document.getElementById('intro-instructions').focus()
if _introDismissed
document.getElementById('show-instructions').focus()
else
document.getElementById('intro-instructions').focus()

document.getElementById('tutorial-dismiss').addEventListener 'click', _hideKeyboardInstructions
document.getElementById('instructions-dismiss').addEventListener 'click', _hideKeyboardInstructions

document.getElementById('board').addEventListener 'keyup', _handleBoardKeyupEvent

document.getElementById('show-intro').addEventListener 'keypress', ->
_showIntro()
document.getElementById('intro-instructions').focus()
document.getElementById('show-intro').addEventListener 'click', _showIntro

document.getElementById('show-instructions').addEventListener 'keypress', ->
_showKeyboardInstructions()
document.getElementById('instructions-dismiss').focus()
document.getElementById('show-instructions').addEventListener 'click', _showKeyboardInstructions

document.getElementById('checkbtn').addEventListener 'click', _confirmDone
document.getElementById('checkbtn').addEventListener 'keyup', _doneButtonKeyupEvent

Expand All @@ -123,19 +132,24 @@ Namespace('WordSearch').Engine = do ->
# once everything is drawn, set the height of the player
Materia.Engine.setHeight()

_showIntro = ->
_introDismissed = false
_showbyId 'intro'

_showKeyboardInstructions = ->
document.getElementById('tutorial').removeAttribute('inert')
document.getElementById('tutorial').classList.add 'show'
# document.getElementById('instructions').removeAttribute('inert')
# document.getElementById('instructions').classList.add 'show'
_showbyId 'instructions'

# this isn't strictly necessary but doing it every time doesn't hurt
document.getElementById('intro').setAttribute('inert', 'true')

_hideKeyboardInstructions = ->
if _introDismissed
_makeBoardUsable
_makeBoardUsable()
else
document.getElementById('intro').removeAttribute 'inert'
_hideById 'tutorial'
_hideById 'instructions'

# show confirmation menu and autofocus the cancel button
_doneButtonKeyupEvent = (e) ->
Expand Down Expand Up @@ -302,10 +316,10 @@ Namespace('WordSearch').Engine = do ->

# show the "are you done" warning
_confirmDone = ->
document.getElementById('game').setAttribute('inert', 'true')
_showbyId 'confirm'

_showbyId = (targetId) ->
document.getElementById('game').setAttribute('inert', 'true')
document.getElementById(targetId).removeAttribute 'inert'
document.getElementById(targetId).classList.add 'show'
document.getElementById('backgroundcover').classList.add 'show'
Expand All @@ -315,14 +329,14 @@ Namespace('WordSearch').Engine = do ->
document.getElementById(targetId).classList.remove 'show'

_makeBoardUsable = ->
document.getElementById('game').removeAttribute('inert')
# rather than have multiple functions to do the same thing, inert all the dialogs
# rather than have multiple functions to do the same thing, hide/inert all the dialogs
_hideById 'confirm'
_hideById 'intro'
_hideById 'tutorial'

_hideById 'instructions'
document.getElementById('backgroundcover').classList.remove 'show'

document.getElementById('game').removeAttribute('inert')

_hideConfirmationDialog = (e) ->
_makeBoardUsable()
# a keyboard event triggered this, autofocus the 'done' button
Expand Down
14 changes: 11 additions & 3 deletions src/player.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
<canvas id='canvas' width=620 height=550></canvas>
</div>
<div id='sidebar' class='main-element'>
<div>
<button id='show-intro'
class='icon-tutorial'>
</button>
<button id='show-instructions'
class='icon-keyboard'>
</button>
</div>
<h1>Terms</h1>
<div id='terms'></div>
<div id='checkbtn'
Expand Down Expand Up @@ -63,7 +71,7 @@ <h1>Terms</h1>
Let's Go
</button>
</dialog>
<dialog id='tutorial'>
<dialog id='instructions'>
<div class='caption'>
<header>Keyboard Controls</header>
<p>
Expand All @@ -81,10 +89,10 @@ <h1>Terms</h1>
</p>
<p>
When you have selected a range of letters, press <span class='bold'>space</span> again to finalize the selection.
If the selected range corresponds to one of the words in the term list, it will be marked as complete.
If the selected range corresponds to one of the words in the term list, it will be marked as found.
</p>
</div>
<button id='tutorial-dismiss' class='submit action-button'>
<button id='instructions-dismiss' class='submit action-button'>
Okay
</button>
</dialog>
Expand Down
46 changes: 45 additions & 1 deletion src/player.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,50 @@ $green: #70bd34;
padding:0px;
}

@font-face {
font-family: 'icomoon';
src:url('assets/font/icomoon.eot');
src:url('assets/font/icomoon.eot?#iefix') format('embedded-opentype'),
url('assets/font/icomoon.ttf') format('truetype'),
url('assets/font/icomoon.woff') format('woff'),
url('assets/font/icomoon.svg#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}

[class*="icon-"] {
font-family: 'icomoon';
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
font-size: 20px;
color: #fff;
border: none;
outline: none;
background: none;

/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
margin-right: 8px;
cursor: pointer;
transition: linear 0.075s;

&:hover,
&:focus {
color: $green;
}
}

.icon-tutorial:before {
content: "\ea09";
}
.icon-keyboard:before {
content: "\e955";
}

body {
background: #2f3944;
font-family: 'Ruda', arial;
Expand Down Expand Up @@ -64,7 +108,7 @@ button {
}

#intro,
#tutorial,
#instructions,
#confirm {
display: none;
margin: 0 auto;
Expand Down

0 comments on commit a59f3c5

Please sign in to comment.