def _saveName(self): name = self.nameEdit.text().strip() dataman.manager().setGameName(name, md5=self.game.md5) if name: title = "%s - %s" % (name, mytr_("Game Properties")) self.q.setWindowTitle(title) else: self._loadName()
def __init__(self): self.__d = _SubtitleEditorManager() from PySide.QtCore import QCoreApplication qApp = QCoreApplication.instance() qApp.aboutToQuit.connect(self.hide) import dataman dataman.manager().loginChanged.connect(lambda name: name or self.hide())
def __init__(self, parent=None): super(SystemStatus, self).__init__(parent) d = self.__d = _SystemStatus(self) netman.manager().onlineChanged.connect(self.onlineChanged) gameman.manager().processChanged.connect(d.onProcessChanged) dataman.manager().loginChanged.connect(d.onLoginChanged) settings.global_().userLanguageChanged.connect(self.userLanguageChanged) settings.global_().userIdChanged.connect(self.userIdChanged)
def __init__(self, parent=None): self.__d = _NameInputManager() from PySide.QtCore import QCoreApplication qApp = QCoreApplication.instance() qApp.aboutToQuit.connect(self.hide) import dataman dataman.manager().loginChanged.connect(lambda name: name or self.hide())
def __init__(self, parent=None): super(TopicEditorManager, self).__init__(parent) self.__d = _TopicEditorManager() from PySide.QtCore import QCoreApplication qApp = QCoreApplication.instance() qApp.aboutToQuit.connect(self.hide) import dataman dataman.manager().loginChanged.connect(lambda name: name or name == 'guest' or self.hide())
def _saveLanguage(self): w = self.languageEdit index = w.currentIndex() lang = config.LANGUAGES[index] if lang != self.game.language: dataman.manager().setGameLanguage(lang, md5=self.game.md5) if lang == 'ja': skqss.removeclass(w, 'warning') else: skqss.addclass(w, 'warning')
def _saveLoader(self): loader = ('none' if self.disableLoaderButton.isChecked() else 'apploc' if self.applocButton.isChecked() else 'ntlea' if self. ntleaButton.isChecked() else 'ntleas' if self.ntleasButton. isChecked() else 'lsc' if self.localeSwitchButton.isChecked( ) else 'le' if self.localeEmulatorButton.isChecked() else '') #if loader != self.game.loader: # Not needed since they are connected with toggled signal dataman.manager().setGameLoader(loader, md5=self.game.md5) self.launchLanguageEdit.setEnabled(loader not in ('none', 'le'))
def _saveLaunchLanguage(self): w = self.launchLanguageEdit index = w.currentIndex() if not index: lang = '' else: lang = config.LANGUAGES[index - 1] if lang != self.game.launchLanguage: dataman.manager().setGameLaunchLanguage(lang, md5=self.game.md5) if lang in ('', 'ja'): skqss.removeclass(w, 'warning') else: skqss.addclass(w, 'warning')
def __init__(self, parent=None): WINDOW_FLAGS = Qt.Dialog | Qt.WindowMinMaxButtonsHint super(TermInput, self).__init__(parent, WINDOW_FLAGS) skqss.class_(self, 'texture') self.setWindowTitle(my.tr("Create dictionary entry")) self.setWindowIcon(rc.icon('window-dict')) self.__d = _TermInput(self) #self.__d.autofill() #self.resize(300, 270) self.resize(280, 320) #self.statusBar() # show status bar import dataman dataman.manager().loginChanged.connect( lambda name: name or self.hide())
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 updateTopic(self, topicData, imageData, ticketData): """ @param topicData unicode json @param imageData unicode json @param ticketData unicode json """ user = dataman.manager().user() if user.name and user.password: topic = json.loads(topicData) #topic['subjectId'] = self.gameId topic['login'] = user.name topic['password'] = user.password if imageData: image = json.loads(imageData) image['login'] = user.name image['password'] = user.password else: image = None subjectId = topic.get('subjectId') subjectType = topic.get('subjectType') tickets = None if ticketData and subjectId and subjectType == 'game': tickets = self._parseGameTicketData(ticketData, subjectId) if subjectId: del topic['subjectId'] if subjectType: del topic['subjectType'] self._updateTopic(topic, image, tickets)
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 updateAndRefresh(self): if self._locked: dwarn("locked") return gameId = self.gameId if not gameId: #growl.notify(my.tr("Unknown game. Please try updating the database.")) return if netman.manager().isOnline(): if self.itemId and self.itemId < defs.MIN_NORMAL_GAME_ITEM_ID: dprint("found non-normal game, ignore refs") else: self._locked = True # lock before online access #growl.msg(my.tr("Updating game information")) ok = dataman.manager().updateReferences(gameId) #dm.touchGames() if not ok: growl.notify( my. tr("The game title it not specified. You can click the Edit button to add one." )) #else: #growl.msg(my.tr("Found game information")) self._locked = False # always unlock no matter what happened self.refresh()
def refresh(self): """@reimp""" self.newPostButton.setVisible(bool(self.topicId)) #self.gameButton.setVisible(bool(self.subjectId)) host = config.API_HOST # must be the same as rest.coffee for the same origin policy user = dataman.manager().user() w = self.webView w.setHtml( rc.haml_template('haml/reader/topicview').render({ 'host': host, 'locale': config.language2htmllocale(user.language), 'title': tr_("Topic"), 'topicId': self.topicId, 'userName': user.name if not user.isGuest() else '', 'userPassword': user.password, 'rc': rc, 'tr': tr_, }), host) self._injectBeans()
def _saveLaunchPath(self): g = self.game path = self.launchEdit.text().strip() if not path or not os.path.exists(path): self.showWarning(my.tr("Game launch file does not exist")) return if osutil.normalize_path(path) == osutil.normalize_path(g.launchPath): return if osutil.normalize_path(path) == osutil.normalize_path(g.path): path = "" else: path = QtCore.QDir.toNativeSeparators(path) if path != g.launchPath: dprint("game launch path changed") self.showMessage(my.tr("Game launch path saved")) dataman.manager().setGameLaunchPath(path, g.md5)
def lang(self): """ @return user language in html format """ import config, dataman lang = dataman.manager().user().language return config.language2htmllocale(lang) or 'ja'
def submitTopic(self, topicData, imageData, ticketData): """ @param topicData unicode json @param imageData unicode json @param ticketData unicode json """ user = dataman.manager().user() if user.name and user.password: topic = json.loads(topicData) subjectId = topic.get('subjectId') subjectType = topic.get('subjectType') if not subjectId or not subjectType: return topic['login'] = user.name topic['password'] = user.password if imageData: image = json.loads(imageData) image['login'] = user.name image['password'] = user.password else: image = None tickets = None if ticketData and subjectType == 'game': tickets = self._parseGameTicketData(ticketData, subjectId) self._submitTopic(topic, image, tickets)
def _getGameName(gameId): import dataman dm = dataman.manager() for it in dm.queryReferenceData(gameId=gameId, online=False): if it.title: return it.title return dm.queryGameName(id=gameId)
def _defaultUpdateComment(): # -> unicode ret = notr_("typo") import dataman user = dataman.manager().user() if user.id: ret = "@%s: %s" % (user.name, ret) return ret
def clear(self): self.subjectId = 0 self.subjectType = 'subject' self.topicType = 'review' # str self.topicContent = '' # str self.imagePath = '' # unicode import dataman self.topicLanguage = dataman.manager().user().language
def setGameId(self, gameId): """ @param game dataman.GameObject """ import dataman icon = dataman.manager().queryGameIcon(id=gameId) self.setWindowIcon(icon or rc.icon('window-refview')) root = self.rootObject() root.setProperty('gameId', gameId)
def clear(self): self.topicId = 0 # long self.replyId = 0 # long self.postContent = '' # str self.postType = 'post' # str self.imagePath = '' # unicode import dataman self.postLanguage = dataman.manager().user().language
def _canEdit(self): userAccess = [] user = dataman.manager().user() if user.access: #Сделал тут такую хуйню, потому что не знаю можно ли делать нормально(лол) userAccessMass = user.access.split(',') for a in userAccessMass: userAccess.append(a) # Пришлось вырезать дополнительную проверку, ибо хз как обратиться к dataman за itemId # and (self.comment.userId == user.id or (str(self.comment.userId) + ":" + str(self.comment.itemId)) in userAccess) return netman.manager().isOnline() and bool( self.comment) and not self.comment.d.protected
def _parseGameTicketData(self, data, gameId): # string -> [{kw}] ret = [] user = dataman.manager().user() a = json.loads(data) for k, v in a.iteritems(): ret.append({ 'type': k, 'value': v, 'targetId': gameId, 'targetType': 'game', 'login': user.name, 'password': user.password, }) return ret
def showUser(self, id=0, hash=0, name=''): """ @param* id long user id @param* hash long ip hash @param* name unicode name str """ if not dataman.manager().queryUser(id=id, name=name): growl.notify(my.tr("Unknown user. Please try updating the database.")) else: w = self.__d.getDialog() w.setUserId(id) w.setUserName(name) w.setUserHash(hash) w.show()
def refresh(self): user = dataman.manager().user() self.privateButton.setEnabled(not user.isGuest()) self.saveButton.setEnabled(self._canSave()) type = self._getType() self.hostEdit.setEnabled(type in dataman.Term.HOST_TYPES) self.roleEdit.setEnabled(type in dataman.Term.ROLE_TYPES) self.rubyEdit.setEnabled(type in dataman.Term.RUBY_TYPES) self.contextEdit.setEnabled(type in dataman.Term.CONTEXT_TYPES) self._refreshTypeLabel() self._refreshPriority() self._refreshKanji() self._refreshYomi() self._refreshStatus()
def gameLabel(self): import dataman dm = dataman.manager() ret = QtWidgets.QLabel() ret.setToolTip( my. tr("Current game for game-specific definitions in the Shared Dictionary" )) def _refresh(): ret.setText('#' + (dm.currentGameName() or my.tr("Unknown game"))) skqss.class_(ret, 'text-error' if dm.currentGame() else 'text-info') _refresh() dm.currentGameChanged.connect(_refresh) return ret
def showGame(self, game=None, id=None, md5=None): """ @param game dataman.Game @param id long @param md5 unicode """ if not game and (md5 or id): game = dataman.manager().queryGame(id=id, md5=md5) if not game: growl.warn(my.tr("Game is not found. Did you delete it?") ) # This should seldom happen else: w = self.__d.findDialog(id=id, md5=md5) if not w: w = self.__d.getDialog() w.setGame(game) w.show() w.raise_()
def _newName(self, index): import dataman, main row = self.rows[index] name = row['name'] #yomi = row['yomi'] yomi = name info = row['info'] lang = dataman.manager().user().language if lang == 'zhs': yomi = opencc.ja2zhs(yomi) else: lang = 'zht' yomi = opencc.ja2zht(yomi) main.manager().showTermInput(pattern=name, text=yomi, comment=info, type='name', language=lang, tokenId=self.tokenId)
def onReload(self): """@reimp""" dm = dataman.manager() user = dm.queryUser(id=self.userId, name=self.userName) if not user: growl.notify(my.tr("Unknown user. Please try updating the database.")) return self.userId = user.id self.userName = user.name av = dm.queryUserAvatarUrl(self.userId, hash=self.userHash, cache=True) self.setHtml(rc.haml_template('haml/reader/userview').render({ 'user': user, 'avatar': av, 'i18n': i18n, 'rc': rc, 'tr': tr_, 'mytr': mytr_, }))