Ejemplo n.º 1
0
 def set(
     self,
     text_list: List[str],
     start_id: int,
     width: int,
     column: int,
     null_text: str = "",
     cmd_func: FunctionType = None,
     func_args: List[Tuple] = [],
 ):
     """
     设置绘制信息
     Keyword arguments:
     text_list -- 按钮文本列表
     start_id -- 编号的启始id
     width -- 绘制宽度
     column -- 每行最大元素数
     null_text -- 不作为按钮绘制的文本
     cmd_func -- 列表元素按钮绑定函数
     """
     self.width = width
     self.column = column
     new_text_list = value_handle.list_of_groups(text_list, column)
     index = start_id
     now_index = 0
     self.draw_list: List[List[draw.Button]] = []
     for now_text_list in new_text_list:
         now_width = int(width / len(now_text_list))
         now_list = []
         for now_text in now_text_list:
             if now_text != null_text:
                 now_text = text_handle.id_index(index) + now_text
                 now_button = draw.LeftButton(
                     now_text,
                     str(index),
                     now_width,
                     cmd_func=cmd_func,
                     args=(func_args[now_index]),
                 )
                 now_list.append(now_button)
                 self.return_list.append(str(index))
             else:
                 now_text = text_handle.id_index(index) + now_text
                 now_info_draw = draw.LeftDraw()
                 now_info_draw.width = now_width
                 now_info_draw.text = now_text
                 now_info_draw.style = "onbutton"
                 now_list.append(now_info_draw)
             index += 1
             now_index += 1
         self.draw_list.append(now_list)
Ejemplo n.º 2
0
 def __init__(self, text: Tuple[str, UUID], width: int, is_button: bool,
              num_button: bool, button_id: int):
     """ 初始化绘制对象 """
     self.text: UUID = text[1]
     """ 食物uid """
     self.cid: str = text[0]
     """ 食物商店索引id """
     self.draw_text: str = ""
     """ 食物名字绘制文本 """
     self.width: int = width
     """ 最大宽度 """
     self.num_button: bool = num_button
     """ 绘制数字按钮 """
     self.button_id: int = str(button_id)
     """ 按钮返回值 """
     self.button_return: str = str(button_id)
     """ 按钮返回值 """
     name_draw = draw.NormalDraw()
     food_data: game_type.Food = cache.restaurant_data[self.cid][self.text]
     quality_text_data = [_("垃圾"), _("饲料"), _("粮食"), _("美味"), _("春药")]
     food_name = ""
     if isinstance(self.cid, str):
         food_recipe: game_type.Recipes = cache.recipe_data[int(self.cid)]
         food_name = food_recipe.name
     else:
         food_config = game_config.config_food[self.cid]
         food_name = food_config.name
     hunger_text = _("热量:")
     if 27 in food_data.feel:
         hunger_text = f"{hunger_text}{round(food_data.feel[27],2)}"
     else:
         hunger_text = f"{hunger_text}0.00"
     thirsty_text = _("水份:")
     if 28 in food_data.feel:
         thirsty_text = f"{thirsty_text}{round(food_data.feel[28],2)}"
     else:
         thirsty_text = f"{thirsty_text}0.00"
     price = round(1 + sum(food_data.feel.values()) * food_data.quality, 2)
     food_name = (food_name + f" {hunger_text} {thirsty_text} " + _("重量:") +
                  str(round(food_data.weight, 2)) + _("克") + " " +
                  _("品质:") + quality_text_data[food_data.quality] + " " +
                  _("售价:" + str(price)))
     index_text = text_handle.id_index(button_id)
     button_text = f"{index_text}{food_name}"
     name_draw = draw.LeftButton(button_text,
                                 self.button_return,
                                 self.width,
                                 cmd_func=self.buy_food)
     self.now_draw = name_draw
     """ 绘制的对象 """
