foot_bar.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import GdUI as UI
  2. import skin_manager as SkinManager
  3. class FootBar(UI.FlowContainer):
  4. def __init__(self, width, height):
  5. super().__init__(x=0, y=height - 20, width=width, height=20)
  6. self.set_bgcolor(SkinManager.get_color("white"))
  7. self._topline = UI.Widget(x=0, y=0, width=width, height=1,
  8. bg_color=SkinManager.get_color("line"))
  9. self.add_child(self._topline)
  10. self.set_margin(2)
  11. self.set_top_margin(1)
  12. self._Buttons = {"dpad": UI.Image(image=UI.ImageManager.get_sprite("buttons", 18, 18, 1)),
  13. "a_key": UI.Image(image=UI.ImageManager.get_sprite("buttons", 18, 18, 4)),
  14. "b_key": UI.Image(image=UI.ImageManager.get_sprite("buttons", 18, 18, 5)),
  15. "x_key": UI.Image(image=UI.ImageManager.get_sprite("buttons", 18, 18, 2)),
  16. "y_key": UI.Image(image=UI.ImageManager.get_sprite("buttons", 18, 18, 3))}
  17. self._Labels = {"dpad": UI.Label(text="", font_obj=UI.FontManager.get_font("veramono_12")),
  18. "a_key": UI.Label(text="", font_obj=UI.FontManager.get_font("veramono_12")),
  19. "b_key": UI.Label(text="", font_obj=UI.FontManager.get_font("veramono_12")),
  20. "x_key": UI.Label(text="", font_obj=UI.FontManager.get_font("veramono_12")),
  21. "y_key": UI.Label(text="", font_obj=UI.FontManager.get_font("veramono_12"))}
  22. def set_keyhint(self, dpad=None, a_key=None, b_key=None, x_key=None, y_key=None):
  23. # First clear current lists
  24. self.clear_left_childs()
  25. self.clear_right_childs()
  26. self._Labels["dpad"].set_text(dpad)
  27. self._Labels["a_key"].set_text(a_key)
  28. self._Labels["b_key"].set_text(b_key)
  29. self._Labels["x_key"].set_text(x_key)
  30. self._Labels["y_key"].set_text(y_key)
  31. if dpad is not None:
  32. self.add_left_child(self._Buttons["dpad"])
  33. self.add_left_child(self._Labels["dpad"])
  34. if a_key is not None:
  35. self.add_right_child(self._Buttons["a_key"])
  36. self.add_right_child(self._Labels["a_key"])
  37. if b_key is not None:
  38. self.add_right_child(self._Buttons["b_key"])
  39. self.add_right_child(self._Labels["b_key"])
  40. if x_key is not None:
  41. self.add_right_child(self._Buttons["x_key"])
  42. self.add_right_child(self._Labels["x_key"])
  43. if y_key is not None:
  44. self.add_right_child(self._Buttons["y_key"])
  45. self.add_right_child(self._Labels["y_key"])
  46. def reload(self):
  47. # Do nothing for now, later reload info from skinmanager
  48. pass