Skip to content

Commit

Permalink
add debug option to show clickable objects via outlining the clickbox…
Browse files Browse the repository at this point in the history
…es. add ortrig fork, fix bug in event handler, a few other tweaks.
  • Loading branch information
ThomasTheSpaceFox committed Feb 18, 2017
1 parent 6c804f5 commit c734bea
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 153 deletions.
2 changes: 1 addition & 1 deletion DOCS/overview.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Desutezeoid Technical Documentation.
Overview:
Desutezeoid v1.1.3
Desutezeoid v1.2.0
(c) 2015-2017 Thomas Leathers


Expand Down
273 changes: 126 additions & 147 deletions DZU-ENG1.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
pygame.display.init()
pygame.font.init()
pygame.mixer.init()
print "Desutezeoid arbitrary point and click engine v1.1.3"
print "Desutezeoid arbitrary point and click engine v1.2.0"
print "parsing ENGSYSTEM.xml"
conftree = ET.parse("ENGSYSTEM.xml")
confroot = conftree.getroot()
Expand All @@ -31,6 +31,9 @@
debugtag=confroot.find("debug")
DEBUG=int(debugtag.attrib.get("debug", "1"))
printkeys=int(debugtag.attrib.get("printkeys", "1"))
clickfields=int(debugtag.attrib.get("clickfields", "0"))
cfcolor=pygame.Color(debugtag.attrib.get("cfcolor", "#888888"))

beginref=(confroot.find("beginref")).text

globalcoretag=confroot.find("globalcore")
Expand Down Expand Up @@ -113,117 +116,136 @@ def keyprint():
BGfile=(pageconf.find('BG')).text
BG=pygame.image.load(BGfile)
screensurf.fill((170, 170, 170))
#pygame.event.get()
#while pygame.mouse.get_pressed()[0]!=0:
# pygame.event.get()
# print "wait"
# print pygame.mouse.get_pressed()[0]
# time.sleep(0.1)
print "done. begin mainloop"
if BGon==1:
screensurf.blit(BG, (0, 0))
#print keylist
#print keybak
#if keylist!=keybak or forksanitycheck==1:
if True:
#debugmsg("keyid change detected. reparsing forks.")
for fork in forktag.findall("batchtrig"):
#print "batchtrig"
masterkey=fork.attrib.get("keyid")
complist=[1]
for keyif in fork.findall("k"):
ifpol=keyif.attrib.get("if")
subkey=keyif.attrib.get("keyid")
if subkey in keylist:
if ifpol=="1":
complist.extend([1])
else:
complist.extend([0])
elif not subkey in keylist:
if ifpol=="0":
complist.extend([1])
else:
complist.extend([0])
if len(set(complist)) == 1:
if not masterkey in keylist:
keylist.extend([masterkey])
#print keylist
keyprint()
forksanity=1
else:
if masterkey in keylist:
keylist.remove(masterkey)
#print keylist
keyprint()
forksanity=1
for fork in forktag.findall("batchset"):
#print "batch"
#print fork
masterkey=fork.attrib.get("keyid")
toggpol=fork.attrib.get("set")

#debugmsg("keyid change detected. reparsing forks.")
for fork in forktag.findall("ortrig"):
#print "batchtrig"
masterkey=fork.attrib.get("keyid")
orflg=0
for keyif in fork.findall("k"):
ifpol=keyif.attrib.get("if")
subkey=keyif.attrib.get("keyid")
if subkey in keylist:
if ifpol=="1":
orflg=1
elif not subkey in keylist:
if ifpol=="0":
orflg=1
if orflg == 1:
if not masterkey in keylist:
keylist.extend([masterkey])
#print keylist
keyprint()
forksanity=1
else:
if masterkey in keylist:
keylist.remove(masterkey)
if toggpol=="1":
for subkey in fork.findall("k"):
subkeyid=subkey.attrib.get("keyid")
if not subkeyid in keylist:
keylist.extend([subkeyid])
#print keylist
keyprint()
forksanity=1
#print keylist
keyprint()
forksanity=1
for fork in forktag.findall("batchtrig"):
#print "batchtrig"
masterkey=fork.attrib.get("keyid")
complist=[1]
for keyif in fork.findall("k"):
ifpol=keyif.attrib.get("if")
subkey=keyif.attrib.get("keyid")
if subkey in keylist:
if ifpol=="1":
complist.extend([1])
else:
for subkey in fork.findall("k"):
subkeyid=subkey.attrib.get("keyid")
if subkeyid in keylist:
keylist.remove(subkeyid)
#print keylist
keyprint()
forksanity=1
pagejumpflag=0
for fork in forktag.findall("pagejump"):
masterkey=fork.attrib.get("keyid")
if masterkey in keylist:
keylist.remove(masterkey)
curpage=fork.attrib.get("page")
print ("iref: loading page '" + f.ref + "'")
pagejumpflag=1
break
for fork in forktag.findall("timeout"):
masterkey=fork.attrib.get("keyid")
if masterkey in keylist:
notinlist=1
for tif in timeoutlist:
if tif.keyid==masterkey:
notinlist=0
if notinlist==1:
seconds=float(fork.attrib.get("seconds"))
postkey=fork.attrib.get("post", "0")
timeoutlist.extend([timeouttab(seconds, masterkey, postkey)])
for fork in forktag.findall("triggerlock"):
masterkey=fork.attrib.get("keyid")
triggerkey=fork.attrib.get("trigger")
lockkey=fork.attrib.get("lock")
if masterkey in keylist:
#keylist.remove(masterkey)
if lockkey not in keylist:
if triggerkey not in keylist:
keylist.extend([triggerkey])
keylist.extend([lockkey])


