Example #1
0
def init_name_data():
    """ 载入json内姓名配置数据 """
    global man_name_data
    global woman_name_data
    global family_data
    name_data = json_handle.load_json(name_json_path)
    init_name_region(name_data["Boys"], 0)
    init_name_region(name_data["Girls"], 1)
    family_data = json_handle.load_json(family_json_path)["FamilyNameList"]
    init_name_region(family_data, 2)
Example #2
0
def load_config_data() -> dict:
    """
    读取游戏配置数据
    """
    config_path = os.path.join(game_path, "data", "core_cfg.json")
    config_data = json_handle.load_json(config_path)
    return config_data
Example #3
0
def load_dir_now(data_path: str):
    """
    获取路径下的地图数据
    Keyword arguments:
    data_path -- 地图路径
    """
    for i in os.listdir(data_path):
        now_path = os.path.join(data_path, i)
        if os.path.isfile(now_path):
            now_file = i.split(".")
            if len(now_file) > 1:
                if now_file[1] == "json":
                    if now_file[0] == "Scene":
                        now_scene_data = game_type.Scene()
                        now_scene_data.scene_path = get_map_system_path_str(
                            get_map_system_path_for_path(now_path))
                        load_scene_data = json_handle.load_json(now_path)
                        now_scene_data.scene_name = get_text._(
                            load_scene_data["SceneName"])
                        now_scene_data.in_door = load_scene_data[
                            "InOutDoor"] == "In"
                        now_scene_data.scene_tag = load_scene_data["SceneTag"]
                        cache.scene_data[
                            now_scene_data.scene_path] = now_scene_data
                        cache.place_data.setdefault(now_scene_data.scene_tag,
                                                    [])
                        cache.place_data[now_scene_data.scene_tag].append(
                            now_scene_data.scene_path)
                    elif now_file[0] == "Map":
                        now_map_data = game_type.Map()
                        now_map_data.map_path = get_map_system_path_str(
                            get_map_system_path_for_path(now_path))
                        with open(os.path.join(data_path, "Map"),
                                  "r") as now_read_file:
                            draw_data = now_read_file.read()
                            now_map_data.map_draw = get_print_map_data(
                                draw_data)
                        load_map_data = json_handle.load_json(now_path)
                        now_map_data.map_name = get_text._(
                            load_map_data["MapName"])
                        now_map_data.path_edge = load_map_data["PathEdge"]
                        now_map_data.sorted_path = get_sorted_map_path_data(
                            now_map_data.path_edge)
                        cache.map_data[now_map_data.map_path] = now_map_data
        else:
            load_dir_now(now_path)
Example #4
0
def get_font_data_list() -> list:
    """
    读取游戏字体样式配置列表
    """
    font_path = os.path.join(game_path, "data", "FontConfig.json")
    font_data = json_handle.load_json(font_path)
    font_list = list(font_data.keys())
    return font_list
Example #5
0
def get_font_data(font_id: str) -> dict:
    """
    读取游戏字体样式配置数据
    Keyword arguments:
    list_id -- 字体样式
    """
    font_path = os.path.join(game_path, "data", "FontConfig.json")
    font_data = json_handle.load_json(font_path)
    return font_data[font_id]
Example #6
0
def init_map_data():
    """ 载入地图和场景数据 """
    if (os.path.exists(all_scene_data_path)
            and os.path.exists(all_map_data_path)
            and os.path.exists(all_place_data_path)
            and os.path.exists(scene_path_edge_path)):
        with open(all_scene_data_path, "rb") as all_scene_data_file:
            cache.scene_data = pickle.load(all_scene_data_file)
        with open(all_map_data_path, "rb") as all_map_data_file:
            cache.map_data = pickle.load(all_map_data_file)
        with open(all_place_data_path, "rb") as all_place_data_file:
            constant.place_data = pickle.load(all_place_data_file)
        map_handle.scene_path_edge = json_handle.load_json(
            scene_path_edge_path)
    else:
        load_dir_now(map_data_path)
        with open(all_map_data_path, "wb") as all_map_data_file:
            pickle.dump(cache.map_data, all_map_data_file)
        with open(all_scene_data_path, "wb") as all_scene_data_file:
            pickle.dump(cache.scene_data, all_scene_data_file)
        with open(all_place_data_path, "wb") as all_place_data_file:
            pickle.dump(constant.place_data, all_place_data_file)
        map_handle.init_scene_edge_path_data()
