Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # readback.rpy
- init -3 python:
- # config.game_menu.insert(1,( "text_history", u"Text History", ui.jumps("text_history_screen"), 'not main_menu'))
- # Styles.
- style.readback_window = Style(style.nvl_window)
- '''style.readback_window.xmaximum = 760
- style.readback_window.ymaximum = 500
- style.readback_window.align = (.5, .5)'''
- style.readback_frame.background = None
- style.readback_frame.xpadding = 10
- style.readback_frame.xmargin = 5
- style.readback_frame.ymargin = 5
- style.readback_text.color = "#ffdd7d"
- '''style.create("readback_button", "readback_text")
- style.readback_button.background = None
- style.create("readback_button_text", "readback_text")
- style.readback_button_text.selected_color = "#f12"
- style.readback_button_text.hover_color = "#f12"'''
- style.readback_label_text.bold = True
- style.readback_label_text.color = "#ffffff"
- # starts adding new config variables
- config.locked = False
- # Configuration Variable for Text History
- config.readback_buffer_length = 100 # number of lines stored
- config.readback_full = False # True = completely replaces rollback, False = readback accessible from game menu only (dev mode)
- config.readback_disallowed_tags = ["size"] # a list of tags that will be removed in the text history
- config.readback_choice_prefix = ">> " # this is prefixed to the choices the user makes in readback
- # end
- config.locked = True
- init -2 python:
- # Two custom characters that store what they said
- class ReadbackADVCharacter(ADVCharacter):
- def do_done(self, who, what, who_args):
- store_say(who, what, who_args)
- store.current_voice = ''
- return
- class ReadbackNVLCharacter(NVLCharacter):
- def do_done(self, who, what, who_args):
- store_say(who, what, who_args)
- store.current_voice = ''
- return
- # this enables us to show the current line in readback without having to bother the buffer with raw shows
- def say_wrapper(who, what, **kwargs):
- store_current_line(who, what)
- return renpy.show_display_say(who, what, **kwargs)
- config.nvl_show_display_say = say_wrapper
- adv = ReadbackADVCharacter(show_function=say_wrapper)
- nvl = ReadbackNVLCharacter()
- NVLCharacter = ReadbackNVLCharacter
- ## readback
- readback_buffer = []
- current_line = None
- current_voice = None
- def store_say(who, what, who_args):
- say_color = " "
- try:
- say_color = '#%02x%02x%02x' % who_args['color'][0:3]
- except:
- pass
- global readback_buffer, current_voice
- new_line = (who, preparse_say_for_store(what), current_voice, say_color)
- readback_buffer = readback_buffer + [new_line]
- readback_prune()
- def store_current_line(who, what):
- global current_line, current_voice
- current_line = (who, preparse_say_for_store(what), current_voice, " ")
- # remove text tags from dialogue lines
- disallowed_tags_regexp = ""
- for tag in config.readback_disallowed_tags:
- if disallowed_tags_regexp != "":
- disallowed_tags_regexp += "|"
- disallowed_tags_regexp += "{"+tag+"=.*?}|{"+tag+"}|{/"+tag+"}"
- import re
- remove_tags_expr = re.compile(disallowed_tags_regexp) # remove tags undesirable in readback
- def preparse_say_for_store(input):
- global remove_tags_expr
- if input:
- return re.sub(remove_tags_expr, "", input)
- def readback_prune():
- global readback_buffer
- while len(readback_buffer) > config.readback_buffer_length:
- del readback_buffer[0]
- # keymap overriding to show text_history.
- #def readback_catcher():
- #ui.add(renpy.Keymap(rollback=(SetVariable("yvalue", 1.0), ShowMenu("text_history"))))
- #ui.add(renpy.Keymap(rollforward=ui.returns(None)))
- #if config.readback_full:
- #config.rollback_enabled = False
- #config.overlay_functions.append(readback_catcher)
- # Text History Screen.
- screen text_history:
- tag menu
- if not current_line and len(readback_buffer) == 0 and d2_cardgame_block_rollback:
- $ lines_to_show = []
- elif not current_line and len(readback_buffer) == 0:
- $ lines_to_show = []
- elif current_line and len(readback_buffer) == 0:
- $ lines_to_show = [current_line]
- elif current_line and not ( current_line == readback_buffer[-1] or False
- if len(readback_buffer) == 1 else (current_line == readback_buffer[-2]) ):
- $ lines_to_show = readback_buffer# + [current_line]
- else:
- $ lines_to_show = readback_buffer
- #$ adj = NewAdj(changed = store_yvalue, step = 300)
- button style "blank_button" xpos 0 ypos 0 xfill True yfill True action Return()
- window background Frame(get_image("gui/choice/"+persistent.timeofday+"/choice_box.png"),50,50) xmaximum 0.83 xalign 0.01 yalign 0.01 left_padding 75 right_padding 75 bottom_padding 50 top_padding 50:
- style_group "readback"
- side "c t r":
- viewport id "readback":
- draggable True
- mousewheel True
- scrollbars None
- yinitial 1.0
- #frame:
- #$ vp = ui.viewport(mousewheel = True, draggable=True, offsets=(0.0, yvalue), yadjustment = adj)
- vbox:
- null height 10
- python:
- count=1
- total=0
- mass = lines_to_show
- for i in mass:
- if i[1]:
- if not i[2]:
- total+=1
- #renpy.log("line = %s" % i[1])
- for line in lines_to_show:
- if line[0] and line[0] != " ":
- if line[3] and line[3] != " ":
- python:
- sayer = line[0]
- text sayer color line[3]
- else:
- text line[0]
- if line[1]:
- # if there's no voice just log a dialogue
- if not line[2]:
- python:
- cn=total-count
- count+=1
- if persistent.font_size == "small":
- textbutton __(line[1]) text_size 28 style "log_button" text_style "log_button_text" action FunctionCallback(do_rollback,cn)
- elif persistent.font_size == "large":
- textbutton __(line[1]) text_size 35 style "log_button" text_style "log_button_text" action FunctionCallback(do_rollback,cn)
- else:
- null height 1
- # else, dialogue will be saved as a button of which plays voice when clicked
- else:
- textbutton line[1] action Play("voice", line[2] )
- null height 10
- python:
- count=None
- total=None
- mass=None
- $ vbar_null = Frame(get_image("gui/settings/vbar_null.png"),0,0)
- bar value XScrollValue("readback") left_bar "images/misc/none.png" right_bar "images/misc/none.png" thumb "images/misc/none.png" hover_thumb "images/misc/none.png"
- vbar value YScrollValue("readback") bottom_bar vbar_null top_bar vbar_null thumb "images/gui/settings/vthumb.png" thumb_offset -12 xalign 1.0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement