summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2024-02-05 10:49:01 -0300
committerJesusaves <cpntb1@ymail.com>2024-02-05 10:49:01 -0300
commitf6b8c0c64757c73b6f2063d3a6d93ce2f8f527d5 (patch)
treefb7e7222d429204e290b4a904ed311e74855b43f
parentaff41493031b39a04057beba21b396b9d703b481 (diff)
downloadtkinter-f6b8c0c64757c73b6f2063d3a6d93ce2f8f527d5.tar.gz
tkinter-f6b8c0c64757c73b6f2063d3a6d93ce2f8f527d5.tar.bz2
tkinter-f6b8c0c64757c73b6f2063d3a6d93ce2f8f527d5.tar.xz
tkinter-f6b8c0c64757c73b6f2063d3a6d93ce2f8f527d5.zip
MLP support
-rwxr-xr-x__main__.py40
1 files changed, 38 insertions, 2 deletions
diff --git a/__main__.py b/__main__.py
index 43a447c..26472e7 100755
--- a/__main__.py
+++ b/__main__.py
@@ -128,6 +128,16 @@ def now():
def nullp(arg):
return
+# Search for array[?][key]==search in an array of dicts
+# Returns the index, or returns -1
+def dl_search_idx(array, key, search):
+ try:
+ r=next((i for i, item in enumerate(array) if item[key] == search), None)
+ except:
+ traceback.print_exc()
+ r=-1
+ return ifte(r is None, -1, r)
+
## Validates a server entry
def validate_server(srv):
name="Unknown Server"; ok=False
@@ -263,6 +273,30 @@ def launch_game(idx):
return app
+## Run a game from world selection screen, and handles MLP
+def launch_game_master(idx):
+ app=launch_game(idx)
+ while app == 7:
+ stdout("[CLIENT] Mirror Lake triggered.")
+ ## Set credentials
+ auth = {"vaultId": vaultId,
+ "token": vaultToken,
+ "world": serverlist[idx]["UUID"]}
+ 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
+ return
+
## Only meaningful on Linux
os.environ["APPIMAGELAUNCHER_DISABLE"]="1"
@@ -283,7 +317,8 @@ def world_select():
label1.config(font=('helvetica', 14))
canva.create_window(200, 20, window=label1)
- # Not really necessary? Or just TODO?
+ ## Not really necessary? Or just TODO?
+ ## Without these, max is 10 worlds
#scrollbar = tk.Scrollbar(canva, orient=tk.VERTICAL)
#canva.create_window(400, 20, window=scrollbar)
@@ -293,8 +328,9 @@ def world_select():
## 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, serverlist.index(w)), width=300, bg="#cc6600", fg="#fff", activebackground="#ee9933")
+ 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 ...
## TODO: First login greeting?
canva.create_window(100, ypos, window=button)
## TODO: World Info Button