diff --git a/.github/workflows/pyinstaller-linux.yml b/.github/workflows/pyinstaller-linux.yml index 891933d..03e000f 100644 --- a/.github/workflows/pyinstaller-linux.yml +++ b/.github/workflows/pyinstaller-linux.yml @@ -21,7 +21,8 @@ jobs: pip install pyinstaller pip install jsoncparser pip install certifi - pip install pyyaml + pip install am-i-connected + pip install pyperclip - name: Run PyInstaller run: | pyinstaller --noconfirm --onedir --console --name "Snark" --add-data "version.txt:." --add-data "activities.txt:." --add-data "logo128.png:." --add-data "icon-win32.ico:." --add-data "icon-linux.png:." --add-data "LICENSE:." --add-data "README.md:." --add-data "save:save/" --add-data "themes:themes/" --add-data "third_party:third_party/" --add-data "images:images/" --add-data "logs:logs/" "GUI.py" diff --git a/.github/workflows/pyinstaller.yml b/.github/workflows/pyinstaller.yml index 5a2cc35..e408f92 100644 --- a/.github/workflows/pyinstaller.yml +++ b/.github/workflows/pyinstaller.yml @@ -21,7 +21,8 @@ jobs: pip install pyinstaller pip install jsoncparser pip install certifi - pip install pyyaml + pip install am-i-connected + pip install pyperclip - name: Run PyInstaller run: | pyinstaller --noconfirm --onedir --console --name "Snark" --add-data "version.txt:." --add-data "activities.txt:." --add-data "logo128.png:." --add-data "icon-win32.ico:." --add-data "icon-linux.png:." --add-data "LICENSE:." --add-data "README.md:." --add-data "save:save/" --add-data "themes:themes/" --add-data "third_party:third_party/" --add-data "images:images/" --add-data "logs:logs/" "GUI.py" diff --git a/GUI.py b/GUI.py index 9460452..5c045b1 100644 --- a/GUI.py +++ b/GUI.py @@ -16,6 +16,7 @@ import jsonc import certifi import ssl +from am_i_connected import CheckThereIsConnection selected_scr = '' scr_dat = '' @@ -72,58 +73,6 @@ def interp(self): scr_dat = [self.mode, scr] guii.exec_script(scr_dat) -class ScriptWin: - - def __init__(self): - self.nroot = Tk() - self.win() - self.nroot.mainloop() - - def win(self): - self.flags = Flags() - self.nroot.title("Scripts") - - frame = Frame(self.nroot, borderwidth=2, relief="sunken") - frame.grid(column=1, row=1, sticky=(N, E, S, W)) - self.nroot.columnconfigure(1, weight=1) - self.nroot.rowconfigure(1, weight=1) - - if self.flags.allowScripts: - self.scripts = [] - if getattr(sys, 'frozen', False): - EXE_LOCATION = os.path.dirname( sys.executable ) - else: - EXE_LOCATION = os.path.dirname( os.path.realpath( __file__ ) ) - scr_dir = os.path.join(EXE_LOCATION, "scripts") - for s in os.listdir(scr_dir): - self.scripts.append(s.replace('.txt', '')) - print(self.scripts) - - self.scr_list = Listbox(frame) - self.scr_list.grid(column=1, row=1, sticky=(N, S, E, W), padx=40, pady=(40, 0), rowspan=5) - count = 0 - for n in self.scripts: - count += 1 - self.scr_list.insert(count, n) - - select_scr = Button(frame, text="Select", command=self.select) - select_scr.grid(column=1, row=6, sticky=(S)) - else: - b_smd = Label(frame, text=f"Proper script functionality will be implemented in a future release,\nfor now though, the script button is here so I don't have to\ncompletely remodel the GUI with its removal.") - b_smd.grid(column=1, row=1, sticky=(S), padx=25, pady=25) - - select_scr = Button(frame, text="I understand", command=self.close) - select_scr.grid(column=1, row=6, sticky=(S)) - def close(self): - self.nroot.destroy() - - def select(self): - global selected_scr - selected_scr = self.scripts[int(self.scr_list.curselection()[0])] - print(selected_scr) - scr_interp = Interp(selected_scr) - self.nroot.destroy() - class OptWin: def __init__(self): @@ -261,15 +210,16 @@ def save_options(self): def check_version(self): url = "https://github.com/PostScriptReal/Snark_Compiler/raw/refs/heads/main/version.txt" - webVer = urlopen(url, context=ssl.create_default_context(cafile=certifi.where())).read().decode('utf-8') - print(webVer) + if CheckThereIsConnection(): + webVer = urlopen(url, context=ssl.create_default_context(cafile=certifi.where())).read().decode('utf-8') + print(webVer) - # Don't you dare make a Fortnite joke - vFile = open("version.txt", "r") - curVer = vFile.read() + # Don't you dare make a Fortnite joke + vFile = open("version.txt", "r") + curVer = vFile.read() - if curVer != webVer: - a = GetNewVersion(webVer, self.chkVerTheme) + if curVer != webVer: + a = GetNewVersion(webVer, self.chkVerTheme) def __init__(self): super().__init__() @@ -285,7 +235,7 @@ def __init__(self): self.selTheme = self.options["theme"] winSizeFile = False - winSizeVer = 2 + winSizeVer = 3 if sys.platform == "linux" and os.path.exists(f"WinSize{winSizeVer}.txt"): wsFile = open(f"WinSize{winSizeVer}.txt", "r") ws = wsFile.readlines() @@ -370,9 +320,7 @@ def __init__(self): self.frame = Frame(self, borderwidth=2, relief="sunken", bg=thCol["bg"]) self.frame.grid(column=6, row=2, sticky=(N, E, S, W)) self.header = Frame(self.frame, borderwidth=2, bg=thCol["bg"]) - self.header.grid(column=1, row=1, sticky=(N, W, E), columnspan=69) - mtbtns = Frame(self.frame, borderwidth=2, bg=thCol["bg"]) - mtbtns.grid(column=1, row=9, sticky=(S), columnspan=69) + self.header.grid(column=0, row=1, sticky=(N, W, E), columnspan=69) menu = Frame(self.frame, borderwidth=2, bg=thCol["bg"]) menu.grid(column=0, row=2, sticky=(W, S), columnspan=69) """ @@ -395,28 +343,28 @@ def __init__(self): # Create Header Buttons self.dupe_button = Button(self.header, text="Games", command=self.bd_menu, bg=thCol["btn"][0], cursor="hand2") - self.dupe_button.grid(column=0, row=0, sticky=(N), ipadx=buttonPad) + self.dupe_button.grid(column=0, row=0, sticky="nw", ipadx=buttonPad) self.cmpiler_button = Button(self.header, text="Compilers", command=self.cmpSetupMenu, bg=thCol["btn"][0], cursor="hand2") - self.cmpiler_button.grid(column=1, row=0, sticky=(N), ipadx=buttonPad) + self.cmpiler_button.grid(column=1, row=0, sticky="nw", ipadx=buttonPad) self.mat_button = Button(self.header, text="Decompile", command=self.mnc_menu, bg=thCol["btn"][0], cursor="hand2") - self.mat_button.grid(column=2, row=0, sticky=(N), ipadx=buttonPad) + self.mat_button.grid(column=2, row=0, sticky="nw", ipadx=buttonPad) self.comp_button = Button(self.header, text="Compile", command=self.cmp_menu, bg=thCol["btn"][0], cursor="hand2") - self.comp_button.grid(column=3, row=0, sticky=(N), ipadx=buttonPad) + self.comp_button.grid(column=3, row=0, sticky="nw", ipadx=buttonPad) self.scripts = Button(self.header, text="Batch Manager", command=self.scripts, bg=thCol["btn"][0], cursor="hand2") - self.scripts.grid(column=4, row=0, sticky=(N), ipadx=buttonPad) + self.scripts.grid(column=4, row=0, sticky="nw", ipadx=buttonPad) self.options = Button(self.header, text="Options", command=self.optionsMenu, bg=thCol["btn"][0], cursor="hand2") - self.options.grid(column=6, row=0, sticky=(N), ipadx=buttonPad) + self.options.grid(column=6, row=0, sticky="nw", ipadx=buttonPad) self.help = Button(self.header, text="Help", command=self.help, bg=thCol["btn"][0], cursor="hand2") - self.help.grid(column=7, row=0, sticky=(N), ipadx=buttonPad) + self.help.grid(column=7, row=0, sticky="nw", ipadx=buttonPad) self.aboutB = Button(self.header, text="About", command=self.about, cursor="hand2") - self.aboutB.grid(column=5, row=0, sticky=(N), ipadx=buttonPad) + self.aboutB.grid(column=5, row=0, sticky="nw", ipadx=buttonPad) # Getting the width of the window before adding in the menus so I can fix the width of the window on different OSs/distros if winSizeFile and not ws[0] == "": @@ -470,7 +418,7 @@ def __init__(self): print(self.goodHeight) if sys.platform == 'linux': - self.geometry(f"{self.goodWidth}x{self.goodHeight}") + self.geometry(f"{self.goodWidth+1}x{self.goodHeight}") else: self.geometry("501x443") @@ -622,8 +570,7 @@ def updateOpt(self, key, val): self.cmpMenu.updateOpt(key, val) self.decMenu.updateOpt(key, val) self.optMenu.updateOpt(key, val) - if self.flags.allowScripts: - self.batchMenu.updateOpt(key, val) + self.batchMenu.updateOpt(key, val) def updateGames(self, comp): self.cmpMenu.updateGames(comp) diff --git a/README.md b/README.md index 09bdf67..5fffbf0 100644 --- a/README.md +++ b/README.md @@ -69,5 +69,9 @@ GeckoN's v6 MDL Decompiler Proprietary + + Sven Co-op StudioMDL + Proprietary + diff --git a/interp.py b/interp.py index de2d06a..680e64b 100644 --- a/interp.py +++ b/interp.py @@ -4,7 +4,7 @@ import os import sys import subprocess -import yaml +# import yaml # Class that gets information from the script header (the lines of text sandwiched inbetween the dashes) class SSTVer: diff --git a/menus.py b/menus.py index 37d3124..87a8c75 100644 --- a/menus.py +++ b/menus.py @@ -12,7 +12,9 @@ import json import sys import jsonc -from interp import SSTReader +# from interp import SSTReader +from platform import freedesktop_os_release as distroInfo +import pyperclip DECOMP_TAB = 0 COMP_TAB = 1 @@ -26,6 +28,8 @@ def __init__(self, thme:dict, safeWidth:int): js = open("save/options.json", 'r') self.options = json.loads(js.read()) js.close() + divider = "--------------------------------------------------------------------------------" + print(f"DISTRO INFORMATION:{divider[19:]}\n{distroInfo()}\n{divider}") def setPath(self, key:str="Snark", pathKey:str="", pathVal:str=""): pathJSON = open("save/paths.json", "r") @@ -393,7 +397,7 @@ def updateOpt(self, key, value): def chComp(self, e): self.selComp = self.gameSel.get() self.name.set(self.selComp) - self.csPath.set(self.csPaths["Other"][self.selComp]) + self.csPath.set(self.csPaths["Other"].get(self.selComp, "")) # If editing options were removed and the compiler doesn't have editing disabled if self.hiddenEdit and not self.compDat[self.selComp]["disableEdit"]: self.hiddenEdit = False @@ -463,17 +467,20 @@ def __init__(self, template, master, startHidden:bool=False): self.opts = Frame(master, borderwidth=2, bg=thme["bg"], relief="sunken") self.tabs = Frame(master, borderwidth=2, bg=thme["bg"]) # Setting up options - js = open("save/options.json", 'r') - self.options = json.loads(js.read()) - js.close() + self.options = template.options + self.linuxWFix = 0 + self.batchListFix = 0 + if self.options["linuxFix"] == "Cinnamon": + self.linuxWFix = 4 + self.batchListFix = 6 self.mdls = [] self.decompTab = Button(self.tabs, text="Decompiling", cursor="hand2", command=self.switchTabDecomp) self.compTab = Button(self.tabs, text="Compiling", cursor="hand2", command=self.switchTabComp) - self.qc_list = Listbox(master, width=self.widthFix, selectmode=EXTENDED, height=15) + self.qc_list = Listbox(master, width=self.widthFix-self.batchListFix, selectmode=EXTENDED, height=15) self.qc_list.insert(0, self.blankClistStr) - self.mdl_list = Listbox(master, width=self.widthFix, selectmode=EXTENDED, height=15) + self.mdl_list = Listbox(master, width=self.widthFix-self.batchListFix, selectmode=EXTENDED, height=15) self.mdl_list.insert(0, self.blankDlistStr) self.qc_list.bind("<>", self.lbSelHandler) self.mdl_list.bind("<>", self.lbSelHandler) @@ -486,7 +493,7 @@ def __init__(self, template, master, startHidden:bool=False): self.pathSelVar = BooleanVar(self.opts, value=True) self.pathSel = Checkbutton(self.opts, text="Use Output Path", variable=self.pathSelVar, command=self.cPathChk) self.cPathVar = StringVar(self.opts, value="") - self.cPath = BoolEntry(self.opts, textvariable=self.cPathVar, placeholder="", width=27) + self.cPath = BoolEntry(self.opts, textvariable=self.cPathVar, placeholder="", width=27-self.linuxWFix) self.pathBrowse = Button(self.opts, text='Save Path', command=self.getCPath, cursor="hand2") if not startHidden: self.show() @@ -714,6 +721,16 @@ def changeTheme(self, newTheme): def updateOpt(self, key, value): if not key.startswith("gsMV"): self.options[key] = value + if key == "linuxFix": + if self.options["linuxFix"] == "Cinnamon": + self.linuxWFix = 2 + self.batchListFix = 6 + else: + self.linuxWFix = 0 + self.batchListFix = 0 + self.cPath.entry.configure(width=27-self.linuxWFix) + self.mdl_list.configure(width=self.widthFix-self.batchListFix) + self.qc_list.configure(width=self.widthFix-self.batchListFix) else: self.options["gsMV"][key.replace("gsMV", "")] = value @@ -734,7 +751,7 @@ def show(self): # self.runBtn.grid(column=0, row=1) self.opts.grid(column=0, row=2, sticky="nsew", pady=(10,0)) self.skipMDL.grid(column=0, row=0, pady=15) - self.cPathLabel.grid(column=1, row=0, padx=10) + self.cPathLabel.grid(column=1, row=0, padx=10-self.linuxWFix) self.pathSel.grid(column=2, row=0) self.cPath.grid(column=3, row=0, padx=5, pady=15) self.pathBrowse.grid(column=4, row=0) @@ -767,6 +784,11 @@ def __init__(self, template, master, batchManager:BatchManagerM, startHidden:boo js.close() # Setting up options self.options = template.options + self.linuxWFix = 0 + self.conWFix = 0 + if self.options["linuxFix"] == "Cinnamon": + self.linuxWFix = 2 + self.conWFix = 6 self.presets = { "presets": { # For most compilers @@ -804,12 +826,12 @@ def __init__(self, template, master, batchManager:BatchManagerM, startHidden:boo self.presetDat = self.presets["presets"][self.presetSel.get()] self.presetSel.bind("<>", self.chPreset) self.name = StringVar() - self.nameEntry = Entry(master, textvariable=self.name, width=self.widthFix) + self.nameEntry = Entry(master, textvariable=self.name, width=self.widthFix-self.linuxWFix) self.nameEntry.bind("", self.inputHandler) if self.options["save_paths"]: self.name.set(self.csPaths["Snark"]["decompileIn"]) tOpts = ["File", "Folder"] - self.typeSel = ttk.Combobox(master, values=tOpts, width=7) + self.typeSel = ttk.Combobox(master, values=tOpts, width=7-self.linuxWFix) self.typeSel.set(tOpts[0]) self.typeSel.bind("<>", self.clearInput) self.out = StringVar() @@ -817,14 +839,14 @@ def __init__(self, template, master, batchManager:BatchManagerM, startHidden:boo self.out.set(self.csPaths["Snark"]["decompileOut"]) if os.path.isdir(self.csPaths["Snark"]["decompileOut"]): self.batchManager.decompOutput = self.csPaths["Snark"]["decompileOut"] - self.outputEntry = Entry(master, textvariable=self.out, width=self.widthFix) + self.outputEntry = Entry(master, textvariable=self.out, width=self.widthFix-self.linuxWFix) self.outputEntry.bind("", self.outputHandler) self.mdlBrowse = Button(master, text='Browse', command=self.findMDL, cursor="hand2") self.outBrowse = Button(master, text='Browse', command=self.output, cursor="hand2") self.advOptLabel = Label(self.advOpt, text="Advanced Options") self.decomp = Button(master, text='Decompile', command=self.startDecomp, cursor="hand2") self.hlmv = Button(master, text='Open model in HLMV', command=self.openHLAM, cursor="hand2") - self.console = Console(master, 'Start a decompile and the terminal output will appear here!', 0, 5, self.conFix, 12) + self.console = Console(master, 'Start a decompile and the terminal output will appear here!', 0, 5, self.conFix-self.conWFix, 12) if self.options["save_paths"] and os.path.isdir(self.name.get()): self.typeSel.set(tOpts[1]) self.getBatch(self.name.get()) @@ -959,6 +981,13 @@ def updateOpt(self, key, value): if key == "defDPreset": self.presetSel.current(value) self.chPreset() + elif key == "linuxFix": + if self.options["linuxFix"] == "Cinnamon": + self.linuxWFix = 2 + self.conWFix = 6 + else: + self.linuxWFix = 0 + self.conWFix = 0 else: self.options["gsMV"][key.replace("gsMV", "")] = value @@ -1206,8 +1235,6 @@ def __init__(self, template, master, batchManager:BatchManagerM, startHidden:boo self.menuTemp = template self.advOptFix = True if self.curFont["family"].lower() == "nimbus sans l" or sys.platform == "win32": - self.widthFix = self.widthFix+6 - self.conFix = self.conFix-7 self.advOptFix = False elif self.safeWidth > 609: self.advOptFix = False @@ -1228,9 +1255,11 @@ def __init__(self, template, master, batchManager:BatchManagerM, startHidden:boo self.profiles = json.loads(js.read()) js.close() self.options = template.options - if self.safeWidth > 659: - n = 2 - self.widthFix, self.conFix = self.widthFix-n, self.conFix-n + self.linuxWFix = 0 + self.conWFix = 0 + if self.options["linuxFix"] == "Cinnamon": + self.linuxWFix = 2 + self.conWFix = 6 self.selects = Frame(master, borderwidth=2, bg=thme["bg"]) self.advOpt = Frame(master, borderwidth=2, bg=thme["bg"], relief="sunken") self.advOpt2 = Frame(self.advOpt, borderwidth=2, bg=thme["bg"]) @@ -1239,9 +1268,9 @@ def __init__(self, template, master, batchManager:BatchManagerM, startHidden:boo self.name = StringVar() if self.options["save_paths"]: self.name.set(self.csPaths["Snark"]["compileIn"]) - self.nameEntry = Entry(master, textvariable=self.name, width=self.widthFix) + self.nameEntry = Entry(master, textvariable=self.name, width=50-self.linuxWFix) tOpts = ["File", "Folder"] - self.typeSel = ttk.Combobox(master, values=tOpts, width=7) + self.typeSel = ttk.Combobox(master, values=tOpts, width=7-self.linuxWFix) self.typeSel.set(tOpts[0]) self.typeSel.bind("<>", self.clearInput) self.nameEntry.bind("", self.inputHandler) @@ -1250,7 +1279,7 @@ def __init__(self, template, master, batchManager:BatchManagerM, startHidden:boo self.out.set(self.csPaths["Snark"]["compileOut"]) if os.path.isdir(self.csPaths["Snark"]["compileOut"]): self.batchManager.decompOutput = self.csPaths["Snark"]["compileOut"] - self.outputEntry = Entry(master, textvariable=self.out, width=self.widthFix) + self.outputEntry = Entry(master, textvariable=self.out, width=50-self.linuxWFix) self.outputEntry.bind("", self.outputHandler) self.mdlBrowse = Button(master, text='Browse', command=self.findMDL, cursor="hand2") self.outBrowse = Button(master, text='Browse', command=self.output, cursor="hand2") @@ -1336,7 +1365,7 @@ def __init__(self, template, master, batchManager:BatchManagerM, startHidden:boo self.outputTT = ToolTip(self.outBrowse, "OPTIONAL, if an output folder is not specified, then it will place the compiled model in a subfolder of where the QC file is located.", background=thme["tt"], foreground=thme["txt"]) self.decomp = Button(master, text='Compile', command=self.startCompile, cursor="hand2") - self.console = Console(master, 'Currently no warnings or errors!', 0, 5, self.conFix, 12) + self.console = Console(master, 'Currently no warnings or errors!', 0, 5, self.conFix-self.conWFix, 12) fldrChk = False if self.options["save_paths"] and os.path.isdir(self.name.get()): self.typeSel.set(tOpts[1]) @@ -1527,6 +1556,13 @@ def updateOpt(self, key, value): self.compilerStuff() elif key == "defGame": self.gameSel.current(self.options[key]) + elif key == "linuxFix": + if self.options["linuxFix"] == "Cinnamon": + self.linuxWFix = 2 + self.conWFix = 6 + else: + self.linuxWFix = 0 + self.conWFix = 0 # Doing this since the gsMV option needs two square bracket data things in order to update stuff properly, # and the function can only use strings. else: @@ -1561,12 +1597,8 @@ def show(self): self.advOpt.grid(column=0, row=3, sticky="nsew", columnspan=10, pady=(20,0)) self.advOptLabel.grid(column=0, row=0, sticky="w") self.logChk.grid(column=0, row=1, sticky="w") - if self.advOptFix or self.safeWidth > 659: - self.dashT.grid(column=2, row=1, sticky="w") - self.dashTChk.grid(column=1, row=1, sticky="w") - else: - self.dashT.grid(column=0, row=1, sticky="w",padx=(145,0)) - self.dashTChk.grid(column=0, row=1, sticky="w",padx=(110,0)) + self.dashT.grid(column=2, row=1, sticky="w") + self.dashTChk.grid(column=1, row=1, sticky="w") self.rNormalChk.grid(column=3, row=1, sticky="w") self.angleChk.grid(column=4, row=1, sticky="w") self.angleSB.grid(column=5, row=1, sticky="w") @@ -1576,20 +1608,10 @@ def show(self): else: self.advOpt2.grid(column=0, row=2, sticky="nsew", columnspan=20) self.ignoreChk.grid(column=7, row=1, sticky="w") - if self.advOptFix: - self.bNormChk.grid(column=8, row=1, sticky="w") - else: - self.bNormChk.grid(column=8, row=1, sticky="w") - if self.advOptFix: - self.flipChk.grid(column=9, row=1, sticky="w") - else: - self.flipChk.grid(column=9, row=1, sticky="w") - if self.advOptFix: - self.groupChk.grid(column=0, row=2, sticky="w",padx=(40,0)) - self.groupSB.grid(column=0, row=2, sticky="w",padx=(81,0)) - else: - self.groupChk.grid(column=3, row=2, sticky="w") - self.groupSB.grid(column=4, row=2, sticky="w") + self.bNormChk.grid(column=8, row=1, sticky="w") + self.flipChk.grid(column=9, row=1, sticky="w") + self.groupChk.grid(column=3, row=2, sticky="w") + self.groupSB.grid(column=4, row=2, sticky="w") if not self.svengine: if self.advOptFix: self.pf2Chk.grid(column=1, row=2, sticky="w") @@ -1863,17 +1885,33 @@ def singleComp(self, mdl:str, out:str, batch:bool, mdlName:str=""): compilerPath = os.path.expanduser(p) compilerFound = True break + if not os.path.isabs(p): + newPath = os.path.join(os.getcwd(), p) + if os.path.exists(newPath): + compilerPath = newPath + compilerFound = True + break if not compilerFound: paths = self.csPaths["Other"][self.compSel.get()] if os.path.exists(paths): compilerPath = paths compilerFound = True + if not os.path.isabs(paths): + newPath = os.path.join(os.getcwd(), paths) + if os.path.exists(newPath): + compilerPath = newPath + compilerFound = True else: paths = self.csPaths["Other"][self.compSel.get()] if not paths == "": if os.path.exists(paths): compilerPath = paths compilerFound = True + if not os.path.isabs(paths): + newPath = os.path.join(os.getcwd(), paths) + if os.path.exists(newPath): + compilerPath = newPath + compilerFound = True else: paths = self.compJS["path"]["default"][sys.platform] for p in paths: @@ -1882,6 +1920,12 @@ def singleComp(self, mdl:str, out:str, batch:bool, mdlName:str=""): compilerPath = os.path.expanduser(p) compilerFound = True break + if not os.path.isabs(p): + newPath = os.path.join(os.getcwd(), p) + if os.path.exists(newPath): + compilerPath = newPath + compilerFound = True + break except: self.console.setOutput("ERROR: Couldn't find compiler, have you selected one?") return @@ -1979,6 +2023,7 @@ def __init__(self, template, master, startHidden:bool=False): self.snarkLogo = Label(master, image=self.snarkLogoPNG) self.githubLogo = HyperlinkImg(master, image=self.gitLogoPNG, lID=0) self.gameBLogo = HyperlinkImg(master, image=self.gbLogoPNG, lID=1) + self.getDistro = Button(master, text='Get Distro Information', command=self.grabOSRel, cursor="hand2") # Text vnum = open('version.txt', "r") self.ver = vnum.read().replace("(OS)", sys.platform) @@ -1990,6 +2035,7 @@ def __init__(self, template, master, startHidden:bool=False): # Tooltips self.githubTT = ToolTip(self.githubLogo.link, "Source Code and Releases on Github", background=thme["tt"], foreground=thme["txt"]) self.gameBtt = ToolTip(self.gameBLogo.link, "Official Download page on Gamebanana", background=thme["tt"], foreground=thme["txt"]) + self.getDistroTT = ToolTip(self.getDistro, "Clicking this will copy the information for your Linux distro to your clipboard, make sure xclip is installed or this won't work.", background=thme["tt"], foreground=thme["txt"]) if not startHidden: self.show() @@ -2034,6 +2080,7 @@ def changeTheme(self, newTheme): self.applyTheme(self.master) self.githubTT.changeTheme(newTheme["tt"], newTheme["txt"]) self.gameBtt.changeTheme(newTheme["tt"], newTheme["txt"]) + self.getDistroTT.changeTheme(newTheme["tt"], newTheme["txt"]) def updateOpt(self, key, value): if not key.startswith("gsMV"): @@ -2041,6 +2088,10 @@ def updateOpt(self, key, value): else: self.options["gsMV"][key.replace("gsMV", "")] = value + def grabOSRel(self): + pyperclip.copy(distroInfo()) + print("The information for your Linux distro has been copied to your clipboard!") + def hide(self): self.hidden = True for w in self.master.winfo_children(): @@ -2052,6 +2103,8 @@ def show(self): self.gameBLogo.grid(column=1,row=1, padx=(50,0)) self.setupLabel.grid(column=1, row=2) self.nameLabel.grid(column=1, row=3) + if sys.platform == 'linux': + self.getDistro.grid(column=1, row=4, pady=(30,0)) class OptionsMenu(): def __init__(self, template, master, thmecallback, updFunc, startHidden:bool=False): @@ -2064,9 +2117,9 @@ def __init__(self, template, master, thmecallback, updFunc, startHidden:bool=Fal self.updFunc = updFunc # Grabbing options self.options = template.options - self.curJSONVer = 5 + self.curJSONVer = 6 # Checking if options JSON is from a previous version... - if not self.options["version"] == self.curJSONVer: + if not self.options["version"] >= self.curJSONVer: self.upgradeJSON() # Pages self.pageButtons = Frame(master, borderwidth=2, bg=thme["bg"]) @@ -2164,10 +2217,14 @@ def __init__(self, template, master, thmecallback, updFunc, startHidden:bool=Fal self.spLabel = Label(master, text="Save paths: ") self.savePathsB = BooleanVar(master, value=self.options["save_paths"]) self.savePathsCB = Checkbutton(master, command=self.chSP, variable=self.savePathsB) - # Checking if anything is exceeding the width of the "safe zone" - """self.show() - self.checkWidth() - self.hide()""" + self.distroLabel = Label(master, text="Distro Resize: ") + self.restartReq1 = Label(master, text="(RESTART REQUIRED)") + self.distros = ["KDE", "Cinnamon"] + if sys.platform == 'linux': + self.distroSel = ttk.Combobox(master, values=self.distros) + self.distroSel.set(self.options["linuxFix"]) + self.distroSel.bind("<>", self.setLF) + self.distroTT = ToolTip(self.distroSel, "This Linux-only selector will tell Snark which distro variant you use, it will resize itself so everything looks correct on your system when you select the option. If there's still windowing bugs, please create an issue on Github or Gamebanana with your distro information copied from the terminal or the about menu.", background=thme["tt"], foreground=thme["txt"]) # Tooltips self.themeTT = ToolTip(self.themeCBox, "Changes the program's theme, the built-in themes are: Freeman, Shephard, Calhoun and Cross.", background=thme["tt"], foreground=thme["txt"]) self.startFolderTT = ToolTip(self.startFent, "Sets the directory that the built-in file explorer will start in, the default is the documents folder.", background=thme["tt"], foreground=thme["txt"]) @@ -2197,10 +2254,19 @@ def upgradeJSON(self): startingFolder = self.options.get("startFolder", "~/Documents") theme = self.options.get("theme", "Freeman") goldSRCModelViewer = self.options.get("gsMV", {"selectedMV": 0, "csPath": ""}) + linuxWinFix = self.options.get("linuxFix", "KDE") + # Detecting which version of Linux you're using for the Windowing fixes + cinnamonDesktops = ['linuxmint'] + try: + cinnamonDesktops.index(distroInfo()["ID"]) + linuxWinFix = 'Cinnamon' + except: + if distroInfo().get("VARIANT_ID", 'kde').lower() == "cinnamon": + linuxWinFix = 'Cinnamon' if self.options["version"] < 5: savePaths = True upgradePaths = True - # Upgrade from version 1 to 4 + # Upgrade from version 1 to 6 newOptions = { "defComp": defaultComp, "defGame": defaultGame, @@ -2210,6 +2276,7 @@ def upgradeJSON(self): "startFolder": startingFolder, "theme": theme, "gsMV": goldSRCModelViewer, + "linuxFix": linuxWinFix, "version": self.curJSONVer } if upgradePaths: @@ -2262,6 +2329,10 @@ def genPg(self): self.presetSel.grid(column=2, row=6, sticky="w") self.spLabel.grid(column=1, row=7, sticky="w") self.savePathsCB.grid(column=2, row=7, sticky="w") + if sys.platform == 'linux': + self.distroLabel.grid(column=1, row=8, sticky="w") + self.distroSel.grid(column=2, row=8, sticky="w") + self.restartReq1.grid(column=3, row=8, sticky="w") self.hlmvLabel.grid_remove() self.hlmvCBox.grid_remove() self.mvPathLabel.grid_remove() @@ -2285,6 +2356,10 @@ def hlmvPg(self): self.presetSel.grid_remove() self.spLabel.grid_remove() self.savePathsCB.grid_remove() + if sys.platform == 'linux': + self.distroLabel.grid_remove() + self.distroSel.grid_remove() + self.restartReq1.grid_remove() self.hlmvLabel.grid(column=1, row=1, sticky="w") self.hlmvCBox.grid(column=2, row=1, sticky="w") self.mvPathLabel.grid(column=1, row=2, sticky="w") @@ -2334,6 +2409,7 @@ def changeTheme(self, newTheme): self.hlmvTT.changeTheme(newTheme["tt"], newTheme["txt"]) self.setMVPtt.changeTheme(newTheme["tt"], newTheme["txt"]) self.savePathsTT.changeTheme(newTheme["tt"], newTheme["txt"]) + self.distroTT.changeTheme(newTheme["tt"], newTheme["txt"]) def chSF(self): path = askdirectory(title="Set starting directory for this file explorer") @@ -2413,6 +2489,11 @@ def chSP(self): self.save_options() self.updFunc("save_paths", self.savePathsB.get()) + def setLF(self, e=False): + opt = self.distroSel.get() + self.options["linuxFix"] = opt + self.save_options() + self.updFunc("linuxFix", opt) def save_options(self): newjson = json.dumps(self.options, sort_keys=True, indent=5) @@ -2451,6 +2532,10 @@ def show(self): self.presetSel.grid(column=2, row=6, sticky="w") self.spLabel.grid(column=1, row=7, sticky="w") self.savePathsCB.grid(column=2, row=7, sticky="w") + if sys.platform == 'linux': + self.distroLabel.grid(column=1, row=8, sticky="w") + self.distroSel.grid(column=2, row=8, sticky="w") + self.restartReq1.grid(column=3, row=8, sticky="w") elif self.curPage == 1: self.hlmvLabel.grid(column=1, row=1, sticky="w") self.hlmvCBox.grid(column=2, row=1, sticky="w") diff --git a/requirements.txt b/requirements.txt index 70eb94f..03bdd6a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -jsonc-parser -scikit-build -tksvg +jsonc-with-comments certifi +am-i-connected +pyperclip diff --git a/save/compilers.jsonc b/save/compilers.jsonc index 4046718..350a629 100644 --- a/save/compilers.jsonc +++ b/save/compilers.jsonc @@ -35,13 +35,39 @@ "path": { "default": { "win32": [ - "C:/Program Files (x86)/Steam/steamapps/common/Sven Co-op SDK/modelling/studiomdl.exe", - "C:/Program Files/Steam/steamapps/common/Sven Co-op SDK/modelling/studiomdl.exe" + "third_party/StudioMDL/SC.exe" ], "linux": [ - "~/.steam/steam/steamapps/common/Sven Co-op SDK/modelling/studiomdl.exe", - "~/.var/app/com.valvesoftware.Steam/.local/share/Steam/steamapps/common/Sven Co-op SDK/modelling/studiomdl.exe", - "~/snap/steam/common/Steam/steamapps/common/Sven Co-op SDK/modelling/studiomdl.exe" + "third_party/StudioMDL/SC.exe" + ], + "darwin": [ + "third_party/StudioMDL/SC.exe" + ] + } + }, + "type": "Svengine", + "capabilities": { + "fullbright": true, + "flatshade": true, + "chromeTRM": true, + "1024px": true, + "unlockedChrome": true, + "noUVshift": true, + "cliptotextures": false + }, + "disableEdit": true + }, + "Sven2018": { + "path": { + "default": { + "win32": [ + "third_party/StudioMDL/SC2018.exe" + ], + "linux": [ + "third_party/StudioMDL/SC2018.exe" + ], + "darwin": [ + "third_party/StudioMDL/SC2018.exe" ] } }, diff --git a/save/compilers.txt b/save/compilers.txt index 27a0c2f..7904fa7 100644 --- a/save/compilers.txt +++ b/save/compilers.txt @@ -1,2 +1,3 @@ GoldSRC Svengine +Sven2018 diff --git a/save/options.json b/save/options.json index 901ced6..56656c4 100755 --- a/save/options.json +++ b/save/options.json @@ -7,8 +7,9 @@ "csPath": "", "selectedMV": 0 }, + "linuxFix": "KDE", "save_paths": true, "startFolder": "~/Documents", "theme": "Freeman", - "version": 5 + "version": 6 } \ No newline at end of file diff --git a/save/paths.json b/save/paths.json index 44c9cd8..4e4e8c7 100755 --- a/save/paths.json +++ b/save/paths.json @@ -1,6 +1,7 @@ { "Other": { "GoldSRC": "", + "Sven2018": "", "Svengine": "" }, "Snark": { diff --git a/third_party/StudioMDL/SC.exe b/third_party/StudioMDL/SC.exe new file mode 100755 index 0000000..88ad9f1 Binary files /dev/null and b/third_party/StudioMDL/SC.exe differ diff --git a/third_party/StudioMDL/SC2018.exe b/third_party/StudioMDL/SC2018.exe new file mode 100644 index 0000000..4532c78 Binary files /dev/null and b/third_party/StudioMDL/SC2018.exe differ diff --git a/version.txt b/version.txt index fed2bb8..3b38478 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v0.3.1-(OS)-alpha +v0.3.2-(OS)-alpha