示例#1
0
 def __init__(self, mid, order, mjson, metadata, parent=None):
     QObject.__init__(self, parent)
     self.setObjectName(str(mid))
     self.m_id = mid
     self.m_order = order
     self.m_json = QJsonValue(mjson)  # or  self.m_json = mjson #
     self.m_metadata = metadata
示例#2
0
文件: api.py 项目: schoentoon/runekit
    def setTaskbarProgress(self, type_: QJsonValue, progress: QJsonValue):
        if not self.app.has_permission("overlay"):
            raise ApiPermissionDeniedException("overlay")

        type_map = {
            0: "RESET",
            1: "IN_PROGRESS",
            2: "ERROR",
            3: "LOADING",
            4: "PAUSED",
        }
        # This can be called with null, but since the default value is 0 we call RESET anyway
        self.app.game_instance.set_taskbar_progress(
            type_map[type_.toDouble(0)], progress.toDouble(0))
示例#3
0
 def appendAttribute(self, attribute, value=QJsonValue()):
     if isinstance(value, QJsonValue):
         if value.isArray():
             pyValue = value.toArray().toVariantList()
         else:
             pyValue = None if value.isNull() else value.toObject()
     else:
         pyValue = value
     self.push(commands.ListAttributeAppendCommand(self._graph, attribute, pyValue))
示例#4
0
        def cb(res: ChallengeRsp):
            if res.qtype == 'roundSummary':
                prg_data = [{
                    'wrd': asdict(i)['prg'][0]['wrd'],
                    'prg': asdict(i)['prg'][0]["prg"],
                    'def_': asdict(i)['prg'][0]['def_']
                } for i in res.pdata.round]

                self.roundSummary.emit(QJsonArray.fromVariantList(prg_data))
            else:
                self.newCard.emit(QJsonValue(asdict(res)))
示例#5
0
 def setJson(self, mjson):
     if mjson.toObject() != self.m_json.toObject():
         self.m_json = QJsonValue(mjson)
         self.jsonChanged.emit()
示例#6
0
class DataJson(QObject):
    def __init__(self, mid, order, mjson, metadata, parent=None):
        QObject.__init__(self, parent)
        self.setObjectName(str(mid))
        self.m_id = mid
        self.m_order = order
        self.m_json = QJsonValue(mjson)  # or  self.m_json = mjson #
        self.m_metadata = metadata

    @Signal
    def idChanged(self):
        pass

    @Signal
    def orderChanged(self):
        pass

    @Signal
    def jsonChanged(self):
        pass

    @Signal
    def metadataChanged(self):
        pass

    def _id(self):
        return self.m_id

    def _order(self):
        return self.m_order

    def _json(self):
        return self.m_json.toObject(
        )  #warning only with self.m_json is QJsonValue()

    def _metadata(self):
        return self.m_metadata


#    def setId(self, mid):
#        if mid!= self.m_id:
#            self.m_id=mid
#            self.idChanged.emit()

    def setOrder(self, order):
        if order != self.m_order:
            self.m_order = order
            self.orderChanged.emit()

    def setJson(self, mjson):
        if mjson.toObject() != self.m_json.toObject():
            self.m_json = QJsonValue(mjson)
            self.jsonChanged.emit()

    def setMetadata(self, metadata):
        if metadata != self.m_metadata:
            self.metadata = metadata
            self.metadataChanged.emit()

    id = Property(int, _id, notify=idChanged)
    order = Property(
        str, _order, setOrder,
        notify=orderChanged)  #only order internal for proxy, default false
    json = Property(QJsonValue, _json, setJson, notify=jsonChanged)
    metadata = Property(
        str, _metadata, setMetadata,
        notify=metadataChanged)  # search proxy memory, defaul false
示例#7
0
 def meInfo(self):
     return QJsonValue.fromVariant(asdict(self.p.meInfo))
示例#8
0
 def start(self):
     self.loading.emit(True)
     self.ac(
         self.p.start,
         lambda rsp: self.started.emit(QJsonValue(asdict(rsp))),
     )
示例#9
0
 def verify_answer(self, idx, nonce):
     logging.info(f'Getting answer for option {idx}, {nonce}')
     self.ac(
         self.p.verify_answer, lambda answer: self.answerBingo.emit(
             idx, QJsonValue(asdict(answer))), nonce,
         self.p.cur_question.secret)