Removing default navigation menu from Text History screen

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Nayru774
Regular
Posts: 120
Joined: Thu Sep 03, 2015 5:25 pm
Completed: SoulSet, Blankspace
Projects: The Elevator Game with Catgirls
Tumblr: NoBreadStudio
itch: nobreadstudio
Location: Poland
Contact:

Removing default navigation menu from Text History screen

#1 Post by Nayru774 »

I tried to figure this out for days now, and I can't for the life of me get it right, so maybe you guys could help me out. How to remove the default Ren'Py navigation menu from my Text History screen and replace it with an imagemap with a simple "Back" button?

Here's an image of the Text History screen I have:

Image

With trial and error, I managed to figure out that disabling this part from the code:

Code: Select all

#config.game_menu.insert(1,( "text_history", u"Text History", ui.jumps("text_history_screen"), 'not main_menu'))
#config.nvl_show_display_say = say_wrapper
...means that it doesn't add an additional button with "Text History" into the navigation menu, but I have no idea how to disable the navigation menu itself altogether.

I also tried to "cheat" through this issue by expanding the Text History area, so that it would hide the menu with its background, and while the menu isn't visible to our eyes then, it's still there and works if you manage to click on the right spots with your mouse (so it's basically invisible, but it's still there).

Trying to add an imagemap into this code (with the "Back" button I mentioned) always ends up giving me an error, at that.

Here's the whole code:

Code: Select all

##############################################################################
# Log / Text History

init -2 python:

    # Two custom characters that store what they said
    class ReadbackADVCharacter(ADVCharacter):
        def do_done(self, who, what):
            store_say(who, what)
            return

    class ReadbackNVLCharacter(NVLCharacter):
        def do_done(self, who, what):
            store_say(who, what)
            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)

    adv = ReadbackADVCharacter(show_function=say_wrapper)
    nvl = ReadbackNVLCharacter()
    config.locked = False
    config.readback_buffer_length = 100 # number of lines stored
    config.readback_full = True # 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
    config.locked = True
    
    readback_buffer = []
    entered_from_game = False
    
    layout.provides("text_history")
    
    #config.game_menu.insert(1,( "text_history", u"Text History", ui.jumps("text_history_screen"), 'not main_menu'))
    #config.nvl_show_display_say = say_wrapper
        
    style.create("readback_text", "say_dialogue")
    style.readback_text.size= 20
    style.readback_text.color = "#c0b199"
    style.create("readback_label", "readback_text")
    style.readback_label.bold = True
    style.create("readback_window", "file_picker_frame")
    style.create("readback_window_box", "file_picker_frame_box")
    style.create("readback_content", "default")
    style.readback_content.background = "int/ground_library.png"
    style.readback_content.xpadding = 20
    style.readback_content.xmargin = 140
    style.readback_content.ymargin = 35
    style.readback_content.background = "int/logbg.png"
    style.create("readback_viewport", "default")
    style.readback_viewport.xmaximum = 600
    style.readback_viewport.xminimum = 600
    style.readback_viewport.ymaximum = 640
    style.readback_viewport.yminimum = 640
    style.readback_viewport.clipping = True

init 2 python:

    def menu(items, **add_input): #overwriting standard menu handler
        newitems = []
        for label, val in items:
            if val == None:
                narrator(label, interact=False)
            else:
                newitems.append((label, val))
        rv = renpy.display_menu(newitems, **add_input)
        for label, val in items:
            if rv == val:
                store_say(None, config.readback_choice_prefix + label)
        return rv

    ## readback
    def store_say(who, what):
        global readback_buffer
        new_line = (preparse_say_for_store(who),preparse_say_for_store(what))
        readback_buffer.append(new_line)
        readback_prune()

    current_line = None
    def store_current_line(who, what):
        global current_line
        current_line = (preparse_say_for_store(who), preparse_say_for_store(what))

    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]

    def readback_catcher():
        ui.add(renpy.Keymap(rollback=ui.callsinnewcontext("_game_menu", "text_history_screen")))
        ui.add(renpy.Keymap(rollforward=ui.returns(None)))

    if config.readback_full:
        config.rollback_enabled = False
        config.overlay_functions.append(readback_catcher)


label text_history_screen:
    python:
        layout.navigation("text_history")

        yadj = ui.adjustment()
        
        if 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 current_line != readback_buffer[-1]:  # current line may not yet be in rb buffer, but has the same format
            lines_to_show = readback_buffer + [current_line]
        else:
            lines_to_show = readback_buffer

        ui.window(style="readback_window")
        ui.vbox(style="readback_window_box")
        #ui.text("Text History", style="prefs_label")


        ui.side(('c', 'r'), spacing=5)
        ui.window(style="readback_content")
        vp = ui.viewport(draggable=True, offsets=(0.0,1.0), mousewheel=True, style="readback_viewport")
        ui.vbox()
        ui.null(height=10)
        for line in lines_to_show:
            if line[0] and line[0] != " ":
                ui.text(line[0], style="readback_label")
            ui.text(line[1], style="readback_text")
            ui.null(height=10)
        ui.close()
        ui.bar(adjustment=vp.yadjustment, style='vscrollbar')

        ui.close()

        ui.close()
        ui.interact()
        
        renpy.jump("text_history_screen")
I would appreciate any kind of help. Even if that help consisted of telling me that I should look for a different source code for my Text History screen and tried from there.
Image Image Image

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Removing default navigation menu from Text History scree

#2 Post by nyaatrap »

Don't you think to wait a few weeks when the next ren'py is out? So It'll be implemented by default. You can test it on viewtopic.php?f=8&t=39594
Your code is 10 years old and far different than modern ren'py. I'm rather surprised it's still working.

User avatar
Nayru774
Regular
Posts: 120
Joined: Thu Sep 03, 2015 5:25 pm
Completed: SoulSet, Blankspace
Projects: The Elevator Game with Catgirls
Tumblr: NoBreadStudio
itch: nobreadstudio
Location: Poland
Contact:

Re: Removing default navigation menu from Text History scree

#3 Post by Nayru774 »

@nyaatrap - Oh, I didn't even realize I was working with an outdated code... Thanks for letting me know.
I will take your advice and wait with this for the time being, then. Thanks!
Image Image Image

Post Reply

Who is online

Users browsing this forum: No registered users