diff --git a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py index 5bfebd7b..3f227953 100644 --- a/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py +++ b/LunaTranslator/LunaTranslator/gui/dialog_savedgame.py @@ -28,6 +28,7 @@ from myutils.wrapper import ( from myutils.utils import ( find_or_create_uid, str2rgba, + duplicateconfig, get_time_stamp, gamdidchangedtask, checkpostlangmatch, @@ -1729,7 +1730,7 @@ def startgamecheck(self, gameuid): startgame(gameuid) -def addgamesingle(callback, targetlist): +def addgamesingle(parent, callback, targetlist): f = QFileDialog.getOpenFileName(options=QFileDialog.Option.DontResolveSymlinks) res = f[0] @@ -1739,9 +1740,19 @@ def addgamesingle(callback, targetlist): uid = find_or_create_uid(targetlist, res) if uid in targetlist: idx = targetlist.index(uid) - if idx == 0: - return - targetlist.pop(idx) + response = QMessageBox.question( + parent, + "", + _TR("游戏已存在,是否重复添加?"), + QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, + QMessageBox.StandardButton.No, + ) + if response == QMessageBox.StandardButton.No: + if idx == 0: + return + targetlist.pop(idx) + else: + uid = duplicateconfig(uid) targetlist.insert(0, uid) callback(uid) @@ -1904,7 +1915,7 @@ class dialog_savedgame_new(QWidget): addgamebatch(self.addgame, self.reflist) def clicked3(self): - addgamesingle(self.addgame, self.reflist) + addgamesingle(self, self.addgame, self.reflist) def tagschanged(self, tags): self.currtags = tags @@ -2365,7 +2376,7 @@ class dialog_savedgame_lagacy(QWidget): self.newline(0, uid) self.table.setCurrentIndex(self.model.index(0, 0)) - addgamesingle(call, savehook_new_list) + addgamesingle(self, call, savehook_new_list) def clicked(self): startgamecheck( @@ -3462,7 +3473,7 @@ class dialog_savedgame_v3(QWidget): addgamebatch(self.addgame, getreflist(self.reftagid)) def clicked3(self): - addgamesingle(self.addgame, getreflist(self.reftagid)) + addgamesingle(self, self.addgame, getreflist(self.reftagid)) def clicked(self): startgamecheck(self, self.currentfocusuid) diff --git a/LunaTranslator/LunaTranslator/myutils/utils.py b/LunaTranslator/LunaTranslator/myutils/utils.py index fefd7320..4c27330c 100644 --- a/LunaTranslator/LunaTranslator/myutils/utils.py +++ b/LunaTranslator/LunaTranslator/myutils/utils.py @@ -2,7 +2,7 @@ import windows import os, time import codecs, hashlib, shutil import socket, gobject, uuid, subprocess, functools -import ctypes, importlib +import ctypes, importlib, json import ctypes.wintypes from qtsymbols import * from traceback import print_exc @@ -249,6 +249,12 @@ def initanewitem(title): return uid +def duplicateconfig(uidold): + uid = f"{time.time()}_{uuid.uuid4()}" + savehook_new_data[uid] = json.loads(json.dumps(savehook_new_data[uidold])) + return uid + + def find_or_create_uid(targetlist, gamepath, title=None): uids = findgameuidofpath(gamepath, findall=True) if len(uids) == 0: @@ -263,10 +269,15 @@ def find_or_create_uid(targetlist, gamepath, title=None): trysearchforid(uid, [title] + guessmaybetitle(gamepath, title)) return uid else: + intarget = uids[0] + index = len(targetlist) for uid in uids: if uid in targetlist: - return uid - return uids[0] + thisindex = targetlist.index(uid) + if thisindex < index: + index = thisindex + intarget = uid + return intarget kanjichs2ja = str.maketrans(static_data["kanjichs2ja"]) @@ -517,7 +528,7 @@ def parsemayberegexreplace(lst: list, line: str): if escape: line = line.replace( codecs.escape_decode(bytes(key, "utf-8"))[0].decode("utf-8"), - codecs.escape_decode(bytes(value, "utf-8"))[0].decode("utf-8") + codecs.escape_decode(bytes(value, "utf-8"))[0].decode("utf-8"), ) else: line = line.replace(key, value) diff --git a/LunaTranslator/files/lang/ar.json b/LunaTranslator/files/lang/ar.json index a830f692..14c03270 100644 --- a/LunaTranslator/files/lang/ar.json +++ b/LunaTranslator/files/lang/ar.json @@ -852,5 +852,6 @@ "作用于翻译": "العمل على الترجمة", "字符串替换": "سلسلة استبدال", "转义": "هروب", - "不推荐使用": "لا ينصح باستخدام" + "不推荐使用": "لا ينصح باستخدام", + "游戏已存在,是否重复添加?": "اللعبة موجودة بالفعل ، هل تريد تكرار ذلك ؟" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cht.json b/LunaTranslator/files/lang/cht.json index ba45e54d..fe9d9c45 100644 --- a/LunaTranslator/files/lang/cht.json +++ b/LunaTranslator/files/lang/cht.json @@ -852,5 +852,6 @@ "作用于翻译": "作用於翻譯", "字符串替换": "字串替換", "转义": "轉義", - "不推荐使用": "不推薦使用" + "不推荐使用": "不推薦使用", + "游戏已存在,是否重复添加?": "遊戲已存在,是否重複添加?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/cs.json b/LunaTranslator/files/lang/cs.json index af05379f..a13dd52b 100644 --- a/LunaTranslator/files/lang/cs.json +++ b/LunaTranslator/files/lang/cs.json @@ -852,5 +852,6 @@ "作用于翻译": "Použití na překlad", "字符串替换": "Náhrada řetězce", "转义": "Útěk", - "不推荐使用": "Nedoporučuje se k použití" + "不推荐使用": "Nedoporučuje se k použití", + "游戏已存在,是否重复添加?": "Hra již existuje, chtěli byste ji znovu přidat?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/de.json b/LunaTranslator/files/lang/de.json index 499bb402..5d5a6561 100644 --- a/LunaTranslator/files/lang/de.json +++ b/LunaTranslator/files/lang/de.json @@ -852,5 +852,6 @@ "作用于翻译": "Auf Übersetzungen angewendet", "字符串替换": "Zeichenfolgenersatz", "转义": "Flucht", - "不推荐使用": "Nicht empfohlen für die Anwendung" + "不推荐使用": "Nicht empfohlen für die Anwendung", + "游戏已存在,是否重复添加?": "Das Spiel existiert bereits, möchtest du es noch einmal hinzufügen?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/en.json b/LunaTranslator/files/lang/en.json index 33a6c877..96471f0d 100644 --- a/LunaTranslator/files/lang/en.json +++ b/LunaTranslator/files/lang/en.json @@ -852,5 +852,6 @@ "作用于翻译": "Applied to translation", "字符串替换": "String replacement", "转义": "Escaping", - "不推荐使用": "Not recommended for use" + "不推荐使用": "Not recommended for use", + "游戏已存在,是否重复添加?": "The game already exists, would you like to add it again?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/es.json b/LunaTranslator/files/lang/es.json index b3a793e1..3041d6ce 100644 --- a/LunaTranslator/files/lang/es.json +++ b/LunaTranslator/files/lang/es.json @@ -852,5 +852,6 @@ "作用于翻译": "Actuar sobre la traducción", "字符串替换": "Reemplazo de cadenas", "转义": "Transliteración", - "不推荐使用": "No se recomienda usar" + "不推荐使用": "No se recomienda usar", + "游戏已存在,是否重复添加?": "¿El juego ya existe, ¿ se repite la adición?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/fr.json b/LunaTranslator/files/lang/fr.json index 504110d9..64109aa7 100644 --- a/LunaTranslator/files/lang/fr.json +++ b/LunaTranslator/files/lang/fr.json @@ -852,5 +852,6 @@ "作用于翻译": "Agir sur la traduction", "字符串替换": "Remplacement de chaîne", "转义": "échappement", - "不推荐使用": "Utilisation non recommandée" + "不推荐使用": "Utilisation non recommandée", + "游戏已存在,是否重复添加?": "Le jeu existe déjà, y a - t - il des ajouts répétés?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/it.json b/LunaTranslator/files/lang/it.json index f61f7859..22d00fed 100644 --- a/LunaTranslator/files/lang/it.json +++ b/LunaTranslator/files/lang/it.json @@ -852,5 +852,6 @@ "作用于翻译": "Applicato alla traduzione", "字符串替换": "Sostituzione stringa", "转义": "Scappare", - "不推荐使用": "Non raccomandato per l'uso" + "不推荐使用": "Non raccomandato per l'uso", + "游戏已存在,是否重复添加?": "Il gioco esiste già, vuoi aggiungerlo di nuovo?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ja.json b/LunaTranslator/files/lang/ja.json index bb5ebf41..c477ae9e 100644 --- a/LunaTranslator/files/lang/ja.json +++ b/LunaTranslator/files/lang/ja.json @@ -852,5 +852,6 @@ "作用于翻译": "翻訳に役立つ", "字符串替换": "文字列置換", "转义": "エスケープ", - "不推荐使用": "使用を推奨しない" + "不推荐使用": "使用を推奨しない", + "游戏已存在,是否重复添加?": "ゲームは既に存在します。追加を繰り返しますか?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ko.json b/LunaTranslator/files/lang/ko.json index c5eadb74..d40fd60c 100644 --- a/LunaTranslator/files/lang/ko.json +++ b/LunaTranslator/files/lang/ko.json @@ -852,5 +852,6 @@ "作用于翻译": "번역에 적용", "字符串替换": "문자열 대체", "转义": "전의", - "不推荐使用": "권장하지 않음" + "不推荐使用": "권장하지 않음", + "游戏已存在,是否重复添加?": "게임이 이미 존재합니다. 다시 추가하시겠습니까?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/nl.json b/LunaTranslator/files/lang/nl.json index 87cdbfc5..11269f65 100644 --- a/LunaTranslator/files/lang/nl.json +++ b/LunaTranslator/files/lang/nl.json @@ -852,5 +852,6 @@ "作用于翻译": "Toegepast op vertaling", "字符串替换": "Vervanging van tekenreeks", "转义": "Ontsnappen", - "不推荐使用": "Niet aanbevolen voor gebruik" + "不推荐使用": "Niet aanbevolen voor gebruik", + "游戏已存在,是否重复添加?": "Het spel bestaat al, wil je het opnieuw toevoegen?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pl.json b/LunaTranslator/files/lang/pl.json index 0c4fa601..5d1950f6 100644 --- a/LunaTranslator/files/lang/pl.json +++ b/LunaTranslator/files/lang/pl.json @@ -852,5 +852,6 @@ "作用于翻译": "Zastosowanie do tłumaczenia", "字符串替换": "Zastąpienie ciągu", "转义": "Ucieczka", - "不推荐使用": "Nie zaleca się stosowania" + "不推荐使用": "Nie zaleca się stosowania", + "游戏已存在,是否重复添加?": "Gra już istnieje, chcesz dodać ją ponownie?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/pt.json b/LunaTranslator/files/lang/pt.json index c2d6a495..feac10f3 100644 --- a/LunaTranslator/files/lang/pt.json +++ b/LunaTranslator/files/lang/pt.json @@ -852,5 +852,6 @@ "作用于翻译": "Aplicado à tradução", "字符串替换": "Substituição de strings", "转义": "Escapar", - "不推荐使用": "Não recomendado para utilização" + "不推荐使用": "Não recomendado para utilização", + "游戏已存在,是否重复添加?": "O jogo já existe, você gostaria de adicioná-lo novamente?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/ru.json b/LunaTranslator/files/lang/ru.json index 525d6553..e29272d3 100644 --- a/LunaTranslator/files/lang/ru.json +++ b/LunaTranslator/files/lang/ru.json @@ -852,5 +852,6 @@ "作用于翻译": "Роль перевода", "字符串替换": "Замена строки", "转义": "Транслитерация", - "不推荐使用": "Не рекомендуется использовать" + "不推荐使用": "Не рекомендуется использовать", + "游戏已存在,是否重复添加?": "Игра уже существует, добавляется ли повторно?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/sv.json b/LunaTranslator/files/lang/sv.json index 3accd328..17913d67 100644 --- a/LunaTranslator/files/lang/sv.json +++ b/LunaTranslator/files/lang/sv.json @@ -852,5 +852,6 @@ "作用于翻译": "Tillämpad på översättning", "字符串替换": "Strängersättning", "转义": "Flykt", - "不推荐使用": "Rekommenderas inte för användning" + "不推荐使用": "Rekommenderas inte för användning", + "游戏已存在,是否重复添加?": "Spelet finns redan, vill du lägga till det igen?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/th.json b/LunaTranslator/files/lang/th.json index c89b9ef9..4a857a27 100644 --- a/LunaTranslator/files/lang/th.json +++ b/LunaTranslator/files/lang/th.json @@ -852,5 +852,6 @@ "作用于翻译": "บทบาทในการแปล", "字符串替换": "การแทนที่สตริง", "转义": "แปลความหมาย", - "不推荐使用": "ไม่แนะนำให้ใช้" + "不推荐使用": "ไม่แนะนำให้ใช้", + "游戏已存在,是否重复添加?": "มีเกมอยู่แล้วคุณต้องการเพิ่มซ้ำหรือไม่?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/tr.json b/LunaTranslator/files/lang/tr.json index 8af08629..a9302cbe 100644 --- a/LunaTranslator/files/lang/tr.json +++ b/LunaTranslator/files/lang/tr.json @@ -852,5 +852,6 @@ "作用于翻译": "Çevirmeye uygulandı", "字符串替换": "String Replacement", "转义": "Kaçmak", - "不推荐使用": "Kullanmak için önerilmez" + "不推荐使用": "Kullanmak için önerilmez", + "游戏已存在,是否重复添加?": "Oyun zaten var, tekrar eklemek ister misiniz?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/uk.json b/LunaTranslator/files/lang/uk.json index bfb13109..90ea5a9b 100644 --- a/LunaTranslator/files/lang/uk.json +++ b/LunaTranslator/files/lang/uk.json @@ -852,5 +852,6 @@ "作用于翻译": "Застосовано до перекладу", "字符串替换": "Заміна рядків", "转义": "Бег", - "不推荐使用": "Не рекомендується використовувати" + "不推荐使用": "Не рекомендується використовувати", + "游戏已存在,是否重复添加?": "Гра вже існує, бажаєте додати її знову?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/vi.json b/LunaTranslator/files/lang/vi.json index bec41fa1..f275a1b6 100644 --- a/LunaTranslator/files/lang/vi.json +++ b/LunaTranslator/files/lang/vi.json @@ -852,5 +852,6 @@ "作用于翻译": "Hành động để dịch", "字符串替换": "Thay thế chuỗi", "转义": "Thoát", - "不推荐使用": "Không khuyến khích sử dụng" + "不推荐使用": "Không khuyến khích sử dụng", + "游戏已存在,是否重复添加?": "Trò chơi đã tồn tại, có được thêm nhiều lần không?" } \ No newline at end of file diff --git a/LunaTranslator/files/lang/zh.json b/LunaTranslator/files/lang/zh.json index 854d992c..44b2e824 100644 --- a/LunaTranslator/files/lang/zh.json +++ b/LunaTranslator/files/lang/zh.json @@ -852,5 +852,6 @@ "作用于翻译": "", "字符串替换": "", "转义": "", - "不推荐使用": "" + "不推荐使用": "", + "游戏已存在,是否重复添加?": "" } \ No newline at end of file