BeingADIK - Copy - Py
BeingADIK - Copy - Py
# This file is part of Ren'Py. The license below applies to Ren'Py only.
# Games and other projects that use Ren'Py may use a different license.
import os
import sys
import warnings
def path_to_common(renpy_base):
return renpy_base + "/renpy/common"
if save_directory is None:
save_directory = renpy.config.save_directory
save_directory = renpy.exports.fsencode(save_directory)
# Android.
if renpy.android:
paths = [
os.path.join(os.environ["ANDROID_OLD_PUBLIC"], "game/saves"),
os.path.join(os.environ["ANDROID_PRIVATE"], "saves"),
os.path.join(os.environ["ANDROID_PUBLIC"], "saves"),
]
for rv in paths:
if os.path.isdir(rv) and test_writable(rv):
break
return rv
if renpy.ios:
from pyobjus import autoclass
from pyobjus.objc_py_types import enum
NSSearchPathDirectory = enum("NSSearchPathDirectory",
NSDocumentDirectory=9)
NSSearchPathDomainMask = enum("NSSearchPathDomainMask", NSUserDomainMask=1)
NSFileManager = autoclass('NSFileManager')
manager = NSFileManager.defaultManager()
url = manager.URLsForDirectory_inDomains_(
NSSearchPathDirectory.NSDocumentDirectory,
NSSearchPathDomainMask.NSUserDomainMask,
).lastObject()
# url.path seems to change type based on iOS version, for some reason.
try:
rv = url.path().UTF8String().decode("utf-8")
except:
rv = url.path.UTF8String().decode("utf-8")
# Search the path above Ren'Py for a directory named "Ren'Py Data".
# If it exists, then use that for our save directory.
path = renpy.config.renpy_base
while True:
if os.path.isdir(path + "/Ren'Py Data"):
return path + "/Ren'Py Data/" + save_directory
newpath = os.path.dirname(path)
if path == newpath:
break
path = newpath
elif renpy.windows:
if 'APPDATA' in os.environ:
return os.environ['APPDATA'] + "/RenPy/" + save_directory
else:
rv = "~/RenPy/" + renpy.config.save_directory
return os.path.expanduser(rv)
else:
rv = "~/.renpy/" + save_directory
return os.path.expanduser(rv)
# Returns the path to the Ren'Py base directory (containing common and
# the launcher, usually.)
def path_to_renpy_base():
renpy_base = os.path.dirname(os.path.realpath(sys.argv[0]))
renpy_base = os.path.abspath(renpy_base)
return renpy_base
##############################################################################
# Doing the version check this way also doubles as an import of ast,
# which helps py2exe et al.
try:
import ast; ast
except:
raise
print("Ren'Py requires at least python 2.6.")
sys.exit(0)
# Android requires us to add code to the main module, and to command some
# renderers.
if android:
__main__ = sys.modules["__main__"]
__main__.path_to_renpy_base = path_to_renpy_base
__main__.path_to_common = path_to_common
__main__.path_to_saves = path_to_saves
os.environ["RENPY_RENDERER"] = "gl"
def main():
renpy_base = path_to_renpy_base()
# Add paths.
if os.path.exists(renpy_base + "/module"):
sys.path.append(renpy_base + "/module")
sys.path.append(renpy_base)
renpy.bootstrap.bootstrap(renpy_base)
if __name__ == "__main__":
main()