modified: clang
new file: icons/obj.png deleted: icons/object.png modified: langsys/lang/de_DE.LAN modified: langsys/lang/en_EN.LAN modified: main.pymain
parent
4bb3864d20
commit
2d17887635
Binary file not shown.
After Width: | Height: | Size: 216 B |
BIN
icons/object.png
BIN
icons/object.png
Binary file not shown.
Before Width: | Height: | Size: 192 B |
|
@ -7,4 +7,7 @@
|
|||
"add": "Erstellen",
|
||||
"obj": "Objekt",
|
||||
"script": "Skript",
|
||||
"rename": "Umbenennen",
|
||||
"delete": "Loeschen",
|
||||
"NN": "Neuer Name:",
|
||||
}
|
|
@ -7,4 +7,7 @@
|
|||
"add": "Create",
|
||||
"obj": "Object",
|
||||
"script": "Script",
|
||||
"rename": "Rename",
|
||||
"delete": "Delete",
|
||||
"NN": "New name:",
|
||||
}
|
57
main.py
57
main.py
|
@ -9,10 +9,14 @@ import time
|
|||
import subprocess
|
||||
import sys
|
||||
import hashengine
|
||||
import os
|
||||
import random
|
||||
import string
|
||||
import easygui
|
||||
|
||||
global LH
|
||||
global gamedata
|
||||
gamedata = []
|
||||
gamedata = {}
|
||||
LH = langsys.langhandler()
|
||||
lang = open("clang", 'r')
|
||||
lang = lang.read()
|
||||
|
@ -65,18 +69,59 @@ def selectlang(new):
|
|||
subprocess.Popen([sys.executable, __file__])
|
||||
|
||||
def add(objtype):
|
||||
obj = dir(types)[objtype]()
|
||||
temp = {"id": objtype, "args": dir(obj)}
|
||||
gamedata.append(temp())
|
||||
global objtree
|
||||
obj = getattr(types, objtype)()
|
||||
temp = {"id": objtype, "args": dir(obj), "name": LH.string(objtype)}
|
||||
id = ""
|
||||
chars = list(string.ascii_letters)
|
||||
for i in range(255):
|
||||
id = id + random.choice(chars)
|
||||
objtree.insert("", tk.END, text=LH.string(objtype), image=icons[objtype], iid=id)
|
||||
gamedata[id] = temp
|
||||
|
||||
def renameobj():
|
||||
target = objtree.focus()
|
||||
if target == "": return
|
||||
new = easygui.enterbox(LH.string("NN"), LH.string("rename"))
|
||||
if new:
|
||||
objtree.item(target, text=new)
|
||||
gamedata[target]["name"] = new
|
||||
|
||||
def delobj():
|
||||
target = objtree.focus()
|
||||
if target == "": return
|
||||
objtree.delete(target)
|
||||
gamedata.pop(target)
|
||||
|
||||
def rpopup(event):
|
||||
try:
|
||||
rmenu.tk_popup(event.x_root, event.y_root)
|
||||
finally:
|
||||
rmenu.grab_release()
|
||||
|
||||
def GUIinit():
|
||||
global container
|
||||
global objtree
|
||||
global rmenu
|
||||
container = tk.Tk()
|
||||
|
||||
global icons
|
||||
icons = {}
|
||||
|
||||
for i in os.listdir("icons"):
|
||||
icons[i.split(".")[0]] = tk.PhotoImage(file=f"icons/{i}")
|
||||
|
||||
#tree init
|
||||
objtree = tkk.Treeview(container)
|
||||
objtree.grid()
|
||||
|
||||
#right click menu
|
||||
rmenu = tk.Menu(container, tearoff=0)
|
||||
rmenu.add_command(label=LH.string("rename"), command=renameobj)
|
||||
rmenu.add_command(label=LH.string("delete"), command=delobj)
|
||||
|
||||
objtree.bind("<Button-3>", rpopup)
|
||||
|
||||
#menu init
|
||||
menu = tk.Menu(container)
|
||||
container.config(menu=menu)
|
||||
|
@ -89,7 +134,8 @@ def GUIinit():
|
|||
|
||||
addmenu = tk.Menu(menu)
|
||||
menu.add_cascade(label=LH.string("add"), menu=addmenu)
|
||||
filemenu.add_command(label=LH.string("obj"), command=lambda: add("obj"))
|
||||
addmenu.add_command(label=LH.string("obj"), command=lambda: add("obj"))
|
||||
addmenu.add_command(label=LH.string("script"), command=lambda: add("script"))
|
||||
|
||||
langmenu = tk.Menu(menu)
|
||||
menu.add_cascade(label=LH.string("langs"), menu=langmenu)
|
||||
|
@ -100,5 +146,6 @@ def GUIinit():
|
|||
|
||||
global types
|
||||
types = hashengine.enum({"obj": hashengine.obj, "script": script})
|
||||
icon = hashengine.enum({"obj": "icons/object.png", "script": "icons/script.pngg"})
|
||||
|
||||
GUIinit()
|
Loading…
Reference in New Issue