def confirmUpdateTerms(): """ @return {reset=bool} or None """ if not netman.manager().isOnline(): growl.warn(my.tr("Cannot perform update when offline")) return #_speak(u"今すぐ辞書を更新しますか?") t = settings.global_().termsTime() or config.VERSION_TIMESTAMP sel = QMessageBox.question( _parent(), my.tr("Update user-contributed dictionary"), "\n\n".join(( "\n". join((my.tr( "Dictionary terms for machine translation are updated on: {0}." ), my. tr("VNR will check for automatically updates. Do you want to update now?" ))), my.tr(""" VNR will do incremental update by default. But if you press Reset, VNR will redownload the entire data, which is slow.""" ), )).format(i18n.timestamp2datetime(t)), Yes | No | Reset, No) if sel == Yes: return {'reset': False} elif sel == Reset: return {'reset': True}
def _save(self): if self.isComplete(): hcode = self.currentHookCode() th = texthook.global_() old_hcode = th.currentHookCode() if hcode == old_hcode: growl.msg(my.tr("Hook code is not changed")) self._saveButton.setEnabled(False) skqss.class_(self._hookEdit, 'normal') else: self._addHookToHistory(hcode) if old_hcode: growl.notify(my.tr("Override previous hook code") + "<br/>" + old_hcode) if th.setHookCode(hcode): #self.q.hide() growl.msg(my.tr("Hook code saved")) self._saveButton.setEnabled(False) skqss.class_(self._hookEdit, 'normal') self.q.hookCodeEntered.emit(hcode) else: growl.error(my.tr("Hook code does not work with the current game")) self._saveButton.setEnabled(False) skqss.class_(self._hookEdit, 'error') hooked = bool(texthook.global_().currentHookCode()) self._deleteButton.setEnabled(hooked) dprint("pass")
def confirmUpdateRefs(game=None): """ @param game dataman.Game or None @return bool """ #if not game: # growl.notify(my.tr("Unknown game. Please try updating the database.")) # return if not netman.manager().isOnline(): growl.warn(my.tr("Cannot perform update when offline")) return #_speak(u"今すぐゲーム情報を更新しますか?") msg = "" if game: t = game.refsUpdateTime or game.visitTime or config.VERSION_TIMESTAMP msg += my.tr("Game references are updated on: {0}.").format( i18n.timestamp2datetime(t)) + "\n" msg += "\n\n".join(( my.tr("VNR will automatically check for updates."), my.tr("""Do you want to update now? It might take a couple of seconds to complete."""), )) return Yes == QMessageBox.question(_parent(), my.tr("Update game references"), msg, Yes | No, No)
def confirmUpdateComments(game=None): """ @param game dataman.Game or None @return bool """ #if not game: # growl.notify(my.tr("Unknown game. Please try updating the database.")) # return if not netman.manager().isOnline(): growl.warn(my.tr("Cannot perform update when offline")) return _speak(u"今すぐ字幕を更新しますか?") msg = "\n\n".join(( my.tr("VNR will automatically check for updates."), my.tr("""Do you want to update now? It might take a couple of seconds to complete."""), )) t = game.commentsUpdateTime or game.visitTime if game else 0 if t > 0: msg = "\n".join((my.tr("Comments are updated on: {0}.").format( i18n.timestamp2datetime(t)), msg)) return Yes == QMessageBox.question( _parent(), my.tr("Update user-contributed comments"), msg, Yes | No, No)
def _submitTopic(self, topic, image, tickets): """ @param topic kw @param image kw or None @param tickets [kw] """ dprint("enter") nm = netman.manager() if tickets: self._submitTickets(tickets) if image: data = skfileio.readdata(image['filename']) if data: topic['image'] = nm.submitImage(data, image) if image and not topic.get('image'): growl.warn("<br/>".join(( my.tr("Failed to submit topic"), my.tr("Please try again"), ))) return if nm.submitTopic(topic): self._onTopicSubmitted(topic, tickets) else: growl.warn("<br/>".join(( my.tr("Failed to submit topic"), my.tr("Please try again"), ))) dprint("leave")
def confirmClearEntries(): """ @return bool """ return Yes == QMessageBox.question( _parent(), my.tr("Confirm deletion"), my.tr("Do you want to permanently delete all entries?"), Yes | No, No)
def showGame(self, gameId): if not gameId: growl.notify( my.tr("Unknown game. Please try updating the database.")) return d = self.__d d.gameId = gameId import dataman dm = dataman.manager() name = self._getGameName(gameId) title = my.tr("Please select the game title") if name: title += " - " + name w = d.dialog w.setWindowTitle(title) icon = self._getGameIcon(gameId) w.setWindowIcon(icon or rc.icon('window-refinput')) if name: w.setDefaultText(name) d.showWindow(w)
def _plot(self, data): """ @param data [dataman.Comment|dataman.Term] @param info DataInfo """ info = DataInfo(data) fig = self.figure #fig.clear() self._plotLanguageStackFigure( fig.add_subplot(221, title=my.tr("Timeline by {0}").format( tr_("language"))), info) self._plotLanguagePieFigure( fig.add_subplot(222, title=my.tr("Percentage by {0}").format( tr_("language"))), info) self._plotUserStackFigure( fig.add_subplot(223, title=my.tr("Timeline by {0}").format( tr_("user"))), info) self._plotUserPieFigure( fig.add_subplot(224, title=my.tr("Percentage by {0}").format( tr_("user"))), info) fig.autofmt_xdate() # rotate x axis
def showGame(self, tokenId=0, itemId=0, info=None): """ @param* tokenId long @param* itemId long @param* info GameInfo """ if not info: import dataman info = dataman.manager().queryGameInfo(itemId=itemId, id=tokenId, cache=True) if info and not tokenId: tokenId = info.gameId if not info or not tokenId: growl.notify(my.tr("Unknown game")) return if not info.hasNames(): growl.notify(my.tr("Game character names not found")) return w = self.__d.getDialog(tokenId) if w and w.isVisible() and w.tokenId() == tokenId: w.raise_() else: w.setGameName(info.title) w.setWindowIcon(info.icon or rc.icon('window-name')) w.setTokenId(tokenId) w.setNames(info.iterNameYomi()) w.show()
def confirmDownloadGameImages(): """ @return bool """ return Yes == QMessageBox.question( _parent(), my.tr("Save game images"), my.tr("Do you want to save all images to your Desktop?"), Yes | No, No)
def _save(self): if not self._canSave(): return q = self.q tm = textman.manager() agent = gameagent.global_() engine = agent.engine() engineName = defs.to_ith_engine_name(engine) scenesig = self._scenarioSignature() namesig = self._nameSignature() enc = self._encoding() lang = self._language() #threads = tm.threadsBySignature() changed = False if scenesig: if lang != tm.gameLanguage(): dprint("language changed") changed = True skevents.runlater(partial(q.languageChanged.emit, lang)) if scenesig != self._lastScenarioSignature or enc != self._lastEncoding: dprint("scenario thread changed") changed = True self._lastScenarioSignature = scenesig self._lastEncoding = enc agent.setEncoding(enc) agent.setScenarioSignature(scenesig) #name = threads[sig].name skevents.runlater( partial(q.scenarioThreadChanged.emit, scenesig, engineName, enc)) if namesig != self._lastNameSignature: dprint("name thread changed") changed = True self._lastNameSignature = namesig agent.setNameSignature(namesig) if not namesig: skevents.runlater(q.nameThreadDisabled.emit) else: #name = threads[namesig].name skevents.runlater( partial(q.nameThreadChanged.emit, namesig, engineName)) #sig_set = set(self._otherSignatures()) #if sig_set != tm.otherSignatures(): # dprint("other threads changed") # changed = True # skevents.runlater(partial( # q.otherThreadsChanged.emit, # {sig:threads[sig].name for sig in sig_set})) msg = (my.tr("Text settings are saved") if changed else my.tr("Text settings are not changed")) q.message.emit(msg) growl.msg(msg) dprint("pass")
def __init__(self, parent=None): super(SelectFilePage, self).__init__(parent) self.setTitle(my.tr("Select game executable")) introLabel = QtWidgets.QLabel(my.tr("Please select the game executable's location")) introLabel.setWordWrap(True) self._edit = QtWidgets.QLineEdit() self._edit.setPlaceholderText(tr_("Location")) self._edit.textChanged.connect(self._validateEdit) self._edit.textChanged.connect(self.completeChanged) self._browseButton = QtWidgets.QPushButton(tr_("Browse") + " ...") skqss.class_(self._browseButton, 'btn btn-info') self._browseButton.clicked.connect(self._browse) #self._applocButton = QtWidgets.QCheckBox(my.tr("Open in Japanese locale (0x0411) using AppLocale")) #self._applocButton.toggled.connect(settings.global_().setApplocEnabled) #self._tzButton = QtWidgets.QCheckBox(my.tr("Open in Japanese time zone (+9 Asia/Tokyo)")) #self._tzButton.toggled.connect(settings.global_().setTimeZoneEnabled) layout = QtWidgets.QVBoxLayout() layout.addWidget(introLabel) row = QtWidgets.QHBoxLayout() row.addWidget(self._edit) row.addWidget(self._browseButton) layout.addLayout(row) #layout.addWidget(self._applocButton) #layout.addWidget(self._tzButton) self.setLayout(layout)
def confirmUpdateSubs(timestamp=0): """ @param* timestamp long @return {reset=bool} or None """ if not netman.manager().isOnline(): growl.warn(my.tr("Cannot perform update when offline")) return ts = i18n.timestamp2datetime(timestamp) if timestamp else tr_('empty') sel = QMessageBox.question( _parent(), my.tr("Update user-contributed subtitles"), "\n\n".join(( "\n".join(( my.tr("Shared subtitles are updated on: {0}."), my. tr("VNR will check for automatically updates. Do you want to update now?" ))), my.tr(""" VNR will do incremental update by default. But if you press Reset, VNR will redownload the entire data, which is slow.""" ), )).format(ts), Yes | No | Reset, No) if sel == Yes: return {'reset': False} elif sel == Reset: return {'reset': True}
def applyTerms(self, text, type, to, fr, context='', host='', mark=False, ignoreIfNotReady=False): """ @param text unicode @param type str @param to str language @param* fr str language @param* context str @param* host str @param* mark bool or None @param* ignoreIfNotReady bool """ if mark is None: mark = self.marked if type in ('encode', 'decode'): key = 'trans', to, fr # share the same manager else: key = type, to, fr man = self.scripts.get(key) if man is None: self.scriptTimes[key] = 0 self.rebuildCacheLater() if ignoreIfNotReady: dwarn("ignore text while processing shared dictionary") growl.notify(my.tr("Processing Shared Dictionary") + "...") return '' if self.scriptLocks.get(key): dwarn("skip applying locked script") if ignoreIfNotReady: dwarn("ignore text while processing shared dictionary") growl.notify(my.tr("Processing Shared Dictionary") + "...") return '' return text if not man: #or man.isEmpty(): return text #if not man.mutex.tryLock(TERM_TRYLOCK_INTERVAL): # dwarn("try lock timeout") # return text ret = text if not man.isEmpty(): category = _termman.make_category(context=context, host=host) if type == 'encode': ret = man.encode(text, category) elif type == 'decode': ret = man.decode(text, category, mark) else: ret = man.transform(text, category, mark) #man.mutex.unlock() return ret
def priorityEdit(self): ret = QtWidgets.QLineEdit() ret.setPlaceholderText(my.tr("Estimated pattern size")) ret.setToolTip(my.tr("Estimated number of characters in pattern")) #ret.textChanged.connect(self._refreshPriority) #ret.textChanged.connect(self._refreshStatus) ret.textChanged.connect(self.refresh) return ret
def localeSwitchButton(self): ret = QtWidgets.QRadioButton( "%s (%s)" % (my.tr("Use {0} to change game locale").format( notr_("LocaleSwitch")), my.tr("need admin priv"))) if features.ADMIN == False: skqss.class_(ret, 'warning') ret.toggled.connect(self._saveLoader) return ret
def confirmExportCsv(): """ @return bool """ return Yes == QMessageBox.question( _parent(), my.tr("Export Excel CSV"), my.tr("Do you want to export the data into an Excel CSV file?"), Yes | No, No)
def confirmRemoveDictionary(name): # unicode """ @return bool """ return Yes == QMessageBox.question( _parent(), my.tr("Remove dictionary"), my.tr("""Do you want to remove the {0} dictionary? You can reinstall it later if you want.""").format(name), Yes | No, No)
def confirmDownloadGameVideos(): """ @return bool """ return Yes == QMessageBox.question( _parent(), my.tr("Download YouTube videos"), my.tr("Do you want to download all YouTube videos to your Desktop?"), Yes | No, No)
def _verifyLaunchEdit(self): path = self.launchEdit.text() ok = bool(path) and os.path.exists(path) skqss.class_(self.launchEdit, 'normal' if ok else 'error') if ok: self.showMessage(my.tr("Find game launch file")) self._saveLaunchPath() else: self.showWarning(my.tr("Game launch file does not exist"))
def nameButton(self): ret = QtWidgets.QPushButton(my.tr("Import Name")) #skqss.class_(ret, 'btn btn-inverse') skqss.class_(ret, 'btn btn-warning') ret.setToolTip(my.tr("Import Japanese names to Shared Dictionary")) ret.setEnabled(False) #ret.setStatusTip(ret.toolTip()) ret.clicked.connect(self._importName) return ret
def confirmRemoveApploc(): """ @return bool """ return Yes == QMessageBox.question( _parent(), my.tr("Remove AppLocale"), my.tr("""Do you want to remove AppLocale? It requires Internet access and might take a couple of minutes. You can reinstall it later if you have Internet access."""), Yes | No, No)
def _refresh(self): ok = self.isCommitPage() skqss.class_(self._edit, 'normal' if ok else 'error') name = self.wizard().profile().threadName if ok: t = my.tr("Successfully synchronized with text thread") + " => " + name else: t = my.tr("Does not find this game from the online database") self._edit.setText(t)
def confirmDownloadFont(name): # unicode """ @return bool """ location = "Caches/Fonts" return Yes == QMessageBox.question( _parent(), my.tr("Download font"), my.tr("""Do you want to download the {0}? It requires Internet access and might take a couple of minutes. The font will be installed to {1}.""").format(name, location), Yes | No, No)
def _onEngineReceived(self, name): # str self.engineName = name self.q.engineChanged.emit(name) if name and self.connectedPid: self.mem.attachProcess(self.connectedPid) growl.notify("%s: %s" % (my.tr("Detect game engine"), name)) else: growl.notify(my.tr("Unrecognized game engine. Fallback to ITH."))
def confirmStretchGameWindow(): """ @return bool """ return Yes == QMessageBox.question( _parent(), my.tr("Switch to full screen"), my.tr("""Do you want to stretch the game window to full screen? You can click the same button again to switch back. Note: This function does not work well for all games ><"""), Yes | No, No)
def confirmDuplicateEntry(): """ @return bool """ return Yes == QMessageBox.question( _parent(), my.tr("Clone entry"), my.tr("""Do you want to clone other people's entry? The entry has already been enabled even without you cloning it. Instead, cloning will result in duplicate entries that makes it more difficult to manage.""" ), Yes | No, No)
def launchEdit(self): ret = QtWidgets.QLineEdit() ret.setReadOnly(True) ret.setPlaceholderText(my.tr("No game path")) ret.setToolTip(my.tr("Game launcher location")) ret.setStatusTip(ret.toolTip()) ret.textChanged.connect(self._verifyLaunchEdit) ret.textChanged.connect(lambda text: self.resetLaunchButton.setEnabled( osutil.normalize_path(text) != osutil.normalize_path(self.game.path ))) return ret
def confirmCompileDictionary(name): # unicode """ @return bool """ location = "Caches/Dictionaries" return Yes == QMessageBox.question( _parent(), my.tr("Compile dictionary"), my.tr("""Do you want to compile the {0} dictionary? It does not require Internet access and might take a couple of seconds. The dictionary will be installed to {1}.""").format(name, location), Yes | No, No)
def confirmKeepSpace(): """ @return bool """ return Yes == QMessageBox.question( _parent(), "%s: %s" % (tr_("Warning"), my.tr("Insert spaces")), my.tr("""Are you sure to preserve spaces in the game text? This might be useful for English games. WARNING: This might result in redundant spaces for Japanese games."""), Yes | No, No)