Save modified characters in project data
This commit is contained in:
parent
0a3be7ef55
commit
cde9c3485f
29
canvas.py
29
canvas.py
@ -68,10 +68,36 @@ class EditorCanvas(tkinter.Canvas):
|
|||||||
|
|
||||||
|
|
||||||
def save_char(self):
|
def save_char(self):
|
||||||
pass
|
if not self.current_char_modified:
|
||||||
|
return
|
||||||
|
|
||||||
|
empty=True
|
||||||
|
for x in range(len(self.current_char_pixels)):
|
||||||
|
if self.current_char_pixels[x]>0:
|
||||||
|
empty=False
|
||||||
|
break
|
||||||
|
if empty:
|
||||||
|
if self.project.does_char_exist(self.current_char):
|
||||||
|
del(self.project.chars[chr(self.current_char)])
|
||||||
|
return
|
||||||
|
|
||||||
|
packed_data=[]
|
||||||
|
bit_counter=0
|
||||||
|
current_value=0
|
||||||
|
for pixel in self.current_char_pixels:
|
||||||
|
current_value|=pixel
|
||||||
|
if bit_counter==8:
|
||||||
|
packed_data.append(current_value)
|
||||||
|
bit_counter=0
|
||||||
|
current_value=0
|
||||||
|
current_value<<=1
|
||||||
|
bit_counter+=1
|
||||||
|
|
||||||
|
self.project.chars[chr(self.current_char)]=base64.b64encode(bytes(packed_data)).decode("ascii")
|
||||||
|
|
||||||
|
|
||||||
def prev_glyph(self):
|
def prev_glyph(self):
|
||||||
|
self.save_char()
|
||||||
self.current_char-=1
|
self.current_char-=1
|
||||||
self.keep_current_char_in_bounds()
|
self.keep_current_char_in_bounds()
|
||||||
self.load_char()
|
self.load_char()
|
||||||
@ -79,6 +105,7 @@ class EditorCanvas(tkinter.Canvas):
|
|||||||
|
|
||||||
|
|
||||||
def next_glyph(self):
|
def next_glyph(self):
|
||||||
|
self.save_char()
|
||||||
self.current_char+=1
|
self.current_char+=1
|
||||||
self.keep_current_char_in_bounds()
|
self.keep_current_char_in_bounds()
|
||||||
self.load_char()
|
self.load_char()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user