2025-02-21 16:23:52 -08:00
|
|
|
from CTkMessagebox import CTkMessagebox
|
|
|
|
import threading
|
|
|
|
from .savetools import loadFile
|
2025-03-07 20:38:10 -08:00
|
|
|
from pathlib import Path
|
|
|
|
from .comunic import getIconDownload
|
|
|
|
import os
|
|
|
|
import signal
|
|
|
|
import json
|
|
|
|
from PIL import Image
|
|
|
|
|
2025-02-21 16:23:52 -08:00
|
|
|
|
|
|
|
try:
|
|
|
|
from os import startfile
|
|
|
|
except:
|
|
|
|
from os import system
|
|
|
|
from sys import platform
|
2025-03-07 20:38:10 -08:00
|
|
|
def killPopen(popen): #jesus
|
|
|
|
os.kill(os.getpgid(popen.pid), signal.SIGTERM)
|
|
|
|
|
|
|
|
def folderExist(path):
|
|
|
|
Path(path).mkdir(parents=True, exist_ok=True)
|
2025-02-21 16:23:52 -08:00
|
|
|
|
|
|
|
def check():
|
|
|
|
print("Save Good")
|
|
|
|
|
|
|
|
def removeChildren(frame):
|
|
|
|
for element in frame.winfo_children():
|
|
|
|
element.destroy()
|
|
|
|
|
|
|
|
def bgThread(func, args):
|
|
|
|
th = threading.Thread(target=func, args=args)
|
|
|
|
th.start()
|
|
|
|
|
|
|
|
def openLocation(self, location):
|
|
|
|
if platform == "linux":
|
|
|
|
system('xdg-open "%s"' % location)
|
|
|
|
elif platform == "windows":
|
|
|
|
startfile(foldername)
|
|
|
|
|
2025-03-07 20:38:10 -08:00
|
|
|
def messageBox(self, title, message, type): #type will be implemented at a later point when required. for now, just fill it in irregardless.
|
2025-02-21 16:23:52 -08:00
|
|
|
CTkMessagebox(title=title, message=message)
|
|
|
|
|
|
|
|
def getLogMax(self, save):
|
|
|
|
return loadFile(self, save)['maxlogsize'] #not entirely sure why I made this a seperate function but eh
|
|
|
|
|
|
|
|
def isNumber(data):
|
|
|
|
if data == '':
|
|
|
|
return True
|
|
|
|
try:
|
|
|
|
rv = int(data)
|
|
|
|
except ValueError:
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
2025-03-07 20:38:10 -08:00
|
|
|
def formatExportWeapons(self, file1):
|
|
|
|
log = open("log.txt", "a")
|
|
|
|
testfile = open("test1.json", 'w')
|
|
|
|
if open(file1):
|
|
|
|
print("opened")
|
|
|
|
with open(file1, 'r') as file:
|
|
|
|
data=json.load(file)["ExportWeapons"]
|
|
|
|
redund = []
|
|
|
|
for diction in range(len(data)):
|
|
|
|
|
|
|
|
for key in list(data[diction].keys()):
|
|
|
|
if key not in ["name", "slot", "uniqueName"]:
|
|
|
|
del data[diction][key]
|
|
|
|
print("deleted " + str(data[diction]["name"] + ' ' + key))
|
|
|
|
if 'slot' not in data[diction].keys():
|
|
|
|
redund.append(diction)
|
|
|
|
|
|
|
|
i=0
|
|
|
|
for diction in redund:
|
|
|
|
|
|
|
|
i+=1
|
|
|
|
print("Removed Unneeded Modular " + str(data[diction-i]["name"]), file=log)
|
|
|
|
del data[diction-i]
|
|
|
|
|
|
|
|
def sortFunc(e):
|
|
|
|
return e["name"]
|
|
|
|
|
|
|
|
data.sort(key=sortFunc)
|
|
|
|
|
|
|
|
json.dump(data, testfile, indent=2)
|
|
|
|
return data
|
|
|
|
|
|
|
|
def formatExportPowersuits(self, file1):
|
|
|
|
log = open("log.txt", "a")
|
|
|
|
testfile = open("test2.json", 'w')
|
|
|
|
if open(file1):
|
|
|
|
print("opened")
|
|
|
|
with open(file1, 'r') as file:
|
|
|
|
data=json.load(file)["ExportWarframes"]
|
|
|
|
redund = []
|
|
|
|
for diction in range(len(data)):
|
|
|
|
|
|
|
|
for key in list(data[diction].keys()):
|
|
|
|
if key not in ["name", "productCategory", "uniqueName"]:
|
|
|
|
del data[diction][key]
|
|
|
|
print("deleted " + str(data[diction]["name"] + ' ' + key))
|
|
|
|
|
|
|
|
|
|
|
|
def sortFunc(e):
|
|
|
|
return e["name"]
|
|
|
|
|
|
|
|
data.sort(key=sortFunc)
|
|
|
|
|
|
|
|
json.dump(data, testfile, indent=2)
|
|
|
|
return data
|
|
|
|
|
|
|
|
def formatExportPlus(self, file1):
|
|
|
|
with open(file1, 'r') as file:
|
|
|
|
data=json.load(file)
|
|
|
|
write = False
|
|
|
|
for item in data.keys():
|
|
|
|
print(data[item])
|
|
|
|
if type(data[item]) is dict:
|
|
|
|
icon = data[item]["icon"]
|
|
|
|
print(data[item])
|
|
|
|
data[item] = icon
|
|
|
|
write=True
|
|
|
|
|
|
|
|
if write == True:
|
|
|
|
with open(file1, 'w') as file:
|
|
|
|
json.dump(data, file, indent=2)
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
def getIcon(self, path, savePath):
|
|
|
|
try:
|
|
|
|
image = Image.open("./cache/items/icons" + savePath)
|
|
|
|
return image
|
|
|
|
except:
|
|
|
|
getIconDownload(self, path, savePath)
|
|
|
|
return Image.open("./cache/items/icons" + savePath)
|
2025-02-21 16:23:52 -08:00
|
|
|
#Old Helper options, left here for future reference. Shitty code, but it works, and it may be useful in the future
|
|
|
|
|
|
|
|
# def getlogmax():
|
|
|
|
# file = 'sngconfig.json'
|
|
|
|
# if Path(file).is_file():
|
|
|
|
# with open(file) as f:
|
|
|
|
# d = json.load(f)
|
|
|
|
#
|
|
|
|
# else:
|
|
|
|
# return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# def check4sn(configfile):
|
|
|
|
# file = helpers.getsnpath(configfile) + "package.json"
|
2025-03-07 20:38:10 -08:00
|
|
|
|
2025-02-21 16:23:52 -08:00
|
|
|
# if Path(file).is_file():
|
|
|
|
# with open(file) as f:
|
|
|
|
# d = json.load(f)
|
|
|
|
# if (d["name"] == "wf-emulator"):
|
|
|
|
# return True
|
|
|
|
# else:
|
|
|
|
# return False#
|
|
|
|
|
|
|
|
|