From 13f03185ca5c826fe903ed856a220ff64545cb9d Mon Sep 17 00:00:00 2001 From: justuswolff Date: Sun, 7 Jul 2024 17:32:02 +0200 Subject: [PATCH] started GUI development --- GUIwrap.py | 57 +++++++++++++++++++++++++++++++++++++++++ autoexec | 2 ++ hashengine.py | 15 +++++++++++ icons/ar-down.png | Bin 0 -> 194 bytes icons/ar-left.png | Bin 0 -> 185 bytes icons/ar-right.png | Bin 0 -> 186 bytes icons/ar-up.png | Bin 0 -> 177 bytes icons/build.png | Bin 0 -> 180 bytes icons/game.png | Bin 0 -> 279 bytes icons/obj.png | Bin 0 -> 216 bytes icons/script.png | Bin 0 -> 248 bytes icons/scriptserv.png | Bin 0 -> 242 bytes icons/sound.png | Bin 0 -> 209 bytes icons/soundserv.png | Bin 0 -> 207 bytes icons/stop-test.png | Bin 0 -> 200 bytes icons/test.png | Bin 0 -> 212 bytes langsys/__init__.py | 30 ++++++++++++++++++++++ langsys/lang/NULL.LAN | 1 + langsys/lang/en_EN.LAN | 13 ++++++++++ 19 files changed, 118 insertions(+) create mode 100644 GUIwrap.py create mode 100644 icons/ar-down.png create mode 100644 icons/ar-left.png create mode 100644 icons/ar-right.png create mode 100644 icons/ar-up.png create mode 100644 icons/build.png create mode 100644 icons/game.png create mode 100644 icons/obj.png create mode 100644 icons/script.png create mode 100644 icons/scriptserv.png create mode 100644 icons/sound.png create mode 100644 icons/soundserv.png create mode 100644 icons/stop-test.png create mode 100644 icons/test.png create mode 100644 langsys/__init__.py create mode 100644 langsys/lang/NULL.LAN create mode 100644 langsys/lang/en_EN.LAN 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 0000000000000000000000000000000000000000..35c13eddfd8d278bfee51bfbe57407d91ef28698 GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!V7RA?V~B-+@}K|z?V0%woH)Uu@=+t9=~7B# z;8~R>5I(qAa>itZnVh@{qVCsuPBvt`QiwUTr_!lvI6;>1s;*b3=DjSL74G){)!Z!pr5CUV~B-+@}K|z?U{EraC%KPb92+^ z=4evGbMm&W!3O=j?P^>bP0l+XkKlZ-i^ literal 0 HcmV?d00001 diff --git a/icons/ar-right.png b/icons/ar-right.png new file mode 100644 index 0000000000000000000000000000000000000000..824617ea3f4e20ced7516ff755499360edc5ee6d GIT binary patch literal 186 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!pueY!V~B6x%`CW6}$UY=i7D4ms~abWApf2qG4{hoPzn~#9Mm* crnd;p>|>FWp7&J74QMojr>mdKI;Vst04*6ir~m)} literal 0 HcmV?d00001 diff --git a/icons/ar-up.png b/icons/ar-up.png new file mode 100644 index 0000000000000000000000000000000000000000..e05f2f9e31505d644d774e8e6204d2d3c5839116 GIT binary patch literal 177 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!pqrQJbagM@ z!^vHGvN^g^w!+}8-)yeHgW?*N5iTlQUt6hIek#A4bE3XYY>%dUu-ZTE?wmLt0ZonN Sk-vZ@GI+ZBxvX!lvI6;>1s;*b3=DjSL74G){)!Z!pr@ycV~B-+@(+K;1Iu^H@hp(ZVOTY@(S_kE z>(UL39cKghv>IMD1>InXHA!Yy|LMSCE^)Po&CN8q>EKGqNroWh>(Bl;`2Rn{oHv(S Uj9hr001ajEboFyt=akR{04a1gl>h($ literal 0 HcmV?d00001 diff --git a/icons/game.png b/icons/game.png new file mode 100644 index 0000000000000000000000000000000000000000..9f2773607d0db43a518ce12502aab478140e2de6 GIT binary patch literal 279 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!;2KXC#}Etusgo{>HW>)8tUOw^<`UnUgK2M+ zbZ+_pt?@LdWw>|y#t4Qws z@;)Y?8X50CG2WxkCzW*>Mwtsd+p+rZ(~p{ywCaz@c#6s|SLj>P)j7Gh^S;u`q@)Dz zo@>3z&sx9Fohr0{|38&*Rf)p=kxNc@9ZZtnD%gD6jx(5N!?ykn&n?wLl%rg{ZZb~m W;^zBM7oQ7sH-o3EpUXO@geCx~RcZ$S literal 0 HcmV?d00001 diff --git a/icons/obj.png b/icons/obj.png new file mode 100644 index 0000000000000000000000000000000000000000..3bfb6d264252b36394f711db4c8e5d981bf05ac8 GIT binary patch literal 216 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1G~mUKs7M+SzC z{oH>NS%G}c0*}aI1_r)EAj~ML;ne^X%=L6}46*QkJNY74g8_%@R(bLLdx~^+u4Rq( z^0(HX{E+Xv(8oHb&YZ7%4xTBMV*W1AnV#CQa@SPfTRZDmzwb3tn>|r-N4(IsP5N8) zSB4+EVb<+2(>)-x{`TKfg3}Dn2_5qk|Mywn{lh6qBc(;m@6+Abg08vm09wr8>FVdQ I&MBb@0G_8wR{#J2 literal 0 HcmV?d00001 diff --git a/icons/script.png b/icons/script.png new file mode 100644 index 0000000000000000000000000000000000000000..85c26f52bd7ea5aa310421297aa489a6ef454077 GIT binary patch literal 248 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!V6Uf(V~B-+@}K|z?U{En#D1RKEgB$Zrm*-v zW2z%VfU!|U%|aQiM#hGq09ONtiD!KRq(o0hl`siTVSeTmnZfXg!J@%J+T)O9La2g+ zc)BoW!7s^~j!lvI6;>1s;*b3=DjSL74G){)!Z!V7sS_V~BpdYDwib)ku!3Uyg20 zEuF@;fonsFio(&`=Ov6zC1y`FE;#%|f5X*@0qSY#lU^Qpnxc5QNm|XAYjyF8n_g!s l4;Nb)|Nr0q{^?)7*PHk3zIWorM4*!xJYD@<);T3K0RWx{Tvh-8 literal 0 HcmV?d00001 diff --git a/icons/sound.png b/icons/sound.png new file mode 100644 index 0000000000000000000000000000000000000000..0696715bc35e20a9f56a325c284f1e3113f1ac0a GIT binary patch literal 209 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!V4A0kV~B$bb9Ie&hb$~>L{ z!lvI6;>1s;*b3=DjSL74G){)!Z!V2Y=UV~B@U(_rZ;?g$go1O^)<=@N>n(?>jeG;VcN=mbZOKvr!@JE)6DK(T=e!h&^`uFS3j3^P60cu literal 0 HcmV?d00001 diff --git a/icons/stop-test.png b/icons/stop-test.png new file mode 100644 index 0000000000000000000000000000000000000000..2a55947b8d36c6c97f221f53e500391ed8eb398f GIT binary patch literal 200 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1SFYWcSQjy#^NA%Cx&(BWL^R}Ea{HEjtmSN z`?>!lvI6;>1s;*b3=DjSL74G){)!Z!V63N$V~B!lvI6;>1s;*b3=DjSL74G){)!Z!V5X;wV~BKG%(6`Utncn=xfoOF^i zQvUD#cEu|@QdZec^EsTLvw8NVQ**2|jfy#@iVIdUy!Q3jb)|ooI?z%EPgg&ebxsLQ E08!*fRsaA1 literal 0 HcmV?d00001 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