for fork in forktag.findall("sound"):
masterkey=fork.attrib.get("keyid")
soundname=fork.attrib.get("sound")
complist.extend([0])
elif not subkey in keylist:
if ifpol=="0":
complist.extend([1])
else:
complist.extend([0])
if len(set(complist)) == 1:
if not masterkey in keylist:
keylist.extend([masterkey])
#print keylist
keyprint()
forksanity=1
else:
if masterkey in keylist:
keylist.remove(masterkey)
soundobj=pygame.mixer.Sound(soundname)
soundobj.play()
if forksanity==1:
forksanitycheck=1
forksanity=0
#skiploop=1
else:
forksanitycheck=0
#print keylist
keyprint()
forksanity=1
for fork in forktag.findall("batchset"):
#print "batch"
#print fork
masterkey=fork.attrib.get("keyid")
toggpol=fork.attrib.get("set")
if masterkey in keylist:
keylist.remove(masterkey)
if toggpol=="1":
for subkey in fork.findall("k"):
subkeyid=subkey.attrib.get("keyid")
if not subkeyid in keylist:
keylist.extend([subkeyid])
#print keylist
keyprint()
forksanity=1
else:
for subkey in fork.findall("k"):
subkeyid=subkey.attrib.get("keyid")
if subkeyid in keylist:
keylist.remove(subkeyid)
#print keylist
keyprint()
forksanity=1
pagejumpflag=0
for fork in forktag.findall("pagejump"):
masterkey=fork.attrib.get("keyid")
if masterkey in keylist:
keylist.remove(masterkey)
curpage=fork.attrib.get("page")
print ("iref: loading page '" + f.ref + "'")
pagejumpflag=1
break
for fork in forktag.findall("timeout"):
masterkey=fork.attrib.get("keyid")
if masterkey in keylist:
notinlist=1
for tif in timeoutlist:
if tif.keyid==masterkey:
notinlist=0
if notinlist==1:
seconds=float(fork.attrib.get("seconds"))
postkey=fork.attrib.get("post", "0")
timeoutlist.extend([timeouttab(seconds, masterkey, postkey)])
for fork in forktag.findall("triggerlock"):
masterkey=fork.attrib.get("keyid")
triggerkey=fork.attrib.get("trigger")
lockkey=fork.attrib.get("lock")
if masterkey in keylist:
#keylist.remove(masterkey)
if lockkey not in keylist:
if triggerkey not in keylist:
keylist.extend([triggerkey])
keylist.extend([lockkey])


for fork in forktag.findall("sound"):
masterkey=fork.attrib.get("keyid")
soundname=fork.attrib.get("sound")
if masterkey in keylist:
keylist.remove(masterkey)
soundobj=pygame.mixer.Sound(soundname)
soundobj.play()
if forksanity==1:
forksanitycheck=1
forksanity=0
#skiploop=1
else:
forksanitycheck=0

