Skip to content

Commit

Permalink
py3 beta 1 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bronya-Rand committed May 23, 2022
1 parent 88d315a commit 2c78f8b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 153 deletions.
7 changes: 7 additions & 0 deletions game/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ This folder was introduced in Version 3.0.1 of the mod template. This folder sto

This folder contains the needed Python package files needed to run DDLC or a mod

### **__imports__.rpy**
This file was introduced in Version [TBD] of the mod template. This file contains the imports necessary to run DDLC.

### **cgs.rpy**

This file defines all the character graphics (CGs) in DDLC such as Yuri's Chocolate CG and Natsuki's Manga CG.
Expand Down Expand Up @@ -66,6 +69,10 @@ This image was introduced in Version 3.0.0 of the mod template. This image is ma

### **renpy_patches.rpy**

This file was introduced in Version [TBD] of the mod template. It's purpose is to prevent users from running this Python 3 template on Python 2 Ren'Py versions (Ren'Py 6/7).

### **renpy_patches.rpy**

This file was introduced in Version 3.0.0 of the mod template. It's purpose is to patch problematic code that can affect DDLC/DDLC mods on certain versions of Ren'Py that is tied to the Ren'Py engine itself.

### **screens.rpy**
Expand Down
File renamed without changes.
11 changes: 9 additions & 2 deletions game/mod_extras/lockdown_check.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,25 @@
# This file is mainly designed to warn new modders about bugs with certain Ren'Py
# versions or warn them about QA issues with running Ren'Py versions higher than
# the one the mod template was tested for.
# New in [TBD]: Add lockout for Ren'Py 6/7 on Py 3 templates.

## DO NOT MODIFY THIS FILE! ##

# Checks if we are on Ren'Py 8
init -100 python:

if renpy.version_tuple < (8, 0, 0):
raise NotRenPyEight

label lockdown_check:

$ version = renpy.version()

if renpy.version_tuple > (7, 4, 11, 2266):
if renpy.version_tuple > (8, 0, 0, 22052208):

scene black
"{b}Warning:{/b} The version of Ren'Py you are trying to mod DDLC on has not been tested for modding compatibility."
"The last recent version of Ren'Py that works for DDLC mods is \"{i}Ren'Py 7.4.10{/i}\"."
"The last recent version of Ren'Py 8 that works for DDLC mods is \"{i}Ren'Py 8.0.0{/i}\"."
"Running DDLC or your DDLC mod on a higher version than the one tested may introduce bugs and other game breaking features."

menu:
Expand Down
11 changes: 4 additions & 7 deletions game/options.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
# This file customizes what your mod is and and how it starts and builds!

# This controls what your mod is called.
define config.name = "DDLC Mod Template"
define config.name = "DDLC Mod Template - Python 3 Edition"

# This controls whether you want your mod name to show in the main menu.
# If your mod name is big, it is suggested to turn this off.
define gui.show_name = True

# This controls the version number of your mod.
define config.version = "3.0.2"
define config.version = "Py3-Beta1"

# This adds information about your mod in the About screen.
# DDLC does not have a 'About' screen so you can leave this blank.
Expand Down Expand Up @@ -152,11 +152,8 @@ init python:

# These variables declare the packages to build your mod that is Team Salvato
# IPG compliant. Do not mess with these variables whatsoever.
if renpy.version_tuple == (6, 99, 12, 4, 2187):
build.package(build.directory_name + "Mod", 'zip', 'mod', description="Ren'Py 6 DDLC Compliant Mod")
else:
build.package(build.directory_name + "Renpy7Mod", 'zip', 'windows linux mac renpy mod',
description="Ren'Py 7 DDLC Compliant Mod")
build.package(build.directory_name + "Renpy7Mod", 'zip', 'windows linux mac renpy mod',
description="Ren'Py 7/8 DDLC Compliant Mod")

# These variables declare the archives that will be made to your packaged mod.
# To add another archive, make a build.archive variable like in this example:
Expand Down
5 changes: 0 additions & 5 deletions game/renpy_check.rpy

This file was deleted.

89 changes: 2 additions & 87 deletions game/renpy_patches.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## renpy_patches.rpy
# This file is mainly designed to patch certain versions of Ren'Py that break
# DDLC/DDLC mods by patching the Ren'Py engine at startup.
## Since this is Ren'Py 8/Py3 branch, some patches have been removed due to
## being obsolete.

init -1 python:
## Patches the Monika Space Room Effects however it might disable
Expand All @@ -19,93 +21,6 @@ python early:
os.environ['wmic process get Description'] = "powershell (Get-Process).ProcessName"
os.environ['wmic os get version'] = "powershell (Get-WmiObject -class Win32_OperatingSystem).Version"

init -1 python:
## Patches the 7.4.6 - 7.4.8 transform bugs.
if renpy.version_tuple >= (7, 4, 6, 1693) and renpy.version_tuple < (7, 4, 9, 2142):

class NewSceneLists(renpy.display.core.SceneLists):

@staticmethod
def add(self,
layer,
thing,
key=None,
zorder=0,
behind=[ ],
at_list=[ ],
name=None,
atl=None,
default_transform=None,
transient=False,
keep_st=False):

if not isinstance(thing, renpy.display.core.Displayable):
raise Exception("Attempting to show something that isn't a displayable:" + repr(thing))

if layer not in self.layers:
raise Exception("Trying to add something to non-existent layer '%s'." % layer)

if key:
self.remove_hide_replaced(layer, key)
self.at_list[layer][key] = at_list

if key and name:
self.shown.predict_show(layer, name)

if transient:
self.additional_transient.append((layer, key))

l = self.layers[layer]

if atl:
thing = renpy.display.motion.ATLTransform(atl, child=thing)

add_index, remove_index, zorder = self.find_index(layer, key, zorder, behind)

at = None
st = None

if remove_index is not None:
sle = l[remove_index]
old = sle.displayable

at = sle.animation_time

if keep_st:
st = sle.show_time

if (not atl and
not at_list and
renpy.config.keep_running_transform and
isinstance(old, renpy.display.motion.Transform)):

thing = sle.displayable._change_transform_child(thing)
else:
thing = self.transform_state(l[remove_index].displayable, thing)

thing.set_transform_event("replace")

else:

if not isinstance(thing, renpy.display.motion.Transform):
thing = self.transform_state(default_transform, thing)

thing.set_transform_event("show")

sle = renpy.display.core.SceneListEntry(key, zorder, st, at, thing, name)
l.insert(add_index, sle)

if remove_index is not None:
if add_index <= remove_index:
remove_index += 1

self.hide_or_replace(layer, remove_index, "replaced")

# use visit_all than _show() due to depreciation
thing.visit_all(lambda d : None)

renpy.display.core.SceneLists.add = NewSceneLists.add

## Fixes a issue where some transitions (menu bg) reset themselves
if renpy.version_tuple >= (7, 4, 7, 1862):
config.atl_start_on_show = False
50 changes: 16 additions & 34 deletions game/screens.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -1177,58 +1177,40 @@ style slider_vbox:

screen history():
tag menu

## Avoid predicting this screen, as it can be very large.
predict False

use game_menu(_("History"), scroll=("vpgrid" if gui.history_height else "viewport")):

style_prefix "history"

for h in _history_list:

window:

## This lays things out properly if history_height is None.
has fixed:
yfit True

if h.who:

label h.who:
style "history_name"
substitute False

## Take the color of the who text from the Character, if
## set.
if "color" in h.who_args:
text_color h.who_args["color"]
$ what = filter_text_tags(h.what, allow=set([]))

$ what = renpy.filter_text_tags(h.what, allow=gui.history_allow_tags)
text what:
substitute False

if not _history_list:
label _("The dialogue history is empty.")

python early:
import renpy.text.textsupport as textsupport
from renpy.text.textsupport import TAG, PARAGRAPH

def filter_text_tags(s, allow=None, deny=None):
if (allow is None) and (deny is None):
raise Exception("Only one of the allow and deny keyword arguments should be given to filter_text_tags.")
if (allow is not None) and (deny is not None):
raise Exception("Only one of the allow and deny keyword arguments should be given to filter_text_tags.")

tokens = textsupport.tokenize(unicode(s))
rv = [ ]

for tokentype, text in tokens:
if tokentype == PARAGRAPH:
rv.append("\n")
elif tokentype == TAG:
kind = text.partition("=")[0]

if kind and (kind[0] == "/"):
kind = kind[1:]

if allow is not None:
if kind in allow:
rv.append("{" + text + "}")
else:
if kind not in deny:
rv.append("{" + text + "}")
else:
rv.append(text)

return "".join(rv)

style history_window is empty

style history_name is gui_label
Expand Down
27 changes: 9 additions & 18 deletions game/script.rpy
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,12 @@ label start:
# This python statement writes a file from within the game to the game folder
# or to the Android/data/[modname]/files/game folder.
python:
if renpy.android and renpy.version_tuple == (6, 99, 12, 4, 2187):
try: file(os.environ['ANDROID_PUBLIC'] + "/hxppy thxughts.png")
except: open(os.environ['ANDROID_PUBLIC'] + "/hxppy thxughts.png", "wb").write(renpy.file("hxppy thxughts.png").read())
elif renpy.android:
if renpy.android:
try: renpy.file(os.environ['ANDROID_PUBLIC'] + "/hxppy thxughts.png")
except: open(os.environ['ANDROID_PUBLIC'] + "/hxppy thxughts.png", "wb").write(renpy.file("hxppy thxughts.png").read())
except IOError: open(os.environ['ANDROID_PUBLIC'] + "/hxppy thxughts.png", "wb").write(renpy.file("hxppy thxughts.png").read())
else:
try: renpy.file(config.basedir + "/hxppy thxughts.png")
except: open(config.basedir + "/hxppy thxughts.png", "wb").write(renpy.file("hxppy thxughts.png").read())
except IOError: open(config.basedir + "/hxppy thxughts.png", "wb").write(renpy.file("hxppy thxughts.png").read())

## Day 5
$ chapter = 5
Expand All @@ -122,15 +119,12 @@ label start:
call poem

python:
if renpy.android and renpy.version_tuple == (6, 99, 12, 4, 2187):
try: file(os.environ['ANDROID_PUBLIC'] + "/CAN YOU HEAR ME.txt")
except: open(os.environ['ANDROID_PUBLIC'] + "/CAN YOU HEAR ME.txt", "wb").write(renpy.file("CAN YOU HEAR ME.txt").read())
elif renpy.android:
if renpy.android:
try: renpy.file(os.environ['ANDROID_PUBLIC'] + "/CAN YOU HEAR ME.txt")
except: open(os.environ['ANDROID_PUBLIC'] + "/CAN YOU HEAR ME.txt", "wb").write(renpy.file("CAN YOU HEAR ME.txt").read())
except IOError: open(os.environ['ANDROID_PUBLIC'] + "/CAN YOU HEAR ME.txt", "wb").write(renpy.file("CAN YOU HEAR ME.txt").read())
else:
try: renpy.file(config.basedir + "/CAN YOU HEAR ME.txt")
except: open(config.basedir + "/CAN YOU HEAR ME.txt", "wb").write(renpy.file("CAN YOU HEAR ME.txt").read())
except IOError: open(config.basedir + "/CAN YOU HEAR ME.txt", "wb").write(renpy.file("CAN YOU HEAR ME.txt").read())

## Day 2 - Act 2
$ chapter = 1
Expand All @@ -142,15 +136,12 @@ label start:
call poem(False)

python:
if renpy.android and renpy.version_tuple == (6, 99, 12, 4, 2187):
try: file(os.environ['ANDROID_PUBLIC'] + "/iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt")
except: open(os.environ['ANDROID_PUBLIC'] + "/iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt", "wb").write(renpy.file("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt").read())
elif renpy.android:
if renpy.android:
try: renpy.file(os.environ['ANDROID_PUBLIC'] + "/iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt")
except: open(os.environ['ANDROID_PUBLIC'] + "/iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt", "wb").write(renpy.file("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt").read())
except IOError: open(os.environ['ANDROID_PUBLIC'] + "/iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt", "wb").write(renpy.file("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt").read())
else:
try: renpy.file(config.basedir + "/iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt")
except: open(config.basedir + "/iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt", "wb").write(renpy.file("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt").read())
except IOError: open(config.basedir + "/iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt", "wb").write(renpy.file("iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii.txt").read())

## Day 3 - Act 2
$ chapter = 2
Expand Down

0 comments on commit 2c78f8b

Please sign in to comment.