init 5 python:
    config.label_overrides["start"] = "patch_start"
    config.label_overrides["chapter_transition"] = "patch_chapter_transition"
    config.label_overrides["after_load"] = "patch_after_load"

    def patch_mother_text(text):
        if renpy.game.preferences.language is not None:
            return text

        replacements = {
            "I'm going to be a mother, [mc_name!c]!": "I'm going to be a mother again, [mc_name!c]!",
            "I'm going to be a mom soon!": "I'm going to be a mom again soon!",
            "And you'll be a great mom.": "And you're already a great mom.",
            "I bet it will be a masculine boy like me haha!": "I bet it will be another masculine boy like me haha!",
            "So the baby... is it even mine? I always thought I would have a kid like me.": "So the baby... is it even mine? I always thought I'd have another kid like me.",
            "I took you into my house. I trusted you. Why did you betray me like this?": "I raised you in this house. I trusted you. Why did you betray me like this?",
            "A few years ago, you witnessed something that forever altered the way you looked at [landlady_name!l]...": "A few years ago, you witnessed something that forever altered the way you looked at your [landlady_name!l]...",
            "She's [landlady_name!l]... I shouldn't be thinking about her like that.": "She's your [landlady_name!l]... I shouldn't be thinking about her like that.",
            "(I am a monster... This is my [landlady_name].)": "(I am a monster... This is my [landlady_name!l].)",
            "Muffled voices drift up from downstairs, pulling you from sleep. Even through the haze of waking up, you can tell it's the [landlord_name!l] and [landlady_name], and they're arguing again.": "Muffled voices drift up from downstairs, pulling you from sleep. Even through the haze of waking up, you can tell it's your [landlord_name!l] and your [landlady_name!l], and they're arguing again.",
            "Suddenly, the muffled voices of [landlady_name!l] and the [landlord_name!l] drift up from the floor below.": "Suddenly, the muffled voices of your [landlady_name!l] and your [landlord_name!l] drift up from the floor below.",
        }
        text = replacements.get(text, text)

        text = text.replace("the roles [landlord_name] expects", "the roles your [landlord_name!l] expects")
        text = text.replace("that [landlord_name] could never erase", "that your [landlord_name!l] could never erase")
        text = text.replace("a fight with [landlord_name]?", "a fight with your [landlord_name!l]?")
        text = text.replace("Hearing [landlord_name]'s implied presence", "Hearing your [landlord_name!l]'s implied presence")
        text = text.replace("found [landlady_name] asleep", "found your [landlady_name!l] asleep")

        text = text.replace("[landlady_name!c]'s eyes rolled back", "Your [landlady_name!l]'s eyes rolled back")
        text = text.replace("[landlady_name!c]'s arm tightens", "Your [landlady_name!l]'s arm tightens")
        text = text.replace("lands on [landlady_name!c]'s face", "lands on your [landlady_name!l]'s face")
        text = text.replace("[landlord_name!c]'s voice isn't", "Your [landlord_name!l]'s voice isn't")

        import re
        possessive = r"(?<!\b[Mm]y )(?<!\b[Hh]er )(?<!\b[Yy]our )(?<!\b[Hh]is )(?<!\b[Tt]he )\[%s!l\]'s"
        text = re.sub(possessive % "landlady_name", "your [landlady_name!l]'s", text)
        text = re.sub(possessive % "landlord_name", "your [landlord_name!l]'s", text)

        text = text.replace("the [landlord_name!l]", "your [landlord_name!l]")
        text = text.replace("The [landlord_name!l]", "Your [landlord_name!l]")
        text = text.replace("the [landlady_name!l]", "your [landlady_name!l]")
        text = text.replace("The [landlady_name!l]", "Your [landlady_name!l]")

        return text

    config.say_menu_text_filters.append(patch_mother_text)

label patch_start:
    if renpy.game.preferences.language is None:
        $ landlady_default = "Mother"
        $ landlord_default = "Father"
        $ landlady_prompt = "How would you like to call her?(Default: Mother)"
        $ landlord_prompt = "How would you like to call him?(Default: Father)"
    else:
        $ landlady_default = renpy.translate_string("Landlady")
        $ landlord_default = renpy.translate_string("Landlord")
        $ landlady_prompt = _("How would you like to call her?(Default: Landlady)")
        $ landlord_prompt = _("How would you like to call him?(Default: Landlord)")

    $ landlady_name = landlady_default
    $ landlord_name = landlord_default

    stop music fadeout 3

    "{color=#f00}{b}Warning{/b}: This game contains audio like moaning sounds. Using headphones is advised.{/color}"

    menu:
        "The game has two minigames. Do you want to skip them?"

        "Yes, skip them.":
            $ persistent.skip_minigames = True

        "No, I want to play them.":
            $ persistent.skip_minigames = False

    scene intro01

    "This is you..."

    "You are a young guy living with your [landlady_name!l] and [landlord_name!l]."

    $ mc_name = renpy.input(_("What is your name?(Default: Shawn)"), default="Shawn")
    $ mc_name = mc_name.strip()

    "You decided to call yourself [mc_name!c]."

    scene portrait

    "This is your [landlady_name!l]. Her name is [landlady_firstname!c], but you don't call her by her first name."

    $ landlady_firstname = renpy.input(_("What is her real first name?(Default: Laura)"), default="Laura")
    $ landlady_firstname = landlady_firstname.strip()
    if not landlady_firstname:
        $ landlady_firstname = "Laura"

    $ landlady_name = renpy.input(landlady_prompt, default=landlady_default)
    $ landlady_name = landlady_name.strip()
    if not landlady_name:
        $ landlady_name = landlady_default

    "You decided to call her [landlady_name!c]."

    scene portrait_landlord

    "And this is the [landlord_name!l]. His name is [landlord_firstname!c] but you can choose how to call him."

    $ landlord_firstname = renpy.input(_("What is his real first name?(Default: Mark)"), default="Mark")
    $ landlord_firstname = landlord_firstname.strip()
    if not landlord_firstname:
        $ landlord_firstname = "Mark"

    $ landlord_name = renpy.input(landlord_prompt, default=landlord_default)
    $ landlord_name = landlord_name.strip()
    if not landlord_name:
        $ landlord_name = landlord_default

    "You decided to call him [landlord_name!c]."

    "But back to you..."

    scene intro01

    "You are a student and you are currently on summer break."

    "Every day, you do the same."

    "You wake up, eat breakfast, go to the gym, come back home, eat lunch, play video games, eat dinner, and go to bed."

    "Nothing exciting is happening in your life."

    "Or so you tell yourself."

    "Because the truth is, beneath the boring routine of study and games, there's a tension that's been simmering for years."
    "A secret history that changed the way you look at the woman you live with... and the way she looks at you."

    call throwback from _call_throwback_patch

    play music "audio/background/background.ogg" fadein 2.0 volume 0.7 loop

    "Back to the present..."

    "The [landlord_name!l] and the [landlady_name!l] decided to go on a vacation for a week."

    "Today is the day. You can finally have the house to yourself."

    "But what is this noise early in the morning?"

    jump intro


label patch_chapter_transition:
    scene intro01
    $ mc_name = renpy.input(_("What is your name?(Default: Shawn)"), default="Shawn")
    $ mc_name = mc_name.strip()
    scene portrait
    if renpy.game.preferences.language is None:
        $ landlady_default = "Mother"
        $ landlady_prompt = "How would you like to call her?(Default: Mother)"
    else:
        $ landlady_default = renpy.translate_string("Landlady")
        $ landlady_prompt = _("How would you liked to call her?(Default: Landlady)")
    $ landlady_name = renpy.input(landlady_prompt, default=landlady_default)
    $ landlady_name = landlady_name.strip()
    if not landlady_name:
        $ landlady_name = landlady_default
    scene portrait_landlord
    if renpy.game.preferences.language is None:
        $ landlord_default = "Father"
        $ landlord_prompt = "How would you like to call him?(Default: Father)"
    else:
        $ landlord_default = renpy.translate_string("Landlord")
        $ landlord_prompt = _("How would you liked to call him?(Default: Landlord)")
    $ landlord_name = renpy.input(landlord_prompt, default=landlord_default)
    $ landlord_name = landlord_name.strip()
    if not landlord_name:
        $ landlord_name = landlord_default
    $ var_mcdom = 4
    scene black
    stop music
    $ renpy.jump(target_label)


label patch_after_load:
    python:
        day = loaded_day_number()
        if day:
            unlock_chapters_before(day)

        if renpy.game.preferences.language is None:
            if landlady_name == "Landlady":
                landlady_name = "Mother"
            if landlord_name == "Landlord":
                landlord_name = "Father"
        else:
            if landlady_name == "Landlady":
                landlady_name = renpy.translate_string("Landlady")
            if landlord_name == "Landlord":
                landlord_name = renpy.translate_string("Landlord")

        sync_achievements(True)
    return
