Skip to content
This repository has been archived by the owner on Jun 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #23 from danch15/master
Browse files Browse the repository at this point in the history
Search box supports search TitleID and Fix some BUGs.
  • Loading branch information
Bob123a1 authored Sep 8, 2018
2 parents a3e8773 + 772886c commit 808ab17
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions CDNSP-GUI-Bob.py
Original file line number Diff line number Diff line change
Expand Up @@ -1739,14 +1739,21 @@ def __init__(self, root, titleID, titleKey, title, dbURL):
# Setup Treeview and Two Scrollbars
container = ttk.Frame(game_selection_frame)
container.grid(row=1, column=0, columnspan=2)
self.tree = ttk.Treeview(columns=("num", "G", "S"), show="headings", selectmode=EXTENDED)
self.tree = ttk.Treeview(columns=("num", "tid", "G", "S"), show="headings", selectmode=EXTENDED)
self.tree.bind('<<TreeviewSelect>>', self.game_info)
self.tree.heading("num", text="#", command=lambda c="num": self.sortby(self.tree, c, 0))
self.tree.column("num", width=40)
self.tree.heading("tid", text=_("TitleID"), command=lambda c="tid": self.sortby(self.tree, c, 0))
self.tree.column("tid", width=140)
self.tree.heading("G", text=_("Game"), command=lambda c="G": self.sortby(self.tree, c, 0))
self.tree.column("G", width=590)
self.tree.heading("S", text=_("State"), command=lambda c="S": self.sortby(self.tree, c, 0))
self.tree.column("S", width=130)
self.tree.heading("S", text=_("State"), command=lambda c="S": self.sortby(self.tree, c, 0))
columnWidth_S = 130
if chosen_lang == "zh-cn":
columnWidth_S = 45
elif chosen_lang == "en":
columnWidth_S = 55
self.tree.column("S", width=columnWidth_S)
vsb = ttk.Scrollbar(orient="vertical", command=self.tree.yview)
hsb = ttk.Scrollbar(orient="horizontal", command=self.tree.xview)
self.tree.configure(yscrollcommand=vsb.set, xscrollcommand=hsb.set)
Expand Down Expand Up @@ -2051,7 +2058,7 @@ def update_list(self, search=False, rebuild=False, label=_("Status:")):

if tid in updates_tid:
state = "Update"
tree_row = (str(number), game_name, state)
tree_row = (str(number), tid, game_name, state)
status_file.write(str(tree_row)+"\n")
status_file.close()
threading.Timer(1, self.done_status).start()
Expand All @@ -2063,11 +2070,12 @@ def update_list(self, search=False, rebuild=False, label=_("Status:")):
self.tree.delete(*self.tree.get_children())
for game_status in self.current_status:
number = game_status[0].strip()
game_name = game_status[1].strip()
state = game_status[2].strip()
tid = game_status[1].strip()
game_name = game_status[2].strip()
state = game_status[3].strip()

tree_row = (number, game_name, state)
if search_term.lower() in game_name.lower():
tree_row = (number, tid, game_name, state)
if search_term.lower().strip() in game_name.lower() or search_term.lower().strip() in tid.lower():
self.tree.insert('', 'end', values=tree_row)

else:
Expand All @@ -2078,11 +2086,11 @@ def update_list(self, search=False, rebuild=False, label=_("Status:")):
if line[-1] == "\n":
line = line[:-1]
if "New" in line:
line = line.replace("New", _("New"))
line = line.replace("'New'", "'" + _("New") + "'")
if "Own" in line:
line = line.replace("Own", _("Own"))
line = line.replace("'Own'", "'" + _("Own") + "'")
if "Update" in line:
line = line.replace("Update", _("Update"))
line = line.replace("'Update'", "'" + _("Update") + "'")
status_list = eval(line)
self.current_status.append(status_list)
self.update_list(search=True)
Expand All @@ -2094,6 +2102,7 @@ def update_list(self, search=False, rebuild=False, label=_("Status:")):
self.tree.yview_moveto(0)
# Reset the sorting back to default (descending)
self.tree.heading("num", text="#", command=lambda c="num": self.sortby(self.tree, c, 1))
self.tree.heading("tid", text=_("TitleID"), command=lambda c="tid": self.sortby(self.tree, c, 0))
self.tree.heading("G", text=_("Game"), command=lambda c="G": self.sortby(self.tree, c, 1))
self.tree.heading("S", text=_("State"), command=lambda c="S": self.sortby(self.tree, c, 1))

Expand Down Expand Up @@ -2166,7 +2175,7 @@ def threaded_game_info(self, evt):
subprocess.check_output("{0} -k keys.txt {1}\\control.nca --section0dir={1}\\section0".format(hactoolPath, result[0].replace("/", "\\")), shell=True)
else:
subprocess.check_output("{0} -k keys.txt '{1}/control.nca' --section0dir='{1}/section0'".format(hactoolPath, result[0]), shell=True)
icon_list = ["icon_AmericanEnglish.dat", "icon_BritishEnglish.dat", "icon_CanadianFrench.dat", "icon_German.dat", "icon_Italian.dat", "icon_Japanese.dat", "icon_LatinAmericanSpanish.dat", "icon_Spanish.dat"]
icon_list = ["icon_AmericanEnglish.dat", "icon_BritishEnglish.dat", "icon_CanadianFrench.dat", "icon_German.dat", "icon_Italian.dat", "icon_Japanese.dat", "icon_LatinAmericanSpanish.dat", "icon_Spanish.dat", "icon_Korean.dat"]
file_name = ""
dir_content = os.listdir(os.path.dirname(os.path.abspath(__file__))+'/Images/{}/section0/'.format(tid))
for i in icon_list:
Expand Down Expand Up @@ -2898,7 +2907,7 @@ def threaded_update_titlekeys(self):
info = ''
new_tid = []
for line in newdb:
if line.strip() not in currdb:
if line.strip() not in currdb and 'RightsID|TitleKey|Name' not in line:
if line.strip() != newdb[0].strip():
new_tid.append(line.strip().split('|')[0])
info += (line.strip()).rsplit('|',1)[1] + '\n'
Expand Down Expand Up @@ -2952,7 +2961,7 @@ def threaded_update_titlekeys(self):
self.titleID = []
self.titleKey = []
for line in newdb:
if line.strip():
if line.strip() and 'RightsID|TitleKey|Name' not in line:
self.title.append(line.strip().split("|")[2])
self.titleID.append(line.strip().split("|")[0][:16])
self.titleKey.append(line.strip().split("|")[1])
Expand All @@ -2979,7 +2988,7 @@ def threaded_update_titlekeys(self):
self.titleID = []
self.titleKey = []
for line in newdb:
if line.strip():
if line.strip() and 'RightsID|TitleKey|Name' not in line:
self.title.append(line.strip().split("|")[2])
self.titleID.append(line.strip().split("|")[0][:16])
self.titleKey.append(line.strip().split("|")[1])
Expand Down Expand Up @@ -3104,7 +3113,7 @@ def threaded_preload_images(self):
raise RuntimeError("command '{}' return with error (code {}): {}".format(e.cmd, e.returncode, e.output))
else:
subprocess.check_output("{0} -k keys.txt '{1}/control.nca' --section0dir='{1}/section0'".format(hactoolPath, result[0]), shell=True)
icon_list = ["icon_AmericanEnglish.dat", "icon_BritishEnglish.dat", "icon_CanadianFrench.dat", "icon_German.dat", "icon_Italian.dat", "icon_Japanese.dat", "icon_LatinAmericanSpanish.dat", "icon_Spanish.dat"]
icon_list = ["icon_AmericanEnglish.dat", "icon_BritishEnglish.dat", "icon_CanadianFrench.dat", "icon_German.dat", "icon_Italian.dat", "icon_Japanese.dat", "icon_LatinAmericanSpanish.dat", "icon_Spanish.dat", "icon_Korean.dat"]
file_name = ""
dir_content = os.listdir(os.path.dirname(os.path.abspath(__file__))+'/Images/{}/section0/'.format(tid))
for i in icon_list:
Expand Down Expand Up @@ -3404,11 +3413,12 @@ def filter_game(self):
self.tree.delete(*self.tree.get_children())
for game_status in self.current_status:
number = game_status[0].strip()
game_name = game_status[1].strip()
state = game_status[2].strip()
tid = game_status[1].strip()
game_name = game_status[2].strip()
state = game_status[3].strip()

tree_row = (number, game_name, state)
if search_term.lower() in game_name.lower():
tree_row = (number, tid, game_name, state)
if search_term.lower().strip() in game_name.lower() or search_term.lower().strip() in tid.lower():
self.tree.insert('', 'end', values=tree_row)

def sysver_zero(self):
Expand Down

0 comments on commit 808ab17

Please sign in to comment.