Created
February 21, 2019 10:03
-
-
Save Enerccio/1e24664f2d6705d30d1f4cce2cced902 to your computer and use it in GitHub Desktop.
insert custom show into renpy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
init 100 python hide: | |
class MyShow(renpy.ast.Show): | |
__slots__ = [ | |
'old_show', | |
] | |
def __init__(self, old_show): | |
# no parent init call! | |
self.old_show = old_show | |
@property | |
def filename(self): | |
return self.old_show.filename | |
@property | |
def linenumber(self): | |
return self.old_show.linenumber | |
@property | |
def name(self): | |
return self.old_show.name | |
@property | |
def next(self): | |
return self.old_show.next | |
@property | |
def imspec(self): | |
return self.old_show.imspec | |
@property | |
def atl(self): | |
return self.old_show.atl | |
def diff_info(self): | |
return self.old_code.diff_info() | |
def get_children(self, f): | |
return self.old_code.get_children(f) | |
def get_init(self): | |
return self.old_code.get_init() | |
def chain(self, next): # @ReservedAssignment | |
return self.old_code.chain(next) | |
def replace_next(self, old, new): | |
return self.old_code.replace_next(old, new) | |
def early_execute(self): | |
return self.old_code.early_execute() | |
def scry(self): | |
return self.old_code.scry() | |
def restructure(self, callback): | |
return self.old_code.restructure(callback) | |
def get_code(self, dialogue_filter=None): | |
return self.old_show.get_code(dialogue_filter) | |
def can_warp(self): | |
return self.old_show.can_warp() | |
def predict(self): | |
return self.old_show.predict() | |
def analyze(self): | |
return self.old_show.analyze() | |
def execute(self, *args, **kwargs): | |
print "Hello, this is my show! %s, %s, %s" % (str(self), str(args), str(kwargs)) | |
return self.old_show.execute(*args, **kwargs) | |
show_map = {} | |
it = 0 | |
for statement in renpy.game.script.all_stmts: | |
if isinstance(statement, renpy.ast.Show): | |
renpy.game.script.all_stmts[it] = MyShow(statement) | |
if statement.__hash__() not in show_map: | |
show_map[statement.__hash__()] = [] | |
show_map[statement.__hash__()].append((statement, renpy.game.script.all_stmts[it])) | |
it += 1 | |
for statement in renpy.game.script.all_stmts: | |
if isinstance(statement, renpy.ast.Node) and hasattr(statement, "next"): | |
if statement.next is not None: | |
next_stmt = statement.next | |
if next_stmt.__hash__() in show_map: | |
for old_stmt, new_stmt in show_map[next_stmt.__hash__()]: | |
if old_stmt is next_stmt: | |
statement.replace_next(statement.next, new_stmt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment