From f6b8c0c64757c73b6f2063d3a6d93ce2f8f527d5 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Mon, 5 Feb 2024 10:49:01 -0300 Subject: MLP support --- __main__.py | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file 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 -- cgit v1.2.3-70-g09d2