Skip to content

Commit

Permalink
get_list重写
Browse files Browse the repository at this point in the history
  • Loading branch information
Flash-Z authored Feb 8, 2023
1 parent e76b348 commit e3eae83
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
20 changes: 20 additions & 0 deletions ToDoList/todolist/UI.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from mcdreforged.api.rtext import *
from todolist.functions import functions as fun

prefix = '!!td'

help_head = """
Expand All @@ -11,3 +14,20 @@
f"§b{prefix} reload": "§r重载插件配置",
f"§b{prefix} add <name> <detail> <progress>": "§r添加/修改名为<name>的项目,可选参数为描述与进度",
}

def get_list(name):
list_msg = RTextList(
f'\n- ',
RText(f'[×] ', color = RColor.red).c(RAction.suggest_command, f'!!td del {name}')
.h(RText(f'Delete', color = RColor.red)),
RText(f'§b{name}').c(RAction.suggest_command,
f'!!td add {name} {fun.list_dic.get(name)["detail"][0]} {fun.list_dic.get(name)["progress"]}')
.h(
f'§r点击项目名以修改信息\n'
f'§7最后修改者:§6 {fun.list_dic.get(name)["creator"]} §7时间:§6 {fun.list_dic.get(name)["time"]}',
# f'\n§7项目类别:§6 {fun.list_dic.get(name)["tags"]}',
f'\n§7项目描述:§6 {fun.list_dic.get(name)["detail"][0]}' if fun.list_dic.get(name)["detail"][0] !="" else "",
f'\n§7进度描述:§6 {fun.list_dic.get(name)["progress"]}' if fun.list_dic.get(name)["progress"] !="" else ""
)
)
return list_msg
15 changes: 1 addition & 14 deletions ToDoList/todolist/operate_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,7 @@ def operate_list(server, info, args):
c.append(list_head)

for name, list_info in fun.list_dic.items():
list_msg = RTextList(
f'\n- ',
RText(f'[×] ', color = RColor.red).c(RAction.suggest_command, f'!!td del {name}')
.h(RText(f'Delete', color = RColor.red)),
RText(f'§b{name}').c(RAction.suggest_command,
f'!!td add {name} {fun.list_dic.get(name)["detail"][0]} {fun.list_dic.get(name)["progress"]}')
.h(
f'§r点击项目名以修改信息\n'
f'§7最后修改者:§6 {fun.list_dic.get(name)["creator"]} §7时间:§6 {fun.list_dic.get(name)["time"]}',
# f'\n§7项目类别:§6 {fun.list_dic.get(name)["tags"]}',
f'\n§7项目描述:§6 {fun.list_dic.get(name)["detail"][0]}' if fun.list_dic.get(name)["detail"][0] !="" else "",
f'\n§7进度描述:§6 {fun.list_dic.get(name)["progress"]}' if fun.list_dic.get(name)["progress"] !="" else ""
)
)
list_msg = get_list(name)
c.append(list_msg)
server.reply(info, RTextList(*c))

Expand Down

0 comments on commit e3eae83

Please sign in to comment.