task_menu.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import json
  2. import os
  3. from game.const import game as G
  4. from game.const import window as W
  5. from game.const import rouge as R
  6. from datetime import datetime
  7. from game.ui.menu.component import PygameButton, PygameButtonBackIMG, Particle, PygameTaskBoard
  8. from game.const.task import daily_task, weekly_task, monthly_task, single_task
  9. from game.file_loader.fileLoader import load_json, load_png, save_encrypt_single_rouge_file, load_rouge_data
  10. current_folder_path = os.getcwd()
  11. class TaskPage:
  12. def __init__(self):
  13. self.screen = W.MENU
  14. def draw(self):
  15. # 日常任务
  16. self.screen.buttons.append(PygameButtonBackIMG(
  17. self.screen, self.screen.screen, 0.5, 0.25, "res/ui/button/task_daily.png", "res/ui/button/task_daily_press.png", action=self.draw_daily, anchor='center')
  18. )
  19. # 周常任务
  20. self.screen.buttons.append(PygameButtonBackIMG(
  21. self.screen, self.screen.screen, 0.35, 0.4, "res/ui/button/task_weekly.png", "res/ui/button/task_weekly_press.png", action=self.draw_weekly, anchor='center')
  22. )
  23. # 月常任务
  24. self.screen.buttons.append(PygameButtonBackIMG(
  25. self.screen, self.screen.screen, 0.65, 0.4, "res/ui/button/task_monthly.png", "res/ui/button/task_monthly_press.png", action=self.draw_monthly, anchor='center')
  26. )
  27. # 常驻任务
  28. self.screen.buttons.append(PygameButtonBackIMG(
  29. self.screen, self.screen.screen, 0.5, 0.55, "res/ui/button/task_single.png", "res/ui/button/task_single_press.png", action=self.draw_single, anchor='center')
  30. )
  31. # 返回主界面
  32. self.screen.buttons.append(PygameButtonBackIMG(
  33. self.screen, self.screen.screen, 0.66, 0.72, "res/ui/button/return.png", "res/ui/button/return_press.png", action=self.screen.refresh, anchor='center')
  34. )
  35. def draw_daily(self):
  36. self.draw_task_page(daily_task)
  37. def draw_weekly(self):
  38. self.draw_task_page(weekly_task)
  39. def draw_monthly(self):
  40. self.draw_task_page(monthly_task)
  41. def draw_single(self):
  42. self.draw_task_page(single_task)
  43. def draw_task_page(self, task_dic):
  44. self.screen.buttons.clear()
  45. board = PygameTaskBoard(
  46. menu=self.screen,
  47. screen=self.screen.screen,
  48. relx=0.5, rely=0.42,
  49. font_name="hk4e_zh-cn.ttf",
  50. font_size=18,
  51. small_scale=0.8,
  52. default_img_path="res/ui/button/task_board.png",
  53. action=None,
  54. anchor='center',
  55. tasks_dict=task_dic,
  56. bar_color_fg=(129, 89, 146),
  57. row_color=(53, 26, 2),
  58. row_color_disabled=(53, 26, 2),
  59. row_color_done=(32, 67, 42),
  60. padding=(26, 30, 26, 50)
  61. )
  62. self.screen.buttons.append(board)
  63. self.screen.buttons.append(PygameButtonBackIMG(
  64. self.screen, self.screen.screen, 0.12, 0.4, "res/ui/button/left.png", "res/ui/button/left_press.png", action=board.prev_page, anchor='center', shiny_spark=False)
  65. )
  66. self.screen.buttons.append(PygameButtonBackIMG(
  67. self.screen, self.screen.screen, 0.88, 0.4, "res/ui/button/right.png", "res/ui/button/right_press.png", action=board.next_page, anchor='center', shiny_spark=False)
  68. )
  69. self.screen.buttons.append(PygameButtonBackIMG(
  70. self.screen, self.screen.screen, 0.66, 0.86, "res/ui/button/return.png", "res/ui/button/return_press.png", action=self.screen.open_task, anchor='center')
  71. )