Skip to content

Commit

Permalink
move cache functions to dzulib so plugins can use them, extend manual.
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasTheSpaceFox committed Nov 18, 2017
1 parent f447e11 commit 687c1f1
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 37 deletions.
44 changes: 10 additions & 34 deletions DZU-ENG1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import dzulib1 as dzulib
import dzupluglib
from dzulib1 import clicktab

from dzulib1 import textrender
from dzulib1 import filelookup

from pygame.locals import *
import xml.etree.ElementTree as ET
Expand Down Expand Up @@ -49,37 +50,12 @@

pygame.event.set_allowed([QUIT, MOUSEBUTTONDOWN, MOUSEBUTTONUP])

filedict={}
textdict={}
imagepath='img'


sfxpath='sfx'
def filelookup(filename):
global filedict
if filename in filedict:
return filedict[filename]
else:
if (filename.lower()).endswith(".jpg") or (filename.lower()).endswith(".jpeg") or (filename.lower()).startswith("no-tr"):
imgret=pygame.image.load(os.path.join(imagepath, filename)).convert()
else:
imgret=pygame.image.load(os.path.join(imagepath, filename)).convert_alpha()
filedict[filename]=imgret
return imgret

def textrender(text, size, fgcolor, bgcolor, transp):
global textdict
keyx=(text + str(size) + fgcolor + bgcolor + str(transp))
if keyx in textdict:
return textdict[keyx]
else:
fgcolor=pygame.Color(fgcolor)
bgcolor=pygame.Color(bgcolor)
texfnt=pygame.font.SysFont(None, size)
if transp==0:
texgfx=texfnt.render(text, True, fgcolor, bgcolor)
else:
texgfx=texfnt.render(text, True, fgcolor)
textdict[keyx]=texgfx
return texgfx
imagepath='img'




Expand Down Expand Up @@ -302,10 +278,10 @@ def qpop(qmsg, xpos, ypos, keyid="0", nokey="0", quyn=0, specialquit=0, fgcol=ui
#print "tic"
if curpage!=prevpage:
print "flushing image cache"
del filedict
filedict={}
del textdict
textdict={}
del dzulib.filedict
dzulib.filedict={}
del dzulib.textdict
dzulib.textdict={}
print "notify plugins of page change"
for pluginst in pluglistactive:
pluginst.pageclear()
Expand Down
2 changes: 1 addition & 1 deletion ENGSYSTEM.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!--window size-->
<screen x="800" y="600"/>
<!--Game/program Title/windown icon.-->
<title base="Desutezeoid v1.6.0 test program. " icon="icon.png" />
<title base="Desutezeoid v1.6.1 test program. " icon="icon.png" />
<!--page to load at engine start.-->
<beginref>startpage.xml</beginref>
<!--debug settings. used in development and testing. printkeys controls keyid list printing.
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.6.0
v1.6.1
an arbitrary point and click engine.
Copyright (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.6.0
<text x="10" y="30" size="20" transp="1" FGCOLOR="#000000">v1.6.1
an arbitrary point and click engine.
Copyright (c) 2015-2017 Thomas Leathers

Expand Down
34 changes: 34 additions & 0 deletions dzulib1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import pygame.image
import pygame.mixer
import pygame
import sys
import time
import os
pygame.display.init()
#this library should contain any functions and data needed by dezutezeoid
#that don't need to be in the actual engine executable
Expand Down Expand Up @@ -48,6 +51,37 @@ def hscroll(scrollval, image):
newimage.blit(image, ((scrollval - offs), 0))
return newimage

imagepath='img'

filedict={}
textdict={}
def filelookup(filename):
global filedict
if filename in filedict:
return filedict[filename]
else:
if (filename.lower()).endswith(".jpg") or (filename.lower()).endswith(".jpeg") or (filename.lower()).startswith("no-tr"):
imgret=pygame.image.load(os.path.join(imagepath, filename)).convert()
else:
imgret=pygame.image.load(os.path.join(imagepath, filename)).convert_alpha()
filedict[filename]=imgret
return imgret

def textrender(text, size, fgcolor, bgcolor, transp):
global textdict
keyx=(text + str(size) + fgcolor + bgcolor + str(transp))
if keyx in textdict:
return textdict[keyx]
else:
fgcolor=pygame.Color(fgcolor)
bgcolor=pygame.Color(bgcolor)
texfnt=pygame.font.SysFont(None, size)
if transp==0:
texgfx=texfnt.render(text, True, fgcolor, bgcolor)
else:
texgfx=texfnt.render(text, True, fgcolor)
textdict[keyx]=texgfx
return texgfx

class clicktab:
def __init__(self, box, reftype, ref, keyid, takekey, sfxclick, sound, quitab=0):
Expand Down
Binary file modified manual/desutezeoid_manual.odt
Binary file not shown.
Binary file modified manual/desutezeoid_manual.pdf
Binary file not shown.

0 comments on commit 687c1f1

Please sign in to comment.