Fix accidentally overwriting custom colour on exit.
This commit is contained in:
parent
c26f9dbc35
commit
eef900f832
16
__init__.py
16
__init__.py
@ -17,7 +17,7 @@ class Configuration:
|
|||||||
self.strs: list = ['flow3r', '', 'noLang', '', '']
|
self.strs: list = ['flow3r', '', 'noLang', '', '']
|
||||||
self.size: int = 75
|
self.size: int = 75
|
||||||
self.font: int = 5
|
self.font: int = 5
|
||||||
self.colour: int = 0 # (0.5, 0.5, 0.5) # index or tuple
|
self.colour: int = (1.0, 1.0, 1.0)
|
||||||
self.delay: int = 8
|
self.delay: int = 8
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -43,10 +43,7 @@ class Configuration:
|
|||||||
res.size = data["size"]
|
res.size = data["size"]
|
||||||
if "font" in data and type(data["font"]) == int:
|
if "font" in data and type(data["font"]) == int:
|
||||||
res.font = data["font"]
|
res.font = data["font"]
|
||||||
if "color" in data:
|
if "color" in data and type(data["color"]) == str and len(data["color"]) == 7 and data["color"][0] == '#':
|
||||||
if type(data["color"]) == int:
|
|
||||||
res.colour = data["color"]
|
|
||||||
if type(data["color"]) == str and len(data["color"]) == 7 and data["color"][0] == '#':
|
|
||||||
res.colour = (
|
res.colour = (
|
||||||
int(data["color"][1:3], 16)/256.0,
|
int(data["color"][1:3], 16)/256.0,
|
||||||
int(data["color"][3:5], 16)/256.0,
|
int(data["color"][3:5], 16)/256.0,
|
||||||
@ -55,10 +52,11 @@ class Configuration:
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def save(self, path: str) -> None:
|
def save(self, path: str) -> None:
|
||||||
|
colourstr: str = '#' + hex(int(255*self.colour[0]))[2:4] + hex(int(255*self.colour[1]))[2:4] + hex(int(255*self.colour[2]))[2:4]
|
||||||
d = {
|
d = {
|
||||||
"size": self.size,
|
"size": self.size,
|
||||||
"font": self.font,
|
"font": self.font,
|
||||||
"color": self.colour if type(self.colour) == int else 0,
|
"color": colourstr,
|
||||||
"delay": self.delay,
|
"delay": self.delay,
|
||||||
}
|
}
|
||||||
for i in range(len(self.hdrs)):
|
for i in range(len(self.hdrs)):
|
||||||
@ -85,11 +83,7 @@ class SensibleNickApp(Application):
|
|||||||
self._en_iter_pressed = False
|
self._en_iter_pressed = False
|
||||||
self._filename = "/flash/nick.json"
|
self._filename = "/flash/nick.json"
|
||||||
self._config = Configuration.load(self._filename)
|
self._config = Configuration.load(self._filename)
|
||||||
self._colours: list = [GO_GREEN, PUSH_RED, WHITE]
|
self._colours: list = [GO_GREEN, PUSH_RED, self._config.colour]
|
||||||
if type(self._config.colour) == int:
|
|
||||||
self._en_colour = self._config.colour
|
|
||||||
else:
|
|
||||||
self._colours[2] = self._config.colour
|
|
||||||
self._en_colour = 2
|
self._en_colour = 2
|
||||||
self.varprint: list(str) = [str for str in self._config.strs if len(str) > 0]
|
self.varprint: list(str) = [str for str in self._config.strs if len(str) > 0]
|
||||||
|
|
||||||
|
@ -10,4 +10,4 @@ author = "Anna_updn, Flow3r Badge Authors"
|
|||||||
license = "LGPL-3.0-only"
|
license = "LGPL-3.0-only"
|
||||||
url = "https://git.flow3r.garden/updn/sensiblenickapp"
|
url = "https://git.flow3r.garden/updn/sensiblenickapp"
|
||||||
description = "A sensible nickname app using touch to show up to 5 strings with some quality of life features."
|
description = "A sensible nickname app using touch to show up to 5 strings with some quality of life features."
|
||||||
version = 1
|
version = 2
|
||||||
|
Loading…
Reference in New Issue
Block a user