Example #7
0
def load_dir_now(data_path: str):
    """
    获取路径下的游戏数据
    Keyword arguments:
    data_path -- 要载入数据的路径
    """
    now_data = {}
    if os.listdir(data_path):
        for i in os.listdir(data_path):
            now_path = os.path.join(data_path, i)
            if os.path.isfile(now_path):
                now_file = i.split(".")
                if len(now_file) > 1:
                    if now_file[1] == "json":
                        if now_file[0] == "Scene":
                            now_scene_data = {}
                            map_system_path = get_map_system_path_for_path(
                                now_path)
                            map_system_path_str = get_map_system_path_str(
                                map_system_path)
                            load_scene_data = json_handle.load_json(now_path)
                            now_scene_data.update(load_scene_data)
                            now_scene_data["SceneCharacterData"] = {}
                            now_scene_data["ScenePath"] = map_system_path
                            now_scene_data = {
                                map_system_path_str: now_scene_data
                            }
                            scene_data.update(now_scene_data)
                            now_scene_tag = load_scene_data["SceneTag"]
                            if now_scene_tag not in cache_contorl.place_data:
                                cache_contorl.place_data[now_scene_tag] = []
                            cache_contorl.place_data[now_scene_tag].append(
                                map_system_path_str)
                        elif now_file[0] == "Map":
                            now_map_data = {}
                            map_system_path = get_map_system_path_for_path(
                                now_path)
                            now_map_data["MapPath"] = map_system_path
                            with open(os.path.join(data_path, "Map"),
                                      "r") as now_read_file:
                                draw_data = now_read_file.read()
                                now_map_data["MapDraw"] = get_print_map_data(
                                    draw_data)
                            map_system_path_str = get_map_system_path_str(
                                map_system_path)
                            now_map_data.update(
                                json_handle.load_json(now_path))
                            cache_contorl.now_init_map_id = map_system_path_str
                            sorted_path_data = get_sorted_map_path_data(
                                now_map_data["PathEdge"])
                            now_map_data["SortedPath"] = sorted_path_data
                            map_data[map_system_path_str] = now_map_data
                        else:
                            if now_file[0] == "NameIndex":
                                data = json_handle.load_json(now_path)
                                init_name_region(data["Boys"], 0)
                                init_name_region(data["Girls"], 1)
                            elif now_file[0] == "FamilyIndex":
                                data = json_handle.load_json(now_path)
                                init_name_region(data["FamilyNameList"], 2)
                            else:
                                now_data[now_file[0]] = json_handle.load_json(
                                    now_path)
                                if now_file[0] == "Equipment":
                                    init_clothing_data(
                                        now_data[now_file[0]]["Clothing"])
                                elif now_file[0] == "StatureDescription":
                                    init_stature_description(
                                        now_data[now_file[0]]["Priority"])
                                elif now_file[0] == "WearItem":
                                    init_wear_item_type_data(
                                        now_data[now_file[0]]["Item"])
            else:
                now_data[i] = load_dir_now(now_path)
    return now_data
Example #8
0
def load_data_json():
    """ 载入data.json内配置数据 """
    global config_data
    config_data = json_handle.load_json(data_path)
Example #9
0
    json_handle,
    constant,
)
from Script.Design import (
    proportional_bar,
    attr_print,
    attr_calculation,
    map_handle,
)

language = game_config.language
game_path = game_path_config.game_path

ROLE_ATTR_FILE_PATH = os.path.join(game_path, "data", language,
                                   "RoleAttributes.json")
role_attr_data = json_handle.load_json(ROLE_ATTR_FILE_PATH)
sex_data = role_attr_data["Sex"]
EQUIPMENT_FILE_PATH = os.path.join(game_path, "data", language,
                                   "Equipment.json")
equipment_data = json_handle.load_json(EQUIPMENT_FILE_PATH)


def get_sex_experience_text(sex_experience_data: dict, sex_name: str) -> list:
    """
    获取性经验描述文本
    Keyword arguments:
    sex_experience_data -- 性经验数据列表
    sex_name -- 性别
    """
    mouth_experience = (
        text_loading.get_text_data(constant.FilePath.STAGE_WORD_PATH, "19") +
Example #10
0
    cache_contorl,
    game_config,
    game_path_config,
    text_loading,
    json_handle,
    value_handle,
    constant,
)
from Script.Design import game_time

language = game_config.language
game_path = game_path_config.game_path
role_attr_path = os.path.join(
    game_path, "data", language, "RoleAttributes.json"
)
role_attr_data = json_handle.load_json(role_attr_path)


def get_tem_list() -> dict:
    """
    获取人物生成模板
    """
    return text_loading.get_text_data(
        constant.FilePath.ATTR_TEMPLATE_PATH, "TemList"
    )


def get_features_list() -> dict:
    """
    获取特征模板
    """