mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 00:24:13 +08:00
add
This commit is contained in:
parent
3a7135a1bd
commit
192df621bb
@ -18,7 +18,7 @@ from myutils.utils import (
|
|||||||
minmaxmoveobservefunc,
|
minmaxmoveobservefunc,
|
||||||
parsemayberegexreplace,
|
parsemayberegexreplace,
|
||||||
kanjitrans,
|
kanjitrans,
|
||||||
checkifnewgame,
|
find_or_create_uid,
|
||||||
checkpostusing,
|
checkpostusing,
|
||||||
stringfyerror,
|
stringfyerror,
|
||||||
)
|
)
|
||||||
@ -483,11 +483,18 @@ class MAINUI:
|
|||||||
return
|
return
|
||||||
if not title:
|
if not title:
|
||||||
title = windows.GetWindowText(hwnd)
|
title = windows.GetWindowText(hwnd)
|
||||||
checkifnewgame(savehook_new_list, pexe, title)
|
|
||||||
if globalconfig["sourcestatus2"]["texthook"]["use"]:
|
if not globalconfig["sourcestatus2"]["texthook"]["use"]:
|
||||||
gameuid = findgameuidofpath(pexe, savehook_new_list)
|
return
|
||||||
self.textsource = texthook(pids, hwnd, pexe, gameuid)
|
gameuid = find_or_create_uid(savehook_new_list, pexe, title)
|
||||||
self.textsource.start()
|
if gameuid not in savehook_new_list:
|
||||||
|
savehook_new_list.insert(0, gameuid)
|
||||||
|
else:
|
||||||
|
if globalconfig["startgamenototop"] == False:
|
||||||
|
idx = savehook_new_list.index(gameuid)
|
||||||
|
savehook_new_list.insert(0, savehook_new_list.pop(idx))
|
||||||
|
self.textsource = texthook(pids, hwnd, pexe, gameuid)
|
||||||
|
self.textsource.start()
|
||||||
|
|
||||||
def starttextsource(self, use=None, checked=True):
|
def starttextsource(self, use=None, checked=True):
|
||||||
self.translation_ui.showhidestate = False
|
self.translation_ui.showhidestate = False
|
||||||
|
@ -23,7 +23,7 @@ from myutils.wrapper import (
|
|||||||
Singleton_close,
|
Singleton_close,
|
||||||
)
|
)
|
||||||
from myutils.utils import (
|
from myutils.utils import (
|
||||||
checkifnewgame,
|
find_or_create_uid,
|
||||||
str2rgba,
|
str2rgba,
|
||||||
gamdidchangedtask,
|
gamdidchangedtask,
|
||||||
titlechangedtask,
|
titlechangedtask,
|
||||||
@ -1769,9 +1769,14 @@ def addgamesingle(callback, targetlist):
|
|||||||
if res == "":
|
if res == "":
|
||||||
return
|
return
|
||||||
res = os.path.normpath(res)
|
res = os.path.normpath(res)
|
||||||
uid = checkifnewgame(targetlist, res)
|
uid = find_or_create_uid(targetlist, res)
|
||||||
if uid:
|
if uid in targetlist:
|
||||||
callback(uid)
|
idx = targetlist.index(uid)
|
||||||
|
if idx == 0:
|
||||||
|
return
|
||||||
|
targetlist.pop(idx)
|
||||||
|
targetlist.insert(0, uid)
|
||||||
|
callback(uid)
|
||||||
|
|
||||||
|
|
||||||
def addgamebatch(callback, targetlist):
|
def addgamebatch(callback, targetlist):
|
||||||
@ -1785,9 +1790,11 @@ def addgamebatch(callback, targetlist):
|
|||||||
path = os.path.normpath(os.path.abspath(os.path.join(_dir, _f)))
|
path = os.path.normpath(os.path.abspath(os.path.join(_dir, _f)))
|
||||||
if path.lower().endswith(".exe") == False:
|
if path.lower().endswith(".exe") == False:
|
||||||
continue
|
continue
|
||||||
uid = checkifnewgame(targetlist, path)
|
uid = find_or_create_uid(targetlist, path)
|
||||||
if uid:
|
if uid in targetlist:
|
||||||
callback(uid)
|
targetlist.pop(targetlist.index(uid))
|
||||||
|
targetlist.insert(0, uid)
|
||||||
|
callback(uid)
|
||||||
|
|
||||||
|
|
||||||
@Singleton_close
|
@Singleton_close
|
||||||
@ -1917,11 +1924,20 @@ class dialog_savedgame_new(QWidget):
|
|||||||
def clicked4(self):
|
def clicked4(self):
|
||||||
opendirforgameuid(self.currentfocusuid)
|
opendirforgameuid(self.currentfocusuid)
|
||||||
|
|
||||||
|
def addgame(self, uid):
|
||||||
|
if uid not in self.idxsave:
|
||||||
|
self.newline(uid, first=True)
|
||||||
|
else:
|
||||||
|
idx = self.idxsave.index(uid)
|
||||||
|
self.idxsave.pop(idx)
|
||||||
|
self.idxsave.insert(0, uid)
|
||||||
|
self.flow.totop1(idx)
|
||||||
|
|
||||||
def clicked3_batch(self):
|
def clicked3_batch(self):
|
||||||
addgamebatch(lambda uid: self.newline(uid, True), self.reflist)
|
addgamebatch(self.addgame, self.reflist)
|
||||||
|
|
||||||
def clicked3(self):
|
def clicked3(self):
|
||||||
addgamesingle(lambda uid: self.newline(uid, True), self.reflist)
|
addgamesingle(self.addgame, self.reflist)
|
||||||
|
|
||||||
def tagschanged(self, tags):
|
def tagschanged(self, tags):
|
||||||
self.currtags = tags
|
self.currtags = tags
|
||||||
@ -2318,7 +2334,7 @@ class LazyLoadTableView(QTableView):
|
|||||||
for i in range(len(self.widgetfunction)):
|
for i in range(len(self.widgetfunction)):
|
||||||
if self.widgetfunction[i][0] >= start:
|
if self.widgetfunction[i][0] >= start:
|
||||||
self.widgetfunction[i][0] += off
|
self.widgetfunction[i][0] += off
|
||||||
print(self.widgetfunction[i])
|
# print(self.widgetfunction[i])
|
||||||
|
|
||||||
self.loadVisibleRows()
|
self.loadVisibleRows()
|
||||||
|
|
||||||
@ -2367,16 +2383,21 @@ class dialog_savedgame_lagacy(QWidget):
|
|||||||
|
|
||||||
idx = self.table.currentIndex().row()
|
idx = self.table.currentIndex().row()
|
||||||
savehook_new_list.pop(idx)
|
savehook_new_list.pop(idx)
|
||||||
|
self.savelist.pop(idx)
|
||||||
self.model.removeRow(self.table.currentIndex().row())
|
self.model.removeRow(self.table.currentIndex().row())
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def clicked3(self):
|
def clicked3(self):
|
||||||
def call(uid):
|
def call(uid):
|
||||||
|
if uid in self.savelist:
|
||||||
|
idx = self.savelist.index(uid)
|
||||||
|
self.savelist.pop(idx)
|
||||||
|
self.model.removeRow(idx)
|
||||||
self.newline(0, uid)
|
self.newline(0, uid)
|
||||||
self.table.setCurrentIndex(self.model.index(0, 0))
|
self.table.setCurrentIndex(self.model.index(0, 0))
|
||||||
|
|
||||||
addgamesingle(call)
|
addgamesingle(call, savehook_new_list)
|
||||||
|
|
||||||
def clicked(self):
|
def clicked(self):
|
||||||
startgamecheck(
|
startgamecheck(
|
||||||
@ -2440,8 +2461,10 @@ class dialog_savedgame_lagacy(QWidget):
|
|||||||
table.setSelectionMode((QAbstractItemView.SelectionMode.SingleSelection))
|
table.setSelectionMode((QAbstractItemView.SelectionMode.SingleSelection))
|
||||||
table.setWordWrap(False)
|
table.setWordWrap(False)
|
||||||
self.table = table
|
self.table = table
|
||||||
|
self.savelist = []
|
||||||
for row, k in enumerate(savehook_new_list): # 2
|
for row, k in enumerate(savehook_new_list): # 2
|
||||||
self.newline(row, k)
|
self.newline(row, k)
|
||||||
|
self.savelist.append(k)
|
||||||
self.table.starttraceir()
|
self.table.starttraceir()
|
||||||
bottom = QHBoxLayout()
|
bottom = QHBoxLayout()
|
||||||
|
|
||||||
@ -3107,11 +3130,20 @@ class dialog_savedgame_v3(QWidget):
|
|||||||
def clicked4(self):
|
def clicked4(self):
|
||||||
opendirforgameuid(self.currentfocusuid)
|
opendirforgameuid(self.currentfocusuid)
|
||||||
|
|
||||||
|
def addgame(self, uid):
|
||||||
|
if uid not in self.reallist[self.reftagid]:
|
||||||
|
self.newline(uid)
|
||||||
|
else:
|
||||||
|
idx = self.reallist[self.reftagid].index(uid)
|
||||||
|
self.reallist[self.reftagid].pop(idx)
|
||||||
|
self.reallist[self.reftagid].insert(0, uid)
|
||||||
|
self.stack.w(calculatetagidx(self.reftagid)).torank1(idx)
|
||||||
|
|
||||||
def clicked3_batch(self):
|
def clicked3_batch(self):
|
||||||
addgamebatch(lambda uid: self.newline(uid), getreflist(self.reftagid))
|
addgamebatch(self.addgame, getreflist(self.reftagid))
|
||||||
|
|
||||||
def clicked3(self):
|
def clicked3(self):
|
||||||
addgamesingle(lambda uid: self.newline(uid), getreflist(self.reftagid))
|
addgamesingle(self.addgame, getreflist(self.reftagid))
|
||||||
|
|
||||||
def clicked(self):
|
def clicked(self):
|
||||||
startgamecheck(self, self.currentfocusuid)
|
startgamecheck(self, self.currentfocusuid)
|
||||||
|
@ -389,6 +389,15 @@ class lazyscrollflow(ScrollArea):
|
|||||||
if refresh:
|
if refresh:
|
||||||
self.resizeandshow()
|
self.resizeandshow()
|
||||||
|
|
||||||
|
@trypass
|
||||||
|
def totop1(self, idx):
|
||||||
|
if idx == 0:
|
||||||
|
return
|
||||||
|
with self.lock:
|
||||||
|
self.widgets.insert(0, self.widgets.pop(idx))
|
||||||
|
self.fakegeos.insert(0, self.fakegeos.pop(idx))
|
||||||
|
self.resizeandshow()
|
||||||
|
|
||||||
@trypass
|
@trypass
|
||||||
def removeidx(self, idx):
|
def removeidx(self, idx):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
@ -548,6 +557,8 @@ class delayloadvbox(QWidget):
|
|||||||
self._dovisinternal(False, self.nowvisregion)
|
self._dovisinternal(False, self.nowvisregion)
|
||||||
|
|
||||||
def torank1(self, i):
|
def torank1(self, i):
|
||||||
|
if i == 0:
|
||||||
|
return
|
||||||
with self.lock:
|
with self.lock:
|
||||||
self.internal_widgets.insert(0, self.internal_widgets.pop(i))
|
self.internal_widgets.insert(0, self.internal_widgets.pop(i))
|
||||||
self.internal_itemH.insert(0, self.internal_itemH.pop(i))
|
self.internal_itemH.insert(0, self.internal_itemH.pop(i))
|
||||||
|
@ -242,10 +242,8 @@ def initanewitem(title):
|
|||||||
return uid
|
return uid
|
||||||
|
|
||||||
|
|
||||||
def checkifnewgame(targetlist, gamepath, title=None):
|
def find_or_create_uid(targetlist, gamepath, title=None):
|
||||||
# 用于添加游戏时,全局查找是否有过历史记录
|
|
||||||
uids = findgameuidofpath(gamepath, findall=True)
|
uids = findgameuidofpath(gamepath, findall=True)
|
||||||
print(uids)
|
|
||||||
if len(uids) == 0:
|
if len(uids) == 0:
|
||||||
uid = initanewitem(title)
|
uid = initanewitem(title)
|
||||||
if title is None:
|
if title is None:
|
||||||
@ -256,19 +254,12 @@ def checkifnewgame(targetlist, gamepath, title=None):
|
|||||||
)
|
)
|
||||||
uid2gamepath[uid] = gamepath
|
uid2gamepath[uid] = gamepath
|
||||||
trysearchforid(uid, [title] + guessmaybetitle(gamepath, title))
|
trysearchforid(uid, [title] + guessmaybetitle(gamepath, title))
|
||||||
isnew = True
|
|
||||||
else:
|
|
||||||
isnew = True
|
|
||||||
for uid in uids:
|
|
||||||
if uid in targetlist:
|
|
||||||
isnew = False
|
|
||||||
break
|
|
||||||
|
|
||||||
if isnew:
|
|
||||||
targetlist.insert(0, uid)
|
|
||||||
return uid
|
return uid
|
||||||
else:
|
else:
|
||||||
return None
|
for uid in uids:
|
||||||
|
if uid in targetlist:
|
||||||
|
return uid
|
||||||
|
return uids[0]
|
||||||
|
|
||||||
|
|
||||||
kanjichs2ja = str.maketrans(static_data["kanjichs2ja"])
|
kanjichs2ja = str.maketrans(static_data["kanjichs2ja"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user