Skip to content
Snippets Groups Projects
Commit 33880957 authored by rahix's avatar rahix
Browse files

fix(personal_state): Use simple_menu drawing method

Instead of duplicating the drawing code in the personal state menu,
reuse the method from the parent class.  This reduces code duplication
but most importantly means the personal state app can benefit from fixes
in the "upstream" code.

Concretely, due to the changes related to ctx, this fixes visual
artifacts produced by the "custom" rendering code (black areas to the
right of the text).
parent 54cc7fd3
No related branches found
No related tags found
No related merge requests found
......@@ -26,24 +26,32 @@ class StateMenu(simple_menu.Menu):
personal_state.set(item[1], True)
os.exit()
def entry2name(self, value):
return value[0]
def draw_entry(self, item, index, offset):
if item[1] == personal_state.NO_CONTACT:
bg = color.RED
fg = color.WHITE
self.color_1 = color.RED
self.color_2 = color.RED
self.color_text = color.WHITE
elif item[1] == personal_state.CHAOS:
bg = color.CHAOSBLUE
fg = color.CHAOSBLUE_DARK
self.color_1 = color.CHAOSBLUE
self.color_2 = color.CHAOSBLUE
self.color_text = color.CHAOSBLUE_DARK
elif item[1] == personal_state.COMMUNICATION:
bg = color.COMMYELLOW
fg = color.COMMYELLOW_DARK
self.color_1 = color.COMMYELLOW
self.color_2 = color.COMMYELLOW
self.color_text = color.COMMYELLOW_DARK
elif item[1] == personal_state.CAMP:
bg = color.CAMPGREEN
fg = color.CAMPGREEN_DARK
self.color_1 = color.CAMPGREEN
self.color_2 = color.CAMPGREEN
self.color_text = color.CAMPGREEN_DARK
else:
bg = color.Color(100, 100, 100)
fg = color.Color(200, 200, 200)
self.color_1 = color.Color(100, 100, 100)
self.color_2 = color.Color(100, 100, 100)
self.color_text = color.Color(200, 200, 200)
self.disp.print(" " + str(item[0]) + " " * 9, posy=offset, fg=fg, bg=bg)
super().draw_entry(item, index, offset)
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment