skin_menu.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. from game import control
  2. from game.algo import rougeGen
  3. from game.file_loader.fileLoader import load_json, load_png, save_encrypt_single_rouge_file, load_rouge_data
  4. import json
  5. import os
  6. import tkinter as tk
  7. from game.const import game as G
  8. from game.const import window as W
  9. from game.const import rouge as R
  10. from datetime import datetime
  11. from game.ui.menu.component import PygameButton, PygameButtonBackIMG, Particle
  12. from game.utils import local_data_manager as DM
  13. current_folder_path = os.getcwd()
  14. class SkinPage:
  15. def __init__(self):
  16. self.screen = W.MENU
  17. user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径
  18. qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径
  19. os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建
  20. self.rouge_achivements_file_path = os.path.join(qqtpve_folder, "rougeOB_achievement.rougedata") # 构建成就文件路径
  21. self.other_file_path = os.path.join(qqtpve_folder, "rougeOBOther.rougedata") # 构建其他文件路径
  22. self.rougeOB_achievements = {}
  23. self.rougeOB_other_data = {}
  24. self.cursor_map = {}
  25. self.current_cursor = None
  26. self.current_bomb = None
  27. self.init_skin_page()
  28. def init_skin_page(self):
  29. has_fire_cursor1 = True
  30. has_fire_cursor2 = False
  31. has_fire_cursor_kubi = False
  32. has_fire_cursor_gold_kubi = False
  33. has_bomb1 = True
  34. has_bomb60 = False
  35. has_bomb1436 = False
  36. DM.init_achievement()
  37. self.rougeOB_achievements = load_rouge_data(self.rouge_achivements_file_path)
  38. def load_achievements_data(self):
  39. max_level = 0
  40. max_diff = "Easy"
  41. max_diff_num = 1
  42. diff_num = {"Easy": 1, "Normal": 2, "Hell": 3, "Hell+": 4}
  43. diff_status = {"Easy": 0, "Normal": 0, "Hell": 0, "Hell+": 0}
  44. max_level = self.rougeOB_achievements["Highest"]["level"]
  45. max_level_hero = self.rougeOB_achievements["Highest"]["hero"]
  46. max_diff = self.rougeOB_achievements["Highest"]["diff"]
  47. self.cursor_map = {
  48. "gold_kubi": (diff_num[max_diff] >= 4 or (diff_num[max_diff] == 3 and max_level >= 15)),
  49. "kubi": (diff_num[max_diff] >= 3 or (diff_num[max_diff] == 2 and max_level >= 15)),
  50. "cursor2": (diff_num[max_diff] >= 2 or (diff_num[max_diff] == 1 and max_level >= 15)),
  51. "cursor1": True,
  52. }
  53. def load_other_data(self):
  54. # 杂项第一次打开
  55. if not os.path.exists(self.other_file_path):
  56. self.rougeOB_other_data = {
  57. "Bomb": [],
  58. "Pet": [],
  59. "Hat": [],
  60. "LastRandom": 0,
  61. "Other": []
  62. }
  63. save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
  64. # 正常打开
  65. else:
  66. self.rougeOB_other_data = load_rouge_data(self.other_file_path)
  67. if 'Cursor_Skin' not in self.rougeOB_other_data.keys():
  68. self.rougeOB_other_data['Cursor_Skin'] = "fire_cursor"
  69. self.current_cursor = "fire_cursor"
  70. save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
  71. else:
  72. self.current_cursor = self.rougeOB_other_data['Cursor_Skin']
  73. if 'Bomb_Skin' not in self.rougeOB_other_data.keys():
  74. self.rougeOB_other_data['Bomb_Skin'] = "bomb1"
  75. self.current_bomb = "bomb1"
  76. save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
  77. else:
  78. self.current_bomb = self.rougeOB_other_data['Bomb_Skin']
  79. self.rougeOB_other_data = self.rougeOB_other_data
  80. print(f"通关次数: {len(self.rougeOB_other_data)}")
  81. if "bomb60" in self.rougeOB_other_data['Bomb']:
  82. has_bomb60 = True
  83. if "bomb1436" in self.rougeOB_other_data['Bomb']:
  84. has_bomb1436 = True
  85. def draw(self):
  86. # 引路人
  87. self.screen.buttons.append(PygameButtonBackIMG(
  88. self.screen, self.screen.screen, 0.5, 0.3, "res/ui/button/cursor.png", "res/ui/button/cursor_press.png", action=self.draw_cursor, anchor='center')
  89. )
  90. # 藏宝阁
  91. self.screen.buttons.append(PygameButtonBackIMG(
  92. self.screen, self.screen.screen, 0.5, 0.45, "res/ui/button/treasure.png", "res/ui/button/treasure_press.png", action=self.draw_treasure, anchor='center')
  93. )
  94. # 返回主界面
  95. self.screen.buttons.append(PygameButtonBackIMG(
  96. self.screen, self.screen.screen, 0.5, 0.6, "res/ui/button/return.png", "res/ui/button/return_press.png", action=self.screen.refresh, anchor='center')
  97. )
  98. def draw_cursor(self):
  99. self.screen.buttons.clear()
  100. self.load_achievements_data()
  101. # 返回主界面
  102. self.screen.buttons.append(PygameButtonBackIMG(
  103. self.screen, self.screen.screen, 0.5, 0.6, "res/ui/button/return.png", "res/ui/button/return_press.png", action=self.screen.refresh, anchor='center')
  104. )
  105. def draw_treasure(self):
  106. self.screen.buttons.clear()
  107. self.load_other_data()
  108. # 返回主界面
  109. self.screen.buttons.append(PygameButtonBackIMG(
  110. self.screen, self.screen.screen, 0.5, 0.6, "res/ui/button/return.png", "res/ui/button/return_press.png", action=self.screen.refresh, anchor='center')
  111. )
  112. """
  113. self.hero_dic= {"Fox": "小倩", "Boboli": "波波丽", "Naruto_old": "火影", "Asha": "阿莎", "Maria": "玛莉亚", "Surprise": "???"}
  114. self.diff_dic = {"Easy": "简单", "Normal": "困难", "Hell": "炼狱", "Hell+": "炼狱+"}
  115. if self.current_bomb == "bomb1":
  116. self.button_bomb = tk.Button(master, text= "(当前选择) \n 糖泡-经典皮肤", bg="#C68E17", font=("Microsoft YaHei", 20))
  117. self.button_bomb.place(relx=0.7, rely=0.15, anchor='w')
  118. elif self.current_bomb == "bomb60":
  119. self.button_bomb = tk.Button(master, text= "(当前选择) \n 糖泡-命运(伤害+50)", bg="#C68E17", font=("Microsoft YaHei", 20))
  120. self.button_bomb.place(relx=0.7, rely=0.15, anchor='w')
  121. elif self.current_bomb == "bomb1436":
  122. self.button_bomb = tk.Button(master, text= "(当前选择) \n 糖泡-深林(生命+150)", bg="#C68E17", font=("Microsoft YaHei", 20))
  123. self.button_bomb.place(relx=0.7, rely=0.15, anchor='w')
  124. self.button100 = tk.Button(master, text= "▶糖泡-经典皮肤", command=self.choose_bomb1, bg="#A23BEC", font=("Microsoft YaHei", 12))
  125. self.button100.place(relx=0.5, rely=0.08, anchor='w')
  126. if has_bomb60:
  127. self.button160 = tk.Button(master, text= "▶糖泡-命运(伤害+50)", command=self.choose_bomb60, bg="#A23BEC", font=("Microsoft YaHei", 12))
  128. self.button160.place(relx=0.5, rely=0.17, anchor='w')
  129. else:
  130. self.button160 = tk.Button(master, text= "(暂未获得) \n 糖泡-命运(伤害+50)", bg="#C6AEC7", font=("Microsoft YaHei", 12))
  131. self.button160.place(relx=0.5, rely=0.17, anchor='w')
  132. if has_bomb1436:
  133. self.button1436 = tk.Button(master, text= "▶糖泡-深林(生命+150)", command=self.choose_bomb1436, bg="#A23BEC", font=("Microsoft YaHei", 12))
  134. self.button1436.place(relx=0.5, rely=0.26, anchor='w')
  135. else:
  136. self.button1436 = tk.Button(master, text= "(暂未获得) \n 糖泡-深林(生命+150)", bg="#C6AEC7", font=("Microsoft YaHei", 12))
  137. self.button1436.place(relx=0.5, rely=0.26, anchor='w')
  138. if self.current_cursor == "fire_cursor":
  139. self.button_total = tk.Button(master, text= "(当前选择) \n 引路人-黄色荧火", bg="#C68E17", font=("Microsoft YaHei", 20))
  140. self.button_total.place(relx=0.25, rely=0.15, anchor='w')
  141. elif self.current_cursor == "fire_cursor2":
  142. self.button_total = tk.Button(master, text= "(当前选择) \n 引路人-森绿荧火", bg="#C68E17", font=("Microsoft YaHei", 20))
  143. self.button_total.place(relx=0.25, rely=0.15, anchor='w')
  144. elif self.current_cursor == "fire_cursor_kubi":
  145. self.button_total = tk.Button(master, text= "(当前选择) \n 引路人-小酷比", bg="#C68E17", font=("Microsoft YaHei", 20))
  146. self.button_total.place(relx=0.25, rely=0.15, anchor='w')
  147. elif self.current_cursor == "fire_cursor_gold_kubi":
  148. self.button_total = tk.Button(master, text= "(当前选择) \n 引路人-金酷比", bg="#C68E17", font=("Microsoft YaHei", 20))
  149. self.button_total.place(relx=0.25, rely=0.15, anchor='w')
  150. self.button0 = tk.Button(master, text= "▶引路人-黄色荧火", command=self.choose_cursor1, bg="#A23BEC", font=("Microsoft YaHei", 12))
  151. self.button0.place(relx=0.05, rely=0.08, anchor='w')
  152. if has_fire_cursor2:
  153. self.button1 = tk.Button(master, text= "▶引路人-森绿荧火", command=self.choose_cursor2, bg="#A23BEC", font=("Microsoft YaHei", 12))
  154. self.button1.place(relx=0.05, rely=0.15, anchor='w')
  155. else:
  156. self.button1 = tk.Button(master, text= "(暂未获得)引路人-森绿荧火(通关简单难度获得)", bg="#C6AEC7", font=("Microsoft YaHei", 12))
  157. self.button1.place(relx=0.05, rely=0.15, anchor='w')
  158. if has_fire_cursor_kubi:
  159. self.button2 = tk.Button(master, text= "▶引路人-小酷比", command=self.choose_cursor3, bg="#A23BEC", font=("Microsoft YaHei", 12))
  160. self.button2.place(relx=0.05, rely=0.22, anchor='w')
  161. else:
  162. self.button2 = tk.Button(master, text= "(暂未获得)引路人-小酷比(通关困难难度获得)", bg="#C6AEC7", font=("Microsoft YaHei", 12))
  163. self.button2.place(relx=0.05, rely=0.22, anchor='w')
  164. if has_fire_cursor_gold_kubi:
  165. self.button3 = tk.Button(master, text= "▶引路人-金酷比", command=self.choose_cursor4, bg="#A23BEC", font=("Microsoft YaHei", 12))
  166. self.button3.place(relx=0.05, rely=0.29, anchor='w')
  167. else:
  168. self.button3 = tk.Button(master, text= "(暂未获得)引路人-金酷比(通关炼狱难度获得)", bg="#C6AEC7", font=("Microsoft YaHei", 12))
  169. self.button3.place(relx=0.05, rely=0.29, anchor='w')
  170. # 返回主界面
  171. self.button000 = tk.Button(master, text= "返回主界面", command=lambda: self.button_return(), bg="#C68E17", font=("Microsoft YaHei", 24))
  172. self.button000.place(relx=0.5, rely=0.8, anchor='center')
  173. # 返回主菜单
  174. def button_return(self):
  175. self.master.destroy()
  176. def choose_cursor1(self):
  177. self.current_cursor = "fire_cursor"
  178. R.cursor_skin = "fire_cursor"
  179. self.rougeOB_other_data['Cursor_Skin'] = "fire_cursor"
  180. save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
  181. self.button_total.config(text = "(当前选择) \n 引路人-黄色荧火")
  182. def choose_cursor2(self):
  183. self.current_cursor = "fire_cursor2"
  184. R.cursor_skin = "fire_cursor2"
  185. self.rougeOB_other_data['Cursor_Skin'] = "fire_cursor2"
  186. save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
  187. self.button_total.config(text = "(当前选择) \n 引路人-森绿荧火")
  188. def choose_cursor3(self):
  189. self.current_cursor = "fire_cursor_kubi"
  190. R.cursor_skin = "fire_cursor_kubi"
  191. self.rougeOB_other_data['Cursor_Skin'] = "fire_cursor_kubi"
  192. save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
  193. self.button_total.config(text = "(当前选择) \n 引路人-小酷比")
  194. def choose_cursor4(self):
  195. self.current_cursor = "fire_cursor_gold_kubi"
  196. R.cursor_skin = "fire_cursor_gold_kubi"
  197. self.rougeOB_other_data['Cursor_Skin'] = "fire_cursor_gold_kubi"
  198. save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
  199. self.button_total.config(text = "(当前选择) \n 引路人-金酷比")
  200. def choose_bomb1(self):
  201. self.current_bomb = "bomb1"
  202. R.bomb_skin = "bomb1"
  203. self.rougeOB_other_data['Bomb_Skin'] = "bomb1"
  204. save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
  205. self.button_bomb.config(text = "(当前选择) \n 糖泡-经典皮肤")
  206. def choose_bomb60(self):
  207. self.current_bomb = "bomb60"
  208. R.bomb_skin = "bomb60"
  209. self.rougeOB_other_data['Bomb_Skin'] = "bomb60"
  210. save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
  211. self.button_bomb.config(text = "(当前选择) \n 糖泡-命运(伤害+50)")
  212. def choose_bomb1436(self):
  213. self.current_bomb = "bomb1436"
  214. R.bomb_skin = "bomb1436"
  215. self.rougeOB_other_data['Bomb_Skin'] = "bomb1436"
  216. save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
  217. self.button_bomb.config(text = "(当前选择) \n 糖泡-深林(生命+150)")
  218. """