Skip to content

Commit 99f7011

Browse files
committed
Auto Update Checking - Can be disabled with --noupdate
1 parent dc338b8 commit 99f7011

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
aiohttp

run.bat

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
:top
2-
"C:/Panda3D-1.11.0-Py37-x64/python/python.exe" -m ttle --hoods TT DL
2+
"C:/Panda3D-1.11.0-Py37-x64/python/python.exe" -m pip install -r requirements.txt
3+
"C:/Panda3D-1.11.0-Py37-x64/python/python.exe" -m ttle --hoods TT
34

45
pause
56
goto top

ttle.py

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
""" ToontownLevelEditor 2.0 Base Class - Drewcification 091420 """
2-
from direct.showbase.ShowBase import ShowBase
3-
import builtins
2+
3+
import asyncio
44
import argparse
5+
import builtins
6+
import webbrowser
7+
from direct.directnotify.DirectNotifyGlobal import directNotify
8+
from direct.showbase.ShowBase import ShowBase
59
from panda3d.core import loadPrcFile, loadPrcFileData
6-
import aiohttp, asyncio
10+
from tkinter import Tk, messagebox
711

812
class ToontownLevelEditor(ShowBase):
9-
APP_VERSION = '1.0.2'
13+
notify = directNotify.newCategory("Open Level Editor")
14+
APP_VERSION = open('ver', 'r').read()
1015
def __init__(self):
1116
# Check for -e or -d launch options
1217
ShowBase.__init__(self)
1318
parser = argparse.ArgumentParser(description="Modes")
1419
parser.add_argument("--experimental", action='store_true', help="Enables experimental features")
1520
parser.add_argument("--debug", action='store_true', help="Enables debugging features")
1621
parser.add_argument("--clash", action='store_true', help="Enables Corporate Clash features")
22+
parser.add_argument("--noupdate", action='store_true', help="Disables Auto Updating")
1723
parser.add_argument("--hoods", nargs="*", help="Only loads the storage files of the specified hoods",
1824
default=['TT', 'DD', 'BR', 'DG',
1925
'DL', 'MM', 'CC', 'CL',
2026
'CM', 'CS', 'GS', 'GZ',
2127
'OZ', 'PA', 'ES', 'TUT'])
28+
2229
args = parser.parse_args()
2330
if args.experimental:
2431
loadPrcFileData("", "want-experimental true")
@@ -35,10 +42,31 @@ def __init__(self):
3542

3643
# Load the prc file
3744
loadPrcFile('editor.prc')
45+
46+
tkroot = Tk()
47+
tkroot.withdraw()
48+
tkroot.title("Open Level Editor")
49+
#tkroot.iconbitmap("resources/icon.ico")
50+
self.tkRoot = tkroot
51+
52+
if not args.noupdate:
53+
loop = asyncio.get_event_loop()
54+
loop.run_until_complete(self.checkUpdates())
3855

3956
# Now we actually start the editor
4057
from toontown.leveleditor import LevelEditor
4158
self.le = LevelEditor.LevelEditor()
4259

43-
60+
async def checkUpdates(self):
61+
import aiohttp
62+
async with aiohttp.ClientSession() as session:
63+
async with session.get("https://raw.githubusercontent.com/OpenToontownTools/TTOpenLevelEditor/master/ver") as resp:
64+
ver = await resp.text()
65+
ver = ver.splitlines()[0]
66+
if ver != self.APP_VERSION:
67+
self.notify.info(f"Client is out of date! Latest: {ver} | Client: {self.APP_VERSION}")
68+
if messagebox.askokcancel("Error", f"Client is out of date!\nLatest: {ver} | Client: {self.APP_VERSION}. Press OK to be taken to the download page."):
69+
webbrowser.open("https://github.com/OpenToontownTools/TTOpenLevelEditor/releases/latest")
70+
else:
71+
self.notify.info("Client is up to date!")
4472
ToontownLevelEditor().run()

0 commit comments

Comments
 (0)