Procházet zdrojové kódy

add support for mac by passing paths to toontown rewritten library dir to engine

Fabian Peter Hammerle před 8 roky
rodič
revize
bdab9948b4
2 změnil soubory, kde provedl 21 přidání a 6 odebrání
  1. 2 2
      setup.py
  2. 19 4
      tooncher/__init__.py

+ 2 - 2
setup.py

@@ -7,12 +7,12 @@ import glob
 setup(
     name = 'tooncher',
     packages = ['tooncher'],
-    version = '0.1',
+    version = '0.1.1',
     description = "automates toontown rewritten's login process",
     author = 'Fabian Peter Hammerle',
     author_email = 'fabian.hammerle@gmail.com',
     url = 'https://github.com/fphammerle/tooncher',
-    download_url = 'https://github.com/fphammerle/tooncher/tarball/0.1',
+    download_url = 'https://github.com/fphammerle/tooncher/tarball/0.1.1',
     keywords = ['game', 'launcher', 'toontown rewritten', 'ttr'],
     classifiers = [],
     scripts = glob.glob('scripts/*'),

+ 19 - 4
tooncher/__init__.py

@@ -1,6 +1,7 @@
 import json
 import os
 import subprocess
+import sys
 import urllib.parse
 import urllib.request
 
@@ -15,13 +16,27 @@ LOGIN_API_URL = 'https://www.toontownrewritten.com/api/login?format=json'
 
 
 def start_engine(engine_path, gameserver, playcookie, **kwargs):
+    env = {
+        'TTR_GAMESERVER': gameserver,
+        'TTR_PLAYCOOKIE': playcookie,
+    }
+    if sys.platform == 'darwin':
+        toontown_library_path = os.path.join(
+            os.path.expanduser('~'), 'Library',
+            'Application Support', 'Toontown Rewritten',
+        )
+        env['DYLD_LIBRARY_PATH'] = os.path.join(
+            toontown_library_path,
+            'Libraries.bundle',
+        )
+        env['DYLD_FRAMEWORK_PATH'] = os.path.join(
+            toontown_library_path,
+            'Frameworks',
+        )
     return subprocess.Popen(
         args=[engine_path],
         cwd=os.path.dirname(engine_path),
-        env={
-            'TTR_GAMESERVER': gameserver,
-            'TTR_PLAYCOOKIE': playcookie,
-        },
+        env=env,
         **kwargs,
     )