Ejemplo n.º 3
0
 def __init__(self, text: UUID, width: int, is_button: bool,
              num_button: bool, button_id: int):
     self.text: UUID = text
     """ 食物id """
     self.draw_text: str = ""
     """ 食物名字绘制文本 """
     self.width: int = width
     """ 最大宽度 """
     self.num_button: bool = num_button
     """ 绘制数字按钮 """
     self.button_id: int = str(button_id)
     """ 按钮返回值 """
     self.button_return: str = str(button_id)
     """ 按钮返回值 """
     name_draw = draw.NormalDraw()
     food_data: game_type.Food = cache.character_data[0].food_bag[self.text]
     quality_text_data = [_("垃圾"), _("饲料"), _("粮食"), _("美味"), _("春药")]
     food_name = ""
     if food_data.recipe != -1:
         food_recipe: game_type.Recipes = cache.recipe_data[
             food_data.recipe]
         food_name = food_recipe.name
     else:
         food_config = game_config.config_food[food_data.id]
         food_name = food_config.name
     hunger_text = _("热量:")
     if 27 in food_data.feel:
         hunger_text = f"{hunger_text}{round(food_data.feel[27],2)}"
     else:
         hunger_text = f"{hunger_text}0.00"
     thirsty_text = _("水份:")
     if 28 in food_data.feel:
         thirsty_text = f"{thirsty_text}{round(food_data.feel[28],2)}"
     else:
         thirsty_text = f"{thirsty_text}0.00"
     food_name = (food_name + f" {hunger_text} {thirsty_text} " + _("重量:") +
                  str(round(food_data.weight, 2)) + _("克") + " " +
                  _("品质:") + quality_text_data[food_data.quality])
     index_text = text_handle.id_index(button_id)
     button_text = f"{index_text}{food_name}"
     name_draw = draw.LeftButton(button_text,
                                 self.button_return,
                                 self.width,
                                 cmd_func=self.eat_food)
     self.now_draw = name_draw
     """ 绘制的对象 """
Ejemplo n.º 4
0
 def __init__(self, text: Tuple[str, str], width: int, is_button: bool,
              num_button: bool, button_id: int):
     """ 初始化绘制对象 """
     self.text = text[1]
     """ 食物名字 """
     self.cid = text[0]
     """ 食物在食堂内的表id """
     self.draw_text: str = ""
     """ 食物名字绘制文本 """
     self.width: int = width
     """ 最大宽度 """
     self.num_button: bool = num_button
     """ 绘制数字按钮 """
     self.button_id: int = button_id
     """ 数字按钮的id """
     self.button_return: str = str(button_id)
     """ 按钮返回值 """
     name_draw = draw.NormalDraw()
     if is_button:
         if num_button:
             index_text = text_handle.id_index(button_id)
             button_text = f"{index_text}{self.text}"
             name_draw = draw.LeftButton(
                 button_text,
                 self.button_return,
                 self.width,
                 cmd_func=self.see_food_shop_food_list)
         else:
             button_text = f"[{self.text}]"
             name_draw = draw.CenterButton(
                 button_text,
                 self.text,
                 self.width,
                 cmd_func=self.see_food_shop_food_list)
             self.button_return = text
         self.draw_text = button_text
     else:
         name_draw = draw.CenterDraw()
         name_draw.text = f"[{self.text}]"
         name_draw.width = self.width
         self.draw_text = name_draw.text
     self.now_draw = name_draw
     """ 绘制的对象 """
