mirror of
https://gitlab.com/Oreolek/salet.git
synced 2024-07-07 01:04:25 +03:00
Issue #1 fix - proper sectioning
This commit is contained in:
parent
828962b1ff
commit
b05b2974c7
|
@ -58,8 +58,6 @@ dialogue "Dialogue functions", "question2", "world", """
|
||||||
room "world",
|
room "world",
|
||||||
tags: ["world"],
|
tags: ["world"],
|
||||||
optionText: "Enter the world",
|
optionText: "Enter the world",
|
||||||
before: () ->
|
|
||||||
cls()
|
|
||||||
ways: ["university"]
|
ways: ["university"]
|
||||||
content: """
|
content: """
|
||||||
### Rhinestone Room
|
### Rhinestone Room
|
||||||
|
|
|
@ -15,9 +15,8 @@ print = (content) ->
|
||||||
block = document.getElementById("current-situation")
|
block = document.getElementById("current-situation")
|
||||||
if block
|
if block
|
||||||
block.innerHTML = block.innerHTML + markdown(content)
|
block.innerHTML = block.innerHTML + markdown(content)
|
||||||
else #the game is not initialized yet. This is dangerous and will not augment any links.
|
else
|
||||||
block = document.getElementById("content")
|
console.error("No current situation found.")
|
||||||
block.innerHTML = markdown(content)
|
|
||||||
|
|
||||||
Array::remove = (e) -> @[t..t] = [] if (t = @indexOf(e)) > -1
|
Array::remove = (e) -> @[t..t] = [] if (t = @indexOf(e)) > -1
|
||||||
|
|
||||||
|
@ -73,8 +72,11 @@ class SaletRoom extends RaconteurSituation
|
||||||
@clear = spec.clear
|
@clear = spec.clear
|
||||||
if spec.writers?
|
if spec.writers?
|
||||||
@writers = spec.writers
|
@writers = spec.writers
|
||||||
|
if spec.extendSection?
|
||||||
|
@extendSection = spec.extendSection
|
||||||
return this
|
return this
|
||||||
objects: []
|
objects: []
|
||||||
|
extendSection: false
|
||||||
distance: Infinity # distance to the destination
|
distance: Infinity # distance to the destination
|
||||||
clear: true # clear the screen on entering the room?
|
clear: true # clear the screen on entering the room?
|
||||||
|
|
||||||
|
@ -107,8 +109,9 @@ class SaletRoom extends RaconteurSituation
|
||||||
Also if f == this.name (we're in the same location) the `before` and `after` callbacks are ignored.
|
Also if f == this.name (we're in the same location) the `before` and `after` callbacks are ignored.
|
||||||
###
|
###
|
||||||
entering: (character, system, f) ->
|
entering: (character, system, f) ->
|
||||||
if @clear
|
if @clear and f?
|
||||||
system.clearContent()
|
system.clearContent()
|
||||||
|
system.clearContent("#intro")
|
||||||
|
|
||||||
if f != @name and f?
|
if f != @name and f?
|
||||||
@visited++
|
@visited++
|
||||||
|
@ -118,41 +121,46 @@ class SaletRoom extends RaconteurSituation
|
||||||
if @enter
|
if @enter
|
||||||
@enter character, system, f
|
@enter character, system, f
|
||||||
|
|
||||||
|
current_situation = ""
|
||||||
if not @extendSection
|
if not @extendSection
|
||||||
classes = if @classes then ' ' + @classes.join(' ') else ''
|
classes = if @classes then ' ' + @classes.join(' ') else ''
|
||||||
situation = document.getElementById('current-situation')
|
situation = document.getElementById('current-situation')
|
||||||
if situation?
|
if situation?
|
||||||
situation.setAttribute('id', undefined)
|
situation.removeAttribute('id')
|
||||||
system.write("<section id='current-situation' data-situation='#{@name}' class='situation-#{@name}#{classes}'>")
|
# Javascript DOM manipulation functions like jQuery's append() or document.createElement
|
||||||
|
# don't work like a typical printLn - they create *DOM nodes*.
|
||||||
|
# You can't leave an unclosed tag just like that. So we have to buffer the output.
|
||||||
|
current_situation = "<section id='current-situation' data-situation='#{@name}' class='situation-#{@name}#{classes}'>"
|
||||||
|
|
||||||
if f != @name and @before?
|
if f != @name and @before?
|
||||||
content = @before.fcall(this, character, system, f)
|
current_situation += @before.fcall(this, character, system, f)
|
||||||
if content
|
|
||||||
print(content)
|
|
||||||
|
|
||||||
if @look
|
if @look
|
||||||
@look character, system, f
|
current_situation += @look character, system, f
|
||||||
|
|
||||||
if f != @name and @after?
|
if f != @name and @after?
|
||||||
content = @after.fcall(this, character, system, f)
|
current_situation += @after.fcall(this, character, system, f)
|
||||||
if content
|
|
||||||
print(content)
|
|
||||||
|
|
||||||
if not @extendSection
|
if not @extendSection
|
||||||
system.write("</section>")
|
current_situation += "</section>"
|
||||||
|
|
||||||
|
system.write(current_situation)
|
||||||
|
|
||||||
if @choices
|
if @choices
|
||||||
system.writeChoices(system.getSituationIdChoices(@choices, @minChoices, @maxChoices))
|
system.writeChoices(system.getSituationIdChoices(@choices, @minChoices, @maxChoices))
|
||||||
|
|
||||||
look: (character, system, f) ->
|
look: (character, system, f) ->
|
||||||
update_ways(@ways)
|
update_ways(@ways)
|
||||||
|
retval = ""
|
||||||
|
|
||||||
# Print the room description
|
# Print the room description
|
||||||
if @content
|
if @content
|
||||||
system.write(markdown(@content.fcall(this, character, system, f)))
|
retval += markdown(@content.fcall(this, character, system, f))
|
||||||
|
|
||||||
if @objects? then for thing in @objects
|
if @objects? then for thing in @objects
|
||||||
system.write thing.look()
|
retval += thing.look()
|
||||||
|
|
||||||
|
return retval
|
||||||
|
|
||||||
###
|
###
|
||||||
Object action. A function or a string which comes when you click on the object link.
|
Object action. A function or a string which comes when you click on the object link.
|
||||||
|
|
|
@ -27,9 +27,10 @@ markdown = require('./markdown.coffee')
|
||||||
Function.prototype.fcall = Function.prototype.call;
|
Function.prototype.fcall = Function.prototype.call;
|
||||||
String.prototype.fcall = () -> return this
|
String.prototype.fcall = () -> return this
|
||||||
|
|
||||||
#Adds the "fade" class to a htmlString.
|
#Adds the "fadeIn" class to a htmlString.
|
||||||
|
#The class "fade" is redefined by Bootstrap, so it's not the best choice.
|
||||||
String.prototype.fade = () ->
|
String.prototype.fade = () ->
|
||||||
return '<div class="fade">'+this+'</div>'
|
return '<div class="fadeIn">'+this+'</div>'
|
||||||
|
|
||||||
###
|
###
|
||||||
The prototype RaconteurSituation is the basic spec for situations
|
The prototype RaconteurSituation is the basic spec for situations
|
||||||
|
|
|
@ -1153,7 +1153,9 @@ var parseFn = function(str) {
|
||||||
var doWrite = function(content, selector, addMethod, appendMethod) {
|
var doWrite = function(content, selector, addMethod, appendMethod) {
|
||||||
var output = augmentLinks(content).addClass('new');
|
var output = augmentLinks(content).addClass('new');
|
||||||
var element;
|
var element;
|
||||||
if (selector) element = $(selector);
|
if (selector) {
|
||||||
|
element = $(selector);
|
||||||
|
}
|
||||||
if (!element) {
|
if (!element) {
|
||||||
$('#content')[addMethod](output);
|
$('#content')[addMethod](output);
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,3 +199,17 @@ hr {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
border-color: $body-color;
|
border-color: $body-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fade-in animation
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.fadeIn {
|
||||||
|
animation-name: fadeIn;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue