吾今有世家存档修改器 Python版本

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
吾今有世家游戏存档修改器
用于修改GameData.es3文件中的游戏数据

作者: SnowZ
版本: 2.3.1
日期: 2025
"""

import json
import tkinter as tk
from tkinter import ttk, filedialog, messagebox, scrolledtext
import os
import shutil
from datetime import datetime

class SaveEditor:
    """
    游戏存档修改器主类
    提供图形界面来修改ES3格式的存档文件
    """
    
    def __init__(self):
        """
        初始化修改器界面和数据
        """
        self.root = tk.Tk()
        self.root.title("吾今有世家 - 游戏存档修改器 v2.3.1")
        self.root.geometry("1200x800")
        self.root.resizable(True, True)
        
        # 存档数据
        self.game_data = None
        self.save_file_path = ""
        
        # 创建界面
        self.create_widgets()
        
        # 尝试自动加载当前目录的GameData.es3
        default_save = os.path.join(os.getcwd(), "GameData.es3")
        if os.path.exists(default_save):
            self.load_save_file(default_save)
    
    def create_widgets(self):
        """
        创建主界面组件
        """
        # 创建菜单栏
        self.create_menu()
        
        # 创建主框架
        main_frame = ttk.Frame(self.root)
        main_frame.pack(fill=tk.BOTH, expand=True, padx=10, pady=5)
        
        # 创建选项卡控件
        self.notebook = ttk.Notebook(main_frame)
        self.notebook.pack(fill=tk.BOTH, expand=True)
        
        # 创建各个功能选项卡
        self.create_character_tab()      # 人物信息
        self.create_family_tab()         # 家族信息
        self.create_noble_tab()          # 世家信息
        self.create_fief_tab()           # 封地信息
        self.create_military_tab()       # 军事信息
        self.create_economy_tab()        # 经济信息
        self.create_raw_data_tab()       # 原始数据
        
        # 状态栏
        self.status_var = tk.StringVar()
        self.status_var.set("就绪 - 请加载存档文件")
        status_bar = ttk.Label(main_frame, textvariable=self.status_var, relief=tk.SUNKEN)
        status_bar.pack(side=tk.BOTTOM, fill=tk.X, pady=(5, 0))
    
    def create_menu(self):
        """
        创建菜单栏
        """
        menubar = tk.Menu(self.root)
        self.root.config(menu=menubar)
        
        # 文件菜单
        file_menu = tk.Menu(menubar, tearoff=0)
        menubar.add_cascade(label="文件(F)", menu=file_menu)
        file_menu.add_command(label="打开存档(O)", command=self.open_save_file, accelerator="Ctrl+O")
        file_menu.add_command(label="保存存档(S)", command=self.save_file, accelerator="Ctrl+S")
        file_menu.add_command(label="另存为(A)", command=self.save_as_file, accelerator="Ctrl+Shift+S")
        file_menu.add_separator()
        file_menu.add_command(label="备份存档(B)", command=self.backup_save_file)
        file_menu.add_separator()
        file_menu.add_command(label="退出(X)", command=self.root.quit)
        
        # 工具菜单
        tools_menu = tk.Menu(menubar, tearoff=0)
        menubar.add_cascade(label="工具(T)", menu=tools_menu)
        tools_menu.add_command(label="验证数据完整性", command=self.validate_data)
        tools_menu.add_command(label="重置所有修改", command=self.reset_all_changes)
        
        # 帮助菜单
        help_menu = tk.Menu(menubar, tearoff=0)
        menubar.add_cascade(label="帮助(H)", menu=help_menu)
        help_menu.add_command(label="使用说明", command=self.show_help)
        help_menu.add_command(label="关于", command=self.show_about)
        
        # 绑定快捷键
        self.root.bind('<Control-o>', lambda e: self.open_save_file())
        self.root.bind('<Control-s>', lambda e: self.save_file())
        self.root.bind('<Control-Shift-S>', lambda e: self.save_as_file())
    
    def create_character_tab(self):
        """
        创建人物信息修改选项卡
        """
        char_frame = ttk.Frame(self.notebook)
        self.notebook.add(char_frame, text="人物信息")
        
        # 创建子选项卡
        char_notebook = ttk.Notebook(char_frame)
        char_notebook.pack(fill=tk.BOTH, expand=True, padx=5, pady=5)
        
        # 家主信息
        self.create_family_master_tab(char_notebook)
        
        # 门客信息
        self.create_retainer_tab(char_notebook)
        
        # 寒门官员信息
        self.create_official_tab(char_notebook)
    
    def create_family_master_tab(self, parent):
        """
        创建家主信息选项卡
        """
        master_frame = ttk.Frame(parent)
        parent.add(master_frame, text="家主信息")
        
        # 家主信息组
        master_group = ttk.LabelFrame(master_frame, text="家主基本信息")
        master_group.pack(fill=tk.X, padx=10, pady=10)
        
        # 创建输入字段
        self.master_fields = {}
        fields = [
            ("人物编号:", "member_first_id"),
            ("姓名:", "member_first_name"),
            ("人物形象:", "member_first_image"),
            ("年龄:", "member_first_age")
        ]
        
        for i, (label_text, field_key) in enumerate(fields):
            row = i // 2
            col = (i % 2) * 2
            
            ttk.Label(master_group, text=label_text).grid(row=row, column=col, sticky=tk.W, padx=5, pady=5)
            entry = ttk.Entry(master_group, width=20)
            entry.grid(row=row, column=col+1, sticky=tk.W, padx=5, pady=5)
            self.master_fields[field_key] = entry
    
    def create_retainer_tab(self, parent):
        """
        创建门客信息选项卡
        """
        retainer_frame = ttk.Frame(parent)
        parent.add(retainer_frame, text="门客信息")
        
        # 创建树形视图显示门客列表
        columns = ("编号", "姓名", "年龄", "文", "武", "商", "艺", "心情", "酬劳")
        self.retainer_tree = ttk.Treeview(retainer_frame, columns=columns, show='headings', height=15)
        
        # 设置列标题
        for col in columns:
            self.retainer_tree.heading(col, text=col)
            self.retainer_tree.column(col, width=80)
        
        # 添加滚动条
        retainer_scroll = ttk.Scrollbar(retainer_frame, orient=tk.VERTICAL, command=self.retainer_tree.yview)
        self.retainer_tree.configure(yscrollcommand=retainer_scroll.set)
        
        # 布局
        self.retainer_tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=(10, 0), pady=10)
        retainer_scroll.pack(side=tk.RIGHT, fill=tk.Y, padx=(0, 10), pady=10)
        
        # 绑定双击事件
        self.retainer_tree.bind('<Double-1>', self.edit_retainer)
    
    def create_official_tab(self, parent):
        """
        创建寒门官员信息选项卡
        """
        official_frame = ttk.Frame(parent)
        parent.add(official_frame, text="寒门官员")
        
        # 创建树形视图显示官员列表
        columns = ("编号", "形象", "基本信息", "年龄", "文", "武", "商", "艺")
        self.official_tree = ttk.Treeview(official_frame, columns=columns, show='headings', height=15)
        
        # 设置列标题
        for col in columns:
            self.official_tree.heading(col, text=col)
            self.official_tree.column(col, width=100)
        
        # 添加滚动条
        official_scroll = ttk.Scrollbar(official_frame, orient=tk.VERTICAL, command=self.official_tree.yview)
        self.official_tree.configure(yscrollcommand=official_scroll.set)
        
        # 布局
        self.official_tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=(10, 0), pady=10)
        official_scroll.pack(side=tk.RIGHT, fill=tk.Y, padx=(0, 10), pady=10)
    
    def create_family_tab(self):
        """
        创建家族信息选项卡
        """
        family_frame = ttk.Frame(self.notebook)
        self.notebook.add(family_frame, text="家族信息")
        
        # 创建子选项卡
        family_sub_notebook = ttk.Notebook(family_frame)
        family_sub_notebook.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
        
        # 家族基本信息选项卡
        self.create_family_basic_tab(family_sub_notebook)
        
        # 家主信息选项卡
        self.create_family_master_tab(family_sub_notebook)
        
        # 家族成员信息选项卡(妻妾赘婿)
        self.create_family_members_tab(family_sub_notebook)
    
    def create_family_basic_tab(self, parent):
        """
        创建家族基本信息选项卡
        """
        basic_frame = ttk.Frame(parent)
        parent.add(basic_frame, text="家族基本信息")
        
        # 家族基本信息
        family_info = ttk.LabelFrame(basic_frame, text="家族基本信息")
        family_info.pack(fill=tk.X, padx=10, pady=10)
        
        self.family_fields = {}
        family_fields = [
            ("家族位置(郡|县):", "family_location"),
            ("家族姓氏:", "family_surname"),
            ("家族等级:", "family_level"),
            ("经验值:", "family_exp"),
            ("朝廷影响:", "family_influence"),
            ("仓库容量:", "warehouse_capacity")
        ]
        
        for i, (label_text, field_key) in enumerate(family_fields):
            row = i // 3
            col = (i % 3) * 2
            ttk.Label(family_info, text=label_text).grid(row=row, column=col, sticky=tk.W, padx=5, pady=5)
            entry = ttk.Entry(family_info, width=15)
            entry.grid(row=row, column=col+1, sticky=tk.W, padx=5, pady=5)
            self.family_fields[field_key] = entry
        
        # 经济信息
        economy_info = ttk.LabelFrame(basic_frame, text="经济信息")
        economy_info.pack(fill=tk.X, padx=10, pady=10)
        
        self.economy_fields = {}
        economy_fields = [
            ("铜钱数量:", "copper_money"),
            ("元宝数量:", "gold_money"),
            ("月收入:", "monthly_income")
        ]
        
        for i, (label_text, field_key) in enumerate(economy_fields):
            ttk.Label(economy_info, text=label_text).grid(row=0, column=i*2, sticky=tk.W, padx=5, pady=5)
            entry = ttk.Entry(economy_info, width=15)
            entry.grid(row=0, column=i*2+1, sticky=tk.W, padx=5, pady=5)
            self.economy_fields[field_key] = entry
        
        # 保存按钮
        button_frame = ttk.Frame(basic_frame)
        button_frame.pack(fill=tk.X, padx=10, pady=10)
        ttk.Button(button_frame, text="保存家族信息", command=self.save_family_data).pack(side=tk.LEFT, padx=5)
        ttk.Button(button_frame, text="保存经济信息", command=self.save_economy_data).pack(side=tk.LEFT, padx=5)
    
    def create_family_members_tab(self, parent):
        """
        创建家族成员信息选项卡(妻妾赘婿)
        """
        members_frame = ttk.Frame(parent)
        parent.add(members_frame, text="家族成员(妻妾赘婿)")
        
        # 家族成员列表
        members_list_group = ttk.LabelFrame(members_frame, text="家族成员列表")
        members_list_group.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
        
        # 创建家族成员列表树形视图
        member_columns = ("编号", "姓名", "年龄", "性别", "文", "武", "商", "艺", "心情", "健康", "魅力", "关系")
        self.family_members_tree = ttk.Treeview(members_list_group, columns=member_columns, show='headings', height=15)
        
        for col in member_columns:
            self.family_members_tree.heading(col, text=col)
            self.family_members_tree.column(col, width=80)
        
        members_scroll = ttk.Scrollbar(members_list_group, orient=tk.VERTICAL, command=self.family_members_tree.yview)
        self.family_members_tree.configure(yscrollcommand=members_scroll.set)
        
        self.family_members_tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=(5, 0), pady=5)
        members_scroll.pack(side=tk.RIGHT, fill=tk.Y, padx=(0, 5), pady=5)
        
        # 绑定双击编辑事件
        self.family_members_tree.bind('<Double-1>', self.edit_family_member)
        
        # 保存按钮
        save_members_btn = ttk.Button(members_list_group, text="保存家族成员信息", command=self.save_family_members_data)
        save_members_btn.pack(pady=5)
    
    def create_noble_tab(self):
        """
        创建世家信息选项卡
        """
        noble_frame = ttk.Frame(self.notebook)
        self.notebook.add(noble_frame, text="世家信息")
        
        # 皇室信息
        royal_group = ttk.LabelFrame(noble_frame, text="皇室信息")
        royal_group.pack(fill=tk.X, padx=10, pady=10)
        
        self.royal_fields = {}
        royal_fields = [
            ("皇族姓氏:", "royal_name"),
            ("关系:", "royal_relation"),
            ("好感度:", "royal_favor")
        ]
        
        for i, (label_text, field_key) in enumerate(royal_fields):
            ttk.Label(royal_group, text=label_text).grid(row=0, column=i*2, sticky=tk.W, padx=5, pady=5)
            entry = ttk.Entry(royal_group, width=15)
            entry.grid(row=0, column=i*2+1, sticky=tk.W, padx=5, pady=5)
            self.royal_fields[field_key] = entry
        
        # 世家列表
        noble_list_group = ttk.LabelFrame(noble_frame, text="世家列表")
        noble_list_group.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
        
        # 创建世家列表树形视图
        noble_columns = ("编号", "姓氏", "等级", "关系", "坐标", "传承", "影响力")
        self.noble_tree = ttk.Treeview(noble_list_group, columns=noble_columns, show='headings', height=12)
        
        for col in noble_columns:
            self.noble_tree.heading(col, text=col)
            self.noble_tree.column(col, width=100)
        
        noble_scroll = ttk.Scrollbar(noble_list_group, orient=tk.VERTICAL, command=self.noble_tree.yview)
        self.noble_tree.configure(yscrollcommand=noble_scroll.set)
        
        self.noble_tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=(5, 0), pady=5)
        noble_scroll.pack(side=tk.RIGHT, fill=tk.Y, padx=(0, 5), pady=5)
        
        # 绑定双击编辑事件
        self.noble_tree.bind('<Double-1>', self.edit_noble)
        
        # 保存按钮
        save_noble_btn = ttk.Button(noble_list_group, text="保存世家信息", command=self.save_noble_data)
        save_noble_btn.pack(pady=5)
    
    def create_fief_tab(self):
        """
        创建封地信息选项卡
        """
        fief_frame = ttk.Frame(self.notebook)
        self.notebook.add(fief_frame, text="封地信息")
        
        # 封地列表
        fief_group = ttk.LabelFrame(fief_frame, text="封地基础信息")
        fief_group.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
        
        # 创建封地列表树形视图
        fief_columns = ("封地编号", "受封状态", "税率(地|丁|商)", "法律")
        self.fief_tree = ttk.Treeview(fief_group, columns=fief_columns, show='headings', height=15)
        
        for col in fief_columns:
            self.fief_tree.heading(col, text=col)
            self.fief_tree.column(col, width=150)
        
        fief_scroll = ttk.Scrollbar(fief_group, orient=tk.VERTICAL, command=self.fief_tree.yview)
        self.fief_tree.configure(yscrollcommand=fief_scroll.set)
        
        self.fief_tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=(5, 0), pady=5)
        fief_scroll.pack(side=tk.RIGHT, fill=tk.Y, padx=(0, 5), pady=5)
        
        # 绑定双击编辑事件
        self.fief_tree.bind('<Double-1>', self.edit_fief)
        
        # 保存按钮
        save_fief_btn = ttk.Button(fief_group, text="保存封地信息", command=self.save_fief_data)
        save_fief_btn.pack(pady=5)
    
    def create_military_tab(self):
        """
        创建军事信息选项卡
        """
        military_frame = ttk.Frame(self.notebook)
        self.notebook.add(military_frame, text="军事信息")
        
        # 朝堂禁军信息
        court_group = ttk.LabelFrame(military_frame, text="朝堂禁军信息")
        court_group.pack(fill=tk.X, padx=10, pady=10)
        
        self.military_fields = {}
        military_fields = [
            ("禁军数量:", "imperial_army_count"),
            ("士气:", "imperial_army_morale")
        ]
        
        for i, (label_text, field_key) in enumerate(military_fields):
            ttk.Label(court_group, text=label_text).grid(row=0, column=i*2, sticky=tk.W, padx=5, pady=5)
            entry = ttk.Entry(court_group, width=15)
            entry.grid(row=0, column=i*2+1, sticky=tk.W, padx=5, pady=5)
            self.military_fields[field_key] = entry
        
        # 兵营信息
        barracks_group = ttk.LabelFrame(military_frame, text="封地兵营信息")
        barracks_group.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
        
        # 创建兵营列表树形视图
        barracks_columns = ("兵营名称", "位置坐标", "士气", "兵力", "将领武力", "将领统率", "训练度", "经验值", "类型", "容量")
        self.barracks_tree = ttk.Treeview(barracks_group, columns=barracks_columns, show='headings', height=12)
        
        for col in barracks_columns:
            self.barracks_tree.heading(col, text=col)
            self.barracks_tree.column(col, width=80)
        
        barracks_scroll = ttk.Scrollbar(barracks_group, orient=tk.VERTICAL, command=self.barracks_tree.yview)
        self.barracks_tree.configure(yscrollcommand=barracks_scroll.set)
        
        self.barracks_tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=(5, 0), pady=5)
        barracks_scroll.pack(side=tk.RIGHT, fill=tk.Y, padx=(0, 5), pady=5)
        
        # 绑定双击事件
        self.barracks_tree.bind('<Double-1>', self.edit_barracks)
        
        # 保存按钮
        military_button_frame = ttk.Frame(military_frame)
        military_button_frame.pack(fill=tk.X, padx=10, pady=5)
        ttk.Button(military_button_frame, text="保存军事信息", command=self.save_military_data).pack(side=tk.LEFT, padx=5)
    
    def create_economy_tab(self):
        """
        创建经济信息选项卡
        """
        economy_frame = ttk.Frame(self.notebook)
        self.notebook.add(economy_frame, text="经济信息")
        
        # 月收入详情
        income_group = ttk.LabelFrame(economy_frame, text="月收入详情")
        income_group.pack(fill=tk.X, padx=10, pady=10)
        
        self.income_fields = {}
        income_fields = [
            ("封地收入:", "fief_income"),
            ("商业收入:", "trade_income"),
            ("其他收入:", "other_income")
        ]
        
        for i, (label_text, field_key) in enumerate(income_fields):
            ttk.Label(income_group, text=label_text).grid(row=0, column=i*2, sticky=tk.W, padx=5, pady=5)
            entry = ttk.Entry(income_group, width=15)
            entry.grid(row=0, column=i*2+1, sticky=tk.W, padx=5, pady=5)
            self.income_fields[field_key] = entry
        
        # 物品仓库
        warehouse_group = ttk.LabelFrame(economy_frame, text="物品仓库")
        warehouse_group.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
        
        # 创建物品列表树形视图
        item_columns = ("物品编号", "物品名称", "数量", "类型")
        self.item_tree = ttk.Treeview(warehouse_group, columns=item_columns, show='headings', height=15)
        
        for col in item_columns:
            self.item_tree.heading(col, text=col)
            self.item_tree.column(col, width=120)
        
        item_scroll = ttk.Scrollbar(warehouse_group, orient=tk.VERTICAL, command=self.item_tree.yview)
        self.item_tree.configure(yscrollcommand=item_scroll.set)
        
        self.item_tree.pack(side=tk.LEFT, fill=tk.BOTH, expand=True, padx=(5, 0), pady=5)
        item_scroll.pack(side=tk.RIGHT, fill=tk.Y, padx=(0, 5), pady=5)
        
        # 绑定双击事件
        self.item_tree.bind('<Double-1>', self.edit_item)
        
        # 保存按钮
        economy_button_frame = ttk.Frame(economy_frame)
        economy_button_frame.pack(fill=tk.X, padx=10, pady=5)
        ttk.Button(economy_button_frame, text="保存收入信息", command=self.save_income_data).pack(side=tk.LEFT, padx=5)
        ttk.Button(economy_button_frame, text="刷新物品列表", command=self.refresh_item_data).pack(side=tk.LEFT, padx=5)
    
    def create_raw_data_tab(self):
        """
        创建原始数据查看选项卡
        """
        raw_frame = ttk.Frame(self.notebook)
        self.notebook.add(raw_frame, text="原始数据")
        
        # 创建文本框显示原始JSON数据
        self.raw_text = scrolledtext.ScrolledText(raw_frame, wrap=tk.WORD, width=80, height=30)
        self.raw_text.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
        
        # 添加按钮框架
        button_frame = ttk.Frame(raw_frame)
        button_frame.pack(fill=tk.X, padx=10, pady=(0, 10))
        
        ttk.Button(button_frame, text="刷新数据", command=self.refresh_raw_data).pack(side=tk.LEFT, padx=5)
        ttk.Button(button_frame, text="格式化JSON", command=self.format_json).pack(side=tk.LEFT, padx=5)
        ttk.Button(button_frame, text="搜索", command=self.search_in_raw_data).pack(side=tk.LEFT, padx=5)
    
    def open_save_file(self):
        """
        打开存档文件
        """
        file_path = filedialog.askopenfilename(
            title="选择存档文件",
            filetypes=[("ES3存档文件", "*.es3"), ("JSON文件", "*.json"), ("所有文件", "*.*")]
        )
        
        if file_path:
            self.load_save_file(file_path)
    
    def load_save_file(self, file_path):
        """
        加载存档文件
        """
        try:
            with open(file_path, 'r', encoding='utf-8') as f:
                self.game_data = json.load(f)
            
            self.save_file_path = file_path
            self.status_var.set(f"已加载: {os.path.basename(file_path)}")
            
            # 加载数据到界面
            self.load_data_to_ui()
            
            messagebox.showinfo("成功", "存档文件加载成功!")
            
        except Exception as e:
            messagebox.showerror("错误", f"加载存档文件失败:{str(e)}")
            self.status_var.set("加载失败")
    
    def load_data_to_ui(self):
        """
        将数据加载到用户界面
        """
        if not self.game_data:
            return
        
        try:
            # 加载家主信息
            self.load_family_master_data()
            
            # 加载世家信息
            self.load_noble_data()
            
            # 加载门客信息
            self.load_retainer_data()
            
            # 加载寒门官员信息
            self.load_official_data()
            
            # 加载封地信息
            self.load_fief_data()
            
            # 加载军事信息
            self.load_military_data()
            
            # 加载兵营信息
            self.load_barracks_data()
            
            # 加载家族信息
            self.load_family_data()
            
            # 加载家族成员信息
            self.load_family_members_data()
            
            # 加载经济信息
            self.load_economy_data()
            
            # 刷新原始数据
            self.refresh_raw_data()
            
        except Exception as e:
            messagebox.showerror("错误", f"加载数据到界面失败:{str(e)}")
    
    def load_family_master_data(self):
        """
        加载家主数据
        """
        try:
            member_first = self.game_data.get("Member_First", {}).get("value", [])
            if member_first and len(member_first) >= 4:
                self.master_fields["member_first_id"].delete(0, tk.END)
                self.master_fields["member_first_id"].insert(0, member_first[0])
                
                self.master_fields["member_first_name"].delete(0, tk.END)
                self.master_fields["member_first_name"].insert(0, member_first[1])
                
                self.master_fields["member_first_image"].delete(0, tk.END)
                self.master_fields["member_first_image"].insert(0, member_first[2])
                
                self.master_fields["member_first_age"].delete(0, tk.END)
                self.master_fields["member_first_age"].insert(0, member_first[3])
        except Exception as e:
            print(f"加载家主数据失败: {e}")
    
    def load_noble_data(self):
        """
        加载世家数据
        """
        try:
            # 加载皇室信息
            shijia_king = self.game_data.get("ShiJia_king", {}).get("value", [])
            if shijia_king and len(shijia_king) >= 6:
                self.royal_fields["royal_name"].delete(0, tk.END)
                self.royal_fields["royal_name"].insert(0, shijia_king[0])
                
                self.royal_fields["royal_relation"].delete(0, tk.END)
                self.royal_fields["royal_relation"].insert(0, shijia_king[2])
                
                self.royal_fields["royal_favor"].delete(0, tk.END)
                self.royal_fields["royal_favor"].insert(0, shijia_king[5])
            
            # 加载世家列表
            self.noble_tree.delete(*self.noble_tree.get_children())
            shijia_now = self.game_data.get("ShiJia_Now", {}).get("value", [])
            
            for family in shijia_now:
                if len(family) >= 8:
                    self.noble_tree.insert("", tk.END, values=(
                        family[0], family[1], family[2], family[3], 
                        family[5], family[6], family[7]
                    ))
        except Exception as e:
            print(f"加载世家数据失败: {e}")
    
    def load_retainer_data(self):
        """
        加载门客数据
        """
        try:
            self.retainer_tree.delete(*self.retainer_tree.get_children())
            menke_now = self.game_data.get("MenKe_Now", {}).get("value", [])
            
            for retainer in menke_now:
                if len(retainer) >= 25:
                    # 解析基本信息字段
                    info_parts = retainer[2].split('|') if retainer[2] else []
                    name = info_parts[0] if info_parts else "未知"
                    
                    self.retainer_tree.insert("", tk.END, values=(
                        retainer[0],  # 编号
                        name,         # 姓名
                        retainer[3],  # 年龄
                        retainer[4],  # 文
                        retainer[5],  # 武
                        retainer[6],  # 商
                        retainer[7],  # 艺
                        retainer[8],  # 心情
                        retainer[24]  # 酬劳
                    ))
        except Exception as e:
            print(f"加载门客数据失败: {e}")
    
    def load_official_data(self):
        """
        加载寒门官员数据
        """
        try:
            self.official_tree.delete(*self.official_tree.get_children())
            member_hanmen = self.game_data.get("Member_Hanmen", {}).get("value", [])
            
            for official in member_hanmen:
                if len(official) >= 8:
                    self.official_tree.insert("", tk.END, values=(
                        official[0], official[1], official[2], official[3],
                        official[4], official[5], official[6], official[7]
                    ))
        except Exception as e:
            print(f"加载寒门官员数据失败: {e}")
    
    def load_fief_data(self):
        """
        加载封地数据
        """
        try:
            self.fief_tree.delete(*self.fief_tree.get_children())
            fengdi_now = self.game_data.get("Fengdi_now", {}).get("value", [])
            
            for i, fief in enumerate(fengdi_now):
                if len(fief) >= 4:
                    status_text = "已受封" if fief[0] == "1" else "未受封"
                    self.fief_tree.insert("", tk.END, values=(
                        str(i), status_text, fief[2], fief[3]
                    ))
        except Exception as e:
            print(f"加载封地数据失败: {e}")
    
    def load_military_data(self):
        """
        加载军事数据
        """
        try:
            king_city_data = self.game_data.get("KingCityData_now", {}).get("value", [])
            if king_city_data and len(king_city_data) >= 1:
                # 解析禁军信息
                army_info = king_city_data[0].split('|') if king_city_data[0] else []
                if len(army_info) >= 2:
                    self.military_fields["imperial_army_count"].delete(0, tk.END)
                    self.military_fields["imperial_army_count"].insert(0, army_info[0])
                    
                    self.military_fields["imperial_army_morale"].delete(0, tk.END)
                    self.military_fields["imperial_army_morale"].insert(0, army_info[1])
        except Exception as e:
            print(f"加载军事数据失败: {e}")
    
    def load_family_data(self):
        """
        加载家族数据
        """
        try:
            family_data = self.game_data.get("FamilyData", {}).get("value", [])
            if family_data and len(family_data) >= 6:
                self.family_fields["family_location"].delete(0, tk.END)
                self.family_fields["family_location"].insert(0, family_data[0])
                
                self.family_fields["family_surname"].delete(0, tk.END)
                self.family_fields["family_surname"].insert(0, family_data[1])
                
                self.family_fields["family_level"].delete(0, tk.END)
                self.family_fields["family_level"].insert(0, family_data[2])
                
                self.family_fields["family_exp"].delete(0, tk.END)
                self.family_fields["family_exp"].insert(0, family_data[3])
                
                self.family_fields["family_influence"].delete(0, tk.END)
                self.family_fields["family_influence"].insert(0, family_data[4])
                
                self.family_fields["warehouse_capacity"].delete(0, tk.END)
                self.family_fields["warehouse_capacity"].insert(0, family_data[5])
        except Exception as e:
            print(f"加载家族数据失败: {e}")
    
    def load_economy_data(self):
        """
        加载经济数据
        """
        try:
            # 加载货币信息
            cgnum = self.game_data.get("CGNum", {}).get("value", [])
            if cgnum and len(cgnum) >= 2:
                self.economy_fields["copper_money"].delete(0, tk.END)
                self.economy_fields["copper_money"].insert(0, cgnum[0])
                
                self.economy_fields["gold_money"].delete(0, tk.END)
                self.economy_fields["gold_money"].insert(0, cgnum[1])
            
            # 加载月收入信息
            get_money = self.game_data.get("GetMoney_Month", {}).get("value", [])
            if get_money:
                total_income = sum(int(x) for x in get_money if str(x).isdigit())
                self.economy_fields["monthly_income"].delete(0, tk.END)
                self.economy_fields["monthly_income"].insert(0, str(total_income))
            
            # 加载物品信息
            self.refresh_item_data()
            
        except Exception as e:
            print(f"加载经济数据失败: {e}")
    
    def get_item_mapping(self):
        """
        获取物品编号到名称和类型的映射
        """
        return {
            # 特殊物品
            "0": ("线香", "特殊物品"),
            "1": ("肥料", "特殊物品"),
            
            # 粮肉
            "2": ("粮食", "粮肉"),
            "3": ("蔬菜", "粮肉"),
            "4": ("肉食", "粮肉"),
            "5": ("生茶", "农产"),
            
            # 美食
            "6": ("奶酪", "美食"),
            "7": ("果脯", "美食"),
            "8": ("青梅", "美食"),
            "9": ("樱桃", "美食"),
            "10": ("柿子", "美食"),
            "11": ("枇杷", "美食"),
            "12": ("桑葚", "美食"),
            "13": ("桔子", "美食"),
            "14": ("荔枝", "美食"),
            "15": ("熊掌", "美食"),
            "66": ("鱼", "美食"),
            "73": ("团饼茶", "美食"),
            "284": ("鸡蛋", "美食"),
            
            # 布料
            "16": ("麻布", "布料"),
            "17": ("粗布", "布料"),
            "18": ("皮革", "布料"),
            "19": ("素绫", "布料"),
            "20": ("交织绫", "布料"),
            "21": ("单罗纱", "布料"),
            "22": ("四罗纱", "布料"),
            "23": ("雪缎", "布料"),
            "24": ("花缎", "布料"),
            "25": ("云锦", "布料"),
            "26": ("蜀锦", "布料"),
            "27": ("筛绢", "布料"),
            "28": ("天香绢", "布料"),
            
            # 矿产
            "29": ("黄金", "矿产"),
            "30": ("白银", "矿产"),
            "31": ("青铜", "矿产"),
            "32": ("黑铁", "矿产"),
            "33": ("白锡", "矿产"),
            "34": ("赤汞", "矿产"),
            "35": ("玉石", "矿产"),
            "36": ("硫磺", "矿产"),
            "37": ("硝石", "矿产"),
            "38": ("煤炭", "矿产"),
            "39": ("石灰", "矿产"),
            
            # 香粉
            "40": ("石黛", "香粉"),
            "41": ("青雀石黛", "香粉"),
            "42": ("铜黛", "香粉"),
            "43": ("螺子黛", "香粉"),
            "44": ("铅粉", "香粉"),
            "45": ("紫粉", "香粉"),
            "46": ("桃花粉", "香粉"),
            "47": ("胭脂", "香粉"),
            "48": ("乌膏", "香粉"),
            "49": ("泡花露", "香粉"),
            "50": ("蔷薇露", "香粉"),
            
            # 珠宝(女)
            "51": ("银笄", "珠宝(女)"),
            "52": ("钿花", "珠宝(女)"),
            "53": ("花钗", "珠宝(女)"),
            "54": ("耳铛", "珠宝(女)"),
            "55": ("步摇", "珠宝(女)"),
            "56": ("金簪", "珠宝(女)"),
            "57": ("华胜", "珠宝(女)"),
            "58": ("宫绦", "珠宝(女)"),
            "59": ("梳篦", "珠宝(女)"),
            "60": ("臂钏", "珠宝(女)"),
            "61": ("璎珞", "珠宝(女)"),
            
            # 珠宝(男)
            "62": ("发钗", "珠宝(男)"),
            "63": ("扳指", "珠宝(男)"),
            "64": ("玉佩", "珠宝(男)"),
            "65": ("带钩", "珠宝(男)"),
            
            # 农产
            "67": ("棉花", "农产"),
            "74": ("盐", "农产"),
            
            # 丹药
            "68": ("长寿丹", "丹药"),
            "69": ("极乐丹", "丹药"),
            "70": ("美颜丹", "丹药"),
            "71": ("极品美颜丹", "丹药"),
            "72": ("极品长寿丹", "丹药"),
            "75": ("合欢丹", "丹药"),
            "168": ("回魂丹", "丹药"),
            "282": ("堕胎丹", "丹药"),
            "283": ("避孕丹", "丹药"),
            
            # 书法
            "76": ("无名字轴", "书法"),
            "77": ("无名碑帖", "书法"),
            "78": ("名家字轴", "书法"),
            "79": ("名家碑帖", "书法"),
            "80": ("传世字轴", "书法"),
            "81": ("传世碑帖", "书法"),
            
            # 丹青
            "82": ("无名山水画", "丹青"),
            "83": ("无名江山图", "丹青"),
            "84": ("名家山水画", "丹青"),
            "85": ("名家江山图", "丹青"),
            "86": ("传世山水画", "丹青"),
            "87": ("传世江山图", "丹青"),
            
            # 文玩
            "88": ("玉圭", "文玩"),
            "89": ("玉碗", "文玩"),
            "90": ("玉瓶", "文玩"),
            "91": ("玉琥", "文玩"),
            "92": ("玉璧", "文玩"),
            "93": ("玉璜", "文玩"),
            "94": ("玉琮", "文玩"),
            "95": ("玉山", "文玩"),
            "96": ("玉璧", "文玩"),
            
            # 武器
            "97": ("竹弓", "武器"),
            "98": ("木弓", "武器"),
            "99": ("牛角弓", "武器"),
            "100": ("木角弓", "武器"),
            "101": ("木弩", "武器"),
            "102": ("铜弩", "武器"),
            "103": ("连弩", "武器"),
            "104": ("单刀", "武器"),
            "105": ("朴刀", "武器"),
            "106": ("鬼头刀", "武器"),
            "107": ("三尖两刃刀", "武器"),
            "108": ("三尺剑", "武器"),
            "109": ("软剑", "武器"),
            "110": ("七尺剑", "武器"),
            "111": ("子母剑", "武器"),
            
            # 茶具
            "112": ("提梁壶", "茶具"),
            "113": ("油滴盏", "茶具"),
            "114": ("天目盏", "茶具"),
            "115": ("青瓷盏", "茶具"),
            "116": ("红釉盏", "茶具"),
            "117": ("青瓷壶", "茶具"),
            "118": ("楠木茶盘", "茶具"),
            "119": ("檀木茶盘", "茶具"),
            "120": ("玉壶", "茶具"),
            
            # 香具
            "121": ("铜薰球", "香具"),
            "122": ("铜香炉", "香具"),
            "123": ("楠木香筒", "香具"),
            "124": ("金薰球", "香具"),
            "125": ("檀木香盒", "香具"),
            "126": ("金香盒", "香具"),
            "127": ("檀木香筒", "香具"),
            "128": ("金香炉", "香具"),
            
            # 瓷器
            "129": ("高足碗", "瓷器"),
            "130": ("葫芦瓶", "瓷器"),
            "131": ("扁瓶", "瓷器"),
            "132": ("瓷枕", "瓷器"),
            "133": ("琮式瓶", "瓷器"),
            "134": ("梅瓶", "瓷器"),
            "135": ("凤尾瓶", "瓷器"),
            
            # 美酒
            "136": ("黄酒", "美酒"),
            "137": ("曲红酒", "美酒"),
            "138": ("菊花酒", "美酒"),
            "139": ("茱萸酒", "美酒"),
            "140": ("竹叶青", "美酒"),
            "141": ("荔枝酒", "美酒"),
            "142": ("桂花酒", "美酒"),
            "143": ("琥珀酒", "美酒"),
            
            # 乐器
            "144": ("竹箫", "乐器"),
            "145": ("木笛", "乐器"),
            "146": ("芦笙", "乐器"),
            "147": ("二胡", "乐器"),
            "148": ("琵琶", "乐器"),
            "149": ("月琴", "乐器"),
            "150": ("中瑟", "乐器"),
            "151": ("伏羲琴", "乐器"),
            
            # 皮毛
            "152": ("兔皮", "皮毛"),
            "153": ("狼皮", "皮毛"),
            "154": ("鹿皮", "皮毛"),
            "155": ("狐皮", "皮毛"),
            "156": ("虎皮", "皮毛"),
            
            # 符咒
            "157": ("一阶符咒", "符咒"),
            "158": ("二阶符咒", "符咒"),
            "159": ("三阶符咒", "符咒"),
            "160": ("四阶符咒", "符咒"),
            "161": ("五阶符咒", "符咒"),
            "162": ("六阶符咒", "符咒"),
            
            # 毒药
            "163": ("番木鳖", "毒药"),
            "164": ("乌头", "毒药"),
            "165": ("雷公藤", "毒药"),
            "166": ("断肠草", "毒药"),
            "167": ("鹤顶红", "毒药"),
            
            # 书籍 - 文
            "169": ("三字经", "书籍(文)"),
            "170": ("弟子规", "书籍(文)"),
            "171": ("千字文", "书籍(文)"),
            "172": ("蒙求", "书籍(文)"),
            "173": ("广韵", "书籍(文)"),
            "174": ("广雅", "书籍(文)"),
            "175": ("九章", "书籍(文)"),
            "176": ("尔雅", "书籍(文)"),
            "177": ("陵川集", "书籍(文)"),
            "178": ("花间集", "书籍(文)"),
            "179": ("诗品", "书籍(文)"),
            "180": ("文选", "书籍(文)"),
            "181": ("诗经", "书籍(文)"),
            "182": ("尚书", "书籍(文)"),
            "183": ("礼记", "书籍(文)"),
            "184": ("周易", "书籍(文)"),
            "185": ("春秋", "书籍(文)"),
            "186": ("大学", "书籍(文)"),
            "187": ("中庸", "书籍(文)"),
            "188": ("论语", "书籍(文)"),
            "189": ("孟子", "书籍(文)"),
            "190": ("法言", "书籍(文)"),
            "191": ("潜夫论", "书籍(文)"),
            
            # 书籍 - 武
            "192": ("手搏六篇", "书籍(武)"),
            "193": ("棍棒体式", "书籍(武)"),
            "194": ("麻杈棍谱", "书籍(武)"),
            "195": ("手臂录", "书籍(武)"),
            "196": ("拳术教范", "书籍(武)"),
            "197": ("苌氏武技书", "书籍(武)"),
            "198": ("阴符枪谱", "书籍(武)"),
            "199": ("太极拳经", "书籍(武)"),
            "200": ("马槊谱", "书籍(武)"),
            "201": ("三才图会", "书籍(武)"),
            "202": ("拳经", "书籍(武)"),
            "203": ("射经", "书籍(武)"),
            "204": ("剑经", "书籍(武)"),
            "205": ("角力记", "书籍(武)"),
            "206": ("耕余剩技", "书籍(武)"),
            
            # 书籍 - 商
            "207": ("土商类要", "书籍(商)"),
            "208": ("货殖列传", "书籍(商)"),
            "209": ("平淮书", "书籍(商)"),
            "210": ("计然书", "书籍(商)"),
            "211": ("贸易赋", "书籍(商)"),
            "212": ("食货志", "书籍(商)"),
            "213": ("轻重篇", "书籍(商)"),
            "214": ("考工记", "书籍(商)"),
            "215": ("商君书", "书籍(商)"),
            "216": ("陶朱公生意经", "书籍(商)"),
            "217": ("商经", "书籍(商)"),
            
            # 书籍 - 艺
            "218": ("琴律发微", "书籍(艺)"),
            "219": ("琴声十六法", "书籍(艺)"),
            "220": ("唱论", "书籍(艺)"),
            "221": ("琴操", "书籍(艺)"),
            "222": ("乐府杂录", "书籍(艺)"),
            "223": ("乐章集", "书籍(艺)"),
            "224": ("乐府诗集", "书籍(艺)"),
            "225": ("乐书要录", "书籍(艺)"),
            "226": ("碧鸡漫志", "书籍(艺)"),
            "227": ("琴清英", "书籍(艺)"),
            "228": ("梅花三弄", "书籍(艺)"),
            "229": ("猗兰操", "书籍(艺)"),
            "230": ("广陵散", "书籍(艺)"),
            "231": ("阳春白雪", "书籍(艺)"),
            "232": ("高山流水", "书籍(艺)"),
            "233": ("乐记", "书籍(艺)"),
            "234": ("乐经", "书籍(艺)"),
            "235": ("琴赋", "书籍(艺)"),
            "236": ("溪山琴况", "书籍(艺)"),
            "237": ("太古遗音", "书籍(艺)"),
            
            # 书籍 - 计谋
            "238": ("左传", "书籍(计谋)"),
            "239": ("史记", "书籍(计谋)"),
            "240": ("间书", "书籍(计谋)"),
            "241": ("捭阖", "书籍(计谋)"),
            "242": ("飞箝", "书籍(计谋)"),
            "243": ("许和", "书籍(计谋)"),
            "244": ("揣篇", "书籍(计谋)"),
            "245": ("苏子", "书籍(计谋)"),
            "246": ("太白应经", "书籍(计谋)"),
            "247": ("战国策", "书籍(计谋)"),
            "248": ("韩非子", "书籍(计谋)"),
            "249": ("孙子兵法", "书籍(计谋)"),
            "250": ("鬼谷子", "书籍(计谋)"),
            
            # 书籍 - 技能
            "251": ("山海经", "书籍(巫)"),
            "252": ("符咒秘本", "书籍(巫)"),
            "253": ("巫阳古书", "书籍(巫)"),
            "254": ("阴山法笈", "书籍(巫)"),
            "255": ("鲁班书", "书籍(巫)"),
            "256": ("脉经", "书籍(医)"),
            "260": ("精匮要略", "书籍(医)"),
            "261": ("神农本草", "书籍(医)"),
            "262": ("本草纲目", "书籍(医)"),
            "263": ("黄帝内经", "书籍(医)"),
            "264": ("得器歌", "书籍(相)"),
            "265": ("五官杂论", "书籍(相)"),
            "266": ("听声相形", "书籍(相)"),
            "267": ("永乐百问", "书籍(相)"),
            "268": ("柳庄相法", "书籍(相)"),
            "270": ("紫微斗数", "书籍(卜)"),
            "271": ("梅花易数", "书籍(卜)"),
            "272": ("神峰通考", "书籍(卜)"),
            "273": ("渊海子平", "书籍(卜)"),
            "274": ("三命通会", "书籍(卜)"),
            "275": ("素女经", "书籍(媚)"),
            "276": ("洞玄子", "书籍(媚)"),
            "277": ("长物志", "书籍(工)"),
            "278": ("梓人遗制", "书籍(工)"),
            "279": ("齐民要术", "书籍(工)"),
            "280": ("天工开物", "书籍(工)"),
            "281": ("墨经", "书籍(工)")
        }
    
    def refresh_item_data(self):
        """
        刷新物品数据
        """
        try:
            self.item_tree.delete(*self.item_tree.get_children())
            prop_have = self.game_data.get("Prop_have", {}).get("value", [])
            item_mapping = self.get_item_mapping()
            
            for item in prop_have:
                if len(item) >= 2:
                    item_id = str(item[0])
                    quantity = item[1]
                    
                    # 使用物品映射获取名称和类型
                    if item_id in item_mapping:
                        item_name, item_type = item_mapping[item_id]
                    else:
                        item_name = f"未知物品{item_id}"
                        item_type = "未知"
                    
                    self.item_tree.insert("", tk.END, values=(
                        item_id, item_name, quantity, item_type
                    ))
        except Exception as e:
            print(f"刷新物品数据失败: {e}")
    
    def load_barracks_data(self):
        """
        加载兵营数据
        """
        try:
            self.barracks_tree.delete(*self.barracks_tree.get_children())
            junying_now = self.game_data.get("JunYing_now", {}).get("value", [])
            
            for fief_index, fief_barracks in enumerate(junying_now):
                if fief_barracks:  # 如果该封地有兵营
                    for barracks in fief_barracks:
                        if len(barracks) >= 9:
                            position = barracks[0]
                            morale = barracks[1]
                            troops = barracks[2]
                            commander_force = barracks[3]
                            commander_command = barracks[4]
                            training = barracks[5]
                            experience = barracks[6]
                            name = barracks[7]
                            capacity = barracks[8]
                            
                            self.barracks_tree.insert("", tk.END, values=(
                                name, position, morale, troops, commander_force,
                                commander_command, training, experience, f"封地{fief_index}", capacity
                            ))
        except Exception as e:
            print(f"加载兵营数据失败: {e}")
    
    def save_family_data(self):
        """
        保存家族数据
        """
        try:
            if "FamilyData" not in self.game_data:
                self.game_data["FamilyData"] = {"__type": "System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]],mscorlib", "value": []}
            
            family_data = self.game_data["FamilyData"]["value"]
            
            # 确保数组有足够的元素
            while len(family_data) < 10:
                family_data.append("0")
            
            family_data[0] = self.family_fields["family_location"].get()
            family_data[1] = self.family_fields["family_surname"].get()
            family_data[2] = self.family_fields["family_level"].get()
            family_data[3] = self.family_fields["family_exp"].get()
            family_data[4] = self.family_fields["family_influence"].get()
            family_data[5] = self.family_fields["warehouse_capacity"].get()
            
            messagebox.showinfo("成功", "家族信息保存成功!")
        except Exception as e:
            messagebox.showerror("错误", f"保存家族信息失败:{str(e)}")
    
    def save_economy_data(self):
        """
        保存经济数据
        """
        try:
            # 保存货币信息
            if "CGNum" not in self.game_data:
                self.game_data["CGNum"] = {"__type": "System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]],mscorlib", "value": []}
            
            cgnum = self.game_data["CGNum"]["value"]
            while len(cgnum) < 4:
                cgnum.append("0")
            
            cgnum[0] = self.economy_fields["copper_money"].get()
            cgnum[1] = self.economy_fields["gold_money"].get()
            
            messagebox.showinfo("成功", "经济信息保存成功!")
        except Exception as e:
            messagebox.showerror("错误", f"保存经济信息失败:{str(e)}")
    
    def save_military_data(self):
        """
        保存军事数据
        """
        try:
            # 保存禁军信息
            if "KingCityData_now" in self.game_data:
                king_city_data = self.game_data["KingCityData_now"]["value"]
                if king_city_data and len(king_city_data) >= 1:
                    army_count = self.military_fields["imperial_army_count"].get()
                    army_morale = self.military_fields["imperial_army_morale"].get()
                    king_city_data[0] = f"{army_count}|{army_morale}"
            
            messagebox.showinfo("成功", "军事信息保存成功!")
        except Exception as e:
            messagebox.showerror("错误", f"保存军事信息失败:{str(e)}")
    
    def save_noble_data(self):
        """
        保存世家信息
        """
        try:
            # 保存皇室信息
            shijia_king = self.game_data.get("ShiJia_king", {}).get("value", [])
            if len(shijia_king) >= 6:
                shijia_king[0] = self.royal_fields["royal_name"].get()
                shijia_king[2] = self.royal_fields["royal_relation"].get()
                shijia_king[5] = self.royal_fields["royal_favor"].get()
            
            messagebox.showinfo("成功", "世家信息已保存")
        except Exception as e:
            messagebox.showerror("错误", f"保存世家信息失败:{str(e)}")
    
    def save_fief_data(self):
        """
        保存封地信息
        """
        try:
            messagebox.showinfo("成功", "封地信息已保存")
        except Exception as e:
            messagebox.showerror("错误", f"保存封地信息失败:{str(e)}")
    
    def save_income_data(self):
        """
        保存收入信息
        """
        try:
            messagebox.showinfo("提示", "收入信息保存功能开发中...")
        except Exception as e:
            messagebox.showerror("错误", f"保存收入信息失败:{str(e)}")
    
    def edit_noble(self, event):
        """
        编辑世家信息
        """
        try:
            selection = self.noble_tree.selection()
            if not selection:
                return
            
            item = self.noble_tree.item(selection[0])
            values = item['values']
            
            # 创建编辑窗口
            edit_window = tk.Toplevel(self.root)
            edit_window.title("编辑世家信息")
            edit_window.geometry("400x300")
            edit_window.transient(self.root)
            edit_window.grab_set()
            
            # 添加编辑字段
            fields = ["编号", "姓氏", "等级", "关系", "坐标", "传承", "影响力"]
            entries = {}
            
            for i, field in enumerate(fields):
                ttk.Label(edit_window, text=f"{field}:").grid(row=i, column=0, sticky=tk.W, padx=10, pady=5)
                entry = ttk.Entry(edit_window, width=20)
                entry.grid(row=i, column=1, padx=10, pady=5)
                if i < len(values):
                    entry.insert(0, str(values[i]))
                entries[field] = entry
            
            def save_changes():
                try:
                    # 获取世家数据
                    shijia_now = self.game_data.get("ShiJia_Now", {}).get("value", [])
                    noble_index = int(entries["编号"].get())
                    
                    if 0 <= noble_index < len(shijia_now):
                        # 更新世家数据
                        shijia_now[noble_index][1] = entries["姓氏"].get()
                        shijia_now[noble_index][2] = entries["等级"].get()
                        shijia_now[noble_index][3] = entries["关系"].get()
                        shijia_now[noble_index][4] = entries["坐标"].get()
                        shijia_now[noble_index][5] = entries["传承"].get()
                        shijia_now[noble_index][6] = entries["影响力"].get()
                        
                        # 刷新显示
                        self.load_noble_data()
                        messagebox.showinfo("成功", "世家信息已更新")
                        edit_window.destroy()
                    else:
                        messagebox.showerror("错误", "无效的世家编号")
                except Exception as e:
                    messagebox.showerror("错误", f"保存失败:{str(e)}")
            
            # 保存和取消按钮
            button_frame = ttk.Frame(edit_window)
            button_frame.grid(row=len(fields), column=0, columnspan=2, pady=20)
            ttk.Button(button_frame, text="保存", command=save_changes).pack(side=tk.LEFT, padx=5)
            ttk.Button(button_frame, text="取消", command=edit_window.destroy).pack(side=tk.LEFT, padx=5)
            
        except Exception as e:
            messagebox.showerror("错误", f"编辑世家失败:{str(e)}")
    
    def edit_fief(self, event):
        """
        编辑封地信息
        """
        try:
            selection = self.fief_tree.selection()
            if not selection:
                return
            
            item = self.fief_tree.item(selection[0])
            values = item['values']
            
            # 创建编辑窗口
            edit_window = tk.Toplevel(self.root)
            edit_window.title("编辑封地信息")
            edit_window.geometry("400x250")
            edit_window.transient(self.root)
            edit_window.grab_set()
            
            # 添加编辑字段
            fields = ["封地编号", "受封状态", "税率(地|丁|商)", "法律"]
            entries = {}
            
            for i, field in enumerate(fields):
                ttk.Label(edit_window, text=f"{field}:").grid(row=i, column=0, sticky=tk.W, padx=10, pady=5)
                if field == "受封状态":
                    # 下拉选择框
                    combo = ttk.Combobox(edit_window, values=["未受封", "已受封"], width=18)
                    combo.grid(row=i, column=1, padx=10, pady=5)
                    combo.set(values[i] if i < len(values) else "")
                    entries[field] = combo
                else:
                    entry = ttk.Entry(edit_window, width=20)
                    entry.grid(row=i, column=1, padx=10, pady=5)
                    if i < len(values):
                        entry.insert(0, str(values[i]))
                    entries[field] = entry
            
            def save_changes():
                try:
                    # 获取封地数据
                    fengdi_now = self.game_data.get("Fengdi_now", {}).get("value", [])
                    fief_index = int(entries["封地编号"].get())
                    
                    if 0 <= fief_index < len(fengdi_now):
                        # 更新封地数据
                        status = "1" if entries["受封状态"].get() == "已受封" else "0"
                        fengdi_now[fief_index][0] = status
                        fengdi_now[fief_index][2] = entries["税率(地|丁|商)"].get()
                        fengdi_now[fief_index][3] = entries["法律"].get()
                        
                        # 刷新显示
                        self.load_fief_data()
                        messagebox.showinfo("成功", "封地信息已更新")
                        edit_window.destroy()
                    else:
                        messagebox.showerror("错误", "无效的封地编号")
                except Exception as e:
                    messagebox.showerror("错误", f"保存失败:{str(e)}")
            
            # 保存和取消按钮
            button_frame = ttk.Frame(edit_window)
            button_frame.grid(row=len(fields), column=0, columnspan=2, pady=20)
            ttk.Button(button_frame, text="保存", command=save_changes).pack(side=tk.LEFT, padx=5)
            ttk.Button(button_frame, text="取消", command=edit_window.destroy).pack(side=tk.LEFT, padx=5)
            
        except Exception as e:
            messagebox.showerror("错误", f"编辑封地失败:{str(e)}")
    
    def edit_barracks(self, event):
        """
        编辑兵营信息
        """
        try:
            selection = self.barracks_tree.selection()
            if not selection:
                return
            
            item = self.barracks_tree.item(selection[0])
            values = item['values']
            
            # 创建编辑窗口
            edit_window = tk.Toplevel(self.root)
            edit_window.title("编辑兵营信息")
            edit_window.geometry("400x400")
            edit_window.transient(self.root)
            edit_window.grab_set()
            
            # 添加编辑字段
            fields = ["兵营名称", "位置坐标", "士气", "兵力", "将领武力", "将领统率", "训练度", "经验值", "类型", "容量"]
            entries = {}
            
            for i, field in enumerate(fields):
                ttk.Label(edit_window, text=f"{field}:").grid(row=i, column=0, sticky=tk.W, padx=10, pady=5)
                entry = ttk.Entry(edit_window, width=20)
                entry.grid(row=i, column=1, padx=10, pady=5)
                if i < len(values):
                    entry.insert(0, str(values[i]))
                entries[field] = entry
            
            def save_changes():
                try:
                    # 获取兵营数据
                    junying_now = self.game_data.get("JunYing_now", {}).get("value", [])
                    
                    # 找到对应的兵营(通过兵营名称匹配)
                    barracks_name = entries["兵营名称"].get()
                    found = False
                    
                    for fief_index, fief_barracks in enumerate(junying_now):
                        if fief_barracks:  # 如果该封地有兵营
                            for barracks_index, barracks in enumerate(fief_barracks):
                                if len(barracks) >= 9 and barracks[7] == barracks_name:  # 兵营名称在索引7
                                    # 更新兵营数据
                                    barracks[0] = entries["位置坐标"].get()
                                    barracks[1] = entries["士气"].get()
                                    barracks[2] = entries["兵力"].get()
                                    barracks[3] = entries["将领武力"].get()
                                    barracks[4] = entries["将领统率"].get()
                                    barracks[5] = entries["训练度"].get()
                                    barracks[6] = entries["经验值"].get()
                                    barracks[7] = entries["兵营名称"].get()  # 兵营名称
                                    if len(barracks) >= 9:
                                        barracks[8] = entries["容量"].get()
                                    
                                    found = True
                                    break
                            if found:
                                break
                    
                    if found:
                        # 刷新显示
                        self.load_barracks_data()
                        messagebox.showinfo("成功", "兵营信息已更新")
                        edit_window.destroy()
                    else:
                        messagebox.showerror("错误", "未找到对应的兵营")
                except Exception as e:
                    messagebox.showerror("错误", f"保存失败:{str(e)}")
            
            # 保存和取消按钮
            button_frame = ttk.Frame(edit_window)
            button_frame.grid(row=len(fields), column=0, columnspan=2, pady=20)
            ttk.Button(button_frame, text="保存", command=save_changes).pack(side=tk.LEFT, padx=5)
            ttk.Button(button_frame, text="取消", command=edit_window.destroy).pack(side=tk.LEFT, padx=5)
            
        except Exception as e:
            messagebox.showerror("错误", f"编辑兵营失败:{str(e)}")
    
    def edit_item(self, event):
        """
        编辑物品信息
        """
        try:
            selection = self.item_tree.selection()
            if not selection:
                return
            
            item = self.item_tree.item(selection[0])
            values = item['values']
            
            # 创建编辑窗口
            edit_window = tk.Toplevel(self.root)
            edit_window.title("编辑物品信息")
            edit_window.geometry("350x200")
            edit_window.transient(self.root)
            edit_window.grab_set()
            
            # 显示物品信息
            ttk.Label(edit_window, text=f"物品编号: {values[0]}").grid(row=0, column=0, columnspan=2, sticky=tk.W, padx=10, pady=5)
            ttk.Label(edit_window, text=f"物品名称: {values[1]}").grid(row=1, column=0, columnspan=2, sticky=tk.W, padx=10, pady=5)
            ttk.Label(edit_window, text=f"物品类型: {values[3]}").grid(row=2, column=0, columnspan=2, sticky=tk.W, padx=10, pady=5)
            
            # 可编辑的数量字段
            ttk.Label(edit_window, text="数量:").grid(row=3, column=0, sticky=tk.W, padx=10, pady=5)
            quantity_entry = ttk.Entry(edit_window, width=20)
            quantity_entry.grid(row=3, column=1, padx=10, pady=5)
            quantity_entry.insert(0, str(values[2]))
            
            def save_changes():
                try:
                    # 获取物品数据
                    prop_have = self.game_data.get("Prop_have", {}).get("value", [])
                    item_id = str(values[0])  # 确保ID为字符串类型
                    new_quantity = int(quantity_entry.get())
                    
                    # 查找并更新物品数量
                    found = False
                    for i, prop in enumerate(prop_have):
                        if len(prop) >= 2 and str(prop[0]) == item_id:  # 确保比较时都是字符串
                            if new_quantity <= 0:
                                # 如果数量为0或负数,删除该物品
                                prop_have.pop(i)
                                messagebox.showinfo("成功", "物品已删除")
                            else:
                                # 更新数量
                                prop[1] = str(new_quantity)
                                messagebox.showinfo("成功", "物品数量已更新")
                            
                            found = True
                            break
                    
                    # 如果没找到物品且数量大于0,添加新物品
                    if not found and new_quantity > 0:
                        prop_have.append([item_id, str(new_quantity)])
                        messagebox.showinfo("成功", "物品已添加")
                        found = True
                    elif not found and new_quantity <= 0:
                        messagebox.showinfo("提示", "物品不存在,无法设置为0")
                        return
                    
                    if found:
                        # 刷新显示
                        self.refresh_item_data()
                        edit_window.destroy()
                        
                except ValueError:
                    messagebox.showerror("错误", "请输入有效的数量")
                except Exception as e:
                    messagebox.showerror("错误", f"保存失败:{str(e)}")
            
            # 保存和取消按钮
            button_frame = ttk.Frame(edit_window)
            button_frame.grid(row=4, column=0, columnspan=2, pady=20)
            ttk.Button(button_frame, text="保存", command=save_changes).pack(side=tk.LEFT, padx=5)
            ttk.Button(button_frame, text="取消", command=edit_window.destroy).pack(side=tk.LEFT, padx=5)
            
        except Exception as e:
            messagebox.showerror("错误", f"编辑物品失败:{str(e)}")
    
    def refresh_raw_data(self):
        """
        刷新原始数据显示
        """
        if self.game_data:
            self.raw_text.delete(1.0, tk.END)
            formatted_json = json.dumps(self.game_data, ensure_ascii=False, indent=2)
            self.raw_text.insert(1.0, formatted_json)
    
    def format_json(self):
        """
        格式化JSON数据
        """
        try:
            content = self.raw_text.get(1.0, tk.END)
            parsed = json.loads(content)
            formatted = json.dumps(parsed, ensure_ascii=False, indent=2)
            self.raw_text.delete(1.0, tk.END)
            self.raw_text.insert(1.0, formatted)
        except Exception as e:
            messagebox.showerror("错误", f"JSON格式化失败:{str(e)}")
    
    def search_in_raw_data(self):
        """
        在原始数据中搜索
        """
        search_term = tk.simpledialog.askstring("搜索", "请输入搜索关键词:")
        if search_term:
            content = self.raw_text.get(1.0, tk.END)
            start_pos = content.find(search_term)
            if start_pos != -1:
                # 计算行列位置
                lines_before = content[:start_pos].count('\n')
                line_start = content.rfind('\n', 0, start_pos) + 1
                col = start_pos - line_start
                
                # 选中找到的文本
                start_index = f"{lines_before + 1}.{col}"
                end_index = f"{lines_before + 1}.{col + len(search_term)}"
                
                self.raw_text.tag_remove(tk.SEL, 1.0, tk.END)
                self.raw_text.tag_add(tk.SEL, start_index, end_index)
                self.raw_text.see(start_index)
            else:
                messagebox.showinfo("搜索结果", "未找到指定内容")
    
    def edit_retainer(self, event):
        """
        编辑门客信息
        """
        selection = self.retainer_tree.selection()
        if selection:
            item = self.retainer_tree.item(selection[0])
            values = item['values']
            
            # 创建编辑窗口
            edit_window = tk.Toplevel(self.root)
            edit_window.title("编辑门客信息")
            edit_window.geometry("400x300")
            edit_window.transient(self.root)
            edit_window.grab_set()
            
            # 添加编辑字段
            fields = ["编号", "姓名", "年龄", "文", "武", "商", "艺", "心情", "酬劳"]
            entries = {}
            
            for i, field in enumerate(fields):
                ttk.Label(edit_window, text=f"{field}:").grid(row=i, column=0, sticky=tk.W, padx=5, pady=5)
                entry = ttk.Entry(edit_window, width=20)
                entry.grid(row=i, column=1, sticky=tk.W, padx=5, pady=5)
                entry.insert(0, str(values[i]) if i < len(values) else "")
                entries[field] = entry
            
            # 添加按钮
            button_frame = ttk.Frame(edit_window)
            button_frame.grid(row=len(fields), column=0, columnspan=2, pady=10)
            
            def save_changes():
                # 这里应该实现保存逻辑
                messagebox.showinfo("提示", "保存功能待实现")
                edit_window.destroy()
            
            ttk.Button(button_frame, text="保存", command=save_changes).pack(side=tk.LEFT, padx=5)
            ttk.Button(button_frame, text="取消", command=edit_window.destroy).pack(side=tk.LEFT, padx=5)
    
    def save_file(self):
        """
        保存存档文件
        """
        if not self.save_file_path:
            self.save_as_file()
            return
        
        try:
            # 从界面收集数据
            self.collect_data_from_ui()
            
            # 保存到文件
            with open(self.save_file_path, 'w', encoding='utf-8') as f:
                json.dump(self.game_data, f, ensure_ascii=False, separators=(',', ':'))
            
            self.status_var.set(f"已保存: {os.path.basename(self.save_file_path)}")
            messagebox.showinfo("成功", "存档保存成功!")
            
        except Exception as e:
            messagebox.showerror("错误", f"保存存档失败:{str(e)}")
    
    def save_as_file(self):
        """
        另存为存档文件
        """
        file_path = filedialog.asksaveasfilename(
            title="保存存档文件",
            defaultextension=".es3",
            filetypes=[("ES3存档文件", "*.es3"), ("JSON文件", "*.json"), ("所有文件", "*.*")]
        )
        
        if file_path:
            self.save_file_path = file_path
            self.save_file()
    
    def collect_data_from_ui(self):
        """
        从界面收集数据
        """
        if not self.game_data:
            return
        
        try:
            # 收集家主数据
            member_first = self.game_data.get("Member_First", {}).get("value", [])
            if member_first and len(member_first) >= 4:
                member_first[0] = self.master_fields["member_first_id"].get()
                member_first[1] = self.master_fields["member_first_name"].get()
                member_first[2] = self.master_fields["member_first_image"].get()
                member_first[3] = self.master_fields["member_first_age"].get()
            
            # 收集皇室数据
            shijia_king = self.game_data.get("ShiJia_king", {}).get("value", [])
            if shijia_king and len(shijia_king) >= 6:
                shijia_king[0] = self.royal_fields["royal_name"].get()
                shijia_king[2] = self.royal_fields["royal_relation"].get()
                shijia_king[5] = self.royal_fields["royal_favor"].get()
            
            # 收集军事数据
            king_city_data = self.game_data.get("KingCityData_now", {}).get("value", [])
            if king_city_data and len(king_city_data) >= 1:
                army_count = self.military_fields["imperial_army_count"].get()
                army_morale = self.military_fields["imperial_army_morale"].get()
                king_city_data[0] = f"{army_count}|{army_morale}"
            
        except Exception as e:
            print(f"收集界面数据失败: {e}")
    
    def backup_save_file(self):
        """
        备份存档文件
        """
        if not self.save_file_path:
            messagebox.showwarning("警告", "请先加载存档文件")
            return
        
        try:
            timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
            backup_path = f"{self.save_file_path}.backup_{timestamp}"
            shutil.copy2(self.save_file_path, backup_path)
            messagebox.showinfo("成功", f"备份已创建:{os.path.basename(backup_path)}")
        except Exception as e:
            messagebox.showerror("错误", f"创建备份失败:{str(e)}")
    
    def validate_data(self):
        """
        验证数据完整性
        """
        if not self.game_data:
            messagebox.showwarning("警告", "请先加载存档文件")
            return
        
        # 简单的数据验证
        required_keys = ["Member_First", "ShiJia_Now", "MenKe_Now", "Fengdi_now"]
        missing_keys = [key for key in required_keys if key not in self.game_data]
        
        if missing_keys:
            messagebox.showwarning("数据验证", f"缺少以下关键数据:{', '.join(missing_keys)}")
        else:
            messagebox.showinfo("数据验证", "数据完整性检查通过")
    
    def reset_all_changes(self):
        """
        重置所有修改
        """
        if messagebox.askyesno("确认", "确定要重置所有修改吗?这将丢失所有未保存的更改。"):
            if self.save_file_path:
                self.load_save_file(self.save_file_path)
    
    def show_help(self):
        """
        显示使用说明
        """
        help_text = """
吾今有世家存档修改器使用说明:

1. 文件操作:
   - 打开存档:选择GameData.es3文件
   - 保存存档:保存修改到原文件
   - 另存为:保存到新文件
   - 备份存档:创建当前存档的备份

2. 修改功能:
   - 人物信息:修改家主、门客、官员等信息
   - 世家信息:修改皇室和各世家数据
   - 封地信息:修改封地状态和税率
   - 军事信息:修改禁军数量和士气

3. 注意事项:
   - 修改前请务必备份原始存档
   - 某些数值修改可能影响游戏平衡
   - 建议在测试存档上先试用

4. 原始数据:
   - 可以查看和搜索完整的JSON数据
   - 支持JSON格式化显示
   - 高级用户可直接编辑JSON
        """
        
        help_window = tk.Toplevel(self.root)
        help_window.title("使用说明")
        help_window.geometry("600x500")
        help_window.transient(self.root)
        
        text_widget = scrolledtext.ScrolledText(help_window, wrap=tk.WORD)
        text_widget.pack(fill=tk.BOTH, expand=True, padx=10, pady=10)
        text_widget.insert(1.0, help_text)
        text_widget.config(state=tk.DISABLED)
    
    def load_family_members_data(self):
        """
        加载家族成员数据(妻妾赘婿)
        """
        try:
            self.family_members_tree.delete(*self.family_members_tree.get_children())
            member_other_qu = self.game_data.get("Member_Other_qu", {}).get("value", [])
            
            for family_index, family_members in enumerate(member_other_qu):
                if family_members:  # 如果该世家有成员
                    for member in family_members:
                        if len(member) >= 15:
                            member_id = member[0]
                            # 解析姓名信息
                            name_info = member[2].split('|') if member[2] else []
                            name = name_info[0] if name_info else "未知"
                            
                            age = member[3] if len(member) > 3 else "0"
                            wen = member[4] if len(member) > 4 else "0"
                            wu = member[5] if len(member) > 5 else "0"
                            shang = member[6] if len(member) > 6 else "0"
                            yi = member[7] if len(member) > 7 else "0"
                            mood = member[8] if len(member) > 8 else "0"
                            health = member[14] if len(member) > 14 else "0"
                            charm = member[13] if len(member) > 13 else "0"
                            
                            # 解析性别
                            gender_info = name_info[4] if len(name_info) > 4 else "0"
                            gender = "女" if gender_info == "1" else "男"
                            
                            # 解析关系信息
                            relation_info = member[29] if len(member) > 29 else ""
                            relation = "配偶" if "100|100" in relation_info else "其他"
                            
                            self.family_members_tree.insert("", tk.END, values=(
                                member_id, name, age, gender, wen, wu, shang, yi, mood, health, charm, relation
                            ))
        except Exception as e:
            print(f"加载家族成员数据失败: {e}")
    
    def edit_family_member(self, event):
        """
        编辑家族成员信息
        """
        try:
            selection = self.family_members_tree.selection()
            if not selection:
                return
            
            item = self.family_members_tree.item(selection[0])
            values = item['values']
            
            # 创建编辑窗口
            edit_window = tk.Toplevel(self.root)
            edit_window.title("编辑家族成员信息")
            edit_window.geometry("500x600")
            edit_window.transient(self.root)
            edit_window.grab_set()
            
            # 创建输入字段
            entries = {}
            fields = [
                ("成员编号:", "member_id", values[0]),
                ("姓名:", "name", values[1]),
                ("年龄:", "age", values[2]),
                ("性别:", "gender", values[3]),
                ("文:", "wen", values[4]),
                ("武:", "wu", values[5]),
                ("商:", "shang", values[6]),
                ("艺:", "yi", values[7]),
                ("心情:", "mood", values[8]),
                ("健康:", "health", values[9]),
                ("魅力:", "charm", values[10]),
                ("关系:", "relation", values[11])
            ]
            
            for i, (label_text, field_key, current_value) in enumerate(fields):
                ttk.Label(edit_window, text=label_text).grid(row=i, column=0, sticky=tk.W, padx=10, pady=5)
                if field_key == "gender":
                    # 性别下拉框
                    entry = ttk.Combobox(edit_window, values=["男", "女"], state="readonly")
                    entry.set(current_value)
                elif field_key == "relation":
                    # 关系下拉框
                    entry = ttk.Combobox(edit_window, values=["配偶", "其他"], state="readonly")
                    entry.set(current_value)
                else:
                    entry = ttk.Entry(edit_window, width=30)
                    entry.insert(0, str(current_value))
                entry.grid(row=i, column=1, sticky=tk.W, padx=10, pady=5)
                entries[field_key] = entry
            
            def save_changes():
                try:
                    # 获取家族成员数据
                    member_other_qu = self.game_data.get("Member_Other_qu", {}).get("value", [])
                    member_id = entries["member_id"].get()
                    
                    # 查找并更新成员数据
                    found = False
                    for family_index, family_members in enumerate(member_other_qu):
                        if family_members:
                            for member_index, member in enumerate(family_members):
                                if len(member) > 0 and member[0] == member_id:
                                    # 更新成员数据
                                    if len(member) >= 15:
                                        # 更新姓名信息(保持原有格式)
                                        name_info = member[2].split('|') if member[2] else [""] * 10
                                        while len(name_info) < 10:
                                            name_info.append("")
                                        name_info[0] = entries["name"].get()
                                        name_info[4] = "1" if entries["gender"].get() == "女" else "0"
                                        member[2] = "|".join(name_info)
                                        
                                        # 更新其他属性
                                        member[3] = entries["age"].get()
                                        member[4] = entries["wen"].get()
                                        member[5] = entries["wu"].get()
                                        member[6] = entries["shang"].get()
                                        member[7] = entries["yi"].get()
                                        member[8] = entries["mood"].get()
                                        if len(member) > 13:
                                            member[13] = entries["charm"].get()
                                        if len(member) > 14:
                                            member[14] = entries["health"].get()
                                        
                                        # 更新关系信息
                                        if len(member) > 29:
                                            if entries["relation"].get() == "配偶":
                                                member[29] = "100|100"
                                            else:
                                                member[29] = "0|0"
                                        
                                        found = True
                                        break
                            if found:
                                break
                    
                    if found:
                        messagebox.showinfo("成功", "家族成员信息已更新")
                        self.load_family_members_data()  # 刷新显示
                    else:
                        messagebox.showerror("错误", "未找到对应的家族成员")
                    
                    edit_window.destroy()
                except Exception as e:
                    messagebox.showerror("错误", f"保存家族成员信息失败:{str(e)}")
            
            # 保存和取消按钮
            button_frame = ttk.Frame(edit_window)
            button_frame.grid(row=len(fields), column=0, columnspan=2, pady=20)
            ttk.Button(button_frame, text="保存", command=save_changes).pack(side=tk.LEFT, padx=10)
            ttk.Button(button_frame, text="取消", command=edit_window.destroy).pack(side=tk.LEFT, padx=10)
            
        except Exception as e:
            messagebox.showerror("错误", f"编辑家族成员信息失败:{str(e)}")
    
    def save_family_members_data(self):
        """
        保存家族成员信息
        """
        try:
            messagebox.showinfo("成功", "家族成员信息已保存")
        except Exception as e:
            messagebox.showerror("错误", f"保存家族成员信息失败:{str(e)}")
    
    def show_about(self):
        """
        显示关于对话框
        """
        about_text = """
