-
Notifications
You must be signed in to change notification settings - Fork 1
/
dzuinter.py
179 lines (168 loc) · 6.35 KB
/
dzuinter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/usr/bin/env python
import pygame.event
import pygame.key
import pygame.display
import pygame.image
import pygame.mixer
from pygame.locals import *
import pygame
import sys
import time
import os
import dzulib1 as dzulib
from dzulib1 import textrender
pygame.display.init()
import traceback
import random
import xml.etree.ElementTree as ET
pluglist=[]
def OKpop(info, extra=None, extra2=None):
screensurf=pygame.display.get_surface()
bgrect=pygame.Rect(0, 0, screensurf.get_width()//1.8, 6*uitextsize)
bgrect.centerx=(screensurf.get_width()//2)
bgrect.centery=(screensurf.get_height()//2)
pygame.draw.rect(screensurf, uibgcolor, bgrect)
dzulib.trace3dbox(screensurf, uibgcolor, bgrect, 2)
yoff=bgrect.y+2
yjump=uitextsize
#lineren=simplefont.render(info, True, (255, 255, 255), (30, 30, 30))
lineren=textrender(info, uitextsize, uifgcolor, uibgcolor, 0)
screensurf.blit(lineren, ((screensurf.get_width()//2)-(lineren.get_width()//2), yoff+0))
yoff+=yjump
if extra!=None:
#lineren=simplefont.render(extra, True, (255, 255, 255), (30, 30, 30))
lineren=textrender(extra, uitextsize, uifgcolor, uibgcolor, 0)
screensurf.blit(lineren, ((screensurf.get_width()//2)-(lineren.get_width()//2), yoff+0))
yoff+=yjump
if extra2!=None:
#lineren=simplefont.render(extra2, True, (255, 255, 255), (30, 30, 30))
lineren=textrender(extra2, uitextsize, uifgcolor, uibgcolor, 0)
screensurf.blit(lineren, ((screensurf.get_width()//2)-(lineren.get_width()//2), yoff+0))
yoff+=yjump
#lineren=simplefont.render("Press any key or click to continue", True, (255, 255, 255), (30, 30, 30))
lineren=textrender("Press any key or click to continue", uitextsize, uifgcolor, uibgcolor, 0)
screensurf.blit(lineren, ((screensurf.get_width()//2)-(lineren.get_width()//2), yoff+0))
yoff+=yjump
pygame.display.update()
while True:
time.sleep(0.1)
for event in pygame.event.get():
if event.type == QUIT:
return
if event.type == KEYDOWN:
return
if event.type==MOUSEBUTTONDOWN:
return
def YNpop(info):
screensurf=pygame.display.get_surface()
bgrect=pygame.Rect(0, 0, screensurf.get_width()//1.8, 6*uitextsize)
bgrect.centerx=(screensurf.get_width()//2)
bgrect.centery=(screensurf.get_height()//2)
pygame.draw.rect(screensurf, uibgcolor, bgrect)
dzulib.trace3dbox(screensurf, uibgcolor, bgrect, 2)
yoff=bgrect.y+2
yjump=uitextsize
#lineren=simplefont.render(info, True, (255, 255, 255), (30, 30, 30))
lineren=textrender(info, uitextsize, uifgcolor, uibgcolor, 0)
screensurf.blit(lineren, ((screensurf.get_width()//2)-(lineren.get_width()//2), yoff+0))
yoff+=yjump
#lineren=simplefont.render("(Y)es or (N)o?", True, (255, 255, 255), (30, 30, 30))
lineren=textrender(" (Y)es ", uitextsize, uifgcolor, dzulib.colorboost(uibgcolor, 40), 0)
yesrect=screensurf.blit(lineren, ((screensurf.get_width()//2)-(lineren.get_width()//2), yoff+0))
yoff+=yjump
lineren=textrender(" (N)o ", uitextsize, uifgcolor, dzulib.colorboost(uibgcolor, 40), 0)
norect=screensurf.blit(lineren, ((screensurf.get_width()//2)-(lineren.get_width()//2), yoff+0))
yoff+=yjump
pygame.display.update()
while True:
time.sleep(0.1)
for event in pygame.event.get():
if event.type == QUIT:
return 0
if event.type == KEYDOWN and event.key == K_n:
return 0
if event.type == KEYDOWN and event.key == K_y:
return 1
if event.type==MOUSEBUTTONDOWN:
if yesrect.collidepoint(event.pos):
return 1
if norect.collidepoint(event.pos):
return 0
savepath="save"
def charremove(string, indexq):
if indexq==0:
return string
else:
return (string[:(indexq-1)] + string[(indexq):])
def charinsert(string, char, indexq):
if indexq==0:
return char + string
else:
return (string[:(indexq-1)] + char + string[(indexq-1):])
def fileselect(title):
screensurf=pygame.display.get_surface()
curoffset=0
redraw=1
textstring=""
pathlist=sorted(os.listdir(os.path.join(savepath, '.')), key=str.lower)
while True:
time.sleep(0.1)
if redraw==1:
redraw=0
yoff=2
yjump=uitextsize+1
bgrect=pygame.Rect(0, 50, screensurf.get_width()//2, screensurf.get_height())
bgrect.centerx=(screensurf.get_width()//2)
bgrect.centery=(screensurf.get_height()//2)
yoff=bgrect.y+2
pygame.draw.rect(screensurf, uibgcolor, bgrect)
dzulib.trace3dbox(screensurf, uibgcolor, bgrect, 2)
#pygame.draw.rect(screensurf, (255, 255, 255), bgrect, 1)
#lineren=simplefont.render(title, True, (255, 255, 255), (30, 30, 30))
lineren=textrender(title, uitextsize, uifgcolor, uibgcolor, 0)
screensurf.blit(lineren, ((screensurf.get_width()//2)-(lineren.get_width()//2), yoff+50))
yoff+=yjump
linedict={}
for line in pathlist:
if line.endswith('.sav'):
if line.split(".")[0]==textstring:
lineren=textrender(line, uitextsize, uibgcolor, dzulib.colorboost(uifgcolor, 40), 0)
else:
lineren=textrender(line, uitextsize, uifgcolor, dzulib.colorboost(uibgcolor, 40), 0)
bxrect=screensurf.blit(lineren, ((screensurf.get_width()//2)-(lineren.get_width()//2), yoff+50))
yoff+=yjump
linedict[line.split(".")[0]]=bxrect
#abttextB=simplefont.render(textstring+".sav", True, (255, 255, 255), (40, 40, 40))
abttextB=textrender(textstring+".sav", uitextsize, uibgcolor, dzulib.colorboost(uifgcolor, 40), 0)
pygame.draw.line(screensurf, dzulib.colorboost(uibgcolor, 40), (bgrect.x, yoff+yjump*2), (bgrect.x+bgrect.w, yoff+yjump*2), 2)
screensurf.blit(abttextB, (screensurf.get_width()//2-abttextB.get_width()//2, yoff+yjump*3))
pygame.display.update()
for event in pygame.event.get():
if event.type==MOUSEBUTTONDOWN:
for rectbx in linedict:
if linedict[rectbx].collidepoint(event.pos):
if rectbx==textstring:
return rectbx+".sav"
textstring=rectbx
redraw=1
if not bgrect.collidepoint(event.pos):
return None
if event.type == KEYDOWN and event.key == K_BACKSPACE:
if len(textstring)!=0 and curoffset!=0:
textstring=charremove(textstring, curoffset)
curoffset -= 1
redraw=1
break
elif event.type == KEYDOWN and event.key == K_ESCAPE:
return None
elif event.type == KEYDOWN and event.key == K_RETURN:
if textstring!="":
return textstring+ ".sav"
else:
OKpop("\".sav\" is not a valid name.")
return None
elif event.type == KEYDOWN and event.key != K_TAB:
curoffset += 1
textstring=charinsert(textstring, str(event.unicode), curoffset)
redraw=1
break