Ejemplo n.º 5
0
 def draw(self):
     """ 绘制面板 """
     self.return_list = []
     map_path_str = map_handle.get_map_system_path_str_for_list(
         self.now_map)
     map_data: game_type.Map = cache.map_data[map_path_str]
     path_edge = map_data.path_edge
     scene_id_list = list(path_edge.keys())
     if len(scene_id_list):
         character_data: game_type.Character = cache.character_data[0]
         character_scene_id = map_handle.get_map_scene_id_for_scene_path(
             self.now_map, character_data.position)
         scene_path = path_edge[character_scene_id].copy()
         if character_scene_id in scene_path:
             del scene_path[character_scene_id]
         scene_path_list = list(scene_path.keys())
         draw_list = []
         for scene_id in scene_id_list:
             load_scene_data = map_handle.get_scene_data_for_map(
                 map_path_str, scene_id)
             now_scene_path = map_handle.get_map_system_path_for_str(
                 load_scene_data.scene_path)
             now_id_text = f"{scene_id}:{load_scene_data.scene_name}"
             now_draw = draw.LeftButton(now_id_text,
                                        now_id_text,
                                        self.width,
                                        cmd_func=self.move_now,
                                        args=(now_scene_path, ))
             self.return_list.append(now_draw.return_text)
             draw_list.append(now_draw)
         draw_group = value_handle.list_of_groups(draw_list, 4)
         now_width_index = 0
         for now_draw_list in draw_group:
             if len(now_draw_list) > now_width_index:
                 now_width_index = len(now_draw_list)
         now_width = self.width / now_width_index
         for now_draw_list in draw_group:
             for now_draw in now_draw_list:
                 now_draw.width = now_width
                 now_draw.draw()
             line_feed.draw()
     self.end_index = len(scene_id_list) - 1
Ejemplo n.º 6
0
 def __init__(self, text: int, width: int, is_button: bool,
              num_button: bool, button_id: int):
     """ 初始化绘制对象 """
     self.text = text
     """ 道具id """
     self.draw_text: str = ""
     """ 道具名字绘制文本 """
     self.width: int = width
     """ 最大宽度 """
     self.num_button: bool = num_button
     """ 绘制数字按钮 """
     self.button_id: int = button_id
     """ 数字按钮的id """
     self.button_return: str = str(button_id)
     """ 按钮返回值 """
     name_draw = draw.NormalDraw()
     item_config = game_config.config_item[self.text]
     if is_button:
         if num_button:
             index_text = text_handle.id_index(button_id)
             button_text = f"{index_text}{item_config.name}"
             name_draw = draw.LeftButton(button_text,
                                         self.button_return,
                                         self.width,
                                         cmd_func=self.buy_item)
         else:
             button_text = f"[{item_config.name}]"
             name_draw = draw.CenterButton(button_text,
                                           item_config.name,
                                           self.width,
                                           cmd_func=self.buy_item)
             self.button_return = item_config.name
         self.draw_text = button_text
     else:
         name_draw = draw.CenterDraw()
         name_draw.text = f"[{item_config.name}]"
         name_draw.width = self.width
         self.draw_text = name_draw.text
     self.now_draw = name_draw
     """ 绘制的对象 """
