1
from pandac.PandaModules import *
5
def __init__(self,xStart,yStart,xEnd,yEnd):
6
self.xStart,self.yStart,self.xEnd,self.yEnd = xStart,yStart,xEnd,yEnd
8
def draw(self,theme,pos,size):
10
xs,ys = size[0],size[1]
11
u,v,us,vs = self.xStart,self.yStart,self.xEnd,self.yEnd
12
theme.rectStreatch((x,y,xs,ys),(u,v,us,vs))
16
def __init__(self,xStart,yStart,xEnd,yEnd,border):
17
self.xStart,self.yStart,self.xEnd,self.yEnd,self.border = xStart,yStart,xEnd,yEnd,border
19
def draw(self,theme,pos,size):
20
u,v,us,vs,b = self.xStart,self.yStart,self.xEnd,self.yEnd,self.border
21
self.drawBlock(theme,pos,size,u,v,us,vs) # center
23
xs,ys = size[0],size[1]
25
self.drawBlock(theme,Vec2(x,y-b),Vec2(xs,b),u,v-b,us,b) # N
26
self.drawBlock(theme,Vec2(x,y+ys),Vec2(xs,b),u,v+vs,us,b) # S
27
self.drawBlock(theme,Vec2(x-b,y),Vec2(b,ys),u-b,v,b,vs) # W
28
self.drawBlock(theme,Vec2(x+xs,y),Vec2(b,ys),u+us+b,v,b,vs) # E
30
self.drawBlock(theme,Vec2(x-b,y-b),Vec2(b,b),u-b,v-b,b,b) # NW
31
self.drawBlock(theme,Vec2(x+xs,y+ys),Vec2(b,b),u+us+b,v+vs,b,b) # SE
32
self.drawBlock(theme,Vec2(x-b,y+ys),Vec2(b,b),u-b,v+vs,b,b) # SW
33
self.drawBlock(theme,Vec2(x+xs,y-b),Vec2(b,b),u+us+b,v-b,b,b) # NW
35
def drawBlock(self,theme,pos,size,u,v,us,vs):
37
xs,ys = size[0],size[1]
38
#u,v,us,vs = self.xStart,self.yStart,self.xEnd,self.yEnd
39
theme.rectStreatch((x,y,xs,ys),(u,v,us,vs))
43
def __init__(self,xStart,yStart,xEnd,yEnd):
44
self.xStart,self.yStart,self.xEnd,self.yEnd = xStart,yStart,xEnd,yEnd
46
def draw(self,theme,pos,size):
48
xs,ys = size[0],size[1]
50
u,v,us,vs = self.xStart,self.yStart,self.xEnd,self.yEnd
58
fixed_us,fixed_vs = us,vs
59
if xFit < 1: fixed_us = xs%us
60
if yFit < 1: fixed_vs = ys%vs
61
theme.rect((xPos,yPos,fixed_us,fixed_vs),(u,v))
69
def __init__(self,xStart,yStart,xEnd,yEnd,border):
70
self.xStart,self.yStart,self.xEnd,self.yEnd,self.border = xStart,yStart,xEnd,yEnd,border
72
def draw(self,theme,pos,size):
73
u,v,us,vs,b = self.xStart,self.yStart,self.xEnd,self.yEnd,self.border
74
self.drawBlock(theme,pos,size,u,v,us,vs) # center
76
xs,ys = size[0],size[1]
78
self.drawBlock(theme,Vec2(x,y-b),Vec2(xs,b),u,v-b,us,b) # N
79
self.drawBlock(theme,Vec2(x,y+ys),Vec2(xs,b),u,v+vs,us,b) # S
80
self.drawBlock(theme,Vec2(x-b,y),Vec2(b,ys),u-b,v,b,vs) # W
81
self.drawBlock(theme,Vec2(x+xs,y),Vec2(b,ys),u+us+b,v,b,vs) # E
83
self.drawBlock(theme,Vec2(x-b,y-b),Vec2(b,b),u-b,v-b,b,b) # NW
84
self.drawBlock(theme,Vec2(x+xs,y+ys),Vec2(b,b),u+us+b,v+vs,b,b) # SE
85
self.drawBlock(theme,Vec2(x-b,y+ys),Vec2(b,b),u-b,v+vs,b,b) # SW
86
self.drawBlock(theme,Vec2(x+xs,y-b),Vec2(b,b),u+us+b,v-b,b,b) # NW
89
def drawBlock(self,theme,pos,size,u,v,us,vs):
91
xs,ys = size[0],size[1]
100
fixed_us,fixed_vs = us,vs
101
if xFit < 1: fixed_us = xs%us
102
if yFit < 1: fixed_vs = ys%vs
103
theme.rect((xPos,yPos,fixed_us,fixed_vs),(u,v))
109
class TileBarX(TileBorder):
110
def draw(self,theme,pos,size):
111
u,v,us,vs,b = self.xStart,self.yStart,self.xEnd,self.yEnd,self.border
112
self.drawBlock(theme,pos,size,u,v,us,vs) # center
114
xs,ys = size[0],size[1]
115
self.drawBlock(theme,Vec2(x-b,y),Vec2(b,ys),u-b,v,b,vs) # W
116
self.drawBlock(theme,Vec2(x+xs,y),Vec2(b,ys),u+us+b,v,b,vs) # E
120
TEXTURE = "data/guipa2.png"
121
CHECKON = Stretch(360,40,20,20)
122
CHECKOFF = Stretch(400,40,20,20)
123
RADIOON = Stretch(280,40,20,20)
124
RADIOOFF = Stretch(320,40,20,20)
125
PANDA = Tiled(280,80,20,20)
126
INPUT = TileBorder(20,300,180,180,20)
127
FRAME = StretchBorder(20,300,180,180,20)
128
FORM = StretchBorder(20,20,202-20,182-20,20)
129
FRAMEBAR = TileBarX(280,480,140,20,20)
130
BUTTON = Tiled(320,420,20,20)
131
BUTTON = TileBarX(280,480,140,20,20)
132
BUTTON = TileBorder(288,170,490-288,190-170,5)
133
#BUTTON = Tiled(280,80,20,20)
134
#BUTTON = TileBorder(20,20,202-20,182-20,20)
135
DOWN = Tiled(300,160,200,40)
136
TEXTCOLOR = (1,1,1,1)
137
LABLECOLOR = TEXTCOLOR
138
INPUTCOLOR = TEXTCOLOR
144
__builtin__.theme = self
146
self.texture = loader.loadTexture(self.TEXTURE)
147
self.tx = float(self.texture.getXSize())
148
self.ty = float(self.texture.getYSize())
154
self.boxes.append(box)
156
def rect(self,(x,y,xs,ys),(u,v)):
159
self.rectStreatch((x,y,xs,ys),(u,v,us,vs))
161
def rectStreatch(self,(x,y,xs,ys),(u,v,us,vs)):
163
color = Vec4(1,1,1,1)
166
v3 = Vec3(x+xs,z,y+ys)
168
u,v,us,vs = u/self.tx,1-v/self.ty,(u+us)/self.tx,1-(v+vs)/self.ty,
169
self.vertex.addData3f(v1); self.pigment.addData4f(color); self.uv.addData2f(u,v)
170
self.vertex.addData3f(v2); self.pigment.addData4f(color); self.uv.addData2f(us,v)
171
self.vertex.addData3f(v3); self.pigment.addData4f(color); self.uv.addData2f(us,vs)
172
self.vertex.addData3f(v3); self.pigment.addData4f(color); self.uv.addData2f(us,vs)
173
self.vertex.addData3f(v4); self.pigment.addData4f(color); self.uv.addData2f(u,vs)
174
self.vertex.addData3f(v1); self.pigment.addData4f(color); self.uv.addData2f(u,v)
180
def fixZ(self,thing):
182
thing.geom.setBin("fixed",self.z)
184
if "textNode" in thing.__dict__:
185
thing.textNode.setBin("fixed",self.z)
188
def generate(self,box):
189
vdata = GeomVertexData('shadow', GeomVertexFormat.getV3c4t2() , Geom.UHStatic)
190
self.vertex = GeomVertexWriter(vdata, 'vertex')
191
self.pigment = GeomVertexWriter(vdata, 'color')
192
self.uv = GeomVertexWriter(vdata, 'texcoord')
194
color = Vec4(1,1,1,1)
195
name,pos,size,thing = box
197
if not name in self.__class__.__dict__:
199
drawer = self.__class__.__dict__[name]
200
drawer.draw(self,pos,size)
202
prim = GeomTriangles(Geom.UHStatic)
203
for n in range(self.number):
204
prim.addVertices(n*3,n*3+1,n*3+2)
205
prim.closePrimitive()
206
if self.number == 0 :
209
geom.addPrimitive(prim)
211
geomnode = GeomNode('gnode')
212
geomnode.addGeom(geom)
214
guipart = NodePath("guisys%i"%id(self))
215
guipart.setTexture(self.texture)
216
guipart.attachNewNode(geomnode)
217
guipart.setTransparency(True)
218
guipart.setDepthWrite(False)
219
guipart.setDepthTest(False)
220
guipart.setTwoSided(True)
221
guipart.setAttrib(LightAttrib.makeAllOff())
222
guipart.setTexture(self.texture)
223
guipart.setBin("fixed",0)
226
def drawSet(self,boxes):
227
vdata = GeomVertexData('shadow', GeomVertexFormat.getV3c4t2() , Geom.UHStatic)
228
self.vertex = GeomVertexWriter(vdata, 'vertex')
229
self.pigment = GeomVertexWriter(vdata, 'color')
230
self.uv = GeomVertexWriter(vdata, 'texcoord')
232
color = Vec4(1,1,1,1)
235
name,pos,size,thing = box
236
if "textNode" in thing.__dict__:
237
thing.textNode.setY(self.z-.001)
238
if not name in self.__class__.__dict__:
240
drawer = self.__class__.__dict__[name]
241
drawer.draw(self,pos,size)
243
prim = GeomTriangles(Geom.UHStatic)
244
for n in range(self.number):
245
prim.addVertices(n*3,n*3+1,n*3+2)
246
prim.closePrimitive()
248
geom.addPrimitive(prim)
249
geomnode = GeomNode('gnode')
250
geomnode.addGeom(geom)