From 9da204da1d883a1b1963591b5000ad78fbb64551 Mon Sep 17 00:00:00 2001 From: jimbohimself Date: Fri, 7 Mar 2025 20:37:38 -0800 Subject: [PATCH] Upload files to "/" --- __main__.py | 548 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 548 insertions(+) create mode 100644 __main__.py diff --git a/__main__.py b/__main__.py new file mode 100644 index 0000000..232c1d8 --- /dev/null +++ b/__main__.py @@ -0,0 +1,548 @@ +from os.path import isfile, join, exists +import customtkinter +from CTkMessagebox import CTkMessagebox +from subfiles import helpers, install, savetools, themes, comunic + +import json + +from subprocess import Popen, PIPE +import threading + +from pathlib import Path +from sys import platform + + +from hashlib import sha256 + +from os import listdir +from os.path import isfile, join, exists + +import shutil +from websockets.sync.client import connect + + +customtkinter.set_appearance_mode("System") +customtkinter.set_window_scaling(1) +customtkinter.set_widget_scaling(1) + +def placeholder(): + print("placeholder called") + pass + +class menuTools: + def selectFromList(self, itemList, iconList, textvar): + #there is a LOT here, I really should make a "menus" file lol + self.truePath='' + print(textvar.get()) + self.threadRunning=False + currentOption= customtkinter.StringVar() + currentOption.set("Current Option: None") + + self.currentImage = helpers.getIcon(self, "NA", "/placeholder.png") + + currentLimit = customtkinter.StringVar() + + newWindow = customtkinter.CTkToplevel(self.root) + newWindow.title("Select An Option") + newWindow.geometry("600x400") + + customtkinter.CTkLabel(newWindow, text="Please Choose an Option", anchor='center').grid(row=0, column=0, sticky="we") + + centerFrame = customtkinter.CTkFrame(newWindow, width=600, height=200, fg_color="transparent") + centerFrame.pack_propagate(False) + + listFrame= customtkinter.CTkScrollableFrame(centerFrame, height=200, width=300, bg_color="transparent") + self.listFrameInner = customtkinter.CTkFrame(listFrame) + self.listFrameInner.pack() + def submit(self, truePath, textvar, window): + + print(f"truePath : {self.truePath}") + print(textvar.get()) + if currentOption.get() == '': + window.destroy() + else: + textvar.set(self.truePath) + window.destroy() + + + def change(self, path, name, textVar, iconList): + textVar.set(f"Current Option: {name}") + print(path) + self.truePath=path + print(self.truePath) + self.currentImage=helpers.getIcon(self, path, iconList[path]) + icon=customtkinter.CTkImage(dark_image=self.currentImage, size=(200, 200)) + self.iconLabel.destroy() + self.iconLabel = customtkinter.CTkLabel(sideFrame, text="", image=icon, width=275, height=200) + self.iconLabel.grid(row=0, column=0) + + + + def outsideThread(self, listFrame, itemList, limit, truePath): + i = 0 + for element in itemList: + if limit in element["name"].lower(): ass= True + else: ass= False + print(f"{element["name"]} : {str(ass)}") + if limit in element["name"].lower(): + + if "slot" in element: + button = customtkinter.CTkButton(self.listFrameInner, text=(f"{element["name"]} - SLOT {str(element["slot"])}"), border_color="black", anchor="w", fg_color="transparent", width = 299, command=lambda element=element: change(self, element["uniqueName"], element["name"], currentOption, iconList)) + else: + i+=1 + button = customtkinter.CTkButton(self.listFrameInner, text=(f"{element["name"]} - NO SLOT"), border_color="black", anchor="w", fg_color="transparent", width = 299, command=lambda element=element: change(self, element["uniqueName"], element["name"], currentOption, iconList)) + button.pack(anchor="nw", expand=True) + print(i) + + self.threadRunning=False + + def reset(self, args): + if self.threadRunning: + return #If the search thread is running, just wait, don't be fucking lazy, it takes 2 seconds for THE ENTIRE LIST, it is not that hard + helpers.removeChildren(self.listFrameInner) + helpers.bgThread(outsideThread, args) + + helpers.bgThread(outsideThread, [self, listFrame, itemList, '', self.truePath]) + + sideFrame= customtkinter.CTkFrame(centerFrame, height=200, width=275, fg_color="transparent") + + icon=customtkinter.CTkImage(dark_image=self.currentImage, size=(200, 200)) + self.iconLabel = customtkinter.CTkLabel(sideFrame, text="", image=icon, width=275, height=200) + self.iconLabel.grid(row=0, column=0) + sideFrame.grid(row=0, column=0, sticky="nsew") + + + searchFrame=customtkinter.CTkFrame(newWindow, width=600) + searchFrame.grid(row=2, column=0) + search=customtkinter.CTkEntry(searchFrame, textvariable=currentLimit, fg_color="transparent", width=400) + search.grid(row=0, column=0) + + searchButton=customtkinter.CTkButton(searchFrame, width=200, text="Search", command=lambda: reset(self, [self, listFrame, itemList, currentLimit.get(), self.truePath])) + searchButton.grid(row=0, column=1) + + optionLabel= customtkinter.CTkLabel(newWindow, textvariable=currentOption) + + submitButton=customtkinter.CTkButton(newWindow, width=100, text="Submit", height=30, command= lambda: submit(self,self.truePath,textvar,newWindow)) + submitButton.grid(row=4, column=0) + + + centerFrame.grid(row=1, column=0) + listFrame.grid(row=0, column=1) + + optionLabel.grid(row=3, column=0) + + def verticalButtons(self, buttonList, frame): + for button in buttonList.keys(): + sideButton = customtkinter.CTkButton(frame, height=28, hover_color=self.theme["highlight_color"], + border_color=self.theme["highlight_color"], + border_width=(self.x * .001), + fg_color="transparent", + bg_color="transparent", + text=button, + command=buttonList[button]) + sideButton.pack(pady=(self.y * .01), padx=2, side="top", anchor="nw") + + def labelDown(self, labelList, frame, column): + newFrame=customtkinter.CTkFrame(frame, fg_color="transparent") + newFrame.grid(row=0, column=3, sticky="nswe") + + i=1 + l = [] + for labelText in labelList: + label = customtkinter.CTkLabel(newFrame, textvariable=labelText, height=28, text_color="white") + l.append(label) + + for g in l: + g.pack(anchor='nw') + i+=1 + + def horizontalButtons(self, buttonList, frame): + for button in buttonList.keys(): + sideButton = customtkinter.CTkButton(frame, height=28, hover_color=self.theme["highlight_color"], + border_color=self.theme["highlight_color"], + border_width=(self.x * .001), + fg_color="transparent", + bg_color="transparent", + text=button, + command=buttonList[button]) + sideButton.pack(pady=(self.x * .01), padx=2, side="left", anchor="w") + + + + +class menus(): + + def serverMenu(self): + helpers.removeChildren(self.mainFrame) + + topFrame = customtkinter.CTkFrame(self.mainFrame, fg_color=self.theme["bg_deep"], corner_radius=10, height=(self.y * .80), width=(self.x * (.70)), + + ) + topFrame.pack(pady=(self.y * .10)) + topFrame.grid_propagate(0) + + + sideFrame = customtkinter.CTkFrame(topFrame, width=(self.x * .7 * .25), height=self.y*.8, fg_color=self.theme['bg_deep']) + sideFrame.grid(row=0, column=0, sticky="ns") + + borderFrame=customtkinter.CTkFrame(topFrame, width=(self.x * .7 * .01), height=(self.y*.8), fg_color=self.theme['bg_color'], corner_radius=0) + borderFrame.grid(row=0, column=1, sticky="ns") + sideFrame.grid_propagate(1) + + buttonList = { + "Start Server" : lambda: helpers.bgThread(comunic.startServer, [self, self.serverPath, self.logArea]), + "Open Server Location": lambda: helpers.openLocation(self, comunic.getSnPath('sngconfig.json')) + } + menuTools.verticalButtons(self, buttonList=buttonList, frame=sideFrame) + + self.logArea = customtkinter.CTkTextbox(topFrame, width=(self.x * .7 * .74)) + self.logArea.grid(row=0, column=2, sticky="ns") + + def updateMenu(self): + helpers.removeChildren(self.mainFrame) + + topFrame = customtkinter.CTkFrame(self.mainFrame, fg_color=self.theme["bg_deep"], corner_radius=10, height=(self.y * .80), width=(self.x * (.70)), + + ) + topFrame.pack(pady=(self.y * .10)) + topFrame.grid_propagate(0) + + + sideFrame = customtkinter.CTkFrame(topFrame, width=(self.x * .7 * .25), height=self.y*.8, fg_color="transparent", corner_radius=10) + sideFrame.grid(row=0, column=0, sticky="ns") + + borderFrame=customtkinter.CTkFrame(topFrame, width=(self.x * .7 * .01), height=(self.y*.8), fg_color=self.theme['bg_color'], corner_radius=0) + borderFrame.grid(row=0, column=1, sticky="ns") + sideFrame.grid_propagate(1) + + self.versions = [ + customtkinter.StringVar(), + customtkinter.StringVar() + ] + + buttonList = { + "Open Client Location" : lambda: helpers.openLocation(self, self.clientPath), + "Open Server Location": lambda: helpers.openLocation(self, comunic.getSnPath(self.configFile)), + "Update Client Bootstrapper" : lambda: comunic.downloadLatestDll(self, self.clientPath), + "Update Server" : lambda: placeholder() + } + menuTools.verticalButtons(self, buttonList=buttonList, frame=sideFrame) + + + self.versions[0].set("Checking Server Version") + self.versions[1].set("Checking Client Version") + + helpers.bgThread(comunic.getLatestVersions, [self, 'tempFile.json', self.versions]) + + + menuTools.labelDown(self, labelList=self.versions, frame=topFrame, column=3) + + def clientMenu(self): + helpers.removeChildren(self.mainFrame) + + topFrame = customtkinter.CTkFrame(self.mainFrame, fg_color=self.theme["bg_deep"], corner_radius=10, height=(self.y * .80), width=(self.x * (.70)), + + ) + topFrame.pack(pady=(self.y * .10)) + topFrame.grid_propagate(0) + + menuBar = customtkinter.CTkFrame(topFrame, fg_color=self.theme["bg_deep"], width=(self.x * (.70)), height=self.y * .1) + menuBar.grid(row=0, column=0, sticky="we") + + buttonList = { + "Start Client (steam)" : lambda: helpers.bgThread(comunic.startClient, [self, json.load(open(self.configFile))["steamID"]]), + "Open Logs Location" : lambda: comunic.openClientLogs(self, platform) + } + menuTools.horizontalButtons(self, buttonList, menuBar) + + def settingsMenu(self, file): + data = savetools.loadFile(self, file) + helpers.removeChildren(self.mainFrame) + topFrame = customtkinter.CTkScrollableFrame(self.mainFrame, fg_color=self.theme["bg_deep"], corner_radius=10, height=(self.y * .80), width=(self.x * (.70)), + ) + topFrame.pack(pady=(self.y * .10)) + newData = {} + def recusiveIssue(self, data, newData, topFrame, recLayer, i): + print("Length : " + str(i) + " Type : " + str(type(data))) + if type(data) is dict: + + for key in data.keys(): + layerArr = "" + for n in range(recLayer): + layerArr = layerArr + " " + if recLayer > 0: + layerArr=layerArr+"↳" + l = customtkinter.CTkLabel(topFrame, text=layerArr + key, anchor='w') + l.grid(row=i, column=0, sticky='w') + + + print(key + f" : {str(i)}") + + match data[key]: + case str(): + newData[key] = customtkinter.StringVar() + newData[key].set(data[key]) + + e = customtkinter.CTkEntry(topFrame, textvariable=newData[key], width=self.x*.5) + e.grid(row=i, column=1, padx=10) + i+=1 + case bool(): + newData[key] = customtkinter.BooleanVar() + newData[key].set(data[key]) + + e = customtkinter.CTkSwitch(topFrame, variable=newData[key], onvalue=True, offvalue=False, text='') + e.grid(row=i, column=1, padx=10) + i+=1 + case int(): + newData[key] = customtkinter.StringVar() + newData[key].set(str(data[key])) + + e = customtkinter.CTkEntry(topFrame, textvariable=newData[key], width=self.x*.5, validate='key', validatecommand=(self.verifyNumb, '%P')) + e.grid(row=i, column=1, padx=10) + i+=1 + case dict(): + i+=1 + newData[key] = {} + i = recusiveIssue(self, data[key], newData[key], topFrame, (recLayer + 1), i) + case list(): + i+=1 + newData[key] = [] + i = recusiveIssue(self, data[key], newData[key], topFrame, (recLayer + 1), i) + + + elif type(data) is list: + for key in range(len(data)): + layerArr = "" + for n in range(recLayer): + layerArr = layerArr + " " + if recLayer > 0: + layerArr=layerArr+"↳" + l = customtkinter.CTkLabel(topFrame, text=layerArr + str(key), anchor='w') + l.grid(row=i, column=0, sticky='w') + + print(str(key) + " key") + + + match data[key]: + + case str(): + newData.append(customtkinter.StringVar()) + newData[key].set(data[key]) + + e = customtkinter.CTkEntry(topFrame, textvariable=newData[key], width=self.x*.5) + e.grid(row=i, column=1, padx=10) + i+=1 + case bool(): + newData.append(customtkinter.BooleanVar()) + newData[key].set(data[key]) + + e = customtkinter.CTkSwitch(topFrame, variable=newData[key], onvalue=True, offvalue=False, text='') + e.grid(row=i, column=1, padx=10) + i+=1 + case int(): + newData.append(customtkinter.IntVar()) + newData[key].set(data[key]) + + e = customtkinter.CTkEntry(topFrame, textvariable=newData[key], width=self.x*.5) + e.grid(row=i, column=1, padx=10) + i+=1 + case dict(): + i+=1 + newData.append({}) + i = recusiveIssue(self, data[key], newData[key], topFrame, (recLayer + 1), i) + case list(): + i+=1 + newData.append([]) + i = recusiveIssue(self, data[key], newData[key], topFrame, (recLayer + 1), i) + return i + i=0 + i=recusiveIssue(self, data, newData, topFrame, 0, i) + saveButton = customtkinter.CTkButton(topFrame, height=28, hover_color=self.theme["highlight_color"], + border_color=self.theme["highlight_color"], + border_width=(self.x * .001), + fg_color="transparent", + bg_color="transparent", + text="Save Settings", + command=lambda: savetools.saveFile(self, newData, file)) + saveButton.grid(row=i, column=0, sticky='w') + + def plutoMenu(self): + helpers.removeChildren(self.mainFrame) + plutoList=[f for f in listdir(self.clientPath+'/OpenWF/scripts/') if isfile(join(self.clientPath + "/OpenWF/scripts/", f))] + runningList={} + print(plutoList) + + topFrame = customtkinter.CTkFrame(self.mainFrame, fg_color=self.theme["bg_deep"], corner_radius=10, height=(self.y * .80), width=(self.x * (.70)), + + ) + topFrame.pack(pady=(self.y * .10)) + topFrame.grid_propagate(0) + topFrame.columnconfigure(1, weight=1) + i=0 + for pluto in plutoList: + runningList[pluto] = customtkinter.BooleanVar() + label = customtkinter.CTkLabel(topFrame, text=pluto) + label.grid(row=i, column=0, sticky="nsw", padx=10) + toggle = customtkinter + e = customtkinter.CTkSwitch(topFrame, variable=runningList[pluto], command=lambda pluto=pluto: comunic.runPluto(self, pluto, runningList), text='') + e.grid(row=i, column=1, padx=10) + i+=1 + print(pluto) + + def inlineScripting(self): + helpers.removeChildren(self.mainFrame) + + topFrame = customtkinter.CTkFrame(self.mainFrame, fg_color=self.theme["bg_deep"], corner_radius=10, height=(self.y * .80), width=(self.x * (.70)), + ) + topFrame.pack(pady=(self.y * .10)) + topFrame.grid_propagate(0) + + sideFrame = customtkinter.CTkFrame(topFrame, width=(self.x * .7 * .25), height=self.y*.8, fg_color=self.theme['bg_deep']) + sideFrame.grid(row=0, column=0, sticky="ns") + + borderFrame=customtkinter.CTkFrame(topFrame, width=(self.x * .7 * .01), height=(self.y*.8), fg_color=self.theme['bg_color'], corner_radius=0) + borderFrame.grid(row=0, column=1, sticky="ns") + sideFrame.grid_propagate(1) + + buttonList = { + "Push Inline" : lambda: comunic.pushInline(self, self.logArea) + } + menuTools.verticalButtons(self, buttonList=buttonList, frame=sideFrame) + + self.logArea = customtkinter.CTkTextbox(topFrame, width=(self.x * .7 * .74)) + self.logArea.grid(row=0, column=2, sticky="ns") + + def arsenalMenu(self): + helpers.removeChildren(self.mainFrame) + #Load weapons from cache + try: + self.weapons=helpers.formatExportWeapons(self, './cache/items/weapons.json') + self.powersuits=helpers.formatExportPowersuits(self, './cache/items/powersuits.json') + self.weaponsIcons=helpers.formatExportPlus(self, './cache/items/plus/weapons.json') + self.powersuitsIcons=helpers.formatExportPlus(self, './cache/items/plus/powersuits.json') + except: + print("FUCK") + comunic.getWarframeExports(self, "./cache/items/") + comunic.getWarframeExportsPlus(self, "./cache/items/") + self.weapons=helpers.formatExportWeapons(self, './cache/items/weapons.json') + self.powersuits=helpers.formatExportPowersuits(self, './cache/items/powersuits.json') + self.weaponsIcons=helpers.formatExportPlus(self, './cache/items/plus/weapons.json') + self.powersuitsIcons=helpers.formatExportPlus(self, './cache/items/plus/powersuits.json') + + topFrame = customtkinter.CTkFrame(self.mainFrame, fg_color=self.theme["bg_deep"], corner_radius=10, height=(self.y * .80), width=(self.x * (.70)),) + topFrame.pack(pady=(self.y * .10)) + topFrame.grid_propagate(0) + + leftFrame = customtkinter.CTkFrame(topFrame, width=(self.x * .7 * .25), height=self.y*.8, fg_color=self.theme['bg_deep']) + leftFrame.grid(row=0, column=0, sticky="ns") + + borderFrame=customtkinter.CTkFrame(topFrame, width=(self.x * .7 * .01), height=(self.y*.8), fg_color=self.theme['bg_color'], corner_radius=0) + borderFrame.grid(row=0, column=1, sticky="ns") + leftFrame.grid_propagate(1) + + rightFrame = customtkinter.CTkFrame(topFrame, fg_color=self.theme['bg_deep']) + rightFrame.grid(row=0, column=2, sticky="nsew") + + selectedWeapons = {} + i=0 + for entry in ["Warframe", "Primary", "Secondary", "Melee"]: + selectedWeapons[entry] = customtkinter.StringVar() + l=customtkinter.CTkLabel(rightFrame, text=entry) + l.grid(row=i, column=0, padx=6) + + e=customtkinter.CTkEntry(rightFrame, textvariable=selectedWeapons[entry], width=self.x*.3, fg_color=self.theme["fg_color"]) + e.grid(row=i, column=1, sticky="n", padx=10, pady=3) + + if not (entry == "Warframe"): + button=customtkinter.CTkButton(rightFrame, text="📁", width=5, command=lambda selectedWeapons=selectedWeapons[entry]: menuTools.selectFromList(self, self.weapons, self.weaponsIcons, selectedWeapons)) + elif entry == "Warframe": + button=customtkinter.CTkButton(rightFrame, text="📁", width=5, command=lambda selectedWeapons=selectedWeapons[entry]: menuTools.selectFromList(self, self.powersuits, self.powersuitsIcons, selectedWeapons)) + #if not entry: + # how????? + button.grid(row=i, column=2) + + + i+=1 + + buttonList = { + "Push All" : lambda: comunic.pushWeapon(self, [selectedWeapons["Warframe"].get(),selectedWeapons["Primary"].get(),selectedWeapons["Secondary"].get(),selectedWeapons["Melee"].get()], [3, 1, 0, 5]), + "Push Warframe" : lambda: comunic.pushWeapon(self, selectedWeapons["Warframe"].get(), 3), + "Push Primary" : lambda: comunic.pushWeapon(self, selectedWeapons["Primary"].get(), 1), + "Push Secondary" : lambda: comunic.pushWeapon(self, selectedWeapons["Secondary"].get(), 0), + "Push Melee" : lambda: comunic.pushWeapon(self, selectedWeapons["Melee"].get(), 5) + } + + menuTools.verticalButtons(self, buttonList, leftFrame) + + +class main(): + def exit(self): + self.threadStop = True + for thread in self.popenThreads: + helpers.killPopen(thread) + self.root.destroy() + + def __init__(self, configFile): + self.configFile = configFile + self.clientPath = json.load(open(configFile))['wfpath'] + self.serverPath = json.load(open(configFile))['spaceninjapath'] + self.debug = False + self.root = customtkinter.CTk() + self.popenThreads = [] + self.x=750 + self.y=500 + self.theme = themes.getThemes(self)[json.load(open(configFile))['theme']] + self.threadStop = False + print() + for lib in [helpers, install, savetools]: + lib.check() + self.rightFrame = customtkinter.CTkScrollableFrame(self.root, + orientation="vertical", + width=(self.x * .20), + height=(self.y * 1), + fg_color=self.theme["fg_color"], + bg_color=self.theme["bg_color"], + corner_radius=0 + ) + + + buttonList = { + "Server" : lambda: menus.serverMenu(self), + "Server Settings": lambda: menus.settingsMenu(self, self.serverPath+'config.json'), + "Client" : lambda: menus.clientMenu(self), + "Client Settings": lambda: menus.settingsMenu(self, self.clientPath+'OpenWF/client_config.json'), + "Scripts" : lambda: menus.plutoMenu(self), + "Script Store": lambda: placeholder(), + "Inline Scripting" : lambda: menus.inlineScripting(self), + "Metadata" : lambda: placeholder(), + "Arsenal Management": lambda: menus.arsenalMenu(self), + "Weapon Upgrades" : lambda: placeholder(), + "Updates": lambda: menus.updateMenu(self), + "GUI Settings" : lambda: menus.settingsMenu(self, self.configFile) + } + + menuTools.verticalButtons(self, buttonList, self.rightFrame) + self.rightFrame.grid(row=0, column=0) + + self.mainFrame = customtkinter.CTkScrollableFrame(self.root, + width=(self.x * (1-.20)), + height=(self.y * 1), + fg_color=self.theme["bg_color"], + bg_color=self.theme["bg_color"], + corner_radius=0) + self.verifyNumb = self.root.register(helpers.isNumber) + + self.mainFrame.grid(row=0, column=1) + + self.root.title("SpaceNinGui CustomTK 1.0.0") + self.root.protocol("WM_DELETE_WINDOW", lambda: main.exit(self)) + self.root.geometry(f"{str(self.x)}x{str(self.y)}") + self.root.resizable(width=False, height=False) + self.root.mainloop() + + +if __name__ == "__main__": + if isfile('sngconfig.json'): + main('sngconfig.json') + else: + pass