Ejemplo n.º 7
0
 def draw(self):
     """ 绘制操作菜单面板 """
     self.return_list = []
     line = draw.LineDraw("-.-", self.width)
     line.draw()
     fix_draw = draw.NormalDraw()
     fix_width = int(
         (self.width - int(self.width / len(cache.instruct_filter)) * len(cache.instruct_filter)) / 2
     )
     fix_draw.width = fix_width
     fix_draw.text = " " * fix_width
     fix_draw.draw()
     for now_type in cache.instruct_filter:
         now_config = game_config.config_instruct_type[now_type]
         if cache.instruct_filter[now_type]:
             now_button = draw.CenterButton(
                 f"[{now_config.name}]",
                 now_config.name,
                 self.width / len(cache.instruct_filter),
                 " ",
                 "onbutton",
                 "standard",
                 cmd_func=self.change_filter,
                 args=(now_type,),
             )
         else:
             now_button = draw.CenterButton(
                 f"[{now_config.name}]",
                 now_config.name,
                 self.width / len(cache.instruct_filter),
                 cmd_func=self.change_filter,
                 args=(now_type,),
             )
         now_button.width = int(self.width / len(cache.instruct_filter))
         self.return_list.append(now_button.return_text)
         now_button.draw()
     line_feed.draw()
     line = draw.LineDraw("~..", self.width)
     line.draw()
     now_instruct_list = []
     now_premise_data = {}
     for now_type in cache.instruct_filter:
         if cache.instruct_filter[now_type] and now_type in constant.instruct_type_data:
             for instruct in constant.instruct_type_data[now_type]:
                 premise_judge = 0
                 if instruct in constant.instruct_premise_data:
                     for premise in constant.instruct_premise_data[instruct]:
                         if premise in now_premise_data:
                             if now_premise_data[premise]:
                                 continue
                             premise_judge = 1
                             break
                         else:
                             now_premise_value = handle_premise.handle_premise(premise, 0)
                             now_premise_data[premise] = now_premise_value
                             if not now_premise_value:
                                 premise_judge = 1
                                 break
                 if premise_judge:
                     continue
                 now_instruct_list.append(instruct)
     now_instruct_list.sort()
     instruct_group = value_handle.list_of_groups(now_instruct_list, 3)
     now_draw_list = []
     for instruct_list in instruct_group:
         for instruct_id in instruct_list:
             instruct_name = constant.handle_instruct_name_data[instruct_id]
             id_text = text_handle.id_index(instruct_id)
             now_text = f"{id_text}{instruct_name}"
             now_draw = draw.LeftButton(
                 now_text,
                 str(instruct_id),
                 int(self.width / len(instruct_group)),
                 cmd_func=self.handle_instruct,
                 args=(instruct_id,),
             )
             now_draw_list.append(now_draw)
             self.return_list.append(now_draw.return_text)
     now_draw = panel.VerticalDrawTextListGroup(self.width)
     now_group = value_handle.list_of_groups(now_draw_list, 3)
     now_draw.draw_list = now_group
     now_draw.draw()
