コード例 #1
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()
コード例 #2
0
ファイル: gameview.py プロジェクト: blackknifes/VNR-Core
    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()
コード例 #3
0
ファイル: dl.py プロジェクト: blackknifes/VNR-Core
 def finish(self):
     dprint('enter')
     self.writeFile()  # write for the last chunk
     self.stop()
     growl.notify("[download] %s" % my.tr("clean up"))
     self.q.finished.emit()
     dprint('leave')
コード例 #4
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)
コード例 #5
0
  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")
コード例 #6
0
    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
コード例 #7
0
ファイル: gameagent.py プロジェクト: blackknifes/VNR-Core
    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."))
コード例 #8
0
ファイル: dl.py プロジェクト: blackknifes/VNR-Core
 def start(self):
     self.reply = self.nam.get(self.request)
     self.reply.error.connect(self.abort)
     self.reply.readyRead.connect(self.writeFile)
     self.reply.finished.connect(self.finish)
     self.reply.downloadProgress.connect(
         self._progress)  # FIXME: cannot directly connect to q
     growl.notify("[download] %s" % my.tr("start"))
     self.q.started.emit()
     dprint('pass')
     return True
コード例 #9
0
ファイル: main.py プロジェクト: blackknifes/VNR-Core
 def _next(self):
   """Download first vids"""
   dprint("enter: vids count = %i" % len(self.vids))
   if self.vids:
     growl.pageBreak()
     self._cvid = self.vids.pop(0)
     index = self._vidCount - len(self.vids)
     growl.notify("[main] %s (%i/%i): %s" %
         (my.tr("processing"), index, self._vidCount, self._cvid))
     self.solver.solve(self._cvid)
   else:
     self._finish()
   dprint("leave")
コード例 #10
0
ファイル: main.py プロジェクト: blackknifes/VNR-Core
 def _save(self, url, name):
   """
   @param  url  QString
   @param  name  QString
   """
   if url in self._visitedUrls:
     growl.warn(("[main] %s: %s" % (my.tr("pass"), url)))
   else:
     self._visitedUrls.add(url)
     growl.notify("[main] %s: %s" % (my.tr("download"), name))
     growl.notify("[main] %s: %s" % (my.tr("url"), url))
     self._cpath = os.path.join(self.location, name)
     self.downloader.get(url, self._cpath)
コード例 #11
0
ファイル: userview.py プロジェクト: blackknifes/VNR-Core
 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()
コード例 #12
0
ファイル: gameview.py プロジェクト: blackknifes/VNR-Core
 def showItem(self, itemId):
     """
 @param  itemId  long
 """
     if not itemId:
         growl.notify(
             my.tr("Unknown game. Please try updating the database."))
     else:
         w = self.__d.getDialog(itemId=itemId)
         if w.itemId() == itemId:
             w.refresh()
         else:
             w.clear()
             w.setItemId(itemId)
         w.show()
         w.raise_()
コード例 #13
0
ファイル: gameview.py プロジェクト: blackknifes/VNR-Core
 def showGame(self, gameId):
     """
 @param  gameId  long
 """
     if not gameId:
         growl.notify(
             my.tr("Unknown game. Please try updating the database."))
     else:
         w = self.__d.getDialog(gameId=gameId)
         if w.gameId() == gameId:
             w.refresh()
         else:
             w.clear()
             w.setGameId(gameId)
         w.show()
         w.raise_()
コード例 #14
0
ファイル: userview.py プロジェクト: blackknifes/VNR-Core
 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_,
   }))
コード例 #15
0
ファイル: rpcman.py プロジェクト: blackknifes/VNR-Core
    def _onCall(self, socket, cmd, *params):  # on serverMessageReceived
        """
    @param  socket  QTcpSocket
    @param  cmd  str
    @param  params  [unicode]
    """
        dprint(cmd)
        if cmd == 'app.activate':
            self.q.activated.emit()

        elif cmd == 'growl.msg':
            if params:
                growl.msg(params[0])
        elif cmd == 'growl.warn':
            if params:
                growl.warn(params[0])
        elif cmd == 'growl.error':
            if params:
                growl.error(params[0])
        elif cmd == 'growl.notify':
            if params:
                growl.notify(params[0])

        elif cmd == 'agent.ping':
            if params:
                pid = _unmarshalInteger(params[0])
                if pid:
                    self._onAgentPing(socket, pid)
        elif cmd == 'agent.window.text':
            if params:
                self._onWindowTexts(params[0])
        elif cmd == 'agent.engine.name':
            if params:
                self.q.engineReceived.emit(params[0])
        elif cmd == 'agent.engine.text':
            if len(params) == 5:
                self._onEngineText(*params)
            else:
                dwarn("invalid parameter count:", params)

        else:
            dwarn("unknown command: %s" % cmd)
コード例 #16
0
ファイル: dl.py プロジェクト: blackknifes/VNR-Core
 def closeFile(self):
     """
 @return  bool
 """
     dprint('enter')
     ok = False
     if self.file:
         growl.msg("[download] %s" % my.tr("closing file"))
         try:
             self.file.close()
             if self.path and os.path.exists(self.path):
                 growl.notify("[download] %s: %s" %
                              (my.tr("remove existing file"), self.path))
                 dprint("remove existing file:", self.path)
                 skfileio.trashfile(self.path)
             ok = skfileio.rename(self.tmpPath, self.path)
         except IOError, e:
             dwarn(e)
         self.file = None
         if not ok:
             growl.msg("[download] %s: %s" %
                       (my.tr("failed to close file"), self.path))
コード例 #17
0
ファイル: icstalker.py プロジェクト: legoktm/legoktm
	def _growl(self, message):
		growl.notify(message, 'IC Stalker')
コード例 #18
0
 def _growl(self, message):
     growl.notify(message, 'IC Stalker')