plugin system update
parent
c30eeba0f2
commit
18b8ee5554
26
main.py
26
main.py
|
@ -73,8 +73,8 @@ global cooldown
|
||||||
global version
|
global version
|
||||||
global plugindir
|
global plugindir
|
||||||
version = "HE2.2-Hashengine V2.2"
|
version = "HE2.2-Hashengine V2.2"
|
||||||
#plugindir = "plugins"
|
plugindir = "plugins"
|
||||||
plugindir = "testplugins"
|
#plugindir = "testplugins"
|
||||||
cooldown = False
|
cooldown = False
|
||||||
gamedata = {}
|
gamedata = {}
|
||||||
|
|
||||||
|
@ -689,12 +689,13 @@ def testing():
|
||||||
global running
|
global running
|
||||||
global clog
|
global clog
|
||||||
global APIPLUG
|
global APIPLUG
|
||||||
|
global RUNPLUG
|
||||||
try:
|
try:
|
||||||
if running == True: return
|
if running == True: return
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
running = True
|
running = True
|
||||||
testproc = multiprocessing.Process(target=execgame, args=(prepspecified(gamedata), clog.get(), APIPLUG))
|
testproc = multiprocessing.Process(target=execgame, args=(prepspecified(gamedata), clog.get(), APIPLUG, RUNPLUG))
|
||||||
testproc.start()
|
testproc.start()
|
||||||
|
|
||||||
def APIGEN():
|
def APIGEN():
|
||||||
|
@ -778,6 +779,10 @@ def run():
|
||||||
#gameloopsc = script()
|
#gameloopsc = script()
|
||||||
#gameloopsc.code = gamescript
|
#gameloopsc.code = gamescript
|
||||||
#maingame.startscript(lambda: gameloopsc.execute(APIGEN(), log))
|
#maingame.startscript(lambda: gameloopsc.execute(APIGEN(), log))
|
||||||
|
log("executing plugins")
|
||||||
|
for i in RUNPLUG:
|
||||||
|
exec(i, globals())
|
||||||
|
log("done")
|
||||||
log("game test started!!!")
|
log("game test started!!!")
|
||||||
log("---------------------")
|
log("---------------------")
|
||||||
for i in scripts:
|
for i in scripts:
|
||||||
|
@ -831,10 +836,12 @@ import ast
|
||||||
file = open("game.HEGF", 'r')
|
file = open("game.HEGF", 'r')
|
||||||
file = file.read()
|
file = file.read()
|
||||||
file = ast.literal_eval(file)
|
file = ast.literal_eval(file)
|
||||||
player.execgame(file, fAPIPLUG=player.loadplugins(False))
|
temp = fAPIPLUG=player.loadplugins(False)
|
||||||
|
player.execgame(file, fAPIPLUG=temp[0], fRUNPLUG=temp[1])
|
||||||
""")
|
""")
|
||||||
print("done.")
|
print("done.")
|
||||||
print("building finished!")
|
print("building finished!")
|
||||||
|
messagebox.showinfo(LH.string("done"), LH.string("suc"))
|
||||||
|
|
||||||
def importPS():
|
def importPS():
|
||||||
target = filedialog.askopenfile()
|
target = filedialog.askopenfile()
|
||||||
|
@ -948,6 +955,7 @@ def ungridobjtrees():
|
||||||
def loadplugins(GUIe=True):
|
def loadplugins(GUIe=True):
|
||||||
global APIPLUG
|
global APIPLUG
|
||||||
for pluginname in os.listdir(plugindir):
|
for pluginname in os.listdir(plugindir):
|
||||||
|
if pluginname.split(".")[1] == "plg":
|
||||||
file = open(plugindir+"/"+pluginname, 'r')
|
file = open(plugindir+"/"+pluginname, 'r')
|
||||||
plugindata = file.read()
|
plugindata = file.read()
|
||||||
plugindata = ast.literal_eval(plugindata)
|
plugindata = ast.literal_eval(plugindata)
|
||||||
|
@ -956,7 +964,9 @@ def loadplugins(GUIe=True):
|
||||||
exec(plugindata["init"], globals())
|
exec(plugindata["init"], globals())
|
||||||
if "API" in plugindata:
|
if "API" in plugindata:
|
||||||
APIPLUG.append(plugindata["API"])
|
APIPLUG.append(plugindata["API"])
|
||||||
return APIPLUG
|
if "run" in plugindata:
|
||||||
|
RUNPLUG.append(plugindata["run"])
|
||||||
|
return [APIPLUG, RUNPLUG]
|
||||||
|
|
||||||
def GUIinit():
|
def GUIinit():
|
||||||
global container
|
global container
|
||||||
|
@ -1170,13 +1180,15 @@ def aposy(old):
|
||||||
return old
|
return old
|
||||||
return tempvar
|
return tempvar
|
||||||
|
|
||||||
def execgame(gametree, shouldlog=True, fAPIPLUG=[]):
|
def execgame(gametree, shouldlog=True, fAPIPLUG=[], fRUNPLUG=[]):
|
||||||
global GUIe
|
global GUIe
|
||||||
global preview
|
global preview
|
||||||
global clog
|
global clog
|
||||||
global models
|
global models
|
||||||
global APIPLUG
|
global APIPLUG
|
||||||
|
global RUNPLUG
|
||||||
APIPLUG = fAPIPLUG
|
APIPLUG = fAPIPLUG
|
||||||
|
RUNPLUG = fRUNPLUG
|
||||||
preview = hashengine.game(renderer=nullrend, sounddir="/")
|
preview = hashengine.game(renderer=nullrend, sounddir="/")
|
||||||
GUIe = False
|
GUIe = False
|
||||||
models = []
|
models = []
|
||||||
|
@ -1214,6 +1226,8 @@ global DCTE
|
||||||
global gamexsize
|
global gamexsize
|
||||||
global gameysize
|
global gameysize
|
||||||
global APIPLUG
|
global APIPLUG
|
||||||
|
global RUNPLUG
|
||||||
|
RUNPLUG = []
|
||||||
APIPLUG = []
|
APIPLUG = []
|
||||||
gamexsize = 10
|
gamexsize = 10
|
||||||
gameysize = 10
|
gameysize = 10
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
[[{'id': 'script', 'name': 'Skript', 'SID': 'pESBBUtxhoOcWqInhNTdqqqxonEoVbvhJQjHsuSCvsKorTpsPXvWbfElhVTeFmwSZPkFdgBQIoeHNfiBmqXjnRzeIIyokRTJtXXeSyIkxyWqYDOnwNWnVFtWXWoLPJkfcxLFKNJvdClNbgEcZNWJOqgPbTfunPEFeXzUyFYZadEeCIndNkYhWNjaZkIhhEKvdgVCjrLjmpbosAvOeSlhxEyTfJnrBgJgMSMeJOSPQRuMQMwZgjyCSldZtPJuiXA', 'args': {'code': 'from tkinter import messagebox\nmessagebox.showinfo(plugin, plugin)'}}], {}, 10, 10]
|
[[], {}, 10, 10]
|
|
@ -4,4 +4,5 @@ import ast
|
||||||
file = open("game.HEGF", 'r')
|
file = open("game.HEGF", 'r')
|
||||||
file = file.read()
|
file = file.read()
|
||||||
file = ast.literal_eval(file)
|
file = ast.literal_eval(file)
|
||||||
player.execgame(file, fAPIPLUG=player.loadplugins(False))
|
temp = fAPIPLUG=player.loadplugins(False)
|
||||||
|
player.execgame(file, fAPIPLUG=temp[0], fRUNPLUG=temp[1])
|
||||||
|
|
|
@ -689,12 +689,13 @@ def testing():
|
||||||
global running
|
global running
|
||||||
global clog
|
global clog
|
||||||
global APIPLUG
|
global APIPLUG
|
||||||
|
global RUNPLUG
|
||||||
try:
|
try:
|
||||||
if running == True: return
|
if running == True: return
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
running = True
|
running = True
|
||||||
testproc = multiprocessing.Process(target=execgame, args=(prepspecified(gamedata), clog.get(), APIPLUG))
|
testproc = multiprocessing.Process(target=execgame, args=(prepspecified(gamedata), clog.get(), APIPLUG, RUNPLUG))
|
||||||
testproc.start()
|
testproc.start()
|
||||||
|
|
||||||
def APIGEN():
|
def APIGEN():
|
||||||
|
@ -705,7 +706,6 @@ def APIGEN():
|
||||||
for i in APIPLUG:
|
for i in APIPLUG:
|
||||||
exec(i, globals())
|
exec(i, globals())
|
||||||
temp = globals()["PLUGINAPIFUNC"]()
|
temp = globals()["PLUGINAPIFUNC"]()
|
||||||
print(temp)
|
|
||||||
API.update(temp)
|
API.update(temp)
|
||||||
return API
|
return API
|
||||||
|
|
||||||
|
@ -779,6 +779,10 @@ def run():
|
||||||
#gameloopsc = script()
|
#gameloopsc = script()
|
||||||
#gameloopsc.code = gamescript
|
#gameloopsc.code = gamescript
|
||||||
#maingame.startscript(lambda: gameloopsc.execute(APIGEN(), log))
|
#maingame.startscript(lambda: gameloopsc.execute(APIGEN(), log))
|
||||||
|
log("executing plugins")
|
||||||
|
for i in RUNPLUG:
|
||||||
|
exec(i, globals())
|
||||||
|
log("done")
|
||||||
log("game test started!!!")
|
log("game test started!!!")
|
||||||
log("---------------------")
|
log("---------------------")
|
||||||
for i in scripts:
|
for i in scripts:
|
||||||
|
@ -832,7 +836,8 @@ import ast
|
||||||
file = open("game.HEGF", 'r')
|
file = open("game.HEGF", 'r')
|
||||||
file = file.read()
|
file = file.read()
|
||||||
file = ast.literal_eval(file)
|
file = ast.literal_eval(file)
|
||||||
player.execgame(file, fAPIPLUG=player.loadplugins(False))
|
temp = fAPIPLUG=player.loadplugins(False)
|
||||||
|
player.execgame(file, fAPIPLUG=temp[0], fRUNPLUG=temp[1])
|
||||||
""")
|
""")
|
||||||
print("done.")
|
print("done.")
|
||||||
print("building finished!")
|
print("building finished!")
|
||||||
|
@ -957,7 +962,9 @@ def loadplugins(GUIe=True):
|
||||||
exec(plugindata["init"], globals())
|
exec(plugindata["init"], globals())
|
||||||
if "API" in plugindata:
|
if "API" in plugindata:
|
||||||
APIPLUG.append(plugindata["API"])
|
APIPLUG.append(plugindata["API"])
|
||||||
return APIPLUG
|
if "run" in plugindata:
|
||||||
|
RUNPLUG.append(plugindata["run"])
|
||||||
|
return [APIPLUG, RUNPLUG]
|
||||||
|
|
||||||
def GUIinit():
|
def GUIinit():
|
||||||
global container
|
global container
|
||||||
|
@ -1062,7 +1069,7 @@ def GUIinit():
|
||||||
menu.add_cascade(label=LH.string("langs"), menu=langmenu)
|
menu.add_cascade(label=LH.string("langs"), menu=langmenu)
|
||||||
for i in LH.getlangs():
|
for i in LH.getlangs():
|
||||||
langmenu.add_command(label=i, command=lambda i=i: selectlang(i))
|
langmenu.add_command(label=i, command=lambda i=i: selectlang(i))
|
||||||
|
loadplugins()
|
||||||
container.mainloop()
|
container.mainloop()
|
||||||
|
|
||||||
# attribute changers
|
# attribute changers
|
||||||
|
@ -1171,13 +1178,15 @@ def aposy(old):
|
||||||
return old
|
return old
|
||||||
return tempvar
|
return tempvar
|
||||||
|
|
||||||
def execgame(gametree, shouldlog=True, fAPIPLUG=[]):
|
def execgame(gametree, shouldlog=True, fAPIPLUG=[], fRUNPLUG=[]):
|
||||||
global GUIe
|
global GUIe
|
||||||
global preview
|
global preview
|
||||||
global clog
|
global clog
|
||||||
global models
|
global models
|
||||||
global APIPLUG
|
global APIPLUG
|
||||||
|
global RUNPLUG
|
||||||
APIPLUG = fAPIPLUG
|
APIPLUG = fAPIPLUG
|
||||||
|
RUNPLUG = fRUNPLUG
|
||||||
preview = hashengine.game(renderer=nullrend, sounddir="/")
|
preview = hashengine.game(renderer=nullrend, sounddir="/")
|
||||||
GUIe = False
|
GUIe = False
|
||||||
models = []
|
models = []
|
||||||
|
@ -1215,6 +1224,8 @@ global DCTE
|
||||||
global gamexsize
|
global gamexsize
|
||||||
global gameysize
|
global gameysize
|
||||||
global APIPLUG
|
global APIPLUG
|
||||||
|
global RUNPLUG
|
||||||
|
RUNPLUG = []
|
||||||
APIPLUG = []
|
APIPLUG = []
|
||||||
gamexsize = 10
|
gamexsize = 10
|
||||||
gameysize = 10
|
gameysize = 10
|
||||||
|
|
|
@ -13,4 +13,8 @@ addmenu = tk.Menu(menu)
|
||||||
menu.add_cascade(label="exampleplugin", menu=addmenu)
|
menu.add_cascade(label="exampleplugin", menu=addmenu)
|
||||||
addmenu.add_command(label="NULL", command=print())
|
addmenu.add_command(label="NULL", command=print())
|
||||||
""",
|
""",
|
||||||
|
"run": """
|
||||||
|
from tkinter import messagebox
|
||||||
|
messagebox.showinfo("PLUGIN TEST", "PLUGIN TEST")
|
||||||
|
""",
|
||||||
}
|
}
|
|
@ -13,4 +13,8 @@ addmenu = tk.Menu(menu)
|
||||||
menu.add_cascade(label="exampleplugin", menu=addmenu)
|
menu.add_cascade(label="exampleplugin", menu=addmenu)
|
||||||
addmenu.add_command(label="NULL", command=print())
|
addmenu.add_command(label="NULL", command=print())
|
||||||
""",
|
""",
|
||||||
|
"run": """
|
||||||
|
from tkinter import messagebox
|
||||||
|
messagebox.showinfo("PLUGIN TEST", "PLUGIN TEST")
|
||||||
|
""",
|
||||||
}
|
}
|
Loading…
Reference in New Issue