Ejemplo n.º 8
0
 def draw(self):
     """ 绘制对象 """
     while 1:
         if cache.now_panel_id != constant.Panel.SEE_MAP:
             break
         map_path_str = map_handle.get_map_system_path_str_for_list(self.now_map)
         map_data: game_type.Map = cache.map_data[map_path_str]
         map_name = attr_text.get_map_path_text(self.now_map)
         title_draw = draw.TitleLineDraw(_("移动:") + map_name, self.width)
         title_draw.draw()
         now_draw_list: game_type.MapDraw = map_data.map_draw
         character_data: game_type.Character = cache.character_data[0]
         character_scene_id = map_handle.get_map_scene_id_for_scene_path(
             self.now_map, character_data.position
         )
         return_list = []
         for now_draw_line in now_draw_list.draw_text:
             fix_width = int((self.width - now_draw_line.width) / 2)
             fix_text = " " * fix_width
             fix_draw = draw.NormalDraw()
             fix_draw.text = fix_text
             fix_draw.width = fix_width
             fix_draw.draw()
             for draw_text in now_draw_line.draw_list:
                 if draw_text.is_button and draw_text.text != character_scene_id:
                     scene_path = map_handle.get_scene_path_for_map_scene_id(
                         self.now_map, draw_text.text
                     )
                     now_draw = draw.Button(
                         draw_text.text, draw_text.text, cmd_func=self.move_now, args=(scene_path,)
                     )
                     now_draw.width = self.width
                     now_draw.draw()
                     return_list.append(now_draw.return_text)
                 else:
                     now_draw = draw.NormalDraw()
                     now_draw.text = draw_text.text
                     now_draw.width = self.width
                     if draw_text.is_button and draw_text.text == character_scene_id:
                         now_draw.style = "nowmap"
                     now_draw.draw()
             line_feed.draw()
         path_edge = map_data.path_edge
         scene_path = path_edge[character_scene_id].copy()
         if character_scene_id in scene_path:
             del scene_path[character_scene_id]
         scene_path_list = list(scene_path.keys())
         if len(scene_path_list):
             line = draw.LineDraw(".", self.width)
             line.draw()
             message_draw = draw.NormalDraw()
             message_draw.text = _("你可以从这里前往:\n")
             message_draw.width = self.width
             message_draw.draw()
             draw_list = []
             for scene in scene_path_list:
                 load_scene_data = map_handle.get_scene_data_for_map(map_path_str, scene)
                 now_scene_path = map_handle.get_map_system_path_for_str(load_scene_data.scene_path)
                 now_draw = draw.CenterButton(
                     f"[{load_scene_data.scene_name}]",
                     load_scene_data.scene_name,
                     self.width / 4,
                     cmd_func=self.move_now,
                     args=(now_scene_path,),
                 )
                 return_list.append(now_draw.return_text)
                 draw_list.append(now_draw)
             draw_group = value_handle.list_of_groups(draw_list, 4)
             for now_draw_list in draw_group:
                 for now_draw in now_draw_list:
                     now_draw.draw()
                 line_feed.draw()
         scene_id_list = list(path_edge.keys())
         if len(scene_id_list):
             line = draw.LineDraw(".", self.width)
             line.draw()
             message_draw = draw.NormalDraw()
             message_draw.text = _("场景名列表:\n")
             message_draw.width = self.width
             message_draw.draw()
             draw_list = []
             for scene_id in scene_id_list:
                 load_scene_data = map_handle.get_scene_data_for_map(map_path_str, scene_id)
                 now_scene_path = map_handle.get_map_system_path_for_str(load_scene_data.scene_path)
                 now_id_text = f"{scene_id}:{load_scene_data.scene_name}"
                 now_draw = draw.LeftButton(
                     now_id_text, now_id_text, self.width, cmd_func=self.move_now, args=(now_scene_path,)
                 )
                 return_list.append(now_draw.return_text)
                 draw_list.append(now_draw)
             draw_group = value_handle.list_of_groups(draw_list, 4)
             now_width_index = 0
             for now_draw_list in draw_group:
                 if len(now_draw_list) > now_width_index:
                     now_width_index = len(now_draw_list)
             now_width = self.width / now_width_index
             for now_draw_list in draw_group:
                 for now_draw in now_draw_list:
                     now_draw.width = now_width
                     now_draw.draw()
                 line_feed.draw()
         line = draw.LineDraw("=", self.width)
         line.draw()
         now_index = len(scene_id_list)
         if self.now_map != []:
             now_id = text_handle.id_index(now_index)
             now_text = now_id + _("查看上级地图")
             up_button = draw.CenterButton(
                 now_text, str(now_index), self.width / 3, cmd_func=self.up_map
             )
             up_button.draw()
             return_list.append(up_button.return_text)
             now_index += 1
         else:
             now_draw = draw.NormalDraw()
             now_draw.text = " " * int(self.width / 3)
             now_draw.width = self.width / 3
             now_draw.draw()
         back_id = text_handle.id_index(now_index)
         now_text = back_id + _("返回")
         back_button = draw.CenterButton(now_text, str(now_index), self.width / 3)
         back_button.draw()
         return_list.append(back_button.return_text)
         now_index += 1
         character_map = map_handle.get_map_for_path(character_data.position)
         if character_map != self.now_map:
             now_id = text_handle.id_index(now_index)
             now_text = now_id + _("查看下级地图")
             down_button = draw.CenterButton(
                 now_text, str(now_index), self.width / 3, cmd_func=self.down_map
             )
             down_button.draw()
             return_list.append(down_button.return_text)
         line_feed.draw()
         yrn = flow_handle.askfor_all(return_list)
         py_cmd.clr_cmd()
         if yrn == back_button.return_text:
             cache.now_panel_id = constant.Panel.IN_SCENE
             break