summaryrefslogtreecommitdiff
path: root/__main__.py
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2024-02-05 11:17:23 -0300
committerJesusaves <cpntb1@ymail.com>2024-02-05 11:17:23 -0300
commit29ffe5de3c308013742b5bd97f7d75b09bd3b427 (patch)
tree7199cecaf204701770de171d007e561589b19762 /__main__.py
parentf6b8c0c64757c73b6f2063d3a6d93ce2f8f527d5 (diff)
downloadtkinter-29ffe5de3c308013742b5bd97f7d75b09bd3b427.tar.gz
tkinter-29ffe5de3c308013742b5bd97f7d75b09bd3b427.tar.bz2
tkinter-29ffe5de3c308013742b5bd97f7d75b09bd3b427.tar.xz
tkinter-29ffe5de3c308013742b5bd97f7d75b09bd3b427.zip
Some button aligning, a CI template, and Discord RPC
Diffstat (limited to '__main__.py')
-rwxr-xr-x__main__.py108
1 files changed, 59 insertions, 49 deletions
diff --git a/__main__.py b/__main__.py
index 26472e7..8ff730c 100755
--- a/__main__.py
+++ b/__main__.py
@@ -247,7 +247,7 @@ def launch_game(idx):
if pref["local"]:
CMD+=".AppImage"
else:
- ## Mana and M+ are not available on Windows (TODO)
+ ## Mana and M+ are not available on Windows yet (TODO)
if pref["local"]:
CMD+="Mana/manaplus.exe" # FIXME untested
else:
@@ -255,17 +255,23 @@ def launch_game(idx):
## Build the server options
OPT="-s %s -y %s -p %s -S" % (HOST, serverlist[idx]["Type"], PORT)
+ ## Mana "fix"
+ if pref["mana"]:
+ OPT=OPT[:-2]
print("%s %s" % (CMD, OPT))
+
## Local or System-Wide Config folders
if pref["local"]:
if not sys.platform.startswith('win'):
OPT+=" -C %s/Config -L %s/Local" % (CWD, CWD)
else:
OPT+=" -C %s\\Config -L %s\\Local" % (CWD.replace('/','\\'), CWD.replace('/','\\'))
- pass
+ ## Mana "fix" (TODO Untested)
+ if pref["mana"]:
+ OPT=OPT.replace(" -L ", " --localdata-dir ")
## Execute the app
- ## TODO: Threading, MLP
+ ## TODO: Threading?
if pref["shell"]:
app=execute(san("%s %s%s" % (CMD, OPT, PWD)), shell=True) # nosec
else:
@@ -280,8 +286,7 @@ def launch_game_master(idx):
stdout("[CLIENT] Mirror Lake triggered.")
## Set credentials
auth = {"vaultId": vaultId,
- "token": vaultToken,
- "world": serverlist[idx]["UUID"]}
+ "token": vaultToken}
r=vault.post(VAULT_HOST+"/getlake", json=auth, timeout=15.0)
if r.status_code == 200:
goto=r.json()["world"]
@@ -315,7 +320,33 @@ def world_select():
canva.pack()
label1 = tk.Label(root, text='World Selection', bg="#0c3251", fg="#fff")
label1.config(font=('helvetica', 14))
- canva.create_window(200, 20, window=label1)
+ canva.create_window(200, 30, window=label1)
+
+ ## Fetch soul data
+ auth = {"vaultId": vaultId,
+ "token": vaultToken}
+
+ r=vault.post(VAULT_HOST+"/souldata", json=auth, timeout=15.0)
+ if r.status_code != 200:
+ raise Exception("Request error: %d" % r.status_code)
+ dat=r.json()
+ mySoul={}
+ mySoul["level"]=dat["soulv"]
+ mySoul["exp"]=dat["soulx"]
+ mySoul["next"]=dat["varlv"]
+ mySoul["up"]=False
+ ## Newer versions of API may level you up - catch it
+ try:
+ mySoul["up"]=dat["lvlup"]
+ mySoul["home"]=dat["homew"]
+ for s in serverlist:
+ if mySoul["home"] == s["UUID"]:
+ mySoul["home"] = s["Name"]
+ break
+ if mySoul["home"] == "VAULT":
+ mySoul["home"]="Not Set"
+ except:
+ pass
## Not really necessary? Or just TODO?
## Without these, max is 10 worlds
@@ -325,19 +356,25 @@ def world_select():
## Create a list of all worlds
ypos = 60
for w in serverlist:
- ## TODO: Do not block main thread, launch this in a threading
+ ## TODO: Do not block main thread, launch this in a threading?
## TODO: Make the button width fixed, so they align better
## TODO: Image button if an icon can be found
- button = HoverButton(text=w["Name"], command=partial(launch_game_master, serverlist.index(w)), width=300, bg="#cc6600", fg="#fff", activebackground="#ee9933")
- ## TODO: Handle MLP (on the threading?)
- ## while app = 7 ...
+ button = HoverButton(text=w["Name"], command=partial(launch_game_master, serverlist.index(w)), width=40, anchor="w", bg="#cc6600", fg="#fff", activebackground="#ee9933")
## TODO: First login greeting?
- canva.create_window(100, ypos, window=button)
- ## TODO: World Info Button
+ canva.create_window(200, ypos, window=button)
+ ## TODO FIXME: World Info Button
button = HoverButton(text="?", command=partial(info_game, serverlist.index(w)), bg="#cc6600", fg="#fff", activebackground="#ee9933")
- canva.create_window(350, ypos, window=button)
+ canva.create_window(370, ypos, window=button)
ypos += 40
+ ## TODO: Footnote
+ labf = "Lv %d, %d/%d EXP" % (mySoul["level"], mySoul["exp"], mySoul["next"])
+ labelf = tk.Label(root, text=labf, bg="#0c3251", fg="#fff")
+ labelf.config(font=('helvetica', 14))
+ canva.create_window(200, 550, window=labelf)
+ labelf = tk.Label(root, text="Home: %s" % mySoul["home"], bg="#0c3251", fg="#fff")
+ labelf.config(font=('helvetica', 14))
+ canva.create_window(200, 570, window=labelf)
return
#################################################################################
@@ -416,65 +453,38 @@ savePass.set(pref["pass"] != "")
## Email
label1 = tk.Label(root, text='Email:', bg="#0c3251", fg="#fff")
label1.config(font=('helvetica', 14))
-canva.create_window(200, 40, window=label1)
+canva.create_window(180, 40, window=label1)
entry1 = tk.Entry(root)
entry1.insert(0, pref["user"])
-canva.create_window(200, 80, window=entry1)
+canva.create_window(180, 80, window=entry1)
c1 = tk.Checkbutton(root, text="Remember", variable=saveMail, bg="#0c3251", fg="#f70")
-canva.create_window(350, 80, window=c1)
+canva.create_window(320, 80, window=c1)
label2 = tk.Label(root, text='Password:', bg="#0c3251", fg="#fff")
label2.config(font=('helvetica', 14))
-canva.create_window(200, 120, window=label2)
+canva.create_window(180, 120, window=label2)
entry2 = tk.Entry(root, show="*")
entry2.insert(0, pref["pass"])
-canva.create_window(200, 160, window=entry2)
+canva.create_window(180, 160, window=entry2)
c1 = tk.Checkbutton(root, text="Remember", variable=savePass, bg="#0c3251", fg="#f70")
-canva.create_window(350, 160, window=c1)
+canva.create_window(320, 160, window=c1)
label3 = tk.Label(root, text='TOTP:', bg="#0c3251", fg="#fff")
label3.config(font=('helvetica', 14))
-canva.create_window(200, 200, window=label3)
+canva.create_window(180, 200, window=label3)
entry3 = tk.Entry(root)
#entry3.insert(0, pref["totp"])
-canva.create_window(200, 240, window=entry3)
+canva.create_window(180, 240, window=entry3)
button1 = HoverButton(text='Login', command=login, bg="#cc6600", fg="#fff", activebackground="#ee9933")
canva.create_window(200, 300, window=button1)
root.mainloop()
-# Check if you're now logged in
+# Check if you were logged in
if vaultId < 1:
exit(1)
print("Thanks for playing!")
-
-exit(0) # <- FIXME: Not necessary? Just delete stuff below
-
-#################################################################################
-"""
- while True:
- app=launch_game(idx)
-
- ## TODO: Handle MLP
- while app == 7:
- stdout("[CLIENT] Mirror Lake triggered.")
- r=vault.post(VAULT_HOST+"/getlake", json=auth, timeout=15.0)
- if r.status_code == 200:
- goto=r.json()["world"]
- stdout("MLP Target: %s" % str(goto))
- if goto == "" or goto.lower() == "vault":
- stdout("Mirror Lake False Positive")
- break
- try:
- idx=int(dl_search_idx(serverlist, "UUID", goto))
- app=launch_game(idx)
- except:
- traceback.print_exc()
- break
- else:
- stdout("ERROR: Unknown command. Try \"help\".")
-"""