mirror of
https://github.com/clockworkpi/launcher.git
synced 2025-12-13 02:08:50 +01:00
Merge pull request #83 from follower46/wifi-extended-passwords
Added extended wifi passwords
This commit is contained in:
commit
6966fba1b4
@ -19,10 +19,13 @@ class Textarea:
|
|||||||
_BackgroundColor = pygame.Color(229,229,229)
|
_BackgroundColor = pygame.Color(229,229,229)
|
||||||
_CanvasHWND = None
|
_CanvasHWND = None
|
||||||
_MyWords = []
|
_MyWords = []
|
||||||
|
_BlitWords = []
|
||||||
_FontObj = None
|
_FontObj = None
|
||||||
_LineNumber = 0
|
_LineNumber = 0
|
||||||
|
_TextLimit = 63
|
||||||
_TextFull = False
|
_TextFull = False
|
||||||
_TextIndex = 0
|
_TextIndex = 0
|
||||||
|
_BlitIndex = 0
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
@ -68,32 +71,71 @@ class Textarea:
|
|||||||
else:
|
else:
|
||||||
print("is Full %s" % "".join(self._MyWords))
|
print("is Full %s" % "".join(self._MyWords))
|
||||||
|
|
||||||
|
def BuildBlitText(self):
|
||||||
|
blit_rows = [[]]
|
||||||
|
w = 0
|
||||||
|
xmargin = 5
|
||||||
|
endmargin = 15
|
||||||
|
x = self._PosX+xmargin
|
||||||
|
linenumber = 0
|
||||||
|
cursor_row = 0
|
||||||
|
|
||||||
|
for i, v in enumerate(self._MyWords):
|
||||||
|
t = self._FontObj.render(v, True, (8, 135, 174))
|
||||||
|
t_width = t.get_width()
|
||||||
|
w += t_width
|
||||||
|
del(t)
|
||||||
|
|
||||||
|
blit_rows[linenumber].append(v)
|
||||||
|
|
||||||
|
if i == self._TextIndex - 1:
|
||||||
|
cursor_row = linenumber
|
||||||
|
|
||||||
|
if w + t_width >= self._Width-endmargin:
|
||||||
|
x = self._PosX+xmargin
|
||||||
|
w = 0
|
||||||
|
linenumber += 1
|
||||||
|
blit_rows.append([])
|
||||||
|
|
||||||
|
# only paint 2 rows
|
||||||
|
if len(blit_rows) == 1:
|
||||||
|
self._BlitWords = blit_rows[0]
|
||||||
|
self._BlitIndex = self._TextIndex
|
||||||
|
elif len(blit_rows) == 2 or cursor_row < 2:
|
||||||
|
self._BlitWords = blit_rows[0] + blit_rows[1]
|
||||||
|
self._BlitIndex = self._TextIndex
|
||||||
|
else:
|
||||||
|
self._BlitWords = blit_rows[cursor_row - 1] + blit_rows[cursor_row]
|
||||||
|
self._BlitIndex = self._TextIndex
|
||||||
|
for i,v in enumerate(blit_rows):
|
||||||
|
if i == cursor_row - 1:
|
||||||
|
break
|
||||||
|
self._BlitIndex -= len(v)
|
||||||
|
|
||||||
def BlitText(self):
|
def BlitText(self):
|
||||||
"""
|
"""
|
||||||
blit every single word into surface and calc the width ,check multi line
|
blit every single word into surface and calc the width ,check multi line
|
||||||
"""
|
"""
|
||||||
|
# build up blitwords
|
||||||
|
self.BuildBlitText()
|
||||||
|
|
||||||
w = 0
|
w = 0
|
||||||
xmargin = 5
|
xmargin = 5
|
||||||
endmargin = 15
|
endmargin = 15
|
||||||
x = self._PosX+xmargin
|
x = self._PosX+xmargin
|
||||||
y = self._PosY
|
y = self._PosY
|
||||||
linenumber = 0
|
linenumber = 0
|
||||||
self._TextFull = False
|
self._TextFull = len(self._MyWords) > self._TextLimit
|
||||||
for i,v in enumerate(self._MyWords):
|
for i, v in enumerate(self._BlitWords):
|
||||||
t = self._FontObj.render(v,True,(8,135,174))
|
t = self._FontObj.render(v,True,(8,135,174))
|
||||||
w += t.get_width()
|
w += t.get_width()
|
||||||
|
|
||||||
if w >= self._Width-endmargin and linenumber == 0:
|
if w >= self._Width-endmargin and linenumber == 0:
|
||||||
x = self._PosX+xmargin
|
|
||||||
y = self._PosY+ t.get_height()
|
|
||||||
w = 0
|
|
||||||
linenumber +=1
|
linenumber +=1
|
||||||
|
x = self._PosX+xmargin
|
||||||
|
y = self._PosY + t.get_height() * linenumber
|
||||||
|
w = 0
|
||||||
|
|
||||||
if w >= self._Width-endmargin*4 and linenumber > 0:
|
|
||||||
self._TextFull = True
|
|
||||||
self._CanvasHWND.blit(t, (x,y))
|
|
||||||
break
|
|
||||||
self._CanvasHWND.blit(t, (x,y))
|
self._CanvasHWND.blit(t, (x,y))
|
||||||
x += t.get_width()
|
x += t.get_width()
|
||||||
|
|
||||||
@ -104,7 +146,7 @@ class Textarea:
|
|||||||
x = self._PosX+xmargin
|
x = self._PosX+xmargin
|
||||||
y = self._PosY
|
y = self._PosY
|
||||||
linenumber = 0
|
linenumber = 0
|
||||||
for i,v in enumerate(self._MyWords[:self._TextIndex]):
|
for i,v in enumerate(self._BlitWords[:self._BlitIndex]):
|
||||||
t = self._FontObj.render(v,True,(8,135,174))
|
t = self._FontObj.render(v,True,(8,135,174))
|
||||||
w += t.get_width()
|
w += t.get_width()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user