| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- import json
- import os
- from datetime import datetime
- import tkinter as tk
- from game.const import game as G
- from game.const import window as W
- from game.const import rouge as R
- from game.sound import sound_player
- from game.utils import local_data_manager as DM
- from game import control
- from game.algo import rougeGen
- from game.file_loader.fileLoader import load_json, load_png, save_encrypt_single_rouge_file, load_rouge_data
- from game.ui.menu.component import PygameButton, PygameButtonBackIMG, PygameButtonBackIMGRoll, Particle
- current_folder_path = os.getcwd()
- cursor_cn = {
- "引路人-黄色荧火": "fire_cursor1",
- "引路人-森绿荧火": "fire_cursor2",
- "引路人-小酷比": "fire_cursor_kubi",
- "引路人-金酷比": "fire_cursor_gold_kubi",
- }
- cursor_dict = {
- "fire_cursor1": {"own": True, "name": "引路人-黄色荧火", "info": "原初的黄色荧火,为旅者指引前路", "condition": "初始拥有"},
- "fire_cursor2": {"own": False, "name": "引路人-森绿荧火", "info": "俏皮的森绿荧火,为旅者指引前路", "condition": "通关简单难度获得"},
- "fire_cursor_kubi": {"own": False, "name": "引路人-小酷比", "info": "顽皮的小酷比,为旅者指引前路", "condition": "通关困难难度获得"},
- "fire_cursor_gold_kubi": {"own": False, "name": "引路人-金酷比", "info": "稀有的金酷比,为旅者指引前路", "condition": "通关炼狱难度获得"},
- }
- cursor_list = ["引路人-黄色荧火", "引路人-森绿荧火", "引路人-小酷比", "引路人-金酷比"]
- bomb_dict = {
- "bomb1": True,
- "bomb60": False,
- "bomb1436": False,
- }
- class SkinPage:
- def __init__(self):
- self.screen = W.MENU
- user_documents_folder = os.path.expanduser("~\\Documents") # 获取用户的"文档"文件夹路径
- qqtpve_folder = os.path.join(user_documents_folder, "QQTPVE") # 构建QQTPVE文件夹路径
- os.makedirs(qqtpve_folder, exist_ok=True) # 确保QQTPVE文件夹存在,如果不存在则创建
- self.rouge_achivements_file_path = os.path.join(qqtpve_folder, "rougeOB_achievement.rougedata") # 构建成就文件路径
- self.other_file_path = os.path.join(qqtpve_folder, "rougeOBOther.rougedata") # 构建其他文件路径
- self.rougeOB_achievements = {}
- self.rougeOB_other_data = {}
- self.cursor_map = {}
- self.current_cursor = None
- self.view_cursor = None
- self.current_bomb = None
- self.init_skin_page()
- def init_skin_page(self):
- DM.init_achievement()
- self.rougeOB_achievements = load_rouge_data(self.rouge_achivements_file_path)
- def load_achievements_data(self):
- global cursor_dict
- max_level = 0
- max_diff = "Easy"
- max_diff_num = 1
- diff_num = {"Easy": 1, "Normal": 2, "Hell": 3, "Hell+": 4}
- diff_status = {"Easy": 0, "Normal": 0, "Hell": 0, "Hell+": 0}
- max_level = self.rougeOB_achievements["Highest"]["level"]
- max_level_hero = self.rougeOB_achievements["Highest"]["hero"]
- max_diff = self.rougeOB_achievements["Highest"]["diff"]
- cursor_dict["fire_cursor_gold_kubi"]["own"] = (diff_num[max_diff] >= 4 or (diff_num[max_diff] == 3 and max_level >= 15))
- cursor_dict["fire_cursor_kubi"]["own"] = (diff_num[max_diff] >= 3 or (diff_num[max_diff] == 2 and max_level >= 15))
- cursor_dict["fire_cursor2"]["own"] = (diff_num[max_diff] >= 2 or (diff_num[max_diff] == 1 and max_level >= 15))
- cursor_dict["fire_cursor1"]["own"] = True
- def load_other_data(self):
- # 杂项第一次打开
- if not os.path.exists(self.other_file_path):
- self.rougeOB_other_data = {
- "Bomb": [],
- "Pet": [],
- "Hat": [],
- "LastRandom": 0,
- "Other": []
- }
- save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
- # 正常打开
- else:
- self.rougeOB_other_data = load_rouge_data(self.other_file_path)
- # 读取引路人
- if 'Cursor_Skin' not in self.rougeOB_other_data.keys():
- self.rougeOB_other_data['Cursor_Skin'] = "fire_cursor"
- self.current_cursor = "fire_cursor"
- save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
- else:
- self.current_cursor = self.rougeOB_other_data['Cursor_Skin']
- self.view_cursor = self.current_cursor
- # 读取糖泡皮肤
- if 'Bomb_Skin' not in self.rougeOB_other_data.keys():
- self.rougeOB_other_data['Bomb_Skin'] = "bomb1"
- self.current_bomb = "bomb1"
- save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
- else:
- self.current_bomb = self.rougeOB_other_data['Bomb_Skin']
- print(f"rougeOB_other_data: {self.rougeOB_other_data}")
- if "bomb60" in self.rougeOB_other_data['Bomb']:
- has_bomb60 = True
- if "bomb1436" in self.rougeOB_other_data['Bomb']:
- has_bomb1436 = True
- def draw(self):
- # 引路人
- self.screen.buttons.append(PygameButtonBackIMG(
- 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')
- )
- # 藏宝阁
- self.screen.buttons.append(PygameButtonBackIMG(
- 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')
- )
- # 返回主界面
- self.screen.buttons.append(PygameButtonBackIMG(
- 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')
- )
- def draw_cursor(self):
- self.screen.buttons.clear()
- self.load_achievements_data()
- self.load_other_data()
- # ================================= 信息展示 =================================
- info_button = PygameButton(
- self.screen.screen, "", 0.5, 0.56, 18, "#2a2a2a",
- fg_color=(215,220,217), action=None,
- anchor="center", is_bold=True, fix_shape=(320,80), bg_alpha=159,
- frosted_glass=True, blur_radius=8, glass_alpha=8, background=self.screen
- )
- # ================================= 选择 =================================
- choose_button = PygameButtonBackIMG(
- self.screen, self.screen.screen, 0.34, 0.72, "res/ui/button/choose.png", "res/ui/button/choose_press.png",
- action=None, anchor='center'
- )
- # ================================= 展示框 =================================
- cy = 0.29
- button_blank = 0.13
- roll_button = PygameButtonBackIMGRoll(
- self.screen, self.screen.screen, 0.5, cy, "res/ui/button/cursor_board.png", cursor_list,
- action=None, roll_action=None, hover_in_action=None, hover_out_action=None,
- anchor='center', font_name="hk4e_zh-cn.ttf", font_size=24, small_scale=0.7, small_alpha=159, color=(0, 0, 0), shiny_spark=False,
- related_button=[info_button, choose_button],
- notify_action=[lambda x: cursor_update_notify(roll_button, x, self.current_cursor), lambda _: self.update_choose_btn(roll_button, choose_button, info_button)]
- )
- # ================================= 初始化 =================================
- choose_button.action = lambda: self.choose_cursor(roll_button, info_button, choose_button) # 追加action
- roll_button.set_current_text(cursor_dict[self.current_cursor]["name"])
- cursor_update_notify(roll_button, info_button, self.current_cursor)
- self.update_choose_btn(roll_button, choose_button, info_button)
- # ================================= 添加按钮 =================================
- self.screen.buttons.append(info_button)
- self.screen.buttons.append(choose_button)
- self.screen.buttons.append(roll_button)
- # ================================= 上翻页 =================================
- self.screen.buttons.append(PygameButtonBackIMG(
- self.screen, self.screen.screen, 0.5, cy-button_blank, "res/ui/button/up.png", "res/ui/button/up_press.png", action=roll_button.roll_up, anchor='center', shiny_spark=False)
- )
- # ================================= 下翻页 =================================
- self.screen.buttons.append(PygameButtonBackIMG(
- self.screen, self.screen.screen, 0.5, cy+button_blank, "res/ui/button/down.png", "res/ui/button/down_press.png", action=roll_button.roll_down, anchor='center', shiny_spark=False)
- )
- # ================================= 返回上一级 =================================
- self.screen.buttons.append(PygameButtonBackIMG(
- self.screen, self.screen.screen, 0.66, 0.72, "res/ui/button/return.png", "res/ui/button/return_press.png", action=self.screen.open_setting, anchor='center')
- )
- def draw_treasure(self):
- self.screen.buttons.clear()
- self.load_other_data()
- # 返回主界面
- self.screen.buttons.append(PygameButtonBackIMG(
- self.screen, self.screen.screen, 0.66, 0.72, "res/ui/button/return.png", "res/ui/button/return_press.png", action=self.screen.open_setting, anchor='center')
- )
- """
- self.hero_dic= {"Fox": "小倩", "Boboli": "波波丽", "Naruto_old": "火影", "Asha": "阿莎", "Maria": "玛莉亚", "Surprise": "???"}
- self.diff_dic = {"Easy": "简单", "Normal": "困难", "Hell": "炼狱", "Hell+": "炼狱+"}
-
- if self.current_bomb == "bomb1":
- self.button_bomb = tk.Button(master, text= "(当前选择) \n 糖泡-经典皮肤", bg="#C68E17", font=("Microsoft YaHei", 20))
- self.button_bomb.place(relx=0.7, rely=0.15, anchor='w')
- elif self.current_bomb == "bomb60":
- self.button_bomb = tk.Button(master, text= "(当前选择) \n 糖泡-命运(伤害+50)", bg="#C68E17", font=("Microsoft YaHei", 20))
- self.button_bomb.place(relx=0.7, rely=0.15, anchor='w')
- elif self.current_bomb == "bomb1436":
- self.button_bomb = tk.Button(master, text= "(当前选择) \n 糖泡-深林(生命+150)", bg="#C68E17", font=("Microsoft YaHei", 20))
- self.button_bomb.place(relx=0.7, rely=0.15, anchor='w')
- self.button100 = tk.Button(master, text= "▶糖泡-经典皮肤", command=self.choose_bomb1, bg="#A23BEC", font=("Microsoft YaHei", 12))
- self.button100.place(relx=0.5, rely=0.08, anchor='w')
- if has_bomb60:
- self.button160 = tk.Button(master, text= "▶糖泡-命运(伤害+50)", command=self.choose_bomb60, bg="#A23BEC", font=("Microsoft YaHei", 12))
- self.button160.place(relx=0.5, rely=0.17, anchor='w')
- else:
- self.button160 = tk.Button(master, text= "(暂未获得) \n 糖泡-命运(伤害+50)", bg="#C6AEC7", font=("Microsoft YaHei", 12))
- self.button160.place(relx=0.5, rely=0.17, anchor='w')
- if has_bomb1436:
- self.button1436 = tk.Button(master, text= "▶糖泡-深林(生命+150)", command=self.choose_bomb1436, bg="#A23BEC", font=("Microsoft YaHei", 12))
- self.button1436.place(relx=0.5, rely=0.26, anchor='w')
- else:
- self.button1436 = tk.Button(master, text= "(暂未获得) \n 糖泡-深林(生命+150)", bg="#C6AEC7", font=("Microsoft YaHei", 12))
- self.button1436.place(relx=0.5, rely=0.26, anchor='w')
- def choose_bomb1(self):
- self.current_bomb = "bomb1"
- R.bomb_skin = "bomb1"
- self.rougeOB_other_data['Bomb_Skin'] = "bomb1"
- save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
- self.button_bomb.config(text = "(当前选择) \n 糖泡-经典皮肤")
- def choose_bomb60(self):
- self.current_bomb = "bomb60"
- R.bomb_skin = "bomb60"
- self.rougeOB_other_data['Bomb_Skin'] = "bomb60"
- save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
- self.button_bomb.config(text = "(当前选择) \n 糖泡-命运(伤害+50)")
- def choose_bomb1436(self):
- self.current_bomb = "bomb1436"
- R.bomb_skin = "bomb1436"
- self.rougeOB_other_data['Bomb_Skin'] = "bomb1436"
- save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
- self.button_bomb.config(text = "(当前选择) \n 糖泡-深林(生命+150)")
- """
- def choose_cursor(self, roll_btn: PygameButtonBackIMGRoll, info_button, choose_btn):
- cn_name = roll_btn.get_current_text()
- current = cursor_cn[cn_name]
- self.current_cursor = current
- R.cursor_skin = current
- self.rougeOB_other_data['Cursor_Skin'] = current
- save_encrypt_single_rouge_file(self.rougeOB_other_data, "rougeOBOther")
- roll_btn.set_current_text(cursor_dict[self.current_cursor]["name"])
- cursor_update_notify(roll_btn, info_button, self.current_cursor)
- choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
- choose_btn.shiny_spark = False
- choose_btn.action = None
- def update_choose_btn(self, roll_button, choose_btn, info_button):
- # 拿到当前展示的中文名
- cn_name = roll_button.get_current_text()
- # 拿到内部 key
- key = cursor_cn[cn_name]
- # 拿到是否已解锁
- owned = cursor_dict[key]["own"]
- if owned:
- if self.current_cursor == key:
- choose_btn.update_image("res/ui/button/chosen.png", "res/ui/button/chosen.png")
- choose_btn.shiny_spark = False
- choose_btn.action = None
- else:
- choose_btn.update_image("res/ui/button/choose.png", "res/ui/button/choose_press.png")
- choose_btn.shiny_spark = True
- choose_btn.action = lambda cn=cn_name: self.choose_cursor(roll_button, info_button, choose_btn)
- else:
- choose_btn.update_image("res/ui/button/unlock.png", "res/ui/button/unlock.png")
- choose_btn.shiny_spark = False
- choose_btn.action = None
- def cursor_update_notify(board: PygameButtonBackIMGRoll, observer: PygameButton, chosen):
- cn_name = board.get_current_text()
- current = cursor_cn[cn_name]
- is_chosen = "<当前选择>" if (current == chosen) else ""
- owned = "已拥有" if cursor_dict[current]["own"] else "未解锁"
- info = cursor_dict[current]["info"]
- condition = cursor_dict[current]["condition"]
- observer.set_text(f" {is_chosen}{cn_name} \n {info} \n {condition}({owned}) ")
|