diff --git a/GUIwrap.py b/GUIwrap.py new file mode 100644 index 0000000..9cbf102 --- /dev/null +++ b/GUIwrap.py @@ -0,0 +1,57 @@ +# handles GUI +from langsys import langhandler +import mtTkinter as tk +from tkinter import ttk as tkk +import multiprocessing +import os + +global LH +LH = langhandler() +LH.setlang("en_EN") + +# define functions +def do_popup(event): + try: + rm.tk_popup(event.x_root, event.y_root) + finally: + rm.grab_release() + +def delobj(): + raise NotImplementedError() + +container = tk.Tk() + +# init icons +global icons +icons = {} + +for i in os.listdir("icons"): + icons[i.split(".")[0]] = tk.PhotoImage(file=f"icons/{i}") + +global canvas +canvas = tk.Canvas(container) +canvas.grid(row=0, column=0) + +global objtree +objtree = tkk.Treeview(container, columns=("-")) +objtree.heading("#0", text=LH.string("game")) +objtree.grid(row=1, column=0) +objectsid = objtree.insert("", "end", text=LH.string("objs"), image=icons["game"]) +scriptssid = objtree.insert("", "end", text=LH.string("scriptserv"), image=icons["scriptserv"]) +soundssid = objtree.insert("", "end", text=LH.string("soundserv"), image=icons["soundserv"]) + +global rm +rm = tk.Menu(container, tearoff=0) +rm.add_command(label=LH.string("del"), command=delobj) +container.bind("", do_popup) + +global menu +menu = tk.Menu(container) +container.config(menu=menu) + +global filemenu +filemenu = tk.Menu(container) +filemenu.add_command(label=LH.string("exit"), command=container.quit) +menu.add_cascade(menu=filemenu, label=LH.string("file")) + +container.mainloop() \ No newline at end of file diff --git a/autoexec b/autoexec index e69de29..6af79fe 100644 --- a/autoexec +++ b/autoexec @@ -0,0 +1,2 @@ +import threading +threading.Thread(target=lambda: loadfile("GUIwrap.py")).start() \ No newline at end of file diff --git a/hashengine.py b/hashengine.py index 737ea24..1285d78 100644 --- a/hashengine.py +++ b/hashengine.py @@ -41,6 +41,21 @@ class obj: self._parent = value self._parent.children.append(self) +class folder: + def __init__(self): + self._parent = NULL() + self.children = [] + + @property + def parent(self): + return self._parent + + @parent.setter + def parent(self, value): + self._parent.children.remove(self) + self._parent = value + self._parent.children.append(self) + class game: def __init__(self, canvas: tk.Canvas, pixelsize=3): self._canvas = canvas diff --git a/icons/ar-down.png b/icons/ar-down.png new file mode 100644 index 0000000..35c13ed Binary files /dev/null and b/icons/ar-down.png differ diff --git a/icons/ar-left.png b/icons/ar-left.png new file mode 100644 index 0000000..08cb8bd Binary files /dev/null and b/icons/ar-left.png differ diff --git a/icons/ar-right.png b/icons/ar-right.png new file mode 100644 index 0000000..824617e Binary files /dev/null and b/icons/ar-right.png differ diff --git a/icons/ar-up.png b/icons/ar-up.png new file mode 100644 index 0000000..e05f2f9 Binary files /dev/null and b/icons/ar-up.png differ diff --git a/icons/build.png b/icons/build.png new file mode 100644 index 0000000..4bffc31 Binary files /dev/null and b/icons/build.png differ diff --git a/icons/game.png b/icons/game.png new file mode 100644 index 0000000..9f27736 Binary files /dev/null and b/icons/game.png differ diff --git a/icons/obj.png b/icons/obj.png new file mode 100644 index 0000000..3bfb6d2 Binary files /dev/null and b/icons/obj.png differ diff --git a/icons/script.png b/icons/script.png new file mode 100644 index 0000000..85c26f5 Binary files /dev/null and b/icons/script.png differ diff --git a/icons/scriptserv.png b/icons/scriptserv.png new file mode 100644 index 0000000..37c582d Binary files /dev/null and b/icons/scriptserv.png differ diff --git a/icons/sound.png b/icons/sound.png new file mode 100644 index 0000000..0696715 Binary files /dev/null and b/icons/sound.png differ diff --git a/icons/soundserv.png b/icons/soundserv.png new file mode 100644 index 0000000..ff1ace2 Binary files /dev/null and b/icons/soundserv.png differ diff --git a/icons/stop-test.png b/icons/stop-test.png new file mode 100644 index 0000000..2a55947 Binary files /dev/null and b/icons/stop-test.png differ diff --git a/icons/test.png b/icons/test.png new file mode 100644 index 0000000..75ca82f Binary files /dev/null and b/icons/test.png differ diff --git a/langsys/__init__.py b/langsys/__init__.py new file mode 100644 index 0000000..262be8b --- /dev/null +++ b/langsys/__init__.py @@ -0,0 +1,30 @@ +import os +import ast +class langhandler: + def __init__(self, LANGNOTFOUND="LANGNULL", TEXTNOTFOUND="NULL"): + self._langnf = LANGNOTFOUND + self._textnf = TEXTNOTFOUND + self._langs = {} + for i in os.listdir(os.path.dirname(__file__)+"/lang"): + if i.split(".")[1] == "LAN": + file = open(os.path.dirname(__file__)+"/lang/"+i, 'r') + file = file.read() + file = ast.literal_eval(file) + self._langs[i.split(".")[0]] = file + if len(self._langs) <= 0: + print("NO languages found!") + self._langs["NULL"] = { + "NULL": "NULL", + } + self._lang = list(self._langs.keys())[0] + + def setlang(self, new): + self._lang = new + + def string(self, x): + if not self._lang in self._langs: return self._langnf + if not x in self._langs[self._lang]: return x + return self._langs[self._lang][x] + + def getlangs(self): + return list(self._langs.keys()) \ No newline at end of file diff --git a/langsys/lang/NULL.LAN b/langsys/lang/NULL.LAN new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/langsys/lang/NULL.LAN @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/langsys/lang/en_EN.LAN b/langsys/lang/en_EN.LAN new file mode 100644 index 0000000..421b763 --- /dev/null +++ b/langsys/lang/en_EN.LAN @@ -0,0 +1,13 @@ +{ + "game": "Game", + "objs": "Objects", + "scriptserv": "Scripts", + "soundserv": "Sounds", + "folder": "Folder", + "object": "Object", + "script": "Script", + "sound": "Sound", + "del": "Delete", + "file": "File", + "exit": "Exit", +} \ No newline at end of file