for tif in timeoutlist:
if tif.keyid not in keylist:
Expand Down Expand Up @@ -275,29 +297,14 @@ def keyprint():
pos = pygame.mouse.get_pos()
if acttype=="iref":
ref=act.attrib.get("ref")
#for event in pygame.event.get(MOUSEBUTTONDOWN):
#pygame.event.get()
#if clickref.collidepoint(pos)==1 and (pygame.mouse.get_pressed()[0])==1:
# curpage=ref
# break
datstr=clicktab(clickref, "iref", ref, keyid, takekey, clicksoundflg, soundname)
clicklist.extend([datstr])
if acttype=="quit":
ref=act.attrib.get("ref")
#for event in pygame.event.get(MOUSEBUTTONDOWN):
#pygame.event.get()
#if clickref.collidepoint(pos)==1 and (pygame.mouse.get_pressed()[0])==1:
# quitflag=1
# break
datstr=clicktab(clickref, "quit", ref, keyid, takekey, clicksoundflg, soundname)
clicklist.extend([datstr])
if acttype=="key":
ref=act.attrib.get("ref")
#for event in pygame.event.get(MOUSEBUTTONDOWN):
#pygame.event.get()
#if clickref.collidepoint(pos)==1 and (pygame.mouse.get_pressed()[0])==1:
# quitflag=1
# break
datstr=clicktab(clickref, "key", ref, keyid, takekey, clicksoundflg, soundname)
clicklist.extend([datstr])
for labref in coretag.findall("box"):
Expand Down Expand Up @@ -351,29 +358,14 @@ def keyprint():
pos = pygame.mouse.get_pos()
if acttype=="iref":
ref=act.attrib.get("ref")
#for event in pygame.event.get(MOUSEBUTTONDOWN):
#pygame.event.get()
#if clickref.collidepoint(pos)==1 and (pygame.mouse.get_pressed()[0])==1:
# curpage=ref
# break
datstr=clicktab(clickref, "iref", ref, keyid, takekey, clicksoundflg, soundname)
clicklist.extend([datstr])
if acttype=="quit":
ref=act.attrib.get("ref")
#for event in pygame.event.get(MOUSEBUTTONDOWN):
#pygame.event.get()
#if clickref.collidepoint(pos)==1 and (pygame.mouse.get_pressed()[0])==1:
# quitflag=1
# break
datstr=clicktab(clickref, "quit", ref, keyid, takekey, clicksoundflg, soundname)
clicklist.extend([datstr])
if acttype=="key":
ref=act.attrib.get("ref")
#for event in pygame.event.get(MOUSEBUTTONDOWN):
#pygame.event.get()
#if clickref.collidepoint(pos)==1 and (pygame.mouse.get_pressed()[0])==1:
# quitflag=1
# break
datstr=clicktab(clickref, "key", ref, keyid, takekey, clicksoundflg, soundname)
clicklist.extend([datstr])
for texref in coretag.findall("text"):
Expand Down Expand Up @@ -442,33 +434,21 @@ def keyprint():
pos = pygame.mouse.get_pos()
if acttype=="iref":
ref=act.attrib.get("ref")
#for event in pygame.event.get(MOUSEBUTTONDOWN):
#pygame.event.get()
#if clickref.collidepoint(pos)==1 and (pygame.mouse.get_pressed()[0])==1:
# curpage=ref
# break
datstr=clicktab(clickref, "iref", ref, keyid, takekey, clicksoundflg, soundname)
clicklist.extend([datstr])
if acttype=="quit":
ref=act.attrib.get("ref")
#for event in pygame.event.get(MOUSEBUTTONDOWN):
#pygame.event.get()
#if clickref.collidepoint(pos)==1 and (pygame.mouse.get_pressed()[0])==1:
# quitflag=1
# break
datstr=clicktab(clickref, "quit", ref, keyid, takekey, clicksoundflg, soundname)
clicklist.extend([datstr])
if acttype=="key":
ref=act.attrib.get("ref")
#for event in pygame.event.get(MOUSEBUTTONDOWN):
#pygame.event.get()
#if clickref.collidepoint(pos)==1 and (pygame.mouse.get_pressed()[0])==1:
# quitflag=1
# break
datstr=clicktab(clickref, "key", ref, keyid, takekey, clicksoundflg, soundname)
clicklist.extend([datstr])
#else:
#time.sleep(0.04)
if clickfields==1:
for f in clicklist:
pygame.draw.rect(screensurf, cfcolor, f.box, 1)
eventhappen=0
for event in pygame.event.get():
#print "nominal"
Expand Down Expand Up @@ -509,5 +489,4 @@ def keyprint():

pygame.display.update()
pygame.event.pump()
pygame.event.clear()

7 changes: 4 additions & 3 deletions ENGSYSTEM.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
<!--window size-->
<screen x="800" y="600"/>
<!--Game/program Title-->
<title base="Desutezeoid v1.1.3 test program. " />
<title base="Desutezeoid v1.2.0 test program. " />
<!--page to load at engine start.-->
<beginref>test0.xml</beginref>
<!--debug settings. used in development and testing. printkeys controls keyid list printing.-->
<debug debug="1" printkeys="1"/>
<!--debug settings. used in development and testing. printkeys controls keyid list printing.
clickfields uses cfcolor to show outlines around each click field. useful for debugging.-->
<debug debug="1" printkeys="1" clickfields="0" cfcolor="#FFFF00"/>
<!--keyids loaded into the keyid enviornment at startup.-->
<initkeys>
<k keyid="timeloop1"/>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Desutezeoid
v1.1.3
v1.2.0
an arbitrary point and click engine.
(c) 2015-2017 Thomas Leathers

Expand Down
2 changes: 1 addition & 1 deletion about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<act type="none"/>
</label>
<!--notice how the "text" object has similar attributes to the label tag, but lacking click and hover related, attribues. It still has onkey and offkey though. do note this can take longer to process than other core objects.-->
<text x="10" y="30" size="20" transp="1" FGCOLOR="#000000">v1.1.3
<text x="10" y="30" size="20" transp="1" FGCOLOR="#000000">v1.2.0
an arbitrary point and click engine.
(c) 2015-2017 Thomas Leathers

Expand Down
Loading

0 comments on commit c734bea

Please sign in to comment.