吾今有世家 - 游戏存档修改器

版本: 2.3.1
开发: SnowZ

功能特点:
• 支持ES3格式存档文件
• 图形化界面操作
• 多种游戏数据修改
• 数据备份和验证
• 原始JSON数据查看
• 家族成员信息编辑

注意:
修改存档有风险,请谨慎操作!
使用前请备份原始存档文件。
        """
        
        messagebox.showinfo("关于", about_text)
    
    def run(self):
        """
        运行主程序
        """
        self.root.mainloop()

# 程序入口点
if __name__ == "__main__":
    # 导入额外的模块
    try:
        import tkinter.simpledialog
    except ImportError:
        pass
    
    # 创建并运行修改器
    editor = SaveEditor()
    editor.run()

文件下载请看文末,不一定会更新,有些功能还存在bug。

Download permission
View
  • Download for free
    Download after comment
    Download after login
  • {{attr.name}}:
Your current level is
Login for free downloadLogin Your account has been temporarily suspended and cannot be operated! Download after commentComment Download after paying points please firstLogin You have run out of downloads ( times) please come back tomorrow orUpgrade Membership Download after paying pointsPay Now Download after paying pointsPay Now Your current user level is not allowed to downloadUpgrade Membership
You have obtained download permission You can download resources every daytimes, remaining todaytimes left today
  • All rights reserved.
  • No part of this website, including text and images, may be reproduced, modified, distributed, or transmitted in any form or by any means, without the prior written permission of the author.
  • Unauthorized commercial use is strictly prohibited.
  • Unauthorized personal use is strictly prohibited.
0 comment A文章作者 M管理员
    No Comments Yet. Be the first to share what you think