mirror of
https://github.com/Oreolek/gamebookformat.git
synced 2024-05-14 23:18:19 +03:00
Testing and fixing include only tag feature.
This commit is contained in:
parent
fcf41b9869
commit
e404e877ac
16
Makefile
16
Makefile
|
@ -3,10 +3,12 @@ examples=$(wildcard examples/*.gamebook)
|
|||
all: rtf pdf html debug png txt
|
||||
|
||||
rtf: $(examples:.gamebook=.rtf)
|
||||
tex: $(examples:.gamebook=.tex)
|
||||
pdf: $(examples:.gamebook=.pdf)
|
||||
html: $(examples:.gamebook=.html) examples/gamebookformatplay.js \
|
||||
examples/gamebookformat.css
|
||||
debug: $(examples:.gamebook=.debug)
|
||||
dot: $(examples:.gamebook=.dot)
|
||||
png: $(examples:.gamebook=.png)
|
||||
txt: $(examples:.gamebook=.txt)
|
||||
|
||||
|
@ -22,22 +24,22 @@ examples/gamebookformat.css:
|
|||
cp gamebookformat.css $@
|
||||
|
||||
%.rtf: %.gamebook *.py templates/rtf/*.rtf
|
||||
./formatgamebook.py --no-shuffle $< $@
|
||||
python ./buildexamplegamebook.py $< $@
|
||||
|
||||
%.html: %.gamebook *.py templates/html/*.html
|
||||
./formatgamebook.py --no-shuffle $< $@
|
||||
python ./buildexamplegamebook.py $< $@
|
||||
|
||||
%.tex: %.gamebook *.py templates/tex/*.tex
|
||||
./formatgamebook.py --no-shuffle $< $@
|
||||
python ./buildexamplegamebook.py $< $@
|
||||
|
||||
%.dot: %.gamebook *.py templates/dot/*.dot
|
||||
./formatgamebook.py --no-shuffle $< $@
|
||||
python ./buildexamplegamebook.py $< $@
|
||||
|
||||
%.debug: %.gamebook *.py templates/debug/*.debug
|
||||
./formatgamebook.py --no-shuffle $< $@
|
||||
python ./buildexamplegamebook.py $< $@
|
||||
|
||||
%.txt: %.gamebook *.py templates/txt/*.txt
|
||||
./formatgamebook.py --no-shuffle $< $@
|
||||
python ./buildexamplegamebook.py $< $@
|
||||
|
||||
%.pdf: %.tex
|
||||
cd $(dir $<) && pdflatex $(notdir $<) && pdflatex $(notdir $<)
|
||||
|
@ -52,7 +54,7 @@ expected: all
|
|||
cp examples/*.{rtf,tex,html,debug,txt,dot,map} \
|
||||
expected
|
||||
|
||||
checkexpected: clean all
|
||||
checkexpected: clean rtf tex html debug dot txt
|
||||
diff -r -x "*.aux" -x "*.gamebook" -x "*.log" -x "*.out" -x "*.png" \
|
||||
-x "*.pdf" -x .gitignore -x "*.js" -x "*.css" \
|
||||
-q examples expected
|
||||
|
|
22
buildexamplegamebook.py
Executable file
22
buildexamplegamebook.py
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
DEFAULT_OPTIONS = '--no-shuffle'
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 3:
|
||||
print >> sys.stderr, "usage: %s infile outfile" % sys.argv[0]
|
||||
sys.exit(1)
|
||||
infile = sys.argv[1]
|
||||
outfile = sys.argv[2]
|
||||
print infile, outfile
|
||||
optionsfilename = infile + '.options'
|
||||
options = DEFAULT_OPTIONS
|
||||
if os.path.exists(optionsfilename):
|
||||
optionsfile = open(optionsfilename)
|
||||
options += ' ' + ' '.join(optionsfile.readlines())
|
||||
optionsfile.close()
|
||||
os.system("python ./formatgamebook.py %s %s %s" % (
|
||||
options, infile, outfile))
|
36
examples/withdemo.gamebook
Normal file
36
examples/withdemo.gamebook
Normal file
|
@ -0,0 +1,36 @@
|
|||
missingto = demoinfo
|
||||
|
||||
* 1 start :demo:
|
||||
This gamebook contains a few sections tagged as demo, that will
|
||||
be included when building the example
|
||||
(see withdemo.gamebook.options file). There are also some sections
|
||||
without the demo tag that will be ignored.
|
||||
Go on to [[demo1]] or [[demo2]] or [[notindemo1]].
|
||||
|
||||
* notindemo1
|
||||
This section is not included in the demo. Turn to [[notindemo2]].
|
||||
|
||||
* demo1 :demo:
|
||||
This is the first demo section (not counting the start section).
|
||||
You can go on to the end at [[theend]].
|
||||
|
||||
* notindemo2
|
||||
This section is not included in the demo. You can go on to
|
||||
[[demo2]] or [[theend]] or [[altend]].
|
||||
|
||||
* demo2 :demo:
|
||||
This is the second demo section.
|
||||
You can go on to the end at [[theend]] or alternative (not in demo)
|
||||
end at [[altend]].
|
||||
|
||||
* theend :demo:
|
||||
This is the end. It is also included in the demo.
|
||||
|
||||
* demoinfo :demo:
|
||||
This is where references to non-demo sections will lead you.
|
||||
It is configured at the top of the gamebook file.
|
||||
Remember to tag this section correctly to be included.
|
||||
Go on to [[demo2]].
|
||||
|
||||
* altend
|
||||
Alternative end. Not included in the demo.
|
1
examples/withdemo.gamebook.options
Normal file
1
examples/withdemo.gamebook.options
Normal file
|
@ -0,0 +1 @@
|
|||
--include demo
|
39
examples/withoutdemo.gamebook
Normal file
39
examples/withoutdemo.gamebook
Normal file
|
@ -0,0 +1,39 @@
|
|||
missingto = demoinfo
|
||||
|
||||
* 1 start :demo:
|
||||
This gamebook contains a few sections tagged as demo, that will
|
||||
be included when building the example as withdemo.gamebook
|
||||
(see withdemo.gamebook.options file). There are also some sections
|
||||
without the demo tag that will be ignored. This version is built
|
||||
without options and includes all sections.
|
||||
Go on to [[demo1]] or [[demo2]] or [[notindemo1]].
|
||||
|
||||
* notindemo1
|
||||
This section is not included in the demo. Turn to [[notindemo2]].
|
||||
|
||||
* demo1 :demo:
|
||||
This is the first demo section (not counting the start section).
|
||||
You can go on to the end at [[theend]].
|
||||
|
||||
* notindemo2
|
||||
This section is not included in the demo. You can go on to
|
||||
[[demo2]] or [[theend]] or [[altend]].
|
||||
|
||||
* demo2 :demo:
|
||||
This is the second demo section.
|
||||
You can go on to the end at [[theend]] or alternative (not in demo)
|
||||
end at [[altend]].
|
||||
|
||||
* theend :demo:
|
||||
This is the end. It is also included in the demo.
|
||||
|
||||
* demoinfo :demo:
|
||||
This is where references to non-demo sections will lead you.
|
||||
It is configured at the top of the gamebook file.
|
||||
Remember to tag this section correctly to be included.
|
||||
Nothing should lead to this section when building without
|
||||
the demo tag option.
|
||||
Go on to [[demo2]].
|
||||
|
||||
* altend
|
||||
Alternative end. Not included in the demo.
|
12
expected/withdemo.debug
Normal file
12
expected/withdemo.debug
Normal file
|
@ -0,0 +1,12 @@
|
|||
BEGIN DEBUG OUTPUT
|
||||
Book title: Gamebook
|
||||
Number of sections: 5
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
1 (start) - This gamebook contains a few sections tagged as demo, that will be included when building the example (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. Go on to 5 or 4 or 2.
|
||||
2 (demoinfo) - This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Go on to 4.
|
||||
3 (theend) - This is the end. It is also included in the demo.
|
||||
4 (demo2) - This is the second demo section. You can go on to the end at 3 or alternative (not in demo) end at 2.
|
||||
5 (demo1) - This is the first demo section (not counting the start section). You can go on to the end at 3.
|
||||
END DEBUG OUTPUT
|
13
expected/withdemo.dot
Normal file
13
expected/withdemo.dot
Normal file
|
@ -0,0 +1,13 @@
|
|||
digraph gamebook {
|
||||
|
||||
1->5
|
||||
|
||||
1->2
|
||||
|
||||
1->4
|
||||
2->4
|
||||
4->2
|
||||
|
||||
4->3
|
||||
5->3
|
||||
}
|
99
expected/withdemo.html
Normal file
99
expected/withdemo.html
Normal file
|
@ -0,0 +1,99 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>Gamebook</title>
|
||||
<script type="text/javascript" src="gamebookformatplay.js"></script>
|
||||
<link rel="stylesheet" href="gamebookformat.css"
|
||||
type="text/css" />
|
||||
<script>
|
||||
gamebook.id = 'withdemo';
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="hideintrolink nodisplay"
|
||||
onclick="gamebook.hideIntroSections()">(hide instructions)</div>
|
||||
<div class="gamebook">
|
||||
|
||||
<div class="resumelink nodisplay"
|
||||
onclick="gamebook.loadGame()">Resume saved game.</div>
|
||||
|
||||
<div class="startlink"
|
||||
onclick="gamebook.turnTo(1)">Turn to 1 to begin.</div>
|
||||
<script>
|
||||
if (gamebook.hasSavedGame()) {
|
||||
var resumeLinks = document.getElementsByClassName('resumelink');
|
||||
Array.prototype.forEach.call(resumeLinks, function(e) {
|
||||
e.classList.remove('nodisplay');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<div class="section" id="section1">
|
||||
<div class="sectionnumber" id="para1">1</div>
|
||||
<div class="sectiontext">
|
||||
This gamebook contains a few sections tagged as demo, that will be included when building the example (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. Go on to <a class="sectionref enabledlink" data-ref="5">5</a> or <a class="sectionref enabledlink" data-ref="4">4</a> or <a class="sectionref enabledlink" data-ref="2">2</a>.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(1, document.getElementById('section1'));
|
||||
}
|
||||
</script><div class="section" id="section2">
|
||||
<div class="sectionnumber" id="para2">2</div>
|
||||
<div class="sectiontext">
|
||||
This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Go on to <a class="sectionref enabledlink" data-ref="4">4</a>.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(2, document.getElementById('section2'));
|
||||
}
|
||||
</script><div class="section" id="section3">
|
||||
<div class="sectionnumber" id="para3">3</div>
|
||||
<div class="sectiontext">
|
||||
This is the end. It is also included in the demo.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(3, document.getElementById('section3'));
|
||||
}
|
||||
</script><div class="section" id="section4">
|
||||
<div class="sectionnumber" id="para4">4</div>
|
||||
<div class="sectiontext">
|
||||
This is the second demo section. You can go on to the end at <a class="sectionref enabledlink" data-ref="3">3</a> or alternative (not in demo) end at <a class="sectionref enabledlink" data-ref="2">2</a>.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(4, document.getElementById('section4'));
|
||||
}
|
||||
</script><div class="section" id="section5">
|
||||
<div class="sectionnumber" id="para5">5</div>
|
||||
<div class="sectiontext">
|
||||
This is the first demo section (not counting the start section). You can go on to the end at <a class="sectionref enabledlink" data-ref="3">3</a>.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(5, document.getElementById('section5'));
|
||||
}
|
||||
</script> <div id="collections" class="collections">
|
||||
</div>
|
||||
<div id="collectionTemplate" class="collectionTemplate">
|
||||
<span class="collectionheading"></span>
|
||||
<span class="collectioncontents"></span>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.runActionsInIntroSections();
|
||||
}
|
||||
</script>
|
||||
<div class="displayintrolink nodisplay"
|
||||
onclick="gamebook.showIntroSections()">(show instructions)</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
54
expected/withdemo.rtf
Normal file
54
expected/withdemo.rtf
Normal file
|
@ -0,0 +1,54 @@
|
|||
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
|
||||
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\paperw11900\paperh16840\margl1440\margr1440\vieww14140\viewh14860\viewkind0
|
||||
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\b\fs24 \cf0
|
||||
|
||||
\b \qc Gamebook
|
||||
\b0\
|
||||
|
||||
\b Turn to 1 to begin.
|
||||
\b0\
|
||||
\
|
||||
\b \qc 1
|
||||
\b0\
|
||||
\ql This gamebook contains a few sections tagged as demo, that will be included when building the example (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. Go on to \b 5
|
||||
\b0
|
||||
or \b 4
|
||||
\b0
|
||||
or \b 2
|
||||
\b0
|
||||
. \
|
||||
\
|
||||
|
||||
\b \qc 2
|
||||
\b0\
|
||||
\ql This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Go on to \b 4
|
||||
\b0
|
||||
. \
|
||||
\
|
||||
|
||||
\b \qc 3
|
||||
\b0\
|
||||
\ql This is the end. It is also included in the demo. \
|
||||
\
|
||||
|
||||
\b \qc 4
|
||||
\b0\
|
||||
\ql This is the second demo section. You can go on to the end at \b 3
|
||||
\b0
|
||||
or alternative (not in demo) end at \b 2
|
||||
\b0
|
||||
. \
|
||||
\
|
||||
|
||||
\b \qc 5
|
||||
\b0\
|
||||
\ql This is the first demo section (not counting the start section). You can go on to the end at \b 3
|
||||
\b0
|
||||
. \
|
||||
\
|
||||
|
||||
}
|
79
expected/withdemo.tex
Normal file
79
expected/withdemo.tex
Normal file
|
@ -0,0 +1,79 @@
|
|||
\documentclass[a5,onecolumn]{book}
|
||||
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[hidelinks]{hyperref}
|
||||
\usepackage{graphicx}
|
||||
|
||||
\usepackage[top=3.3cm, bottom=3.3cm, left=2cm, right=2cm]{geometry}
|
||||
\newif\ifpdf
|
||||
\ifx\pdfoutput\undefined
|
||||
\pdffalse
|
||||
\else
|
||||
\ifnum\pdfoutput=1
|
||||
\pdftrue
|
||||
\else
|
||||
\pdffalse
|
||||
\fi
|
||||
\fi
|
||||
|
||||
\title{Gamebook}
|
||||
\author{}
|
||||
\date{}
|
||||
|
||||
\newcounter{sectionnr}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section1}
|
||||
\subsection*{\begin{center} \textbf{1} \end{center}}
|
||||
|
||||
\noindent
|
||||
This gamebook contains a few sections tagged as demo, that will be included when building the example (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. Go on to \textbf{\autoref{section5}} or \textbf{\autoref{section4}} or \textbf{\autoref{section2}}.
|
||||
\vspace{1em}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section2}
|
||||
\subsection*{\begin{center} \textbf{2} \end{center}}
|
||||
|
||||
\noindent
|
||||
This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Go on to \textbf{\autoref{section4}}.
|
||||
\vspace{1em}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section3}
|
||||
\subsection*{\begin{center} \textbf{3} \end{center}}
|
||||
|
||||
\noindent
|
||||
This is the end. It is also included in the demo.
|
||||
\vspace{1em}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section4}
|
||||
\subsection*{\begin{center} \textbf{4} \end{center}}
|
||||
|
||||
\noindent
|
||||
This is the second demo section. You can go on to the end at \textbf{\autoref{section3}} or alternative (not in demo) end at \textbf{\autoref{section2}}.
|
||||
\vspace{1em}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section5}
|
||||
\subsection*{\begin{center} \textbf{5} \end{center}}
|
||||
|
||||
\noindent
|
||||
This is the first demo section (not counting the start section). You can go on to the end at \textbf{\autoref{section3}}.
|
||||
\vspace{1em}
|
||||
\end{document}
|
20
expected/withdemo.txt
Normal file
20
expected/withdemo.txt
Normal file
|
@ -0,0 +1,20 @@
|
|||
Gamebook
|
||||
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
1
|
||||
This gamebook contains a few sections tagged as demo, that will be included when building the example (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. Go on to 5 or 4 or 2.
|
||||
|
||||
2
|
||||
This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Go on to 4.
|
||||
|
||||
3
|
||||
This is the end. It is also included in the demo.
|
||||
|
||||
4
|
||||
This is the second demo section. You can go on to the end at 3 or alternative (not in demo) end at 2.
|
||||
|
||||
5
|
||||
This is the first demo section (not counting the start section). You can go on to the end at 3.
|
||||
|
15
expected/withoutdemo.debug
Normal file
15
expected/withoutdemo.debug
Normal file
|
@ -0,0 +1,15 @@
|
|||
BEGIN DEBUG OUTPUT
|
||||
Book title: Gamebook
|
||||
Number of sections: 8
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
1 (start) - This gamebook contains a few sections tagged as demo, that will be included when building the example as withdemo.gamebook (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. This version is built without options and includes all sections. Go on to 7 or 5 or 8.
|
||||
2 (altend) - Alternative end. Not included in the demo.
|
||||
3 (demoinfo) - This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Nothing should lead to this section when building without the demo tag option. Go on to 5.
|
||||
4 (theend) - This is the end. It is also included in the demo.
|
||||
5 (demo2) - This is the second demo section. You can go on to the end at 4 or alternative (not in demo) end at 2.
|
||||
6 (notindemo2) - This section is not included in the demo. You can go on to 5 or 4 or 2.
|
||||
7 (demo1) - This is the first demo section (not counting the start section). You can go on to the end at 4.
|
||||
8 (notindemo1) - This section is not included in the demo. Turn to 6.
|
||||
END DEBUG OUTPUT
|
19
expected/withoutdemo.dot
Normal file
19
expected/withoutdemo.dot
Normal file
|
@ -0,0 +1,19 @@
|
|||
digraph gamebook {
|
||||
|
||||
1->8
|
||||
|
||||
1->5
|
||||
|
||||
1->7
|
||||
3->5
|
||||
5->2
|
||||
|
||||
5->4
|
||||
6->4
|
||||
|
||||
6->5
|
||||
|
||||
6->2
|
||||
7->4
|
||||
8->6
|
||||
}
|
129
expected/withoutdemo.html
Normal file
129
expected/withoutdemo.html
Normal file
|
@ -0,0 +1,129 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>Gamebook</title>
|
||||
<script type="text/javascript" src="gamebookformatplay.js"></script>
|
||||
<link rel="stylesheet" href="gamebookformat.css"
|
||||
type="text/css" />
|
||||
<script>
|
||||
gamebook.id = 'withoutdemo';
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="hideintrolink nodisplay"
|
||||
onclick="gamebook.hideIntroSections()">(hide instructions)</div>
|
||||
<div class="gamebook">
|
||||
|
||||
<div class="resumelink nodisplay"
|
||||
onclick="gamebook.loadGame()">Resume saved game.</div>
|
||||
|
||||
<div class="startlink"
|
||||
onclick="gamebook.turnTo(1)">Turn to 1 to begin.</div>
|
||||
<script>
|
||||
if (gamebook.hasSavedGame()) {
|
||||
var resumeLinks = document.getElementsByClassName('resumelink');
|
||||
Array.prototype.forEach.call(resumeLinks, function(e) {
|
||||
e.classList.remove('nodisplay');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<div class="section" id="section1">
|
||||
<div class="sectionnumber" id="para1">1</div>
|
||||
<div class="sectiontext">
|
||||
This gamebook contains a few sections tagged as demo, that will be included when building the example as withdemo.gamebook (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. This version is built without options and includes all sections. Go on to <a class="sectionref enabledlink" data-ref="7">7</a> or <a class="sectionref enabledlink" data-ref="5">5</a> or <a class="sectionref enabledlink" data-ref="8">8</a>.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(1, document.getElementById('section1'));
|
||||
}
|
||||
</script><div class="section" id="section2">
|
||||
<div class="sectionnumber" id="para2">2</div>
|
||||
<div class="sectiontext">
|
||||
Alternative end. Not included in the demo.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(2, document.getElementById('section2'));
|
||||
}
|
||||
</script><div class="section" id="section3">
|
||||
<div class="sectionnumber" id="para3">3</div>
|
||||
<div class="sectiontext">
|
||||
This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Nothing should lead to this section when building without the demo tag option. Go on to <a class="sectionref enabledlink" data-ref="5">5</a>.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(3, document.getElementById('section3'));
|
||||
}
|
||||
</script><div class="section" id="section4">
|
||||
<div class="sectionnumber" id="para4">4</div>
|
||||
<div class="sectiontext">
|
||||
This is the end. It is also included in the demo.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(4, document.getElementById('section4'));
|
||||
}
|
||||
</script><div class="section" id="section5">
|
||||
<div class="sectionnumber" id="para5">5</div>
|
||||
<div class="sectiontext">
|
||||
This is the second demo section. You can go on to the end at <a class="sectionref enabledlink" data-ref="4">4</a> or alternative (not in demo) end at <a class="sectionref enabledlink" data-ref="2">2</a>.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(5, document.getElementById('section5'));
|
||||
}
|
||||
</script><div class="section" id="section6">
|
||||
<div class="sectionnumber" id="para6">6</div>
|
||||
<div class="sectiontext">
|
||||
This section is not included in the demo. You can go on to <a class="sectionref enabledlink" data-ref="5">5</a> or <a class="sectionref enabledlink" data-ref="4">4</a> or <a class="sectionref enabledlink" data-ref="2">2</a>.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(6, document.getElementById('section6'));
|
||||
}
|
||||
</script><div class="section" id="section7">
|
||||
<div class="sectionnumber" id="para7">7</div>
|
||||
<div class="sectiontext">
|
||||
This is the first demo section (not counting the start section). You can go on to the end at <a class="sectionref enabledlink" data-ref="4">4</a>.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(7, document.getElementById('section7'));
|
||||
}
|
||||
</script><div class="section" id="section8">
|
||||
<div class="sectionnumber" id="para8">8</div>
|
||||
<div class="sectiontext">
|
||||
This section is not included in the demo. Turn to <a class="sectionref enabledlink" data-ref="6">6</a>.
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.addSection(8, document.getElementById('section8'));
|
||||
}
|
||||
</script> <div id="collections" class="collections">
|
||||
</div>
|
||||
<div id="collectionTemplate" class="collectionTemplate">
|
||||
<span class="collectionheading"></span>
|
||||
<span class="collectioncontents"></span>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
if (this.gamebook) {
|
||||
gamebook.runActionsInIntroSections();
|
||||
}
|
||||
</script>
|
||||
<div class="displayintrolink nodisplay"
|
||||
onclick="gamebook.showIntroSections()">(show instructions)</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
77
expected/withoutdemo.rtf
Normal file
77
expected/withoutdemo.rtf
Normal file
|
@ -0,0 +1,77 @@
|
|||
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
|
||||
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\paperw11900\paperh16840\margl1440\margr1440\vieww14140\viewh14860\viewkind0
|
||||
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\b\fs24 \cf0
|
||||
|
||||
\b \qc Gamebook
|
||||
\b0\
|
||||
|
||||
\b Turn to 1 to begin.
|
||||
\b0\
|
||||
\
|
||||
\b \qc 1
|
||||
\b0\
|
||||
\ql This gamebook contains a few sections tagged as demo, that will be included when building the example as withdemo.gamebook (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. This version is built without options and includes all sections. Go on to \b 7
|
||||
\b0
|
||||
or \b 5
|
||||
\b0
|
||||
or \b 8
|
||||
\b0
|
||||
. \
|
||||
\
|
||||
|
||||
\b \qc 2
|
||||
\b0\
|
||||
\ql Alternative end. Not included in the demo. \
|
||||
\
|
||||
|
||||
\b \qc 3
|
||||
\b0\
|
||||
\ql This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Nothing should lead to this section when building without the demo tag option. Go on to \b 5
|
||||
\b0
|
||||
. \
|
||||
\
|
||||
|
||||
\b \qc 4
|
||||
\b0\
|
||||
\ql This is the end. It is also included in the demo. \
|
||||
\
|
||||
|
||||
\b \qc 5
|
||||
\b0\
|
||||
\ql This is the second demo section. You can go on to the end at \b 4
|
||||
\b0
|
||||
or alternative (not in demo) end at \b 2
|
||||
\b0
|
||||
. \
|
||||
\
|
||||
|
||||
\b \qc 6
|
||||
\b0\
|
||||
\ql This section is not included in the demo. You can go on to \b 5
|
||||
\b0
|
||||
or \b 4
|
||||
\b0
|
||||
or \b 2
|
||||
\b0
|
||||
. \
|
||||
\
|
||||
|
||||
\b \qc 7
|
||||
\b0\
|
||||
\ql This is the first demo section (not counting the start section). You can go on to the end at \b 4
|
||||
\b0
|
||||
. \
|
||||
\
|
||||
|
||||
\b \qc 8
|
||||
\b0\
|
||||
\ql This section is not included in the demo. Turn to \b 6
|
||||
\b0
|
||||
. \
|
||||
\
|
||||
|
||||
}
|
103
expected/withoutdemo.tex
Normal file
103
expected/withoutdemo.tex
Normal file
|
@ -0,0 +1,103 @@
|
|||
\documentclass[a5,onecolumn]{book}
|
||||
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage[T1]{fontenc}
|
||||
\usepackage[hidelinks]{hyperref}
|
||||
\usepackage{graphicx}
|
||||
|
||||
\usepackage[top=3.3cm, bottom=3.3cm, left=2cm, right=2cm]{geometry}
|
||||
\newif\ifpdf
|
||||
\ifx\pdfoutput\undefined
|
||||
\pdffalse
|
||||
\else
|
||||
\ifnum\pdfoutput=1
|
||||
\pdftrue
|
||||
\else
|
||||
\pdffalse
|
||||
\fi
|
||||
\fi
|
||||
|
||||
\title{Gamebook}
|
||||
\author{}
|
||||
\date{}
|
||||
|
||||
\newcounter{sectionnr}
|
||||
|
||||
\begin{document}
|
||||
|
||||
\maketitle
|
||||
|
||||
\thispagestyle{empty}
|
||||
|
||||
\pagestyle{empty}
|
||||
|
||||
\clearpage
|
||||
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section1}
|
||||
\subsection*{\begin{center} \textbf{1} \end{center}}
|
||||
|
||||
\noindent
|
||||
This gamebook contains a few sections tagged as demo, that will be included when building the example as withdemo.gamebook (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. This version is built without options and includes all sections. Go on to \textbf{\autoref{section7}} or \textbf{\autoref{section5}} or \textbf{\autoref{section8}}.
|
||||
\vspace{1em}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section2}
|
||||
\subsection*{\begin{center} \textbf{2} \end{center}}
|
||||
|
||||
\noindent
|
||||
Alternative end. Not included in the demo.
|
||||
\vspace{1em}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section3}
|
||||
\subsection*{\begin{center} \textbf{3} \end{center}}
|
||||
|
||||
\noindent
|
||||
This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Nothing should lead to this section when building without the demo tag option. Go on to \textbf{\autoref{section5}}.
|
||||
\vspace{1em}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section4}
|
||||
\subsection*{\begin{center} \textbf{4} \end{center}}
|
||||
|
||||
\noindent
|
||||
This is the end. It is also included in the demo.
|
||||
\vspace{1em}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section5}
|
||||
\subsection*{\begin{center} \textbf{5} \end{center}}
|
||||
|
||||
\noindent
|
||||
This is the second demo section. You can go on to the end at \textbf{\autoref{section4}} or alternative (not in demo) end at \textbf{\autoref{section2}}.
|
||||
\vspace{1em}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section6}
|
||||
\subsection*{\begin{center} \textbf{6} \end{center}}
|
||||
|
||||
\noindent
|
||||
This section is not included in the demo. You can go on to \textbf{\autoref{section5}} or \textbf{\autoref{section4}} or \textbf{\autoref{section2}}.
|
||||
\vspace{1em}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section7}
|
||||
\subsection*{\begin{center} \textbf{7} \end{center}}
|
||||
|
||||
\noindent
|
||||
This is the first demo section (not counting the start section). You can go on to the end at \textbf{\autoref{section4}}.
|
||||
\vspace{1em}
|
||||
\phantomsection
|
||||
\refstepcounter{sectionnr}
|
||||
\label{section8}
|
||||
\subsection*{\begin{center} \textbf{8} \end{center}}
|
||||
|
||||
\noindent
|
||||
This section is not included in the demo. Turn to \textbf{\autoref{section6}}.
|
||||
\vspace{1em}
|
||||
\end{document}
|
29
expected/withoutdemo.txt
Normal file
29
expected/withoutdemo.txt
Normal file
|
@ -0,0 +1,29 @@
|
|||
Gamebook
|
||||
|
||||
|
||||
|
||||
Turn to 1 to begin.
|
||||
1
|
||||
This gamebook contains a few sections tagged as demo, that will be included when building the example as withdemo.gamebook (see withdemo.gamebook.options file). There are also some sections without the demo tag that will be ignored. This version is built without options and includes all sections. Go on to 7 or 5 or 8.
|
||||
|
||||
2
|
||||
Alternative end. Not included in the demo.
|
||||
|
||||
3
|
||||
This is where references to non-demo sections will lead you. It is configured at the top of the gamebook file. Remember to tag this section correctly to be included. Nothing should lead to this section when building without the demo tag option. Go on to 5.
|
||||
|
||||
4
|
||||
This is the end. It is also included in the demo.
|
||||
|
||||
5
|
||||
This is the second demo section. You can go on to the end at 4 or alternative (not in demo) end at 2.
|
||||
|
||||
6
|
||||
This section is not included in the demo. You can go on to 5 or 4 or 2.
|
||||
|
||||
7
|
||||
This is the first demo section (not counting the start section). You can go on to the end at 4.
|
||||
|
||||
8
|
||||
This section is not included in the demo. Turn to 6.
|
||||
|
13
sections.py
13
sections.py
|
@ -43,7 +43,8 @@ class IntroSection (Section):
|
|||
repr(self.tags))
|
||||
|
||||
class ShuffledSections:
|
||||
def __init__(self, as_list, from_nr, from_name, nr_sections):
|
||||
def __init__(self, as_list, from_nr, from_name, nr_sections,
|
||||
skipped_names, missingto):
|
||||
self.as_list = as_list
|
||||
self.from_nr = from_nr
|
||||
self.from_name = from_name
|
||||
|
@ -52,9 +53,11 @@ class ShuffledSections:
|
|||
self.name_to_nr[n] = from_name[n].nr
|
||||
for nr in nr_sections:
|
||||
self.name_to_nr[nr_sections[nr]] = nr
|
||||
for name in skipped_names:
|
||||
self.name_to_nr[name] = self.name_to_nr[missingto]
|
||||
|
||||
STR_BOOK_CONFIG = set(['id', 'title', 'author', 'starttext', 'hideintrotext',
|
||||
'showintrotext', 'resumetext'])
|
||||
'showintrotext', 'resumetext', 'missingto'])
|
||||
INT_BOOK_CONFIG = set(['max'])
|
||||
|
||||
class Book:
|
||||
|
@ -65,6 +68,7 @@ class Book:
|
|||
self.nr_sections = {}
|
||||
self.codewords = set()
|
||||
self.includetag = includetag
|
||||
self.skipped_names = set()
|
||||
self.config = {'max' : 0,
|
||||
'title' : 'Gamebook',
|
||||
'author' : '',
|
||||
|
@ -72,6 +76,7 @@ class Book:
|
|||
'hideintrotext' : '(hide instructions)',
|
||||
'showintrotext' : '(show instructions)',
|
||||
'resumetext' : 'Resume saved game.',
|
||||
'missingto' : None,
|
||||
'id' : bookid}
|
||||
|
||||
def configure(self, name, value):
|
||||
|
@ -84,6 +89,7 @@ class Book:
|
|||
|
||||
def add(self, section):
|
||||
if self.includetag and not section.hastag(self.includetag):
|
||||
self.skipped_names.add(section.name)
|
||||
return
|
||||
if section.name in self.from_name:
|
||||
raise Exception('Duplicate section names (%s) not allowed.' %
|
||||
|
@ -132,4 +138,5 @@ class Book:
|
|||
if section:
|
||||
shuffled_from_name[section.name] = section
|
||||
return ShuffledSections(as_list, from_nr, shuffled_from_name,
|
||||
self.nr_sections)
|
||||
self.nr_sections, self.skipped_names,
|
||||
self.config['missingto'])
|
||||
|
|
4
todo.org
4
todo.org
|
@ -1,4 +1,4 @@
|
|||
* TODO [44/72] [61%]
|
||||
* TODO [45/72] [62%]
|
||||
- [X] Debug output
|
||||
- [X] DOT output
|
||||
- [X] LaTeX output
|
||||
|
@ -49,7 +49,7 @@
|
|||
- [X] Unit tests (finally...)
|
||||
- [X] Save game (ie player) state
|
||||
- [X] Load game (ie player) state
|
||||
- [ ] Flag to select what tag(s) to include (eg for demo/preview/short...)
|
||||
- [X] Flag to select what tag(s) to include (eg for demo/preview/short...)
|
||||
Allow sections with same name as long as only one is included.
|
||||
Add book config for what section to use for references to excluded sections
|
||||
(eg links to outside of demo version can lead to section explaining that)
|
||||
|
|
Loading…
Reference in a new issue