foot_bar.py 2.7 KB

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