Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ea9d436ce | |||
| c05e4e528e | |||
| e10488b77a | |||
| 86e0cb3331 | |||
| c6397c08af | |||
| f9db64231d | |||
| f3c3c67def | |||
| 6d316a9c78 | |||
| 6e7e68b31a | |||
| a24e6b2af1 | |||
| 597b01c26b | |||
| a262eb0f60 | |||
| 92006d237c | |||
| 1427336746 | |||
| c35ed8a7cd | |||
| 90f47eacf3 | |||
| ee093925f5 | |||
| f686a810a7 | |||
| e2a12284d5 | |||
| 10b4064a53 | |||
| f1ea5289aa | |||
| a26ed9c328 |
@@ -1,54 +0,0 @@
|
||||
*.rpyc
|
||||
*.rpyb
|
||||
*.rpymc
|
||||
*.pyc
|
||||
*.pyo
|
||||
|
||||
*~
|
||||
*.bak
|
||||
|
||||
saves
|
||||
tmp
|
||||
cache
|
||||
|
||||
log.txt
|
||||
|
||||
/build
|
||||
/dist
|
||||
/dists
|
||||
/renpy.app
|
||||
/jedit
|
||||
/lint.txt
|
||||
/renpy.code
|
||||
/traceback.txt
|
||||
/testing*
|
||||
/screenshot*
|
||||
/errors.txt
|
||||
/styles.txt
|
||||
/Microsoft.VC90.CRT.manifest
|
||||
/console.exe
|
||||
/msvcr90.dll
|
||||
/python27.dll
|
||||
/renpy.exe
|
||||
/lib/windows-x86
|
||||
/lib/linux-x86_64
|
||||
/lib/linux-i686
|
||||
/lib/python2.7
|
||||
/doc
|
||||
/.pydevproject
|
||||
/.pydevproject.bak
|
||||
/.project
|
||||
/.settings
|
||||
/LICENSE.txt
|
||||
/template/README.html
|
||||
/the_question/README.html
|
||||
/tutorial/README.html
|
||||
/renpy/angle/*.pyx
|
||||
/renpy/angle/*.pxd
|
||||
/renpy-ppc.zip
|
||||
/module/build
|
||||
/module/gen
|
||||
/editra
|
||||
|
||||
dl
|
||||
renpy/vc_version.py
|
||||
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# This program adds froms to every unqualified call found in the game
|
||||
# directory. It's not perfect, but it's better than nothing.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
|
||||
def find_labels(fn, labels):
|
||||
|
||||
f = file(fn, "r")
|
||||
|
||||
for l in f:
|
||||
|
||||
m = re.match(r'^\s*call\s+\w+\s+from\s+(\w+)\s*$', l)
|
||||
if m:
|
||||
labels[m.group(1)] = True
|
||||
|
||||
f.close()
|
||||
|
||||
def replace_labels(fn, labels):
|
||||
|
||||
f = file(fn, "r")
|
||||
of = file(fn + ".new", "w")
|
||||
|
||||
|
||||
def replaceit(m):
|
||||
target = m.group(2)
|
||||
|
||||
num = 0
|
||||
|
||||
while True:
|
||||
num += 1
|
||||
label = "_call_%s_%d" % (target, num)
|
||||
|
||||
if label not in labels:
|
||||
break
|
||||
|
||||
labels[label] = True
|
||||
|
||||
return m.group(1) + "call " + target + " from " + label + m.group(3)
|
||||
|
||||
for l in f:
|
||||
l = re.sub(r'^(\s*)call\s+(\w+)(\s*$)', replaceit, l)
|
||||
of.write(l)
|
||||
|
||||
f.close()
|
||||
of.close()
|
||||
|
||||
os.rename(fn, fn + ".bak")
|
||||
os.rename(fn + ".new", fn)
|
||||
|
||||
def main():
|
||||
|
||||
gamedir = "game"
|
||||
|
||||
if len(sys.argv) >= 2:
|
||||
gamedir = sys.argv[1]
|
||||
|
||||
print "Processing files in", gamedir
|
||||
|
||||
files = [ gamedir + "/" + i for i in os.listdir(gamedir)
|
||||
if i.endswith(".rpy") ]
|
||||
|
||||
labels = { }
|
||||
|
||||
for fn in files:
|
||||
print "Finding labels in", fn
|
||||
find_labels(fn, labels)
|
||||
|
||||
for fn in files:
|
||||
print "Replacing labels in", fn
|
||||
replace_labels(fn, labels)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
ln -s ../help.html tutorial/README.html
|
||||
ln -s ../help.html the_question/README.html
|
||||
ln -s ../help.html template/README.html
|
||||
|
||||
ln -s sphinx/source/license.rst LICENSE.txt
|
||||
ln -s sphinx/build/html doc
|
||||
@@ -1,10 +0,0 @@
|
||||
# This file sets up the normal python modules. It's used to help eclipse
|
||||
# do type detection, by providing an importable version of the cython code.
|
||||
|
||||
from distutils.core import setup
|
||||
|
||||
setup(
|
||||
packages=['renpy', 'renpy.gl', 'renpy.angle', 'renpy.display', 'renpy.audio', 'renpy.text', 'pysdlsound'],
|
||||
package_dir={ 'pysdlsound' : 'module' },
|
||||
)
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
cd images
|
||||
..\archiver.exe images *.png *.jpg
|
||||
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# The Ren'Py archiver. This builds a Ren'Py archive file, and the
|
||||
# associated index file. These files are really easy to reverse-engineer,
|
||||
# but are probably better than nothing.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import encodings.zlib_codec
|
||||
import random
|
||||
|
||||
from cPickle import loads, dumps, HIGHEST_PROTOCOL
|
||||
|
||||
# The most we will go without inserting some padding. 10k.
|
||||
padding_every = 10240
|
||||
|
||||
# The amount of padding we will add.
|
||||
padding_max = 32
|
||||
|
||||
def randpadding():
|
||||
|
||||
plen = random.randint(1, padding_max)
|
||||
|
||||
rv = ""
|
||||
|
||||
for i in range(0, plen):
|
||||
rv += chr(random.randint(1, 255))
|
||||
|
||||
return rv
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 3:
|
||||
print "Usage: %s <file-prefix> <files ...>" % sys.argv[0]
|
||||
return
|
||||
|
||||
prefix = sys.argv[1]
|
||||
|
||||
# Archive file.
|
||||
archivef = file(prefix + ".rpa", "wb")
|
||||
|
||||
# Index file.
|
||||
indexf = file(prefix + ".rpi", "wb")
|
||||
|
||||
index = { }
|
||||
|
||||
random.seed()
|
||||
|
||||
offset = 0
|
||||
|
||||
for fn in sys.argv[2:]:
|
||||
index[fn] = [ ]
|
||||
|
||||
print "Adding %s..." % fn
|
||||
|
||||
datafile = file(fn, "rb")
|
||||
|
||||
while True:
|
||||
|
||||
# Pad with junk.
|
||||
padding = randpadding()
|
||||
archivef.write(padding)
|
||||
offset += len(padding)
|
||||
|
||||
# Pick a random block size.
|
||||
block = random.randint(1, padding_every)
|
||||
|
||||
data = datafile.read(block)
|
||||
|
||||
if not data:
|
||||
break
|
||||
|
||||
dlen = len(data)
|
||||
|
||||
archivef.write(data)
|
||||
|
||||
index[fn].append((offset, dlen))
|
||||
offset += dlen
|
||||
|
||||
datafile.close()
|
||||
|
||||
archivef.close()
|
||||
|
||||
indexf.write(dumps(index, HIGHEST_PROTOCOL).encode("zlib"))
|
||||
indexf.close()
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,111 +1,31 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import modulefinder
|
||||
import shutil
|
||||
from distutils.core import setup
|
||||
import py2exe #@UnresolvedImport @UnusedImport
|
||||
import py2exe
|
||||
import sys
|
||||
import zipfile
|
||||
import traceback
|
||||
import os
|
||||
|
||||
# The pythonpath on my system.
|
||||
sys.path.insert(0, 'c:\\msys\\1.0\\newbuild\\install\\bin')
|
||||
sys.path.insert(0, 'c:\\msys\\1.0\\newbuild\\install\\python')
|
||||
if len(sys.argv) != 2:
|
||||
print "Usage: build_exe.py <prefix>"
|
||||
print ""
|
||||
print "Builds <prefix>.exe."
|
||||
print "Expects icons in <prefix>.ico."
|
||||
|
||||
def move_from_dist(fn):
|
||||
"""
|
||||
Moves the file `fn` from the dist directory to the main
|
||||
directory. (This means we don't need symlinks on windows.)
|
||||
"""
|
||||
sys.exit(-1)
|
||||
|
||||
if os.path.isdir(fn):
|
||||
shutil.rmtree(fn)
|
||||
elif os.path.exists(fn):
|
||||
os.unlink(fn)
|
||||
def program(name):
|
||||
return dict(script="run_game.py",
|
||||
icon_resources=[ (0, name + ".ico"),
|
||||
],
|
||||
dest_base=name)
|
||||
|
||||
os.rename("dist/" + fn, fn)
|
||||
programs = [
|
||||
program(sys.argv[1]),
|
||||
]
|
||||
|
||||
import renpy
|
||||
renpy.setup_modulefinder(modulefinder) #@UndefinedVariable
|
||||
sys.argv[1:] = [ 'py2exe' ]
|
||||
|
||||
def main():
|
||||
|
||||
sys.argv[1:] = [ 'py2exe', '-a', '--dll-excludes', 'w9xpopen.exe', ]
|
||||
|
||||
setup(name="Ren'Py",
|
||||
windows=[ dict(script="renpy.py",
|
||||
dest_base="renpy",
|
||||
icon_resources=[ (1, "newicon.ico") ],
|
||||
),
|
||||
],
|
||||
|
||||
console=[ dict(script="renpy.py", dest_base="console") ],
|
||||
|
||||
zipfile='lib/windows-x86/renpy.code',
|
||||
|
||||
options={ 'py2exe' : { 'excludes' : [ 'doctest',
|
||||
'pygame.macosx',
|
||||
'pygame.surfarray',
|
||||
'pygame.mixer',
|
||||
'pygame.mixer_music',
|
||||
'_ssl',
|
||||
'_hashlib',
|
||||
'win32con',
|
||||
'win32api',
|
||||
'Numeric',
|
||||
'os2emxpath',
|
||||
'macpath',
|
||||
'multiprocessing',
|
||||
'_multiprocessing',
|
||||
],
|
||||
'optimize' : 2,
|
||||
} },
|
||||
)
|
||||
|
||||
|
||||
zfold = zipfile.ZipFile("dist/lib/windows-x86/renpy.code")
|
||||
zfnew = zipfile.ZipFile("dist/lib/windows-x86/renpy.code.new", "w", zipfile.ZIP_STORED)
|
||||
|
||||
seen = { }
|
||||
|
||||
for fn in zfold.namelist():
|
||||
if fn.startswith("renpy/"):
|
||||
|
||||
# Keep around .pyo files that load pyd files.
|
||||
pydfn = fn.replace("/", ".").replace(".pyo", ".pyd")
|
||||
if not os.path.exists("dist/lib/windows-x86/" + pydfn):
|
||||
continue
|
||||
|
||||
if fn in seen:
|
||||
continue
|
||||
|
||||
if fn == "SDL_mixer.dll":
|
||||
continue
|
||||
|
||||
seen[fn] = True
|
||||
|
||||
zfnew.writestr(fn, zfold.read(fn))
|
||||
|
||||
zfold.close()
|
||||
zfnew.close()
|
||||
|
||||
os.unlink("dist/lib/windows-x86/renpy.code")
|
||||
os.rename("dist/lib/windows-x86/renpy.code.new", "dist/lib/windows-x86/renpy.code")
|
||||
|
||||
# Take these files from the old python.
|
||||
shutil.copy("c:/Python26/Microsoft.VC90.CRT.manifest", "Microsoft.VC90.CRT.manifest")
|
||||
shutil.copy("c:/Python26/msvcr90.dll", "msvcr90.dll")
|
||||
|
||||
move_from_dist("lib/windows-x86")
|
||||
move_from_dist("console.exe")
|
||||
move_from_dist("python27.dll")
|
||||
move_from_dist("renpy.exe")
|
||||
|
||||
|
||||
try:
|
||||
main()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
setup(name="RenPy",
|
||||
windows=programs,
|
||||
console=[ "archiver.py", "add_from.py" ],
|
||||
zipfile='lib/renpy.zip',
|
||||
)
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import collections
|
||||
import glob
|
||||
import re
|
||||
import os
|
||||
|
||||
# A map from string to filename, line number where the string is found.
|
||||
strings = collections.defaultdict(list)
|
||||
|
||||
def process(fn):
|
||||
|
||||
lineno = 0
|
||||
|
||||
for data in file(fn, "r"):
|
||||
|
||||
lineno += 1
|
||||
|
||||
matches = [ ]
|
||||
|
||||
matches += re.finditer(r'\bu\"(\\"|[^"])+\"', data)
|
||||
matches += re.finditer(r"\bu\'(\\'|[^'])+\'", data)
|
||||
|
||||
for m in matches:
|
||||
s = m.group(0)[2:-1]
|
||||
|
||||
if "\\u" in s:
|
||||
continue
|
||||
|
||||
if len(s) == 1:
|
||||
continue
|
||||
|
||||
strings[s].append("%s:%d" % (fn, lineno))
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
files = [ ]
|
||||
|
||||
files += glob.glob("launcher/*.rpy")
|
||||
files += glob.glob("common/*.rpy")
|
||||
files += glob.glob("common/*.rpym")
|
||||
files += glob.glob("common/_layout/*.rpym")
|
||||
files += glob.glob("common/_compat/*.rpym")
|
||||
|
||||
if "launcher/strings.rpy" in files:
|
||||
files.remove("launcher/strings.rpy")
|
||||
|
||||
for fn in files:
|
||||
process(fn)
|
||||
|
||||
converse = [ ]
|
||||
|
||||
for k, v in strings.iteritems():
|
||||
v = " ".join(sorted(v))
|
||||
converse.append((v, k))
|
||||
|
||||
converse.sort()
|
||||
|
||||
f = file("launcher/strings.rpy", "w")
|
||||
|
||||
files = set(i for i in os.listdir("launcher") if i.endswith(".rpy"))
|
||||
|
||||
print >>f, """\
|
||||
init python:
|
||||
LAUNCHER_RPYS = %r
|
||||
|
||||
TRANSLATION_STRINGS = [
|
||||
""" % files
|
||||
|
||||
for v, k in converse:
|
||||
# print
|
||||
# print "#:", v
|
||||
# print "#, python-format"
|
||||
|
||||
print >>f, " u\"%s\"," % unicode(k)
|
||||
|
||||
print >>f, """\
|
||||
]
|
||||
"""
|
||||
@@ -1,35 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# This file contains warpers that are used by ATL. They need to be defined
|
||||
# early, so Ren'Py knows about them when parsing other files.
|
||||
|
||||
python early hide:
|
||||
|
||||
# pause is defined internally, but would look like:
|
||||
#
|
||||
# @renpy.atl_warper
|
||||
# def pause(t):
|
||||
# if t >= 1.0:
|
||||
# return 1.0
|
||||
# else:
|
||||
# return 0.0
|
||||
|
||||
@renpy.atl_warper
|
||||
def linear(t):
|
||||
return t
|
||||
|
||||
@renpy.atl_warper
|
||||
def easeout(x):
|
||||
import math
|
||||
return 1.0 - math.cos(x * math.pi / 2.0)
|
||||
|
||||
@renpy.atl_warper
|
||||
def easein(x):
|
||||
import math
|
||||
return math.cos((1.0 - x) * math.pi / 2.0)
|
||||
|
||||
@renpy.atl_warper
|
||||
def ease(x):
|
||||
import math
|
||||
return .5 - math.cos(math.pi * x) / 2.0
|
||||
@@ -1,301 +0,0 @@
|
||||
|
||||
# Contains functions and variables that control the building of
|
||||
# distributions.
|
||||
|
||||
init -1000 python in build:
|
||||
|
||||
def make_file_lists(s):
|
||||
"""
|
||||
Turns `s` into a (perhaps empty) list of file_lists.
|
||||
|
||||
If `s` is a list or None, then returns it. If it's a string, splits
|
||||
it on whitespace. Otherwise, errors out.
|
||||
"""
|
||||
|
||||
if s is None:
|
||||
return s
|
||||
elif isinstance(s, list):
|
||||
return s
|
||||
elif isinstance(s, basestring):
|
||||
return s.split()
|
||||
|
||||
raise Exception("Expected a string, list, or None.")
|
||||
|
||||
|
||||
|
||||
def pattern_list(l):
|
||||
"""
|
||||
Apply file_lists to the second argument of each tuple in a list.
|
||||
"""
|
||||
|
||||
rv = [ ]
|
||||
|
||||
for pattern, groups in l:
|
||||
rv.append((pattern, make_file_lists(groups)))
|
||||
|
||||
return rv
|
||||
|
||||
# Patterns that are used to classify Ren'Py.
|
||||
renpy_patterns = pattern_list([
|
||||
( "**~", None),
|
||||
( "**/#*", None),
|
||||
( "**/.*", None),
|
||||
( "**.old", None),
|
||||
( "**.new", None),
|
||||
( "**.rpa", None),
|
||||
|
||||
( "**/*.pyc", None),
|
||||
|
||||
( "renpy.py", "all"),
|
||||
( "renpy/**", "all"),
|
||||
( "common/**", "all"),
|
||||
|
||||
# Windows-specific patterns.
|
||||
( "python*.dll", "windows" ),
|
||||
( "msvcr*.dll", "windows"),
|
||||
( "Microsoft.VC*.CRT.manifest", "windows"),
|
||||
( "lib/dxwebsetup.exe", "windows"),
|
||||
( "lib/windows-x86/**", "windows"),
|
||||
|
||||
# Linux patterns.
|
||||
( "renpy.sh", "linux"),
|
||||
( "lib/linux-x86_64/**", "linux"),
|
||||
( "lib/linux-i686/**", "linux"),
|
||||
( "lib/python2.7/**", "linux"),
|
||||
|
||||
# Mac patterns.
|
||||
( "renpy.app/Contents/Ren'Py Launcher", None),
|
||||
( "renpy.app/Contents/Info.plist", None),
|
||||
( "renpy.app/Contents/Resources/launcher.py", None),
|
||||
( "renpy.app/Contents/Resources/launcher.icns", None),
|
||||
( "renpy.app/**", "mac"),
|
||||
|
||||
# Shared patterns.
|
||||
( "/lib/", "windows linux"),
|
||||
])
|
||||
|
||||
|
||||
def classify_renpy(pattern, groups):
|
||||
"""
|
||||
Classifies files in the Ren'Py base directory according to pattern.
|
||||
"""
|
||||
|
||||
renpy_patterns.append((pattern, make_file_lists(groups)))
|
||||
|
||||
# Patterns that are relative to the base directory.
|
||||
|
||||
early_base_patterns = pattern_list([
|
||||
("*.py", None),
|
||||
("*.sh", None),
|
||||
("*.app/", None),
|
||||
("*.dll", None),
|
||||
("*.manifest", None),
|
||||
|
||||
("lib/", None),
|
||||
("renpy/", None),
|
||||
("update/", None),
|
||||
("common/", None),
|
||||
("update/", None),
|
||||
|
||||
("icon.ico", None),
|
||||
("icon.icns", None),
|
||||
("project.json", None),
|
||||
|
||||
("tmp/", None),
|
||||
("game/saves/", None),
|
||||
|
||||
("archived/", None),
|
||||
("launcherinfo.py", None),
|
||||
("android.txt", None),
|
||||
])
|
||||
|
||||
base_patterns = [ ]
|
||||
|
||||
late_base_patterns = pattern_list([
|
||||
("**", "all")
|
||||
])
|
||||
|
||||
def classify(pattern, file_list):
|
||||
"""
|
||||
:doc: build
|
||||
|
||||
Classifies files that match `pattern` into `file_list`.
|
||||
"""
|
||||
|
||||
base_patterns.append((pattern, make_file_lists(file_list)))
|
||||
|
||||
def clear():
|
||||
"""
|
||||
:doc: build
|
||||
|
||||
Clears the list of patterns used to classify files.
|
||||
"""
|
||||
|
||||
base_patterns[:] = [ ]
|
||||
|
||||
def remove(l, pattern):
|
||||
"""
|
||||
Removes the pattern from the list.
|
||||
"""
|
||||
|
||||
l[:] = [ (p, fl) for i in l if p != pattern ]
|
||||
|
||||
# Archiving.
|
||||
|
||||
archives = [ ]
|
||||
|
||||
def archive(name, file_list="all"):
|
||||
"""
|
||||
:doc: build
|
||||
|
||||
Declares the existence of an archive. If one or more files are
|
||||
classified with `name`, `name`.rpa is build as an archive. The
|
||||
archive is included in the named file lists.
|
||||
"""
|
||||
|
||||
archives.append((name, make_file_lists(file_list)))
|
||||
|
||||
archive("archive", "all")
|
||||
|
||||
# Documentation patterns.
|
||||
|
||||
documentation_patterns = [ ]
|
||||
|
||||
def documentation(pattern):
|
||||
"""
|
||||
:doc: build
|
||||
|
||||
Declares a pattern that matches documentation. In a mac app build,
|
||||
files matching the documentation pattern are stored twice - once
|
||||
inside the app package, and again outside of it.
|
||||
"""
|
||||
|
||||
documentation_patterns.append(pattern)
|
||||
|
||||
xbit_patterns = [
|
||||
"**.sh",
|
||||
"**/*.so.*",
|
||||
"**/*.so",
|
||||
"**/*.dylib",
|
||||
"**.app/Contents/MacOS/*",
|
||||
"lib/**/python",
|
||||
"lib/**/zsync",
|
||||
"lib/**/zsyncmake",
|
||||
]
|
||||
|
||||
def executable(pattern):
|
||||
"""
|
||||
:doc: build
|
||||
|
||||
Adds a pattern marking files as executable on platforms that support it.
|
||||
(Linux and Macintosh)
|
||||
"""
|
||||
|
||||
xbit_patterns.append(pattern)
|
||||
|
||||
# Packaging.
|
||||
|
||||
packages = [ ]
|
||||
|
||||
def package(name, format, file_lists, description=None, update=True, dlc=False):
|
||||
"""
|
||||
:doc: build
|
||||
|
||||
Declares a package that can be built by the packaging
|
||||
tool.
|
||||
|
||||
`name`
|
||||
The name of the package.
|
||||
|
||||
`format`
|
||||
The format of the package. A string containing a space separated
|
||||
list of:
|
||||
|
||||
zip
|
||||
A zip file.
|
||||
app-zip
|
||||
A zip file containing a macintosh application.
|
||||
tar.bz2
|
||||
A tar.bz2 file.
|
||||
|
||||
The empty string will not build any package formats (this
|
||||
makes dlc possible).
|
||||
|
||||
`file_lists`
|
||||
A list containing the file lists that will be contained
|
||||
within the package.
|
||||
|
||||
`description`
|
||||
An optional description of the package to be built.
|
||||
|
||||
`update`
|
||||
If true and updates are being built, an update will be
|
||||
built for this package.
|
||||
|
||||
`dlc`
|
||||
If true, any zip or tar.bz2 file will be built in
|
||||
standalone DLC mode, without an update directory.
|
||||
"""
|
||||
|
||||
formats = format.split()
|
||||
|
||||
for i in formats:
|
||||
if i not in [ "zip", "app-zip", "tar.bz2" ]:
|
||||
raise Exception("Format {} not known.".format(i))
|
||||
|
||||
if description is None:
|
||||
description = name
|
||||
|
||||
d = {
|
||||
"name" : name,
|
||||
"formats" : formats,
|
||||
"file_lists" : make_file_lists(file_lists),
|
||||
"description" : description,
|
||||
"update" : update,
|
||||
"dlc" : dlc,
|
||||
}
|
||||
|
||||
packages.append(d)
|
||||
|
||||
package("all", "zip", "windows mac linux all", "All Desktop Platforms")
|
||||
package("linux", "tar.bz2", "linux all", "Linux x86/x86_64")
|
||||
package("mac", "app-zip", "mac all", "Macintosh x86")
|
||||
package("win", "zip", "windows all", "Windows x86")
|
||||
|
||||
# Data that we expect the user to set.
|
||||
|
||||
# The name of directories in the archives.
|
||||
directory_name = ""
|
||||
|
||||
# The name of executables.
|
||||
executable_name = ""
|
||||
|
||||
# Should we include update information into the archives?
|
||||
include_update = False
|
||||
|
||||
# A verbose version to include in the update.
|
||||
version = None
|
||||
|
||||
# Are we building Ren'Py?
|
||||
renpy = False
|
||||
|
||||
# This function is called by the json_dump command to dump the build data
|
||||
# into the json file.
|
||||
def dump():
|
||||
rv = { }
|
||||
|
||||
rv["directory_name"] = directory_name
|
||||
rv["executable_name"] = executable_name
|
||||
rv["include_update"] = include_update
|
||||
|
||||
rv["packages"] = packages
|
||||
rv["archives"] = archives
|
||||
rv["documentation_patterns"] = documentation_patterns
|
||||
rv["base_patterns"] = early_base_patterns + base_patterns + late_base_patterns
|
||||
rv["renpy_patterns"] = renpy_patterns
|
||||
rv["xbit_patterns"] = xbit_patterns
|
||||
rv["version"] = version or directory_name
|
||||
|
||||
rv["renpy"] = renpy
|
||||
|
||||
return rv
|
||||
@@ -1,128 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init -1210 python:
|
||||
|
||||
# This is called when script_version is set, to immediately
|
||||
# run code in response to a script_version change.
|
||||
def _set_script_version(version):
|
||||
|
||||
if version is None:
|
||||
return
|
||||
|
||||
if version <= (5, 6, 0):
|
||||
config.check_properties = False
|
||||
|
||||
if version <= (6, 5, 0):
|
||||
layout.compat()
|
||||
|
||||
if version <= (6, 9, 1):
|
||||
store.library = store.config
|
||||
|
||||
if version <= (6, 9, 3):
|
||||
|
||||
# Before 6.10, these were positions, rather than transforms.
|
||||
store.left = Position(xalign=0.0)
|
||||
store.center = Position(xalign=0.5)
|
||||
store.truecenter = Position(xalign=0.5, yalign=0.5)
|
||||
store.right = Position(xalign=1.0)
|
||||
store.offscreenleft = Position(xpos=0.0, xanchor=1.0)
|
||||
store.offscreenright = Position(xpos=1.0, xanchor=0.0)
|
||||
|
||||
if version <= (6, 10, 2):
|
||||
# Before 6.11, we used the image placement to handle
|
||||
# the location of things on the screen.
|
||||
style.image_placement.xpos = 0.5
|
||||
style.image_placement.ypos = 1.0
|
||||
style.image_placement.xanchor = 0.5
|
||||
style.image_placement.yanchor = 1.0
|
||||
|
||||
config.transform_uses_child_position = False
|
||||
config.default_transform = None
|
||||
config.start_scene_black = True
|
||||
|
||||
if version <= (6, 11, 0):
|
||||
config.movetransition_respects_offsets = False
|
||||
|
||||
if version <= (6, 11, 2):
|
||||
config.imagereference_respects_position = True
|
||||
config.predict_screens = False
|
||||
config.choice_screen_chosen = False
|
||||
|
||||
if version <= (6, 12, 0):
|
||||
config.keep_running_transform = False
|
||||
config.image_attributes = False
|
||||
config.new_character_image_argument = False
|
||||
config.save_physical_size = False
|
||||
|
||||
if version <= (6, 12, 2):
|
||||
style.default.language = "western"
|
||||
style.default.layout = "greedy"
|
||||
config.new_substitutions = False
|
||||
config.broken_line_spacing = True
|
||||
|
||||
if (6, 12, 2) < version <= (6, 13, 8):
|
||||
config.old_substitutions = False
|
||||
|
||||
if version <= (6, 13, 12):
|
||||
global MoveTransition
|
||||
MoveTransition = OldMoveTransition
|
||||
|
||||
|
||||
init 1210 python hide::
|
||||
|
||||
# This returns true if the script_version is <= the
|
||||
# script_version supplied. Give it the last script version
|
||||
# where an old version was used.
|
||||
def compat(x, y, z):
|
||||
return config.script_version and config.script_version <= (x, y, z)
|
||||
|
||||
# Compat for changes to with-callback.
|
||||
if compat(5, 4, 5):
|
||||
if config.with_callback:
|
||||
def compat_with_function(trans, paired, old=config.with_callback):
|
||||
old(trans)
|
||||
return trans
|
||||
|
||||
config.with_callback = compat_with_function
|
||||
|
||||
if not config.sound:
|
||||
config.has_sound = False
|
||||
config.has_music = False
|
||||
config.has_voice = False
|
||||
|
||||
# Compat for SFont recoloring.
|
||||
if compat(5, 1, 1):
|
||||
config.recolor_sfonts = False
|
||||
|
||||
if compat(5, 5, 4):
|
||||
config.implicit_with_none = False
|
||||
|
||||
# Compat for changes to button look.
|
||||
if compat(5, 5, 4):
|
||||
style.button.setdefault(xpos=0.5, xanchor=0.5)
|
||||
style.menu_button.clear()
|
||||
style.menu_button_text.clear()
|
||||
|
||||
if compat(5, 6, 6):
|
||||
config.reject_midi = False
|
||||
|
||||
if compat(6, 2, 0):
|
||||
config.reject_backslash = False
|
||||
|
||||
if compat(6, 9, 0):
|
||||
style.motion.clear()
|
||||
|
||||
if "Fullscreen" in config.translations:
|
||||
fs = _("Fullscreen")
|
||||
config.translations.setdefault("Fullscreen 4:3", fs + " 4:3")
|
||||
config.translations.setdefault("Fullscreen 16:9", fs + " 16:9")
|
||||
config.translations.setdefault("Fullscreen 16:10", fs + " 16:10")
|
||||
|
||||
for i in layout.compat_funcs:
|
||||
i()
|
||||
|
||||
if config.hyperlink_styler or config.hyperlink_callback or config.hyperlink_focus:
|
||||
style.default.hyperlink_functions = (config.hyperlink_styler, config.hyperlink_callback, config.hyperlink_focus)
|
||||
|
||||
|
||||
@@ -1,283 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# This file contains a number of definitions of standard
|
||||
# locations and transitions. We've moved them into the common
|
||||
# directory so that it's easy for an updated version of all of these
|
||||
# definitions.
|
||||
|
||||
init -1110:
|
||||
|
||||
transform reset:
|
||||
alpha 1 rotate None zoom 1 xzoom 1 yzoom 1 align (0, 0) alignaround (0, 0) subpixel False size None crop None
|
||||
|
||||
# These are positions that can be used inside at clauses. We set
|
||||
# them up here so that they can be used throughout the program.
|
||||
transform left:
|
||||
xpos 0.0 xanchor 0.0 ypos 1.0 yanchor 1.0
|
||||
|
||||
transform right:
|
||||
xpos 1.0 xanchor 1.0 ypos 1.0 yanchor 1.0
|
||||
|
||||
transform center:
|
||||
xpos 0.5 xanchor 0.5 ypos 1.0 yanchor 1.0
|
||||
|
||||
transform truecenter:
|
||||
xpos 0.5 xanchor 0.5 ypos 0.5 yanchor 0.5
|
||||
|
||||
transform topleft:
|
||||
xpos 0.0 xanchor 0.0 ypos 0.0 yanchor 0.0
|
||||
|
||||
transform topright:
|
||||
xpos 1.0 xanchor 1.0 ypos 0.0 yanchor 0.0
|
||||
|
||||
transform top:
|
||||
xpos 0.5 xanchor 0.5 ypos 0.0 yanchor 0.0
|
||||
|
||||
# Offscreen positions for use with the move transition. Images at
|
||||
# these positions are still shown (and consume
|
||||
# resources)... remember to hide the image after the transition.
|
||||
transform offscreenleft:
|
||||
xpos 0.0 xanchor 1.0 ypos 1.0 yanchor 1.0
|
||||
|
||||
transform offscreenright:
|
||||
xpos 1.0 xanchor 0.0 ypos 1.0 yanchor 1.0
|
||||
|
||||
transform default:
|
||||
alpha 1 rotate None zoom 1 xzoom 1 yzoom 1 align (0, 0) alignaround (0, 0) subpixel False size None crop None
|
||||
xpos 0.5 xanchor 0.5 ypos 1.0 yanchor 1.0
|
||||
|
||||
# These are used by the transitions to move things offscreen. We don't
|
||||
# expect them to be used by user code.
|
||||
transform _moveleft:
|
||||
xpos 0.0 xanchor 1.0
|
||||
|
||||
transform _moveright:
|
||||
xpos 1.0 xanchor 0.0
|
||||
|
||||
transform _movetop:
|
||||
ypos 0.0 yanchor 1.0
|
||||
|
||||
transform _movebottom:
|
||||
ypos 1.0 yanchor 0.0
|
||||
|
||||
python:
|
||||
config.default_transform = default
|
||||
|
||||
|
||||
init -1110 python:
|
||||
|
||||
_define = define = object()
|
||||
|
||||
# Transitions ############################################################
|
||||
|
||||
# Simple transitions.
|
||||
fade = Fade(.5, 0, .5) # Fade to black and back.
|
||||
dissolve = Dissolve(0.5)
|
||||
pixellate = Pixellate(1.0, 5)
|
||||
|
||||
# Various uses of CropMove.
|
||||
wiperight = CropMove(1.0, "wiperight")
|
||||
wipeleft = CropMove(1.0, "wipeleft")
|
||||
wipeup = CropMove(1.0, "wipeup")
|
||||
wipedown = CropMove(1.0, "wipedown")
|
||||
|
||||
slideright = CropMove(1.0, "slideright")
|
||||
slideleft = CropMove(1.0, "slideleft")
|
||||
slideup = CropMove(1.0, "slideup")
|
||||
slidedown = CropMove(1.0, "slidedown")
|
||||
|
||||
slideawayright = CropMove(1.0, "slideawayright")
|
||||
slideawayleft = CropMove(1.0, "slideawayleft")
|
||||
slideawayup = CropMove(1.0, "slideawayup")
|
||||
slideawaydown = CropMove(1.0, "slideawaydown")
|
||||
|
||||
irisout = CropMove(1.0, "irisout")
|
||||
irisin = CropMove(1.0, "irisin")
|
||||
|
||||
# Ease images around. These are basically cosine-warped moves.
|
||||
def _ease_out_time_warp(x):
|
||||
print "ZZZ"
|
||||
import math
|
||||
return 1.0 - math.cos(x * math.pi / 2.0)
|
||||
|
||||
def _ease_in_time_warp(x):
|
||||
import math
|
||||
return math.cos((1.0 - x) * math.pi / 2.0)
|
||||
|
||||
def _ease_time_warp(x):
|
||||
import math
|
||||
return .5 - math.cos(math.pi * x) / 2.0
|
||||
|
||||
|
||||
# Back up the move transition, so that if MoveTransition gets replaced by
|
||||
# renpy.compat, this still works.
|
||||
__MoveTransition = MoveTransition
|
||||
|
||||
# This defines a family of move transitions, using the old-style methods.
|
||||
def move_transitions(prefix, delay, time_warp=None, in_time_warp=None, out_time_warp=None, old=False, layers=[ 'master' ], **kwargs):
|
||||
"""
|
||||
:doc: transition_family
|
||||
|
||||
This defines a family of move transitions, similar to the move and ease
|
||||
transitions. For a given `prefix`, this defines the transitions:
|
||||
|
||||
* *prefix*- A transition that takes `delay` seconds to move images that
|
||||
changed positions to their new locations.
|
||||
|
||||
* *prefix*\ inleft, *prefix*\ inright, *prefix*\ intop, *prefix*\ inbottom - Transitions
|
||||
that take `delay` seconds to move images that changed positions to their
|
||||
new locations, with newly shown images coming in from the appropriate
|
||||
side.
|
||||
|
||||
* *prefix*\ outleft, *prefix*\ outright, *prefix*\ outtop, *prefix*\ outbottom -
|
||||
Transitions that take `delay` seconds to move images that changed
|
||||
positions to their new locations, with newly hidden images leaving via
|
||||
the appropriate side.
|
||||
|
||||
`time_warp`, `in_time_warp`, `out_time_warp`
|
||||
Time warp functions that are given a time from 0.0 to 1.0 representing
|
||||
the fraction of the move complete, and return a value in the same
|
||||
range giving the fraction of a linear move that is complete.
|
||||
|
||||
This can be used to define functions that ease the images around,
|
||||
rather than moving them at a constant speed.
|
||||
|
||||
The three argument are used for images remaining on the screen,
|
||||
newly shown images, and newly hidden images, respectively.
|
||||
|
||||
`old`
|
||||
If true, the transitions to move the old displayables, rather than the new ones.
|
||||
|
||||
`layers`
|
||||
The layers the transition will apply to.
|
||||
|
||||
::
|
||||
|
||||
# This defines all of the pre-defined transitions beginning
|
||||
# with "move".
|
||||
init python:
|
||||
define.move_transitions("move", 0.5)
|
||||
|
||||
"""
|
||||
|
||||
moves = {
|
||||
"" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
time_warp=time_warp),
|
||||
|
||||
"inright" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
enter=_moveright,
|
||||
time_warp=time_warp,
|
||||
enter_time_warp=in_time_warp,
|
||||
),
|
||||
|
||||
"inleft" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
enter=_moveleft,
|
||||
time_warp=time_warp,
|
||||
enter_time_warp=in_time_warp,
|
||||
),
|
||||
|
||||
"intop" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
enter=_movetop,
|
||||
time_warp=time_warp,
|
||||
enter_time_warp=in_time_warp,
|
||||
),
|
||||
|
||||
"inbottom" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
enter=_movebottom,
|
||||
time_warp=time_warp,
|
||||
enter_time_warp=in_time_warp,
|
||||
),
|
||||
|
||||
"outright" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
leave=_moveright,
|
||||
time_warp=time_warp,
|
||||
leave_time_warp=out_time_warp,
|
||||
),
|
||||
|
||||
"outleft" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
leave=_moveleft,
|
||||
time_warp=time_warp,
|
||||
leave_time_warp=out_time_warp,
|
||||
),
|
||||
|
||||
"outtop" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
leave=_movetop,
|
||||
time_warp=time_warp,
|
||||
leave_time_warp=out_time_warp,
|
||||
),
|
||||
|
||||
"outbottom" : MoveTransition(
|
||||
delay,
|
||||
old=old,
|
||||
layers=layers,
|
||||
leave=_movebottom,
|
||||
time_warp=time_warp,
|
||||
leave_time_warp=out_time_warp,
|
||||
),
|
||||
}
|
||||
|
||||
for k, v in moves.iteritems():
|
||||
setattr(store, prefix + k, v)
|
||||
|
||||
define.move_transitions = move_transitions
|
||||
del move_transitions
|
||||
|
||||
define.move_transitions("move", 0.5)
|
||||
define.move_transitions("ease", 0.5, _ease_time_warp, _ease_in_time_warp, _ease_out_time_warp)
|
||||
|
||||
# Zoom-based transitions. Legacy - nowadays, these are probably best done with ATL.
|
||||
zoomin = OldMoveTransition(0.5, enter_factory=ZoomInOut(0.01, 1.0))
|
||||
zoomout = OldMoveTransition(0.5, leave_factory=ZoomInOut(1.0, 0.01))
|
||||
zoominout = OldMoveTransition(0.5, enter_factory=ZoomInOut(0.01, 1.0), leave_factory=ZoomInOut(1.0, 0.01))
|
||||
|
||||
# These shake the screen up and down for a quarter second.
|
||||
# The delay needs to be an integer multiple of the period.
|
||||
vpunch = Move((0, 10), (0, -10), .10, bounce=True, repeat=True, delay=.275)
|
||||
hpunch = Move((15, 0), (-15, 0), .10, bounce=True, repeat=True, delay=.275)
|
||||
|
||||
# These use the ImageDissolve to do some nifty effects.
|
||||
blinds = ImageDissolve(im.Tile("blindstile.png"), 1.0, 8)
|
||||
squares = ImageDissolve(im.Tile("squarestile.png"), 1.0, 256)
|
||||
|
||||
|
||||
init -1110:
|
||||
image black = Solid("#000")
|
||||
|
||||
init 1110 python:
|
||||
if not hasattr(store, 'narrator'):
|
||||
narrator = Character(None, kind=adv, what_style='say_thought')
|
||||
|
||||
if not hasattr(store, 'name_only'):
|
||||
name_only = adv
|
||||
|
||||
if not hasattr(store, 'centered'):
|
||||
centered = Character(None, what_style="centered_text", window_style="centered_window")
|
||||
|
||||
# This is necessary to ensure that config.default_transform works.
|
||||
if config.default_transform:
|
||||
config.default_transform._show()
|
||||
@@ -1,329 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init -1135 python:
|
||||
|
||||
class __GalleryAllPriorCondition(object):
|
||||
|
||||
def check(self, all_prior):
|
||||
return all_prior
|
||||
|
||||
|
||||
class __GalleryArbitraryCondition(object):
|
||||
def __init__(self, condition):
|
||||
self.condition = condition
|
||||
|
||||
def check(self, all_prior):
|
||||
return eval(self.condition)
|
||||
|
||||
|
||||
class __GalleryUnlockCondition(object):
|
||||
def __init__(self, images):
|
||||
self.images = images
|
||||
|
||||
def check(self, all_prior):
|
||||
for i in self.images:
|
||||
if not renpy.seen_image(i):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
class __GalleryImage(object):
|
||||
def __init__(self, gallery, displayables):
|
||||
|
||||
# The gallery object we belong to.
|
||||
self.gallery = gallery
|
||||
|
||||
# A list of conditions for this image to be displayed.
|
||||
self.conditions = [ ]
|
||||
|
||||
# A list of displayables to show.
|
||||
self.displayables = displayables
|
||||
|
||||
# A list of transforms to apply to those displayables, or None
|
||||
# to not apply a transform.
|
||||
self.transforms = [ None ] * len(displayables)
|
||||
|
||||
|
||||
def check_unlock(self, all_prior):
|
||||
"""
|
||||
Returns True if the image is unlocked.
|
||||
"""
|
||||
|
||||
for i in self.conditions:
|
||||
if not i.check(all_prior):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def show(self, locked, index, count):
|
||||
"""
|
||||
Shows this image when it's unlocked.
|
||||
"""
|
||||
|
||||
renpy.transition(self.gallery.transition)
|
||||
ui.saybehavior()
|
||||
|
||||
displayables = [ ]
|
||||
|
||||
for d, transform in zip(self.displayables, self.transforms):
|
||||
|
||||
if transform is not None:
|
||||
d = transform(d)
|
||||
else:
|
||||
d = config.default_transform(d)
|
||||
|
||||
displayables.append(d)
|
||||
|
||||
renpy.show_screen("_gallery", locked=locked, index=index + 1, count=count, displayables=displayables, gallery=self.gallery)
|
||||
ui.interact()
|
||||
|
||||
class __GalleryButton(object):
|
||||
def __init__(self, gallery):
|
||||
self.gallery = gallery
|
||||
self.images = [ ]
|
||||
self.conditions = [ ]
|
||||
|
||||
def check_unlock(self):
|
||||
for i in self.conditions:
|
||||
if not i.check(True):
|
||||
return False
|
||||
|
||||
for i in self.images:
|
||||
if i.check_unlock(False):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def show(self):
|
||||
|
||||
all_prior = True
|
||||
|
||||
for i, img in enumerate(self.images):
|
||||
locked = not img.check_unlock(all_prior)
|
||||
img.show(locked, i, len(self.images))
|
||||
|
||||
renpy.transition(self.gallery.transition)
|
||||
|
||||
class Gallery(object):
|
||||
"""
|
||||
:doc: gallery class
|
||||
|
||||
This class supports the creation of an image gallery by handling the
|
||||
locking of images, providing an action that can show one or more images,
|
||||
and a providing method that creates buttons that use that action.
|
||||
|
||||
.. attribute:: transition
|
||||
|
||||
The transition that is used when changing images.
|
||||
|
||||
.. attribute:: locked_button
|
||||
|
||||
The default displayable used by make_button for a locked button.
|
||||
|
||||
.. attribute:: hover_border
|
||||
|
||||
The default hover border used by make_button.
|
||||
|
||||
.. attribute:: idle_border
|
||||
|
||||
The default idle border used by make_button.
|
||||
"""
|
||||
|
||||
transition = None
|
||||
|
||||
hover_border = None
|
||||
idle_border = None
|
||||
|
||||
locked_button = None
|
||||
|
||||
def __init__(self):
|
||||
|
||||
# A map from button name (or image) to __GalleryButton object.
|
||||
self.buttons = { }
|
||||
|
||||
self.button_ = None
|
||||
self.image_ = None
|
||||
self.unlockable = None
|
||||
|
||||
def button(self, name):
|
||||
"""
|
||||
:doc: gallery method
|
||||
|
||||
Creates a new button, named `name`.
|
||||
|
||||
`name`
|
||||
The name of the button being created.
|
||||
"""
|
||||
|
||||
self.button_ = __GalleryButton(self)
|
||||
self.unlockable = self.button_
|
||||
self.buttons[name] = self.button_
|
||||
|
||||
def image(self, *displayables):
|
||||
"""
|
||||
:doc: gallery method
|
||||
|
||||
Adds a new image to the current button, where an image consists
|
||||
of one or more displayables.
|
||||
"""
|
||||
|
||||
self.image_ = __GalleryImage(self, displayables)
|
||||
self.button_.images.append(self.image_)
|
||||
self.unlockable = self.image_
|
||||
|
||||
display = image
|
||||
|
||||
def transform(self, *transforms):
|
||||
"""
|
||||
:doc: gallery method
|
||||
|
||||
Applies transforms to the last image registered. This should be
|
||||
called with the same number of transforms as the image has
|
||||
displayables. The transforms are applied to the corresponding
|
||||
displayables.
|
||||
|
||||
If a transform is None, the default transform is used.
|
||||
"""
|
||||
|
||||
self.image_.transforms = transforms
|
||||
|
||||
def unlock(self, *images):
|
||||
"""
|
||||
:doc: gallery method
|
||||
|
||||
A condition that takes one or more image names as argument, and
|
||||
is satisfied when all the named images have been seen by the
|
||||
player. The image names should be given as strings.
|
||||
"""
|
||||
|
||||
self.unlockable.conditions.append(__GalleryUnlockCondition(images))
|
||||
|
||||
def condition(self, expression):
|
||||
"""
|
||||
:doc: gallery method
|
||||
|
||||
A condition that is satisfied when an expression evaluates to true.
|
||||
|
||||
`expression`
|
||||
A string giving a python expression.
|
||||
"""
|
||||
|
||||
if not isinstance(expression, basestring):
|
||||
raise Exception("Gallery condition must be a string containing an expression.")
|
||||
|
||||
self.unlockable.conditions.append(__GalleryArbitraryCondition(expression))
|
||||
|
||||
def allprior(self):
|
||||
"""
|
||||
:doc: gallery method
|
||||
|
||||
A condition that is true if all prior images associated with the
|
||||
current button have been unlocked.
|
||||
"""
|
||||
|
||||
self.unlockable.conditions.append(__GalleryAllPriorCondition())
|
||||
|
||||
def unlock_image(self, *images):
|
||||
"""
|
||||
:doc: gallery method
|
||||
|
||||
A convenience method that is equivalent to calling image and unlock
|
||||
with the same parameters. This will cause an image to be displayed
|
||||
if it has been seen before.
|
||||
|
||||
The images should be specified as strings giving image names.
|
||||
"""
|
||||
|
||||
self.image(*images)
|
||||
self.unlock(*images)
|
||||
|
||||
def Action(self, name):
|
||||
"""
|
||||
:doc: gallery method
|
||||
|
||||
An action that displays the images associated with the given button
|
||||
name.
|
||||
"""
|
||||
|
||||
if name not in self.buttons:
|
||||
raise Exception("{0!r} is not a button defined in this gallery.".format(name))
|
||||
|
||||
b = self.buttons[name]
|
||||
|
||||
if b.check_unlock():
|
||||
return ui.invokesinnewcontext(b.show)
|
||||
else:
|
||||
return None
|
||||
|
||||
def make_button(self, name, unlocked, locked=None, hover_border=None, idle_border=None, **properties):
|
||||
"""
|
||||
:doc: gallery method
|
||||
|
||||
This creates a button that displays the images associated with the given
|
||||
button name.
|
||||
|
||||
`name`
|
||||
The name of the button that will be created.
|
||||
|
||||
`unlocked`
|
||||
A displayable that is displayed for this button when it is
|
||||
unlocked.
|
||||
|
||||
`locked`
|
||||
A displayable that is displayed for this button when it is
|
||||
locked. If None, the locked_button field of the gallery
|
||||
object is used instead.
|
||||
|
||||
`hover_border`
|
||||
A displayable that is used to overlay this button when when
|
||||
it is unlocked and has focus. If None, the hover_border
|
||||
field of the gallery object is used.
|
||||
|
||||
`idle_border`
|
||||
A displayable that is used to overlay this button when when
|
||||
it is unlocked but unfocused. If None, the idle_border
|
||||
field of the gallery object is used.
|
||||
|
||||
Additional keyword arguments become style properties of the
|
||||
created button object.
|
||||
"""
|
||||
|
||||
action = self.Action(name)
|
||||
|
||||
if locked is None:
|
||||
locked = self.locked_button
|
||||
|
||||
if hover_border is None:
|
||||
hover_border = self.hover_border
|
||||
|
||||
if idle_border is None:
|
||||
idle_border = self.idle_border
|
||||
|
||||
return Button(action=action, child=unlocked, insensitive_child=locked, hover_foreground=hover_border, idle_foreground=idle_border, **properties)
|
||||
|
||||
|
||||
init -1135:
|
||||
|
||||
# Displays a set of images in the gallery, or indicates that the images
|
||||
# are locked. This is given the following arguments:
|
||||
#
|
||||
# locked
|
||||
# True if the image is locked.
|
||||
# displayables
|
||||
# A list of transformed displayables that should be shown to the user.
|
||||
# index
|
||||
# A 1-based index of the image being shown.
|
||||
# count
|
||||
# The number of images attached to the current button.
|
||||
# gallery
|
||||
# The image gallery object.
|
||||
screen _gallery:
|
||||
if locked:
|
||||
add "#000"
|
||||
text "Image [index] of [count] locked." align (0.5, 0.5)
|
||||
else:
|
||||
for d in displayables:
|
||||
add d
|
||||
|
||||
@@ -1,377 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# This contains code to choose between OpenGL and Software rendering, when
|
||||
# a system supports both.
|
||||
|
||||
init -1024:
|
||||
|
||||
python hide:
|
||||
import os
|
||||
store.__dxwebsetup = os.path.join(config.renpy_base, "lib", "dxwebsetup.exe")
|
||||
|
||||
python:
|
||||
class _SetRenderer(Action):
|
||||
"""
|
||||
Sets the preferred renderer to one of "auto", "angle", "gl", or
|
||||
"sw".
|
||||
"""
|
||||
|
||||
def __init__(self, renderer):
|
||||
self.renderer = renderer
|
||||
|
||||
def __call__(self):
|
||||
_preferences.renderer = self.renderer
|
||||
renpy.restart_interaction()
|
||||
|
||||
def get_selected(self):
|
||||
return _preferences.renderer == self.renderer
|
||||
|
||||
# This is displayed to ask the user to choose the renderer he or she
|
||||
# wants to use. It takes no parameters, doesn't return anything, and
|
||||
# is expected to call _SetRenderer actions and quit when done.
|
||||
#
|
||||
# This screen can be customized by the creator, provided the actions
|
||||
# remain available.
|
||||
screen _choose_renderer:
|
||||
|
||||
frame:
|
||||
style_group ""
|
||||
|
||||
xalign .5
|
||||
yalign .33
|
||||
xpadding 20
|
||||
ypadding 20
|
||||
|
||||
xmaximum 400
|
||||
|
||||
has vbox
|
||||
|
||||
label _("Graphics Acceleration")
|
||||
|
||||
null height 10
|
||||
|
||||
textbutton _("Automatically Choose"):
|
||||
action _SetRenderer("auto")
|
||||
xfill True
|
||||
|
||||
if renpy.renpy.windows:
|
||||
textbutton _("Force Angle/DirectX Renderer"):
|
||||
action _SetRenderer("angle")
|
||||
xfill True
|
||||
|
||||
textbutton _("Force OpenGL Renderer"):
|
||||
action _SetRenderer("gl")
|
||||
xfill True
|
||||
|
||||
textbutton _("Force Software Renderer"):
|
||||
action _SetRenderer("sw")
|
||||
xfill True
|
||||
|
||||
null height 10
|
||||
|
||||
text _("Changes will take effect the next time this program is run.") substitute True
|
||||
|
||||
null height 10
|
||||
|
||||
textbutton _(u"Quit"):
|
||||
action Quit(confirm=False)
|
||||
xfill True
|
||||
|
||||
if not renpy.display.interface.safe_mode:
|
||||
textbutton _("Return"):
|
||||
action Return(0)
|
||||
xfill True
|
||||
|
||||
|
||||
# This is displayed when a display performance problem occurs.
|
||||
#
|
||||
# `problem` is the kind of problem that is occuring. It can be:
|
||||
# - "sw" if the software renderer was selected.
|
||||
# - "slow" if the performance test failed.
|
||||
# - "fixed" if we're operating w/o shaders.
|
||||
# - other things, added in the future.
|
||||
#
|
||||
# `url` is the url of a web page on renpy.org that will include
|
||||
# info on troubleshooting display problems.
|
||||
screen _performance_warning:
|
||||
|
||||
frame:
|
||||
style_group ""
|
||||
|
||||
xalign .5
|
||||
yalign .33
|
||||
|
||||
xpadding 20
|
||||
ypadding 20
|
||||
|
||||
xmaximum 400
|
||||
|
||||
has vbox
|
||||
|
||||
label _("Performance Warning")
|
||||
|
||||
null height 10
|
||||
|
||||
if problem == "sw":
|
||||
text _("This computer is using software rendering.")
|
||||
elif problem == "fixed":
|
||||
text _("This computer is not using shaders.")
|
||||
elif problem == "slow":
|
||||
text _("This computer is displaying graphics slowly.")
|
||||
else:
|
||||
text _("This computer has a problem displaying graphics: [problem].") substitute True
|
||||
|
||||
null height 10
|
||||
|
||||
if directx_update:
|
||||
text _("Its graphics drivers may be out of date or not operating correctly. This can lead to slow or incorrect graphics display. Updating DirectX could fix this problem.")
|
||||
else:
|
||||
text _("Its graphics drivers may be out of date or not operating correctly. This can lead to slow or incorrect graphics display.")
|
||||
|
||||
if directx_update:
|
||||
null height 10
|
||||
|
||||
textbutton _("Update DirectX"):
|
||||
action directx_update
|
||||
xfill True
|
||||
|
||||
null height 10
|
||||
|
||||
textbutton _("Continue, Show this warning again"):
|
||||
action Return(True)
|
||||
xfill True
|
||||
|
||||
textbutton _("Continue, Don't show warning again"):
|
||||
action Return(False)
|
||||
xfill True
|
||||
|
||||
null height 10
|
||||
|
||||
textbutton _("Quit"):
|
||||
action Quit(confirm=False)
|
||||
xfill True
|
||||
|
||||
# Used while a directx update is ongoing.
|
||||
screen _directx_update:
|
||||
|
||||
frame:
|
||||
style_group ""
|
||||
|
||||
xalign .5
|
||||
yalign .33
|
||||
|
||||
xpadding 20
|
||||
ypadding 20
|
||||
|
||||
xmaximum 400
|
||||
|
||||
has vbox
|
||||
|
||||
label _("Updating DirectX.")
|
||||
|
||||
null height 10
|
||||
|
||||
text _("DirectX web setup has been started. It may start minimized in the taskbar. Please follow the prompts to install DirectX.")
|
||||
|
||||
null height 10
|
||||
|
||||
text _("{b}Note:{/b} Microsoft's DirectX web setup program will, by default, install the Bing toolbar. If you do not want this toolbar, uncheck the appropriate box.")
|
||||
|
||||
null height 10
|
||||
|
||||
text _("When setup finishes, please click below to restart this program.")
|
||||
|
||||
textbutton _("Restart") action Return(True)
|
||||
|
||||
|
||||
|
||||
init -1024 python:
|
||||
# The image that we fill the screen with in GL-test mode.
|
||||
config.gl_test_image = "black"
|
||||
|
||||
class __GLTest(renpy.Displayable):
|
||||
"""
|
||||
This counts the number of times it's been rendered, and
|
||||
the number of seconds it's been displayed, and uses them
|
||||
to make the decisions as to if OpenGL is working or not.
|
||||
"""
|
||||
|
||||
def __init__(self, frames, fps, timeout):
|
||||
super(__GLTest, self).__init__()
|
||||
|
||||
self.target = 1.0 * frames / fps
|
||||
self.frames = frames
|
||||
self.timeout = timeout
|
||||
|
||||
self.times = [ ]
|
||||
self.success = False
|
||||
|
||||
renpy.renpy.display.log.write("- Target is {0} frames in {1} seconds.".format(frames, self.target))
|
||||
|
||||
def render(self, width, height, st, at):
|
||||
rv = renpy.Render(width, height)
|
||||
|
||||
if self.success:
|
||||
return rv
|
||||
|
||||
self.times.append(st)
|
||||
|
||||
renpy.redraw(self, 0)
|
||||
|
||||
renpy.renpy.display.log.write("- Frame drawn at %f seconds." % st)
|
||||
|
||||
if len(self.times) >= self.frames:
|
||||
frames_timing = self.times[-1] - self.times[-self.frames]
|
||||
|
||||
renpy.renpy.display.log.write("- %f seconds to render %d frames.", frames_timing, self.frames)
|
||||
|
||||
if frames_timing <= self.target:
|
||||
self.success = True
|
||||
renpy.timeout(0)
|
||||
|
||||
return rv
|
||||
|
||||
def event(self, ev, x, y, st):
|
||||
|
||||
if self.success:
|
||||
return True
|
||||
|
||||
if st > self.timeout:
|
||||
return False
|
||||
|
||||
renpy.timeout(self.timeout - st)
|
||||
|
||||
config.performance_test = True
|
||||
|
||||
def __gl_test():
|
||||
|
||||
import os
|
||||
|
||||
# If we've entered safe mode, display the renderer choice screen.
|
||||
# This screen will cause us to quit.
|
||||
|
||||
if _restart:
|
||||
return
|
||||
|
||||
if not config.gl_enable:
|
||||
return
|
||||
|
||||
if renpy.display.interface.safe_mode:
|
||||
renpy.call_in_new_context("_choose_renderer")
|
||||
|
||||
if not config.performance_test:
|
||||
return
|
||||
|
||||
_gl_performance_test()
|
||||
|
||||
def _gl_performance_test():
|
||||
|
||||
import os
|
||||
|
||||
if not _preferences.performance_test and "RENPY_PERFORMANCE_TEST" not in os.environ:
|
||||
return
|
||||
|
||||
# Don't bother on androuid - there's nothing the user can do.
|
||||
if renpy.renpy.android:
|
||||
return
|
||||
|
||||
renpy.renpy.display.log.write("Performance test:")
|
||||
|
||||
# This will cause the screen to start displaying.
|
||||
ui.pausebehavior(0)
|
||||
ui.interact(suppress_underlay=True, suppress_overlay=True)
|
||||
|
||||
# The problem we have.
|
||||
problem = None
|
||||
|
||||
renderer_info = renpy.get_renderer_info()
|
||||
|
||||
# Software renderer check.
|
||||
if config.renderer != "sw" and renderer_info["renderer"] == "sw":
|
||||
problem = "sw"
|
||||
|
||||
# Speed check.
|
||||
if problem is None:
|
||||
|
||||
# The parameters of the performance test. If we do not hit FPS fps
|
||||
# over FRAMES frames before DELAY seconds are up, we fail.
|
||||
FRAMES = 5
|
||||
FPS = 15
|
||||
DELAY = 1.5
|
||||
|
||||
renpy.transition(Dissolve(DELAY), always=True, force=True)
|
||||
ui.add(__GLTest(FRAMES, FPS, DELAY))
|
||||
result = ui.interact(suppress_overlay=True, suppress_underlay=True)
|
||||
|
||||
if not result:
|
||||
problem = "slow"
|
||||
|
||||
# Lack of shaders check.
|
||||
if problem is None:
|
||||
if not "RENPY_GL_ENVIRON" in os.environ:
|
||||
if renderer_info["renderer"] == "gl" and renderer_info["environ"] == "fixed":
|
||||
problem = "fixed"
|
||||
|
||||
if problem is None:
|
||||
return
|
||||
|
||||
if renpy.renpy.windows and os.path.exists(__dxwebsetup):
|
||||
directx_update = Jump("_directx_update")
|
||||
else:
|
||||
directx_update = None
|
||||
|
||||
# Give the warning message to the user.
|
||||
renpy.show_screen("_performance_warning", problem=problem, directx_update=directx_update, _transient=True)
|
||||
result = ui.interact(suppress_overlay=True, suppress_underlay=True)
|
||||
|
||||
|
||||
# Store the user's choice, and continue.
|
||||
_preferences.performance_test = result
|
||||
return
|
||||
|
||||
|
||||
label _gl_test:
|
||||
|
||||
# Show the test image.
|
||||
scene
|
||||
show expression config.gl_test_image
|
||||
|
||||
$ __gl_test()
|
||||
|
||||
# Hide the test image.
|
||||
scene
|
||||
|
||||
return
|
||||
|
||||
# We can assume we're on windows here. We're also always restart once we
|
||||
# make it here.
|
||||
label _directx_update:
|
||||
|
||||
if renpy.has_label("directx_update"):
|
||||
jump expression "directx_update"
|
||||
|
||||
label _directx_update_main:
|
||||
|
||||
python hide:
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Start dxsetup. We have to go through startfile to ensure that UAC
|
||||
# doesn't cause problems.
|
||||
os.startfile(__dxwebsetup)
|
||||
|
||||
renpy.show_screen("_directx_update")
|
||||
ui.interact(suppress_overlay=True, suppress_underlay=True)
|
||||
|
||||
# Restart the current program.
|
||||
subprocess.Popen(sys.argv)
|
||||
renpy.quit()
|
||||
|
||||
label _choose_renderer:
|
||||
scene expression "#000"
|
||||
|
||||
$ renpy.call_screen("_choose_renderer")
|
||||
return
|
||||
|
||||
|
||||
@@ -1,434 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init -1105 python:
|
||||
|
||||
class Layout():
|
||||
def __call__(self, func):
|
||||
setattr(self, func.func_name, func)
|
||||
return func
|
||||
|
||||
layout = _layout = Layout()
|
||||
del Layout
|
||||
|
||||
layout.compat_funcs = [ ]
|
||||
layout.provided = set()
|
||||
|
||||
init -1105 python hide:
|
||||
|
||||
# Called to indicate that the given kind of layout has been
|
||||
# provided.
|
||||
@layout
|
||||
def provides(kind):
|
||||
|
||||
if kind in layout.provided:
|
||||
raise Exception("%s has already been provided by another layout function." % kind)
|
||||
|
||||
layout.provided.add(kind)
|
||||
|
||||
# Called by registered themes to have the default versions of
|
||||
# various kinds of layouts provided, if a more specific version
|
||||
# has not been requested by the user.
|
||||
@layout
|
||||
def defaults():
|
||||
|
||||
# Do nothing, in compatibility mode.
|
||||
if 'compat' in layout.provided:
|
||||
return
|
||||
|
||||
defaults = dict(
|
||||
main_menu=layout.classic_main_menu,
|
||||
load_save=layout.classic_load_save,
|
||||
navigation=layout.classic_navigation,
|
||||
yesno_prompt=layout.classic_yesno_prompt,
|
||||
preferences=layout.classic_preferences,
|
||||
joystick_preferences=layout.classic_joystick_preferences,
|
||||
)
|
||||
|
||||
if renpy.has_screen("main_menu"):
|
||||
defaults["main_menu"] = layout.screen_main_menu
|
||||
|
||||
if renpy.has_screen("load") and renpy.has_screen("save"):
|
||||
defaults["load_save"] = layout.screen_load_save
|
||||
|
||||
if renpy.has_screen("yesno_prompt"):
|
||||
defaults["yesno_prompt"] = layout.screen_yesno_prompt
|
||||
|
||||
if renpy.has_screen("preferences"):
|
||||
defaults["preferences"] = layout.screen_preferences
|
||||
|
||||
if renpy.has_screen("joystick_preferences"):
|
||||
defaults["joystick_preferences"] = layout.screen_joystick_preferences
|
||||
|
||||
for k, v in defaults.iteritems():
|
||||
if k not in layout.provided:
|
||||
v()
|
||||
|
||||
if store._game_menu_screen is None:
|
||||
if renpy.has_label("save_screen"):
|
||||
store._game_menu_screen = "save_screen"
|
||||
elif renpy.has_label("preferences_screen"):
|
||||
store._game_menu_screen = "preferences_screen"
|
||||
|
||||
|
||||
##########################################################################
|
||||
# These live on the layout object, and ease the construction of buttons,
|
||||
# labels, and prompts. A sufficently aggressive layout might change
|
||||
# these.
|
||||
|
||||
@layout
|
||||
def button(label,
|
||||
type=None,
|
||||
selected=False,
|
||||
enabled=True,
|
||||
clicked=None,
|
||||
hovered=None,
|
||||
unhovered=None,
|
||||
index=None,
|
||||
**properties):
|
||||
|
||||
"""
|
||||
label - The label of this button. Will be translated if necessary.
|
||||
type - The type of this button. Used to generate the appropriate styles.
|
||||
selected - Determines if this button should be selected.
|
||||
enabled - Determines if this button should be enabled.
|
||||
clicked - A function that is run when the button is clicked.
|
||||
hovered - A function that is run when the button is hovered.
|
||||
unhovered - A function that is run when the button is unhovered.
|
||||
index - A style index. If None, label is used.
|
||||
size_group - The size_group used by this button.
|
||||
"""
|
||||
|
||||
if not enabled:
|
||||
clicked = None
|
||||
|
||||
if selected and enabled:
|
||||
role = "selected_"
|
||||
else:
|
||||
role = ""
|
||||
|
||||
if type:
|
||||
button_style = type + "_button"
|
||||
text_style = type + "_button_text"
|
||||
else:
|
||||
button_style = 'button'
|
||||
text_style = 'button_text'
|
||||
|
||||
if index is None:
|
||||
index = label
|
||||
|
||||
button_style = getattr(style, button_style)[index]
|
||||
text_style = getattr(style, text_style)[index]
|
||||
|
||||
rv = ui.button(style=button_style, role=role, clicked=clicked, hovered=hovered, unhovered=unhovered, **properties)
|
||||
ui.text(_(label), style=text_style)
|
||||
|
||||
return rv
|
||||
|
||||
@layout
|
||||
def label(label, type, suffix="label", index=None, **properties):
|
||||
|
||||
if index is None:
|
||||
index = label
|
||||
|
||||
if type:
|
||||
label_style = getattr(style, type + "_" + suffix)[index]
|
||||
text_style = getattr(style, type + "_" + suffix + "_text")[index]
|
||||
else:
|
||||
label_style = style.label[index]
|
||||
text_style = style.label_text[index]
|
||||
|
||||
ui.window(style=label_style, **properties)
|
||||
ui.text(_(label), style=text_style)
|
||||
|
||||
@layout
|
||||
def prompt(label, type, index=None, **properties):
|
||||
return layout.label(label, type, "prompt", index, **properties)
|
||||
|
||||
@layout
|
||||
def list(entries, clicked=None, hovered=None, unhovered=None, selected=None, **properties):
|
||||
|
||||
ui.window(style=style.list, **properties)
|
||||
ui.vbox(style=style.list_box)
|
||||
|
||||
size_group = str(id(entries))
|
||||
|
||||
for i, (spacers, content) in enumerate(entries):
|
||||
if clicked is not None:
|
||||
new_clicked = renpy.curry(clicked)(i)
|
||||
else:
|
||||
new_clicked = None
|
||||
|
||||
if hovered is not None:
|
||||
new_hovered = renpy.curry(hovered)(i)
|
||||
else:
|
||||
new_hovered = None
|
||||
|
||||
if unhovered is not None:
|
||||
new_unhovered = renpy.curry(unhovered)(i)
|
||||
else:
|
||||
new_unhovered = None
|
||||
|
||||
if selected == i:
|
||||
role = "selected_"
|
||||
else:
|
||||
role = ""
|
||||
|
||||
ui.button(style=style.list_row[i%2],
|
||||
clicked=new_clicked,
|
||||
hovered=new_hovered,
|
||||
unhovered=new_unhovered,
|
||||
role=role,
|
||||
size_group=size_group,
|
||||
)
|
||||
|
||||
ui.hbox(style=style.list_row_box)
|
||||
|
||||
for j in range(0, spacers):
|
||||
ui.window(style=style.list_spacer)
|
||||
ui.null()
|
||||
|
||||
ui.text(content, style=style.list_text)
|
||||
|
||||
ui.close() # row
|
||||
|
||||
ui.close() # vbox
|
||||
|
||||
##########################################################################
|
||||
# Misc.
|
||||
|
||||
@layout
|
||||
def button_menu():
|
||||
|
||||
config.narrator_menu = True
|
||||
|
||||
style.menu.box_spacing = 2
|
||||
style.menu_window.set_parent(style.default)
|
||||
style.menu_window.xalign = 0.5
|
||||
style.menu_window.yalign = 0.5
|
||||
style.menu_choice.set_parent(style.button_text)
|
||||
style.menu_choice.clear()
|
||||
style.menu_choice_button.set_parent(style.button)
|
||||
style.menu_choice_button.xminimum = int(config.screen_width * 0.75)
|
||||
style.menu_choice_button.xmaximum = int(config.screen_width * 0.75)
|
||||
|
||||
store._button_menu = button_menu
|
||||
|
||||
###########################################################################
|
||||
# Compat layout.
|
||||
|
||||
@layout
|
||||
def compat():
|
||||
layout.provides('compat')
|
||||
renpy.load_module("_compat/styles")
|
||||
renpy.load_module("_compat/library")
|
||||
renpy.load_module("_compat/mainmenu")
|
||||
renpy.load_module("_compat/gamemenu")
|
||||
renpy.load_module("_compat/preferences")
|
||||
renpy.load_module("_compat/themes")
|
||||
|
||||
###########################################################################
|
||||
# Classic layout.
|
||||
|
||||
@layout
|
||||
def classic_main_menu():
|
||||
renpy.load_module("_layout/classic_main_menu")
|
||||
|
||||
@layout
|
||||
def classic_navigation():
|
||||
renpy.load_module('_layout/classic_navigation')
|
||||
|
||||
@layout
|
||||
def classic_load_save():
|
||||
renpy.load_module('_layout/classic_load_save')
|
||||
|
||||
@layout
|
||||
def classic_yesno_prompt():
|
||||
renpy.load_module('_layout/classic_yesno_prompt')
|
||||
|
||||
@layout
|
||||
def classic_preferences(center=False):
|
||||
renpy.load_module('_layout/classic_preferences')
|
||||
|
||||
if center:
|
||||
style.prefs_button.xalign = 0.5
|
||||
style.prefs_slider.xalign = 0.5
|
||||
style.prefs_jump_button.xalign = 0.5
|
||||
|
||||
@layout
|
||||
def classic_joystick_preferences():
|
||||
renpy.load_module('_layout/classic_joystick_preferences')
|
||||
|
||||
@layout
|
||||
def two_column_preferences():
|
||||
renpy.load_module("_layout/two_column_preferences")
|
||||
|
||||
@layout
|
||||
def one_column_preferences():
|
||||
renpy.load_module("_layout/one_column_preferences")
|
||||
|
||||
@layout
|
||||
def grouped_main_menu(per_group=2, equal_size=True):
|
||||
renpy.load_module("_layout/grouped_main_menu")
|
||||
config.main_menu_per_group = per_group
|
||||
|
||||
if equal_size:
|
||||
style.mm_button.size_group = "main_menu"
|
||||
|
||||
|
||||
@layout
|
||||
def grouped_navigation(per_group=2, equal_size=True):
|
||||
renpy.load_module("_layout/grouped_navigation")
|
||||
config.navigation_per_group = per_group
|
||||
|
||||
if equal_size:
|
||||
style.gm_nav_button.size_group = "navigation"
|
||||
|
||||
@layout
|
||||
def scrolling_load_save():
|
||||
renpy.load_module("_layout/scrolling_load_save")
|
||||
|
||||
|
||||
@layout
|
||||
def imagemap_main_menu(ground, selected, hotspots, idle=None, variant=None):
|
||||
renpy.load_module("_layout/imagemap_main_menu")
|
||||
|
||||
config.main_menu_ground[variant] = ground
|
||||
config.main_menu_selected[variant] = selected
|
||||
config.main_menu_hotspots[variant] = hotspots
|
||||
config.main_menu_idle[variant] = idle
|
||||
|
||||
@layout
|
||||
def imagemap_navigation(ground, idle, hover, selected_idle, selected_hover,
|
||||
hotspots):
|
||||
|
||||
renpy.load_module("_layout/imagemap_navigation")
|
||||
|
||||
config.navigation_ground = ground
|
||||
config.navigation_idle = idle
|
||||
config.navigation_hover = hover
|
||||
config.navigation_selected_idle = selected_idle
|
||||
config.navigation_selected_hover = selected_hover
|
||||
config.navigation_hotspots = hotspots
|
||||
|
||||
@layout
|
||||
def imagemap_preferences(ground, idle, hover, selected_idle, selected_hover,
|
||||
hotspots):
|
||||
|
||||
renpy.load_module("_layout/imagemap_preferences")
|
||||
|
||||
config.preferences_ground = ground
|
||||
config.preferences_idle = idle
|
||||
config.preferences_hover = hover
|
||||
config.preferences_selected_idle = selected_idle
|
||||
config.preferences_selected_hover = selected_hover
|
||||
config.preferences_hotspots = hotspots
|
||||
|
||||
@layout
|
||||
def imagemap_yesno_prompt(ground, idle, hover, hotspots, prompt_images={ }):
|
||||
|
||||
renpy.load_module("_layout/imagemap_yesno_prompt")
|
||||
|
||||
config.yesno_prompt_ground = ground
|
||||
config.yesno_prompt_idle = idle
|
||||
config.yesno_prompt_hover = hover
|
||||
config.yesno_prompt_hotspots = hotspots
|
||||
config.yesno_prompt_message_images = prompt_images
|
||||
|
||||
@layout
|
||||
def imagemap_load_save(ground, idle, hover, selected_idle, selected_hover,
|
||||
hotspots, variant=None):
|
||||
|
||||
renpy.load_module("_layout/imagemap_load_save")
|
||||
|
||||
config.load_save_ground[variant] = ground
|
||||
config.load_save_idle[variant] = idle
|
||||
config.load_save_hover[variant] = hover
|
||||
config.load_save_selected_idle[variant] = selected_idle
|
||||
config.load_save_selected_hover[variant] = selected_hover
|
||||
config.load_save_hotspots[variant] = hotspots
|
||||
|
||||
@layout
|
||||
def screen_main_menu():
|
||||
renpy.load_module("_layout/screen_main_menu")
|
||||
|
||||
@layout
|
||||
def screen_load_save():
|
||||
renpy.load_module("_layout/screen_load_save")
|
||||
|
||||
@layout
|
||||
def screen_preferences():
|
||||
renpy.load_module("_layout/screen_preferences")
|
||||
|
||||
@layout
|
||||
def screen_joystick_preferences():
|
||||
renpy.load_module("_layout/screen_joystick_preferences")
|
||||
|
||||
@layout
|
||||
def screen_yesno_prompt():
|
||||
renpy.load_module("_layout/screen_yesno_prompt")
|
||||
|
||||
layout.ARE_YOU_SURE = u"Are you sure?"
|
||||
layout.DELETE_SAVE = u"Are you sure you want to delete this save?"
|
||||
layout.OVERWRITE_SAVE = u"Are you sure you want to overwrite your save?"
|
||||
layout.LOADING = u"Loading will lose unsaved progress.\nAre you sure you want to do this?"
|
||||
layout.QUIT = u"Are you sure you want to quit?"
|
||||
layout.MAIN_MENU = u"Are you sure you want to return to the main menu?\nThis will lose unsaved progress."
|
||||
|
||||
@layout
|
||||
def invoke_yesno_prompt(*args):
|
||||
_enter_menu()
|
||||
return layout.yesno_prompt(*args)
|
||||
|
||||
@layout
|
||||
def yesno_screen(message, yes=None, no=None):
|
||||
"""
|
||||
:doc: other
|
||||
|
||||
This causes the a yes/no prompt screen with the given message
|
||||
to be displayed. The screen will be hidden when the user hits
|
||||
yes or no.
|
||||
|
||||
`message`
|
||||
The message that will be displayed.
|
||||
|
||||
`yes`
|
||||
An action that is run when the user chooses yes.
|
||||
|
||||
`no`
|
||||
An action that is run when the user chooses no.
|
||||
"""
|
||||
|
||||
if renpy.has_screen("yesno_prompt"):
|
||||
|
||||
yes_action = [ Hide("yesno_prompt") ]
|
||||
no_action = [ Hide("yesno_prompt") ]
|
||||
|
||||
if yes is not None:
|
||||
yes_action.append(yes)
|
||||
if no is not None:
|
||||
no_action.append(no)
|
||||
|
||||
renpy.show_screen(
|
||||
"yesno_prompt",
|
||||
message=message,
|
||||
yes_action=yes_action,
|
||||
no_action=no_action)
|
||||
|
||||
renpy.restart_interaction()
|
||||
|
||||
return
|
||||
|
||||
if renpy.invoke_in_new_context(layout.invoke_yesno_prompt, None, message):
|
||||
if yes is not None:
|
||||
yes()
|
||||
else:
|
||||
if no is not None:
|
||||
no()
|
||||
|
||||
|
||||
def __auto_save_extra_info():
|
||||
return save_name
|
||||
|
||||
config.auto_save_extra_info = __auto_save_extra_info
|
||||
|
||||
@@ -1,914 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# This file consists of renpy functions that aren't expected to be
|
||||
# touched by the user too much. We reserve the _ prefix for names
|
||||
# defined in the library.
|
||||
|
||||
init -1180 python:
|
||||
|
||||
# These are settings that the user can tweak to control the
|
||||
# look of the main menu and the load/save/escape screens.
|
||||
|
||||
# basics: The version of Ren'Py this script is intended for, or
|
||||
# None if it's intended for the current version.
|
||||
config.script_version = None
|
||||
|
||||
# The minimum version of the module we work with. Don't change
|
||||
# this unless you know what you're doing.
|
||||
config.module_version = 6007001
|
||||
|
||||
# Should we warn the user if the module is missing or has a bad
|
||||
# version?
|
||||
config.module_warning = False
|
||||
|
||||
# basics: A map from a string that's displayed by the interface to
|
||||
# a translated value of that string.
|
||||
config.translations = { }
|
||||
|
||||
# Used internally to maintain compatiblity with old
|
||||
# translations of strings.
|
||||
config.old_names = { }
|
||||
|
||||
# basics: True if the skip indicator should be shown.
|
||||
config.skip_indicator = True
|
||||
|
||||
# basics: The width of a thumbnail.
|
||||
config.thumbnail_width = 66
|
||||
|
||||
# basics: The height of a thumbnail.
|
||||
config.thumbnail_height = 50
|
||||
|
||||
# basics: If not None, the default value of the fullscreen
|
||||
# preference when the game is first run.
|
||||
config.default_fullscreen = None
|
||||
|
||||
# basics: If not None, the default value of the text_cps
|
||||
# preference when the game is first run.
|
||||
config.default_text_cps = None
|
||||
|
||||
# If not None, the default value of afm_time
|
||||
config.default_afm_time = None
|
||||
|
||||
# If not None, the default value of afm_enable
|
||||
config.default_afm_enable = None
|
||||
|
||||
# Should we automatically define images?
|
||||
config.automatic_images = None
|
||||
|
||||
# Prefixes to strip from automatic images.
|
||||
config.automatic_images_strip = [ ]
|
||||
|
||||
# A save to automatically load, if it exists.
|
||||
config.auto_load = None
|
||||
|
||||
# Layers to clear when entering the menus.
|
||||
config.menu_clear_layers = [ ]
|
||||
|
||||
# Should we start the game with scene black or just scene?
|
||||
config.start_scene_black = False
|
||||
|
||||
# Voice and Sound samples.
|
||||
config.sample_sound = None
|
||||
config.sample_voice = None
|
||||
|
||||
# This is updated to give the user an idea of where a save is
|
||||
# taking place.
|
||||
save_name = ''
|
||||
|
||||
# Should the window be shown during transitions?
|
||||
_window_during_transitions = False
|
||||
|
||||
def _default_with_callback(trans, paired=None):
|
||||
if (_window_during_transitions and not
|
||||
renpy.context_nesting_level() and
|
||||
not renpy.count_displayables_in_layer('transient')):
|
||||
|
||||
# narrator("", interact=False)
|
||||
ui.window(style=style.say_window["empty"])
|
||||
ui.null()
|
||||
|
||||
return trans
|
||||
|
||||
config.with_callback = _default_with_callback
|
||||
|
||||
|
||||
def _default_empty_window():
|
||||
|
||||
who = _last_say_who
|
||||
|
||||
if who is not None:
|
||||
who = eval(who)
|
||||
|
||||
if who is None:
|
||||
who = narrator
|
||||
|
||||
if isinstance(who, NVLCharacter):
|
||||
nvl_show_core()
|
||||
else:
|
||||
store.narrator("", interact=False)
|
||||
|
||||
config.empty_window = _default_empty_window
|
||||
|
||||
style.skip_indicator = Style(style.default, heavy=True, help='The skip indicator.')
|
||||
style.skip_indicator.xpos = 10
|
||||
style.skip_indicator.ypos = 10
|
||||
|
||||
# This is used to jump to a label with a transition.
|
||||
def _intra_jumps_core(label, transition):
|
||||
renpy.transition(getattr(config, transition))
|
||||
renpy.jump(label)
|
||||
|
||||
_intra_jumps = renpy.curry(_intra_jumps_core)
|
||||
|
||||
# The function that's used to translate strings in the game menu.
|
||||
def _(s):
|
||||
"""
|
||||
Translates s into another language or something.
|
||||
"""
|
||||
|
||||
if s in config.translations:
|
||||
return config.translations[s]
|
||||
|
||||
if s in config.old_names and config.old_names[s] in config.translations:
|
||||
return config.translations[config.old_names[s]]
|
||||
|
||||
return s
|
||||
|
||||
config.extend_interjection = "{fast}"
|
||||
|
||||
def extend(what, interact=True):
|
||||
who = _last_say_who
|
||||
|
||||
if who is not None:
|
||||
who = eval(who)
|
||||
|
||||
if who is None:
|
||||
who = narrator
|
||||
|
||||
if isinstance(who, basestring):
|
||||
who = unknown.copy(who)
|
||||
|
||||
# This ensures extend works even with NVL mode.
|
||||
who.do_extend()
|
||||
|
||||
what = _last_say_what + config.extend_interjection + what
|
||||
|
||||
renpy.exports.say(who, what, interact=interact)
|
||||
store._last_say_what = what
|
||||
|
||||
extend.record_say = False
|
||||
|
||||
# Are the windows currently hidden?
|
||||
_windows_hidden = False
|
||||
|
||||
def toggle_skipping():
|
||||
|
||||
if not config.skipping:
|
||||
config.skipping = "slow"
|
||||
else:
|
||||
config.skipping = None
|
||||
|
||||
if renpy.context()._menu:
|
||||
renpy.jump("_noisy_return")
|
||||
else:
|
||||
renpy.restart_interaction()
|
||||
|
||||
config.help = None
|
||||
|
||||
def _help(help=None):
|
||||
|
||||
if help is None:
|
||||
help = config.help
|
||||
|
||||
if help is None:
|
||||
return
|
||||
|
||||
if renpy.has_label(help):
|
||||
renpy.call_in_new_context(help)
|
||||
return
|
||||
|
||||
_preferences.fullscreen = False
|
||||
|
||||
try:
|
||||
import webbrowser
|
||||
webbrowser.open_new("file:///" + config.basedir + "/" + help)
|
||||
except:
|
||||
pass
|
||||
|
||||
# Called to make a screenshot happen.
|
||||
def _screenshot():
|
||||
import os.path
|
||||
import os
|
||||
import __main__
|
||||
|
||||
# Pick the directory to save into.
|
||||
dest = config.renpy_base.rstrip("/")
|
||||
|
||||
# Guess if we're an OSX App.
|
||||
if dest.endswith("/Contents/Resources/autorun"):
|
||||
# Go up 4 directories.
|
||||
dest = os.path.dirname(dest)
|
||||
dest = os.path.dirname(dest)
|
||||
dest = os.path.dirname(dest)
|
||||
dest = os.path.dirname(dest)
|
||||
|
||||
# Try to pick a filename.
|
||||
i = 1
|
||||
while True:
|
||||
fn = os.path.join(dest, config.screenshot_pattern % i)
|
||||
if not os.path.exists(fn):
|
||||
break
|
||||
i += 1
|
||||
|
||||
try:
|
||||
renpy.screenshot(fn)
|
||||
except:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
if config.screenshot_callback is not None:
|
||||
config.screenshot_callback(fn)
|
||||
|
||||
def _screenshot_callback(fn):
|
||||
renpy.notify(_("Saved screenshot as %s.") % fn)
|
||||
|
||||
config.screenshot_callback = _screenshot_callback
|
||||
|
||||
_predict_screens = [ ]
|
||||
|
||||
init -1180 python hide:
|
||||
|
||||
import os
|
||||
config.screenshot_pattern = os.environ.get("RENPY_SCREENSHOT_PATTERN", "screenshot%04d.png")
|
||||
|
||||
def dump_styles():
|
||||
if config.developer:
|
||||
renpy.style.write_text("styles.txt")
|
||||
|
||||
# This is run when entering the game menu.
|
||||
config.game_menu_action = None
|
||||
|
||||
def invoke_game_menu():
|
||||
if renpy.context()._menu:
|
||||
if renpy.context()._main_menu:
|
||||
return
|
||||
else:
|
||||
renpy.jump("_noisy_return")
|
||||
else:
|
||||
if config.game_menu_action:
|
||||
renpy.display.behavior.run(config.game_menu_action)
|
||||
else:
|
||||
renpy.call_in_new_context('_game_menu')
|
||||
|
||||
def keymap_toggle_skipping():
|
||||
if renpy.context()._menu:
|
||||
return
|
||||
|
||||
toggle_skipping()
|
||||
|
||||
def fast_skip():
|
||||
if config.fast_skipping or config.developer:
|
||||
config.skipping = "fast"
|
||||
|
||||
if renpy.context()._menu:
|
||||
renpy.jump("_noisy_return")
|
||||
|
||||
def reload_game():
|
||||
if not config.developer:
|
||||
return
|
||||
|
||||
renpy.call_in_new_context("_save_reload_game")
|
||||
|
||||
def launch_editor():
|
||||
if not config.developer:
|
||||
return
|
||||
|
||||
filename, line = renpy.get_filename_line()
|
||||
renpy.launch_editor([ filename ], line)
|
||||
|
||||
# The default keymap. We might also want to put some of this into
|
||||
# the launcher.
|
||||
km = renpy.Keymap(
|
||||
rollback = renpy.rollback,
|
||||
screenshot = _screenshot,
|
||||
toggle_fullscreen = renpy.toggle_fullscreen,
|
||||
toggle_music = renpy.toggle_music,
|
||||
toggle_skip = keymap_toggle_skipping,
|
||||
fast_skip = fast_skip,
|
||||
game_menu = invoke_game_menu,
|
||||
hide_windows = renpy.curried_call_in_new_context("_hide_windows"),
|
||||
launch_editor = launch_editor,
|
||||
dump_styles = dump_styles,
|
||||
reload_game = reload_game,
|
||||
developer = renpy.curried_call_in_new_context("_developer"),
|
||||
quit = renpy.quit_event,
|
||||
iconify = renpy.iconify,
|
||||
help = _help,
|
||||
choose_renderer = renpy.curried_call_in_new_context("_choose_renderer"),
|
||||
)
|
||||
|
||||
config.underlay = [ km ]
|
||||
|
||||
def skip_indicator():
|
||||
|
||||
### skip_indicator default
|
||||
# (text) The style and placement of the skip indicator.
|
||||
|
||||
if config.skip_indicator is True:
|
||||
|
||||
if config.skipping == "slow" and config.skip_indicator:
|
||||
ui.text(_(u"Skip Mode"), style='skip_indicator')
|
||||
|
||||
if config.skipping == "fast" and config.skip_indicator:
|
||||
ui.text(_(u"Fast Skip Mode"), style='skip_indicator')
|
||||
|
||||
return
|
||||
|
||||
if not config.skip_indicator:
|
||||
return
|
||||
|
||||
if not config.skipping:
|
||||
return
|
||||
|
||||
ui.add(renpy.easy.displayable(config.skip_indicator))
|
||||
|
||||
config.overlay_functions.append(skip_indicator)
|
||||
|
||||
# Hyperlink functions. Duplicated in _errorhandling.rpym.
|
||||
def hyperlink_styler(target):
|
||||
return style.hyperlink_text
|
||||
|
||||
def hyperlink_function(target):
|
||||
if target.startswith("http:"):
|
||||
try:
|
||||
import webbrowser
|
||||
webbrowser.open(target)
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
renpy.call_in_new_context(target)
|
||||
|
||||
style.default.hyperlink_functions = (hyperlink_styler, hyperlink_function, None)
|
||||
|
||||
# Prediction of screens.
|
||||
def predict():
|
||||
|
||||
for s in _predict_screens:
|
||||
if renpy.has_screen(s):
|
||||
renpy.predict_screen(s)
|
||||
|
||||
s = _game_menu_screen
|
||||
|
||||
if s is None:
|
||||
return
|
||||
|
||||
if renpy.has_screen(s):
|
||||
renpy.predict_screen(s)
|
||||
return
|
||||
|
||||
if s.endswith("_screen"):
|
||||
s = s[:-7]
|
||||
if renpy.has_screen(s):
|
||||
renpy.predict_screen(s)
|
||||
return
|
||||
|
||||
|
||||
config.predict_callbacks.append(predict)
|
||||
|
||||
def imagemap_auto_function(auto_param, variant):
|
||||
rv = auto_param % variant
|
||||
|
||||
if renpy.loadable(rv):
|
||||
return rv
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
config.imagemap_auto_function = imagemap_auto_function
|
||||
|
||||
|
||||
label _hide_windows:
|
||||
|
||||
if renpy.context()._menu:
|
||||
return
|
||||
|
||||
if _windows_hidden:
|
||||
return
|
||||
|
||||
python:
|
||||
_windows_hidden = True
|
||||
ui.saybehavior(dismiss=['dismiss', 'hide_windows'])
|
||||
ui.interact(suppress_overlay=True, suppress_window=True)
|
||||
_windows_hidden = False
|
||||
|
||||
return
|
||||
|
||||
|
||||
# This code here handles check for the correct version of the Ren'Py module.
|
||||
|
||||
label _save_reload_game:
|
||||
python hide:
|
||||
renpy.take_screenshot((config.thumbnail_width, config.thumbnail_height))
|
||||
renpy.music.stop()
|
||||
|
||||
ui.add(Solid((0, 0, 0, 255)))
|
||||
ui.text("Saving game...",
|
||||
size=32, xalign=0.5, yalign=0.5, color=(255, 255, 255, 255))
|
||||
|
||||
renpy.pause(0)
|
||||
|
||||
renpy.save("_reload-1", "reload save game")
|
||||
|
||||
ui.add(Solid((0, 0, 0, 255)))
|
||||
ui.text("Reloading script...",
|
||||
size=32, xalign=0.5, yalign=0.5, color=(255, 255, 255, 255))
|
||||
|
||||
renpy.pause(0)
|
||||
|
||||
renpy.utter_restart()
|
||||
|
||||
label _load_reload_game:
|
||||
|
||||
if not renpy.can_load("_reload-1"):
|
||||
return
|
||||
|
||||
python hide:
|
||||
renpy.rename_save("_reload-1", "_reload-2")
|
||||
|
||||
ui.add(Solid((0, 0, 0, 255)))
|
||||
ui.text("Reloading game...",
|
||||
size=32, xalign=0.5, yalign=0.5, color=(255, 255, 255, 255))
|
||||
|
||||
ui.pausebehavior(0)
|
||||
ui.interact(suppress_underlay=True, suppress_overlay=True)
|
||||
|
||||
renpy.load("_reload-2")
|
||||
|
||||
return
|
||||
|
||||
init -1001:
|
||||
image text = renpy.ParameterizedText(style="centered_text")
|
||||
|
||||
# Lock the library object.
|
||||
$ config.locked = True
|
||||
|
||||
|
||||
# Implement config.default_fullscreen and config.default_text_cps.
|
||||
init 1180 python:
|
||||
|
||||
if not persistent._set_preferences:
|
||||
persistent._set_preferences = True
|
||||
|
||||
if config.default_fullscreen is not None:
|
||||
_preferences.fullscreen = config.default_fullscreen
|
||||
|
||||
if config.default_text_cps is not None:
|
||||
_preferences.text_cps = config.default_text_cps
|
||||
|
||||
if config.default_afm_time is not None:
|
||||
_preferences.afm_time = config.default_afm_time
|
||||
|
||||
if config.default_afm_enable is not None:
|
||||
_preferences.afm_enable = config.default_afm_enable
|
||||
_preferences.using_afm_enable = True
|
||||
else:
|
||||
_preferences.afm_enable = True
|
||||
_preferences.using_afm_enable = False
|
||||
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Code that originated in 00gamemenu.rpy
|
||||
init -1180 python:
|
||||
|
||||
######################################################################
|
||||
# First up, we define a bunch of configuration variable, which the
|
||||
# user can change.
|
||||
|
||||
# menus: Music to play when entering the game menu.
|
||||
config.game_menu_music = None
|
||||
|
||||
# menus: Sound played when entering the library without clicking a
|
||||
# button.
|
||||
config.enter_sound = None
|
||||
|
||||
# menus: Sound played when leaving the library without clicking a
|
||||
# button.
|
||||
config.exit_sound = None
|
||||
|
||||
# menus: Transition that occurs when entering the game menu.
|
||||
config.enter_transition = None
|
||||
|
||||
# menus: Transition that occurs when leaving the game menu.
|
||||
config.exit_transition = None
|
||||
|
||||
# menus: Transition that's used when going from one screen to another.
|
||||
config.intra_transition = None
|
||||
|
||||
# menus: Transition that's used when going from the main to the game
|
||||
# menu.
|
||||
config.main_game_transition = None
|
||||
|
||||
# menus: Transition that's used when going from the game to the main
|
||||
# menu.
|
||||
config.game_main_transition = None
|
||||
|
||||
# menus: Transition that's used at the end of the game, when returning
|
||||
# to the main menu.
|
||||
config.end_game_transition = None
|
||||
|
||||
# menus: Transition that's used at the end of the splash screen, when
|
||||
# it is shown.
|
||||
config.end_splash_transition = None
|
||||
|
||||
# Transition that's used after the game is loaded.
|
||||
config.after_load_transition = None
|
||||
|
||||
# basics: True if autosave should be used.
|
||||
config.has_autosave = True
|
||||
|
||||
# basics: True if quicksave has been enabled.
|
||||
config.has_quicksave = False
|
||||
|
||||
# A list of layers to clear when entering the main and game menus.
|
||||
config.clear_layers = [ ]
|
||||
|
||||
# The _window_subtitle used inside menus.
|
||||
config.menu_window_subtitle = ''
|
||||
|
||||
# The screen that we go to when entering the game menu.
|
||||
_game_menu_screen = None
|
||||
|
||||
style.error_root = Style(style.default)
|
||||
style.error_title = Style(style.default)
|
||||
style.error_body = Style(style.default)
|
||||
|
||||
def _show_exception(title, message):
|
||||
|
||||
ui.window(style='error_root')
|
||||
ui.vbox()
|
||||
|
||||
ui.text(title, style='error_title')
|
||||
ui.text("")
|
||||
ui.text(message, style='error_body')
|
||||
ui.text("")
|
||||
ui.text(_(u"Please click to continue."), style='error_body')
|
||||
|
||||
ui.close()
|
||||
|
||||
ui.saybehavior()
|
||||
|
||||
ui.interact()
|
||||
|
||||
def _enter_menu():
|
||||
config.skipping = None
|
||||
|
||||
renpy.movie_stop(only_fullscreen=True)
|
||||
renpy.take_screenshot((config.thumbnail_width, config.thumbnail_height))
|
||||
|
||||
for i in config.menu_clear_layers:
|
||||
renpy.scene(layer=i)
|
||||
|
||||
renpy.context()._menu = True
|
||||
renpy.context()._main_menu = False
|
||||
renpy.context_dynamic("main_menu")
|
||||
renpy.context_dynamic("_window_subtitle")
|
||||
renpy.context_dynamic("_window")
|
||||
|
||||
store.main_menu = False
|
||||
store._window_subtitle = config.menu_window_subtitle
|
||||
store._window = False
|
||||
|
||||
store.mouse_visible = True
|
||||
store.suppress_overlay = True
|
||||
ui.clear()
|
||||
|
||||
for i in config.clear_layers:
|
||||
renpy.scene(layer=i)
|
||||
|
||||
# Run at the end of init, to set up autosaving based on the user's
|
||||
# choices.
|
||||
init 1180 python:
|
||||
|
||||
if config.has_autosave:
|
||||
config.autosave_slots = 10
|
||||
else:
|
||||
config.autosave_frequency = None
|
||||
|
||||
# Factored this all into one place, to make our lives a bit easier.
|
||||
label _enter_game_menu:
|
||||
$ _enter_menu()
|
||||
|
||||
$ renpy.transition(config.enter_transition)
|
||||
|
||||
if renpy.has_label("enter_game_menu"):
|
||||
call expression "enter_game_menu" from _call_enter_game_menu_1
|
||||
|
||||
if config.game_menu_music:
|
||||
$ renpy.music.play(config.game_menu_music, if_changed=True)
|
||||
|
||||
return
|
||||
|
||||
# Entry points from the game into menu-space.
|
||||
label _game_menu(_game_menu_screen=_game_menu_screen):
|
||||
if not _game_menu_screen:
|
||||
return
|
||||
|
||||
$ renpy.play(config.enter_sound)
|
||||
|
||||
call _enter_game_menu from _call__enter_game_menu_0
|
||||
|
||||
if renpy.has_label("game_menu"):
|
||||
jump expression "game_menu"
|
||||
|
||||
if renpy.has_screen(_game_menu_screen):
|
||||
$ renpy.show_screen(_game_menu_screen)
|
||||
$ ui.interact()
|
||||
jump _noisy_return
|
||||
|
||||
jump expression _game_menu_screen
|
||||
|
||||
label _game_menu_save:
|
||||
call _enter_game_menu from _call__enter_game_menu_1
|
||||
|
||||
if renpy.has_label("_save_screen"):
|
||||
jump expression "_save_screen"
|
||||
else:
|
||||
jump expression "save_screen"
|
||||
|
||||
label _game_menu_load:
|
||||
call _enter_game_menu from _call__enter_game_menu_2
|
||||
|
||||
if renpy.has_label("_load_screen"):
|
||||
jump expression "_load_screen"
|
||||
else:
|
||||
jump expression "load_screen"
|
||||
|
||||
label _game_menu_preferences:
|
||||
call _enter_game_menu from _call__enter_game_menu_3
|
||||
|
||||
if renpy.has_label("_prefs_screen"):
|
||||
jump expression "_prefs_screen"
|
||||
else:
|
||||
jump expression "preferences_screen"
|
||||
|
||||
label _quit:
|
||||
$ renpy.quit()
|
||||
|
||||
label _return_skipping:
|
||||
$ config.skipping = "slow"
|
||||
jump _return
|
||||
|
||||
# Make some noise, then return.
|
||||
label _noisy_return:
|
||||
$ renpy.play(config.exit_sound)
|
||||
|
||||
# Return to the game.
|
||||
label _return:
|
||||
|
||||
if renpy.context()._main_menu:
|
||||
$ renpy.transition(config.game_main_transition)
|
||||
jump _main_menu_screen
|
||||
|
||||
$ renpy.transition(config.exit_transition)
|
||||
|
||||
return
|
||||
|
||||
label _confirm_quit:
|
||||
|
||||
if renpy.has_label("confirm_quit"):
|
||||
jump expression "confirm_quit"
|
||||
elif renpy.has_label("_compat_confirm_quit"):
|
||||
jump expression "_compat_confirm_quit"
|
||||
else:
|
||||
jump expression "_quit_prompt"
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Code that originated in 00mainmenu.rpy
|
||||
|
||||
init -1180 python hide:
|
||||
|
||||
# menus: Music to play at the main menu.
|
||||
config.main_menu_music = None
|
||||
|
||||
# advanced: Callbacks to run at start.
|
||||
config.start_callbacks = [ ]
|
||||
|
||||
|
||||
# This fixes up the context, if necessary, then calls the real
|
||||
# after_load.
|
||||
label _after_load:
|
||||
$ renpy.context()._menu = False
|
||||
$ renpy.context()._main_menu = False
|
||||
|
||||
if config.after_load_transition:
|
||||
$ renpy.transition(config.after_load_transition, force=True)
|
||||
|
||||
if renpy.has_label("after_load"):
|
||||
jump expression "after_load"
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
# This is the true starting point of the program. Sssh... Don't
|
||||
# tell anyone.
|
||||
label _start:
|
||||
|
||||
python hide:
|
||||
renpy.context()._menu = False
|
||||
renpy.context()._main_menu = False
|
||||
|
||||
for i in config.start_callbacks:
|
||||
i()
|
||||
|
||||
$ renpy.block_rollback()
|
||||
|
||||
call _gl_test
|
||||
|
||||
call _load_reload_game from _call__load_reload_game_1
|
||||
|
||||
if not _restart and config.auto_load and renpy.can_load(config.auto_load):
|
||||
$ renpy.load(config.auto_load)
|
||||
|
||||
if config.start_scene_black:
|
||||
scene black
|
||||
else:
|
||||
scene
|
||||
|
||||
if not _restart:
|
||||
$ ui.pausebehavior(0)
|
||||
$ ui.interact(suppress_underlay=True, suppress_overlay=True)
|
||||
|
||||
$ renpy.block_rollback()
|
||||
|
||||
$ _old_game_menu_screen = _game_menu_screen
|
||||
$ _old_predict_screens = _predict_screens
|
||||
$ _game_menu_screen = None
|
||||
$ _predict_screens = [ 'main_menu' ]
|
||||
|
||||
if renpy.has_label("splashscreen") and not _restart:
|
||||
call expression "splashscreen" from _call_splashscreen_1
|
||||
|
||||
$ _game_menu_screen = _old_game_menu_screen
|
||||
$ del _old_game_menu_screen
|
||||
|
||||
$ renpy.block_rollback()
|
||||
|
||||
if config.main_menu_music:
|
||||
$ renpy.music.play(config.main_menu_music, if_changed=True)
|
||||
else:
|
||||
$ renpy.music.stop()
|
||||
|
||||
# Clean out any residual scene from the splashscreen.
|
||||
if config.start_scene_black:
|
||||
scene black
|
||||
else:
|
||||
scene
|
||||
|
||||
|
||||
# This has to be python, to deal with a case where _restart may
|
||||
# change across a shift-reload.
|
||||
python:
|
||||
if _restart is None:
|
||||
renpy.transition(config.end_splash_transition)
|
||||
else:
|
||||
renpy.transition(_restart[0])
|
||||
renpy.jump(_restart[1])
|
||||
|
||||
label _invoke_main_menu:
|
||||
|
||||
# Again, this has to be python.
|
||||
python:
|
||||
if _restart:
|
||||
renpy.call_in_new_context(_restart[2])
|
||||
else:
|
||||
renpy.call_in_new_context("_main_menu")
|
||||
|
||||
|
||||
# If the main menu returns, then start the game.
|
||||
jump start
|
||||
|
||||
# At this point, we've been switched into a new context. So we
|
||||
# initialize it.
|
||||
label _main_menu(_main_menu_screen="_main_menu_screen"):
|
||||
|
||||
$ _enter_menu()
|
||||
|
||||
python:
|
||||
renpy.dynamic("_load_prompt")
|
||||
_load_prompt = False
|
||||
|
||||
renpy.context()._main_menu = True
|
||||
store.main_menu = True
|
||||
|
||||
jump expression _main_menu_screen
|
||||
|
||||
# This is called to show the main menu to the user.
|
||||
label _main_menu_screen:
|
||||
|
||||
# Let the user completely override the main menu. (But please note
|
||||
# it still lives in the menu context, rather than the game context.)
|
||||
if renpy.has_label("main_menu"):
|
||||
jump expression "main_menu"
|
||||
|
||||
# New name.
|
||||
elif renpy.has_label("main_menu_screen"):
|
||||
jump expression "main_menu_screen"
|
||||
|
||||
# Compatibility name.
|
||||
elif renpy.has_label("_library_main_menu"):
|
||||
jump expression "_library_main_menu"
|
||||
|
||||
return
|
||||
|
||||
init 1180 python hide:
|
||||
|
||||
def create_automatic_images():
|
||||
|
||||
seps = config.automatic_images
|
||||
|
||||
if seps is True:
|
||||
seps = [ ' ', '/', '_' ]
|
||||
|
||||
for dir, fn in renpy.loader.listdirfiles():
|
||||
|
||||
if fn.startswith("_"):
|
||||
continue
|
||||
|
||||
# Only .png and .jpg
|
||||
if not fn.lower().endswith(".png") and not fn.lower().endswith(".jpg"):
|
||||
continue
|
||||
|
||||
# Strip the extension, replace slashes.
|
||||
shortfn = fn[:-4].replace("\\", "/")
|
||||
|
||||
# Determine the name.
|
||||
name = ( shortfn, )
|
||||
for sep in seps:
|
||||
name = tuple(j for i in name for j in i.split(sep))
|
||||
|
||||
# Strip name components.
|
||||
while name:
|
||||
for i in config.automatic_images_strip:
|
||||
if name[0] == i:
|
||||
name = name[1:]
|
||||
break
|
||||
else:
|
||||
break
|
||||
|
||||
# Only names of 2 components or more.
|
||||
if len(name) < 2:
|
||||
continue
|
||||
|
||||
# Reject if it already exists.
|
||||
if name in renpy.display.image.images:
|
||||
continue
|
||||
|
||||
renpy.image(name, fn)
|
||||
|
||||
if config.automatic_images:
|
||||
create_automatic_images()
|
||||
|
||||
|
||||
# After init, make some changes based on if config.developer is True.
|
||||
init 1180 python hide:
|
||||
|
||||
if config.developer:
|
||||
if config.debug_sound is None:
|
||||
config.debug_sound = True
|
||||
|
||||
renpy.load_module("_developer")
|
||||
|
||||
|
||||
|
||||
# Entry point for the developer screen. The rest of it is loaded from
|
||||
# _developer.rpym
|
||||
label _developer:
|
||||
|
||||
if not config.developer:
|
||||
return
|
||||
|
||||
$ _enter_menu()
|
||||
|
||||
jump expression "_developer_screen"
|
||||
|
||||
|
||||
# Translations.
|
||||
init -1180 python:
|
||||
|
||||
def _language_activate():
|
||||
|
||||
if persistent._language:
|
||||
language = persistent._language
|
||||
else:
|
||||
language = "translations"
|
||||
|
||||
if renpy.loadable(language + ".rpt"):
|
||||
config.translator = renpy.Translator(language)
|
||||
else:
|
||||
config.translator = None
|
||||
|
||||
_language_activate()
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# Common stuff that's used by the various Ren'Py menus. This includes
|
||||
# the default definitions of config.main_menu and config.game_menu, as
|
||||
# well as the default definitions of the various preferences (and the objects
|
||||
# holding those preferences)
|
||||
|
||||
init -1150 python:
|
||||
|
||||
config.main_menu = [
|
||||
(u"Start Game", "start", "True"),
|
||||
(u"Load Game", _intra_jumps("load_screen", "main_game_transition"), "True"),
|
||||
(u"Preferences", _intra_jumps("preferences_screen", "main_game_transition"), "True"),
|
||||
(u"Help", _help, "True", "config.help"),
|
||||
(u"Quit", ui.jumps("_quit"), "True"),
|
||||
]
|
||||
|
||||
config.game_menu = [
|
||||
( None, u"Return", ui.jumps("_return"), 'True'),
|
||||
( "preferences", u"Preferences", _intra_jumps("preferences_screen", "intra_transition"), 'True' ),
|
||||
( "save", u"Save Game", _intra_jumps("save_screen", "intra_transition"), 'not main_menu' ),
|
||||
( "load", u"Load Game", _intra_jumps("load_screen", "intra_transition"), 'True'),
|
||||
( None, u"Main Menu", ui.callsinnewcontext("_main_menu_prompt"), 'not main_menu' ),
|
||||
( "help", u"Help", _help, "True", "config.help"),
|
||||
( None, u"Quit", ui.callsinnewcontext("_quit_prompt"), 'True' ),
|
||||
]
|
||||
|
||||
label _quit_prompt:
|
||||
$ renpy.loadsave.force_autosave()
|
||||
|
||||
if layout.yesno_prompt(None, layout.QUIT):
|
||||
jump _quit
|
||||
else:
|
||||
return
|
||||
|
||||
label _main_menu_prompt:
|
||||
$ renpy.loadsave.force_autosave()
|
||||
|
||||
if layout.yesno_prompt(None, layout.MAIN_MENU):
|
||||
$ renpy.full_restart(transition=config.game_main_transition)
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# This file contains code that sets up the various mixers, based on how
|
||||
# the user sets config.has_music, .has_sound, and .has_voice.
|
||||
|
||||
init -1130 python hide:
|
||||
|
||||
# Set to true in the very unlikely event you want to manually init
|
||||
# the sound system.
|
||||
config.force_sound = False
|
||||
|
||||
# basics: True if the game will have music.
|
||||
config.has_music = True
|
||||
|
||||
# basics: True if the game will have sound effects.
|
||||
config.has_sound = True
|
||||
|
||||
# Register 8 channels by default, for compatiblity with older version
|
||||
# of Ren'Py.
|
||||
for i in xrange(0, 8):
|
||||
renpy.music.register_channel(i)
|
||||
|
||||
renpy.music.register_channel("movie", "music", False, stop_on_mute=False, buffer_queue=False)
|
||||
|
||||
# Set up default names for some of the channels.
|
||||
renpy.music.alias_channel(0, "sound")
|
||||
renpy.music.alias_channel(7, "music")
|
||||
renpy.music.alias_channel(2, "voice")
|
||||
|
||||
init 1130:
|
||||
|
||||
python hide:
|
||||
|
||||
if not config.has_music and not config.has_sound:
|
||||
mixers = None
|
||||
|
||||
elif not config.has_music and config.has_sound:
|
||||
mixers = [ 'sfx' ] * 8
|
||||
|
||||
elif config.has_music and not config.has_sound:
|
||||
mixers = [ 'music' ] * 8
|
||||
|
||||
else:
|
||||
mixers = [ 'sfx' ] * 3 + [ 'music' ] * 5
|
||||
|
||||
if config.has_voice:
|
||||
if not mixers:
|
||||
mixers = [ 'voice' ] * 8
|
||||
else:
|
||||
mixers[2] = 'voice'
|
||||
|
||||
if not mixers:
|
||||
config.sound = config.force_sound
|
||||
|
||||
else:
|
||||
for i, m in enumerate(mixers):
|
||||
renpy.sound.set_mixer(i, m, default=True)
|
||||
if m == 'music':
|
||||
renpy.music.set_music(i, True, default=True)
|
||||
else:
|
||||
renpy.music.set_music(i, False, default=True)
|
||||
|
||||
@@ -1,221 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# This file contains the code to implement Ren'Py's music room function,
|
||||
# which consists of the ability to set up a playlist (the aforementioned
|
||||
# "music room"), and then a series of actions that let the player
|
||||
# navigate through the music room.
|
||||
|
||||
init -1135 python:
|
||||
|
||||
class __MusicRoomPlay(Action):
|
||||
"""
|
||||
The action returned by MusicRoom.Play when called with a file.
|
||||
"""
|
||||
|
||||
def __init__(self, mr, filename):
|
||||
self.mr = mr
|
||||
self.filename = filename
|
||||
self.selected = self.get_selected()
|
||||
|
||||
def __call__(self):
|
||||
self.mr.play(self.filename, 0)
|
||||
|
||||
def get_sensitive(self):
|
||||
return self.mr.is_unlocked(self.filename)
|
||||
|
||||
def get_selected(self):
|
||||
return renpy.music.get_playing(self.mr.channel) == self.filename
|
||||
|
||||
def periodic(self, st):
|
||||
if self.selected != self.get_selected():
|
||||
renpy.restart_interaction()
|
||||
|
||||
return .1
|
||||
|
||||
class MusicRoom(object):
|
||||
"""
|
||||
:doc: music_room class
|
||||
|
||||
A music room that contains a series of songs that can be unlocked
|
||||
by the user, and actions that can play entries from the list in
|
||||
order.
|
||||
"""
|
||||
|
||||
def __init__(self, channel="music", fadeout=0.0, fadein=0.0):
|
||||
"""
|
||||
`channel`
|
||||
The channel that this music room will operate on.
|
||||
|
||||
`fadeout`
|
||||
The number of seconds it takes to fade out the old
|
||||
music when changing tracks.
|
||||
|
||||
`fadein`
|
||||
The number of seconds it takes to fade in the new
|
||||
music when changing tracks.
|
||||
"""
|
||||
|
||||
self.channel = channel
|
||||
self.fadeout = fadeout
|
||||
self.fadein = fadein
|
||||
|
||||
# The list of strings giving the titles of songs that make up the
|
||||
# playlist.
|
||||
self.playlist = [ ]
|
||||
|
||||
# A set of filenames, so we can quickly check if a valid filename
|
||||
# has been provided.
|
||||
self.filenames = set()
|
||||
|
||||
# The set of songs that are always unlocked.
|
||||
self.always_unlocked = set()
|
||||
|
||||
|
||||
def add(self, filename, always_unlocked=False):
|
||||
"""
|
||||
:doc: music_room method
|
||||
|
||||
Adds the music file `filename` to this music room. The music room
|
||||
will play unlocked files in the order that they are added to the
|
||||
room.
|
||||
|
||||
`always_unlocked`
|
||||
If true, the music file will be always unlocked. This allows
|
||||
the file to show up in the music room before it has been
|
||||
played in the game.
|
||||
"""
|
||||
|
||||
self.playlist.append(filename)
|
||||
self.filenames.add(filename)
|
||||
|
||||
if always_unlocked:
|
||||
self.always_unlocked.add(filename)
|
||||
|
||||
def is_unlocked(self, filename):
|
||||
"""
|
||||
:doc: music_room method
|
||||
|
||||
Returns true if the filename has been unlocked (or is always
|
||||
unlocked), and false if it is still locked.
|
||||
"""
|
||||
|
||||
if filename in self.always_unlocked:
|
||||
return True
|
||||
|
||||
return renpy.seen_audio(filename)
|
||||
|
||||
def unlocked_playlist(self):
|
||||
"""
|
||||
Returns a list of filenames in the playlist that have been
|
||||
unlocked.
|
||||
"""
|
||||
|
||||
return [ i for i in self.playlist if self.is_unlocked(i) ]
|
||||
|
||||
def play(self, filename=None, offset=0):
|
||||
"""
|
||||
Starts the music room playing. The file we start playing with is
|
||||
selected in two steps.
|
||||
|
||||
If `filename` is an unlocked file, we start by playing it.
|
||||
Otherwise, we start by playing the currently playing file, and if
|
||||
that doesn't exist or isn't unlocked, we start with the first file.
|
||||
|
||||
We then apply `offset`. If `offset` is positive, we advance that many
|
||||
files, otherwise we go back that many files.
|
||||
|
||||
The selected file is then played.
|
||||
|
||||
"""
|
||||
|
||||
playlist = self.unlocked_playlist()
|
||||
|
||||
if not playlist:
|
||||
return
|
||||
|
||||
if filename is None:
|
||||
filename = renpy.music.get_playing(channel=self.channel)
|
||||
|
||||
try:
|
||||
idx = playlist.index(filename)
|
||||
except ValueError:
|
||||
idx = 0
|
||||
|
||||
idx = (idx + offset) % len(playlist)
|
||||
|
||||
playlist = playlist[idx:] + playlist[:idx]
|
||||
|
||||
renpy.music.play(playlist, channel=self.channel, fadeout=self.fadeout, fadein=self.fadein)
|
||||
|
||||
def stop(self):
|
||||
"""
|
||||
Stops the music from playing.
|
||||
"""
|
||||
|
||||
renpy.music.stop(channel=self.channel, fadeout=self.fadeout)
|
||||
|
||||
def next(self):
|
||||
"""
|
||||
Plays the next file in the playlist.
|
||||
"""
|
||||
|
||||
return self.play(None, 1)
|
||||
|
||||
def previous(self):
|
||||
"""
|
||||
Plays the previous file in the playlist.
|
||||
"""
|
||||
|
||||
return self.play(None, -1)
|
||||
|
||||
def Play(self, filename=None):
|
||||
"""
|
||||
:doc: music_room method
|
||||
|
||||
Causes the music room to start playing. If `filename` is given, that
|
||||
file begins playing. Otherwise, the currently playing file starts
|
||||
over (if it's unlocked), or the first file starts playing.
|
||||
|
||||
If `filename` is given, buttons with this action will be insensitive
|
||||
while `filename` is locked, and will be selected when `filename`
|
||||
is playing.
|
||||
"""
|
||||
|
||||
if filename is None:
|
||||
return self.play
|
||||
|
||||
if filename not in self.filenames:
|
||||
raise Exception("{0!r} is not a filename registered with this music room.".format(filename))
|
||||
|
||||
return __MusicRoomPlay(self, filename)
|
||||
|
||||
def Stop(self):
|
||||
"""
|
||||
:doc: music_room method
|
||||
|
||||
Stops the music.
|
||||
"""
|
||||
|
||||
return self.stop
|
||||
|
||||
|
||||
def Next(self):
|
||||
"""
|
||||
:doc: music_room method
|
||||
|
||||
An action that causes the music room to play the next unlocked file
|
||||
in the playlist.
|
||||
"""
|
||||
|
||||
return self.next
|
||||
|
||||
def Previous(self):
|
||||
"""
|
||||
:doc: music_room method
|
||||
|
||||
An action that causes the music room to play the previous unlocked
|
||||
file in the playlist.
|
||||
"""
|
||||
|
||||
return self.previous
|
||||
@@ -1,416 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# This is an implementation of NVL-mode, which can be used to show
|
||||
# dialogue in a fullscreen way, like NVL-style games. Multiple lines
|
||||
# of dialogue are shown on the screen at once, whenever a line of
|
||||
# dialogue is said by a NVLCharacter. Calling the nvl_clear function
|
||||
# clears the screen, ensuring that the the next line will appear at
|
||||
# the top of the screen.
|
||||
#
|
||||
# You can also have menus appear on the screen, by running:
|
||||
#
|
||||
# init:
|
||||
# $ menu = nvl_menu
|
||||
#
|
||||
# It's also possible to make the narrator a NVLCharacter, using code like:
|
||||
#
|
||||
# init:
|
||||
# $ narrator = NVLCharacter(None)
|
||||
|
||||
##############################################################################
|
||||
# The implementation of NVL mode lives below this line.
|
||||
|
||||
init -1100 python:
|
||||
|
||||
# Styles that are used by nvl mode.
|
||||
style.create('nvl_window', 'default', 'the window containing nvl-mode dialogue')
|
||||
style.create('nvl_vbox', 'vbox', 'the vbox containing each box of nvl-mode dialogue')
|
||||
style.create('nvl_label', 'say_label', 'an nvl-mode character\'s name')
|
||||
style.create('nvl_dialogue', 'say_dialogue', 'nvl-mode character dialogue')
|
||||
style.create('nvl_entry', 'default', 'a window containing each line of nvl-mode dialogue')
|
||||
|
||||
style.create('nvl_menu_window', 'default', 'a window containing an nvl-mode menu')
|
||||
style.create('nvl_menu_choice', 'default', 'an nvl-mode menu choice')
|
||||
style.create('nvl_menu_choice_chosen', 'nvl_menu_choice', 'an nvl-mode menu choice that has been chosen')
|
||||
style.create('nvl_menu_choice_button', 'default', 'an nvl-mode choice button')
|
||||
style.create('nvl_menu_choice_chosen_button', 'nvl_menu_choice_button', 'an nvl-mode choice button that\'s been chosen.')
|
||||
|
||||
# Set up nvl mode styles.
|
||||
style.nvl_label.minwidth = 150
|
||||
style.nvl_label.text_align = 1.0
|
||||
|
||||
style.nvl_window.background = "#0008"
|
||||
style.nvl_window.yfill = True
|
||||
style.nvl_window.xfill = True
|
||||
style.nvl_window.xpadding = 20
|
||||
style.nvl_window.ypadding = 30
|
||||
|
||||
style.nvl_vbox.box_spacing = 10
|
||||
|
||||
style.nvl_menu_choice.idle_color = "#0ff"
|
||||
style.nvl_menu_choice.hover_color = "#ff0"
|
||||
style.nvl_menu_choice_button.left_margin = 160
|
||||
style.nvl_menu_choice_button.right_margin = 20
|
||||
style.nvl_menu_choice_button.xfill = True
|
||||
style.nvl_menu_choice_button.hover_background = "#F0F2"
|
||||
|
||||
# nvlmode: The CTC indicator to use when at the end of an NVL page.
|
||||
config.nvl_page_ctc = None
|
||||
|
||||
# nvlmode: The position of the CTC indicator used at the end of an NVL page.
|
||||
config.nvl_page_ctc_position = "nestled"
|
||||
|
||||
# Should we used paged rollback?
|
||||
config.nvl_paged_rollback = False
|
||||
|
||||
# A hook that delta wanted, that is called instead of renpy.show_display_say
|
||||
config.nvl_show_display_say = renpy.show_display_say
|
||||
|
||||
# A list of arguments that have been passed to nvl_record_show.
|
||||
nvl_list = None
|
||||
|
||||
# If set, then all of the nvl-specific style get indexed with this.
|
||||
nvl_variant = None
|
||||
|
||||
# Returns the appropriate variant style.
|
||||
def __s(s):
|
||||
if nvl_variant:
|
||||
return s[nvl_variant]
|
||||
else:
|
||||
return s
|
||||
|
||||
def __nvl_screen_dialogue():
|
||||
"""
|
||||
Returns widget_properties and dialogue for the current NVL
|
||||
mode screen.
|
||||
"""
|
||||
|
||||
widget_properties = { }
|
||||
dialogue = [ ]
|
||||
|
||||
for i, entry in enumerate(nvl_list):
|
||||
if not entry:
|
||||
continue
|
||||
|
||||
who, what, kwargs = entry
|
||||
|
||||
if i == len(nvl_list) - 1:
|
||||
who_id = "who"
|
||||
what_id = "what"
|
||||
window_id = "window"
|
||||
|
||||
else:
|
||||
who_id = "who%d" % i
|
||||
what_id = "what%d" % i
|
||||
window_id = "window%d" % i
|
||||
|
||||
widget_properties[who_id] = kwargs["who_args"]
|
||||
widget_properties[what_id] = kwargs["what_args"]
|
||||
widget_properties[window_id] = kwargs["window_args"]
|
||||
|
||||
dialogue.append((who, what, who_id, what_id, window_id))
|
||||
|
||||
return widget_properties, dialogue
|
||||
|
||||
def __nvl_show_screen(screen_name, **scope):
|
||||
"""
|
||||
Shows an nvl-mode screen. Returns the "what" widget.
|
||||
"""
|
||||
|
||||
widget_properties, dialogue = __nvl_screen_dialogue()
|
||||
|
||||
renpy.show_screen(screen_name, _transient=True, _widget_properties=widget_properties, dialogue=dialogue, **scope)
|
||||
renpy.shown_window()
|
||||
|
||||
return renpy.get_widget(screen_name, "what")
|
||||
|
||||
def nvl_show_core(who=None, what=None):
|
||||
|
||||
# Screen version.
|
||||
if renpy.has_screen("nvl"):
|
||||
return __nvl_show_screen("nvl", items=[ ])
|
||||
|
||||
if renpy.in_rollback():
|
||||
nvl_window = __s(style.nvl_window)['rollback']
|
||||
nvl_vbox = __s(style.nvl_vbox)['rollback']
|
||||
else:
|
||||
nvl_window = __s(style.nvl_window)
|
||||
nvl_vbox = __s(style.nvl_vbox)
|
||||
|
||||
ui.window(style=nvl_window)
|
||||
ui.vbox(style=nvl_vbox)
|
||||
|
||||
rv = None
|
||||
|
||||
for i in nvl_list:
|
||||
if not i:
|
||||
continue
|
||||
|
||||
who, what, kw = i
|
||||
rv = config.nvl_show_display_say(who, what, variant=nvl_variant, **kw)
|
||||
|
||||
ui.close()
|
||||
|
||||
renpy.shown_window()
|
||||
|
||||
return rv
|
||||
|
||||
def nvl_window():
|
||||
nvl_show_core()
|
||||
|
||||
def nvl_show(with_):
|
||||
nvl_show_core()
|
||||
renpy.with_statement(with_)
|
||||
|
||||
def nvl_hide(with_):
|
||||
nvl_show_core()
|
||||
renpy.with_statement(None)
|
||||
renpy.with_statement(with_)
|
||||
|
||||
def nvl_erase():
|
||||
if nvl_list:
|
||||
nvl_list.pop()
|
||||
|
||||
# Check to see if one of the next statements is nvl clear.
|
||||
def nvl_clear_next():
|
||||
|
||||
# The number of statements forward to look.
|
||||
count = 10
|
||||
|
||||
scry = renpy.scry()
|
||||
scry = scry.next()
|
||||
|
||||
while count and scry:
|
||||
|
||||
count -= 1
|
||||
if scry.nvl_clear:
|
||||
return True
|
||||
|
||||
if scry.interacts:
|
||||
return False
|
||||
|
||||
scry = scry.next()
|
||||
|
||||
|
||||
class NVLCharacter(ADVCharacter):
|
||||
|
||||
def __init__(self,
|
||||
who=renpy.character.NotSet,
|
||||
kind=None,
|
||||
**properties):
|
||||
|
||||
if kind is None:
|
||||
kind = store.nvl
|
||||
|
||||
if "clear" in properties:
|
||||
self.clear = properties.pop("clear")
|
||||
else:
|
||||
self.clear = kind.clear
|
||||
|
||||
ADVCharacter.__init__(
|
||||
self,
|
||||
who,
|
||||
kind=kind,
|
||||
**properties)
|
||||
|
||||
def do_add(self, who, what):
|
||||
|
||||
if store.nvl_list is None:
|
||||
store.nvl_list = [ ]
|
||||
|
||||
kwargs = self.show_args.copy()
|
||||
kwargs["what_args"] = self.what_args
|
||||
kwargs["who_args"] = self.who_args
|
||||
kwargs["window_args"] = self.window_args
|
||||
|
||||
store.nvl_list.append((who, what, kwargs))
|
||||
|
||||
def do_display(self, who, what, **display_args):
|
||||
|
||||
page = self.clear or nvl_clear_next()
|
||||
|
||||
if config.nvl_page_ctc and page:
|
||||
display_args["ctc"] = config.nvl_page_ctc
|
||||
display_args["ctc_position"] = config.nvl_page_ctc_position
|
||||
|
||||
if config.nvl_paged_rollback:
|
||||
if page:
|
||||
checkpoint = True
|
||||
else:
|
||||
if renpy.in_rollback():
|
||||
return
|
||||
checkpoint = False
|
||||
else:
|
||||
checkpoint = True
|
||||
|
||||
renpy.display_say(
|
||||
who,
|
||||
what,
|
||||
nvl_show_core,
|
||||
checkpoint=checkpoint,
|
||||
**display_args)
|
||||
|
||||
def do_done(self, who, what):
|
||||
if self.clear:
|
||||
nvl_clear()
|
||||
|
||||
def do_extend(self):
|
||||
renpy.mode(self.mode)
|
||||
store.nvl_list = store.nvl_list[:-1]
|
||||
|
||||
# The default NVLCharacter.
|
||||
nvl = NVLCharacter(
|
||||
show_say_vbox_properties={ 'box_layout' : 'horizontal' },
|
||||
who_style='nvl_label',
|
||||
what_style='nvl_dialogue',
|
||||
window_style='nvl_entry',
|
||||
type='nvl',
|
||||
mode='nvl',
|
||||
clear=False,
|
||||
kind=adv)
|
||||
|
||||
def nvl_clear():
|
||||
store.nvl_list = [ ]
|
||||
|
||||
# Run clear at the start of the game.
|
||||
config.start_callbacks.append(nvl_clear)
|
||||
|
||||
|
||||
def nvl_menu(items):
|
||||
|
||||
renpy.mode('nvl_menu')
|
||||
|
||||
if nvl_list is None:
|
||||
store.nvl_list = [ ]
|
||||
|
||||
screen = None
|
||||
|
||||
if renpy.has_screen("nvl_choice"):
|
||||
screen = "nvl_choice"
|
||||
elif renpy.has_screen("nvl"):
|
||||
screen = "nvl"
|
||||
|
||||
if screen is not None:
|
||||
|
||||
widget_properties, dialogue = __nvl_screen_dialogue()
|
||||
|
||||
return renpy.display_menu(
|
||||
items,
|
||||
widget_properties=widget_properties,
|
||||
screen=screen,
|
||||
scope={ "dialogue" : dialogue },
|
||||
window_style=__s(style.nvl_menu_window),
|
||||
choice_style=__s(style.nvl_menu_choice),
|
||||
choice_chosen_style=__s(style.nvl_menu_choice_chosen),
|
||||
choice_button_style=__s(style.nvl_menu_choice_button),
|
||||
choice_chosen_button_style=__s(style.nvl_menu_choice_chosen_button),
|
||||
type="nvl",
|
||||
)
|
||||
|
||||
|
||||
# Traditional version.
|
||||
ui.layer("transient")
|
||||
ui.clear()
|
||||
ui.close()
|
||||
|
||||
ui.window(style=__s(style.nvl_window))
|
||||
ui.vbox(style=__s(style.nvl_vbox))
|
||||
|
||||
for i in nvl_list:
|
||||
if not i:
|
||||
continue
|
||||
|
||||
who, what, kw = i
|
||||
rv = renpy.show_display_say(who, what, **kw)
|
||||
|
||||
renpy.display_menu(items, interact=False,
|
||||
window_style=__s(style.nvl_menu_window),
|
||||
choice_style=__s(style.nvl_menu_choice),
|
||||
choice_chosen_style=__s(style.nvl_menu_choice_chosen),
|
||||
choice_button_style=__s(style.nvl_menu_choice_button),
|
||||
choice_chosen_button_style=__s(style.nvl_menu_choice_chosen_button),
|
||||
)
|
||||
|
||||
ui.close()
|
||||
|
||||
roll_forward = renpy.roll_forward_info()
|
||||
|
||||
rv = ui.interact(roll_forward=roll_forward)
|
||||
renpy.checkpoint(rv)
|
||||
|
||||
return rv
|
||||
|
||||
NVLSpeaker = NVLCharacter
|
||||
|
||||
config.nvl_adv_transition = None
|
||||
config.adv_nvl_transition = None
|
||||
|
||||
|
||||
# This is used to execute the nvl and adv mode transitions.
|
||||
def _nvl_adv_callback(mode, old_modes):
|
||||
|
||||
old = old_modes[0]
|
||||
|
||||
if config.adv_nvl_transition:
|
||||
if mode == "nvl" or mode == "nvl_menu":
|
||||
if old == "say" or old == "menu":
|
||||
nvl_show(config.adv_nvl_transition)
|
||||
|
||||
if config.nvl_adv_transition:
|
||||
if mode == "say" or mode == "menu":
|
||||
if old == "nvl" or old == "nvl_menu":
|
||||
nvl_hide(config.nvl_adv_transition)
|
||||
|
||||
config.mode_callbacks.append(_nvl_adv_callback)
|
||||
|
||||
python early hide:
|
||||
|
||||
def parse_nvl_show_hide(l):
|
||||
rv = l.simple_expression()
|
||||
if rv is None:
|
||||
renpy.error('expected simple expression')
|
||||
|
||||
if not l.eol():
|
||||
renpy.error('expected end of line')
|
||||
|
||||
return rv
|
||||
|
||||
def lint_nvl_show_hide(trans):
|
||||
_try_eval(trans, 'transition')
|
||||
|
||||
def execute_nvl_show(trans):
|
||||
nvl_show(eval(trans))
|
||||
|
||||
def execute_nvl_hide(trans):
|
||||
nvl_hide(eval(trans))
|
||||
|
||||
renpy.statements.register("nvl show",
|
||||
parse=parse_nvl_show_hide,
|
||||
execute=execute_nvl_show,
|
||||
lint=lint_nvl_show_hide)
|
||||
|
||||
renpy.statements.register("nvl hide",
|
||||
parse=parse_nvl_show_hide,
|
||||
execute=execute_nvl_hide,
|
||||
lint=lint_nvl_show_hide)
|
||||
|
||||
def parse_nvl_clear(l):
|
||||
if not l.eol():
|
||||
renpy.error('expected end of line')
|
||||
|
||||
return None
|
||||
|
||||
def execute_nvl_clear(parse):
|
||||
nvl_clear()
|
||||
|
||||
def scry_nvl_clear(parse, scry):
|
||||
scry.nvl_clear = True
|
||||
|
||||
renpy.statements.register('nvl clear',
|
||||
parse=parse_nvl_clear,
|
||||
execute=execute_nvl_clear,
|
||||
scry=scry_nvl_clear)
|
||||
|
||||
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
# This file contains the spline motion code contributed by Aenakume, at
|
||||
# http://lemmasoft.renai.us/forums/viewtopic.php?f=8&t=3977
|
||||
|
||||
init -1080 python:
|
||||
class _SplineInterpolator(object):
|
||||
|
||||
ANCHORS = {
|
||||
'top' : 0.0,
|
||||
'center' : 0.5,
|
||||
'bottom' : 1.0,
|
||||
'left' : 0.0,
|
||||
'right' : 1.0,
|
||||
}
|
||||
|
||||
def __init__(self, points, anchors=(0.5, 0.5)):
|
||||
|
||||
assert len(points) >= 2, "Need at least a start and end point."
|
||||
|
||||
def setup_coordinate_(c):
|
||||
if len(c) == 2:
|
||||
c += anchors
|
||||
return [ self.ANCHORS.get(i, i) for i in c ]
|
||||
|
||||
self.points = []
|
||||
|
||||
for p in points:
|
||||
length = len(p)
|
||||
|
||||
if isinstance(p[-1], float):
|
||||
length = len(p) - 1
|
||||
point = [ p[-1] ]
|
||||
else:
|
||||
length = len(p)
|
||||
point = [ -1 ]
|
||||
|
||||
self.points.append(point + [ setup_coordinate_(p[i]) for i in range(length) ])
|
||||
|
||||
# Make sure start and end times are set, if not already set
|
||||
if self.points[0][0] == -1:
|
||||
self.points[0][0] = 0.0
|
||||
if self.points[-1][0] == -1:
|
||||
self.points[-1][0] = 1.0
|
||||
|
||||
# Now we gotta calculate the step times that need calculating
|
||||
for start in range(1, len(self.points) - 1):
|
||||
if self.points[start][0] != -1:
|
||||
continue
|
||||
|
||||
end = start + 1
|
||||
|
||||
while end < (len(self.points) - 1) and self.points[end][0] == -1:
|
||||
end += 1
|
||||
|
||||
step = (self.points[end][0] - self.points[start - 1][0]) / float(end - start + 1)
|
||||
|
||||
for i in range(start, end):
|
||||
self.points[i][0] = self.points[i - 1][0] + step
|
||||
|
||||
# And finally, sort the list of points by increasing time
|
||||
self.points.sort(key=lambda a : a[0])
|
||||
|
||||
self.initialized = None
|
||||
|
||||
def init_values(self, sizes):
|
||||
def to_abs_(value, size):
|
||||
if type(value) == float:
|
||||
return value * size
|
||||
else:
|
||||
return value
|
||||
|
||||
def coord_(c):
|
||||
|
||||
if len(c) == 2:
|
||||
c = c + (0, 0)
|
||||
|
||||
return ( to_abs_(c[0], sizes[0]) - to_abs_(c[2], sizes[2]),
|
||||
to_abs_(c[1], sizes[1]) - to_abs_(c[3], sizes[3]) )
|
||||
|
||||
for p in self.points:
|
||||
for i in range(1, len(p)):
|
||||
p[i] = coord_(p[i])
|
||||
|
||||
self.initialized = sizes
|
||||
|
||||
def __call__(self, t, sizes):
|
||||
# Initialize if necessary
|
||||
if not self.initialized == sizes:
|
||||
self.init_values(sizes)
|
||||
|
||||
# Now we must determine which segment we are in
|
||||
for segment in range(len(self.points)):
|
||||
if self.points[segment][0] > t:
|
||||
break
|
||||
|
||||
# If this is the zeroth segment, just start at the start point
|
||||
if segment == 0:
|
||||
result = self.points[0][1]
|
||||
# If this is past the last segment, just leave it at the end point
|
||||
elif segment == len(self.points) - 1 and t > self.points[-1][0]:
|
||||
result = self.points[-1][1]
|
||||
else:
|
||||
# Scale t
|
||||
t = (t - self.points[segment - 1][0]) / (self.points[segment][0] - self.points[segment - 1][0])
|
||||
|
||||
# Get start and end points
|
||||
start = self.points[segment - 1][1]
|
||||
end = self.points[segment][1]
|
||||
|
||||
# Now what kind of interpolation is it?
|
||||
if len(self.points[segment]) == 2: # Straight line
|
||||
t_p = 1.0 - t
|
||||
|
||||
result = [ t_p * start[i] + t * end[i] for i in 0,1 ]
|
||||
|
||||
elif len(self.points[segment]) == 3: # Quadratic Bezier
|
||||
t_pp = (1.0 - t)**2
|
||||
t_p = 2 * t * (1.0 - t)
|
||||
t2 = t**2
|
||||
|
||||
result = [ t_pp * start[i] + t_p * self.points[segment][2][i] + t2 * end[i] for i in 0,1 ]
|
||||
|
||||
elif len(self.points[segment]) == 4: # Cubic Bezier
|
||||
t_ppp = (1.0 - t)**3
|
||||
t_pp = 3 * t * (1.0 - t)**2
|
||||
t_p = 3 * t**2 * (1.0 - t)
|
||||
t3 = t**3
|
||||
|
||||
result = [ t_ppp * start[i] + t_pp * self.points[segment][2][i] + t_p * self.points[segment][3][i] + t3 * end[i] for i in 0,1 ]
|
||||
|
||||
return ( absolute(result[0]), absolute(result[1]), 0, 0 )
|
||||
|
||||
def SplineMotion(points, time, child=None, anchors=(0.5, 0.5), repeat=False, bounce=False, anim_timebase=False, style='default', time_warp=None, **properties):
|
||||
return Motion(_SplineInterpolator(points, anchors), time, child, repeat=repeat, bounce=bounce, anim_timebase=anim_timebase, style=style, time_warp=time_warp, add_sizes=True, **properties)
|
||||
|
||||
|
||||
@@ -1,569 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# This file contains code that creates a few new statements. We'll
|
||||
# also describe here the API for defining your own statements.
|
||||
#
|
||||
# Statements can be defined by calling renpy.statements.register. This
|
||||
# function takes a string giving the keywords at the start of the
|
||||
# statement, and then up to 4 functions defining the behavior of the
|
||||
# statement: parse, execute, predict, and lint. If given the keyword
|
||||
# argument block=True, the statement will take a block.
|
||||
#
|
||||
# The parse function takes a lexer object as an argument, and is
|
||||
# expected to return some parser data. The lexer has the following
|
||||
# methods.
|
||||
#
|
||||
# l.eol() - True if we are at the end of the line.
|
||||
# l.match(re) - Matches an arbitrary regexp string.
|
||||
# l.keyword(s) - Matches s.
|
||||
# l.name() - Matches any non-keyword name. Note that this only
|
||||
# counts built-in keywords.
|
||||
# l.word() - Matches any word, period.
|
||||
# l.string() - Matches a renpy string.
|
||||
# l.integer() - Matches an integer, returns a string containing the
|
||||
# integer.
|
||||
# l.float() - Matches a floating point number.
|
||||
# l.simple_expression() - Matches a simple python expression, returns
|
||||
# it as a string.
|
||||
# l.rest() - Skips whitespace, then returns the rest of the line.
|
||||
# l.checkpoint() - Returns an opaque object representing the current
|
||||
# point in the parse.
|
||||
# l.revert(o) - Given the object returned by l.checkpoint(), returns
|
||||
# there.
|
||||
#
|
||||
# l.subblock_lexer() - Return a lexer that gives a sub-block for the
|
||||
# block associated with the current statement.
|
||||
# l.advance() - In a subblock lexer, advance to the next line. This needs
|
||||
# to be called before the above functions can be called on the first line.
|
||||
#
|
||||
#
|
||||
#
|
||||
# The parse function is expected to return an object, which is passed
|
||||
# to the other functions. Parse should call renpy.error with the error
|
||||
# message to report an error.
|
||||
#
|
||||
# The execute function is passed the object returned from parse, and
|
||||
# is expected to execute the statement.
|
||||
#
|
||||
# The predict function is passed the object returned from parse, and
|
||||
# is expected to return a list of images that are used by the
|
||||
# statement.
|
||||
#
|
||||
# The lint function is called at lint time, after the init code is
|
||||
# run. It should check the statement for errors, and report them by
|
||||
# calling renpy.error with the appropriate error message.
|
||||
#
|
||||
# The scry function is called with a scry object. It may mutate that
|
||||
# object, but it is then expected to return it. See 00nvlmode.rpy for
|
||||
# details.
|
||||
#
|
||||
# The next function is expected to return a string giving the label of
|
||||
# the next statement to execute, or None to indicate that next
|
||||
# statement in the block should be executed. The next function is
|
||||
# called during predict, scry, and execute, and should always return
|
||||
# the same value. (Or scrying may be incorrect.)
|
||||
|
||||
|
||||
python early hide:
|
||||
|
||||
# Music play - The example of a full statement.
|
||||
|
||||
def parse_play_music(l):
|
||||
|
||||
file = l.simple_expression()
|
||||
if not file:
|
||||
renpy.error("play requires a file")
|
||||
|
||||
fadeout = "None"
|
||||
fadein = "0"
|
||||
channel = None
|
||||
loop = None
|
||||
if_changed = False
|
||||
|
||||
while True:
|
||||
|
||||
if l.eol():
|
||||
break
|
||||
|
||||
if l.keyword('fadeout'):
|
||||
fadeout = l.simple_expression()
|
||||
if fadeout is None:
|
||||
renpy.error('expected simple expression')
|
||||
|
||||
continue
|
||||
|
||||
if l.keyword('fadein'):
|
||||
fadein = l.simple_expression()
|
||||
if fadein is None:
|
||||
renpy.error('expected simple expression')
|
||||
|
||||
continue
|
||||
|
||||
if l.keyword('channel'):
|
||||
channel = l.simple_expression()
|
||||
if channel is None:
|
||||
renpy.error('expected simple expression')
|
||||
|
||||
continue
|
||||
|
||||
if l.keyword('loop'):
|
||||
loop = True
|
||||
continue
|
||||
|
||||
if l.keyword('noloop'):
|
||||
loop = False
|
||||
continue
|
||||
|
||||
if l.keyword('if_changed'):
|
||||
if_changed = True
|
||||
continue
|
||||
|
||||
renpy.error('could not parse statement.')
|
||||
|
||||
return dict(file=file,
|
||||
fadeout=fadeout,
|
||||
fadein=fadein,
|
||||
channel=channel,
|
||||
loop=loop,
|
||||
if_changed=if_changed)
|
||||
|
||||
def execute_play_music(p):
|
||||
|
||||
if p["channel"] is not None:
|
||||
channel = eval(p["channel"])
|
||||
else:
|
||||
channel = "music"
|
||||
|
||||
renpy.music.play(eval(p["file"]),
|
||||
fadeout=eval(p["fadeout"]),
|
||||
fadein=eval(p["fadein"]),
|
||||
channel=channel,
|
||||
loop=p.get("loop", None),
|
||||
if_changed=p.get("if_changed", False))
|
||||
|
||||
def predict_play_music(p):
|
||||
return [ ]
|
||||
|
||||
def lint_play_music(p, channel="music"):
|
||||
|
||||
file = _try_eval(p["file"], 'filename')
|
||||
|
||||
if p["channel"] is not None:
|
||||
channel = _try_eval(p["channel"], 'channel')
|
||||
|
||||
if not isinstance(file, list):
|
||||
file = [ file ]
|
||||
|
||||
for fn in file:
|
||||
if isinstance(fn, basestring):
|
||||
try:
|
||||
if not renpy.music.playable(fn, channel):
|
||||
renpy.error("%r is not loadable" % fn)
|
||||
except:
|
||||
pass
|
||||
|
||||
renpy.statements.register('play music',
|
||||
parse=parse_play_music,
|
||||
execute=execute_play_music,
|
||||
predict=predict_play_music,
|
||||
lint=lint_play_music)
|
||||
|
||||
# From here on, we'll steal bits of other statements when defining other
|
||||
# statements.
|
||||
|
||||
def parse_queue_music(l):
|
||||
|
||||
file = l.simple_expression()
|
||||
if not file:
|
||||
renpy.error("queue requires a file")
|
||||
|
||||
channel = None
|
||||
loop = None
|
||||
|
||||
while not l.eol():
|
||||
|
||||
if l.keyword('channel'):
|
||||
channel = l.simple_expression()
|
||||
if channel is None:
|
||||
renpy.error('expected simple expression')
|
||||
|
||||
if l.keyword('loop'):
|
||||
loop = True
|
||||
continue
|
||||
|
||||
if l.keyword('noloop'):
|
||||
loop = False
|
||||
continue
|
||||
|
||||
renpy.error('expected end of line')
|
||||
|
||||
return dict(file=file, channel=channel, loop=loop)
|
||||
|
||||
def execute_queue_music(p):
|
||||
if p["channel"] is not None:
|
||||
channel = eval(p["channel"])
|
||||
else:
|
||||
channel = "music"
|
||||
|
||||
renpy.music.queue(
|
||||
eval(p["file"]),
|
||||
channel=channel,
|
||||
loop=p.get("loop", None))
|
||||
|
||||
|
||||
renpy.statements.register('queue music',
|
||||
parse=parse_queue_music,
|
||||
execute=execute_queue_music,
|
||||
lint=lint_play_music)
|
||||
|
||||
def parse_stop_music(l):
|
||||
fadeout = "None"
|
||||
|
||||
if l.keyword("fadeout"):
|
||||
fadeout = l.simple_expression()
|
||||
|
||||
channel = None
|
||||
|
||||
if l.keyword('channel'):
|
||||
channel = l.simple_expression()
|
||||
if channel is None:
|
||||
renpy.error('expected simple expression')
|
||||
|
||||
if not l.eol():
|
||||
renpy.error('expected end of line')
|
||||
|
||||
if fadeout is None:
|
||||
renpy.error('expected simple expression')
|
||||
|
||||
return dict(fadeout=fadeout, channel=channel)
|
||||
|
||||
def execute_stop_music(p):
|
||||
if p["channel"] is not None:
|
||||
channel = eval(p["channel"])
|
||||
else:
|
||||
channel = "music"
|
||||
|
||||
renpy.music.stop(fadeout=eval(p["fadeout"]), channel=channel)
|
||||
|
||||
renpy.statements.register('stop music',
|
||||
parse=parse_stop_music,
|
||||
execute=execute_stop_music)
|
||||
|
||||
|
||||
# Sound statements. They share alot with the equivalent music
|
||||
# statements.
|
||||
|
||||
def execute_play_sound(p):
|
||||
|
||||
if p["channel"] is not None:
|
||||
channel = eval(p["channel"])
|
||||
else:
|
||||
channel = "sound"
|
||||
|
||||
fadeout = eval(p["fadeout"]) or 0
|
||||
|
||||
renpy.sound.play(eval(p["file"]),
|
||||
fadeout=fadeout,
|
||||
fadein=eval(p["fadein"]),
|
||||
channel=channel)
|
||||
|
||||
def lint_play_sound(p, lint_play_music=lint_play_music):
|
||||
return lint_play_music(p, channel="sound")
|
||||
|
||||
renpy.statements.register('play sound',
|
||||
parse=parse_play_music,
|
||||
execute=execute_play_sound,
|
||||
lint=lint_play_sound)
|
||||
|
||||
def execute_queue_sound(p):
|
||||
if p["channel"] is not None:
|
||||
channel = eval(p["channel"])
|
||||
else:
|
||||
channel = "sound"
|
||||
|
||||
renpy.sound.queue(eval(p["file"]), channel=channel)
|
||||
|
||||
|
||||
renpy.statements.register('queue sound',
|
||||
parse=parse_queue_music,
|
||||
execute=execute_queue_sound,
|
||||
lint=lint_play_music)
|
||||
|
||||
def execute_stop_sound(p):
|
||||
if p["channel"] is not None:
|
||||
channel = eval(p["channel"])
|
||||
else:
|
||||
channel = "sound"
|
||||
|
||||
fadeout = eval(p["fadeout"]) or 0
|
||||
|
||||
renpy.sound.stop(fadeout=fadeout, channel=channel)
|
||||
|
||||
renpy.statements.register('stop sound',
|
||||
parse=parse_stop_music,
|
||||
execute=execute_stop_sound)
|
||||
|
||||
|
||||
# Generic play/queue/stop statements. These take a channel name as
|
||||
# the second thing.
|
||||
|
||||
def parse_play_generic(l, parse_play_music=parse_play_music):
|
||||
channel = l.name()
|
||||
|
||||
if channel is None:
|
||||
renpy.error('play requires a channel')
|
||||
|
||||
rv = parse_play_music(l)
|
||||
if rv["channel"] is None:
|
||||
rv["channel"] = repr(channel)
|
||||
|
||||
return rv
|
||||
|
||||
def parse_queue_generic(l, parse_queue_music=parse_queue_music):
|
||||
channel = l.name()
|
||||
|
||||
if channel is None:
|
||||
renpy.error('queue requires a channel')
|
||||
|
||||
rv = parse_queue_music(l)
|
||||
if rv["channel"] is None:
|
||||
rv["channel"] = repr(channel)
|
||||
|
||||
return rv
|
||||
|
||||
def parse_stop_generic(l, parse_stop_music=parse_stop_music):
|
||||
channel = l.name()
|
||||
|
||||
if channel is None:
|
||||
renpy.error('stop requires a channel')
|
||||
|
||||
rv = parse_stop_music(l)
|
||||
if rv["channel"] is None:
|
||||
rv["channel"] = repr(channel)
|
||||
|
||||
return rv
|
||||
|
||||
def lint_play_generic(p, lint_play_music=lint_play_music):
|
||||
channel = eval(p["channel"])
|
||||
|
||||
if not renpy.music.channel_defined(channel):
|
||||
renpy.error("channel %r is not defined" % channel)
|
||||
|
||||
lint_play_music(p, channel)
|
||||
|
||||
def lint_stop_generic(p):
|
||||
channel = eval(p["channel"])
|
||||
|
||||
if not renpy.music.channel_defined(channel):
|
||||
renpy.error("channel %r is not defined" % channel)
|
||||
|
||||
renpy.statements.register('play',
|
||||
parse=parse_play_generic,
|
||||
execute=execute_play_music,
|
||||
predict=predict_play_music,
|
||||
lint=lint_play_generic)
|
||||
|
||||
renpy.statements.register('queue',
|
||||
parse=parse_queue_generic,
|
||||
execute=execute_queue_music,
|
||||
lint=lint_play_generic)
|
||||
|
||||
renpy.statements.register('stop',
|
||||
parse=parse_stop_generic,
|
||||
execute=execute_stop_music,
|
||||
lint=lint_stop_generic)
|
||||
|
||||
|
||||
##########################################################################
|
||||
# "window show" and "window hide" statements.
|
||||
|
||||
def parse_window(l):
|
||||
p = l.simple_expression()
|
||||
if not l.eol():
|
||||
renpy.error('expected end of line')
|
||||
|
||||
return p
|
||||
|
||||
def lint_window(p):
|
||||
if p is not None:
|
||||
_try_eval(p, 'window transition')
|
||||
|
||||
def execute_window_show(p):
|
||||
if store._window:
|
||||
return
|
||||
|
||||
if p is not None:
|
||||
trans = eval(p)
|
||||
else:
|
||||
trans = config.window_show_transition
|
||||
|
||||
renpy.with_statement(None)
|
||||
store._window = True
|
||||
renpy.with_statement(trans)
|
||||
|
||||
def execute_window_hide(p):
|
||||
if not _window:
|
||||
return
|
||||
|
||||
if p is not None:
|
||||
trans = eval(p)
|
||||
else:
|
||||
trans = config.window_hide_transition
|
||||
|
||||
renpy.with_statement(None)
|
||||
store._window = False
|
||||
renpy.with_statement(trans)
|
||||
|
||||
renpy.statements.register('window show',
|
||||
parse=parse_window,
|
||||
execute=execute_window_show,
|
||||
lint=lint_window)
|
||||
|
||||
renpy.statements.register('window hide',
|
||||
parse=parse_window,
|
||||
execute=execute_window_hide,
|
||||
lint=lint_window)
|
||||
|
||||
##########################################################################
|
||||
# Pause statement.
|
||||
|
||||
def parse_pause(l):
|
||||
|
||||
delay = l.simple_expression()
|
||||
|
||||
if not l.eol():
|
||||
renpy.error("expected end of line.")
|
||||
|
||||
return { "delay" : delay }
|
||||
|
||||
def lint_pause(p):
|
||||
|
||||
if p["delay"]:
|
||||
_try_eval(p["delay"], 'pause statement')
|
||||
|
||||
def execute_pause(p):
|
||||
|
||||
if p["delay"]:
|
||||
delay = eval(p["delay"])
|
||||
renpy.with_statement(Pause(delay))
|
||||
else:
|
||||
renpy.pause()
|
||||
|
||||
|
||||
renpy.statements.register('pause',
|
||||
parse=parse_pause,
|
||||
lint=lint_pause,
|
||||
execute=execute_pause)
|
||||
|
||||
|
||||
init -1200 python:
|
||||
|
||||
config.window_show_transition = None
|
||||
config.window_hide_transition = None
|
||||
|
||||
def _try_eval(e, what):
|
||||
try:
|
||||
return eval(e)
|
||||
except:
|
||||
renpy.error('unable to evaluate %s %r' % (what, e))
|
||||
|
||||
##############################################################################
|
||||
# Screen-related statements.
|
||||
|
||||
python early hide:
|
||||
|
||||
def parse_show_call_screen(l):
|
||||
|
||||
# Parse a name.
|
||||
name = l.require(l.name)
|
||||
|
||||
# Parse a parameter list. (name -> expression string)
|
||||
parameters = { }
|
||||
|
||||
if l.match(r"\("):
|
||||
|
||||
while True:
|
||||
pname = l.name()
|
||||
if not pname:
|
||||
break
|
||||
|
||||
l.require(r"=")
|
||||
|
||||
expr = l.delimited_python(",)")
|
||||
|
||||
if not expr:
|
||||
l.error("expected expression.")
|
||||
|
||||
parameters[pname] = expr
|
||||
|
||||
if not l.match(r','):
|
||||
break
|
||||
|
||||
l.require(r'\)')
|
||||
l.expect_eol()
|
||||
|
||||
return dict(name=name, parameters=parameters)
|
||||
|
||||
def parse_hide_screen(l):
|
||||
name = l.require(l.name)
|
||||
|
||||
l.expect_eol()
|
||||
|
||||
return dict(name=name)
|
||||
|
||||
def predict_screen(p):
|
||||
if not p["parameters"]:
|
||||
renpy.predict_screen(p["name"])
|
||||
|
||||
def execute_show_screen(p):
|
||||
|
||||
name = p["name"]
|
||||
parameters = p["parameters"]
|
||||
|
||||
kwargs = { }
|
||||
|
||||
for k, v in parameters.iteritems():
|
||||
kwargs[k] = eval(v)
|
||||
|
||||
renpy.show_screen(name, **kwargs)
|
||||
|
||||
def execute_call_screen(p):
|
||||
name = p["name"]
|
||||
parameters = p["parameters"]
|
||||
|
||||
kwargs = { }
|
||||
|
||||
for k, v in parameters.iteritems():
|
||||
kwargs[str(k)] = eval(v)
|
||||
|
||||
store._return = renpy.call_screen(name, **kwargs)
|
||||
|
||||
def execute_hide_screen(p):
|
||||
name = p["name"]
|
||||
renpy.hide_screen(name)
|
||||
|
||||
def lint_screen(p):
|
||||
name = p["name"]
|
||||
if not renpy.has_screen(name):
|
||||
renpy.error("Screen %s does not exist." % name)
|
||||
|
||||
|
||||
renpy.statements.register("show screen",
|
||||
parse=parse_show_call_screen,
|
||||
execute=execute_show_screen,
|
||||
predict=predict_screen,
|
||||
lint=lint_screen)
|
||||
|
||||
renpy.statements.register("call screen",
|
||||
parse=parse_show_call_screen,
|
||||
execute=execute_call_screen,
|
||||
predict=predict_screen,
|
||||
lint=lint_screen)
|
||||
|
||||
renpy.statements.register("hide screen",
|
||||
parse=parse_hide_screen,
|
||||
execute=execute_hide_screen)
|
||||
|
||||
|
||||
|
||||
@@ -1,328 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# This file is responsible for creating and defining the default styles
|
||||
# used by the system.
|
||||
|
||||
# This file should be considered part of the Ren'Py library, and not
|
||||
# something that needs to be modified by the user. Instead, just update
|
||||
# the appropriate style property in an init: block in your script.
|
||||
#
|
||||
# For example, to change the default window backgrounds to a
|
||||
# transparent dark red, add:
|
||||
#
|
||||
# init:
|
||||
# $ style.window.background = "#8008"
|
||||
#
|
||||
# to your script. No need to mess around here, it will just make your
|
||||
# life harder when a new version of Ren'Py is released.
|
||||
|
||||
init -1200 python hide:
|
||||
|
||||
# Style Declarations #################################################
|
||||
|
||||
style.default = Style(None, help='root of style hierarchy')
|
||||
style.text = Style(style.default, help='style of text')
|
||||
|
||||
style.fixed = Style(style.default, help='fixed layouts')
|
||||
style.hbox = Style(style.default, help='horizontal boxes')
|
||||
style.vbox = Style(style.default, help='vertical boxes')
|
||||
style.grid = Style(style.default, help='grid layouts')
|
||||
style.side = Style(style.default, help='side layouts')
|
||||
|
||||
style.window = Style(style.default, help='windows created with ui.window')
|
||||
|
||||
style.image_placement = Style(style.default, help='default placement of images on the screen')
|
||||
style.image = Style(style.default, help="default style of images")
|
||||
|
||||
style.motion = Style(style.default, help="default style of motions and zooms.")
|
||||
style.animation = Style(style.default, help="default style of animations.")
|
||||
|
||||
style.say_label = Style(style.default, help='the name of the character speaking dialogue.')
|
||||
style.say_dialogue = Style(style.default, help='used for dialogue text')
|
||||
style.say_thought = Style(style.default, help='used by the default narrator')
|
||||
style.say_window = Style(style.window, help='windows containing dialogue and thoughts')
|
||||
style.say_who_window = Style(style.window, help='window containing the label in two-window-say mode')
|
||||
style.say_two_window_vbox = Style(style.vbox, help='vbox containing the two windows in two-window-say mode')
|
||||
style.say_vbox = Style(style.vbox, help='contains the label (if present) and the body of dialogue')
|
||||
|
||||
style.menu = Style(style.default, help='the vbox containing an in-game menu')
|
||||
style.menu_caption = Style(style.default, help='in-game menu caption text')
|
||||
style.menu_choice = Style(style.default, help='text of an in-game menu choice')
|
||||
style.menu_choice_button = Style(style.default, help='buttons containing in-game menu choices')
|
||||
style.menu_choice_chosen = Style(style.menu_choice, help='text of an in-game menu choice that has been chosen')
|
||||
style.menu_choice_chosen_button = Style(style.menu_choice_button, help='buttons containing chosen in-game menu choices')
|
||||
style.menu_window = Style(style.window, help='a window containing a menu')
|
||||
|
||||
style.input = Style(style.default, help='style of an input control')
|
||||
style.input_text = Style(style.input, help='text of an input box')
|
||||
style.input_prompt = Style(style.default, help='prompt of an input box')
|
||||
style.input_window = Style(style.window, help='window of an input box')
|
||||
|
||||
style.centered_window = Style(style.default, help='window containing centered text')
|
||||
style.centered_text = Style(style.default, help='centered text')
|
||||
|
||||
style.imagemap = Style(style.image_placement, help='default style of imagemaps')
|
||||
style.hotspot = Style(style.default, help='default style of hotspots inside imagemaps')
|
||||
style.hotbar = Style(style.default, help='default style of hotbars inside imagemaps')
|
||||
style.imagemap_button = style.hotspot
|
||||
|
||||
style.image_button = Style(style.default, help='default style of image buttons')
|
||||
style.image_button_image = Style(style.default, help='default style of images inside image buttons')
|
||||
|
||||
style.hyperlink = Style(style.default, help=None) # ignored
|
||||
style.hyperlink_text = Style(style.default, help='hyperlinked text')
|
||||
style.ruby_text = Style(style.default, help='ruby text')
|
||||
|
||||
style.viewport = Style(style.default, help='default style of viewports')
|
||||
style.transform = Style(style.motion, help='default style of transforms')
|
||||
|
||||
style.list = Style(style.default)
|
||||
style.list_box = Style(style.vbox)
|
||||
style.list_row = Style(style.default)
|
||||
style.list_row_box = Style(style.hbox)
|
||||
style.list_spacer = Style(style.default)
|
||||
style.list_text = Style(style.default)
|
||||
|
||||
style.tile = Style(style.default, help='default style of tile')
|
||||
|
||||
# The base styles that can be customized by themes.
|
||||
|
||||
style.frame = Style(style.default, help='base style for frames.')
|
||||
style.menu_frame = Style(style.frame, help='base style for frames used in the game and main menus.')
|
||||
|
||||
style.button = Style(style.default, help='base style for buttons.')
|
||||
style.button_text = Style(style.default, help='base style for button text')
|
||||
|
||||
style.small_button = Style(style.button, help="base style for small buttons")
|
||||
style.small_button_text = Style(style.button_text, help="base style for small button text")
|
||||
style.radio_button = Style(style.button, help="base style for radio buttons")
|
||||
style.radio_button_text = Style(style.button_text, help="base style for radio button text")
|
||||
style.check_button = Style(style.button, help="base style for check buttons")
|
||||
style.check_button_text = Style(style.button_text, help="base style for check button text")
|
||||
|
||||
style.large_button = Style(style.default, help="base style for large buttons")
|
||||
style.large_button_text = Style(style.default, help="base style for large button text")
|
||||
|
||||
style.label = Style(style.default, help="base style for windows surrounding labels")
|
||||
style.label_text = Style(style.default, help="base style for label text")
|
||||
|
||||
style.prompt = Style(style.default, help="base style for windows surrounding prompts")
|
||||
style.prompt_text = Style(style.default, help="base style for prompt text")
|
||||
|
||||
style.bar = Style(style.default, help='base style for horizontal bars')
|
||||
style.vbar = Style(style.default, help='base style for vertical bars')
|
||||
|
||||
style.slider = Style(style.default, help='base style for horizontal sliders')
|
||||
style.vslider = Style(style.default, help='base style for vertical sliders')
|
||||
|
||||
style.scrollbar = Style(style.default, help='base style for horizontal scrollbars')
|
||||
style.vscrollbar = Style(style.default, help='base style for vertical scollbars')
|
||||
|
||||
style.mm_root = Style(style.default, help="main menu root window")
|
||||
style.gm_root = Style(style.default, help="game menu root window")
|
||||
|
||||
|
||||
init -1090 python:
|
||||
|
||||
# Colors #############################################################
|
||||
|
||||
# The Default Style ###################################################
|
||||
|
||||
# Text properties.
|
||||
style.default.font = "DejaVuSans.ttf"
|
||||
style.default.language = "unicode"
|
||||
style.default.antialias = True
|
||||
style.default.size = 22
|
||||
style.default.color = (255, 255, 255, 255)
|
||||
style.default.black_color = (0, 0, 0, 255)
|
||||
style.default.bold = False
|
||||
style.default.italic = False
|
||||
style.default.underline = False
|
||||
style.default.strikethrough = False
|
||||
style.default.kerning = 0.0
|
||||
style.default.drop_shadow = None
|
||||
style.default.drop_shadow_color = (0, 0, 0, 255)
|
||||
style.default.outlines = [ ]
|
||||
style.default.minwidth = 0
|
||||
style.default.text_align = 0
|
||||
style.default.justify = False
|
||||
style.default.text_y_fudge = 0
|
||||
style.default.first_indent = 0
|
||||
style.default.rest_indent = 0
|
||||
style.default.line_spacing = 0
|
||||
style.default.line_leading = 0
|
||||
style.default.line_overlap_split = 0
|
||||
style.default.layout = "tex"
|
||||
style.default.subtitle_width = 0.9
|
||||
style.default.slow_cps = None
|
||||
style.default.slow_cps_multiplier = 1.0
|
||||
style.default.slow_abortable = False
|
||||
# style.default.hyperlink_functions (set in 00library.rpy)
|
||||
|
||||
# Window properties.
|
||||
style.default.background = None
|
||||
style.default.xpadding = 0
|
||||
style.default.ypadding = 0
|
||||
style.default.xmargin = 0
|
||||
style.default.ymargin = 0
|
||||
style.default.xfill = False
|
||||
style.default.yfill = False
|
||||
style.default.xminimum = 0 # Includes margins and padding.
|
||||
style.default.yminimum = 0 # Includes margins and padding.
|
||||
|
||||
# Placement properties.
|
||||
style.default.xpos = None # 0
|
||||
style.default.ypos = None # 0
|
||||
style.default.xanchor = None # 0
|
||||
style.default.yanchor = None # 0
|
||||
style.default.xmaximum = None
|
||||
style.default.ymaximum = None
|
||||
style.default.xoffset = 0
|
||||
style.default.yoffset = 0
|
||||
style.default.subpixel = False
|
||||
|
||||
# Sound properties.
|
||||
style.default.sound = None
|
||||
|
||||
# Box properties.
|
||||
style.default.spacing = 0
|
||||
style.default.first_spacing = None
|
||||
style.default.box_layout = None
|
||||
style.default.box_wrap = False
|
||||
|
||||
# Focus properties.
|
||||
style.default.focus_mask = None
|
||||
style.default.focus_rect = None
|
||||
|
||||
# Bar properties.
|
||||
style.default.fore_bar = Null()
|
||||
style.default.aft_bar = Null()
|
||||
style.default.thumb = None
|
||||
style.default.thumb_shadow = None
|
||||
style.default.left_gutter = 0
|
||||
style.default.right_gutter = 0
|
||||
style.default.thumb_offset = 0
|
||||
style.default.unscrollable = None
|
||||
|
||||
# Misc.
|
||||
style.default.activate_sound = None
|
||||
style.default.clipping = False
|
||||
|
||||
# Boxes.
|
||||
style.hbox.box_layout = 'horizontal'
|
||||
style.vbox.box_layout = 'vertical'
|
||||
|
||||
# Motions, zooms, rotozooms, and transforms.
|
||||
style.motion.xanchor = 0
|
||||
style.motion.yanchor = 0
|
||||
style.motion.xpos = 0
|
||||
style.motion.ypos = 0
|
||||
|
||||
# Windows.
|
||||
style.window.background = Solid((0, 0, 0, 192))
|
||||
style.window.xpadding = 6
|
||||
style.window.ypadding = 6
|
||||
style.window.xmargin = 0
|
||||
style.window.ymargin = 0
|
||||
style.window.xfill = True
|
||||
style.window.yfill = False
|
||||
style.window.yminimum = 150 # Includes margins and padding.
|
||||
style.window.xalign = 0.5
|
||||
style.window.yalign = 1.0
|
||||
|
||||
# Dialogue
|
||||
style.say_label.bold = True
|
||||
style.say_vbox.spacing = 8
|
||||
|
||||
# Two window styles.
|
||||
style.say_who_window.xminimum = 200
|
||||
style.say_who_window.yminimum = 34
|
||||
style.say_who_window.xfill = False
|
||||
style.say_who_window.xalign = 0
|
||||
|
||||
style.say_two_window_vbox.yalign = 1.0
|
||||
|
||||
# Menus.
|
||||
style.menu_choice.idle_color = "#0ff"
|
||||
style.menu_choice.hover_color = "#ff0"
|
||||
style.input.color = "#ff0"
|
||||
|
||||
# Styles used by centered.
|
||||
style.centered_window.xalign = 0.5
|
||||
style.centered_window.xfill = False
|
||||
style.centered_window.yalign = 0.5
|
||||
style.centered_window.yfill = False
|
||||
style.centered_window.xpadding = 10
|
||||
|
||||
style.centered_text.textalign = 0.5
|
||||
style.centered_text.xalign = 0.5
|
||||
style.centered_text.yalign = 0.5
|
||||
style.centered_text.layout = "subtitle"
|
||||
|
||||
# Hyperlinks.
|
||||
style.hyperlink_text.underline = True
|
||||
style.hyperlink_text.hover_color = "#0ff"
|
||||
style.hyperlink_text.idle_color = "#08f"
|
||||
|
||||
# Ruby.
|
||||
style.ruby_text.size = 22
|
||||
style.ruby_text.xoffset = 0
|
||||
style.default.ruby_style = style.ruby_text
|
||||
|
||||
# Bars.
|
||||
style.default.bar_invert = False
|
||||
style.default.bar_resizing = False
|
||||
style.default.bar_vertical = False
|
||||
|
||||
style.vbar.bar_vertical = True
|
||||
style.vslider.bar_vertical = True
|
||||
style.vscrollbar.bar_vertical = True
|
||||
style.vscrollbar.bar_invert = True
|
||||
|
||||
# Viewport
|
||||
style.viewport.clipping = True
|
||||
|
||||
# Transform
|
||||
style.transform.subpixel = True
|
||||
|
||||
# Menu windows.
|
||||
style.mm_root.background = "#000"
|
||||
style.mm_root.xfill = True
|
||||
style.mm_root.yfill = True
|
||||
|
||||
style.gm_root.background = "#000"
|
||||
style.gm_root.xfill = True
|
||||
style.gm_root.yfill = True
|
||||
|
||||
# Lists.
|
||||
style.list_row.xfill = True
|
||||
|
||||
style.list_row.ymargin = 0
|
||||
style.list_row.background = "#eee"
|
||||
style.list_row[1].background = "#ddd"
|
||||
style.list_row.hover_background = "#fff"
|
||||
style.list_row[1].hover_background = "#fff"
|
||||
style.list_row.selected_background = "#cce"
|
||||
style.list_row[1].selected_background = "#cce"
|
||||
style.list_text.color = "#000"
|
||||
style.list_text.size = 14
|
||||
style.list_spacer.xminimum = 15
|
||||
|
||||
# Tile
|
||||
style.tile.clipping = True
|
||||
|
||||
|
||||
######################################################################
|
||||
|
||||
# Error messages.
|
||||
style.error_root.background = Solid((220, 220, 255, 255))
|
||||
style.error_root.xfill = True
|
||||
style.error_root.yfill = True
|
||||
style.error_root.xpadding = 20
|
||||
style.error_root.ypadding = 20
|
||||
|
||||
style.error_title.color = (255, 128, 128, 255)
|
||||
style.error_body.color = (128, 128, 255, 255)
|
||||
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# This file contains code for the style preferences system, which allows
|
||||
# the user to define preferences that update styles.
|
||||
|
||||
init -1135 python:
|
||||
|
||||
# A map from preference name to list of (alternative, style, property, value)
|
||||
# tuples.
|
||||
__preferences = { }
|
||||
|
||||
# A map from preference name to the list of alternatives for that preference.
|
||||
__alternatives = { }
|
||||
|
||||
# Are style preferences dirty? If so, we need to update them at the start of
|
||||
# the next operation.
|
||||
__spdirty = object()
|
||||
__spdirty.flag = True
|
||||
|
||||
# A map from preference name to alternative.
|
||||
if persistent._style_preferences is None:
|
||||
persistent._style_preferences = { }
|
||||
|
||||
|
||||
def __register_style_preference(preference, alternative, style, property, value):
|
||||
"""
|
||||
:doc: style_preferences
|
||||
:name: renpy.register_style_preference
|
||||
|
||||
Registers information about an alternative for a style preference.
|
||||
|
||||
`preference`
|
||||
A string, the name of the style property.
|
||||
|
||||
`alternative`
|
||||
A string, the name of the alternative.
|
||||
|
||||
`style`
|
||||
The style that will be updated. This may be a style object or a string giving the style name.
|
||||
|
||||
`property`
|
||||
A string giving the name of the style property that will be update.
|
||||
|
||||
`value`
|
||||
The value that will be assigned to the style property.
|
||||
"""
|
||||
|
||||
if preference not in __preferences:
|
||||
__preferences[preference] = [ ]
|
||||
__alternatives[preference] = [ ]
|
||||
|
||||
if alternative not in __alternatives:
|
||||
__alternatives[preference].append(alternative)
|
||||
|
||||
__preferences[preference].append((alternative, style, property, value))
|
||||
|
||||
def __init():
|
||||
"""
|
||||
Called at the end of the init phase, to ensure that each preference
|
||||
has a valid value.
|
||||
"""
|
||||
|
||||
for preference, alternatives in __alternatives.iteritems():
|
||||
alt = persistent._style_preferences.get(preference, None)
|
||||
|
||||
if alt not in alternatives:
|
||||
persistent._style_preferences[preference] = alternatives[0]
|
||||
|
||||
def __update():
|
||||
"""
|
||||
Called at least once per interaction, to update the styles if necessary.
|
||||
"""
|
||||
|
||||
if not __spdirty.flag:
|
||||
return
|
||||
|
||||
for preference, alternatives in __preferences.iteritems():
|
||||
|
||||
alt = persistent._style_preferences.get(preference, None)
|
||||
|
||||
for alternative, style, property, value in alternatives:
|
||||
if alternative == alt:
|
||||
setattr(style, property, value)
|
||||
|
||||
renpy.style.rebuild()
|
||||
|
||||
__spdirty.flag = False
|
||||
|
||||
def __check(preference, alternative=None):
|
||||
|
||||
if preference not in __alternatives:
|
||||
raise Exception("{0} is not a known style preference.".format(preference))
|
||||
|
||||
if alternative is not None:
|
||||
if alternative not in __alternatives[preference]:
|
||||
raise Exception("{0} is not a known alternative for style preference {1}.".format(alternative, preference))
|
||||
|
||||
|
||||
def __set_style_preference(preference, alternative):
|
||||
"""
|
||||
:doc: style_preferences
|
||||
:name: renpy.set_style_preference
|
||||
|
||||
Sets the selected alternative for the style preference.
|
||||
|
||||
`preference`
|
||||
A string giving the name of the style preference.
|
||||
|
||||
`alternative`
|
||||
A string giving the name of the alternative.
|
||||
"""
|
||||
|
||||
__check(preference, alternative)
|
||||
|
||||
persistent._style_preferences[preference] = alternative
|
||||
__spdirty.flag = True
|
||||
|
||||
renpy.restart_interaction()
|
||||
|
||||
def __get_style_preference(preference):
|
||||
"""
|
||||
:doc: style_preferences
|
||||
:name: renpy.get_style_preference
|
||||
|
||||
Returns a string giving the name of the selected alternative for the named style preference.
|
||||
|
||||
`preference`
|
||||
A string giving the name of the style preference.
|
||||
"""
|
||||
|
||||
__check(preference)
|
||||
|
||||
return persistent._style_preferences[preference]
|
||||
|
||||
class StylePreference(Action):
|
||||
"""
|
||||
:doc: style_preferences
|
||||
|
||||
An action that causes `alternative` to become the selected alternative for the given style preference.
|
||||
|
||||
`preference`
|
||||
A string giving the name of the style preference.
|
||||
|
||||
`alternative`
|
||||
A string giving the name of the alternative.
|
||||
"""
|
||||
|
||||
def __init__(self, preference, alternative):
|
||||
|
||||
__check(preference, alternative)
|
||||
|
||||
self.preference = preference
|
||||
self.alternative = alternative
|
||||
|
||||
def __call__(self):
|
||||
__set_style_preference(self.preference, self.alternative)
|
||||
|
||||
def get_selected(self):
|
||||
return __get_style_preference(self.preference) == self.alternative
|
||||
|
||||
renpy.register_style_preference = __register_style_preference
|
||||
renpy.set_style_preference = __set_style_preference
|
||||
renpy.get_style_preference = __get_style_preference
|
||||
|
||||
config.interact_callbacks.append(__update)
|
||||
|
||||
init 1135 python:
|
||||
|
||||
__init()
|
||||
@@ -1,131 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# This extra contains a basic implementation of voice support. Right
|
||||
# now, voice is given its own toggle, and can either be turned on or
|
||||
# turned off. In the future, we'll probably provide some way of
|
||||
# toggling it on or off for individual characters.
|
||||
#
|
||||
# To use it, place a voice "<sndfile>" line before each voiced line of
|
||||
# dialogue.
|
||||
#
|
||||
# voice "e_1001.ogg"
|
||||
# e "Voice support lets you add the spoken word to your games."
|
||||
#
|
||||
# Normally, a voice is cancelled at the start of the next
|
||||
# interaction. If you want a voice to span interactions, call
|
||||
# voice_sustain.
|
||||
#
|
||||
# voice "e_1002.ogg"
|
||||
# e "Voice sustain is a technique that allows the same voice file.."
|
||||
#
|
||||
# $ voice_sustain()
|
||||
# e "...to play for two lines of dialogue."
|
||||
|
||||
init -1120:
|
||||
|
||||
python:
|
||||
|
||||
_voice = object()
|
||||
_voice.play = None
|
||||
_voice.sustain = False
|
||||
_voice.seen_in_lint = False
|
||||
|
||||
# Call this to specify the voice file that will be played for
|
||||
# the user.
|
||||
def voice(file, **kwargs):
|
||||
|
||||
if not config.has_voice:
|
||||
return
|
||||
|
||||
_voice.play = file
|
||||
_last_voice_play = file
|
||||
|
||||
# Call this to specify that the currently playing voice file
|
||||
# should be sustained through the current interaction.
|
||||
def voice_sustain(ignored="", **kwargs):
|
||||
if not config.has_voice:
|
||||
return
|
||||
|
||||
_voice.sustain = True
|
||||
|
||||
# Call this to replay the last bit of voice.
|
||||
def voice_replay():
|
||||
renpy.sound.play(_last_voice_play, channel="voice")
|
||||
|
||||
# Returns true if we can replay the voice.
|
||||
def voice_can_replay():
|
||||
return _last_voice_play != None
|
||||
|
||||
python hide:
|
||||
|
||||
# basics: True if the game will have voice.
|
||||
config.has_voice = True
|
||||
|
||||
# This is called on each interaction, to ensure that the
|
||||
# appropriate voice file is played for the user.
|
||||
def voice_interact():
|
||||
|
||||
if not config.has_voice:
|
||||
return
|
||||
|
||||
if _voice.play and not config.skipping:
|
||||
renpy.sound.play(_voice.play, channel="voice")
|
||||
store._last_voice_play = _voice.play
|
||||
elif not _voice.sustain:
|
||||
renpy.sound.stop(channel="voice")
|
||||
store._last_voice_play = _voice.play
|
||||
|
||||
_voice.play = None
|
||||
_voice.sustain = False
|
||||
|
||||
config.start_interact_callbacks.append(voice_interact)
|
||||
config.say_sustain_callbacks.append(voice_sustain)
|
||||
|
||||
def voice_afm_callback():
|
||||
return not renpy.sound.is_playing(channel="voice")
|
||||
|
||||
config.afm_callback = voice_afm_callback
|
||||
|
||||
python early hide:
|
||||
|
||||
def parse_voice(l):
|
||||
fn = l.simple_expression()
|
||||
if fn is None:
|
||||
renpy.error('expected simple expression (string)')
|
||||
|
||||
if not l.eol():
|
||||
renpy.error('expected end of line')
|
||||
|
||||
return fn
|
||||
|
||||
def execute_voice(fn):
|
||||
fn = eval(fn)
|
||||
voice(fn)
|
||||
|
||||
def lint_voice(fn):
|
||||
_voice.seen_in_lint = True
|
||||
|
||||
fn = _try_eval(fn, 'voice filename')
|
||||
if isinstance(fn, basestring) and not renpy.loadable(fn):
|
||||
renpy.error('voice file %r is not loadable' % fn)
|
||||
|
||||
renpy.statements.register('voice',
|
||||
parse=parse_voice,
|
||||
execute=execute_voice,
|
||||
lint=lint_voice)
|
||||
|
||||
def parse_voice_sustain(l):
|
||||
if not l.eol():
|
||||
renpy.error('expected end of line')
|
||||
|
||||
return None
|
||||
|
||||
def execute_voice_sustain(parsed):
|
||||
voice_sustain()
|
||||
|
||||
renpy.statements.register('voice sustain',
|
||||
parse=parse_voice_sustain,
|
||||
execute=execute_voice_sustain)
|
||||
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
Fonts are (c) Bitstream (see below). DejaVu changes are in public domain.
|
||||
Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below)
|
||||
|
||||
Bitstream Vera Fonts Copyright
|
||||
------------------------------
|
||||
|
||||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is
|
||||
a trademark of Bitstream, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of the fonts accompanying this license ("Fonts") and associated
|
||||
documentation files (the "Font Software"), to reproduce and distribute the
|
||||
Font Software, including without limitation the rights to use, copy, merge,
|
||||
publish, distribute, and/or sell copies of the Font Software, and to permit
|
||||
persons to whom the Font Software is furnished to do so, subject to the
|
||||
following conditions:
|
||||
|
||||
The above copyright and trademark notices and this permission notice shall
|
||||
be included in all copies of one or more of the Font Software typefaces.
|
||||
|
||||
The Font Software may be modified, altered, or added to, and in particular
|
||||
the designs of glyphs or characters in the Fonts may be modified and
|
||||
additional glyphs or characters may be added to the Fonts, only if the fonts
|
||||
are renamed to names not containing either the words "Bitstream" or the word
|
||||
"Vera".
|
||||
|
||||
This License becomes null and void to the extent applicable to Fonts or Font
|
||||
Software that has been modified and is distributed under the "Bitstream
|
||||
Vera" names.
|
||||
|
||||
The Font Software may be sold as part of a larger software package but no
|
||||
copy of one or more of the Font Software typefaces may be sold by itself.
|
||||
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
|
||||
TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
|
||||
FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
|
||||
ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
|
||||
FONT SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the names of Gnome, the Gnome
|
||||
Foundation, and Bitstream Inc., shall not be used in advertising or
|
||||
otherwise to promote the sale, use or other dealings in this Font Software
|
||||
without prior written authorization from the Gnome Foundation or Bitstream
|
||||
Inc., respectively. For further information, contact: fonts at gnome dot
|
||||
org.
|
||||
|
||||
Arev Fonts Copyright
|
||||
------------------------------
|
||||
|
||||
Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the fonts accompanying this license ("Fonts") and
|
||||
associated documentation files (the "Font Software"), to reproduce
|
||||
and distribute the modifications to the Bitstream Vera Font Software,
|
||||
including without limitation the rights to use, copy, merge, publish,
|
||||
distribute, and/or sell copies of the Font Software, and to permit
|
||||
persons to whom the Font Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright and trademark notices and this permission notice
|
||||
shall be included in all copies of one or more of the Font Software
|
||||
typefaces.
|
||||
|
||||
The Font Software may be modified, altered, or added to, and in
|
||||
particular the designs of glyphs or characters in the Fonts may be
|
||||
modified and additional glyphs or characters may be added to the
|
||||
Fonts, only if the fonts are renamed to names not containing either
|
||||
the words "Tavmjong Bah" or the word "Arev".
|
||||
|
||||
This License becomes null and void to the extent applicable to Fonts
|
||||
or Font Software that has been modified and is distributed under the
|
||||
"Tavmjong Bah Arev" names.
|
||||
|
||||
The Font Software may be sold as part of a larger software package but
|
||||
no copy of one or more of the Font Software typefaces may be sold by
|
||||
itself.
|
||||
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
|
||||
TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the name of Tavmjong Bah shall not
|
||||
be used in advertising or otherwise to promote the sale, use or other
|
||||
dealings in this Font Software without prior written authorization
|
||||
from Tavmjong Bah. For further information, contact: tavmjong @ free
|
||||
. fr.
|
||||
|
||||
$Id: LICENSE 2133 2007-11-28 02:46:28Z lechimp $
|
||||
@@ -0,0 +1,55 @@
|
||||
This package was debianized by Michael Fedrowitz <michaelf@debian.org>
|
||||
on Sun, 23 Feb 2003.
|
||||
|
||||
It was downloaded from
|
||||
'http://ftp.gnome.org/pub/GNOME/sources/ttf-bitstream-vera/'.
|
||||
|
||||
Upstream Author: Bitstream, Inc.
|
||||
|
||||
Copyright:
|
||||
|
||||
Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream
|
||||
Vera is a trademark of Bitstream, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the fonts accompanying this license ("Fonts") and associated
|
||||
documentation files (the "Font Software"), to reproduce and distribute
|
||||
the Font Software, including without limitation the rights to use,
|
||||
copy, merge, publish, distribute, and/or sell copies of the Font
|
||||
Software, and to permit persons to whom the Font Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright and trademark notices and this permission notice
|
||||
shall be included in all copies of one or more of the Font Software
|
||||
typefaces.
|
||||
|
||||
The Font Software may be modified, altered, or added to, and in
|
||||
particular the designs of glyphs or characters in the Fonts may be
|
||||
modified and additional glyphs or characters may be added to the
|
||||
Fonts, only if the fonts are renamed to names not containing either
|
||||
the words "Bitstream" or the word "Vera".
|
||||
|
||||
This License becomes null and void to the extent applicable to Fonts
|
||||
or Font Software that has been modified and is distributed under the
|
||||
"Bitstream Vera" names.
|
||||
|
||||
The Font Software may be sold as part of a larger software package but
|
||||
no copy of one or more of the Font Software typefaces may be sold by
|
||||
itself.
|
||||
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL
|
||||
BITSTREAM OR THE GNOME FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL,
|
||||
OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT
|
||||
SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
|
||||
Except as contained in this notice, the names of Gnome, the Gnome
|
||||
Foundation, and Bitstream Inc., shall not be used in advertising or
|
||||
otherwise to promote the sale, use or other dealings in this Font
|
||||
Software without prior written authorization from the Gnome Foundation
|
||||
or Bitstream Inc., respectively. For further information, contact:
|
||||
fonts at gnome dot org.
|
||||
@@ -1,504 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
######################################################################
|
||||
# First up, we define a bunch of configuration variable, which the
|
||||
# user can change.
|
||||
|
||||
# The contents of the game menu choices.
|
||||
config.game_menu = [
|
||||
( "return", u"Return", ui.jumps("_return"), 'True'),
|
||||
( "skipping", u"Begin Skipping", ui.jumps("_return_skipping"), 'config.allow_skipping and not renpy.context()._main_menu'),
|
||||
( "prefs", u"Preferences", _intra_jumps("_prefs_screen", "intra_transition"), 'True' ),
|
||||
( "save", u"Save Game", _intra_jumps("_save_screen", "intra_transition"), 'not renpy.context()._main_menu' ),
|
||||
( "load", u"Load Game", _intra_jumps("_load_screen", "intra_transition"), 'True'),
|
||||
( "mainmenu", u"Main Menu", lambda : _mainmenu_prompt(), 'not renpy.context()._main_menu' ),
|
||||
( "quit", u"Quit", lambda : _quit_prompt("quit"), 'True' ),
|
||||
]
|
||||
|
||||
# If not None, a map from the names of the game menu
|
||||
# navigation buttons to new fixed positions for them on
|
||||
# the screen.
|
||||
config.game_menu_positions = None
|
||||
|
||||
# The number of columns of files to show at once.
|
||||
config.file_page_cols = 2
|
||||
|
||||
# The number of rows of files to show at once.
|
||||
config.file_page_rows = 5
|
||||
|
||||
# The number of pages to add quick access buttons for.
|
||||
config.file_quick_access_pages = 5
|
||||
|
||||
# The positions of file picker components.
|
||||
config.file_picker_positions = None
|
||||
|
||||
|
||||
# This lets us disable the file pager. (So we only have one
|
||||
# page of files.)
|
||||
config.disable_file_pager = False
|
||||
|
||||
# This lets us disable the thumbnails in the file pager.
|
||||
config.disable_thumbnails = False
|
||||
|
||||
# How we format time.
|
||||
config.time_format = "%b %d, %H:%M"
|
||||
|
||||
# How we format loade_save slot formats.
|
||||
config.file_entry_format = "%(time)s\n%(save_name)s"
|
||||
|
||||
# If True, we will be prompted before loading a game. (This can
|
||||
# be changed from inside the game code, so that one can load from
|
||||
# the first few screens but not after that.)
|
||||
_load_prompt = True
|
||||
|
||||
|
||||
_game_menu_screen = "_save_screen"
|
||||
|
||||
######################################################################
|
||||
# Next, support code.
|
||||
|
||||
# This is used to store scratch data that's used by the
|
||||
# library, but shouldn't be saved out as part of the savegame.
|
||||
_scratch = object()
|
||||
|
||||
# This returns a window containing the game menu navigation
|
||||
# buttons, set up to jump to the appropriate screen sections.
|
||||
#
|
||||
# This can be overridden by user code. It's called with the
|
||||
# name of the selected screen... one of "mainmenu", "prefs",
|
||||
# "save", "load", or "quit", at least for the default game
|
||||
# menu. If None, then it's an indication that none of the
|
||||
# nav buttons should be shown.
|
||||
def _game_nav(screen, buttons=True):
|
||||
|
||||
global _screen
|
||||
_screen = screen
|
||||
|
||||
ui.add(renpy.Keymap(toggle_fullscreen = renpy.toggle_fullscreen))
|
||||
ui.add(renpy.Keymap(game_menu=ui.jumps("_noisy_return")))
|
||||
|
||||
ui.window(style=style.gm_root[screen])
|
||||
ui.null()
|
||||
|
||||
if not screen:
|
||||
return
|
||||
|
||||
if not config.game_menu_positions:
|
||||
ui.window(style='gm_nav_frame')
|
||||
ui.vbox(focus='gm_nav', style='gm_nav_vbox')
|
||||
|
||||
for i, (key, label, clicked, enabled) in enumerate(config.game_menu):
|
||||
|
||||
disabled = False
|
||||
|
||||
if not eval(enabled):
|
||||
disabled = True
|
||||
clicked = None
|
||||
|
||||
if config.game_menu_positions:
|
||||
kwargs = config.game_menu_positions.get(label, { })
|
||||
else:
|
||||
kwargs = { }
|
||||
|
||||
_button_factory(label, "gm_nav",
|
||||
selected=(key==screen),
|
||||
disabled=disabled,
|
||||
clicked=clicked,
|
||||
properties=kwargs)
|
||||
|
||||
if not config.game_menu_positions:
|
||||
ui.close()
|
||||
|
||||
# This is called from the game menu to interact with the
|
||||
# user. It suppresses all of the underlays and overlays.
|
||||
def _game_interact():
|
||||
|
||||
return ui.interact(suppress_underlay=True,
|
||||
suppress_overlay=True,
|
||||
mouse="gamemenu")
|
||||
|
||||
|
||||
# This renders a slot with a file in it, in the file picker.
|
||||
def _render_savefile(index, name, filename, extra_info, screenshot, mtime, newest, clickable, **positions):
|
||||
|
||||
if clickable:
|
||||
clicked = ui.returns(("return", (filename, True)))
|
||||
else:
|
||||
clicked = None
|
||||
|
||||
ui.button(style=style.file_picker_entry[index],
|
||||
clicked=clicked,
|
||||
**positions)
|
||||
|
||||
ui.hbox(style=style.file_picker_entry_box[index])
|
||||
|
||||
if not config.disable_thumbnails:
|
||||
ui.add(screenshot)
|
||||
|
||||
if newest:
|
||||
ui.text(name + ". ", style=style.file_picker_new[index])
|
||||
else:
|
||||
ui.text(name + ". ", style=style.file_picker_old[index])
|
||||
|
||||
|
||||
s = config.file_entry_format % dict(
|
||||
time=renpy.time.strftime(config.time_format,
|
||||
renpy.time.localtime(mtime)),
|
||||
save_name=extra_info)
|
||||
|
||||
ui.text(s, style=style.file_picker_extra_info[index])
|
||||
|
||||
ui.close()
|
||||
|
||||
# This renders an empty slot in the file picker.
|
||||
def _render_new_slot(index, name, filename, clickable, **positions):
|
||||
|
||||
if clickable:
|
||||
clicked=ui.returns(("return", (filename, False)))
|
||||
enable_hover = True
|
||||
else:
|
||||
clicked = None
|
||||
enable_hover = True
|
||||
|
||||
ui.button(style=style.file_picker_entry[index],
|
||||
clicked=clicked,
|
||||
enable_hover=enable_hover,
|
||||
**positions)
|
||||
|
||||
ui.hbox(style=style.file_picker_entry_box[index])
|
||||
|
||||
if not config.disable_thumbnails:
|
||||
ui.null(width=config.thumbnail_width,
|
||||
height=config.thumbnail_height)
|
||||
|
||||
|
||||
ui.text(name + ". ", style=style.file_picker_old[index])
|
||||
|
||||
ui.text(_(u"Empty Slot."), style=style.file_picker_empty_slot[index])
|
||||
ui.close()
|
||||
|
||||
_scratch.file_picker_page = None
|
||||
|
||||
# The names of the various pages that the file picker knows
|
||||
# about.
|
||||
def _file_picker_pages():
|
||||
|
||||
rv = [ ]
|
||||
|
||||
if config.has_autosave:
|
||||
rv.append("Auto")
|
||||
|
||||
if config.has_quicksave:
|
||||
rv.append("Quick")
|
||||
|
||||
for i in range(1, config.file_quick_access_pages + 1):
|
||||
rv.append(str(i))
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
# This function is given a page, and should map it to the names
|
||||
# of the files on that page.
|
||||
def _file_picker_page_files(page):
|
||||
|
||||
per_page = config.file_page_cols * config.file_page_rows
|
||||
rv = [ ]
|
||||
|
||||
if config.has_autosave:
|
||||
if page == 0:
|
||||
for i in range(1, per_page + 1):
|
||||
rv.append(("auto-" + str(i), "a" + str(i), True))
|
||||
|
||||
return rv
|
||||
else:
|
||||
page -= 1
|
||||
|
||||
if config.has_quicksave:
|
||||
if page == 0:
|
||||
for i in range(1, per_page + 1):
|
||||
rv.append(("quick-" + str(i), "q" + str(i), True))
|
||||
|
||||
return rv
|
||||
else:
|
||||
page -= 1
|
||||
|
||||
for i in range(per_page * page + 1, per_page * page + 1 + per_page):
|
||||
rv.append(("%d" % i, "%d" % i, False))
|
||||
|
||||
return rv
|
||||
|
||||
# Given a filename, returns the page that filename is on.
|
||||
def _file_picker_file_page(filename):
|
||||
|
||||
per_page = config.file_page_cols * config.file_page_rows
|
||||
|
||||
base = 0
|
||||
|
||||
if config.has_autosave:
|
||||
if filename.startswith("auto-"):
|
||||
return base
|
||||
else:
|
||||
base += 1
|
||||
|
||||
if config.has_quicksave:
|
||||
if filename.startswith("quick-"):
|
||||
return base
|
||||
else:
|
||||
base += 1
|
||||
|
||||
return base + int((int(filename) - 1) / per_page)
|
||||
|
||||
|
||||
def _file_picker_process_screenshot(s):
|
||||
return s
|
||||
|
||||
# This displays a file picker that can chose a save file from
|
||||
# the list of save files.
|
||||
def _file_picker(selected, save):
|
||||
|
||||
# The number of slots in a page.
|
||||
file_page_length = config.file_page_cols * config.file_page_rows
|
||||
|
||||
saved_games = renpy.list_saved_games(regexp=r'(auto-|quick-)?[0-9]+')
|
||||
|
||||
newest = None
|
||||
newest_mtime = None
|
||||
save_info = { }
|
||||
|
||||
for fn, extra_info, screenshot, mtime in saved_games:
|
||||
screenshot = _file_picker_process_screenshot(screenshot)
|
||||
save_info[fn] = (extra_info, screenshot, mtime)
|
||||
|
||||
if not fn.startswith("auto-") and mtime > newest_mtime:
|
||||
newest = fn
|
||||
newest_mtime = mtime
|
||||
|
||||
if config.file_picker_positions:
|
||||
positions = config.file_picker_positions
|
||||
else:
|
||||
positions = { }
|
||||
|
||||
# The index of the first entry in the page.
|
||||
fpp = _scratch.file_picker_page
|
||||
|
||||
if fpp is None:
|
||||
|
||||
if newest:
|
||||
fpp = _file_picker_file_page(newest)
|
||||
else:
|
||||
fpp = _file_picker_file_page("1")
|
||||
|
||||
|
||||
while True:
|
||||
|
||||
if fpp < 0:
|
||||
fpp = 0
|
||||
|
||||
_scratch.file_picker_page = fpp
|
||||
|
||||
# Show navigation
|
||||
_game_nav(selected)
|
||||
|
||||
if not config.file_picker_positions:
|
||||
|
||||
ui.window(style='file_picker_frame')
|
||||
ui.vbox(style='file_picker_frame_vbox') # whole thing.
|
||||
|
||||
if not config.disable_file_pager:
|
||||
|
||||
### file_picker_navbox thick_hbox
|
||||
# (box) The box containing the naviation (next/previous)
|
||||
# buttons in the file picker.
|
||||
|
||||
### file_picker_nav_button menu_button
|
||||
# (window, hover) The style that is used for enabled file
|
||||
# picker navigation buttons.
|
||||
|
||||
### file_picker_nav_button_text menu_button_text
|
||||
# (text) The style that is used for the label of enabled
|
||||
# file picker navigation buttons.
|
||||
|
||||
# Draw the navigation.
|
||||
if not config.file_picker_positions:
|
||||
ui.hbox(style='file_picker_navbox') # nav buttons.
|
||||
|
||||
def tb(cond, label, clicked, selected):
|
||||
_button_factory(label,
|
||||
"file_picker_nav",
|
||||
disabled=not cond,
|
||||
clicked=clicked,
|
||||
selected=selected,
|
||||
properties=positions.get("nav_" + label, { }))
|
||||
|
||||
# Previous
|
||||
tb(fpp > 0, _(u'Previous'), ui.returns(("fppdelta", -1)), selected=False)
|
||||
|
||||
# Quick Access
|
||||
for i, name in enumerate(_file_picker_pages()):
|
||||
tb(True, name, ui.returns(("fppset", i)), fpp == i)
|
||||
|
||||
# Next
|
||||
tb(True, _(u'Next'), ui.returns(("fppdelta", +1)), False)
|
||||
|
||||
# Done with nav buttons.
|
||||
if not config.file_picker_positions:
|
||||
ui.close()
|
||||
|
||||
# This draws a single slot.
|
||||
def entry(name, filename, offset, ro):
|
||||
place = positions.get("entry_" + str(offset + 1), { })
|
||||
|
||||
if filename not in save_info:
|
||||
clickable = save and not ro
|
||||
|
||||
_render_new_slot(offset, name, filename, clickable, **place)
|
||||
else:
|
||||
clickable = not save or not ro
|
||||
|
||||
extra_info, screenshot, mtime = save_info[filename]
|
||||
_render_savefile(offset, name, filename, extra_info, screenshot,
|
||||
mtime, newest == filename, clickable, **place)
|
||||
|
||||
if not config.file_picker_positions:
|
||||
ui.grid(config.file_page_cols,
|
||||
config.file_page_rows,
|
||||
style='file_picker_grid',
|
||||
transpose=True) # slots
|
||||
|
||||
for i, (filename, name, ro) in enumerate(_file_picker_page_files(fpp)):
|
||||
entry(name, filename, i, ro)
|
||||
|
||||
if not config.file_picker_positions:
|
||||
ui.close() # slots
|
||||
ui.close() # whole thing
|
||||
|
||||
result = _game_interact()
|
||||
type, value = result
|
||||
|
||||
if type == "return":
|
||||
return value
|
||||
|
||||
if type == "fppdelta":
|
||||
fpp += value
|
||||
|
||||
if type == "fppset":
|
||||
fpp = value
|
||||
|
||||
|
||||
# This renders a yes/no prompt, as part of the game menu. If
|
||||
# screen is None, then it omits the game menu navigation.
|
||||
def _yesno_prompt(screen, message):
|
||||
"""
|
||||
@param screen: The screen button that should be highlighted when this prompt is shown. If None, then no game menu navigation is shown.
|
||||
|
||||
@param message: The message that is shown to the user to prompt them to answer yes or no.
|
||||
|
||||
This function returns True if the user clicks Yes, or False if the user clicks No.
|
||||
"""
|
||||
|
||||
renpy.transition(config.intra_transition)
|
||||
|
||||
_game_nav(screen)
|
||||
|
||||
ui.window(style='yesno_frame')
|
||||
ui.vbox(style='yesno_frame_vbox')
|
||||
|
||||
_label_factory(message, "yesno")
|
||||
|
||||
ui.hbox(style='yesno_button_hbox')
|
||||
|
||||
# The extra nulls are because we want equal whitespace surrounding
|
||||
# the two buttons. It should work as long as we have xfill=True
|
||||
_button_factory(u"Yes", 'yesno', clicked=ui.returns(True))
|
||||
_button_factory(u"No", 'yesno', clicked=ui.returns(False))
|
||||
|
||||
ui.close()
|
||||
ui.close()
|
||||
|
||||
rv = _game_interact()
|
||||
renpy.transition(config.intra_transition)
|
||||
return rv
|
||||
|
||||
config.old_names["Are you sure you want to quit?"] = "Are you sure you want to quit the game?"
|
||||
|
||||
def _quit_prompt(screen="quit"):
|
||||
|
||||
def prompt():
|
||||
return _yesno_prompt(screen, u"Are you sure you want to quit?")
|
||||
|
||||
if renpy.invoke_in_new_context(prompt):
|
||||
renpy.quit()
|
||||
else:
|
||||
return
|
||||
|
||||
config.old_names["Are you sure you want to return to the main menu?\nThis will lose unsaved progress."] = "Are you sure you want to return to the main menu?\nThis will end your game."
|
||||
|
||||
def _mainmenu_prompt(screen="mainmenu"):
|
||||
|
||||
def prompt():
|
||||
return _yesno_prompt(screen, u"Are you sure you want to return to the main menu?\nThis will lose unsaved progress.")
|
||||
|
||||
if renpy.invoke_in_new_context(prompt):
|
||||
renpy.full_restart(transition=config.game_main_transition)
|
||||
else:
|
||||
return
|
||||
|
||||
label _compat_confirm_quit:
|
||||
$ _quit_prompt(None)
|
||||
return
|
||||
|
||||
|
||||
init -1160:
|
||||
$ config.old_names["Loading will lose unsaved progress.\nAre you sure you want to do this?"] = "Loading a new game will end your current game.\nAre you sure you want to do this?"
|
||||
|
||||
label _load_screen:
|
||||
|
||||
if renpy.has_label("_load_screen_hook"):
|
||||
call expression "_load_screen_hook" from _call__load_screen_hook
|
||||
|
||||
python hide:
|
||||
|
||||
fn, exists = _file_picker("load", False )
|
||||
|
||||
if not renpy.context()._main_menu and _load_prompt:
|
||||
if _yesno_prompt("load", u"Loading will lose unsaved progress.\nAre you sure you want to do this?"):
|
||||
renpy.load(fn)
|
||||
else:
|
||||
renpy.load(fn)
|
||||
|
||||
jump _load_screen
|
||||
|
||||
label _save_screen:
|
||||
|
||||
if renpy.has_label("_save_screen_hook"):
|
||||
call expression "_save_screen_hook" from _call__save_screen_hook
|
||||
|
||||
$ _fn, _exists = _file_picker("save", True)
|
||||
|
||||
if not _exists or _yesno_prompt("save", u"Are you sure you want to overwrite your save?"):
|
||||
python hide:
|
||||
|
||||
if save_name:
|
||||
full_save_name = save_name
|
||||
else:
|
||||
full_save_name = ""
|
||||
|
||||
try:
|
||||
renpy.save(_fn, full_save_name)
|
||||
|
||||
except Exception, e:
|
||||
|
||||
if config.debug:
|
||||
raise
|
||||
|
||||
message = ( _(u"The error message was:") + "\n\n" +
|
||||
e.__class__.__name__ + ": " + unicode(e) + "\n\n" +
|
||||
_(u"You may want to try saving in a different slot, or playing for a while and trying again later.") )
|
||||
|
||||
_show_exception(_(u"Save Failed."), message)
|
||||
|
||||
|
||||
jump _save_screen
|
||||
@@ -1,112 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init:
|
||||
python:
|
||||
|
||||
# A dict of 5-tuples mapping button labels to image buttons.
|
||||
config.image_buttons = { }
|
||||
|
||||
# A dict mapping label to image.
|
||||
config.image_labels = { }
|
||||
|
||||
# Maps from button or label to additional properties.
|
||||
config.button_properties = { }
|
||||
config.button_text_properties = { }
|
||||
config.label_properties = { }
|
||||
|
||||
def _button_factory(label,
|
||||
type=None,
|
||||
selected=None,
|
||||
disabled=False,
|
||||
clicked=None,
|
||||
properties={},
|
||||
index=None,
|
||||
**props):
|
||||
"""
|
||||
This function is called to create the various buttons used
|
||||
in the game menu. By overriding this function, one can
|
||||
(for example) replace the default textbuttons with image buttons.
|
||||
When it is called, it's expected to add a button to the screen.
|
||||
|
||||
@param label: The label of this button, before translation.
|
||||
|
||||
@param type: The type of the button. One of "mm" (main menu),
|
||||
"gm_nav" (game menu), "file_picker_nav", "yesno", or "prefs".
|
||||
|
||||
@param selected: True if the button is selected, False if not,
|
||||
or None if it doesn't matter.
|
||||
|
||||
@param disabled: True if the button is disabled, False if not.
|
||||
|
||||
@param clicked: A function that should be executed when the
|
||||
button is clicked.
|
||||
|
||||
@param properties: Addtional layout properties.
|
||||
"""
|
||||
|
||||
props.update(properties)
|
||||
props.update(config.button_properties.get(label, { }))
|
||||
|
||||
if disabled:
|
||||
clicked = None
|
||||
|
||||
if selected and not disabled:
|
||||
role = "selected_"
|
||||
else:
|
||||
role = ""
|
||||
|
||||
|
||||
if label in config.image_buttons:
|
||||
|
||||
(idle, hover, sel_idle, sel_hover, disabled) = config.image_buttons[label]
|
||||
|
||||
ui.imagebutton(idle,
|
||||
hover,
|
||||
disabled,
|
||||
hover,
|
||||
sel_idle,
|
||||
sel_hover,
|
||||
disabled,
|
||||
sel_hover,
|
||||
clicked=clicked,
|
||||
style=style.image_button[label],
|
||||
role=role,
|
||||
**props)
|
||||
|
||||
return
|
||||
|
||||
button_style = type + "_button"
|
||||
text_style = type + "_button_text"
|
||||
|
||||
if index is None:
|
||||
index = label
|
||||
|
||||
button_style = getattr(style, button_style)[index]
|
||||
text_style = getattr(style, text_style)[index]
|
||||
|
||||
ui.button(style=button_style, clicked=clicked, role=role, **props)
|
||||
ui.text(_(label), style=text_style, **config.button_text_properties.get(label, { }))
|
||||
|
||||
def _label_factory(label, type, properties={}, **props):
|
||||
"""
|
||||
This function is called to create a new label. It can be
|
||||
overridden by the user to change how these labels are created.
|
||||
|
||||
@param label: The label of the box.
|
||||
|
||||
@param type: "prefs" or "yesno". (perhaps more by now.)
|
||||
|
||||
@param properties: This may contain position properties.
|
||||
"""
|
||||
|
||||
props.update(properties)
|
||||
props.update(config.label_properties.get(label, { }))
|
||||
|
||||
if label in config.image_labels:
|
||||
ui.image(config.image_labels[label], **props)
|
||||
return
|
||||
|
||||
style = getattr(store.style, type + "_label")[label]
|
||||
|
||||
ui.text(_(label), style=style, **props)
|
||||
@@ -1,62 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init -1170 python hide:
|
||||
|
||||
config.old_names['Quit'] = 'Quit Game'
|
||||
|
||||
# The contents of the main menu.
|
||||
config.main_menu = [
|
||||
( u"Start Game", "start", 'True'),
|
||||
( u"Continue Game", _intra_jumps("_load_screen", "main_game_transition"), 'True' ),
|
||||
( u"Preferences", _intra_jumps("_prefs_screen", "main_game_transition"), 'True' ),
|
||||
( u"Quit", ui.jumps("_quit"), 'True' ),
|
||||
]
|
||||
|
||||
# If not None, this is used to fix the positions of the
|
||||
# things in the main menu.
|
||||
config.main_menu_positions = None
|
||||
|
||||
# Styles used in this file.
|
||||
|
||||
# This is the default main menu, which we get if the user hasn't
|
||||
# defined his own, or if that function calls this explicitly.
|
||||
label _library_main_menu:
|
||||
|
||||
python hide:
|
||||
|
||||
ui.add(renpy.Keymap(toggle_fullscreen = renpy.toggle_fullscreen))
|
||||
|
||||
ui.window(style='mm_root')
|
||||
ui.null()
|
||||
|
||||
if not config.main_menu_positions:
|
||||
ui.window(style='mm_menu_frame')
|
||||
ui.vbox(style='mm_menu_frame_vbox')
|
||||
|
||||
for i, (text, clicked, enabled) in enumerate(config.main_menu):
|
||||
|
||||
if isinstance(clicked, basestring):
|
||||
clicked = ui.jumpsoutofcontext(clicked)
|
||||
|
||||
if config.main_menu_positions:
|
||||
kwargs = config.main_menu_positions.get(text, { })
|
||||
else:
|
||||
kwargs = { }
|
||||
|
||||
if not eval(enabled):
|
||||
clicked = None
|
||||
disabled = True
|
||||
else:
|
||||
disabled = False
|
||||
|
||||
_button_factory(text, "mm", clicked=clicked, disabled=disabled, properties=kwargs)
|
||||
|
||||
if not config.main_menu_positions:
|
||||
ui.close()
|
||||
|
||||
store._result = ui.interact(suppress_overlay=True,
|
||||
suppress_underlay=True,
|
||||
mouse="mainmenu")
|
||||
|
||||
jump _main_menu
|
||||
@@ -1,607 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# Copyright 2004-2012 Tom Rothamel
|
||||
#
|
||||
# Please see the LICENSE.txt distributed with Ren'Py for permission to
|
||||
# copy and modify.
|
||||
|
||||
# This file contains the code to implement the Ren'Py preferences
|
||||
# screen.
|
||||
|
||||
init python:
|
||||
|
||||
# This is a map from the name of the style that is applied to
|
||||
# a list of preferences that should be placed into a vbox
|
||||
# with that style.
|
||||
config.preferences = { }
|
||||
|
||||
# Ditto, for joystick preferences.
|
||||
config.joystick_preferences = { }
|
||||
|
||||
# Positions for preferences... overrides the above.
|
||||
config.preference_positions = None
|
||||
config.joystick_preference_positions = None
|
||||
|
||||
# This is a map from preference name to that preference
|
||||
# object, that can be used in rearranging preferences.
|
||||
config.all_preferences = { }
|
||||
|
||||
# If true, the preference choices will be arranged in an
|
||||
# hbox.
|
||||
config.hbox_pref_choices = False
|
||||
|
||||
# A list of (readable name, synthetic key) tuples
|
||||
# corresponding to joystick events.
|
||||
config.joystick_keys = [
|
||||
(u'Left', 'joy_left'),
|
||||
(u'Right', 'joy_right'),
|
||||
(u'Up', 'joy_up'),
|
||||
(u'Down', 'joy_down'),
|
||||
(u'Select/Dismiss', 'joy_dismiss'),
|
||||
(u'Rollback', 'joy_rollback'),
|
||||
(u'Hold to Skip', 'joy_holdskip'),
|
||||
(u'Toggle Skip', 'joy_toggleskip'),
|
||||
(u'Hide Text', 'joy_hide'),
|
||||
(u'Menu', 'joy_menu'),
|
||||
]
|
||||
|
||||
# If True, then we can always get into the joystick
|
||||
# preferences.
|
||||
config.always_has_joystick = False
|
||||
|
||||
|
||||
def _prefs_screen_run(prefs_map, positions):
|
||||
|
||||
|
||||
_game_nav("prefs")
|
||||
|
||||
if positions is not None:
|
||||
for name, pos in positions.iteritems():
|
||||
ui.vbox(**pos)
|
||||
config.all_preferences[name].render_preference()
|
||||
ui.close()
|
||||
|
||||
else:
|
||||
|
||||
### prefs_frame default
|
||||
# (window) A window containing all preferences.
|
||||
|
||||
ui.window(style='prefs_frame')
|
||||
ui.fixed()
|
||||
|
||||
for style, prefs in prefs_map.iteritems():
|
||||
|
||||
ui.vbox(style=style)
|
||||
for i in prefs:
|
||||
i.render_preference()
|
||||
ui.close()
|
||||
|
||||
ui.close()
|
||||
|
||||
_game_interact()
|
||||
|
||||
|
||||
class _Preference(object):
|
||||
"""
|
||||
This is a class that's used to represent a multiple-choice
|
||||
preference.
|
||||
"""
|
||||
|
||||
def __init__(self, name, field, values, base=_preferences):
|
||||
"""
|
||||
@param name: The name of this preference. It will be
|
||||
displayed to the user.
|
||||
|
||||
@param variable: The field on the base object
|
||||
that will be assigned the selected value. This field
|
||||
must exist.
|
||||
|
||||
@param values: A list of value name, value, condition
|
||||
triples. The value name is the name of this value that
|
||||
will be shown to the user. The value is the literal
|
||||
python value that will be assigned if this value is
|
||||
selected. The condition is a condition that will be
|
||||
evaluated to determine if this is a legal value. If no
|
||||
conditions are true, this preference will not be
|
||||
displayed to the user. A condition of None is always
|
||||
considered to be True.
|
||||
|
||||
@param base: The base object on which the variable is
|
||||
read from and set. This defaults to _preferences,
|
||||
the user preferences object.
|
||||
"""
|
||||
|
||||
self.name = name
|
||||
self.field = field
|
||||
self.values = values
|
||||
self.base = base
|
||||
|
||||
config.all_preferences[name] = self
|
||||
|
||||
def render_preference(self):
|
||||
values = [ (name, val) for name, val, cond in self.values
|
||||
if cond is None or renpy.eval(cond) ]
|
||||
|
||||
if not values:
|
||||
return
|
||||
|
||||
|
||||
ui.window(style=style.prefs_pref_frame[self.name])
|
||||
ui.vbox(style=style.prefs_pref_vbox[self.name])
|
||||
|
||||
_label_factory(self.name, "prefs")
|
||||
|
||||
cur = getattr(self.base, self.field)
|
||||
|
||||
### prefs_hbox default
|
||||
# If config.hbox_pref_choices is True, the style
|
||||
# of the hbox containing the choices.
|
||||
|
||||
if config.hbox_pref_choices:
|
||||
ui.hbox(style=style.prefs_hbox[self.name])
|
||||
|
||||
for name, value in values:
|
||||
|
||||
### prefs_button menu_button
|
||||
# (window, hover) The style of an unselected preferences
|
||||
# button.
|
||||
|
||||
### prefs_button_text menu_button_text
|
||||
# (text, hover) The style of the text of an unselected
|
||||
# preferences button.
|
||||
|
||||
def clicked(value=value):
|
||||
setattr(self.base, self.field, value)
|
||||
return True
|
||||
|
||||
_button_factory(name, "prefs",
|
||||
selected=cur==value,
|
||||
clicked=clicked)
|
||||
|
||||
if config.hbox_pref_choices:
|
||||
ui.close()
|
||||
|
||||
ui.close()
|
||||
|
||||
|
||||
class _VolumePreference(object):
|
||||
"""
|
||||
This represents a preference that controls one of the
|
||||
volumes in the system. It is represented as a slider bar,
|
||||
and a button that can be pushed to play a sample sound on
|
||||
a channel.
|
||||
"""
|
||||
|
||||
def __init__(self, name, mixer, enable='True', sound='None', channel=0):
|
||||
"""
|
||||
@param name: The name of this preference, as shown to the user.
|
||||
|
||||
@param mixer: The mixer this preference controls.
|
||||
|
||||
@param enable: A string giving a python expression. If
|
||||
the expression is evaluates to false, this preference
|
||||
is not shown.
|
||||
|
||||
@param sound: A string that is evaluated to yield
|
||||
another string. The yielded string is expected to give
|
||||
a sound file, which is played as the sample sound. (We
|
||||
apologize for the convolution of this.)
|
||||
|
||||
@param channel: The number of the channel the sample
|
||||
sound is played on.
|
||||
"""
|
||||
|
||||
self.name = name
|
||||
self.mixer = mixer
|
||||
self.enable = enable
|
||||
self.sound = sound
|
||||
self.channel = channel
|
||||
|
||||
config.all_preferences[name] = self
|
||||
|
||||
def render_preference(self):
|
||||
|
||||
if not eval(self.enable):
|
||||
return
|
||||
|
||||
sound = eval(self.sound)
|
||||
|
||||
ui.window(style=style.prefs_pref_frame[self.name])
|
||||
ui.vbox(style=style.prefs_pref_vbox[self.name])
|
||||
|
||||
_label_factory(self.name, "prefs")
|
||||
|
||||
def changed(v):
|
||||
|
||||
_preferences.set_volume(self.mixer, v / 128.0)
|
||||
|
||||
ui.bar(128,
|
||||
int(_preferences.get_volume(self.mixer) * 128),
|
||||
changed=changed,
|
||||
style=style.prefs_volume_slider[self.name])
|
||||
|
||||
if sound:
|
||||
def clicked():
|
||||
renpy.sound.play(sound, channel=self.channel)
|
||||
|
||||
_button_factory(u"Test", "soundtest", clicked=clicked, index=self.name)
|
||||
|
||||
ui.close()
|
||||
|
||||
class _SliderPreference(object):
|
||||
"""
|
||||
A class that represents a preference that is controlled by a
|
||||
slider.
|
||||
"""
|
||||
|
||||
def __init__(self, name, range, get, set, enable='True'):
|
||||
"""
|
||||
@param set: The name of this preference, that is shown to the user.
|
||||
|
||||
@param range: An integer giving the maximum value of
|
||||
this slider. The slider goes from 0 to range.
|
||||
|
||||
@param get: A function that's called to get the
|
||||
initial value of the slider. It's called with no
|
||||
arguments, and should return an integet between 0 and
|
||||
range, inclusive.
|
||||
|
||||
@param set: A function that's called when the value of
|
||||
the slider is set by the user. It is called with a
|
||||
single integer, in the range 0 to range, inclusive.
|
||||
|
||||
@param enable: A string giving a python expression. If
|
||||
the expression is evaluates to false, this preference
|
||||
is not shown.
|
||||
"""
|
||||
|
||||
self.name = name
|
||||
self.range = range
|
||||
self.get = get
|
||||
self.set = set
|
||||
self.enable = enable
|
||||
|
||||
config.all_preferences[name] = self
|
||||
|
||||
def render_preference(self):
|
||||
|
||||
if not eval(self.enable):
|
||||
return
|
||||
|
||||
ui.window(style=style.prefs_pref_frame[self.name])
|
||||
ui.vbox(style=style.prefs_pref_vbox[self.name])
|
||||
|
||||
_label_factory(self.name, "prefs")
|
||||
|
||||
def changed(v):
|
||||
self.set(v)
|
||||
|
||||
### prefs_slider bar
|
||||
# (bar) The style that is applied to preference
|
||||
# sliders.
|
||||
|
||||
ui.bar(self.range,
|
||||
self.get(),
|
||||
changed=changed,
|
||||
style=style.prefs_slider[self.name])
|
||||
|
||||
ui.close()
|
||||
|
||||
|
||||
class _PreferenceSpinner(object):
|
||||
"""
|
||||
This is a class that's used to represent a preference
|
||||
spinner, which is a preference that can be incremented
|
||||
and decremented, when shown to the user.
|
||||
"""
|
||||
|
||||
def __init__(self, name, field, minimum, maximum, delta,
|
||||
cond = "True", render = lambda x : str(x),
|
||||
base=_preferences):
|
||||
"""
|
||||
@param name: The name of this preference, that is presented
|
||||
to the user.
|
||||
|
||||
@param field: The name of the field on the base object
|
||||
that is updated by this spinner.
|
||||
|
||||
@param minimum: The minimum value that this spinner can set
|
||||
the value to.
|
||||
|
||||
@param maximum: The maximum value that this spinner can set
|
||||
the value to.
|
||||
|
||||
@param delta: The delta by which this spinner is
|
||||
incremented or decremented.
|
||||
|
||||
@param cond: If this condition is not true, this spinner is
|
||||
not shown.
|
||||
|
||||
@param render: This function is called with the value of
|
||||
the field, and is expected to render that value to a
|
||||
string.
|
||||
|
||||
@param base: The base object that this spinner updates
|
||||
the field on. It defaults to _preferences, the preferences
|
||||
object.
|
||||
"""
|
||||
|
||||
self.name = name
|
||||
self.field = field
|
||||
self.minimum = minimum
|
||||
self.maximum = maximum
|
||||
self.delta = delta
|
||||
self.cond = cond
|
||||
self.render = render
|
||||
self.base = base
|
||||
|
||||
config.all_preferences[name] = self
|
||||
|
||||
def render_preference(self):
|
||||
|
||||
if not renpy.eval(self.cond):
|
||||
return
|
||||
|
||||
ui.window(style=style.prefs_pref_frame[self.name])
|
||||
ui.vbox(style=style.prefs_pref_vbox[self.name])
|
||||
|
||||
_label_factory(self.name, "prefs")
|
||||
|
||||
cur = getattr(self.base, self.field)
|
||||
|
||||
def minus_clicked():
|
||||
value = cur - self.delta
|
||||
value = max(self.minimum, value)
|
||||
setattr(self.base, self.field, value)
|
||||
return True
|
||||
|
||||
def plus_clicked():
|
||||
value = cur + self.delta
|
||||
value = min(self.maximum, value)
|
||||
setattr(self.base, self.field, value)
|
||||
return True
|
||||
|
||||
ui.hbox(style=style.prefs_spinner[self.name])
|
||||
_button_factory("-", "prefs_spinner", clicked=minus_clicked)
|
||||
_label_factory(self.render(cur), "prefs_spinner")
|
||||
_button_factory("+", "prefs_spinner", clicked=plus_clicked)
|
||||
ui.close()
|
||||
|
||||
ui.close()
|
||||
|
||||
def _joystick_select_binding():
|
||||
|
||||
for label, key in config.joystick_keys:
|
||||
|
||||
def my_clicked(label=label, key=key):
|
||||
return (label, key)
|
||||
|
||||
_button_factory(_(label) + " - " + _(_preferences.joymap.get(key, u"Not Assigned")), "prefs_js", clicked=my_clicked, index=label)
|
||||
|
||||
|
||||
def _joystick_get_binding():
|
||||
ui.add(renpy.display.joystick.JoyBehavior())
|
||||
ui.saybehavior()
|
||||
|
||||
def _joystick_take_binding(binding, key):
|
||||
|
||||
if not isinstance(binding, basestring):
|
||||
if key in _preferences.joymap:
|
||||
del _preferences.joymap[key]
|
||||
else:
|
||||
_preferences.joymap[key] = binding
|
||||
|
||||
|
||||
|
||||
class _JoystickPreference(object):
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
config.all_preferences[name] = self
|
||||
|
||||
|
||||
def render_preference(self):
|
||||
|
||||
def set_binding(label, key):
|
||||
_game_nav(None)
|
||||
|
||||
ui.window(style='js_frame')
|
||||
ui.vbox(style='js_frame_vbox')
|
||||
_label_factory(_(u"Joystick Mapping") + " - " + _(label), "js_function")
|
||||
_label_factory(u'Move the joystick or press a joystick button to create the mapping. Click the mouse to remove the mapping.', 'js_prompt')
|
||||
ui.close()
|
||||
|
||||
_joystick_get_binding()
|
||||
binding = _game_interact()
|
||||
_joystick_take_binding(binding, key)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
ui.window(style='prefs_js_frame')
|
||||
ui.vbox(style='prefs_js_vbox')
|
||||
_label_factory(self.name, 'prefs')
|
||||
|
||||
for label, key in config.joystick_keys:
|
||||
|
||||
def clicked(label=label, key=key):
|
||||
return renpy.invoke_in_new_context(set_binding, label, key)
|
||||
|
||||
_button_factory(_(label) + " - " + _(_preferences.joymap.get(key, u"Not Assigned")), "prefs_js", clicked=clicked, index=label)
|
||||
|
||||
ui.close()
|
||||
|
||||
|
||||
class _JumpPreference(object):
|
||||
|
||||
def __init__(self, name, target, condition="True"):
|
||||
self.name = name
|
||||
self.target = target
|
||||
self.condition = condition
|
||||
|
||||
config.all_preferences[name] = self
|
||||
|
||||
def render_preference(self):
|
||||
|
||||
ui.window(style=style.prefs_jump[self.name])
|
||||
|
||||
if eval(self.condition):
|
||||
clicked=ui.jumps(self.target)
|
||||
else:
|
||||
clicked=None
|
||||
|
||||
_button_factory(self.name, 'prefs_jump', clicked=clicked)
|
||||
|
||||
def _remove_preference(name):
|
||||
"""
|
||||
Removes the preference with the given name from the
|
||||
preferences menu.
|
||||
"""
|
||||
|
||||
pref = config.all_preferences.get(name, None)
|
||||
if not pref:
|
||||
return
|
||||
|
||||
for k, v in config.preferences.iteritems():
|
||||
if pref in v:
|
||||
v.remove(pref)
|
||||
|
||||
init python hide:
|
||||
|
||||
# Enablers for some preferences.
|
||||
config.has_music = True
|
||||
config.has_sound = True
|
||||
config.sample_sound = None
|
||||
config.has_transitions = True
|
||||
config.has_cps = True
|
||||
config.has_afm = True
|
||||
config.has_skipping = True
|
||||
config.has_skip_after_choice = True
|
||||
|
||||
|
||||
# Left
|
||||
|
||||
pl1 = _Preference(u'Display', 'fullscreen', [
|
||||
(u'Window', False, None),
|
||||
(u'Fullscreen', True, None),
|
||||
])
|
||||
|
||||
pl2 = _Preference(u'Transitions', 'transitions', [
|
||||
(u'All', 2, 'config.has_transitions'),
|
||||
(u'Some', 1, 'config.has_transitions and default_transition'),
|
||||
(u'None', 0, 'config.has_transitions'),
|
||||
])
|
||||
|
||||
# Center
|
||||
|
||||
pc1 = _Preference(u'Skip', 'skip_unseen', [
|
||||
(u'Seen Messages', False, 'config.allow_skipping and config.has_skipping'),
|
||||
(u'All Messages', True, 'config.allow_skipping and config.has_skipping'),
|
||||
])
|
||||
|
||||
config.old_names['Skip'] = 'TAB and CTRL Skip'
|
||||
config.all_preferences['TAB and CTRL Skip'] = pc1
|
||||
|
||||
|
||||
pc2= _Preference(u'After Choices', 'skip_after_choices', [
|
||||
(u'Stop Skipping', False, 'config.allow_skipping and config.has_skip_after_choice'),
|
||||
(u'Keep Skipping', True, 'config.allow_skipping and config.has_skip_after_choice'),
|
||||
])
|
||||
|
||||
config.old_names['Keep Skipping'] = 'Continue Skipping'
|
||||
|
||||
def cps_get():
|
||||
cps = _preferences.text_cps
|
||||
if cps == 0:
|
||||
cps = 150
|
||||
else:
|
||||
cps -= 1
|
||||
return cps
|
||||
|
||||
def cps_set(cps):
|
||||
cps += 1
|
||||
if cps == 151:
|
||||
cps = 0
|
||||
_preferences.text_cps = cps
|
||||
|
||||
|
||||
pc3 = _SliderPreference(u'Text Speed', 150, cps_get, cps_set,
|
||||
'config.has_cps')
|
||||
|
||||
|
||||
def afm_get():
|
||||
afm = _preferences.afm_time
|
||||
if afm == 0:
|
||||
afm = 40
|
||||
else:
|
||||
afm -= 1
|
||||
return afm
|
||||
|
||||
def afm_set(afm):
|
||||
afm += 1
|
||||
if afm == 41:
|
||||
afm = 0
|
||||
_preferences.afm_time = afm
|
||||
|
||||
pc4 = _SliderPreference(u'Auto-Forward Time', 40, afm_get, afm_set,
|
||||
'config.has_afm')
|
||||
|
||||
# Right
|
||||
|
||||
pr1 = _VolumePreference(u"Music Volume", 'music', 'config.has_music')
|
||||
pr2 = _VolumePreference(u"Sound Volume", 'sfx', 'config.has_sound', 'config.sample_sound')
|
||||
|
||||
_JumpPreference(u'Joystick...', '_joystick_screen', 'renpy.display.joystick.enabled or config.always_has_joystick')
|
||||
|
||||
_JoystickPreference(u'Joystick Configuration')
|
||||
|
||||
config.preferences['prefs_left'] = [
|
||||
config.all_preferences[u'Display'],
|
||||
config.all_preferences[u'Transitions'],
|
||||
config.all_preferences[u'Joystick...'],
|
||||
]
|
||||
|
||||
config.preferences['prefs_center'] = [
|
||||
config.all_preferences[u'Skip'],
|
||||
config.all_preferences[u'After Choices'],
|
||||
config.all_preferences[u'Text Speed'],
|
||||
config.all_preferences[u'Auto-Forward Time'],
|
||||
]
|
||||
|
||||
config.preferences['prefs_right'] = [
|
||||
config.all_preferences[u'Music Volume'],
|
||||
config.all_preferences[u'Sound Volume'],
|
||||
]
|
||||
|
||||
config.joystick_preferences['prefs_joystick'] = [
|
||||
config.all_preferences[u'Joystick Configuration'],
|
||||
]
|
||||
|
||||
config.sample_voice = None
|
||||
|
||||
vp = _VolumePreference(u'Voice Volume',
|
||||
'voice',
|
||||
'config.has_voice',
|
||||
'config.sample_voice',
|
||||
2)
|
||||
|
||||
config.preferences['prefs_right'].insert(1, vp)
|
||||
|
||||
label _prefs_screen:
|
||||
|
||||
$ _prefs_screen_run(config.preferences, config.preference_positions)
|
||||
|
||||
jump _prefs_screen
|
||||
|
||||
label _joystick_screen:
|
||||
|
||||
$ _prefs_screen_run(config.joystick_preferences, config.joystick_preference_positions)
|
||||
|
||||
jump _joystick_screen
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,357 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python hide:
|
||||
|
||||
style.menu_button = Style(style.button, heavy=True, help='Buttons that are part of the main or game menus.')
|
||||
style.menu_button_text = Style(style.button_text, heavy=True, help='The label of buttons that are part of the main or game menus.')
|
||||
|
||||
style.thin_hbox = Style(style.hbox, heavy=True, help='A hbox with a small amount of spacing.')
|
||||
style.thick_hbox = Style(style.hbox, heavy=True, help='A hbox with a large amount of spacing.')
|
||||
style.thin_vbox = Style(style.vbox, heavy=True, help='A vbox with a small amount of spacing.')
|
||||
style.thick_vbox = Style(style.vbox, heavy=True, help='A vbox with a large amount of spacing.')
|
||||
|
||||
style.mm_menu_frame = Style(style.default, heavy=True, help='The frame containing the main menu.')
|
||||
style.mm_menu_frame_vbox = Style(style.thin_vbox, heavy=True, help='The vbox containing the main menu.')
|
||||
style.mm_button = Style(style.menu_button, heavy=True, help='A main menu button.')
|
||||
style.mm_button_text = Style(style.menu_button_text, heavy=True, help='A main menu button label.')
|
||||
style.default.drop_shadow = (1, 1)
|
||||
|
||||
style.gm_nav_frame = Style(style.default, heavy=True, help='The frame containing the navigation buttons.')
|
||||
style.gm_nav_vbox = Style(style.thin_vbox, heavy=True, help='The vbox containing the navigation buttons.')
|
||||
style.gm_nav_button = Style(style.menu_button, heavy=True, help='A navigation button.')
|
||||
style.gm_nav_button_text = Style(style.menu_button_text, heavy=True, help='A navigation button label.')
|
||||
|
||||
style.file_picker_entry = Style(style.menu_button, heavy=True, help='A button you click to save or load a file.')
|
||||
style.file_picker_entry_box = Style(style.thin_hbox, heavy=True, help='The box inside that button.')
|
||||
style.file_picker_text = Style(style.default, heavy=True, help='Base style for text inside a file picker entry.')
|
||||
style.file_picker_new = Style(style.file_picker_text, heavy=True, help='The number of the newest file.')
|
||||
style.file_picker_old = Style(style.file_picker_text, heavy=True, help='The number of non-newest files.')
|
||||
style.file_picker_extra_info = Style(style.file_picker_text, heavy=True, help='Extra text (the date and save info) of a file.')
|
||||
style.file_picker_empty_slot = Style(style.file_picker_text, heavy=True, help='The style of "Empty Slot" text.')
|
||||
style.file_picker_frame = Style(style.default, heavy=True, help='The frame containing the file picker.')
|
||||
style.file_picker_frame_vbox = Style(style.thin_vbox, heavy=True, help='The box containing file picker navigation and the file picker grid.')
|
||||
style.file_picker_navbox = Style(style.thick_hbox, heavy=True, help='The box containing the file picker navigation buttons.')
|
||||
style.file_picker_nav_button = Style(style.menu_button, heavy=True, help='A file picker navigation button.')
|
||||
style.file_picker_nav_button_text = Style(style.menu_button_text, heavy=True, help='A file picker navigation button label.')
|
||||
style.file_picker_grid = Style(style.default, heavy=True, help='The grid containing the entries in the file picker.')
|
||||
|
||||
style.yesno_frame = Style(style.default, heavy=True, help='The frame containing the yes/no dialog.')
|
||||
style.yesno_frame_vbox = Style(style.thick_vbox, heavy=True, help='Separates the label from the buttons in a yes/no dialog.')
|
||||
style.yesno_label = Style(style.default, heavy=True, help='The label of a yes/no dialog.')
|
||||
style.yesno_button_hbox = Style(style.thick_hbox, heavy=True, help="The box containing the Yes and No buttons.")
|
||||
style.yesno_button = Style(style.menu_button, heavy=True, help='A Yes/No button.')
|
||||
style.yesno_button_text = Style(style.menu_button_text, heavy=True, help='A Yes/No button label.')
|
||||
|
||||
|
||||
style.prefs_frame = Style(style.default, heavy=True, help='')
|
||||
style.prefs_pref_frame = Style(style.default, heavy=True, help='')
|
||||
style.prefs_pref_vbox = Style(style.thin_vbox, heavy=True, help='')
|
||||
style.prefs_label = Style(style.default, heavy=True, help='')
|
||||
style.prefs_hbox = Style(style.default, heavy=True, help='')
|
||||
style.prefs_button = Style(style.menu_button, heavy=True, help='')
|
||||
style.prefs_button_text = Style(style.menu_button_text, heavy=True, help='')
|
||||
style.soundtest_button = Style(style.prefs_button, heavy=True, help='')
|
||||
style.soundtest_button_text = Style(style.prefs_button_text, heavy=True, help='')
|
||||
style.prefs_slider = Style(style.bar, heavy=True, help='')
|
||||
style.prefs_volume_slider = Style(style.prefs_slider, heavy=True, help='')
|
||||
style.prefs_spinner = Style(style.default, heavy=True, help='')
|
||||
style.prefs_spinner_label = Style(style.prefs_label, heavy=True, help='')
|
||||
style.prefs_spinner_button = Style(style.prefs_button, heavy=True, help='')
|
||||
style.prefs_spinner_button_text = Style(style.prefs_button_text, heavy=True, help='')
|
||||
style.prefs_js_frame = Style(style.prefs_pref_frame, heavy=True, help='')
|
||||
style.prefs_js_vbox = Style(style.prefs_pref_vbox, heavy=True, help='')
|
||||
style.prefs_js_button = Style(style.prefs_button, heavy=True, help='')
|
||||
style.prefs_js_button_text = Style(style.prefs_button_text, heavy=True, help='')
|
||||
style.js_frame = Style(style.prefs_frame, heavy=True, help='')
|
||||
style.js_frame_vbox = Style(style.thick_vbox, heavy=True, help='')
|
||||
style.js_function_label = Style(style.prefs_label, heavy=True, help='')
|
||||
style.js_prompt_label = Style(style.prefs_label, heavy=True, help='')
|
||||
style.prefs_jump = Style(style.prefs_pref_frame, heavy=True, help='')
|
||||
style.prefs_jump_button = Style(style.prefs_button, heavy=True, help='')
|
||||
style.prefs_jump_button_text = Style(style.prefs_button_text, heavy=True, help='')
|
||||
style.prefs_column = Style(style.default, heavy=True, help='')
|
||||
style.prefs_left = Style(style.prefs_column, heavy=True, help='')
|
||||
style.prefs_center = Style(style.prefs_column, heavy=True, help='')
|
||||
style.prefs_right = Style(style.prefs_column, heavy=True, help='')
|
||||
style.prefs_joystick = Style(style.prefs_center, heavy=True, help='')
|
||||
|
||||
style.thin_hbox.spacing = 3
|
||||
style.thick_hbox.spacing = 30
|
||||
style.thin_vbox.spacing = 0
|
||||
style.thick_vbox.spacing = 30
|
||||
|
||||
dark_cyan = (0, 192, 255, 255)
|
||||
bright_cyan = (0, 255, 255, 255)
|
||||
dark_red = (255, 128, 128, 255)
|
||||
bright_red = (255, 64, 64, 255)
|
||||
green = (0, 128, 0, 255)
|
||||
|
||||
# Frames.
|
||||
style.frame.background = Solid((0, 0, 128, 128))
|
||||
style.frame.xpadding = 10
|
||||
style.frame.ypadding = 5
|
||||
style.frame.xmargin = 10
|
||||
style.frame.ymargin = 5
|
||||
|
||||
|
||||
######################################################################
|
||||
# Buttons.
|
||||
|
||||
style.button_text.color = dark_cyan
|
||||
style.button_text.hover_color = bright_cyan
|
||||
style.button_text.insensitive_color = (192, 192, 192, 255)
|
||||
style.button_text.size = 24
|
||||
style.button_text.drop_shadow = (2, 2)
|
||||
|
||||
style.button_text.selected_color = dark_red
|
||||
style.button_text.selected_hover_color = bright_red
|
||||
|
||||
style.button_text.xpos = 0.5
|
||||
style.button_text.xanchor = 0.5
|
||||
|
||||
style.menu_button.xpos = 0.5
|
||||
style.menu_button.xanchor = 0.5
|
||||
|
||||
|
||||
######################################################################
|
||||
# Bar.
|
||||
|
||||
style.bar.ymaximum = 22
|
||||
|
||||
style.bar.left_bar = Solid(bright_cyan)
|
||||
style.bar.right_bar = Solid((0, 0, 0, 128))
|
||||
style.bar.bottom_bar = Solid(bright_cyan)
|
||||
style.bar.top_bar = Solid((0, 0, 0, 128))
|
||||
style.bar.left_gutter = 0
|
||||
style.bar.right_gutter = 0
|
||||
style.bar.thumb = None
|
||||
style.bar.thumb_offset = 0
|
||||
style.bar.thumb_shadow = None
|
||||
|
||||
style.vbar.xmaximum = 22
|
||||
|
||||
style.vbar.left_bar = Solid(bright_cyan)
|
||||
style.vbar.right_bar = Solid((0, 0, 0, 128))
|
||||
style.vbar.bottom_bar = Solid(bright_cyan)
|
||||
style.vbar.top_bar = Solid((0, 0, 0, 128))
|
||||
style.vbar.left_gutter = 0
|
||||
style.vbar.right_gutter = 0
|
||||
style.vbar.bottom_gutter = 0
|
||||
style.vbar.top_gutter = 0
|
||||
style.vbar.thumb = None
|
||||
style.vbar.thumb_offset = 0
|
||||
style.vbar.thumb_shadow = None
|
||||
|
||||
style.vscrollbar.set_parent(style.vbar)
|
||||
style.scrollbar.set_parent(style.bar)
|
||||
|
||||
style.vscrollbar.bottom_bar = Solid((0, 0, 0, 128))
|
||||
style.vscrollbar.top_bar = Solid(bright_cyan)
|
||||
|
||||
style.slider.ymaximum = 1
|
||||
style.vslider.xmaximum = 1
|
||||
|
||||
######################################################################
|
||||
# Main menu.
|
||||
|
||||
style.mm_menu_frame.xpos = 0.9
|
||||
style.mm_menu_frame.xanchor = 1.0
|
||||
style.mm_menu_frame.ypos = 0.9
|
||||
style.mm_menu_frame.yanchor = 1.0
|
||||
|
||||
|
||||
######################################################################
|
||||
# Game menu common.
|
||||
|
||||
style.gm_nav_frame.xpos = 0.95
|
||||
style.gm_nav_frame.xanchor = 1.0
|
||||
style.gm_nav_frame.ypos = 0.95
|
||||
style.gm_nav_frame.yanchor = 1.0
|
||||
|
||||
|
||||
##############################################################################
|
||||
# File picker.
|
||||
|
||||
style.file_picker_frame.xpos = 0
|
||||
style.file_picker_frame.xanchor = 0.0
|
||||
style.file_picker_frame.ypos = 0
|
||||
style.file_picker_frame.yanchor = 0.0
|
||||
style.file_picker_frame.xpadding = 5
|
||||
|
||||
style.file_picker_navbox.xpos = 10
|
||||
|
||||
style.file_picker_grid.xfill = True
|
||||
|
||||
style.file_picker_entry.xpadding = 5
|
||||
style.file_picker_entry.ypadding = 2
|
||||
style.file_picker_entry.xmargin = 5
|
||||
style.file_picker_entry.xfill = True
|
||||
style.file_picker_entry.ymargin = 2
|
||||
style.file_picker_entry.background = Solid((255, 255, 255, 255))
|
||||
style.file_picker_entry.hover_background = Solid((255, 255, 192, 255))
|
||||
|
||||
style.file_picker_text.size = 16
|
||||
style.file_picker_text.color = dark_cyan
|
||||
style.file_picker_text.hover_color = bright_cyan
|
||||
|
||||
style.file_picker_new.hover_color = bright_red
|
||||
style.file_picker_new.idle_color = dark_red
|
||||
|
||||
style.file_picker_new.minwidth = 40
|
||||
style.file_picker_old.minwidth = 40
|
||||
|
||||
style.file_picker_new.text_align = 1.0
|
||||
style.file_picker_old.text_align = 1.0
|
||||
|
||||
|
||||
######################################################################
|
||||
# Yes/No Dialog
|
||||
|
||||
style.yesno_label.color = green
|
||||
style.yesno_label.textalign = 0.5
|
||||
style.yesno_label.xpos = 0.5
|
||||
style.yesno_label.xanchor = 0.5
|
||||
|
||||
style.yesno_frame.xfill = True
|
||||
style.yesno_frame.yminimum = 0.5
|
||||
style.yesno_frame.xmargin = .1
|
||||
|
||||
style.yesno_frame_vbox.xpos = 0.5
|
||||
style.yesno_frame_vbox.xanchor = 0.5
|
||||
style.yesno_frame_vbox.ypos = 0.5
|
||||
style.yesno_frame_vbox.yanchor = 0.5
|
||||
|
||||
style.yesno_button_hbox.xalign = 0.5
|
||||
style.yesno_button_hbox.spacing = 100
|
||||
|
||||
##############################################################################
|
||||
# Preferences.
|
||||
|
||||
|
||||
style.prefs_pref_frame.xpos = 0.5
|
||||
style.prefs_pref_frame.xanchor = 0.5
|
||||
style.prefs_pref_frame.bottom_margin = 10
|
||||
|
||||
style.prefs_label.xpos = 0.5
|
||||
style.prefs_label.xanchor = 0.5
|
||||
style.prefs_label.color = green
|
||||
|
||||
style.prefs_slider.xmaximum=200
|
||||
style.prefs_slider.ymaximum=22
|
||||
style.prefs_slider.xpos = 0.5
|
||||
style.prefs_slider.xanchor = 0.5
|
||||
|
||||
style.prefs_hbox.xpos = 0.5
|
||||
style.prefs_hbox.xanchor = 0.5
|
||||
|
||||
style.prefs_button.xpos = 0.5
|
||||
style.prefs_button.xanchor = 0.5
|
||||
|
||||
style.prefs_button.selected_xpos = 0.5
|
||||
style.prefs_button.selected_xanchor = 0.5
|
||||
|
||||
style.prefs_frame.xfill=True
|
||||
style.prefs_frame.ypadding = 0.05
|
||||
|
||||
style.prefs_column.spacing = 6
|
||||
|
||||
style.prefs_left.xanchor = 0.5
|
||||
style.prefs_left.xpos = 1.0 / 6.0
|
||||
|
||||
style.prefs_center.xanchor = 0.5
|
||||
style.prefs_center.xpos = 3.0 / 6.0
|
||||
|
||||
style.prefs_right.xanchor = 0.5
|
||||
style.prefs_right.xpos = 5.0 / 6.0
|
||||
|
||||
style.prefs_spinner.xpos = 0.5
|
||||
style.prefs_spinner.xanchor = 0.5
|
||||
|
||||
style.prefs_spinner_label.minwidth = 100
|
||||
style.prefs_spinner_label.textalign = 0.5
|
||||
|
||||
style.prefs_js_button_text.size = 18
|
||||
style.prefs_js_button_text.drop_shadow = (1, 1)
|
||||
|
||||
style.js_function_label.textalign = 0.5
|
||||
style.js_prompt_label.textalign = 0.5
|
||||
|
||||
style.js_frame.xfill = True
|
||||
style.js_frame.yminimum = 0.5
|
||||
style.js_frame.xmargin = .1
|
||||
|
||||
style.js_frame_vbox.xpos = 0.5
|
||||
style.js_frame_vbox.xanchor = 0.5
|
||||
style.js_frame_vbox.ypos = 0.5
|
||||
style.js_frame_vbox.yanchor = 0.5
|
||||
|
||||
style.soundtest_button.activate_sound = None
|
||||
|
||||
style.window.background = Solid((0, 0, 128, 128))
|
||||
style.window.xpadding = 10
|
||||
style.window.ypadding = 5
|
||||
style.window.xmargin = 10
|
||||
style.window.ymargin = 5
|
||||
style.window.xfill = True
|
||||
style.window.yfill = False
|
||||
style.window.xminimum = 0 # Includes margins and padding.
|
||||
style.window.yminimum = 150 # Includes margins and padding.
|
||||
|
||||
|
||||
|
||||
######################################################################
|
||||
# Compatibility names for renamed styles.
|
||||
style.file_picker_window_vbox = style.file_picker_frame_vbox
|
||||
style.prefs_window = style.prefs_frame
|
||||
style.mm_root_window = style.mm_root
|
||||
style.file_picker_window = style.file_picker_frame
|
||||
style.prefs_pref = style.prefs_pref_frame
|
||||
style.gm_root_window = style.gm_root
|
||||
style.yesno_window_vbox = style.yesno_frame_vbox
|
||||
style.joyprompt_label = style.js_prompt_label
|
||||
style.gm_nav_window = style.gm_nav_frame
|
||||
style.joy_window = style.js_frame
|
||||
style.mm_menu_window = style.mm_menu_frame
|
||||
style.error_window = style.error_root
|
||||
style.joyfunc_label = style.js_function_label
|
||||
style.joy_vbox = style.js_frame_vbox
|
||||
style.yesno_window = style.yesno_frame
|
||||
style.mm_menu_window_vbox = style.mm_menu_frame_vbox
|
||||
style.menu_choice_button_text = style.menu_choice
|
||||
style.menu_choice_chosen_button_text = style.menu_choice_chosen
|
||||
|
||||
store._selected_compat = [ ]
|
||||
|
||||
class _SelectedCompat(object):
|
||||
|
||||
def __init__(self, target):
|
||||
self.__dict__["target"] = target
|
||||
self.__dict__["property_updates"] = [ ]
|
||||
|
||||
store._selected_compat.append(self)
|
||||
|
||||
def __setattr__(self, k, v):
|
||||
self.property_updates.append((k, v))
|
||||
|
||||
def apply(self):
|
||||
target = getattr(style, self.target)
|
||||
for k, v in self.property_updates:
|
||||
setattr(target, "selected_" + k, v)
|
||||
|
||||
def clear(self):
|
||||
self.__dict__["property_updates"] = [ ]
|
||||
|
||||
|
||||
style.selected_button = _SelectedCompat('button')
|
||||
style.selected_button_text = _SelectedCompat('button_text')
|
||||
style.gm_nav_selected_button = _SelectedCompat('gm_nav_button')
|
||||
style.gm_nav_selected_button_text = _SelectedCompat('gm_nav_button_text')
|
||||
style.prefs_selected_button = _SelectedCompat('prefs_button')
|
||||
style.prefs_selected_button_text = _SelectedCompat('prefs_button_text')
|
||||
|
||||
def apply_selected_compat():
|
||||
for scs in _selected_compat:
|
||||
scs.apply()
|
||||
|
||||
layout.compat_funcs.append(apply_selected_compat)
|
||||
@@ -1,503 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
# Copyright 2004-2012 Tom Rothamel
|
||||
#
|
||||
# Please see the LICENSE.txt distributed with Ren'Py for permission to
|
||||
# copy and modify.
|
||||
|
||||
init -1100:
|
||||
python:
|
||||
|
||||
theme = object()
|
||||
|
||||
def RoundRect(color, small=False):
|
||||
"""
|
||||
Creates a roundrect displayable. Size should be one of
|
||||
6 or 12, while color is the color of the roundrect.
|
||||
"""
|
||||
|
||||
if small:
|
||||
size = 6
|
||||
else:
|
||||
if config.screen_width <= 640:
|
||||
size = 6
|
||||
else:
|
||||
size = 12
|
||||
|
||||
return Frame(theme.OneOrTwoColor("_roundrect/rr%dg.png" % size, color), size, size)
|
||||
|
||||
def _display_button_menu(menuitems):
|
||||
|
||||
narration = [ s for s, i in menuitems if i is None and s ]
|
||||
menuitems = [ (s, i) for s, i in menuitems if i is not None or not s ]
|
||||
|
||||
if narration:
|
||||
renpy.say(None, "\n".join(narration), interact=False)
|
||||
|
||||
return renpy.display_menu(menuitems)
|
||||
|
||||
def _button_menu():
|
||||
|
||||
store.menu = _display_button_menu
|
||||
|
||||
style.menu.clear()
|
||||
style.menu.box_spacing = 2
|
||||
|
||||
style.menu_window.clear()
|
||||
style.menu_window.take(style.default)
|
||||
style.menu_window.xpos = 0.5
|
||||
style.menu_window.xanchor = 0.5
|
||||
style.menu_window.ypos = 0.5
|
||||
style.menu_window.yanchor = 0.5
|
||||
|
||||
style.menu_choice.clear()
|
||||
style.menu_choice.take(style.button_text)
|
||||
|
||||
style.menu_choice_button.clear()
|
||||
style.menu_choice_button.take(style.button)
|
||||
|
||||
style.menu_choice_chosen.clear()
|
||||
style.menu_choice_chosen_button.clear()
|
||||
|
||||
style.menu_choice_button.xminimum = int(config.screen_width * 0.75)
|
||||
style.menu_choice_button.xmaximum = int(config.screen_width * 0.75)
|
||||
|
||||
|
||||
theme.button_menu = _button_menu
|
||||
|
||||
python hide:
|
||||
|
||||
def OneOrTwoColor(image, color):
|
||||
if len(color) == 2:
|
||||
return im.Twocolor(image, color[0], color[1])
|
||||
else:
|
||||
return im.Twocolor(image, color, color)
|
||||
|
||||
theme.OneOrTwoColor = OneOrTwoColor
|
||||
|
||||
|
||||
def theme_roundrect(
|
||||
widget = (0, 60, 120, 255),
|
||||
widget_hover = (0, 80, 160, 255),
|
||||
widget_text = (200, 225, 255, 255),
|
||||
widget_selected = (255, 255, 200, 255),
|
||||
disabled = (64, 64, 64, 255),
|
||||
disabled_text = (200, 200, 200, 255),
|
||||
label = (255, 255, 255, 255),
|
||||
frame = (100, 150, 200, 255),
|
||||
window = (0, 0, 0, 192),
|
||||
mm_root = Solid((220, 235, 255, 255)),
|
||||
gm_root = Solid((220, 235, 255, 255)),
|
||||
centered = False,
|
||||
button_menu = True,
|
||||
launcher = False,
|
||||
rounded_window = True,
|
||||
less_rounded = False,
|
||||
):
|
||||
|
||||
"""This enables the use of the roundrect theme. By
|
||||
default, this theme styles the game in a blue color
|
||||
scheme. However, by supplying one or more of the
|
||||
parameters given below, the color scheme can be
|
||||
changed.
|
||||
|
||||
@param widget: The background color of non-focued
|
||||
buttons and sliders.
|
||||
|
||||
@param widget_hover: The background color of focused
|
||||
buttons and sliders.
|
||||
|
||||
@param widget_text: The text color of non-selected buttons.
|
||||
|
||||
@param widget_selected: The text color of selected buttons.
|
||||
|
||||
@param disabled: The background color of disabled buttons.
|
||||
|
||||
@param disabled_text: The text color of disabled buttons.
|
||||
|
||||
@param label: The text color of non-selected labels.
|
||||
|
||||
@param frame: The background color of frames.
|
||||
|
||||
@param mm_root: A displayable (such as
|
||||
an Image or Solid) that will be used as
|
||||
the background for the main menu.
|
||||
|
||||
@param gm_root: A displayable (such as
|
||||
an Image or Solid) that will be used as
|
||||
the background for the game menu.
|
||||
|
||||
@param centered: If True, the buttons and sliders will
|
||||
be centered in the frames or windows that contain
|
||||
them. If False, the default, they will be pushed to the
|
||||
right side.
|
||||
"""
|
||||
|
||||
if config.screen_width <= 640:
|
||||
size = 18
|
||||
small = 12
|
||||
|
||||
big = False
|
||||
|
||||
spacing = 0
|
||||
pref_spacing = 5
|
||||
title_spacing = 6
|
||||
|
||||
frame_width = 200
|
||||
widget_width = 160
|
||||
|
||||
config.thumbnail_width = 60
|
||||
config.thumbnail_height = 45
|
||||
|
||||
config.file_page_cols = 2
|
||||
config.file_page_rows = 4
|
||||
# style.file_picker_frame.xmaximum = 450
|
||||
|
||||
prefcols = [ 110, 320, 530 ]
|
||||
|
||||
nav_xpos = 530
|
||||
|
||||
else:
|
||||
|
||||
size = 22
|
||||
small = 16
|
||||
|
||||
big = True
|
||||
|
||||
spacing = 0
|
||||
pref_spacing = 10
|
||||
title_spacing = 12
|
||||
|
||||
frame_width = 250
|
||||
widget_width = 200
|
||||
|
||||
prefcols = [ 137, 400, 663 ]
|
||||
|
||||
nav_xpos = 663
|
||||
|
||||
rrslider_empty = "_roundrect/rrslider_empty.png"
|
||||
rrslider_full = "_roundrect/rrslider_full.png"
|
||||
rrslider_thumb = "_roundrect/rrslider_thumb.png"
|
||||
|
||||
rrslider_radius = 6
|
||||
rrslider_height = 24
|
||||
|
||||
rrvslider_empty = "_roundrect/rrvslider_empty.png"
|
||||
rrvslider_full = "_roundrect/rrvslider_full.png"
|
||||
rrvslider_thumb = "_roundrect/rrvslider_thumb.png"
|
||||
|
||||
rrscrollbar = "_roundrect/rrscrollbar.png"
|
||||
rrscrollbar_thumb = "_roundrect/rrscrollbar_thumb.png"
|
||||
rrvscrollbar = "_roundrect/rrvscrollbar.png"
|
||||
rrvscrollbar_thumb = "_roundrect/rrvscrollbar_thumb.png"
|
||||
|
||||
rrvslider_radius = 6
|
||||
rrvslider_width = 24
|
||||
|
||||
|
||||
def rrframe(sty):
|
||||
sty.background = RoundRect(frame, less_rounded)
|
||||
sty.xpadding = 6
|
||||
sty.ypadding = 6
|
||||
|
||||
if big and not less_rounded:
|
||||
store._roundrect_radius = 12
|
||||
else:
|
||||
store._roundrect_radius = 6
|
||||
|
||||
style.button.clear()
|
||||
style.button.background = RoundRect(widget, less_rounded)
|
||||
style.button.hover_background = RoundRect(widget_hover, less_rounded)
|
||||
style.button.xminimum = widget_width
|
||||
style.button.ypadding = 1
|
||||
style.button.xpadding = _roundrect_radius
|
||||
style.button.xmargin = 1
|
||||
style.button.ymargin = 1
|
||||
|
||||
style.button_text.clear()
|
||||
style.button_text.drop_shadow = None
|
||||
style.button_text.color = widget_text
|
||||
style.button_text.size = size
|
||||
style.button_text.xpos = 0.5
|
||||
style.button_text.xanchor = 0.5
|
||||
style.button_text.ypos = 0.5
|
||||
style.button_text.yanchor = 0.5
|
||||
style.button_text.textalign = 0.5
|
||||
|
||||
style.button.insensitive_background = RoundRect(disabled, less_rounded)
|
||||
style.button_text.insensitive_color = disabled_text
|
||||
|
||||
style.button_text.selected_color = widget_selected
|
||||
|
||||
style.menu_button.clear()
|
||||
|
||||
style.mm_root.background = mm_root
|
||||
style.gm_root.background = gm_root
|
||||
|
||||
style.mm_menu_frame_vbox.box_spacing = spacing
|
||||
rrframe(style.mm_menu_frame)
|
||||
style.mm_menu_frame.xpos = nav_xpos
|
||||
style.mm_menu_frame.xanchor = 0.5
|
||||
|
||||
style.gm_nav_vbox.box_spacing = spacing
|
||||
rrframe(style.gm_nav_frame)
|
||||
style.gm_nav_frame.xpos = nav_xpos
|
||||
style.gm_nav_frame.xanchor = 0.5
|
||||
|
||||
|
||||
rrframe(style.prefs_pref_frame)
|
||||
del style.prefs_pref_frame.bottom_margin
|
||||
style.prefs_pref_frame.xfill = True
|
||||
|
||||
style.prefs_pref_vbox.box_spacing = spacing
|
||||
style.prefs_pref_vbox.box_first_spacing = title_spacing
|
||||
style.prefs_pref_vbox.xfill = True
|
||||
|
||||
style.prefs_frame.ypadding = pref_spacing
|
||||
|
||||
rrframe(style.prefs_column)
|
||||
style.prefs_column.box_spacing = pref_spacing
|
||||
style.prefs_column.xmaximum = frame_width
|
||||
|
||||
style.prefs_left.xpos = prefcols[0]
|
||||
style.prefs_center.xpos = prefcols[1]
|
||||
style.prefs_right.xpos = prefcols[2]
|
||||
|
||||
style.prefs_label.color = label
|
||||
style.prefs_label.size = size
|
||||
style.prefs_label.drop_shadow = None
|
||||
style.prefs_label.xpos = 0
|
||||
style.prefs_label.xanchor = 0
|
||||
|
||||
if centered:
|
||||
style.prefs_button.xpos = 0.5
|
||||
style.prefs_button.xanchor = 0.5
|
||||
else:
|
||||
style.prefs_button.xpos = 1.0
|
||||
style.prefs_button.xanchor = 1.0
|
||||
|
||||
|
||||
|
||||
style.bar.ymaximum = rrslider_height
|
||||
style.bar.left_gutter = rrslider_radius
|
||||
style.bar.right_gutter = rrslider_radius
|
||||
style.bar.thumb_offset = -rrslider_radius
|
||||
|
||||
style.bar.left_bar = Frame(theme.OneOrTwoColor(rrslider_full, widget), rrslider_radius * 2, 0)
|
||||
style.bar.right_bar = Frame(theme.OneOrTwoColor(rrslider_empty, widget), rrslider_radius * 2, 0)
|
||||
style.bar.thumb = theme.OneOrTwoColor(rrslider_thumb, widget)
|
||||
|
||||
style.bar.hover_left_bar = Frame(theme.OneOrTwoColor(rrslider_full, widget_hover), rrslider_radius * 2, 0)
|
||||
style.bar.hover_right_bar = Frame(theme.OneOrTwoColor(rrslider_empty, widget_hover), rrslider_radius * 2, 0)
|
||||
style.bar.hover_thumb = theme.OneOrTwoColor(rrslider_thumb, widget_hover)
|
||||
|
||||
style.scrollbar.clear()
|
||||
style.scrollbar.left_bar = Frame(theme.OneOrTwoColor(rrscrollbar, widget), 6, 0)
|
||||
style.scrollbar.right_bar = Frame(theme.OneOrTwoColor(rrscrollbar, widget), 6, 0)
|
||||
style.scrollbar.hover_left_bar = Frame(theme.OneOrTwoColor(rrscrollbar, widget_hover), 6, 0)
|
||||
style.scrollbar.hover_right_bar = Frame(theme.OneOrTwoColor(rrscrollbar, widget_hover), 6, 0)
|
||||
style.scrollbar.thumb = Frame(theme.OneOrTwoColor(rrscrollbar_thumb, widget), 6, 0)
|
||||
style.scrollbar.hover_thumb = Frame(theme.OneOrTwoColor(rrscrollbar_thumb, widget_hover), 6, 0)
|
||||
style.scrollbar.left_gutter = 6
|
||||
style.scrollbar.right_gutter = 6
|
||||
style.scrollbar.ymaximum = 12
|
||||
style.scrollbar.thumb_offset = 6
|
||||
|
||||
style.vbar.xmaximum = rrvslider_width
|
||||
style.vbar.top_gutter = rrvslider_radius
|
||||
style.vbar.bottom_gutter = rrvslider_radius
|
||||
style.vbar.thumb_offset = -rrvslider_radius
|
||||
|
||||
style.vbar.bottom_bar = Frame(theme.OneOrTwoColor(rrvslider_full, widget), 0, rrvslider_radius * 2)
|
||||
style.vbar.top_bar = Frame(theme.OneOrTwoColor(rrvslider_empty, widget), 0, rrvslider_radius * 2)
|
||||
style.vbar.thumb = theme.OneOrTwoColor(rrvslider_thumb, widget)
|
||||
|
||||
style.vbar.hover_bottom_bar = Frame(theme.OneOrTwoColor(rrvslider_full, widget_hover), 0, rrvslider_radius * 2)
|
||||
style.vbar.hover_top_bar = Frame(theme.OneOrTwoColor(rrvslider_empty, widget_hover), 0, rrvslider_radius * 2)
|
||||
style.vbar.hover_thumb = theme.OneOrTwoColor(rrvslider_thumb, widget_hover)
|
||||
|
||||
style.vscrollbar.clear()
|
||||
style.vscrollbar.bar_invert = True
|
||||
style.vscrollbar.top_bar = Frame(theme.OneOrTwoColor(rrvscrollbar, widget), 0, 6)
|
||||
style.vscrollbar.bottom_bar = Frame(theme.OneOrTwoColor(rrvscrollbar, widget), 0, 6)
|
||||
style.vscrollbar.hover_top_bar = Frame(theme.OneOrTwoColor(rrvscrollbar, widget_hover), 0, 6)
|
||||
style.vscrollbar.hover_bottom_bar = Frame(theme.OneOrTwoColor(rrvscrollbar, widget_hover), 0, 6)
|
||||
style.vscrollbar.thumb = Frame(theme.OneOrTwoColor(rrvscrollbar_thumb, widget), 0, 6)
|
||||
style.vscrollbar.hover_thumb = Frame(theme.OneOrTwoColor(rrvscrollbar_thumb, widget_hover), 0, 6)
|
||||
style.vscrollbar.top_gutter = 6
|
||||
style.vscrollbar.bottom_gutter = 6
|
||||
style.vscrollbar.xmaximum = 12
|
||||
style.vscrollbar.thumb_offset = 6
|
||||
|
||||
style.prefs_slider.xmaximum=widget_width
|
||||
del style.prefs_slider.ymaximum
|
||||
|
||||
if centered:
|
||||
style.prefs_slider.xpos = 0.5
|
||||
style.prefs_slider.xanchor = 0.5
|
||||
else:
|
||||
style.prefs_slider.xpos = 1.0
|
||||
style.prefs_slider.xanchor = 1.0
|
||||
|
||||
style.soundtest_button.xminimum = 0
|
||||
|
||||
# Joystick
|
||||
|
||||
style.prefs_joystick.xmaximum = 600
|
||||
style.prefs_joystick.xpos = 0.5
|
||||
style.prefs_joystick.xanchor = 0.5
|
||||
style.prefs_js_button.background = RoundRect(widget, True)
|
||||
style.prefs_js_button.hover_background = RoundRect(widget_hover, True)
|
||||
style.prefs_js_button_text.drop_shadow = None
|
||||
style.prefs_js_button_text.size = small
|
||||
style.prefs_js_button.xminimum = 450
|
||||
|
||||
rrframe(style.js_frame)
|
||||
del style.js_frame.yminimum
|
||||
style.js_frame.ypadding = .05
|
||||
style.js_frame.xpadding = rrslider_radius
|
||||
style.js_frame.xmargin = .05
|
||||
style.js_frame.ypos = .1
|
||||
style.js_frame.yanchor = 0
|
||||
|
||||
style.js_function_label.xpos = 0.5
|
||||
style.js_function_label.xanchor = 0.5
|
||||
|
||||
style.js_prompt_label.xpos = 0.5
|
||||
style.js_prompt_label.xanchor = 0.5
|
||||
|
||||
# Yes/No
|
||||
|
||||
rrframe(style.yesno_frame)
|
||||
del style.yesno_frame.yminimum
|
||||
style.yesno_frame.ypadding = .05
|
||||
style.yesno_frame.xpadding = rrslider_radius
|
||||
style.yesno_frame.xmargin = .05
|
||||
style.yesno_frame.ypos = .1
|
||||
style.yesno_frame.yanchor = 0
|
||||
|
||||
style.yesno_label.color = label
|
||||
style.yesno_label.drop_shadow = None
|
||||
|
||||
# File Picker
|
||||
|
||||
rrframe(style.file_picker_frame)
|
||||
style.file_picker_frame.xmargin = 6
|
||||
style.file_picker_frame.ymargin = 6
|
||||
|
||||
style.file_picker_frame_vbox.box_spacing = 4
|
||||
style.file_picker_nav_button.xminimum = 0
|
||||
|
||||
style.file_picker_navbox.box_spacing = spacing
|
||||
del style.file_picker_navbox.xpos
|
||||
|
||||
style.file_picker_entry.background = RoundRect(widget, less_rounded)
|
||||
style.file_picker_entry.hover_background = RoundRect(widget_hover, less_rounded)
|
||||
style.file_picker_entry.xpadding = _roundrect_radius
|
||||
style.file_picker_entry.xmargin = 2
|
||||
|
||||
style.file_picker_text.size = small
|
||||
style.file_picker_text.drop_shadow = None
|
||||
style.file_picker_text.color = widget_text
|
||||
style.file_picker_new.color = widget_selected
|
||||
|
||||
style.file_picker_old.minwidth = 40
|
||||
style.file_picker_new.minwidth = 40
|
||||
|
||||
style.file_picker_old.text_align = 1.0
|
||||
style.file_picker_new.text_align = 1.0
|
||||
|
||||
if config.script_version is None or config.script_version > (6, 0, 0):
|
||||
style.file_picker_text.insensitive_color = disabled_text
|
||||
style.file_picker_entry.insensitive_background = RoundRect(disabled, less_rounded)
|
||||
|
||||
|
||||
config.file_quick_access_pages = 8
|
||||
|
||||
# In-game.
|
||||
|
||||
if rounded_window:
|
||||
|
||||
style.window.background = RoundRect(window, less_rounded)
|
||||
style.window.xpadding = 6
|
||||
style.window.ypadding = 6
|
||||
style.window.xmargin = 6
|
||||
style.window.ymargin = 6
|
||||
|
||||
else:
|
||||
|
||||
style.window.background = Solid(window)
|
||||
style.window.xpadding = 6
|
||||
style.window.ypadding = 6
|
||||
style.window.xmargin = 0
|
||||
style.window.ymargin = 0
|
||||
|
||||
|
||||
style.default.size = size
|
||||
style.default.drop_shadow = None
|
||||
|
||||
rrframe(style.frame)
|
||||
style.frame.xpadding = 6
|
||||
style.frame.ypadding = 6
|
||||
style.frame.xmargin = 6
|
||||
style.frame.ymargin = 6
|
||||
|
||||
if button_menu:
|
||||
_button_menu()
|
||||
|
||||
if launcher:
|
||||
style.launcher_mid_vbox.xpos = 80
|
||||
style.launcher_mid_vbox.ypos = 50
|
||||
|
||||
style.launcher_bottom_vbox.xpos = 80
|
||||
style.launcher_bottom_vbox.ypos = 360
|
||||
style.launcher_bottom_vbox.yanchor = 1.0
|
||||
|
||||
style.launcher_button.xpos = 20
|
||||
style.launcher_button.xminimum = 240
|
||||
|
||||
style.launcher_title_label.color = label
|
||||
style.launcher_title_label.size = 28
|
||||
|
||||
style.launcher_text.xpos = 140
|
||||
style.launcher_text.xanchor = 0.5
|
||||
style.launcher_text.xmaximum = 240
|
||||
style.launcher_text.color = label
|
||||
style.launcher_text.text_align = 0.5
|
||||
|
||||
|
||||
style.launcher_label.xpos = 140
|
||||
style.launcher_label.xanchor = 0.5
|
||||
style.launcher_label.xmaximum = 240
|
||||
style.launcher_label.color = label
|
||||
style.launcher_label.text_align = 0.5
|
||||
|
||||
style.launcher_input.xpos = 140
|
||||
style.launcher_input.xanchor = 0.5
|
||||
style.launcher_input.xmaximum = 240
|
||||
style.launcher_input.color = widget
|
||||
style.launcher_input.text_align = 0.5
|
||||
|
||||
store._launcher_per_page = 9
|
||||
|
||||
theme.roundrect = theme_roundrect
|
||||
|
||||
def theme_roundrect_red(**params):
|
||||
"""
|
||||
This sets up a red/pink variant of the roundrect theme.
|
||||
"""
|
||||
|
||||
args = dict(widget=(150, 50, 50, 255),
|
||||
widget_hover=(200, 50, 50, 255),
|
||||
widget_text=(255, 225, 225, 255),
|
||||
frame=(225, 115, 115, 192),
|
||||
mm_root=Solid((255, 225, 225, 255)),
|
||||
gm_root=Solid((255, 225, 225, 255)),
|
||||
)
|
||||
|
||||
args.update(params)
|
||||
theme.roundrect(**args)
|
||||
|
||||
theme.roundrect_red = theme_roundrect_red
|
||||
|
||||
@@ -1,584 +0,0 @@
|
||||
# This file contains code that helps support the development of Ren'Py
|
||||
# games.
|
||||
|
||||
screen _developer:
|
||||
|
||||
frame:
|
||||
style_group ""
|
||||
|
||||
align (.025, .05)
|
||||
|
||||
has vbox
|
||||
|
||||
label "Developer Menu"
|
||||
|
||||
textbutton _(u"Reload Game (Shift+R)"):
|
||||
action ui.callsinnewcontext("_save_reload_game")
|
||||
size_group "developer"
|
||||
textbutton _(u"Variable Viewer"):
|
||||
action Jump("_debugger_screen")
|
||||
size_group "developer"
|
||||
textbutton _(u"Theme Test"):
|
||||
action Jump("_theme_test")
|
||||
size_group "developer"
|
||||
textbutton _(u"Style Hierarchy"):
|
||||
action Jump("_style_hierarchy")
|
||||
size_group "developer"
|
||||
textbutton _(u"Image Location Picker"):
|
||||
action Jump("_image_location_picker")
|
||||
size_group "developer"
|
||||
textbutton _(u"Filename List"):
|
||||
action Jump("_filename_list")
|
||||
size_group "developer"
|
||||
|
||||
null height 15
|
||||
|
||||
textbutton _(u"Return"):
|
||||
action Return()
|
||||
size_group "developer"
|
||||
|
||||
label _developer_screen:
|
||||
|
||||
call screen _developer
|
||||
|
||||
return
|
||||
|
||||
label _debugger_screen:
|
||||
|
||||
python hide:
|
||||
|
||||
ui.window(style=style.gm_root)
|
||||
ui.null()
|
||||
|
||||
ui.frame(ymargin=10, xmargin=10, style=style.menu_frame)
|
||||
ui.side(['t', 'c', 'r', 'b'])
|
||||
|
||||
layout.label("Variable Viewer", None)
|
||||
|
||||
entries = [ ]
|
||||
|
||||
ebc = store.__dict__.ever_been_changed
|
||||
ebc = list(ebc)
|
||||
ebc.sort()
|
||||
|
||||
ebc.remove("nvl_list")
|
||||
|
||||
import repr
|
||||
aRepr = repr.Repr()
|
||||
aRepr.maxstring = 40
|
||||
|
||||
for var in ebc:
|
||||
if not hasattr(store, var):
|
||||
continue
|
||||
|
||||
if var.startswith("__00"):
|
||||
continue
|
||||
|
||||
if var.startswith("_") and not var.startswith("__"):
|
||||
continue
|
||||
|
||||
val = aRepr.repr(getattr(store, var))
|
||||
s = (var + " = " + val)
|
||||
s = s.replace("{", "{{")
|
||||
s = s.replace("[", "[[")
|
||||
entries.append((0, s))
|
||||
|
||||
if entries:
|
||||
vp = ui.viewport(mousewheel=True)
|
||||
layout.list(entries)
|
||||
ui.bar(adjustment=vp.yadjustment, style='vscrollbar')
|
||||
else:
|
||||
layout.prompt("No variables have changed since the game started.", None)
|
||||
ui.null()
|
||||
|
||||
layout.button(u"Return to the developer menu", None, clicked=ui.returns(True))
|
||||
|
||||
ui.close()
|
||||
|
||||
ui.interact()
|
||||
|
||||
jump _developer_screen
|
||||
|
||||
label _theme_test:
|
||||
|
||||
python hide:
|
||||
|
||||
# Never gets pickled
|
||||
def role(b):
|
||||
if b:
|
||||
return "selected_"
|
||||
else:
|
||||
return ""
|
||||
|
||||
toggle_var = True
|
||||
adj = ui.adjustment(100, 25, page=25, adjustable=True)
|
||||
|
||||
while True:
|
||||
|
||||
ui.window(style=style.gm_root)
|
||||
ui.null()
|
||||
|
||||
# Buttons
|
||||
ui.hbox(box_spacing=10, xpos=10, ypos=10)
|
||||
|
||||
ui.vbox(box_spacing=10)
|
||||
|
||||
sg = "theme_test"
|
||||
|
||||
ui.frame(style='menu_frame')
|
||||
ui.vbox()
|
||||
layout.label("Button", None)
|
||||
ui.textbutton("Button", size_group=sg, clicked=ui.returns("gndn"))
|
||||
ui.textbutton("Button (Selected)", size_group=sg, clicked=ui.returns("gndn"), role=role(True))
|
||||
ui.textbutton("Small", clicked=ui.returns("gndn"), style='small_button')
|
||||
ui.close()
|
||||
|
||||
ui.frame(style='menu_frame')
|
||||
ui.vbox()
|
||||
layout.label("Radio Button", None)
|
||||
ui.textbutton("True", size_group=sg, clicked=ui.returns("set"), role=role(toggle_var), style='radio_button')
|
||||
ui.textbutton("False", size_group=sg, clicked=ui.returns("unset"), role=role(not toggle_var), style='radio_button')
|
||||
ui.close()
|
||||
|
||||
ui.frame(style='menu_frame')
|
||||
ui.vbox()
|
||||
layout.label("Check Button", None)
|
||||
ui.textbutton("Check Button", size_group=sg, clicked=ui.returns("toggle"), role=role(toggle_var), style='check_button')
|
||||
ui.close()
|
||||
|
||||
ui.frame(style='menu_frame')
|
||||
ui.vbox(box_spacing=2)
|
||||
ui.bar(adjustment=adj, style='bar', xmaximum=200)
|
||||
ui.bar(adjustment=adj, style='slider', xmaximum=200)
|
||||
ui.bar(adjustment=adj, style='scrollbar', xmaximum=200)
|
||||
ui.close()
|
||||
|
||||
ui.close() # vbox
|
||||
|
||||
ui.frame(style='menu_frame')
|
||||
ui.hbox(box_spacing=2)
|
||||
ui.bar(adjustment=adj, style='vbar', ymaximum=200)
|
||||
ui.bar(adjustment=adj, style='vslider', ymaximum=200)
|
||||
ui.bar(adjustment=adj, style='vscrollbar', ymaximum=200)
|
||||
ui.close()
|
||||
|
||||
ui.frame(style='menu_frame', xmaximum=0.95)
|
||||
ui.vbox(box_spacing=20)
|
||||
layout.prompt("This is a prompt. We've made this text long enough to wrap around so it fills multiple lines.", None)
|
||||
ui.close()
|
||||
|
||||
ui.close() # hbox
|
||||
|
||||
ui.frame(style='menu_frame', xalign=.01, yalign=.99)
|
||||
ui.textbutton("Return to the developer menu", clicked=ui.returns("return"))
|
||||
|
||||
rv = ui.interact()
|
||||
if rv == "return":
|
||||
renpy.jump("_developer_screen")
|
||||
|
||||
elif rv == "set":
|
||||
toggle_var = True
|
||||
elif rv == "unset":
|
||||
toggle_var = False
|
||||
elif rv == "toggle":
|
||||
toggle_var = not toggle_var
|
||||
|
||||
label _style_hierarchy:
|
||||
|
||||
python hide:
|
||||
|
||||
ui.window(style=style.gm_root)
|
||||
ui.null()
|
||||
|
||||
ui.frame(ymargin=10, xmargin=10, style=style.menu_frame)
|
||||
ui.side(['t', 'c', 'r', 'b'], spacing=2)
|
||||
|
||||
layout.label("Style Hierarchy", None)
|
||||
|
||||
hier = renpy.style.style_hierarchy()
|
||||
|
||||
entries = [ (i[0], i[1] + " - " + str(i[2])) for i in hier if i[2] ]
|
||||
|
||||
vp = ui.viewport(mousewheel=True)
|
||||
layout.list(entries)
|
||||
ui.bar(adjustment=vp.yadjustment, style='vscrollbar')
|
||||
|
||||
layout.button(u"Return to the developer menu", None, clicked=ui.returns(True))
|
||||
|
||||
ui.close()
|
||||
|
||||
ui.interact()
|
||||
|
||||
jump _developer_screen
|
||||
|
||||
init -1050 python:
|
||||
config.missing_background = "black"
|
||||
|
||||
init 1050 python:
|
||||
|
||||
if config.developer:
|
||||
|
||||
# This is used to indicate that a scene has just occured,
|
||||
# and so if the next thing is a missing_show, we should
|
||||
# blank the screen.
|
||||
__missing_scene = False
|
||||
|
||||
# This returns the __missing dictionary from the current
|
||||
# context object.
|
||||
def __missing():
|
||||
try:
|
||||
return renpy.context().__missing
|
||||
except AttributeError:
|
||||
rv = dict()
|
||||
renpy.context().__missing = rv
|
||||
return rv
|
||||
|
||||
def __missing_show_callback(name, what, layer):
|
||||
if layer != 'master':
|
||||
return False
|
||||
|
||||
global __missing_scene
|
||||
if __missing_scene:
|
||||
renpy.show(name, what=config.missing_background)
|
||||
__missing_scene = False
|
||||
|
||||
what = " ".join(what).replace("{", "{{").replace("[", "[[")
|
||||
__missing()[name[0]] = what
|
||||
return True
|
||||
|
||||
def __missing_hide_callback(name, layer):
|
||||
if layer != 'master':
|
||||
return False
|
||||
|
||||
global __missing_scene
|
||||
__missing_scene = False
|
||||
|
||||
__missing().pop(name[0], None)
|
||||
return True
|
||||
|
||||
def __missing_scene_callback(layer):
|
||||
if layer != 'master':
|
||||
return False
|
||||
|
||||
global __missing_scene
|
||||
__missing_scene = True
|
||||
__missing().clear()
|
||||
|
||||
return True
|
||||
|
||||
def __missing_overlay():
|
||||
missing = __missing()
|
||||
|
||||
if not missing:
|
||||
return
|
||||
|
||||
ui.vbox(xalign=0.5, yalign=0.0)
|
||||
ui.text(_("Undefined Images"), xalign=0.5)
|
||||
|
||||
for what in sorted(missing.values()):
|
||||
ui.text(what, xalign=0.5)
|
||||
|
||||
ui.close()
|
||||
|
||||
|
||||
config.missing_scene = __missing_scene_callback
|
||||
config.missing_show = __missing_show_callback
|
||||
config.missing_hide = __missing_hide_callback
|
||||
config.overlay_functions.append(__missing_overlay)
|
||||
|
||||
init -1050 python:
|
||||
|
||||
class __FPSMeter(object):
|
||||
|
||||
def __init__(self):
|
||||
self.last_frames = None
|
||||
self.last_time = None
|
||||
|
||||
def __call__(self, st, at):
|
||||
|
||||
if self.last_time is not None:
|
||||
frames = config.frames - self.last_frames
|
||||
time = st - self.last_time
|
||||
|
||||
text = "FPS: %.1f" % (frames / time)
|
||||
|
||||
else:
|
||||
text = "FPS: --.-"
|
||||
|
||||
self.last_frames = config.frames
|
||||
self.last_time = st
|
||||
|
||||
return Text(text, xalign=1.0), .5
|
||||
|
||||
label _fps_meter:
|
||||
|
||||
python hide:
|
||||
def fps_overlay():
|
||||
ui.add(DynamicDisplayable(__FPSMeter()))
|
||||
|
||||
# We normally don't want to change this at runtime... but here
|
||||
# it's okay, because we don't want to save the FPS meter anyway.
|
||||
#
|
||||
# Do as I say, not as I do.
|
||||
config.overlay_functions.append(fps_overlay)
|
||||
|
||||
return
|
||||
|
||||
init python:
|
||||
|
||||
# This is a displayable that can keep track of the mouse coordinates,
|
||||
# and show them to the user.
|
||||
class __ImageLocationPicker(renpy.Displayable):
|
||||
|
||||
def __init__(self, fn, **kwargs):
|
||||
super(__ImageLocationPicker, self).__init__(**kwargs)
|
||||
|
||||
self.child = Image(fn)
|
||||
|
||||
self.mouse = None
|
||||
self.point1 = None
|
||||
self.point2 = None
|
||||
|
||||
def render(self, width, height, st, at):
|
||||
rv = renpy.Render(width, height)
|
||||
|
||||
cr = renpy.render(self.child, width, height, st, at)
|
||||
rv.blit(cr, (0, 0))
|
||||
|
||||
text = [ ]
|
||||
|
||||
|
||||
if self.point1 and self.point2 and not self.point1 == self.point2:
|
||||
x1, y1 = self.point1
|
||||
x2, y2 = self.point2
|
||||
|
||||
x1 = min(x1, cr.width)
|
||||
x2 = min(x2, cr.width)
|
||||
y1 = min(y1, cr.height)
|
||||
y2 = min(y2, cr.height)
|
||||
|
||||
minx = min(x1, x2)
|
||||
miny = min(y1, y2)
|
||||
maxx = max(x1, x2)
|
||||
maxy = max(y1, y2)
|
||||
|
||||
w = maxx - minx
|
||||
h = maxy - miny
|
||||
|
||||
if w and h:
|
||||
|
||||
sr = renpy.render(Solid("#0ff4"), w, h, st, at)
|
||||
rv.blit(sr, (minx, miny))
|
||||
|
||||
# text.append("Imagemap rectangle: %r" % ((minx, miny, maxx, maxy),))
|
||||
text.append("Rectangle: %r" % ((minx, miny, w, h),))
|
||||
|
||||
if self.mouse:
|
||||
mx, my = self.mouse
|
||||
if mx < cr.width and my < cr.height:
|
||||
text.append(_("Mouse position: %r") % (self.mouse,))
|
||||
|
||||
text.append(_("Right-click or escape to quit."))
|
||||
|
||||
td = Text("\n".join(text), size=14, color="#fff", outlines=[ (1, "#000", 0, 0 ) ])
|
||||
tr = renpy.render(td, width, height, st, at)
|
||||
|
||||
rv.blit(tr, (0, height - tr.height))
|
||||
|
||||
return rv
|
||||
|
||||
def event(self, ev, x, y, st):
|
||||
import pygame
|
||||
|
||||
self.mouse = (x, y)
|
||||
renpy.redraw(self, 0)
|
||||
|
||||
if ev.type == pygame.MOUSEBUTTONDOWN and ev.button == 1:
|
||||
self.point1 = (x, y)
|
||||
self.point2 = (x, y)
|
||||
|
||||
elif ev.type == pygame.MOUSEMOTION and ev.buttons[0]:
|
||||
self.point2 = (x, y)
|
||||
|
||||
elif ev.type == pygame.MOUSEBUTTONUP and ev.button == 1:
|
||||
self.point2 = (x, y)
|
||||
|
||||
|
||||
label _image_location_picker:
|
||||
|
||||
scene black
|
||||
|
||||
python hide:
|
||||
|
||||
image_files = [
|
||||
fn
|
||||
for dir, fn in renpy.loader.listdirfiles()
|
||||
if fn.lower().endswith(".jpg") or fn.lower().endswith(".png")
|
||||
if not fn[0] == "_"
|
||||
]
|
||||
|
||||
image_files.sort()
|
||||
|
||||
|
||||
xadjustment = ui.adjustment()
|
||||
yadjustment = ui.adjustment()
|
||||
|
||||
|
||||
while True:
|
||||
|
||||
ui.frame()
|
||||
ui.vbox()
|
||||
|
||||
layout.label(u"Image Location Picker", None)
|
||||
|
||||
ui.textbutton(_(u"Done"), clicked=ui.returns(False), size_group="files")
|
||||
|
||||
ui.side(['c', 'b', 'r'], spacing=5)
|
||||
vp = ui.viewport(xadjustment=xadjustment, yadjustment=yadjustment, mousewheel=True)
|
||||
|
||||
ui.vbox()
|
||||
|
||||
for fn in image_files:
|
||||
ui.button(clicked=ui.returns(fn), size_group="files", xminimum=1.0)
|
||||
ui.text(fn.replace("{", "{{").replace("[", "[["), style="button_text", xalign=0.0)
|
||||
|
||||
ui.close()
|
||||
|
||||
ui.bar(adjustment=xadjustment, style='scrollbar')
|
||||
ui.bar(adjustment=yadjustment, style='vscrollbar')
|
||||
ui.close()
|
||||
|
||||
ui.close()
|
||||
|
||||
rv = ui.interact()
|
||||
|
||||
if rv is False:
|
||||
renpy.jump("_developer_screen")
|
||||
|
||||
# Now, allow the user to pick the image.
|
||||
|
||||
ui.keymap(game_menu=ui.returns(True))
|
||||
ui.add(__ImageLocationPicker(rv))
|
||||
ui.interact()
|
||||
|
||||
|
||||
|
||||
# ...
|
||||
|
||||
renpy.jump("_image_location_picker")
|
||||
|
||||
label _filename_list:
|
||||
|
||||
python hide:
|
||||
import os
|
||||
f = file("files.txt", "w")
|
||||
|
||||
for dirname, dirs, files in os.walk(config.gamedir):
|
||||
|
||||
dirs.sort()
|
||||
files.sort()
|
||||
|
||||
for fn in files:
|
||||
fn = os.path.join(dirname, fn)
|
||||
fn = fn[len(config.gamedir) + 1:]
|
||||
print >>f, fn.encode("utf-8", "replace")
|
||||
print fn.encode("utf-8", "replace")
|
||||
|
||||
f.close()
|
||||
|
||||
renpy.launch_editor(["files.txt"], transient=1)
|
||||
|
||||
|
||||
jump _developer_screen
|
||||
|
||||
# The style inspector.
|
||||
screen _inspector:
|
||||
zorder 1010
|
||||
modal True
|
||||
|
||||
frame:
|
||||
style_group ""
|
||||
|
||||
xfill True
|
||||
yfill True
|
||||
|
||||
|
||||
has vbox
|
||||
|
||||
label _("Style Inspector")
|
||||
|
||||
null height 20
|
||||
|
||||
if not tree:
|
||||
text _("Nothing to inspect.")
|
||||
else:
|
||||
for depth, width, height, d in tree:
|
||||
$ t = ( " " * depth +
|
||||
u" \u2022 " +
|
||||
d.__class__.__name__ + " : " +
|
||||
"style=%s, " % (__format_style(d.style),) +
|
||||
"size=(%dx%d)" % (width, height) )
|
||||
|
||||
text "[t!q]"
|
||||
|
||||
null height 20
|
||||
|
||||
text _("(Click to continue.)")
|
||||
|
||||
python:
|
||||
ui.saybehavior()
|
||||
|
||||
init python:
|
||||
def _image_load_log_function(st, at):
|
||||
|
||||
ill = list(renpy.get_image_load_log(3))
|
||||
|
||||
if not ill:
|
||||
return Null(), .25
|
||||
|
||||
vbox = VBox()
|
||||
|
||||
for when, filename, preload in ill:
|
||||
if preload:
|
||||
color="#ffffff"
|
||||
else:
|
||||
color="#ffcccc"
|
||||
|
||||
vbox.add(Text(filename.replace("{", "{{").replace("[", "[["), size=12, color=color, style="_default"))
|
||||
|
||||
rv = Window(vbox, style="_frame", background="#0004", xpadding=5, ypadding=5, xminimum=200)
|
||||
return rv, .25
|
||||
|
||||
screen _image_load_log:
|
||||
zorder 1000
|
||||
|
||||
add DynamicDisplayable(_image_load_log_function)
|
||||
|
||||
|
||||
init python:
|
||||
|
||||
def __format_style(s):
|
||||
|
||||
while s:
|
||||
if s.name:
|
||||
break
|
||||
|
||||
if s.parent:
|
||||
s = style.get(s.parent)
|
||||
else:
|
||||
break
|
||||
|
||||
return s.name[0] + "".join([ "[%r]" % i for i in s.name[1:] ])
|
||||
|
||||
def __inspect(tree):
|
||||
renpy.context_dynamic("_window")
|
||||
store._window = False
|
||||
|
||||
renpy.exports.show_screen("_inspector", _transient=True, tree=tree)
|
||||
renpy.ui.interact(mouse="screen", type="screen", suppress_overlay=True, suppress_underlay=True)
|
||||
|
||||
config.inspector = __inspect
|
||||
|
||||
init python:
|
||||
config.underlay.append(im.Tile("_transparent_tile.png"))
|
||||
|
||||
@@ -1,488 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
#
|
||||
# This file contains the code for in-game Ren'Py error handling. It's a
|
||||
# module (as opposed to a .rpy file) because that allows us to ensure
|
||||
# that it is fully loaded or run before any other Ren'Py code runs.
|
||||
|
||||
|
||||
|
||||
# These styles define the look of the Ren'Py in-game interface (the
|
||||
# amie2-inspired look). They're also used in the launcher.
|
||||
init python:
|
||||
# default
|
||||
style._default = Style(None)
|
||||
|
||||
# Temporarily, until the real styles can be defined.
|
||||
style.default = style._default
|
||||
style.image = style._default
|
||||
style.fixed = style._default
|
||||
|
||||
style._default.font = "DejaVuSans.ttf"
|
||||
style._default.language = "unicode"
|
||||
style._default.antialias = True
|
||||
style._default.size = 14
|
||||
style._default.color = "#111"
|
||||
style._default.black_color = (0, 0, 0, 255)
|
||||
style._default.bold = False
|
||||
style._default.italic = False
|
||||
style._default.underline = False
|
||||
style._default.strikethrough = False
|
||||
style._default.kerning = 0.0
|
||||
style._default.drop_shadow = None
|
||||
style._default.drop_shadow_color = (0, 0, 0, 255)
|
||||
style._default.outlines = [ ]
|
||||
style._default.minwidth = 0
|
||||
style._default.text_align = 0
|
||||
style._default.justify = False
|
||||
style._default.text_y_fudge = 0
|
||||
style._default.first_indent = 0
|
||||
style._default.rest_indent = 0
|
||||
style._default.line_spacing = 0
|
||||
style._default.line_leading = 0
|
||||
style._default.line_overlap_split = 0
|
||||
style._default.layout = "tex"
|
||||
style._default.subtitle_width = 0.9
|
||||
style._default.slow_cps = None
|
||||
style._default.slow_cps_multiplier = 1.0
|
||||
style._default.slow_abortable = False
|
||||
|
||||
# Window properties.
|
||||
style._default.background = None
|
||||
style._default.xpadding = 0
|
||||
style._default.ypadding = 0
|
||||
style._default.xmargin = 0
|
||||
style._default.ymargin = 0
|
||||
style._default.xfill = False
|
||||
style._default.yfill = False
|
||||
style._default.xminimum = 0 # Includes margins and padding.
|
||||
style._default.yminimum = 0 # Includes margins and padding.
|
||||
|
||||
# Placement properties.
|
||||
style._default.xpos = None # 0
|
||||
style._default.ypos = None # 0
|
||||
style._default.xanchor = None # 0
|
||||
style._default.yanchor = None # 0
|
||||
style._default.xmaximum = None
|
||||
style._default.ymaximum = None
|
||||
style._default.xoffset = 0
|
||||
style._default.yoffset = 0
|
||||
style._default.subpixel = False
|
||||
|
||||
# Sound properties.
|
||||
style._default.sound = None
|
||||
|
||||
# Box properties.
|
||||
style._default.spacing = 0
|
||||
style._default.first_spacing = None
|
||||
style._default.box_layout = None
|
||||
style._default.box_wrap = False
|
||||
|
||||
# Focus properties.
|
||||
style._default.focus_mask = None
|
||||
style._default.focus_rect = None
|
||||
|
||||
# Bar properties.
|
||||
style._default.fore_bar = Null()
|
||||
style._default.aft_bar = Null()
|
||||
style._default.thumb = None
|
||||
style._default.thumb_shadow = None
|
||||
style._default.left_gutter = 0
|
||||
style._default.right_gutter = 0
|
||||
style._default.thumb_offset = 0
|
||||
style._default.unscrollable = None
|
||||
style._default.bar_invert = False
|
||||
style._default.bar_vertical = False
|
||||
|
||||
# Misc.
|
||||
style._default.activate_sound = None
|
||||
style._default.clipping = False
|
||||
|
||||
##########################################################################
|
||||
|
||||
# frame
|
||||
style._frame = Style(style._default)
|
||||
style._frame.background = Frame("_theme_amie2/frame.png", 40, 40)
|
||||
style._frame.xmargin = 0
|
||||
style._frame.ymargin = 0
|
||||
style._frame.xpadding = 15
|
||||
style._frame.ypadding = 10
|
||||
|
||||
# text
|
||||
style._text = Style(style._default)
|
||||
|
||||
# boxes/boxlike
|
||||
style._fixed = Style(style._default)
|
||||
style._hbox = Style(style._default)
|
||||
style._vbox = Style(style._default)
|
||||
style._grid = Style(style._default)
|
||||
style._side = Style(style._default)
|
||||
style._viewport = Style(style._default)
|
||||
|
||||
style._hbox.box_layout = 'horizontal'
|
||||
style._vbox.box_layout = 'vertical'
|
||||
style._viewport.clipping = True
|
||||
|
||||
# button
|
||||
style._button = Style(style._default)
|
||||
style._button_text = Style(style._default)
|
||||
style._button.xpadding = 8
|
||||
style._button.ypadding = 6
|
||||
style._button.xoffset = -5
|
||||
|
||||
style._button.background = Frame("_theme_amie2/button.png", 10, 10)
|
||||
style._button.hover_background = Frame("_theme_amie2/button_hover.png", 10, 10)
|
||||
style._button_text.size = 16
|
||||
style._button_text.color = "#111"
|
||||
style._button_text.selected_color = "#11f"
|
||||
style._button_text.insensitive_color = "#ccc"
|
||||
style._button_text.xalign = 0.5
|
||||
style._button_text.yoffset = 0
|
||||
|
||||
# label
|
||||
style._label = Style(style._default)
|
||||
style._label_text = Style(style._default)
|
||||
|
||||
style._label.top_margin = 10
|
||||
style._label.bottom_margin = 5
|
||||
|
||||
style._label_text.color = "#000"
|
||||
style._label_text.bold = True
|
||||
|
||||
# bar
|
||||
style._bar = Style(style._default)
|
||||
|
||||
style._bar.left_bar = Frame("_theme_amie2/hover_frame.png", 10, 10)
|
||||
style._bar.right_bar = Frame("_theme_amie2/bar.png", 10, 10)
|
||||
style._bar.thumb = None
|
||||
style._bar.hover_thumb = None
|
||||
style._bar.ymaximum = 20
|
||||
|
||||
style._scrollbar = Style(style._default)
|
||||
style._vscrollbar = Style(style._default)
|
||||
|
||||
style._scrollbar.left_bar = Frame("_theme_amie2/bar.png", 10, 10)
|
||||
style._scrollbar.right_bar = Frame("_theme_amie2/bar.png", 10, 10)
|
||||
style._scrollbar.thumb = Frame("_theme_amie2/frame.png", 10, 10)
|
||||
style._scrollbar.hover_thumb = Frame("_theme_amie2/hover_frame.png", 10, 10)
|
||||
style._scrollbar.thumb_offset = 10
|
||||
style._scrollbar.left_gutter = 5
|
||||
style._scrollbar.right_gutter = 5
|
||||
style._scrollbar.unscrollable = "hide"
|
||||
|
||||
style._scrollbar.ymaximum = 20
|
||||
style._vscrollbar.xmaximum = 20
|
||||
style._vscrollbar.bar_vertical = True
|
||||
style._vscrollbar.bar_invert = True
|
||||
|
||||
style._hyperlink = Style(style._default)
|
||||
style._hyperlink.color = "#008"
|
||||
style._hyperlink.hover_underline = True
|
||||
|
||||
# Early hyperlink support.
|
||||
init python hide:
|
||||
def hyperlink_styler(target):
|
||||
return style._hyperlink
|
||||
|
||||
def hyperlink_function(target):
|
||||
if target.startswith("http:"):
|
||||
try:
|
||||
import webbrowser
|
||||
webbrowser.open(target)
|
||||
except:
|
||||
pass
|
||||
|
||||
if target.startswith("edit:"):
|
||||
prefix, line, filename = target.split(":", 2)
|
||||
line = int(line)
|
||||
|
||||
renpy.launch_editor([ filename ], line)
|
||||
|
||||
style._default.hyperlink_functions = (hyperlink_styler, hyperlink_function, None)
|
||||
|
||||
init python:
|
||||
|
||||
# Null translation function. This gets redefined once things start
|
||||
# successfully.
|
||||
def _(s):
|
||||
return s
|
||||
|
||||
# This function is responsible for taking a traceback, and converting
|
||||
# it to a string that can be shown with text.
|
||||
def __format_traceback(s):
|
||||
import re
|
||||
|
||||
lines = [ i.replace("{", "{{") for i in s.split("\n") ]
|
||||
|
||||
rv = [ "{b}" + lines[0] + "{/b}" ]
|
||||
|
||||
for i in lines[1:]:
|
||||
i = re.sub(r'(File "(.*)", line (\d+))', r'{a=edit:\3:\2}\1{/a}', i)
|
||||
rv.append(i)
|
||||
|
||||
return "\n".join(rv)
|
||||
|
||||
|
||||
def __format_parse_errors(s):
|
||||
import re
|
||||
|
||||
rv = ""
|
||||
|
||||
lines = s.split("\n")
|
||||
len_lines = len(lines)
|
||||
|
||||
ln = 0
|
||||
|
||||
while ln < len_lines:
|
||||
line = lines[ln]
|
||||
ln += 1
|
||||
|
||||
if ln < len_lines and lines[ln].endswith("^"):
|
||||
highlight = len(lines[ln]) - 1
|
||||
ln += 1
|
||||
else:
|
||||
highlight = -1
|
||||
|
||||
pos = 0
|
||||
|
||||
for c in line:
|
||||
if pos == highlight:
|
||||
rv += u"{color=#c00}\u2192{/color}"
|
||||
highlight = -1
|
||||
|
||||
pos += 1
|
||||
|
||||
if c == "{":
|
||||
rv += "{{"
|
||||
else:
|
||||
rv += c
|
||||
|
||||
if highlight > 0:
|
||||
rv += u"{color=#c00}\u2190{/color}"
|
||||
|
||||
rv += "\n"
|
||||
|
||||
|
||||
rv = re.sub(r'(File "(.*)", line (\d+))', r'{a=edit:\3:\2}\1{/a}', rv)
|
||||
|
||||
return rv
|
||||
|
||||
class __EditFile(Action):
|
||||
def __init__(self, filename):
|
||||
self.filename = filename
|
||||
|
||||
def __call__(self):
|
||||
try:
|
||||
renpy.launch_editor([ self.filename ], 1, transient=1)
|
||||
except:
|
||||
pass
|
||||
|
||||
def __can_open_traceback():
|
||||
return True
|
||||
|
||||
# The transform used for errors. ATL isn't ready yet.
|
||||
def __transform_function(state, st, at):
|
||||
done = min(st / .1, 1.0)
|
||||
state.zoom = .5 + .5 * done
|
||||
state.alpha = done
|
||||
state.xalign = 0.5
|
||||
state.yalign = 0.5
|
||||
|
||||
if done < 1.0:
|
||||
return 0
|
||||
else:
|
||||
return None
|
||||
|
||||
__transform = Transform(function=__transform_function, style='_default')
|
||||
|
||||
class __TooltipAction(object):
|
||||
|
||||
def __init__(self, tooltip, value):
|
||||
self.tooltip = tooltip
|
||||
self.value = value
|
||||
|
||||
def __call__(self):
|
||||
if self.tooltip.value != self.value:
|
||||
self.tooltip.value = self.value
|
||||
renpy.restart_interaction()
|
||||
|
||||
def unhovered(self):
|
||||
if self.tooltip.value != self.tooltip.default:
|
||||
self.tooltip.value = self.tooltip.default
|
||||
renpy.restart_interaction()
|
||||
|
||||
class __Tooltip(object):
|
||||
def __init__(self, default):
|
||||
self.value = default
|
||||
self.default = default
|
||||
|
||||
def action(self, value):
|
||||
return __TooltipAction(self, value)
|
||||
|
||||
class __XScrollValue(BarValue):
|
||||
def __init__(self, viewport):
|
||||
self.viewport = viewport
|
||||
|
||||
def get_adjustment(self):
|
||||
w = renpy.get_widget(None, self.viewport)
|
||||
if not isinstance(w, Viewport):
|
||||
raise Exception("The displayable with id %r is not declared, or not a viewport." % self.viewport)
|
||||
|
||||
return w.xadjustment
|
||||
|
||||
def get_style(self):
|
||||
return "scrollbar", "vscrollbar"
|
||||
|
||||
class __YScrollValue(BarValue):
|
||||
def __init__(self, viewport):
|
||||
self.viewport = viewport
|
||||
|
||||
def get_adjustment(self):
|
||||
w = renpy.get_widget(None, self.viewport)
|
||||
if not isinstance(w, Viewport):
|
||||
raise Exception("The displayable with id %r is not declared, or not a viewport." % self.viewport)
|
||||
|
||||
return w.yadjustment
|
||||
|
||||
def get_style(self):
|
||||
return "scrollbar", "vscrollbar"
|
||||
|
||||
|
||||
# The screen that is used for error handling.
|
||||
screen _exception:
|
||||
modal True
|
||||
zorder 1090
|
||||
|
||||
default tt = __Tooltip("")
|
||||
default fmt_short = __format_traceback(short)
|
||||
default fmt_full = __format_traceback(full)
|
||||
|
||||
add Solid("#000")
|
||||
|
||||
frame:
|
||||
style_group ""
|
||||
xfill True
|
||||
|
||||
at __transform
|
||||
|
||||
has side "t c r b"
|
||||
|
||||
vbox:
|
||||
label _("An exception has occurred.")
|
||||
|
||||
viewport:
|
||||
id "viewport"
|
||||
child_size (4000, None)
|
||||
mousewheel True
|
||||
|
||||
has vbox
|
||||
|
||||
text fmt_short substitute False
|
||||
text fmt_full substitute False
|
||||
|
||||
bar:
|
||||
style "_vscrollbar"
|
||||
value __YScrollValue("viewport")
|
||||
|
||||
vbox:
|
||||
|
||||
bar:
|
||||
style "_scrollbar"
|
||||
value __XScrollValue("viewport")
|
||||
|
||||
hbox:
|
||||
box_wrap True
|
||||
|
||||
if rollback_action:
|
||||
textbutton _("Rollback"):
|
||||
action rollback_action
|
||||
hovered tt.action(_("Attempts a roll back to a prior time, allowing you to save or choose a different choice."))
|
||||
|
||||
if ignore_action:
|
||||
textbutton _("Ignore"):
|
||||
action ignore_action
|
||||
hovered tt.action(_("Ignores the exception, allowing you to continue. This often leads to additional errors."))
|
||||
|
||||
if config.developer:
|
||||
textbutton _("Reload"):
|
||||
action reload_action
|
||||
hovered tt.action(_("Reloads the game from disk, saving and restoring game state if possible."))
|
||||
|
||||
textbutton _("Open Traceback"):
|
||||
action __EditFile(traceback_fn)
|
||||
hovered tt.action(_("Opens the traceback.txt file in a text editor."))
|
||||
|
||||
null width 30
|
||||
|
||||
textbutton _("Quit"):
|
||||
action renpy.quit
|
||||
hovered tt.action(_("Quits the game."))
|
||||
|
||||
# Tooltip.
|
||||
text tt.value size 12
|
||||
|
||||
if config.developer and reload_action:
|
||||
key "R" action reload_action
|
||||
|
||||
# The screen that is used for error handling.
|
||||
screen _parse_errors:
|
||||
modal True
|
||||
zorder 1090
|
||||
|
||||
default tt = __Tooltip("")
|
||||
default fmt_errors = __format_parse_errors(errors)
|
||||
|
||||
add Solid("#000")
|
||||
|
||||
frame:
|
||||
style_group ""
|
||||
xfill True
|
||||
|
||||
at __transform
|
||||
|
||||
has side "t c r b"
|
||||
|
||||
vbox:
|
||||
label _("Parsing the script failed.")
|
||||
|
||||
viewport:
|
||||
id "viewport"
|
||||
child_size (None, None)
|
||||
mousewheel True
|
||||
|
||||
has vbox
|
||||
text fmt_errors substitute False
|
||||
|
||||
bar:
|
||||
style "_vscrollbar"
|
||||
value __YScrollValue("viewport")
|
||||
|
||||
vbox:
|
||||
|
||||
bar:
|
||||
style "_scrollbar"
|
||||
value __XScrollValue("viewport")
|
||||
|
||||
hbox:
|
||||
box_wrap True
|
||||
|
||||
textbutton _("Reload"):
|
||||
action reload_action
|
||||
hovered tt.action(_("Reloads the game from disk, saving and restoring game state if possible."))
|
||||
|
||||
textbutton _("Open Parse Errors"):
|
||||
action __EditFile(error_fn)
|
||||
hovered tt.action(_("Opens the errors.txt file in a text editor."))
|
||||
|
||||
null width 30
|
||||
|
||||
textbutton _("Quit"):
|
||||
action renpy.quit
|
||||
hovered tt.action(_("Quits the game."))
|
||||
|
||||
# Tooltip.
|
||||
text tt.value size 12
|
||||
|
||||
if config.developer and reload_action:
|
||||
key "R" action reload_action
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('joystick_preferences')
|
||||
|
||||
style.js_frame = Style(style.menu_frame, help="frame used for changing a joystick binding")
|
||||
style.js_frame_box = Style(style.vbox, help="vbox used for changing a joystick binding")
|
||||
style.js_function_prompt = Style(style.prompt, help="the name of the joystick binding to change (window)")
|
||||
style.js_function_prompt_text = Style(style.prompt_text, help="the name of the joystick binding to change (text)")
|
||||
style.js_action_prompt = Style(style.prompt, help="prompting the user how to change a joystick binding (window)")
|
||||
style.js_action_prompt_text = Style(style.prompt_text, help="prompting the user how to change a joystick binding (text)")
|
||||
|
||||
style.js_prefs_frame = Style(style.menu_frame, help="frame containing all joystick bindings")
|
||||
style.js_prefs_box = Style(style.vbox, help="box containing all joystick bindings")
|
||||
style.js_prefs_button = Style(style.button, help="button containing a joystick binding")
|
||||
style.js_prefs_button_text = Style(style.button_text, help="button containing a joystick binding (text)")
|
||||
|
||||
style.js_prefs_label = Style(style.label, help="joystick preferences label (window)")
|
||||
style.js_prefs_label_text = Style(style.label_text, help="joystick preferences label (text)")
|
||||
|
||||
style.js_frame.ypos = .1
|
||||
style.js_frame.ypadding = .05
|
||||
style.js_frame.xmargin = .1
|
||||
style.js_frame_box.box_spacing = 30
|
||||
|
||||
style.js_prefs_frame.xpos = 10
|
||||
style.js_prefs_frame.ypos = 10
|
||||
|
||||
style.js_prefs_button.xminimum = 0.5
|
||||
style.js_prefs_box.box_first_spacing = 10
|
||||
|
||||
config.joystick_keys = [
|
||||
(u'Left', 'joy_left'),
|
||||
(u'Right', 'joy_right'),
|
||||
(u'Up', 'joy_up'),
|
||||
(u'Down', 'joy_down'),
|
||||
(u'Select/Dismiss', 'joy_dismiss'),
|
||||
(u'Rollback', 'joy_rollback'),
|
||||
(u'Hold to Skip', 'joy_holdskip'),
|
||||
(u'Toggle Skip', 'joy_toggleskip'),
|
||||
(u'Hide Text', 'joy_hide'),
|
||||
(u'Menu', 'joy_menu'),
|
||||
]
|
||||
|
||||
def _joystick_select_binding():
|
||||
|
||||
for label, key in config.joystick_keys:
|
||||
|
||||
def my_clicked(label=label, key=key):
|
||||
return (label, key)
|
||||
|
||||
layout.button(_(label) + " - " + _(_preferences.joymap.get(key, u"Not Assigned")), "prefs_js", clicked=my_clicked, index=label)
|
||||
|
||||
def _joystick_get_binding():
|
||||
ui.saybehavior()
|
||||
ui.add(renpy.display.joystick.JoyBehavior())
|
||||
|
||||
def _joystick_take_binding(binding, key):
|
||||
|
||||
if not isinstance(binding, basestring):
|
||||
if key in _preferences.joymap:
|
||||
del _preferences.joymap[key]
|
||||
else:
|
||||
_preferences.joymap[key] = binding
|
||||
|
||||
|
||||
def _joystick_preferences():
|
||||
|
||||
def set_binding(label, key):
|
||||
layout.navigation(None)
|
||||
|
||||
ui.window(style='js_frame')
|
||||
ui.vbox(style='js_frame_box')
|
||||
layout.prompt(_(u"Joystick Mapping") + " - " + _(label), "js_function")
|
||||
layout.prompt(u'Move the joystick or press a joystick button to create the mapping. Click the mouse to remove the mapping.', 'js_action')
|
||||
ui.close()
|
||||
|
||||
_joystick_get_binding()
|
||||
binding = ui.interact(mouse="gamemenu")
|
||||
_joystick_take_binding(binding, key)
|
||||
|
||||
return True
|
||||
|
||||
ui.window(style='js_prefs_frame')
|
||||
ui.vbox(style='js_prefs_box')
|
||||
|
||||
layout.label("Joystick Configuration", "js_prefs")
|
||||
|
||||
for label, key in config.joystick_keys:
|
||||
|
||||
def clicked(label=label, key=key):
|
||||
return renpy.invoke_in_new_context(set_binding, label, key)
|
||||
|
||||
layout.button(_(label) + " - " + _(_preferences.joymap.get(key, u"Not Assigned")), "js_prefs", clicked=clicked, index=label)
|
||||
|
||||
ui.close()
|
||||
|
||||
label joystick_preferences_screen:
|
||||
|
||||
while True:
|
||||
python:
|
||||
layout.navigation("joystick_preferences")
|
||||
_joystick_preferences()
|
||||
ui.interact(mouse="gamemenu")
|
||||
|
||||
|
||||
|
||||
@@ -1,353 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('load_save')
|
||||
|
||||
# Define styles
|
||||
style.file_picker_entry = Style(style.large_button, help="used to select a file to load or save")
|
||||
style.file_picker_entry_box = Style(style.hbox, help="the box inside a file picker entry")
|
||||
|
||||
style.file_picker_text = Style(style.large_button_text, help="text inside a file picker entry")
|
||||
style.file_picker_empty_slot = Style(style.file_picker_text, help="text inside an empty file picker entry slot")
|
||||
style.file_picker_extra_info = Style(style.file_picker_text)
|
||||
style.file_picker_new = Style(style.file_picker_text)
|
||||
style.file_picker_old = Style(style.file_picker_text)
|
||||
|
||||
style.file_picker_frame = Style(style.menu_frame, help="the frame enclosing the entire file picker")
|
||||
style.file_picker_frame_box = Style(style.vbox, help="the box containing the navbox and the grid of file picker entries")
|
||||
|
||||
style.file_picker_navbox = Style(style.hbox, help="the box containing navigation buttons")
|
||||
|
||||
style.file_picker_nav_button = Style(style.small_button, help="a file picker navigation button")
|
||||
style.file_picker_nav_button_text = Style(style.small_button_text, help="file picker navigation button text")
|
||||
|
||||
style.file_picker_grid = Style(style.default, help="a grid containing file picker navigation buttons")
|
||||
|
||||
# Adjust styles.
|
||||
style.file_picker_entry.xminimum = 0.5
|
||||
|
||||
style.file_picker_frame.xmargin = 6
|
||||
style.file_picker_frame.ymargin = 6
|
||||
|
||||
style.file_picker_frame_box.box_spacing = 4
|
||||
style.file_picker_entry_box.box_spacing = 4
|
||||
|
||||
# The number of columns per page of files.
|
||||
config.file_page_cols = 2
|
||||
|
||||
if config.screen_width <= 640:
|
||||
# The number of rows per page of files.
|
||||
config.file_page_rows = 4
|
||||
|
||||
# The number of quick access pages.
|
||||
config.file_quick_access_pages = 6
|
||||
else:
|
||||
config.file_page_rows = 5
|
||||
config.file_quick_access_pages = 8
|
||||
|
||||
# True if we want to disable the file pager.
|
||||
config.disable_file_pager = False
|
||||
|
||||
# True to suppress the display of thumbnails.
|
||||
config.disable_thumbnails = False
|
||||
|
||||
# The default thumbnail to use when no file exists.
|
||||
config.load_save_empty_thumbnail = None
|
||||
|
||||
# How we format time in a file entry.
|
||||
config.time_format = "%b %d, %H:%M"
|
||||
|
||||
# How we format a file entry.
|
||||
config.file_entry_format = "%(time)s\n%(save_name)s"
|
||||
|
||||
# True if we should prompt before loading a game.
|
||||
_load_prompt = True
|
||||
|
||||
# This is used to store scratch data that's used by the
|
||||
# library, but shouldn't be saved out as part of the savegame.
|
||||
__scratch = object()
|
||||
__scratch.file_picker_page = None
|
||||
|
||||
def _render_savefile(index, name, extra_info, screenshot, mtime, newest, clicked):
|
||||
|
||||
import time
|
||||
|
||||
ui.button(style=style.file_picker_entry[index],
|
||||
clicked=clicked,
|
||||
role=("selected_" if newest else ""),
|
||||
keymap={ "save_delete" : ui.returns(("unlink", name)) }
|
||||
)
|
||||
|
||||
ui.hbox(style=style.file_picker_entry_box[index])
|
||||
|
||||
if not config.disable_thumbnails:
|
||||
ui.add(screenshot)
|
||||
|
||||
if newest:
|
||||
ui.text(name + ". ", style=style.file_picker_new[index])
|
||||
else:
|
||||
ui.text(name + ". ", style=style.file_picker_old[index])
|
||||
|
||||
s = config.file_entry_format % dict(
|
||||
time=time.strftime(config.time_format,
|
||||
time.localtime(mtime)),
|
||||
save_name=extra_info)
|
||||
|
||||
ui.text(s, style=style.file_picker_extra_info[index])
|
||||
|
||||
ui.close()
|
||||
|
||||
def _render_new_slot(index, name, clicked):
|
||||
|
||||
ui.button(style=style.file_picker_entry[index],
|
||||
clicked=clicked)
|
||||
|
||||
|
||||
ui.hbox(style=style.file_picker_entry_box[index])
|
||||
|
||||
if not config.disable_thumbnails:
|
||||
|
||||
if config.load_save_empty_thumbnail:
|
||||
ui.add(config.load_save_empty_thumbnail)
|
||||
else:
|
||||
ui.null(width=config.thumbnail_width,
|
||||
height=config.thumbnail_height)
|
||||
|
||||
ui.text(name + ". ", style=style.file_picker_old[index])
|
||||
|
||||
ui.text(_(u"Empty Slot."), style=style.file_picker_empty_slot[index])
|
||||
ui.close()
|
||||
|
||||
|
||||
# Returns the names of the various pages that the file picker knows
|
||||
# about.
|
||||
def _file_picker_pages():
|
||||
|
||||
rv = [ ]
|
||||
|
||||
if config.has_autosave:
|
||||
rv.append(u"Auto")
|
||||
|
||||
if config.has_quicksave:
|
||||
rv.append(u"Quick")
|
||||
|
||||
for i in range(1, config.file_quick_access_pages + 1):
|
||||
rv.append(str(i))
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
# This function is given a page, and should map it to the names
|
||||
# of the files on that page.
|
||||
def _file_picker_page_files(page):
|
||||
|
||||
per_page = config.file_page_cols * config.file_page_rows
|
||||
rv = [ ]
|
||||
|
||||
if config.has_autosave:
|
||||
if page == 0:
|
||||
for i in range(1, per_page + 1):
|
||||
rv.append(("auto-" + str(i), _(u"a") + str(i), True))
|
||||
|
||||
return rv
|
||||
else:
|
||||
page -= 1
|
||||
|
||||
if config.has_quicksave:
|
||||
if page == 0:
|
||||
for i in range(1, per_page + 1):
|
||||
rv.append(("quick-" + str(i), _(u"q") + str(i), True))
|
||||
|
||||
return rv
|
||||
else:
|
||||
page -= 1
|
||||
|
||||
for i in range(per_page * page + 1, per_page * page + 1 + per_page):
|
||||
rv.append(("%d" % i, "%d" % i, False))
|
||||
|
||||
return rv
|
||||
|
||||
# Given a filename, returns the page that filename is on.
|
||||
def _file_picker_file_page(filename):
|
||||
|
||||
per_page = config.file_page_cols * config.file_page_rows
|
||||
|
||||
base = 0
|
||||
|
||||
if config.has_autosave:
|
||||
if filename.startswith("auto-"):
|
||||
return base
|
||||
else:
|
||||
base += 1
|
||||
|
||||
if config.has_quicksave:
|
||||
if filename.startswith("quick-"):
|
||||
return base
|
||||
else:
|
||||
base += 1
|
||||
|
||||
try:
|
||||
return base + int((int(filename) - 1) / per_page)
|
||||
except:
|
||||
return base
|
||||
|
||||
# Processes a screenshot.
|
||||
def _file_picker_process_screenshot(s):
|
||||
return s
|
||||
|
||||
# This displays a file picker that can chose a save file from
|
||||
# the list of save files.
|
||||
def _file_picker(screen, save):
|
||||
|
||||
# Should we update the list of saved games?
|
||||
update = True
|
||||
|
||||
while True:
|
||||
|
||||
|
||||
if update:
|
||||
|
||||
update = False
|
||||
|
||||
# The number of slots in a page.
|
||||
file_page_length = config.file_page_cols * config.file_page_rows
|
||||
|
||||
# The list of saved games.
|
||||
saved_games = renpy.list_saved_games(regexp=r'(auto-|quick-)?[0-9]+')
|
||||
|
||||
# Figure out which game is the newest and so on.
|
||||
newest = None
|
||||
newest_mtime = None
|
||||
save_info = { }
|
||||
|
||||
for fn, extra_info, screenshot, mtime in saved_games:
|
||||
screenshot = _file_picker_process_screenshot(screenshot)
|
||||
save_info[fn] = (extra_info, screenshot, mtime)
|
||||
|
||||
if not fn.startswith("auto-") and mtime > newest_mtime:
|
||||
newest = fn
|
||||
newest_mtime = mtime
|
||||
|
||||
# The index of the first entry in the page.
|
||||
fpp = __scratch.file_picker_page
|
||||
|
||||
if fpp is None:
|
||||
if newest:
|
||||
fpp = _file_picker_file_page(newest)
|
||||
else:
|
||||
fpp = _file_picker_file_page("1")
|
||||
|
||||
|
||||
if fpp < 0:
|
||||
fpp = 0
|
||||
|
||||
__scratch.file_picker_page = fpp
|
||||
|
||||
# Show navigation
|
||||
layout.navigation(screen)
|
||||
|
||||
ui.window(style='file_picker_frame')
|
||||
ui.vbox(style='file_picker_frame_box') # whole thing.
|
||||
|
||||
if not config.disable_file_pager:
|
||||
|
||||
# Draw the navigation.
|
||||
ui.hbox(style='file_picker_navbox') # nav buttons.
|
||||
|
||||
def tb(cond, label, clicked, selected):
|
||||
layout.button(label,
|
||||
"file_picker_nav",
|
||||
enabled=cond,
|
||||
clicked=clicked,
|
||||
selected=selected)
|
||||
|
||||
# Previous
|
||||
tb(fpp > 0, u'Previous', ui.returns(("fppdelta", -1)), selected=False)
|
||||
|
||||
# Quick Access
|
||||
for i, name in enumerate(_file_picker_pages()):
|
||||
tb(True, name, ui.returns(("fppset", i)), fpp == i)
|
||||
|
||||
# Next
|
||||
tb(True, u'Next', ui.returns(("fppdelta", +1)), False)
|
||||
|
||||
ui.close()
|
||||
|
||||
# This draws a single slot.
|
||||
def entry(name, filename, offset, ro):
|
||||
clicked = ui.returns(("return", filename))
|
||||
|
||||
if filename not in save_info:
|
||||
if (not save) or ro:
|
||||
clicked = None
|
||||
|
||||
_render_new_slot(offset, name, clicked)
|
||||
else:
|
||||
if save and ro:
|
||||
clicked = None
|
||||
|
||||
extra_info, screenshot, mtime = save_info[filename]
|
||||
_render_savefile(offset,
|
||||
name,
|
||||
extra_info,
|
||||
screenshot,
|
||||
mtime,
|
||||
newest == filename,
|
||||
clicked)
|
||||
|
||||
ui.grid(config.file_page_cols,
|
||||
config.file_page_rows,
|
||||
style='file_picker_grid',
|
||||
transpose=True) # slots
|
||||
|
||||
for i, (filename, name, ro) in enumerate(_file_picker_page_files(fpp)):
|
||||
entry(name, filename, i, ro)
|
||||
|
||||
ui.close() # slots
|
||||
ui.close() # whole thing
|
||||
|
||||
result = ui.interact(mouse="gamemenu")
|
||||
type, value = result
|
||||
|
||||
if type == "unlink":
|
||||
if layout.yesno_prompt(screen, layout.DELETE_SAVE):
|
||||
renpy.unlink_save(value)
|
||||
update = True
|
||||
|
||||
if type == "return":
|
||||
return value
|
||||
|
||||
if type == "fppdelta":
|
||||
fpp += value
|
||||
|
||||
if type == "fppset":
|
||||
fpp = value
|
||||
|
||||
|
||||
label save_screen:
|
||||
|
||||
python hide:
|
||||
while True:
|
||||
fn = _file_picker("save", True)
|
||||
|
||||
if renpy.can_load(fn):
|
||||
if not layout.yesno_prompt("save", layout.OVERWRITE_SAVE):
|
||||
continue
|
||||
|
||||
renpy.save(fn, extra_info=store.save_name)
|
||||
|
||||
|
||||
label load_screen:
|
||||
|
||||
python hide:
|
||||
|
||||
while True:
|
||||
fn = _file_picker("load", False)
|
||||
|
||||
if _load_prompt:
|
||||
if not layout.yesno_prompt("load", layout.LOADING):
|
||||
continue
|
||||
|
||||
renpy.load(fn)
|
||||
@@ -1,60 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('main_menu')
|
||||
|
||||
style.mm_menu_frame = Style(style.menu_frame, help="frame containing main menu")
|
||||
style.mm_menu_frame_box = Style(style.vbox, help="box containing main menu buttons")
|
||||
|
||||
style.mm_button = Style(style.button, help="main menu button")
|
||||
style.mm_button_text = Style(style.button_text, help="main menu button (text)")
|
||||
|
||||
style.mm_button.size_group = "mm"
|
||||
|
||||
style.mm_menu_frame.xpos = 5.0/6.0
|
||||
style.mm_menu_frame.xanchor = 0.5
|
||||
style.mm_menu_frame.ypos = 0.9
|
||||
style.mm_menu_frame.yanchor = 1.0
|
||||
|
||||
label main_menu_screen:
|
||||
|
||||
python hide:
|
||||
|
||||
# Ignore right-click while at the main menu.
|
||||
ui.keymap(game_menu=ui.returns(None))
|
||||
|
||||
# Show the background.
|
||||
ui.window(style='mm_root')
|
||||
ui.null()
|
||||
|
||||
ui.frame(style='mm_menu_frame')
|
||||
ui.vbox(style='mm_menu_frame_box')
|
||||
|
||||
for e in config.main_menu:
|
||||
|
||||
if len(e) == 3:
|
||||
label, clicked, enabled = e
|
||||
shown = "True"
|
||||
else:
|
||||
label, clicked, enabled, shown = e
|
||||
|
||||
if not eval(shown):
|
||||
continue
|
||||
|
||||
# This checks to see if clicked is a string. If so, we want clicked
|
||||
# to jump us out of the current context.
|
||||
if isinstance(clicked, basestring):
|
||||
clicked=ui.jumpsoutofcontext(clicked)
|
||||
|
||||
# Create each button.
|
||||
layout.button(label, "mm", enabled=eval(enabled), clicked=clicked)
|
||||
|
||||
ui.close()
|
||||
|
||||
ui.interact(mouse="mainmenu")
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('navigation')
|
||||
|
||||
style.gm_nav_frame = Style(style.menu_frame, help="game menu navigation frame")
|
||||
style.gm_nav_box = Style(style.vbox, help="box containing game menu navigation buttons")
|
||||
|
||||
style.gm_nav_button = Style(style.button, help="game menu navigation button")
|
||||
style.gm_nav_button_text = Style(style.button_text, help="game menu navigation button (text)")
|
||||
|
||||
style.gm_nav_button.size_group = "gm_nav_button"
|
||||
|
||||
style.gm_nav_frame.xpos = 5.0/6.0
|
||||
style.gm_nav_frame.xanchor = 0.5
|
||||
style.gm_nav_frame.ypos = 0.95
|
||||
style.gm_nav_frame.yanchor = 1.0
|
||||
|
||||
def _navigation(screen=None):
|
||||
|
||||
# Display the game menu background
|
||||
ui.window(style=style.gm_root[screen])
|
||||
ui.null()
|
||||
|
||||
if screen is None:
|
||||
return
|
||||
|
||||
# Display the navigation frame.
|
||||
ui.frame(style='gm_nav_frame')
|
||||
ui.vbox(focus='gm_nav', style='gm_nav_box')
|
||||
|
||||
for e in config.game_menu:
|
||||
|
||||
if len(e) == 4:
|
||||
key, label, clicked, enabled = e
|
||||
shown = "True"
|
||||
else:
|
||||
key, label, clicked, enabled, shown = e
|
||||
|
||||
if not eval(shown):
|
||||
continue
|
||||
|
||||
layout.button(label,
|
||||
"gm_nav",
|
||||
selected=(screen==key),
|
||||
enabled=eval(enabled),
|
||||
clicked=clicked)
|
||||
|
||||
ui.close()
|
||||
|
||||
layout.navigation = _navigation
|
||||
@@ -1,86 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('preferences')
|
||||
|
||||
# Load the common code.
|
||||
renpy.load_module("_layout/classic_preferences_common")
|
||||
|
||||
# Create styles.
|
||||
style.prefs_column = Style(style.vbox, help="preference columns")
|
||||
style.prefs_left = Style(style.prefs_column, help="the left preference column")
|
||||
style.prefs_center = Style(style.prefs_column, help="the center preference column")
|
||||
style.prefs_right = Style(style.prefs_column, help="the right preference column")
|
||||
|
||||
# Customize styles.
|
||||
style.prefs_pref_frame.xfill = True
|
||||
style.prefs_column.xanchor = 0.5
|
||||
|
||||
if config.screen_width <= 640:
|
||||
style.prefs_pref_box.box_spacing = 6
|
||||
|
||||
style.prefs_column.xmaximum = 200
|
||||
style.prefs_column.box_spacing = 5
|
||||
style.prefs_frame.top_margin = 5
|
||||
|
||||
style.prefs_left.xpos = 110
|
||||
style.prefs_center.xpos = 320
|
||||
style.prefs_right.xpos = 530
|
||||
|
||||
style.prefs_slider.xmaximum = 160
|
||||
|
||||
else:
|
||||
style.prefs_pref_box.box_spacing = 12
|
||||
|
||||
style.prefs_column.xmaximum = 250
|
||||
style.prefs_column.box_spacing = 10
|
||||
style.prefs_frame.top_margin = 10
|
||||
|
||||
style.prefs_left.xpos = 137
|
||||
style.prefs_center.xpos = 400
|
||||
style.prefs_right.xpos = 663
|
||||
|
||||
style.prefs_slider.xmaximum = 200
|
||||
|
||||
style.prefs_pref_box.xfill = True
|
||||
style.prefs_volume_box.xfill = True
|
||||
style.prefs_pref_choicebox.xfill = True
|
||||
style.prefs_button.xalign = 1.0
|
||||
style.prefs_jump_button.xalign = 1.0
|
||||
style.prefs_slider.xalign = 1.0
|
||||
style.soundtest_button.xalign = 1.0
|
||||
|
||||
style.prefs_button.size_group = "prefs"
|
||||
style.prefs_jump_button.size_group = "prefs"
|
||||
|
||||
# Place preferences into groups.
|
||||
config.preferences['prefs_left'] = [
|
||||
config.all_preferences[u'Display'],
|
||||
config.all_preferences[u'Transitions'],
|
||||
config.all_preferences[u'Text Speed'],
|
||||
config.all_preferences[u'Joystick...'],
|
||||
]
|
||||
|
||||
config.preferences['prefs_center'] = [
|
||||
config.all_preferences[u'Skip'],
|
||||
config.all_preferences[u'Begin Skipping'],
|
||||
config.all_preferences[u'After Choices'],
|
||||
config.all_preferences[u'Auto-Forward Time'],
|
||||
]
|
||||
|
||||
config.preferences['prefs_right'] = [
|
||||
config.all_preferences[u'Music Volume'],
|
||||
config.all_preferences[u'Sound Volume'],
|
||||
config.all_preferences[u'Voice Volume'],
|
||||
]
|
||||
|
||||
|
||||
label preferences_screen:
|
||||
|
||||
python hide:
|
||||
_prefs_screen_run(config.preferences)
|
||||
|
||||
jump preferences_screen
|
||||
|
||||
@@ -1,380 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
# Styles
|
||||
style.prefs_frame = Style(style.default, help="the frame containing all of the preferences")
|
||||
style.prefs_frame_box = Style(style.default, help="the box inside the frame containing all of the preferences")
|
||||
|
||||
style.prefs_pref_frame = Style(style.menu_frame, help="a frame containing a single preference")
|
||||
style.prefs_pref_box = Style(style.vbox, help="the box separating the preference label from the preference choices")
|
||||
style.prefs_pref_choicebox = Style(style.vbox, help="the box containing the preference choices")
|
||||
|
||||
style.prefs_label = Style(style.label, help="a preference label (window)")
|
||||
style.prefs_label_text = Style(style.label_text, help="a preference label (text)")
|
||||
|
||||
style.prefs_button = Style(style.radio_button, help="preference value button")
|
||||
style.prefs_button_text = Style(style.radio_button_text, help="preference value button (text)")
|
||||
|
||||
style.prefs_slider = Style(style.slider, help="preference value slider bar")
|
||||
|
||||
style.prefs_volume_box = Style(style.vbox, help="box containing a volume slider and soundtest button")
|
||||
style.prefs_volume_slider = Style(style.prefs_slider, help="volume slider bar")
|
||||
|
||||
style.soundtest_button = Style(style.small_button, help="soundtest button")
|
||||
style.soundtest_button_text = Style(style.small_button_text, help="soundtest button (text)")
|
||||
|
||||
style.prefs_jump = Style(style.prefs_pref_frame, help="jump preference frame")
|
||||
style.prefs_jump_button = Style(style.button, help="jump preference button")
|
||||
style.prefs_jump_button_text = Style(style.button_text, help="jump preference button (text)")
|
||||
|
||||
# This is a map from the name of the style that is applied to
|
||||
# a list of preferences that should be placed into a vbox
|
||||
# with that style.
|
||||
config.preferences = { }
|
||||
|
||||
# This is a map from preference name to that preference
|
||||
# object, that can be used in rearranging preferences.
|
||||
config.all_preferences = { }
|
||||
|
||||
# Should the soundtest button be before the volume slider?
|
||||
config.soundtest_before_volume = False
|
||||
|
||||
def _prefs_screen_run(prefs_map):
|
||||
|
||||
layout.navigation("preferences")
|
||||
|
||||
ui.window(style='prefs_frame')
|
||||
ui.fixed(style='prefs_frame_box')
|
||||
|
||||
for style, prefs in prefs_map.iteritems():
|
||||
|
||||
ui.vbox(style=style)
|
||||
for i in prefs:
|
||||
i.render()
|
||||
ui.close()
|
||||
|
||||
ui.close()
|
||||
|
||||
ui.interact(mouse="gamemenu")
|
||||
|
||||
class _Preference(object):
|
||||
"""
|
||||
This is a class that's used to represent a multiple-choice
|
||||
preference.
|
||||
"""
|
||||
|
||||
def __init__(self, name, field, values, base=_preferences):
|
||||
"""
|
||||
@param name: The name of this preference. It will be
|
||||
displayed to the user.
|
||||
|
||||
@param variable: The field on the base object
|
||||
that will be assigned the selected value. This field
|
||||
must exist.
|
||||
|
||||
@param values: A list of value name, value, condition
|
||||
triples. The value name is the name of this value that
|
||||
will be shown to the user. The value is the literal
|
||||
python value that will be assigned if this value is
|
||||
selected. The condition is a condition that will be
|
||||
evaluated to determine if this is a legal value. If no
|
||||
conditions are true, this preference will not be
|
||||
displayed to the user. A condition of None is always
|
||||
considered to be True.
|
||||
|
||||
@param base: The base object on which the variable is
|
||||
read from and set. This defaults to _preferences,
|
||||
the user preferences object.
|
||||
"""
|
||||
|
||||
self.name = name
|
||||
self.field = field
|
||||
self.values = values
|
||||
self.base = base
|
||||
|
||||
config.all_preferences[name] = self
|
||||
|
||||
|
||||
def render(self):
|
||||
values = [ (name, val) for name, val, cond in self.values
|
||||
if cond is None or renpy.eval(cond) ]
|
||||
|
||||
if not values:
|
||||
return
|
||||
|
||||
ui.window(style=style.prefs_pref_frame[self.name])
|
||||
ui.vbox(style=style.prefs_pref_box[self.name])
|
||||
|
||||
layout.label(self.name, "prefs")
|
||||
|
||||
cur = getattr(self.base, self.field)
|
||||
|
||||
ui.hbox(style=style.prefs_pref_choicebox[self.name])
|
||||
|
||||
for name, value in values:
|
||||
def clicked(value=value):
|
||||
setattr(self.base, self.field, value)
|
||||
return True
|
||||
|
||||
layout.button(name, "prefs",
|
||||
selected=(cur==value),
|
||||
clicked=clicked)
|
||||
|
||||
ui.close() # choicebox
|
||||
ui.close() # vbox
|
||||
|
||||
class _VolumePreference(object):
|
||||
"""
|
||||
This represents a preference that controls one of the
|
||||
volumes in the system. It is represented as a slider bar,
|
||||
and a button that can be pushed to play a sample sound on
|
||||
a channel.
|
||||
"""
|
||||
|
||||
def __init__(self, name, mixer, enable='True', sound='None', channel="sound"):
|
||||
"""
|
||||
@param name: The name of this preference, as shown to the user.
|
||||
|
||||
@param mixer: The mixer this preference controls.
|
||||
|
||||
@param enable: A string giving a python expression. If
|
||||
the expression is evaluates to false, this preference
|
||||
is not shown.
|
||||
|
||||
@param sound: A string that is evaluated to yield
|
||||
another string. The yielded string is expected to give
|
||||
a sound file, which is played as the sample sound. (We
|
||||
apologize for the convolution of this.)
|
||||
|
||||
@param channel: The number of the channel the sample
|
||||
sound is played on.
|
||||
"""
|
||||
|
||||
self.name = name
|
||||
self.mixer = mixer
|
||||
self.enable = enable
|
||||
self.sound = sound
|
||||
self.channel = channel
|
||||
|
||||
config.all_preferences[name] = self
|
||||
|
||||
def render(self):
|
||||
|
||||
if not eval(self.enable):
|
||||
return
|
||||
|
||||
sound = eval(self.sound)
|
||||
|
||||
ui.window(style=style.prefs_pref_frame[self.name])
|
||||
ui.vbox(style=style.prefs_pref_box[self.name])
|
||||
|
||||
layout.label(self.name, "prefs")
|
||||
|
||||
ui.vbox(style=style.prefs_volume_box[self.name])
|
||||
|
||||
if sound:
|
||||
def clicked():
|
||||
renpy.sound.play(sound, channel=self.channel)
|
||||
|
||||
if sound and config.soundtest_before_volume:
|
||||
layout.button(u"Test", "soundtest", clicked=clicked, index=self.name)
|
||||
|
||||
def changed(v):
|
||||
_preferences.set_volume(self.mixer, v / 128.0)
|
||||
|
||||
ui.bar(128,
|
||||
int(_preferences.get_volume(self.mixer) * 128),
|
||||
changed=changed,
|
||||
style=style.prefs_volume_slider[self.name])
|
||||
|
||||
if sound and not config.soundtest_before_volume:
|
||||
layout.button(u"Test", "soundtest", clicked=clicked, index=self.name)
|
||||
|
||||
ui.close()
|
||||
ui.close()
|
||||
|
||||
class _SliderPreference(object):
|
||||
"""
|
||||
A class that represents a preference that is controlled by a
|
||||
slider.
|
||||
"""
|
||||
|
||||
def __init__(self, name, field, range, enable='True', base=_preferences):
|
||||
"""
|
||||
@param name: The name of this preference, that is shown to the user.
|
||||
|
||||
@param range: An integer giving the maximum value of
|
||||
this slider. The slider goes from 0 to range.
|
||||
|
||||
@param get: A function that's called to get the
|
||||
initial value of the slider. It's called with no
|
||||
arguments, and should return an integet between 0 and
|
||||
range, inclusive.
|
||||
|
||||
@param set: A function that's called when the value of
|
||||
the slider is set by the user. It is called with a
|
||||
single integer, in the range 0 to range, inclusive.
|
||||
|
||||
@param enable: A string giving a python expression. If
|
||||
the expression is evaluates to false, this preference
|
||||
is not shown.
|
||||
"""
|
||||
|
||||
self.name = name
|
||||
self.field = field
|
||||
self.range = range
|
||||
self.enable = enable
|
||||
self.base = base
|
||||
|
||||
config.all_preferences[name] = self
|
||||
|
||||
def get(self):
|
||||
value = getattr(self.base, self.field)
|
||||
if value == 0:
|
||||
value = self.range
|
||||
else:
|
||||
value -= 1
|
||||
|
||||
return value
|
||||
|
||||
def set(self, value):
|
||||
value += 1
|
||||
if value == self.range + 1:
|
||||
value = 0
|
||||
|
||||
setattr(self.base, self.field, value)
|
||||
|
||||
def render(self):
|
||||
|
||||
if not eval(self.enable):
|
||||
return
|
||||
|
||||
ui.window(style=style.prefs_pref_frame[self.name])
|
||||
ui.vbox(style=style.prefs_pref_box[self.name])
|
||||
|
||||
layout.label(self.name, "prefs")
|
||||
|
||||
def changed(v):
|
||||
self.set(v)
|
||||
|
||||
ui.bar(self.range,
|
||||
self.get(),
|
||||
changed=changed,
|
||||
style=style.prefs_slider[self.name])
|
||||
|
||||
ui.close()
|
||||
|
||||
|
||||
class _JumpPreference(object):
|
||||
|
||||
def __init__(self, name, target, condition="True", show="True"):
|
||||
self.name = name
|
||||
self.target = target
|
||||
self.condition = condition
|
||||
self.show = show
|
||||
|
||||
config.all_preferences[name] = self
|
||||
|
||||
def render(self):
|
||||
|
||||
if not eval(self.show):
|
||||
return
|
||||
|
||||
ui.window(style=style.prefs_jump[self.name])
|
||||
|
||||
if eval(self.condition):
|
||||
clicked=ui.jumps(self.target)
|
||||
else:
|
||||
clicked=None
|
||||
|
||||
layout.button(self.name, 'prefs_jump', clicked=clicked)
|
||||
|
||||
def _remove_preference(name):
|
||||
"""
|
||||
Removes the preference with the given name from the
|
||||
preferences menu.
|
||||
"""
|
||||
|
||||
pref = config.all_preferences.get(name, None)
|
||||
if not pref:
|
||||
return
|
||||
|
||||
for k, v in config.preferences.iteritems():
|
||||
if pref in v:
|
||||
v.remove(pref)
|
||||
|
||||
init python hide:
|
||||
|
||||
# Enablers for some preferences.
|
||||
config.sample_sound = None
|
||||
config.sample_voice = None
|
||||
config.has_transitions = True
|
||||
config.has_cps = True
|
||||
config.has_afm = True
|
||||
config.has_skipping = True
|
||||
config.has_skip_after_choice = True
|
||||
config.always_has_joystick = False
|
||||
config.has_joystick = True
|
||||
|
||||
|
||||
# Left
|
||||
|
||||
_Preference(u'Display', 'fullscreen', [
|
||||
(u'Window', False, None),
|
||||
(u'Fullscreen', True, None),
|
||||
])
|
||||
|
||||
_Preference(u'Transitions', 'transitions', [
|
||||
(u'All', 2, 'config.has_transitions'),
|
||||
(u'Some', 1, 'config.has_transitions and default_transition'),
|
||||
(u'None', 0, 'config.has_transitions'),
|
||||
])
|
||||
|
||||
# Center
|
||||
|
||||
_Preference(u'Skip', 'skip_unseen', [
|
||||
(u'Seen Messages', False, 'config.allow_skipping and config.has_skipping'),
|
||||
(u'All Messages', True, 'config.allow_skipping and config.has_skipping'),
|
||||
])
|
||||
|
||||
_JumpPreference(u'Begin Skipping',
|
||||
'_return_skipping',
|
||||
'not main_menu',
|
||||
'config.allow_skipping and config.has_skipping')
|
||||
|
||||
|
||||
_Preference(u'After Choices', 'skip_after_choices', [
|
||||
(u'Stop Skipping', False, 'config.allow_skipping and config.has_skip_after_choice'),
|
||||
(u'Keep Skipping', True, 'config.allow_skipping and config.has_skip_after_choice'),
|
||||
])
|
||||
|
||||
config.old_names['Keep Skipping'] = 'Continue Skipping'
|
||||
|
||||
_SliderPreference(u'Text Speed', "text_cps", 150, 'config.has_cps')
|
||||
_SliderPreference(u'Auto-Forward Time', "afm_time", 40, 'config.has_afm')
|
||||
|
||||
# Right
|
||||
|
||||
_VolumePreference(u"Music Volume",
|
||||
'music',
|
||||
'config.has_music')
|
||||
|
||||
_VolumePreference(u"Sound Volume",
|
||||
'sfx',
|
||||
'config.has_sound',
|
||||
'config.sample_sound',
|
||||
'sound')
|
||||
|
||||
_VolumePreference(u'Voice Volume',
|
||||
'voice',
|
||||
'config.has_voice',
|
||||
'config.sample_voice',
|
||||
'voice')
|
||||
|
||||
_JumpPreference(u'Joystick...',
|
||||
'joystick_preferences_screen',
|
||||
'renpy.display.joystick.enabled or config.always_has_joystick',
|
||||
'config.has_joystick')
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python hide:
|
||||
|
||||
layout.provides('yesno_prompt')
|
||||
|
||||
# Define styles
|
||||
style.yesno_frame = Style(style.menu_frame, help="frame containing a yes/no prompt and yes/no buttons")
|
||||
style.yesno_frame_vbox = Style(style.vbox, help="box separating yes/no prompt from yes/no buttons")
|
||||
|
||||
style.yesno_prompt = Style(style.prompt, help="a yes/no prompt")
|
||||
style.yesno_prompt_text = Style(style.prompt_text, help="a yes/no prompt (text)")
|
||||
|
||||
style.yesno_button_hbox = Style(style.hbox, help="the box separating yes and no buttons")
|
||||
style.yesno_button = Style(style.button, help="a yes or no button")
|
||||
style.yesno_button_text = Style(style.button_text, help="a yes or no button (text)")
|
||||
|
||||
# Alter styles.
|
||||
style.yesno_frame.xfill = True
|
||||
style.yesno_frame.xmargin = .05
|
||||
style.yesno_frame.ypos = .1
|
||||
style.yesno_frame.yanchor = 0
|
||||
style.yesno_frame.ypadding = .05
|
||||
|
||||
style.yesno_frame_vbox.xalign = 0.5
|
||||
style.yesno_frame_vbox.yalign = 0.5
|
||||
style.yesno_frame_vbox.box_spacing = 30
|
||||
|
||||
style.yesno_button_hbox.xalign = 0.5
|
||||
style.yesno_button_hbox.spacing = 100
|
||||
|
||||
style.yesno_button.size_group = "yesno"
|
||||
|
||||
def yesno_prompt(screen, message):
|
||||
renpy.transition(config.intra_transition)
|
||||
|
||||
layout.navigation(screen)
|
||||
|
||||
ui.window(style='yesno_frame')
|
||||
ui.vbox(style='yesno_frame_vbox')
|
||||
|
||||
layout.prompt(message, "yesno")
|
||||
|
||||
ui.hbox(style='yesno_button_hbox')
|
||||
|
||||
# The extra nulls are because we want equal whitespace surrounding
|
||||
# the two buttons. It should work as long as we have xfill=True
|
||||
layout.button(u"Yes", 'yesno', clicked=ui.returns(True))
|
||||
layout.button(u"No", 'yesno', clicked=ui.returns(False))
|
||||
|
||||
ui.close()
|
||||
ui.close()
|
||||
|
||||
rv = ui.interact(mouse="gamemenu")
|
||||
renpy.transition(config.intra_transition)
|
||||
return rv
|
||||
|
||||
layout.yesno_prompt = yesno_prompt
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('main_menu')
|
||||
|
||||
style.mm_menu_frame = Style(style.menu_frame, help="frame containing main menu")
|
||||
style.mm_outer_box = Style(style.vbox, help="outer box containing main menu buttons")
|
||||
style.mm_inner_box = Style(style.hbox, help="inner box containing main menu buttons")
|
||||
|
||||
style.mm_button = Style(style.button, help="main menu button")
|
||||
style.mm_button_text = Style(style.button_text, help="main menu button (text)")
|
||||
|
||||
style.mm_menu_frame.xalign = 0.5
|
||||
style.mm_menu_frame.yalign = 0.98
|
||||
style.mm_inner_box.xalign = 0.5
|
||||
|
||||
config.main_menu_per_group = 2
|
||||
|
||||
|
||||
label main_menu_screen:
|
||||
|
||||
python hide:
|
||||
# Ignore right-click while at the main menu.
|
||||
ui.keymap(game_menu=ui.returns(None))
|
||||
|
||||
# Show the background.
|
||||
ui.window(style='mm_root')
|
||||
ui.null()
|
||||
|
||||
ui.frame(style='mm_menu_frame')
|
||||
ui.vbox(style='mm_outer_box')
|
||||
|
||||
inner_open = False
|
||||
|
||||
for i, e in enumerate(config.main_menu):
|
||||
|
||||
if len(e) == 3:
|
||||
label, clicked, enabled = e
|
||||
shown = "True"
|
||||
else:
|
||||
label, clicked, enabled, shown = e
|
||||
|
||||
if not eval(shown):
|
||||
continue
|
||||
|
||||
if i % config.main_menu_per_group == 0:
|
||||
if inner_open:
|
||||
ui.close()
|
||||
|
||||
ui.hbox(style='mm_inner_box')
|
||||
inner_open = True
|
||||
|
||||
# This checks to see if clicked is a string. If so, we want clicked
|
||||
# to jump us out of the current context.
|
||||
if isinstance(clicked, basestring):
|
||||
clicked=ui.jumpsoutofcontext(clicked)
|
||||
|
||||
# Create each button.
|
||||
layout.button(label, "mm", enabled=eval(enabled), clicked=clicked)
|
||||
|
||||
if inner_open:
|
||||
ui.close() # inner box
|
||||
|
||||
ui.close() # outer box
|
||||
|
||||
ui.interact(mouse="mainmenu")
|
||||
|
||||
return
|
||||
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('navigation')
|
||||
|
||||
style.gm_nav_frame = Style(style.menu_frame, help="game menu navigation frame")
|
||||
style.gm_nav_inner_box = Style(style.hbox, help="inner box containing game menu navigation buttons")
|
||||
style.gm_nav_outer_box = Style(style.vbox, help="outer box containing game menu navigation buttons")
|
||||
|
||||
style.gm_nav_button = Style(style.button, help="game menu navigation button")
|
||||
style.gm_nav_button_text = Style(style.button_text, help="game menu navigation button (text)")
|
||||
|
||||
style.gm_nav_button.size_group = "gm_nav_button"
|
||||
|
||||
style.gm_nav_frame.xalign = 0.5
|
||||
style.gm_nav_frame.ypos = 0.98
|
||||
style.gm_nav_frame.yanchor = 1.0
|
||||
|
||||
style.gm_nav_inner_box.xalign = 0.5
|
||||
|
||||
config.navigation_per_group = 4
|
||||
|
||||
def navigation(screen=None):
|
||||
|
||||
# Display the game menu background
|
||||
ui.window(style=style.gm_root[screen])
|
||||
ui.null()
|
||||
|
||||
if screen is None:
|
||||
return
|
||||
|
||||
# Display the navigation frame.
|
||||
ui.frame(style='gm_nav_frame')
|
||||
ui.vbox(focus='gm_nav', style='gm_nav_outer_box')
|
||||
|
||||
box_open = False
|
||||
|
||||
for i, e in enumerate(config.game_menu):
|
||||
|
||||
if len(e) == 4:
|
||||
key, label, clicked, enabled = e
|
||||
shown = "True"
|
||||
else:
|
||||
key, label, clicked, enabled, shown = e
|
||||
|
||||
if not eval(shown):
|
||||
continue
|
||||
|
||||
if i % config.navigation_per_group == 0:
|
||||
if box_open:
|
||||
ui.close()
|
||||
|
||||
ui.hbox(style='gm_nav_inner_box')
|
||||
box_open = True
|
||||
|
||||
layout.button(label,
|
||||
"gm_nav",
|
||||
selected=(screen==key),
|
||||
enabled=eval(enabled),
|
||||
clicked=clicked)
|
||||
|
||||
if box_open:
|
||||
ui.close() # inner box.
|
||||
|
||||
ui.close() # outer box.
|
||||
|
||||
layout.navigation = navigation
|
||||
@@ -1,127 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
class _ImageMapper(object):
|
||||
|
||||
def __init__(self, screen, ground, idle, hover, selected_idle, selected_hover, hotspots, navigation=True, variant=None):
|
||||
|
||||
# If the argument is a dict, look up the screen in that dict, and
|
||||
# return the result. Otherwise, just return the result.
|
||||
def maybe_variant(a):
|
||||
if isinstance(a, dict):
|
||||
if variant in a:
|
||||
return a[variant]
|
||||
else:
|
||||
return a[None]
|
||||
return a
|
||||
|
||||
ground = maybe_variant(ground)
|
||||
|
||||
self.idle = maybe_variant(idle) or ground
|
||||
self.hover = maybe_variant(hover) or self.idle
|
||||
self.selected_idle = maybe_variant(selected_idle) or self.idle
|
||||
self.selected_hover = maybe_variant(selected_hover) or self.hover
|
||||
|
||||
self.hotspots = { }
|
||||
for (x1, y1, x2, y2, name) in maybe_variant(hotspots):
|
||||
self.hotspots[name] = (x1, y1, x2, y2)
|
||||
|
||||
self.remaining_hotspots = set(self.hotspots.keys())
|
||||
|
||||
if navigation:
|
||||
|
||||
# Display the layout navigation only if there are no
|
||||
# game menu buttons defined.
|
||||
for i in config.game_menu:
|
||||
if i[1] in self.hotspots:
|
||||
break
|
||||
else:
|
||||
layout.navigation(screen)
|
||||
|
||||
ui.fixed(style='imagemap')
|
||||
ui.image(ground)
|
||||
|
||||
if navigation:
|
||||
|
||||
# Display any navigation buttons that exist.
|
||||
for e in config.game_menu:
|
||||
screen_ = e[0]
|
||||
name = e[1]
|
||||
act = e[2]
|
||||
enable = e[3]
|
||||
|
||||
if not eval(enable):
|
||||
continue
|
||||
|
||||
self.button(name, act, screen == screen_)
|
||||
|
||||
def button(self, name, clicked, selected, keymap={}):
|
||||
|
||||
if name not in self.hotspots:
|
||||
return None
|
||||
|
||||
self.remaining_hotspots.discard(name)
|
||||
|
||||
x1, y1, x2, y2 = self.hotspots[name]
|
||||
|
||||
if clicked is None:
|
||||
return (x1, y1, x2, y2)
|
||||
|
||||
if selected:
|
||||
idle = self.selected_idle
|
||||
hover = self.selected_hover
|
||||
else:
|
||||
idle = self.idle
|
||||
hover = self.hover
|
||||
|
||||
ui.imagebutton(
|
||||
LiveCrop((x1, y1, (x2 - x1), (y2 - y1)), idle),
|
||||
LiveCrop((x1, y1, (x2 - x1), (y2 - y1)), hover),
|
||||
xpos=x1,
|
||||
ypos=y1,
|
||||
xanchor=0,
|
||||
yanchor=0,
|
||||
clicked=clicked,
|
||||
focus_mask=True,
|
||||
style='imagemap_button',
|
||||
keymap=keymap,
|
||||
)
|
||||
|
||||
return (x1, y1, x2, y2)
|
||||
|
||||
|
||||
def bar(self, name, range, value, changed):
|
||||
|
||||
if name not in self.hotspots:
|
||||
return
|
||||
|
||||
self.remaining_hotspots.discard(name)
|
||||
|
||||
x1, y1, x2, y2 = self.hotspots[name]
|
||||
|
||||
ui.bar(
|
||||
range,
|
||||
value,
|
||||
changed=changed,
|
||||
left_gutter=0,
|
||||
right_gutter=0,
|
||||
left_bar=LiveCrop((x1, y1, (x2 - x1), (y2 - y1)), self.selected_idle),
|
||||
right_bar=LiveCrop((x1, y1, (x2 - x1), (y2 - y1)), self.idle),
|
||||
hover_left_bar=LiveCrop((x1, y1, (x2 - x1), (y2 - y1)), self.selected_hover),
|
||||
hover_right_bar=LiveCrop((x1, y1, (x2 - x1), (y2 - y1)), self.hover),
|
||||
bar_resizing=False,
|
||||
xpos=x1,
|
||||
ypos=y1,
|
||||
xmaximum=(x2-x1),
|
||||
ymaximum=(y2-y1),
|
||||
thumb=None,
|
||||
thumb_shadow=None,
|
||||
thumb_offset=0)
|
||||
|
||||
def nothing(self, name):
|
||||
self.remaining_hotspots.discard(name)
|
||||
|
||||
def close(self):
|
||||
ui.close()
|
||||
@@ -1,354 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('load_save')
|
||||
renpy.load_module("_layout/imagemap_common")
|
||||
|
||||
# The ground image.
|
||||
config.load_save_ground = { }
|
||||
|
||||
# The idle image.
|
||||
config.load_save_idle = { }
|
||||
|
||||
# The hover image.
|
||||
config.load_save_hover = { }
|
||||
|
||||
# The selected idle image.
|
||||
config.load_save_selected_idle = { }
|
||||
|
||||
# The selected hover image.
|
||||
config.load_save_selected_hover = { }
|
||||
|
||||
# The hotspots. Each hotspot is defined by a tuple giving:
|
||||
# - The x-coordinate of the left side.
|
||||
# - The y-coordinate of the top side.
|
||||
# - The x-coordinate of the right side.
|
||||
# - The y-coordinate of the bottoms side.
|
||||
# - The name of the button or slider this is equivalent to.
|
||||
config.load_save_hotspots = { }
|
||||
|
||||
# Define styles
|
||||
style.file_picker_text = Style(style.large_button_text, help="text inside a file picker entry")
|
||||
style.file_picker_empty_slot = Style(style.file_picker_text, help="text inside an empty file picker entry slot")
|
||||
style.file_picker_text_window = Style(style.default, help="a window containing the file picker text.")
|
||||
style.file_picker_ss_window = Style(style.default, help="a window containing the screenshot.")
|
||||
|
||||
# Should we disable thumbnails?
|
||||
config.disable_thumbnails = False
|
||||
|
||||
# The default thumbnail to use when no file exists.
|
||||
config.load_save_empty_thumbnail = None
|
||||
|
||||
# How we format time in a file entry.
|
||||
config.time_format = "%b %d, %H:%M"
|
||||
|
||||
# How we format a file entry.
|
||||
config.file_entry_format = "%(time)s\n%(save_name)s"
|
||||
|
||||
# True if we should prompt before loading a game.
|
||||
_load_prompt = True
|
||||
|
||||
# This is used to store scratch data that's used by the
|
||||
# library, but shouldn't be saved out as part of the savegame.
|
||||
__scratch = object()
|
||||
__scratch.file_picker_page = None
|
||||
__scratch.initialized = False
|
||||
__scratch.per_page = 0
|
||||
__scratch.pages = 0
|
||||
__scratch.has_autosave = False
|
||||
__scratch.has_quicksave = False
|
||||
|
||||
def _render_savefile(ime, index, name, extra_info, screenshot, mtime, newest, clicked):
|
||||
|
||||
import time
|
||||
|
||||
(x1, y1, x2, y2) = ime.button(
|
||||
"slot_%d" % index, clicked, newest,
|
||||
keymap={ "save_delete" : ui.returns(("unlink", name)) })
|
||||
|
||||
ui.fixed(xpos=x1, ypos=y1, xmaximum=x2-x1, ymaximum=y2-y1)
|
||||
|
||||
if not config.disable_thumbnails:
|
||||
ui.window(style=style.file_picker_ss_window[index])
|
||||
ui.add(screenshot)
|
||||
|
||||
s = name + ". " + config.file_entry_format % dict(
|
||||
time=time.strftime(config.time_format,
|
||||
time.localtime(mtime)),
|
||||
save_name=extra_info)
|
||||
|
||||
ui.window(style=style.file_picker_text_window[index])
|
||||
ui.text(s, style=style.file_picker_text[index])
|
||||
|
||||
ui.close()
|
||||
|
||||
def _render_new_slot(ime, index, name, clicked):
|
||||
|
||||
(x1, y1, x2, y2) = ime.button("slot_%d" % index, clicked, False)
|
||||
|
||||
ui.fixed(xpos=x1, ypos=y1, xmaximum=x2-x1, ymaximum=y2-y1)
|
||||
|
||||
if not config.disable_thumbnails:
|
||||
|
||||
if config.load_save_empty_thumbnail:
|
||||
ui.window(style=style.file_picker_ss_window[index])
|
||||
ui.add(config.load_save_empty_thumbnail)
|
||||
|
||||
ui.window(style=style.file_picker_text_window[index])
|
||||
ui.text(name + ". " + _(u"Empty Slot.") + "\n", style=style.file_picker_empty_slot[index])
|
||||
|
||||
ui.close()
|
||||
|
||||
|
||||
# This function is given a page, and should map it to the names
|
||||
# of the files on that page.
|
||||
def _file_picker_page_files(page):
|
||||
|
||||
per_page = __scratch.per_page
|
||||
rv = [ ]
|
||||
|
||||
if __scratch.has_autosave:
|
||||
if page == 0:
|
||||
for i in range(1, per_page + 1):
|
||||
rv.append(("auto-" + str(i), _(u"a") + str(i), True))
|
||||
|
||||
return rv
|
||||
else:
|
||||
page -= 1
|
||||
|
||||
if __scratch.has_quicksave:
|
||||
if page == 0:
|
||||
for i in range(1, per_page + 1):
|
||||
rv.append(("quick-" + str(i), _(u"q") + str(i), True))
|
||||
|
||||
return rv
|
||||
else:
|
||||
page -= 1
|
||||
|
||||
for i in range(per_page * page + 1, per_page * page + 1 + per_page):
|
||||
rv.append(("%d" % i, "%d" % i, False))
|
||||
|
||||
return rv
|
||||
|
||||
# Given a filename, returns the page that filename is on.
|
||||
def _file_picker_file_page(filename):
|
||||
|
||||
per_page = __scratch.per_page
|
||||
|
||||
base = 0
|
||||
|
||||
if __scratch.has_autosave:
|
||||
if filename.startswith("auto-"):
|
||||
return base
|
||||
else:
|
||||
base += 1
|
||||
|
||||
if __scratch.has_quicksave:
|
||||
if filename.startswith("quick-"):
|
||||
return base
|
||||
else:
|
||||
base += 1
|
||||
|
||||
try:
|
||||
return base + int((int(filename) - 1) / per_page)
|
||||
except:
|
||||
return base
|
||||
|
||||
# Processes a screenshot.
|
||||
def _file_picker_process_screenshot(s):
|
||||
return s
|
||||
|
||||
# Initialize the scratch information.
|
||||
def _file_picker_init():
|
||||
|
||||
hotspots = set()
|
||||
|
||||
if isinstance(config.load_save_hotspots, dict):
|
||||
for d in config.load_save_hotspots.values():
|
||||
for (x1, y1, x2, y2, name) in d:
|
||||
hotspots.add(name)
|
||||
else:
|
||||
for (x1, y1, x2, y2, name) in config.load_save_hotspots:
|
||||
hotspots.add(name)
|
||||
|
||||
__scratch.has_autosave = ("page_auto" in hotspots)
|
||||
__scratch.has_quicksave = ("page_quick" in hotspots)
|
||||
|
||||
__scratch.per_page = 0
|
||||
|
||||
while ("slot_%d" % __scratch.per_page) in hotspots:
|
||||
__scratch.per_page += 1
|
||||
|
||||
__scratch.pages = 1
|
||||
|
||||
while ("page_%d" % __scratch.pages) in hotspots:
|
||||
__scratch.pages += 1
|
||||
|
||||
__scratch.pages -= 1
|
||||
|
||||
def _file_picker_pages():
|
||||
|
||||
rv = [ ]
|
||||
|
||||
if config.has_autosave:
|
||||
rv.append("page_auto")
|
||||
|
||||
if config.has_quicksave:
|
||||
rv.append("page_quick")
|
||||
|
||||
for i in range(1, __scratch.pages + 1):
|
||||
rv.append("page_%d" % i)
|
||||
|
||||
return rv
|
||||
|
||||
|
||||
# This displays a file picker that can chose a save file from
|
||||
# the list of save files.
|
||||
def _file_picker(screen, save):
|
||||
|
||||
if not __scratch.initialized:
|
||||
__scratch.initialized = True
|
||||
_file_picker_init()
|
||||
|
||||
# The number of slots in a page.
|
||||
file_page_length = __scratch.per_page
|
||||
|
||||
update = True
|
||||
|
||||
while True:
|
||||
|
||||
if update:
|
||||
|
||||
update = False
|
||||
|
||||
saved_games = renpy.list_saved_games(regexp=r'(auto-|quick-)?[0-9]+')
|
||||
|
||||
newest = None
|
||||
newest_mtime = None
|
||||
save_info = { }
|
||||
|
||||
for fn, extra_info, screenshot, mtime in saved_games:
|
||||
screenshot = _file_picker_process_screenshot(screenshot)
|
||||
save_info[fn] = (extra_info, screenshot, mtime)
|
||||
|
||||
if not fn.startswith("auto-") and mtime > newest_mtime:
|
||||
newest = fn
|
||||
newest_mtime = mtime
|
||||
|
||||
# The index of the first entry in the page.
|
||||
fpp = __scratch.file_picker_page
|
||||
|
||||
if fpp is None:
|
||||
|
||||
if newest:
|
||||
fpp = _file_picker_file_page(newest)
|
||||
else:
|
||||
fpp = _file_picker_file_page("1")
|
||||
|
||||
|
||||
if fpp < 0:
|
||||
fpp = 0
|
||||
|
||||
__scratch.file_picker_page = fpp
|
||||
|
||||
ime = _ImageMapper(
|
||||
screen,
|
||||
config.load_save_ground,
|
||||
config.load_save_idle,
|
||||
config.load_save_hover,
|
||||
config.load_save_selected_idle,
|
||||
config.load_save_selected_hover,
|
||||
config.load_save_hotspots,
|
||||
variant=screen)
|
||||
|
||||
|
||||
def tb(enabled, label, clicked, selected):
|
||||
|
||||
if not enabled:
|
||||
return
|
||||
|
||||
ime.button(label, clicked, selected)
|
||||
|
||||
# Previous
|
||||
tb(fpp > 0, 'previous', ui.returns(("fppdelta", -1)), selected=False)
|
||||
|
||||
# Quick Access
|
||||
for i, name in enumerate(_file_picker_pages()):
|
||||
tb(True, name, ui.returns(("fppset", i)), fpp == i)
|
||||
|
||||
# Next
|
||||
tb(True, 'next', ui.returns(("fppdelta", +1)), False)
|
||||
|
||||
# This draws a single slot.
|
||||
def entry(name, filename, offset, ro):
|
||||
clicked = ui.returns(("return", filename))
|
||||
|
||||
if filename not in save_info:
|
||||
if (not save) or ro:
|
||||
clicked = None
|
||||
|
||||
_render_new_slot(ime, offset, name, clicked)
|
||||
|
||||
else:
|
||||
if save and ro:
|
||||
clicked = None
|
||||
|
||||
extra_info, screenshot, mtime = save_info[filename]
|
||||
_render_savefile(ime,
|
||||
offset,
|
||||
name,
|
||||
extra_info,
|
||||
screenshot,
|
||||
mtime,
|
||||
newest == filename,
|
||||
clicked)
|
||||
|
||||
for i, (filename, name, ro) in enumerate(_file_picker_page_files(fpp)):
|
||||
entry(name, filename, i, ro)
|
||||
|
||||
ime.close()
|
||||
|
||||
result = ui.interact(mouse="gamemenu")
|
||||
type, value = result
|
||||
|
||||
if type == "unlink":
|
||||
if layout.yesno_prompt(screen, layout.DELETE_SAVE):
|
||||
renpy.unlink_save(value)
|
||||
update = True
|
||||
|
||||
if type == "return":
|
||||
return value
|
||||
|
||||
if type == "fppdelta":
|
||||
fpp += value
|
||||
|
||||
if type == "fppset":
|
||||
fpp = value
|
||||
|
||||
|
||||
label save_screen:
|
||||
|
||||
python hide:
|
||||
while True:
|
||||
fn = _file_picker("save", True)
|
||||
|
||||
if renpy.can_load(fn):
|
||||
if not layout.yesno_prompt("save", layout.OVERWRITE_SAVE):
|
||||
continue
|
||||
|
||||
renpy.save(fn, extra_info=store.save_name)
|
||||
|
||||
|
||||
label load_screen:
|
||||
|
||||
python hide:
|
||||
while True:
|
||||
fn = _file_picker("load", False)
|
||||
|
||||
if _load_prompt:
|
||||
if not layout.yesno_prompt("load", layout.LOADING):
|
||||
continue
|
||||
|
||||
renpy.load(fn)
|
||||
@@ -1,80 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('main_menu')
|
||||
renpy.load_module("_layout/imagemap_common")
|
||||
|
||||
# The ground image.
|
||||
config.main_menu_ground = { }
|
||||
|
||||
# The selected/hover image.
|
||||
config.main_menu_selected = { }
|
||||
|
||||
# The idle image.
|
||||
config.main_menu_idle = { }
|
||||
|
||||
# The hotspots. Each hotspot is defined by a tuple giving:
|
||||
# - The x-coordinate of the left side.
|
||||
# - The y-coordinate of the top side.
|
||||
# - The x-coordinate of the right side.
|
||||
# - The y-coordinate of the bottoms side.
|
||||
# - Either the (untranslated) name of the main menu button this hotspot
|
||||
# is equivalent to, or, a label in the program to jump to when this
|
||||
# hotspot is clicked.
|
||||
config.main_menu_hotspots = { }
|
||||
|
||||
# This can be set from user code to define the main menu variant to use.
|
||||
_main_menu_variant = None
|
||||
|
||||
label main_menu_screen:
|
||||
|
||||
python hide:
|
||||
|
||||
# Ignore right-click while at the main menu.
|
||||
ui.keymap(game_menu=ui.returns(None))
|
||||
|
||||
# Show the background.
|
||||
ui.window(style='mm_root')
|
||||
ui.null()
|
||||
|
||||
ime = _ImageMapper(
|
||||
None,
|
||||
config.main_menu_ground,
|
||||
config.main_menu_idle,
|
||||
config.main_menu_selected,
|
||||
config.main_menu_idle,
|
||||
config.main_menu_selected,
|
||||
config.main_menu_hotspots,
|
||||
navigation=False,
|
||||
variant=_main_menu_variant)
|
||||
|
||||
for e in config.main_menu:
|
||||
if len(e) == 4:
|
||||
name, act, enabled, shown = e
|
||||
else:
|
||||
name, act, enabled = e
|
||||
shown = "True"
|
||||
|
||||
if not eval(shown):
|
||||
ime.nothing(name)
|
||||
|
||||
if not eval(enabled):
|
||||
act = None
|
||||
|
||||
if isinstance(act, basestring):
|
||||
act = ui.jumpsoutofcontext(act)
|
||||
|
||||
ime.button(name, act, False)
|
||||
|
||||
for i in list(ime.remaining_hotspots):
|
||||
ime.button(i, ui.jumpsoutofcontext(i), None)
|
||||
|
||||
ime.close()
|
||||
ui.interact(mouse='mainmenu')
|
||||
|
||||
jump main_menu_screen
|
||||
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('navigation')
|
||||
|
||||
# The ground image.
|
||||
config.navigation_ground = None
|
||||
|
||||
# The idle image.
|
||||
config.navigation_idle = None
|
||||
|
||||
# The hover image.
|
||||
config.navigation_hover = None
|
||||
|
||||
# The selected idle image.
|
||||
config.navigation_selected_idle = None
|
||||
|
||||
# The selected hover image.
|
||||
config.navigation_selected_hover = None
|
||||
|
||||
# The hotspots. Each hotspot is defined by a tuple giving:
|
||||
# - The x-coordinate of the left side.
|
||||
# - The y-coordinate of the top side.
|
||||
# - The x-coordinate of the right side.
|
||||
# - The y-coordinate of the bottoms side.
|
||||
# - The name of the game menu button this is equivalent to.
|
||||
config.navigation_hotspots = None
|
||||
|
||||
def _navigation(screen=None):
|
||||
|
||||
# Display the game menu background
|
||||
ui.window(style=style.gm_root[screen])
|
||||
ui.null()
|
||||
|
||||
if screen is None:
|
||||
return
|
||||
|
||||
# A map from button name to game menu information.
|
||||
gm = dict()
|
||||
|
||||
for e in config.game_menu:
|
||||
screen_ = e[0]
|
||||
name_ = e[1]
|
||||
act = e[2]
|
||||
enable = e[3]
|
||||
|
||||
gm[name_] = (screen_, act, enable)
|
||||
|
||||
ui.fixed(style='imagemap')
|
||||
ui.image(config.navigation_ground)
|
||||
|
||||
for (x0, y0, x1, y1, name) in config.navigation_hotspots:
|
||||
|
||||
if name not in gm:
|
||||
raise Exception("%r was used in a game menu hotspot, but isn't the name of a game menu button." % name)
|
||||
|
||||
screen_, act, enable = gm[name]
|
||||
|
||||
if not eval(enable):
|
||||
continue
|
||||
|
||||
if screen_ == screen:
|
||||
idle = config.navigation_selected_idle
|
||||
hover = config.navigation_selected_hover
|
||||
else:
|
||||
idle = config.navigation_idle
|
||||
hover = config.navigation_hover
|
||||
|
||||
ui.imagebutton(
|
||||
LiveCrop((x0, y0, x1-x0, y1-y0), idle),
|
||||
LiveCrop((x0, y0, x1-x0, y1-y0), hover),
|
||||
clicked=act,
|
||||
style='imagemap_button',
|
||||
xpos=x0,
|
||||
ypos=y0,
|
||||
xanchor=0,
|
||||
yanchor=0,
|
||||
focus_mask=True,
|
||||
)
|
||||
|
||||
ui.close()
|
||||
|
||||
layout.navigation = _navigation
|
||||
@@ -1,147 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('preferences')
|
||||
renpy.load_module("_layout/imagemap_common")
|
||||
|
||||
# The ground image.
|
||||
config.preferences_ground = None
|
||||
|
||||
# The idle image.
|
||||
config.preferences_idle = None
|
||||
|
||||
# The hover image.
|
||||
config.preferences_hover = None
|
||||
|
||||
# The selected idle image.
|
||||
config.preferences_selected_idle = None
|
||||
|
||||
# The selected hover image.
|
||||
config.preferences_selected_hover = None
|
||||
|
||||
# The hotspots. Each hotspot is defined by a tuple giving:
|
||||
# - The x-coordinate of the left side.
|
||||
# - The y-coordinate of the top side.
|
||||
# - The x-coordinate of the right side.
|
||||
# - The y-coordinate of the bottoms side.
|
||||
# - The name of the button or slider this is equivalent to.
|
||||
config.preferences_hotspots = None
|
||||
|
||||
config.sample_sound = None
|
||||
config.sample_voice = None
|
||||
config.always_has_joystick = False
|
||||
|
||||
def __set(base, field, value):
|
||||
setattr(base, field, value)
|
||||
return True
|
||||
|
||||
__curried_set = renpy.curry(__set)
|
||||
|
||||
|
||||
def __show_preferences():
|
||||
|
||||
ime = _ImageMapper(
|
||||
"preferences",
|
||||
config.preferences_ground,
|
||||
config.preferences_idle,
|
||||
config.preferences_hover,
|
||||
config.preferences_selected_idle,
|
||||
config.preferences_selected_hover,
|
||||
config.preferences_hotspots)
|
||||
|
||||
def pref(name, pref, value):
|
||||
ime.button(
|
||||
name,
|
||||
__curried_set(_preferences, pref, value),
|
||||
getattr(_preferences, pref) == value)
|
||||
|
||||
pref("Window", "fullscreen", False)
|
||||
pref("Fullscreen", "fullscreen", True)
|
||||
|
||||
pref("All", "transitions", 2)
|
||||
pref("Some", "transitions", 1)
|
||||
pref("None", "transitions", 0)
|
||||
|
||||
pref("Seen Messages", "skip_unseen", False)
|
||||
pref("All Messages", "skip_unseen", True)
|
||||
|
||||
if not main_menu:
|
||||
ime.button("Begin Skipping", ui.jumps("_return_skipping"), False)
|
||||
|
||||
pref("Stop Skipping", "skip_after_choices", False)
|
||||
pref("Keep Skipping", "skip_after_choices", True)
|
||||
|
||||
if renpy.display.joystick.enabled or config.always_has_joystick:
|
||||
ime.button("Joystick", ui.jumps("joystick_preferences_screen"), False)
|
||||
|
||||
def play_sound():
|
||||
renpy.music.play(config.sample_sound, channel="sound")
|
||||
|
||||
ime.button("Sound Test", play_sound, False)
|
||||
|
||||
def play_voice():
|
||||
renpy.music.play(config.sample_sound, channel="voice")
|
||||
|
||||
ime.button("Voice Test", play_voice, False)
|
||||
|
||||
v = _preferences.text_cps
|
||||
if v == 0:
|
||||
v = 150
|
||||
else:
|
||||
v = v - 1
|
||||
|
||||
def set_text_cps(v):
|
||||
if v == 150:
|
||||
v = 0
|
||||
else:
|
||||
v = v + 1
|
||||
|
||||
_preferences.text_cps = v
|
||||
|
||||
ime.bar("Text Speed", 150, v, set_text_cps)
|
||||
|
||||
v = _preferences.afm_time
|
||||
if v == 0:
|
||||
v = 40
|
||||
else:
|
||||
v = v - 1
|
||||
|
||||
def set_afm_time(v):
|
||||
if v == 40:
|
||||
v = 0
|
||||
else:
|
||||
v = v + 1
|
||||
|
||||
_preferences.afm_time = v
|
||||
|
||||
ime.bar("Auto-Forward Time", 40, v, set_afm_time)
|
||||
|
||||
def set_music(v):
|
||||
_preferences.set_volume('music', v / 128.0)
|
||||
def set_sound(v):
|
||||
_preferences.set_volume('sfx', v / 128.0)
|
||||
def set_voice(v):
|
||||
_preferences.set_volume('voice', v / 128.0)
|
||||
|
||||
if config.has_music:
|
||||
ime.bar("Music Volume", 128, int(_preferences.get_volume('music') * 128), set_music)
|
||||
if config.has_sound:
|
||||
ime.bar("Sound Volume", 128, int(_preferences.get_volume('sfx') * 128), set_sound)
|
||||
if config.has_voice:
|
||||
ime.bar("Voice Volume", 128, int(_preferences.get_volume('voice') * 128), set_voice)
|
||||
|
||||
ime.close()
|
||||
ui.interact(mouse="gamemenu")
|
||||
|
||||
label preferences_screen:
|
||||
|
||||
while True:
|
||||
$ __show_preferences()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python hide:
|
||||
|
||||
layout.provides('yesno_prompt')
|
||||
|
||||
renpy.load_module("_layout/imagemap_common")
|
||||
|
||||
# Define styles
|
||||
style.yesno_prompt = Style(style.prompt, help="a yes/no prompt")
|
||||
style.yesno_prompt_text = Style(style.prompt_text, help="a yes/no prompt (text)")
|
||||
|
||||
# Define config variables.
|
||||
config.yesno_prompt_ground = None
|
||||
config.yesno_prompt_idle = None
|
||||
config.yesno_prompt_hover = None
|
||||
config.yesno_prompt_hotspots = None
|
||||
|
||||
config.yesno_prompt_message_images = { }
|
||||
|
||||
|
||||
def yesno_prompt(screen, message):
|
||||
renpy.transition(config.intra_transition)
|
||||
|
||||
ime = _ImageMapper(
|
||||
screen,
|
||||
config.yesno_prompt_ground,
|
||||
config.yesno_prompt_idle,
|
||||
config.yesno_prompt_hover,
|
||||
config.yesno_prompt_idle,
|
||||
config.yesno_prompt_hover,
|
||||
config.yesno_prompt_hotspots)
|
||||
|
||||
ime.button("Yes", ui.returns(True), False)
|
||||
ime.button("No", ui.returns(False), False)
|
||||
|
||||
ime.close()
|
||||
|
||||
default = config.yesno_prompt_message_images.get(layout.ARE_YOU_SURE, None)
|
||||
message_image = config.yesno_prompt_message_images.get(message, default)
|
||||
|
||||
if message_image:
|
||||
ui.add(message_image)
|
||||
else:
|
||||
layout.prompt(message, "yesno")
|
||||
|
||||
rv = ui.interact(mouse="gamemenu")
|
||||
renpy.transition(config.intra_transition)
|
||||
return rv
|
||||
|
||||
layout.yesno_prompt = yesno_prompt
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('preferences')
|
||||
|
||||
# Load the common code.
|
||||
renpy.load_module("_layout/classic_preferences_common")
|
||||
|
||||
# Create styles.
|
||||
style.prefs_column = Style(style.vbox, help="the single preferences column")
|
||||
|
||||
style.prefs_frame.set_parent(style.menu_frame)
|
||||
style.prefs_pref_frame.set_parent(style.default)
|
||||
|
||||
# Adjust styles.
|
||||
style.prefs_frame_box.box_layout = 'vertical'
|
||||
|
||||
style.prefs_frame.xalign = 0.0
|
||||
style.prefs_frame.ypos = 10
|
||||
style.prefs_frame.xmargin = 10
|
||||
|
||||
style.prefs_slider.xmaximum = 200
|
||||
style.prefs_slider.xalign = 1.0
|
||||
|
||||
style.prefs_volume_slider.xmaximum = 200
|
||||
style.prefs_volume_slider.xalign = 1.0
|
||||
style.prefs_volume_box.xalign = 1.0
|
||||
style.prefs_volume_box.box_layout = 'horizontal'
|
||||
|
||||
style.prefs_pref_box.xfill = True
|
||||
style.prefs_pref_box.box_layout = 'horizontal'
|
||||
style.prefs_pref_choicebox.box_layout = 'horizontal'
|
||||
style.prefs_pref_choicebox.xalign = 1.0
|
||||
|
||||
style.prefs_jump.xfill = True
|
||||
|
||||
style.prefs_column.box_spacing = 5
|
||||
|
||||
style.soundtest_button.xalign = 1.0
|
||||
style.prefs_jump_button.xalign = 1.0
|
||||
|
||||
config.translations["Fullscreen 16:9"] = "16:9"
|
||||
config.translations["Fullscreen 16:10"] = "16:10"
|
||||
|
||||
config.soundtest_before_volume = True
|
||||
|
||||
|
||||
# Place preferences into groups.
|
||||
config.preferences['prefs_column'] = [
|
||||
config.all_preferences[u'Display'],
|
||||
config.all_preferences[u'Transitions'],
|
||||
config.all_preferences[u'Skip'],
|
||||
config.all_preferences[u'Begin Skipping'],
|
||||
config.all_preferences[u'After Choices'],
|
||||
config.all_preferences[u'Text Speed'],
|
||||
config.all_preferences[u'Auto-Forward Time'],
|
||||
config.all_preferences[u'Music Volume'],
|
||||
config.all_preferences[u'Sound Volume'],
|
||||
config.all_preferences[u'Voice Volume'],
|
||||
config.all_preferences[u'Joystick...'],
|
||||
]
|
||||
|
||||
|
||||
label preferences_screen:
|
||||
|
||||
$ _prefs_screen_run(config.preferences)
|
||||
|
||||
jump preferences_screen
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('joystick_preferences')
|
||||
|
||||
label joystick_preferences_screen:
|
||||
|
||||
$ renpy.show_screen('joystick_preferences')
|
||||
$ ui.interact()
|
||||
|
||||
jump _noisy_return
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('load_save')
|
||||
|
||||
label load_screen:
|
||||
|
||||
$ renpy.show_screen('load')
|
||||
$ ui.interact()
|
||||
jump _noisy_return
|
||||
|
||||
label save_screen:
|
||||
|
||||
$ renpy.show_screen('save')
|
||||
$ ui.interact()
|
||||
jump _noisy_return
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('main_menu')
|
||||
|
||||
label main_menu_screen:
|
||||
|
||||
$ renpy.show_screen("main_menu")
|
||||
$ ui.interact()
|
||||
|
||||
return
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('preferences')
|
||||
|
||||
label preferences_screen:
|
||||
|
||||
$ renpy.show_screen('preferences')
|
||||
$ ui.interact()
|
||||
|
||||
jump _noisy_return
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python hide:
|
||||
|
||||
layout.provides('yesno_prompt')
|
||||
|
||||
def yesno_prompt(screen, message):
|
||||
rv = renpy.call_screen('yesno_prompt', message=message, yes_action=Return(True), no_action=Return(False))
|
||||
return rv
|
||||
|
||||
layout.yesno_prompt = yesno_prompt
|
||||
@@ -1,229 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('load_save')
|
||||
|
||||
# Store some global information that won't be saved.
|
||||
__session = object()
|
||||
__session.scrollbar_position = None
|
||||
|
||||
# Should we prompt to load?
|
||||
_load_prompt = True
|
||||
|
||||
# The number of normal save slots.
|
||||
config.load_save_slots = 50
|
||||
|
||||
# The number of autosave slots.
|
||||
config.load_save_auto_slots = 5
|
||||
|
||||
# The number of quicksave slots.
|
||||
config.load_save_quick_slots = 5
|
||||
|
||||
# How we format time in a file entry.
|
||||
config.time_format = "%b %d, %H:%M"
|
||||
|
||||
# How we format a file entry.
|
||||
config.file_entry_format = "%(time)s\n%(save_name)s"
|
||||
|
||||
# Set the default size of thumbnails.
|
||||
config.thumbnail_width = 320
|
||||
config.thumbnail_height = 240
|
||||
|
||||
# The default empty slot thumbnail.
|
||||
config.load_save_empty_thumbnail = None
|
||||
|
||||
# Styles.
|
||||
style.file_picker_frame = Style(style.frame, help="frame containing the file picker")
|
||||
style.file_picker_side = Style(style.default, help="ui.side containing the file picker and the scrollbars")
|
||||
style.file_picker_viewport = Style(style.viewport, help="viewport containing the file picker entries")
|
||||
style.file_picker_box = Style(style.vbox, help="box containing the file picker entries")
|
||||
style.file_picker_entry = Style(style.large_button, help="the buttons containing information about each file")
|
||||
style.file_picker_text = Style(style.large_button_text, help="the text inside a file picker entry.")
|
||||
style.file_picker_scrollbar = Style(style.vscrollbar, help="the text inside a file picker entry.")
|
||||
|
||||
style.thumbnail_frame = Style(style.frame, help="the style of the frame containing a thumbnail")
|
||||
|
||||
|
||||
# Position things correctly.
|
||||
style.file_picker_frame.xmaximum = 0.5
|
||||
style.file_picker_frame.xmargin = 6
|
||||
style.file_picker_frame.ymargin = 6
|
||||
style.file_picker_frame.yfill = True
|
||||
|
||||
style.file_picker_entry.xfill = True
|
||||
style.file_picker_entry.yminimum = 58
|
||||
|
||||
style.thumbnail_frame.ymargin = 6
|
||||
style.thumbnail_frame.xpos = 0.75
|
||||
style.thumbnail_frame.xanchor = 0.5
|
||||
|
||||
def _file_picker_thumbnail(st, at):
|
||||
if __session.thumbnail:
|
||||
rv = __session.thumbnail
|
||||
elif config.load_save_empty_thumbnail:
|
||||
rv = config.load_save_empty_thumbnail
|
||||
else:
|
||||
rv = Null(width=config.thumbnail_width, height=config.thumbnail_height)
|
||||
|
||||
return rv, None
|
||||
|
||||
|
||||
def _file_picker(screen):
|
||||
|
||||
while True:
|
||||
|
||||
@renpy.curry
|
||||
def hovered(thumbnail):
|
||||
if __session.thumbnail is not thumbnail:
|
||||
__session.thumbnail = thumbnail
|
||||
renpy.restart_interaction()
|
||||
|
||||
@renpy.curry
|
||||
def unhovered(thumbnail):
|
||||
if __session.thumbnail is thumbnail:
|
||||
__session.thumbnail = None
|
||||
renpy.restart_interaction()
|
||||
|
||||
__session.thumbnail = None
|
||||
|
||||
layout.navigation(screen)
|
||||
|
||||
newest = None
|
||||
newest_time = None
|
||||
|
||||
info = { }
|
||||
|
||||
for name, extra_info, thumbnail, time in renpy.list_saved_games():
|
||||
|
||||
info[name] = (extra_info, thumbnail, time)
|
||||
|
||||
if not name[0] in "0123456789":
|
||||
continue
|
||||
|
||||
if time > newest_time:
|
||||
newest = name
|
||||
newest_time = time
|
||||
|
||||
slots = [ ]
|
||||
|
||||
for i in range(1, config.load_save_slots + 1):
|
||||
slots.append((str(i), str(i)))
|
||||
|
||||
if config.has_quicksave:
|
||||
for i in range(1, config.load_save_quick_slots + 1):
|
||||
slots.append(('quick-'+ str(i), _(u'q') + str(i)))
|
||||
|
||||
if config.has_autosave:
|
||||
for i in range(1, config.load_save_auto_slots + 1):
|
||||
slots.append(('auto-' + str(i), _(u'a') + str(i)))
|
||||
|
||||
ui.frame(style=style.file_picker_frame)
|
||||
ui.side(['c', 'r'], style=style.file_picker_side)
|
||||
|
||||
|
||||
|
||||
if __session.scrollbar_position is None:
|
||||
if newest is None:
|
||||
yoffset = 0
|
||||
else:
|
||||
yoffset = 1.0 * (int(newest) - 1) / len(slots)
|
||||
value = 0
|
||||
|
||||
else:
|
||||
value = __session.scrollbar_position
|
||||
yoffset = None
|
||||
|
||||
adj = ui.adjustment(value=value)
|
||||
ui.viewport(yadjustment=adj, offsets=(0, yoffset), style=style.file_picker_viewport, mousewheel=True)
|
||||
|
||||
ui.vbox(style=style.file_picker_box, focus=renpy.time.time())
|
||||
|
||||
|
||||
for i, (fn, n) in enumerate(slots):
|
||||
|
||||
clicked = ui.returns(("select", fn))
|
||||
|
||||
if screen == "save" and fn.startswith("auto-"):
|
||||
clicked = None
|
||||
|
||||
if screen == "load" and fn not in info:
|
||||
clicked = None
|
||||
|
||||
if fn in info:
|
||||
extra_info, thumbnail, time = info[fn]
|
||||
|
||||
ui.button(style=style.file_picker_entry[i],
|
||||
clicked=clicked,
|
||||
hovered=hovered(thumbnail),
|
||||
unhovered=unhovered(thumbnail),
|
||||
role = "selected_" if (fn == newest) else "",
|
||||
keymap = { "save_delete" : ui.returns(("unlink", fn)) },
|
||||
)
|
||||
|
||||
s = config.file_entry_format % dict(
|
||||
time=renpy.time.strftime(
|
||||
config.time_format,
|
||||
renpy.time.localtime(time)),
|
||||
save_name=extra_info)
|
||||
|
||||
ui.text(n + ". " + s, style=style.file_picker_text[i])
|
||||
|
||||
else:
|
||||
ui.button(style=style.file_picker_entry[i],
|
||||
clicked=clicked,
|
||||
role = "selected_" if (fn == newest) else "")
|
||||
|
||||
ui.text(n + ". " + _(u"Empty Slot."),
|
||||
style=style.file_picker_text[i])
|
||||
|
||||
ui.close() # vbox/viewport
|
||||
|
||||
ui.bar(adjustment=adj, style=style.file_picker_scrollbar)
|
||||
|
||||
ui.close() # side/window
|
||||
|
||||
# Thumbnail.
|
||||
ui.frame(style=style.thumbnail_frame)
|
||||
ui.add(DynamicDisplayable(_file_picker_thumbnail))
|
||||
|
||||
try:
|
||||
action, arg = ui.interact(mouse="gamemenu")
|
||||
finally:
|
||||
__session.scrollbar_position = adj.value
|
||||
__session.thumbnail = None
|
||||
|
||||
if action == "select":
|
||||
return arg
|
||||
|
||||
elif action == "unlink":
|
||||
if layout.yesno_prompt("save", layout.DELETE_SAVE):
|
||||
renpy.unlink_save(arg)
|
||||
|
||||
|
||||
label save_screen:
|
||||
|
||||
python hide:
|
||||
while True:
|
||||
fn = _file_picker("save")
|
||||
|
||||
if renpy.can_load(fn):
|
||||
if not layout.yesno_prompt("save", layout.OVERWRITE_SAVE):
|
||||
continue
|
||||
|
||||
renpy.save(fn, extra_info=store.save_name)
|
||||
|
||||
|
||||
label load_screen:
|
||||
|
||||
python hide:
|
||||
|
||||
while True:
|
||||
fn = _file_picker("load")
|
||||
|
||||
if _load_prompt:
|
||||
if not layout.yesno_prompt("load", layout.LOADING):
|
||||
continue
|
||||
|
||||
renpy.load(fn)
|
||||
@@ -1,81 +0,0 @@
|
||||
# Copyright 2004-2012 Tom Rothamel <pytom@bishoujo.us>
|
||||
# See LICENSE.txt for license details.
|
||||
|
||||
init python:
|
||||
|
||||
layout.provides('preferences')
|
||||
|
||||
# Load the common code.
|
||||
renpy.load_module("_layout/classic_preferences_common")
|
||||
|
||||
# Create styles.
|
||||
style.prefs_column = Style(style.vbox, help="columns of preferences")
|
||||
style.prefs_left = Style(style.prefs_column, help="the left preference column")
|
||||
style.prefs_right = Style(style.prefs_column, help="the right preference column")
|
||||
|
||||
style.prefs_left.xmaximum = 520
|
||||
style.prefs_right.xmaximum = 250
|
||||
|
||||
style.prefs_left.xpos = 271
|
||||
style.prefs_left.xanchor = 0.5
|
||||
style.prefs_left.ypos = 10
|
||||
|
||||
style.prefs_right.xpos = 667
|
||||
style.prefs_right.xanchor = 0.5
|
||||
style.prefs_right.ypos = 10
|
||||
|
||||
style.prefs_slider.xmaximum = 400
|
||||
style.prefs_slider.xalign = 1.0
|
||||
|
||||
style.prefs_volume_slider.xmaximum = 200
|
||||
style.prefs_volume_slider.xalign = 1.0
|
||||
|
||||
style.prefs_pref_box.xfill = True
|
||||
style.prefs_pref_choicebox.box_layout = 'horizontal'
|
||||
style.prefs_pref_choicebox.xalign = 1.0
|
||||
style.prefs_volume_box.xalign = 1.0
|
||||
|
||||
style.prefs_jump.xfill = True
|
||||
|
||||
style.prefs_column.box_spacing = 5
|
||||
|
||||
style.prefs_button.set_parent(style.small_button)
|
||||
style.prefs_button_text.set_parent(style.small_button_text)
|
||||
|
||||
style.soundtest_button.xalign = 1.0
|
||||
style.prefs_jump_button.xalign = 1.0
|
||||
|
||||
|
||||
config.sample_voice = "18005551212.ogg"
|
||||
|
||||
config.translations["Fullscreen 16:9"] = "16:9"
|
||||
config.translations["Fullscreen 16:10"] = "16:10"
|
||||
|
||||
|
||||
|
||||
|
||||
# Place preferences into groups.
|
||||
config.preferences['prefs_left'] = [
|
||||
config.all_preferences[u'Display'],
|
||||
config.all_preferences[u'Transitions'],
|
||||
config.all_preferences[u'Skip'],
|
||||
config.all_preferences[u'Begin Skipping'],
|
||||
config.all_preferences[u'After Choices'],
|
||||
config.all_preferences[u'Text Speed'],
|
||||
config.all_preferences[u'Auto-Forward Time'],
|
||||
]
|
||||
|
||||
config.preferences['prefs_right'] = [
|
||||
config.all_preferences[u'Music Volume'],
|
||||
config.all_preferences[u'Sound Volume'],
|
||||
config.all_preferences[u'Voice Volume'],
|
||||
config.all_preferences[u'Joystick...'],
|
||||
]
|
||||
|
||||
|
||||
label preferences_screen:
|
||||
|
||||
$ _prefs_screen_run(config.preferences)
|
||||
|
||||
jump preferences_screen
|
||||
|
||||
|
Before Width: | Height: | Size: 171 B |
|
Before Width: | Height: | Size: 340 B |
|
Before Width: | Height: | Size: 175 B |
|
Before Width: | Height: | Size: 386 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 279 B |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 897 B |
|
Before Width: | Height: | Size: 476 B |
|
Before Width: | Height: | Size: 867 B |
|
Before Width: | Height: | Size: 1014 B |
|
Before Width: | Height: | Size: 391 B |
|
Before Width: | Height: | Size: 1017 B |
|
Before Width: | Height: | Size: 529 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 374 B |
|
Before Width: | Height: | Size: 325 B |
|
Before Width: | Height: | Size: 554 B |
|
Before Width: | Height: | Size: 534 B |
|
Before Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 358 B |
|
Before Width: | Height: | Size: 474 B |
|
Before Width: | Height: | Size: 954 B |
|
Before Width: | Height: | Size: 733 B |
|
Before Width: | Height: | Size: 405 B |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 656 B |
|
Before Width: | Height: | Size: 789 B |
|
Before Width: | Height: | Size: 409 B |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 623 B |