Compare commits
35 Commits
6.18
...
6.17.2.319
| Author | SHA1 | Date | |
|---|---|---|---|
| a0a58c9129 | |||
| ecd1ccf0e7 | |||
| d89d4f4f94 | |||
| cd2029e759 | |||
| c50e91e970 | |||
| d7482744e8 | |||
| 7cc5cfcbae | |||
| 918158fcae | |||
| 23e2f4f0a8 | |||
| 25a6ec4ce6 | |||
| 0c04e5e861 | |||
| 6f328c8984 | |||
| 61d2ad2202 | |||
| 93acff591f | |||
| 314446cffd | |||
| e5186a7d63 | |||
| aaba96b31e | |||
| ca1f9855fa | |||
| 3c6eb040f8 | |||
| 856a99c3f2 | |||
| 959434f404 | |||
| 435ef3f5b6 | |||
| e5d39cf4de | |||
| c03fa98992 | |||
| 195d3eb8e2 | |||
| f6a2e7ed1f | |||
| cb3bc2341f | |||
| dcc38c3ab6 | |||
| d37188abfe | |||
| b97ec70769 | |||
| aaec19d784 | |||
| c44ef66bcb | |||
| 104e46bb45 | |||
| 4da70a637c | |||
| e10325aa7d |
@@ -47,7 +47,6 @@ check_dirty()
|
||||
|
||||
os.chdir("/home/tom/ab/renpy/android")
|
||||
check_dirty()
|
||||
subprocess.check_call([ "./add_renpy.sh", short_version ])
|
||||
|
||||
if not args.no_tag:
|
||||
subprocess.check_call([ "git", "tag", "-a", "rapt-" + version, "-m", "Tagging RAPT release." ])
|
||||
|
||||
@@ -92,6 +92,8 @@ init python:
|
||||
return ANDROID_NO_SDK
|
||||
if not os.path.exists(os.path.join(RAPT_PATH, "android.keystore")):
|
||||
return ANDROID_NO_KEY
|
||||
if not os.path.exists(os.path.join(RAPT_PATH, "local.properties")):
|
||||
return ANDROID_NO_KEY
|
||||
if not os.path.exists(os.path.join(project.current.path, ".android.json")):
|
||||
return ANDROID_NO_CONFIG
|
||||
return ANDROID_OK
|
||||
|
||||
@@ -24,12 +24,13 @@
|
||||
# This contains code for scanning for editors, and for allowing the user to
|
||||
# select an editor.
|
||||
|
||||
init python in editor:
|
||||
init 1 python in editor:
|
||||
|
||||
from store import Action, renpy, config, persistent
|
||||
import store.project as project
|
||||
import store.updater as updater
|
||||
import store.interface as interface
|
||||
import store.util as util
|
||||
import store
|
||||
|
||||
import glob
|
||||
@@ -83,8 +84,19 @@ init python in editor:
|
||||
if d is None:
|
||||
continue
|
||||
|
||||
for filename in glob.glob(d + "/*/*.edit.py"):
|
||||
scan_editor(filename)
|
||||
if not os.path.isdir(d):
|
||||
continue
|
||||
|
||||
for i in util.listdir(d):
|
||||
i = os.path.join(d, i)
|
||||
if not os.path.isdir(d):
|
||||
continue
|
||||
|
||||
for j in util.listdir(i):
|
||||
j = os.path.join(i, j)
|
||||
|
||||
if j.endswith(".edit.py"):
|
||||
scan_editor(j)
|
||||
|
||||
########################################################################
|
||||
|
||||
|
||||
@@ -67,6 +67,9 @@ label new_project:
|
||||
if persistent.projects_directory is None:
|
||||
call choose_projects_directory
|
||||
|
||||
if persistent.projects_directory is None:
|
||||
$ interface.error(_("The projects directory could not be set. Giving up."))
|
||||
|
||||
python hide:
|
||||
|
||||
project_name = interface.input(
|
||||
|
||||
@@ -380,7 +380,8 @@ init python in project:
|
||||
if not os.path.isdir(d):
|
||||
return
|
||||
|
||||
for pdir in os.listdir(d):
|
||||
for pdir in util.listdir(d):
|
||||
|
||||
ppath = os.path.join(d, pdir)
|
||||
|
||||
# A project must be a directory.
|
||||
@@ -595,7 +596,11 @@ label choose_projects_directory:
|
||||
|
||||
path = renpy.fsdecode(path)
|
||||
|
||||
persistent.projects_directory = path
|
||||
if os.path.isdir(path):
|
||||
persistent.projects_directory = path
|
||||
else:
|
||||
path = os.path.abspath(config.renpy_base)
|
||||
|
||||
project.manager.scan()
|
||||
|
||||
return
|
||||
|
||||
@@ -1,15 +1,35 @@
|
||||
translate japanese python:
|
||||
MTLC = "tl/japanese/MTLc3m.ttf"
|
||||
style.l_default.font = MTLC
|
||||
style.l_default.size = 16
|
||||
style.l_button_text.selected_font = MTLC
|
||||
style.l_button_text.selected_bold = True
|
||||
style.l_link_text.font = MTLC
|
||||
style.l_alternate_text.font = MTLC
|
||||
style.l_navigation_button_text.font = MTLC
|
||||
style.l_navigation_text.font = MTLC
|
||||
style.l_navigation_text.bold = True
|
||||
style.l_checkbox_text.selected_font = MTLC
|
||||
style.l_nonbox_text.selected_font = MTLC
|
||||
style.hyperlink_text.font = MTLC
|
||||
make_style_backup()
|
||||
translate japanese python:
|
||||
MTLC = "tl/japanese/MTLc3m.ttf"
|
||||
|
||||
translate japanese style l_default:
|
||||
font MTLC
|
||||
size 16
|
||||
|
||||
translate japanese style l_button_text:
|
||||
selected_font MTLC
|
||||
selected_bold True
|
||||
|
||||
translate japanese style l_link_text:
|
||||
font MTLC
|
||||
|
||||
translate japanese style l_alternate_text:
|
||||
font MTLC
|
||||
|
||||
translate japanese style l_navigation_button_text:
|
||||
font MTLC
|
||||
|
||||
translate japanese style l_navigation_text:
|
||||
font MTLC
|
||||
bold True
|
||||
|
||||
translate japanese style l_checkbox_text:
|
||||
selected_font MTLC
|
||||
|
||||
translate japanese style l_nonbox_text:
|
||||
selected_font MTLC
|
||||
|
||||
translate japanese style hyperlink_text:
|
||||
font MTLC
|
||||
|
||||
translate japanese python:
|
||||
make_style_backup()
|
||||
|
||||
+24
-1
@@ -19,9 +19,26 @@
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
init python in util:
|
||||
init -1 python in util:
|
||||
import os
|
||||
|
||||
def listdir(d):
|
||||
"""
|
||||
Returns a list of files and directories in `d` that are accessible with
|
||||
the filesystem encoding.
|
||||
"""
|
||||
|
||||
try:
|
||||
d = renpy.fsdecode(d)
|
||||
|
||||
if not os.path.isdir(d):
|
||||
return [ ]
|
||||
|
||||
return [ i for i in os.listdir(d) if isinstance(i, unicode) ]
|
||||
|
||||
except:
|
||||
return [ ]
|
||||
|
||||
def walk(directory, base=None):
|
||||
"""
|
||||
Walks through the directories and files underneath `directory`,
|
||||
@@ -38,6 +55,9 @@ init python in util:
|
||||
|
||||
for subdir, directories, files in os.walk(directory):
|
||||
for fn in directories:
|
||||
if not isinstance(fn, unicode):
|
||||
continue
|
||||
|
||||
fullfn = os.path.join(subdir, fn)
|
||||
relfn = os.path.relpath(fullfn, base)
|
||||
|
||||
@@ -46,6 +66,9 @@ init python in util:
|
||||
yield relfn, True
|
||||
|
||||
for fn in files:
|
||||
if not isinstance(fn, unicode):
|
||||
continue
|
||||
|
||||
fullfn = os.path.join(subdir, fn)
|
||||
relfn = os.path.relpath(fullfn, base)
|
||||
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ except ImportError:
|
||||
vc_version = 0
|
||||
|
||||
# The tuple giving the version number.
|
||||
version_tuple = (6, 18, 0, vc_version)
|
||||
version_tuple = (6, 17, 2, vc_version)
|
||||
|
||||
# The name of this version.
|
||||
version_name = "In This Decade..."
|
||||
|
||||
@@ -1811,6 +1811,11 @@ class TranslateString(Node):
|
||||
renpy.translation.add_string_translation(self.language, self.old, self.new)
|
||||
|
||||
class TranslatePython(Node):
|
||||
"""
|
||||
Runs python code when changing the language.
|
||||
|
||||
This is no longer generated, but is still run when encountered.
|
||||
"""
|
||||
|
||||
__slots__ = [
|
||||
'language',
|
||||
@@ -1841,6 +1846,40 @@ class TranslatePython(Node):
|
||||
# renpy.python.create_store(self.store)
|
||||
# renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
|
||||
|
||||
|
||||
class TranslateBlock(Node):
|
||||
"""
|
||||
Runs a block of code when changing the language.
|
||||
"""
|
||||
|
||||
__slots__ = [
|
||||
'block',
|
||||
'language',
|
||||
]
|
||||
|
||||
def __init__(self, loc, language, block):
|
||||
super(TranslateBlock, self).__init__(loc)
|
||||
|
||||
self.language = language
|
||||
self.block = block
|
||||
|
||||
def get_children(self):
|
||||
return self.block
|
||||
|
||||
# We handle chaining specially. We want to chain together the nodes in
|
||||
# the block, but we want that chain to end in None, and we also want
|
||||
# this node to just continue on to the next node in normal execution.
|
||||
def chain(self, next): #@ReservedAssignment
|
||||
self.next = next
|
||||
chain_block(self.block, None)
|
||||
|
||||
def execute(self):
|
||||
next_node(self.next)
|
||||
statement_name("translate_block")
|
||||
|
||||
def restructure(self, callback):
|
||||
callback(self.block)
|
||||
|
||||
class Style(Node):
|
||||
|
||||
__slots__ = [
|
||||
|
||||
+18
-18
@@ -176,14 +176,14 @@ init -1500 python in _console:
|
||||
message = ""
|
||||
|
||||
if self.first_time:
|
||||
message += renpy.version() + " console, originally by Shiz, C, and delta.\n"
|
||||
message += "Press <esc> to exit console. Type help for help.\n"
|
||||
message += __("%(version)s console, originally by Shiz, C, and delta.\n") % {"version": renpy.version()}
|
||||
message += __("Press <esc> to exit console. Type help for help.\n")
|
||||
self.first_time = False
|
||||
|
||||
if self.can_renpy():
|
||||
message += "Ren'Py script enabled."
|
||||
message += __("Ren'Py script enabled.")
|
||||
else:
|
||||
message += "Ren'Py script disabled."
|
||||
message += __("Ren'Py script disabled.")
|
||||
|
||||
he.result = message
|
||||
self.history.append(he)
|
||||
@@ -389,24 +389,24 @@ init -1500 python in _console:
|
||||
|
||||
return wrap
|
||||
|
||||
@command("help: show this help")
|
||||
@command(_("help: show this help"))
|
||||
def help(l):
|
||||
keys = list(config.console_commands.iterkeys())
|
||||
keys.sort()
|
||||
|
||||
rv = "commands:\n"
|
||||
rv = __("commands:\n")
|
||||
|
||||
for k in keys:
|
||||
f = config.console_commands[k]
|
||||
if f.help is None:
|
||||
continue
|
||||
|
||||
rv += " " + f.help + "\n"
|
||||
rv += " " + __(f.help) + "\n"
|
||||
|
||||
if console.can_renpy():
|
||||
rv += " <renpy script statement>: run the statement\n"
|
||||
rv += __(" <renpy script statement>: run the statement\n")
|
||||
|
||||
rv += " <python expression or statement>: run the expression or statement"
|
||||
rv += __(" <python expression or statement>: run the expression or statement")
|
||||
|
||||
return rv
|
||||
|
||||
@@ -414,11 +414,11 @@ init -1500 python in _console:
|
||||
def halp(l):
|
||||
return help(l).replace("e", "a")
|
||||
|
||||
@command("clear: clear the console history")
|
||||
@command(_("clear: clear the console history"))
|
||||
def clear(l):
|
||||
console.history[:] = [ ]
|
||||
|
||||
@command("exit: exit the console")
|
||||
@command(_("exit: exit the console"))
|
||||
def exit(l):
|
||||
renpy.jump("_console_return")
|
||||
|
||||
@@ -426,7 +426,7 @@ init -1500 python in _console:
|
||||
def quit(l):
|
||||
renpy.jump("_console_return")
|
||||
|
||||
@command("load <slot>: loads the game from slot")
|
||||
@command(_("load <slot>: loads the game from slot"))
|
||||
def load(l):
|
||||
name = l.rest().strip()
|
||||
|
||||
@@ -439,7 +439,7 @@ init -1500 python in _console:
|
||||
console.history[-1].result = "Loading slot {!r}.".format(name)
|
||||
|
||||
|
||||
@command("save <slot>: saves the game in slot")
|
||||
@command(_("save <slot>: saves the game in slot"))
|
||||
def save(l):
|
||||
name = l.rest().strip()
|
||||
|
||||
@@ -450,7 +450,7 @@ init -1500 python in _console:
|
||||
|
||||
return "Saved slot {!r}.".format(name)
|
||||
|
||||
@command("reload: reloads the game, refreshing the scripts")
|
||||
@command(_("reload: reloads the game, refreshing the scripts"))
|
||||
def reload(l):
|
||||
store._reload_game()
|
||||
|
||||
@@ -458,7 +458,7 @@ init -1500 python in _console:
|
||||
def R(l):
|
||||
store._reload_game()
|
||||
|
||||
@command("watch <expression>: watch a python expression")
|
||||
@command(_("watch <expression>: watch a python expression"))
|
||||
def watch(l):
|
||||
expr = l.rest()
|
||||
expr.strip()
|
||||
@@ -467,7 +467,7 @@ init -1500 python in _console:
|
||||
traced_expressions.append(expr)
|
||||
renpy.show_screen("_trace_screen")
|
||||
|
||||
@command("unwatch <expression>: stop watching an expression")
|
||||
@command(_("unwatch <expression>: stop watching an expression"))
|
||||
def unwatch(l):
|
||||
expr = l.rest()
|
||||
expr.strip()
|
||||
@@ -475,13 +475,13 @@ init -1500 python in _console:
|
||||
if expr in traced_expressions:
|
||||
traced_expressions.remove(expr)
|
||||
|
||||
@command("unwatchall: stop watching all expressions")
|
||||
@command(_("unwatchall: stop watching all expressions"))
|
||||
def unwatchall(l):
|
||||
traced_expressions[:] = [ ]
|
||||
renpy.hide_screen("_trace_screen")
|
||||
|
||||
|
||||
@command("jump <label>: jumps to label")
|
||||
@command(_("jump <label>: jumps to label"))
|
||||
def jump(l):
|
||||
label = l.name()
|
||||
|
||||
|
||||
@@ -129,6 +129,10 @@ init -1500 python:
|
||||
|
||||
`stop_action`
|
||||
An action to run when the music has stopped.
|
||||
|
||||
Single_track and shuffle conflict with each other. Only one should
|
||||
be true at a time. (Actions that set single_track and shuffle
|
||||
enforce this.)
|
||||
"""
|
||||
|
||||
self.channel = channel
|
||||
@@ -165,7 +169,10 @@ init -1500 python:
|
||||
self.single_track = single_track
|
||||
|
||||
# Should we shuffle the playlist?
|
||||
self.shuffle = shuffle
|
||||
if self.single_track:
|
||||
self.shuffle = False
|
||||
else:
|
||||
self.shuffle = shuffle
|
||||
|
||||
# In older versions, loop would loop a single trak.
|
||||
if self.loop_compat and loop:
|
||||
@@ -435,7 +442,10 @@ init -1500 python:
|
||||
This action sets the value of the single_track property.
|
||||
"""
|
||||
|
||||
return [ SetField(self, "single_track", value), self.queue_if_playing ]
|
||||
if value:
|
||||
return [ SetField(self, "single_track", value), SetField(self, "shuffle", False), self.queue_if_playing ]
|
||||
else:
|
||||
return [ SetField(self, "single_track", value), self.queue_if_playing ]
|
||||
|
||||
|
||||
def SetShuffle(self, value):
|
||||
@@ -445,7 +455,10 @@ init -1500 python:
|
||||
This action sets the value of the shuffle property.
|
||||
"""
|
||||
|
||||
return [ SetField(self, "shuffle", value), self.queue_if_playing ]
|
||||
if value:
|
||||
return [ SetField(self, "shuffle", value), SetField(self, "single_track", False), self.queue_if_playing ]
|
||||
else:
|
||||
return [ SetField(self, "shuffle", value), self.queue_if_playing ]
|
||||
|
||||
def ToggleLoop(self):
|
||||
"""
|
||||
@@ -464,7 +477,7 @@ init -1500 python:
|
||||
This action toggles the value of the single_track property.
|
||||
"""
|
||||
|
||||
return [ ToggleField(self, "single_track"), self.queue_if_playing ]
|
||||
return [ ToggleField(self, "single_track"), SetField(self, "shuffle", False), self.queue_if_playing ]
|
||||
|
||||
def ToggleShuffle(self):
|
||||
"""
|
||||
@@ -473,4 +486,4 @@ init -1500 python:
|
||||
This action toggles the value of the shuffle property.
|
||||
"""
|
||||
|
||||
return [ ToggleField(self, "shuffle"), self.queue_if_playing ]
|
||||
return [ ToggleField(self, "shuffle"), SetField(self, "single_track", False), self.queue_if_playing ]
|
||||
|
||||
@@ -406,14 +406,14 @@ init python:
|
||||
rv.blit(sr, (minx, miny))
|
||||
|
||||
# text.append("Imagemap rectangle: %r" % ((minx, miny, maxx, maxy),))
|
||||
text.append(_("Rectangle: %r") % ((minx, miny, w, h),))
|
||||
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(__("Mouse position: %r") % (self.mouse,))
|
||||
|
||||
text.append(_("Right-click or escape to quit."))
|
||||
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)
|
||||
|
||||
+1
-1
@@ -543,7 +543,7 @@ def input(prompt, default='', allow=None, exclude='{}', length=None, with_none=N
|
||||
|
||||
`pixel_width`
|
||||
If not None, the input is limited to being this many pixels wide,
|
||||
in the font used by the
|
||||
in the font used by the input to display text.
|
||||
"""
|
||||
|
||||
renpy.exports.mode('input')
|
||||
|
||||
+22
-13
@@ -1857,6 +1857,7 @@ def screen_statement(l, loc):
|
||||
# The guts of screen language parsing is in screenlang.py. It
|
||||
# assumes we ate the "screen" keyword before it's called.
|
||||
screen = renpy.screenlang.parse_screen(l)
|
||||
|
||||
l.advance()
|
||||
|
||||
if not screen:
|
||||
@@ -1926,17 +1927,6 @@ def translate_strings(init_loc, language, l):
|
||||
|
||||
return ast.Init(init_loc, block, 0)
|
||||
|
||||
def translate_python(loc, language, l):
|
||||
l.require(':')
|
||||
l.expect_block('python block')
|
||||
|
||||
python_code = l.python_block()
|
||||
|
||||
l.advance()
|
||||
|
||||
return ast.TranslatePython(loc, language, python_code)
|
||||
|
||||
|
||||
@statement("translate")
|
||||
def translate_statement(l, loc):
|
||||
|
||||
@@ -1949,8 +1939,27 @@ def translate_statement(l, loc):
|
||||
|
||||
if identifier == "strings":
|
||||
return translate_strings(loc, language, l)
|
||||
|
||||
elif identifier == "python":
|
||||
return translate_python(loc, language, l)
|
||||
try:
|
||||
old_init = l.init
|
||||
l.init = True
|
||||
|
||||
block = [ python_statement(l, loc) ]
|
||||
return [ ast.TranslateBlock(loc, language, block) ]
|
||||
finally:
|
||||
l.init = old_init
|
||||
|
||||
elif identifier == "style":
|
||||
try:
|
||||
old_init = l.init
|
||||
l.init = True
|
||||
|
||||
block = [ style_statement(l, loc) ]
|
||||
return [ ast.TranslateBlock(loc, language, block) ]
|
||||
finally:
|
||||
l.init = old_init
|
||||
|
||||
|
||||
l.require(':')
|
||||
l.expect_eol()
|
||||
@@ -1965,7 +1974,7 @@ def translate_statement(l, loc):
|
||||
|
||||
|
||||
@statement("style")
|
||||
def style_statment(l, loc, rest_expression=False):
|
||||
def style_statement(l, loc):
|
||||
|
||||
# Parse priority and name.
|
||||
name = l.require(l.word)
|
||||
|
||||
+1
-1
@@ -639,7 +639,7 @@ class RevertableSet(sets.Set):
|
||||
class RevertableObject(object):
|
||||
|
||||
def __new__(cls, *args, **kwargs):
|
||||
self = super(RevertableObject, cls).__new__(cls, *args, **kwargs)
|
||||
self = super(RevertableObject, cls).__new__(cls)
|
||||
|
||||
log = renpy.game.log
|
||||
if log is not None:
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
# Copyright 2004-2014 Tom Rothamel <pytom@bishoujo.us>
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person
|
||||
# obtaining a copy of this software and associated documentation files
|
||||
# (the "Software"), to deal in the Software without restriction,
|
||||
# including without limitation the rights to use, copy, modify, merge,
|
||||
# publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
# and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# Import the Python AST module, instead of the Ren'Py ast module.
|
||||
ast = __import__("ast", { })
|
||||
|
||||
def is_constant(expr):
|
||||
"""
|
||||
Returns true if `expr` (a string) is constant for the purposes of
|
||||
the screen language.
|
||||
|
||||
Screen language ignores object identity for the purposes of
|
||||
object equality.
|
||||
"""
|
||||
|
||||
def check_slice(slice): # @ReservedAssignment
|
||||
|
||||
if isinstance(slice, ast.Index):
|
||||
return check_node(slice.value)
|
||||
|
||||
elif isinstance(slice, ast.Slice):
|
||||
if slice.lower and not check_node(slice.lower):
|
||||
return False
|
||||
if slice.upper and not check_node(slice.upper):
|
||||
return False
|
||||
if slice.step and not check_node(slice.step):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def check_nodes(nodes):
|
||||
"""
|
||||
Checks a list of nodes. Returns true if all are constant, and
|
||||
False otherwise.
|
||||
"""
|
||||
|
||||
for i in nodes:
|
||||
if not check_node(i):
|
||||
return False
|
||||
return True
|
||||
|
||||
def check_node(node):
|
||||
"""
|
||||
Returns true if the ast node `node` is constant.
|
||||
"""
|
||||
|
||||
#PY3: see if there are new node types.
|
||||
|
||||
if isinstance(node, (ast.Num, ast.Str)):
|
||||
return True
|
||||
|
||||
elif isinstance(node, (ast.List, ast.Tuple)):
|
||||
return check_nodes(node.elts)
|
||||
|
||||
elif isinstance(node, ast.BoolOp):
|
||||
return check_nodes(node.values)
|
||||
|
||||
elif isinstance(node, ast.BinOp):
|
||||
return (
|
||||
check_node(node.left) and
|
||||
check_node(node.right)
|
||||
)
|
||||
|
||||
elif isinstance(node, ast.UnaryOp):
|
||||
return check_node(node.operand)
|
||||
|
||||
elif isinstance(node, ast.IfExp):
|
||||
return (
|
||||
check_node(node.test) and
|
||||
check_node(node.body) and
|
||||
check_node(node.orelse)
|
||||
)
|
||||
|
||||
elif isinstance(node, ast.Dict):
|
||||
return (
|
||||
check_nodes(node.keys) and
|
||||
check_nodes(node.values)
|
||||
)
|
||||
|
||||
elif isinstance(node, ast.Set):
|
||||
return check_nodes(node.elts)
|
||||
|
||||
elif isinstance(node, ast.Compare):
|
||||
return (
|
||||
check_node(node.left) and
|
||||
check_nodes(node.comparators)
|
||||
)
|
||||
|
||||
elif isinstance(node, ast.Repr):
|
||||
return check_node(node.value)
|
||||
|
||||
elif isinstance(node, ast.Attribute):
|
||||
return check_node(node.value)
|
||||
|
||||
elif isinstance(node, ast.Subscript):
|
||||
return (
|
||||
check_node(node.value) and
|
||||
check_slice(node.slice)
|
||||
)
|
||||
|
||||
return False
|
||||
|
||||
node = ast.parse(expr, mode='eval').body
|
||||
return check_node(node)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
assert is_constant("1")
|
||||
assert is_constant("1 + 5")
|
||||
assert is_constant("not 42")
|
||||
assert is_constant("(1, 2, 'a', [ '4', 5+2-1 ])")
|
||||
assert is_constant("{ 'foo' : { 'bar', 'baz' } }")
|
||||
|
||||
assert not is_constant("foo + 42")
|
||||
|
||||
@@ -57,6 +57,10 @@ class ScriptTranslator(object):
|
||||
# A map from language to the StringTranslator for that language.
|
||||
self.strings = collections.defaultdict(StringTranslator)
|
||||
|
||||
# A map from language to a list of TranslateBlock objects for
|
||||
# that language.
|
||||
self.block = collections.defaultdict(list)
|
||||
|
||||
# A map from language to a list of TranslatePython objects for
|
||||
# that language.
|
||||
self.python = collections.defaultdict(list)
|
||||
@@ -86,6 +90,9 @@ class ScriptTranslator(object):
|
||||
if isinstance(n, renpy.ast.TranslatePython):
|
||||
self.python[n.language].append(n)
|
||||
|
||||
if isinstance(n, renpy.ast.TranslateBlock):
|
||||
self.block[n.language].append(n)
|
||||
|
||||
elif isinstance(n, renpy.ast.Menu):
|
||||
|
||||
for i in n.items:
|
||||
@@ -455,6 +462,12 @@ def change_language(language):
|
||||
renpy.style.restore(style_backup)
|
||||
renpy.style.rebuild()
|
||||
|
||||
def run_blocks():
|
||||
for i in tl.block[language]:
|
||||
renpy.game.context().run(i.block[0])
|
||||
|
||||
renpy.game.invoke_in_new_context(run_blocks)
|
||||
|
||||
for i in tl.python[language]:
|
||||
renpy.python.py_exec_bytecode(i.code.bytecode)
|
||||
|
||||
|
||||
@@ -214,6 +214,21 @@ For example::
|
||||
|
||||
show expression "moon.png" as moon
|
||||
|
||||
**Show Layer.**
|
||||
The show layer statement allows one to apply a transform or ATL transform to an
|
||||
entire layer (such as "master"), using syntax like::
|
||||
|
||||
show layer master at flip
|
||||
|
||||
or::
|
||||
|
||||
show layer master:
|
||||
xalign 0.5 yalign 0.5 rotate 180
|
||||
|
||||
To stop applying transforms to the layer, use::
|
||||
|
||||
show layer master
|
||||
|
||||
.. _scene-statement:
|
||||
|
||||
Scene Statement
|
||||
|
||||
@@ -25,5 +25,5 @@
|
||||
|
||||
`pixel_width`
|
||||
If not None, the input is limited to being this many pixels wide,
|
||||
in the font used by the
|
||||
in the font used by the input to display text.
|
||||
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
|
||||
`stop_action`
|
||||
An action to run when the music has stopped.
|
||||
|
||||
Single_track and shuffle conflict with each other. Only one should
|
||||
be true at a time. (Actions that set single_track and shuffle
|
||||
enforce this.)
|
||||
|
||||
.. method:: Next(self)
|
||||
|
||||
|
||||
@@ -219,10 +219,11 @@ Styles. ::
|
||||
|
||||
|
||||
.. _style-preferences:
|
||||
|
||||
Style Preferences
|
||||
-----------------
|
||||
|
||||
It's often desireable to allow the user to customize aspects of the user
|
||||
It's often desirable to allow the user to customize aspects of the user
|
||||
interface that are best expressed as styles. For example, a creator may want
|
||||
to give players of his game the ability to adjust the look, color, and size
|
||||
of the text. Style preferences allow for this customization.
|
||||
|
||||
@@ -322,16 +322,22 @@ Style Translations
|
||||
|
||||
It may be necessary to change styles - especially font-related
|
||||
styles - when translating a game. Ren'Py handles this with translate
|
||||
python blocks. These blocks can contain code to change
|
||||
language-related styles::
|
||||
style blocks and translate python blocks. These blocks can contain code
|
||||
to change language-related variables and styles. For example::
|
||||
|
||||
translate piglatin style default:
|
||||
font "stonecutter.ttf"
|
||||
|
||||
or equivalently::
|
||||
|
||||
translate piglatin python:
|
||||
style.default.font = "stonecutter.ttf"
|
||||
style.default.font = "stonecutter.ttf"
|
||||
|
||||
When a language is activated - either at the start of the game, or
|
||||
after a language change - Ren'Py resets the styles to their contents
|
||||
at the end of the init phase. It then runs all translate python blocks
|
||||
associated with the current language, in some order. Finally, it
|
||||
and translate style blocks associated with the current language, guaranteeing
|
||||
that blocks appearing earlier in a file are executed first. Finally, it
|
||||
rebuilds styles, allowing the changes to take effect.
|
||||
|
||||
Style translations may be added to any .rpy file.
|
||||
|
||||
@@ -288,7 +288,7 @@ translate None strings:
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:43
|
||||
old "Displayable Inspector"
|
||||
new "Displayableインスペクター"
|
||||
new "Displayable インスペクター"
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:49
|
||||
old "Nothing to inspect."
|
||||
@@ -304,7 +304,7 @@ translate None strings:
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:123
|
||||
old "Inspecting Styles of [displayable_name!q]"
|
||||
new "[displayable_name!q]のスタイルをインスペクト中"
|
||||
new "[displayable_name!q] のスタイルをインスペクト中"
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:135
|
||||
old "displayable:"
|
||||
@@ -312,11 +312,11 @@ translate None strings:
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:142
|
||||
old " (no properties affect the displayable)"
|
||||
new " (Displayableに影響しているプロパティーはありません)"
|
||||
new " (Displayable に影響しているプロパティーはありません)"
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:144
|
||||
old " (default properties omitted)"
|
||||
new " (デフォルトのプロパティーは省略)"
|
||||
new " (デフォルトのプロパティーは省略します)"
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:174
|
||||
old "<repr() failed>"
|
||||
@@ -390,3 +390,75 @@ translate None strings:
|
||||
old "Done"
|
||||
new "完了"
|
||||
|
||||
# Translation updated at 2014-02-24 16:15
|
||||
|
||||
translate None strings:
|
||||
|
||||
# renpy/common/00console.rpy:179
|
||||
old "%(version)s console, originally by Shiz, C, and delta.\n"
|
||||
new "%(version)s コンソール, 作成者: Shiz, C, delta\n"
|
||||
|
||||
# renpy/common/00console.rpy:180
|
||||
old "Press <esc> to exit console. Type help for help.\n"
|
||||
new "<esc> を押して終了。help と入力してヘルプを表示。\n"
|
||||
|
||||
# renpy/common/00console.rpy:184
|
||||
old "Ren'Py script enabled."
|
||||
new "Ren'Py スクリプト有効。"
|
||||
|
||||
# renpy/common/00console.rpy:186
|
||||
old "Ren'Py script disabled."
|
||||
new "Ren'Py スクリプト無効。"
|
||||
|
||||
# renpy/common/00console.rpy:392
|
||||
old "help: show this help"
|
||||
new "help: このヘルプを表示"
|
||||
|
||||
# renpy/common/00console.rpy:397
|
||||
old "commands:\n"
|
||||
new "コマンド:\n"
|
||||
|
||||
# renpy/common/00console.rpy:407
|
||||
old " <renpy script statement>: run the statement\n"
|
||||
new " <Ren'Py スクリプトステートメント>: ステートメントを実行\n"
|
||||
|
||||
# renpy/common/00console.rpy:409
|
||||
old " <python expression or statement>: run the expression or statement"
|
||||
new " <Python 式またはステートメント>: 式またはステートメントを実行"
|
||||
|
||||
# renpy/common/00console.rpy:417
|
||||
old "clear: clear the console history"
|
||||
new "clear: コンソール履歴を消去"
|
||||
|
||||
# renpy/common/00console.rpy:421
|
||||
old "exit: exit the console"
|
||||
new "exit: コンソールを終了"
|
||||
|
||||
# renpy/common/00console.rpy:429
|
||||
old "load <slot>: loads the game from slot"
|
||||
new "load <スロット>: スロットからゲームをロード"
|
||||
|
||||
# renpy/common/00console.rpy:442
|
||||
old "save <slot>: saves the game in slot"
|
||||
new "save <スロット>: スロットにゲームを保存"
|
||||
|
||||
# renpy/common/00console.rpy:453
|
||||
old "reload: reloads the game, refreshing the scripts"
|
||||
new "reload: ゲームをリロードしてスクリプトを再読み込み"
|
||||
|
||||
# renpy/common/00console.rpy:461
|
||||
old "watch <expression>: watch a python expression"
|
||||
new "watch <式>: Python 式をウォッチ"
|
||||
|
||||
# renpy/common/00console.rpy:470
|
||||
old "unwatch <expression>: stop watching an expression"
|
||||
new "unwatch <式>: Python 式のウォッチを解除"
|
||||
|
||||
# renpy/common/00console.rpy:478
|
||||
old "unwatchall: stop watching all expressions"
|
||||
new "unwatchall: すべての式のウォッチを解除"
|
||||
|
||||
# renpy/common/00console.rpy:484
|
||||
old "jump <label>: jumps to label"
|
||||
new "jump <ラベル>: ラベルにジャンプ"
|
||||
|
||||
|
||||
@@ -326,3 +326,182 @@ translate japanese strings:
|
||||
old "Quick save complete."
|
||||
new "クイックセーブ完了。"
|
||||
|
||||
|
||||
translate japanese strings:
|
||||
|
||||
# renpy/common/_developer/developer.rpym:65
|
||||
old "Developer Menu"
|
||||
new "開発者メニュー"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:67
|
||||
old "Reload Game (Shift+R)"
|
||||
new "ゲームのリロード (Shift+R)"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:69
|
||||
old "Console (Shift+O)"
|
||||
new "コンソール (Shift+D)"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:71
|
||||
old "Variable Viewer"
|
||||
new "変数ビューアー"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:73
|
||||
old "Theme Test"
|
||||
new "テーマのテスト"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:75
|
||||
old "Image Location Picker"
|
||||
new "画像位置ピッカー"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:77
|
||||
old "Filename List"
|
||||
new "ファイル名のリスト"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:81
|
||||
old "Show Image Load Log"
|
||||
new "画像ロード履歴の表示"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:84
|
||||
old "Hide Image Load Log"
|
||||
new "画像ロード履歴の非表示"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:149
|
||||
old "No variables have changed since the game started."
|
||||
new "ゲーム起動時から変更された変数はありません。"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:152
|
||||
old "Return to the developer menu"
|
||||
new "開発者メニューに戻ります"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:309
|
||||
old "Undefined Images"
|
||||
new "未定義の画像"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:409
|
||||
old "Rectangle: %r"
|
||||
new "矩形: %r"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:414
|
||||
old "Mouse position: %r"
|
||||
new "マウス位置: %r"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:416
|
||||
old "Right-click or escape to quit."
|
||||
new "右クリックまたはEscで終了。"
|
||||
|
||||
# renpy/common/_developer/developer.rpym:467
|
||||
old "Done"
|
||||
new "完了"
|
||||
|
||||
# Translation updated at 2014-02-23 11:23
|
||||
|
||||
translate japanese strings:
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:43
|
||||
old "Displayable Inspector"
|
||||
new "Displayable インスペクター"
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:49
|
||||
old "Nothing to inspect."
|
||||
new "インスペクトするものがありません"
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:58
|
||||
old "Size"
|
||||
new "サイズ"
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:63
|
||||
old "Style"
|
||||
new "スタイル"
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:123
|
||||
old "Inspecting Styles of [displayable_name!q]"
|
||||
new "[displayable_name!q] のスタイルをインスペクト中"
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:135
|
||||
old "displayable:"
|
||||
new "Displayable:"
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:142
|
||||
old " (no properties affect the displayable)"
|
||||
new " (Displayable に影響しているプロパティーはありません)"
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:144
|
||||
old " (default properties omitted)"
|
||||
new " (デフォルトのプロパティーは省略します)"
|
||||
|
||||
# renpy/common/_developer/inspector.rpym:174
|
||||
old "<repr() failed>"
|
||||
new "<repr() 失敗>"
|
||||
|
||||
# Translation updated at 2014-02-24 16:15
|
||||
|
||||
translate japanese strings:
|
||||
|
||||
# renpy/common/00console.rpy:179
|
||||
old "%(version)s console, originally by Shiz, C, and delta.\n"
|
||||
new "%(version)s コンソール, 作成者: Shiz, C, delta\n"
|
||||
|
||||
# renpy/common/00console.rpy:180
|
||||
old "Press <esc> to exit console. Type help for help.\n"
|
||||
new "<esc> を押して終了。help と入力してヘルプを表示。\n"
|
||||
|
||||
# renpy/common/00console.rpy:184
|
||||
old "Ren'Py script enabled."
|
||||
new "Ren'Py スクリプト有効。"
|
||||
|
||||
# renpy/common/00console.rpy:186
|
||||
old "Ren'Py script disabled."
|
||||
new "Ren'Py スクリプト無効。"
|
||||
|
||||
# renpy/common/00console.rpy:392
|
||||
old "help: show this help"
|
||||
new "help: このヘルプを表示"
|
||||
|
||||
# renpy/common/00console.rpy:397
|
||||
old "commands:\n"
|
||||
new "コマンド:\n"
|
||||
|
||||
# renpy/common/00console.rpy:407
|
||||
old " <renpy script statement>: run the statement\n"
|
||||
new " <Ren'Py スクリプトステートメント>: ステートメントを実行\n"
|
||||
|
||||
# renpy/common/00console.rpy:409
|
||||
old " <python expression or statement>: run the expression or statement"
|
||||
new " <Python 式またはステートメント>: 式またはステートメントを実行"
|
||||
|
||||
# renpy/common/00console.rpy:417
|
||||
old "clear: clear the console history"
|
||||
new "clear: コンソール履歴を消去"
|
||||
|
||||
# renpy/common/00console.rpy:421
|
||||
old "exit: exit the console"
|
||||
new "exit: コンソールを終了"
|
||||
|
||||
# renpy/common/00console.rpy:429
|
||||
old "load <slot>: loads the game from slot"
|
||||
new "load <スロット>: スロットからゲームをロード"
|
||||
|
||||
# renpy/common/00console.rpy:442
|
||||
old "save <slot>: saves the game in slot"
|
||||
new "save <スロット>: スロットにゲームを保存"
|
||||
|
||||
# renpy/common/00console.rpy:453
|
||||
old "reload: reloads the game, refreshing the scripts"
|
||||
new "reload: ゲームをリロードしてスクリプトを再読み込み"
|
||||
|
||||
# renpy/common/00console.rpy:461
|
||||
old "watch <expression>: watch a python expression"
|
||||
new "watch <式>: Python 式をウォッチ"
|
||||
|
||||
# renpy/common/00console.rpy:470
|
||||
old "unwatch <expression>: stop watching an expression"
|
||||
new "unwatch <式>: Python 式のウォッチを解除"
|
||||
|
||||
# renpy/common/00console.rpy:478
|
||||
old "unwatchall: stop watching all expressions"
|
||||
new "unwatchall: すべての式のウォッチを解除"
|
||||
|
||||
# renpy/common/00console.rpy:484
|
||||
old "jump <label>: jumps to label"
|
||||
new "jump <ラベル>: ラベルにジャンプ"
|
||||
|
||||
|
||||
@@ -60,3 +60,15 @@ translate japanese strings:
|
||||
old "This is text."
|
||||
new "これはテキスト。"
|
||||
|
||||
# game/demo_layers.rpy:64
|
||||
translate japanese demo_layers_91559c86:
|
||||
|
||||
# e "The \"behind\" clause lets you place an image behind another."
|
||||
e "behind 節は画像を他の画像の後ろに表示します。"
|
||||
|
||||
# game/demo_layers.rpy:77
|
||||
translate japanese demo_layers_a983efbd:
|
||||
|
||||
# e "Finally, the \"show layer\" statement allows you to apply a transform to an entire layer."
|
||||
e "つまり、 \"show layer\" ステートメントではレイヤーすべてに変換を適用出来ます。"
|
||||
|
||||
|
||||
@@ -146,3 +146,10 @@ translate japanese strings:
|
||||
old "Is there anything else you'd like to see?"
|
||||
new "他に見たいものはありますか?"
|
||||
|
||||
|
||||
# game/script.rpy:126
|
||||
translate japanese end_762dc07a:
|
||||
|
||||
# e "The background music is \"Sunflower Slow Drag\", by Scott Joplin and Scott Hayden, performed by the United States Marine Band. The concert music is by Alessio."
|
||||
e "バックグラウンドミュージックは Scott Joplin と Scott Hayden による \"Sunflower Slow Drag\" です。"
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
translate japanese python:
|
||||
style.default.font = "MTLc3m.ttf"
|
||||
style.default.language = "japanese-strict"
|
||||
style._default.font = "MTLc3m.ttf"
|
||||
style._default.language = "japanese-strict"
|
||||
translate japanese style default:
|
||||
font "MTLc3m.ttf"
|
||||
language "japanese-strict"
|
||||
|
||||
translate japanese style _default:
|
||||
font "MTLc3m.ttf"
|
||||
language "japanese-strict"
|
||||
|
||||
Reference in New Issue
Block a user