diff --git a/DOCS/overview.txt b/DOCS/overview.txt index 26db446..436b41d 100644 --- a/DOCS/overview.txt +++ b/DOCS/overview.txt @@ -1,6 +1,6 @@ Desutezeoid Technical Documentation. Overview: -Desutezeoid v1.1.2 +Desutezeoid v1.1.3 (c) 2015-2017 Thomas Leathers diff --git a/DZU-ENG1.py b/DZU-ENG1.py index 79a2683..3a528c3 100755 --- a/DZU-ENG1.py +++ b/DZU-ENG1.py @@ -7,12 +7,13 @@ import pygame import time import os +import copy from pygame.locals import * import xml.etree.ElementTree as ET pygame.display.init() pygame.font.init() pygame.mixer.init() -print "Desutezeoid arbitrary point and click engine v1.1.2" +print "Desutezeoid arbitrary point and click engine v1.1.3" print "parsing ENGSYSTEM.xml" conftree = ET.parse("ENGSYSTEM.xml") confroot = conftree.getroot() @@ -23,11 +24,17 @@ for initk in initkeystag.findall("k"): if (initk.attrib.get("keyid"))!="0": keylist.extend([initk.attrib.get("keyid")]) -print keylist + scrnx=int(screentag.attrib.get("x", "800")) scrny=int(screentag.attrib.get("y", "600")) titletag=confroot.find("title") +debugtag=confroot.find("debug") +DEBUG=int(debugtag.attrib.get("debug", "1")) +printkeys=int(debugtag.attrib.get("printkeys", "1")) beginref=(confroot.find("beginref")).text + +globalcoretag=confroot.find("globalcore") +globalforkstag=confroot.find("globalforks") print "config parsed." titlebase=titletag.attrib.get("base", "Desutezeoid: ") class clicktab: @@ -45,13 +52,17 @@ def __init__(self, seconds, keyid, postkey): self.regtime=time.time() self.seconds=seconds self.postkey=postkey -DEBUG=1 + #class keyobj: # def __init__(self, keyid): # self=keyid def debugmsg(msg): if DEBUG==1: print msg +def keyprint(): + if printkeys==1: + print keylist +keyprint() prevpage="NULL" #point this to your first screen c: no menu program really needed :o curpage=beginref @@ -73,14 +84,23 @@ def debugmsg(msg): #print "tic" if curpage!=prevpage: print "preparsing page" - pygame.mixer.music.stop() + tree = ET.parse(curpage) root = tree.getroot() prevpage=curpage coretag=root.find('core') forktag=root.find('forks') + print "parsing global core objects into page structure..." + for glb in globalcoretag: + coretag.append(copy.deepcopy(glb)) + print "parsing global fork objects into page structure..." + for glb in globalforkstag: + forktag.append(copy.deepcopy(glb)) pageconf=root.find('pageconf') pagetitle=(pageconf.find('title')).text + BGMstop=int(pageconf.attrib.get("BGMstop", "1")) + if BGMstop==1: + pygame.mixer.music.stop() BGon=int(pageconf.attrib.get("BGimg", "0")) BGMon=int(pageconf.attrib.get("BGM", "0")) if BGMon==1: @@ -127,12 +147,14 @@ def debugmsg(msg): if len(set(complist)) == 1: if not masterkey in keylist: keylist.extend([masterkey]) - print keylist + #print keylist + keyprint() forksanity=1 else: if masterkey in keylist: keylist.remove(masterkey) - print keylist + #print keylist + keyprint() forksanity=1 for fork in forktag.findall("batchset"): #print "batch" @@ -146,14 +168,16 @@ def debugmsg(msg): subkeyid=subkey.attrib.get("keyid") if not subkeyid in keylist: keylist.extend([subkeyid]) - print keylist + #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 + #print keylist + keyprint() forksanity=1 pagejumpflag=0 for fork in forktag.findall("pagejump"): @@ -210,7 +234,8 @@ def debugmsg(msg): if tif.postkey not in keylist: if tif.postkey!="0": keylist.extend([tif.postkey]) - print keylist + #print keylist + keyprint() timeoutlist.remove(tif) keybak=list(keylist) @@ -275,6 +300,113 @@ def debugmsg(msg): # break datstr=clicktab(clickref, "key", ref, keyid, takekey, clicksoundflg, soundname) clicklist.extend([datstr]) + for labref in coretag.findall("box"): + keyid=labref.attrib.get('keyid', "0") + takekey=labref.attrib.get('takekey', "0") + onkey=labref.attrib.get('onkey', "0") + offkey=labref.attrib.get('offkey', "0") + hoverkey=labref.attrib.get('hoverkey', "0") + clicksoundflg=int(labref.attrib.get('sfxclick', "0")) + soundname=(labref.attrib.get('sound', "0")) + if ((onkey=="0" and offkey=="0") or (onkey=="0" and offkey not in keylist) or (onkey in keylist and offkey=="0") or (onkey in keylist and offkey not in keylist)): + imgx=int(labref.attrib.get("x")) + imgy=int(labref.attrib.get("y")) + sizex=int(labref.attrib.get("sizex")) + sizey=int(labref.attrib.get("sizey")) + onhov=int(labref.attrib.get("onhov", "0")) + hovcolor=pygame.Color(labref.attrib.get("HOVCOLOR", "#FFFFFF")) + hovalpha=int(labref.attrib.get("hovalpha", "140")) + boxalpha=int(labref.attrib.get("alpha", "100")) + boxcolor=pygame.Color(labref.attrib.get("COLOR", "#FFFFFF")) + #imgcon=(labref.find("con")).text + act=labref.find("act") + acttype=act.attrib.get("type", "none") + pos = pygame.mouse.get_pos() + #imggfx=pygame.image.load(imgcon) + boxgfx=pygame.Surface((sizex, sizey)) + boxgfx.convert_alpha() + #imggfx.fill(boxcolor) + boxgfx.set_alpha(0) + clickref=screensurf.blit(boxgfx, (imgx, imgy)) + if onhov==1 and clickref.collidepoint(pos)==1: + boxgfx.fill(hovcolor) + boxgfx.set_alpha(hovalpha) + #skip blitting a second time if alpha is 0. + if hovalpha!=0: + clickref=screensurf.blit(boxgfx, (imgx, imgy)) + else: + boxgfx.fill(boxcolor) + boxgfx.set_alpha(boxalpha) + #skip blitting a second time if alpha is 0. + if boxalpha!=0: + clickref=screensurf.blit(boxgfx, (imgx, imgy)) + if hoverkey!="0": + if clickref.collidepoint(pos)==1: + if not hoverkey in keylist: + keylist.extend([hoverkey]) + else: + if hoverkey in keylist: + keylist.remove(hoverkey) + if acttype!="none": + 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"): + onkey=texref.attrib.get('onkey', "0") + offkey=texref.attrib.get('offkey', "0") + if ((onkey=="0" and offkey=="0") or (onkey=="0" and offkey not in keylist) or (onkey in keylist and offkey=="0") or (onkey in keylist and offkey not in keylist)): + labx=int(texref.attrib.get("x")) + laby=int(texref.attrib.get("y")) + size=int(texref.attrib.get("size")) + FGCOL=pygame.Color(texref.attrib.get("FGCOLOR", "#FFFFFF")) + BGCOL=pygame.Color(texref.attrib.get("BGCOLOR", "#000000")) + transp=int(texref.attrib.get("transp", "0")) + texfnt=pygame.font.SysFont(None, size) + pixcnt1=laby + pixjmp=(size+0) + textcont=(texref.text + "\n") + textchunk="" + #this draws the text body line-per-line + for texch in textcont: + if texch=="\n": + #if at newline, render line of text, clear textchunk, and add to pixcnt1 + if transp==0: + texgfx=texfnt.render(textchunk, True, FGCOL, BGCOL) + else: + texgfx=texfnt.render(textchunk, True, FGCOL) + screensurf.blit(texgfx, (labx, pixcnt1)) + pixcnt1 += pixjmp + textchunk="" + else: + #if not at a newline yet, keep building textchunk. + textchunk=(textchunk + texch) + + #clickref=screensurf.blit(labgfx, (labx, laby)) for labref in coretag.findall("label"): keyid=labref.attrib.get('keyid', "0") takekey=labref.attrib.get('takekey', "0") @@ -356,11 +488,13 @@ def debugmsg(msg): if f.keyid!="0": if not f.keyid in keylist: keylist.extend([f.keyid]) - print keylist + #print keylist + keyprint() if f.takekey!="0": if takekey in keylist and f.takekey!="0": keylist.remove(f.takekey) - print keylist + #print keylist + keyprint() if f.reftype=="iref": curpage=f.ref print ("iref: loading page '" + f.ref + "'") diff --git a/ENGSYSTEM.xml b/ENGSYSTEM.xml index 7670be4..509df33 100644 --- a/ENGSYSTEM.xml +++ b/ENGSYSTEM.xml @@ -3,12 +3,41 @@ - + <title base="Desutezeoid v1.1.3 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"/> <!--keyids loaded into the keyid enviornment at startup.--> <initkeys> <k keyid="timeloop1"/> <k keyid="testkey1"/> </initkeys> + + <!--Explanation of "globalforks" and "globalcore": these corrispond to the "forks" and "core" sections of page xml files. these are populated into corresponding areas of the page structure in memory. This is why "forks" and "core objects" here act as if they are in every page's xml file.--> + + <!--These forks are present on each page--> + <globalforks> + <!--this is an endless loop of 3 keyids. this is started by a keyid added by the initkeys section of config. also note how since this is in globalforks, it stays running. + and with a nonlooping sequence, such as an "on-click" animation. you would only need it on the page the animation is present on.--> + <timeout keyid="timeloop1" seconds="0.5" post="timeloop2"/> + <timeout keyid="timeloop2" seconds="0.5" post="timeloop3"/> + <timeout keyid="timeloop3" seconds="0.5" post="timeloop1"/> + </globalforks> + <!--these core objects are present on each page--> + <globalcore> + <!--this label uses the act type "quit" when clicked, this will quit the "game" also note how since this is present in globalcore, it shows on every page.--> + <label x="0" y="580" size="20" BGCOLOR="#880000" FGCOLOR="#FFFFFF" > + <con>QUIT</con> + <act type="quit" ref="test1.xml"/> + </label> + <label x="40" y="580" size="20" BGCOLOR="#008800" FGCOLOR="#FFFFFF" > + <con>About</con> + <act type="iref" ref="about.xml"/> + </label> + <label x="80" y="580" size="20" BGCOLOR="#008800" FGCOLOR="#FFFFFF" > + <con>Home</con> + <act type="iref" ref="test0.xml"/> + </label> + </globalcore> </conf> \ No newline at end of file diff --git a/README.md b/README.md index c98757b..54ae9ba 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Desutezeoid -v1.1.2 +v1.1.3 an arbitrary point and click engine. (c) 2015-2017 Thomas Leathers diff --git a/about.xml b/about.xml new file mode 100644 index 0000000..fc1de86 --- /dev/null +++ b/about.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<main> + <pageconf BGimg="1" BGM="0"> + <title>About Desutezeoid. + BGseaside.jpg + BGM1.ogg + + + + + + + v1.1.3 +an arbitrary point and click engine. +(c) 2015-2017 Thomas Leathers + + +Desutezeoid is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +Desutezeoid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Desutezeoid. If not, see <http://www.gnu.org/licenses/>. + + \ No newline at end of file diff --git a/test0.xml b/test0.xml index 1b5c4f5..aba42f8 100644 --- a/test0.xml +++ b/test0.xml @@ -36,11 +36,7 @@ but only after the keyid is present will the countdown begin. it is safe to remo timeout fork associated with it. as the timeout instance in question will be removed automatically. The timeout instance is also removed after the specified time lapses. also if the optional post keyid atribbute is set, a keyid will be passively added after timeout.--> - - - - + @@ -48,7 +44,12 @@ The timeout instance is also removed after the specified time lapses. also if th Hello world! :D - + + + + + + - testimg0.png testimg1.png - + animtest1a.png diff --git a/test1.xml b/test1.xml index d9f7f5a..ff6bb74 100644 --- a/test1.xml +++ b/test1.xml @@ -1,14 +1,11 @@
- + + another page BGseaside.jpg - - - - starting booster rockets... - +
\ No newline at end of file