1
0
Fork 0
mirror of https://gitlab.com/Oreolek/salet.git synced 2024-07-02 06:45:06 +03:00

Fixed goBack and backported various UI fixes.

This commit is contained in:
Alexander Yakovlev 2016-04-05 08:56:44 +07:00
parent 8c5cd01b9a
commit 606629d83f
3 changed files with 10 additions and 5 deletions

View file

@ -11,7 +11,6 @@ salet = Salet({
})
$(document).ready(() ->
salet.beginGame()
salet.character.bought_lamp = false
)
###
@ -31,6 +30,8 @@ textcycle = (content, ref) ->
# The first room of the game.
# For accessibility reasons the text is provided in HTML, not here.
room "start", salet,
enter: (salet) ->
salet.character.bought_lamp = false
dsc: """
""",
choices: "#start"

View file

@ -304,10 +304,12 @@ class Salet
# Go back N rooms. It's not an UNDO.
# Also, steps = 1 is the current room
@goBack = (steps = 2) =>
if @progress.path.length > steps
if @progress.path.length == 1
location = @start
else if @progress.path.length > steps
location = @progress.path[@progress.path.length - steps]
else
location = @start
return @goBack(steps - 1)
@processClick(location)
# Transition between rooms.

View file

@ -26,7 +26,7 @@ addClass = (element, className) ->
class SaletView
init: (salet) =>
$("#content, #ways, #buttons").on("click", "a", (event) ->
$("#page").on("click", "a", (event) ->
event.preventDefault()
a = $(this)
href = a.attr('href')
@ -86,7 +86,9 @@ class SaletView
###
clearContent: (elementSelector = "#content") ->
if (elementSelector == "#content") # empty the intro with the content
document.getElementById("intro").innerHTML = ""
intro = document.getElementById("intro")
if intro?
intro.innerHTML = ""
document.querySelector(elementSelector).innerHTML = ""
prepareContent: (content) ->