Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
  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())
Ejemplo n.º 3
0
  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)
Ejemplo n.º 4
0
  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())
Ejemplo n.º 5
0
  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())
Ejemplo n.º 6
0
 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')
Ejemplo n.º 7
0
    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'))
Ejemplo n.º 8
0
 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')
Ejemplo n.º 9
0
    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())
Ejemplo n.º 10
0
  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()
Ejemplo n.º 11
0
    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)
Ejemplo n.º 12
0
    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)
Ejemplo n.º 13
0
    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()
Ejemplo n.º 14
0
    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()
Ejemplo n.º 15
0
 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)
Ejemplo n.º 16
0
 def lang(self):
     """
 @return  user language in html format
 """
     import config, dataman
     lang = dataman.manager().user().language
     return config.language2htmllocale(lang) or 'ja'
Ejemplo n.º 17
0
 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)
Ejemplo n.º 18
0
 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)
Ejemplo n.º 19
0
def _defaultUpdateComment():  # -> unicode
    ret = notr_("typo")
    import dataman
    user = dataman.manager().user()
    if user.id:
        ret = "@%s: %s" % (user.name, ret)
    return ret
Ejemplo n.º 20
0
    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
Ejemplo n.º 21
0
 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)
Ejemplo n.º 22
0
    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
Ejemplo n.º 23
0
    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
Ejemplo n.º 24
0
 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
Ejemplo n.º 25
0
 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()
Ejemplo n.º 26
0
    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()
Ejemplo n.º 27
0
    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
Ejemplo n.º 28
0
 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_()
Ejemplo n.º 29
0
  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)
Ejemplo n.º 30
0
 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_,
   }))