def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_fgoMainWindow() self.ui.setupUi(self) self.ui.CBX_PARTY.clear() self.ui.CBX_PARTY.addItems(config.sections()) self.ui.CBX_PARTY.setCurrentIndex(-1) self.loadParty('DEFAULT') self.serialno = fgoFunc.base.serialno self.IMG_FRIEND = fgoFunc.IMG_FRIEND
def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_fgoMainWindow() self.ui.setupUi(self) self.ui.CBX_PARTY.addItems(config.sections()) self.ui.CBX_PARTY.setCurrentIndex(-1) self.loadParty('DEFAULT') self.serial = fgoFunc.base.serial self.IMG_FRIEND = fgoFunc.IMG_FRIEND self.signalFuncBegin.connect(self.funcBegin) self.signalFuncEnd.connect(self.funcEnd)
def __init__(self,parent=None): super().__init__(parent) self.ui=Ui_fgoMainWindow() self.ui.setupUi(self) self.ui.CBX_PARTY.addItems(config.sections()) self.ui.CBX_PARTY.setCurrentIndex(-1) self.ui.TXT_PARTY.setValidator(QRegExpValidator(QRegExp('10|[0-9]'),self)) self.loadParty('DEFAULT') self.serialno=fgoFunc.base.serialno self.getDevice() self.IMG_FRIEND=fgoFunc.IMG_FRIEND self.signalFuncBegin.connect(self.funcBegin)#,Qt.BlockingQueuedConnection) self.signalFuncEnd.connect(self.funcEnd)
class MyMainWindow(QMainWindow): signalFuncBegin = pyqtSignal() signalFuncEnd = pyqtSignal() def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_fgoMainWindow() self.ui.setupUi(self) self.ui.CBX_PARTY.addItems(config.sections()) self.ui.CBX_PARTY.setCurrentIndex(-1) self.ui.TXT_PARTY.setValidator( QRegExpValidator(QRegExp('10|[0-9]'), self)) self.loadParty('DEFAULT') self.serialno = fgoFunc.base.serialno self.getDevice() self.thread = threading.Thread() self.signalFuncBegin.connect(self.funcBegin) self.signalFuncEnd.connect(self.funcEnd) def keyPressEvent(self, key): if key.modifiers() == Qt.NoModifier: try: fgoFunc.base.press(QTK2VK[key.key()]) except: pass def closeEvent(self, event): if self.thread.is_alive() and QMessageBox.warning( self, '关闭', '战斗正在进行,确认关闭?', QMessageBox.Yes | QMessageBox.No, QMessageBox.No) != QMessageBox.Yes: event.ignore() return fgoFunc.terminateFlag = True if not self.thread._started: self.thread.join() event.accept() def runFunc(self, func, *args, **kwargs): if not self.serialno: return QMessageBox.critical(self, '错误', '无设备连接', QMessageBox.Ok) def f(): try: fgoFunc.suspendFlag = False fgoFunc.terminateFlag = False fgoFunc.tobeTerminatedFlag = False fgoFunc.fuse.reset() self.signalFuncBegin.emit() self.applyAll() func(*args, **kwargs) except Exception as e: logger.exception(e) finally: self.signalFuncEnd.emit() QApplication.beep() self.thread = threading.Thread(target=f, name='BattleFunc') self.thread.start() def funcBegin(self): self.ui.BTN_ONEBATTLE.setEnabled(False) self.ui.BTN_MAIN.setEnabled(False) self.ui.BTN_USER.setEnabled(False) self.ui.BTN_PAUSE.setEnabled(True) self.ui.BTN_PAUSE.setChecked(False) self.ui.BTN_STOP.setEnabled(True) self.ui.MENU_SCRIPT.setEnabled(False) self.ui.MENU_CONTROL_STOPLATER.setEnabled(True) self.ui.MENU_CONTROL_STOPLATER.setChecked(False) def funcEnd(self): self.ui.BTN_ONEBATTLE.setEnabled(True) self.ui.BTN_MAIN.setEnabled(True) self.ui.BTN_USER.setEnabled(True) self.ui.BTN_PAUSE.setEnabled(False) self.ui.BTN_STOP.setEnabled(False) self.ui.MENU_SCRIPT.setEnabled(True) self.ui.MENU_CONTROL_STOPLATER.setChecked(False) self.ui.MENU_CONTROL_STOPLATER.setEnabled(False) def loadParty(self, x): self.ui.TXT_PARTY.setText(config[x]['partyIndex']) skillInfo = eval(config[x]['skillInfo']) for i, j, k in ((i, j, k) for i in range(6) for j in range(3) for k in range(3)): eval( f'self.ui.TXT_SKILL_{i}_{j}_{k}.setText("{skillInfo[i][j][k]}")' ) houguInfo = eval(config[x]['houguInfo']) for i, j in ((i, j) for i in range(6) for j in range(2)): eval(f'self.ui.TXT_HOUGU_{i}_{j}.setText("{houguInfo[i][j]}")') dangerPos = eval(config[x]['dangerPos']) for i in range(3): eval(f'self.ui.TXT_DANGER_{i}.setText("{dangerPos[i]}")') eval(f'self.ui.RBT_FRIEND_{config[x]["friendPos"]}.setChecked(True)') masterSkill = eval(config[x]['masterSkill']) for i, j in ((i, j) for i in range(3) for j in range(4 if i == 2 else 3)): eval(f'self.ui.TXT_MASTER_{i}_{j}.setText("{masterSkill[i][j]}")') def saveParty(self): if not self.ui.CBX_PARTY.currentText(): return config[self.ui.CBX_PARTY.currentText()] = { 'partyIndex': self.ui.TXT_PARTY.text(), 'skillInfo': str([[[ int((lambda self: eval(f'self.ui.TXT_SKILL_{i}_{j}_{k}.text()') )(self)) for k in range(3) ] for j in range(3)] for i in range(6)]).replace(' ', ''), 'houguInfo': str([[ int((lambda self: eval(f'self.ui.TXT_HOUGU_{i}_{j}.text()') )(self)) for j in range(2) ] for i in range(6)]).replace(' ', ''), 'dangerPos': str([ int(( lambda self: eval(f'self.ui.TXT_DANGER_{i}.text()'))(self)) for i in range(3) ]).replace(' ', ''), 'friendPos': self.ui.BTG_FRIEND.checkedButton().objectName()[-1], 'masterSkill': str([[ int((lambda self: eval(f'self.ui.TXT_MASTER_{i}_{j}.text()') )(self)) for j in range(4 if i == 2 else 3) ] for i in range(3)]).replace(' ', '') } with open('fgoConfig.ini', 'w') as f: config.write(f) def resetParty(self): self.loadParty('DEFAULT') def getDevice(self): text, ok = (lambda adbList: QInputDialog.getItem( self, '选取设备', '在下拉列表中选择一个设备', adbList, adbList.index(self.serialno) if self.serialno and self.serialno in adbList else 0, True, Qt.WindowStaysOnTopHint))( [i for i, j in ADB().devices() if j == 'device']) if ok: self.serialno = text def adbConnect(self): text, ok = QInputDialog.getText(self, '连接设备', '远程设备地址', text='localhost:5555') if ok and text: ADB(text) def refreshDevice(self): fgoFunc.base = fgoFunc.Base(fgoFunc.base.serialno) def checkCheck(self): QMessageBox.critical( self, '错误', '无设备连接', QMessageBox.Ok ) if fgoFunc.base.serialno is None else fgoFunc.Check(0).show().save() def getFriend(self): pass def applyAll(self): if self.serialno != fgoFunc.base.serialno: fgoFunc.base = fgoFunc.Base(self.serialno) self.serialno = fgoFunc.base.serialno fgoFunc.partyIndex = int(self.ui.TXT_PARTY.text()) fgoFunc.skillInfo = [[[ int((lambda self: eval(f'self.ui.TXT_SKILL_{i}_{j}_{k}.text()') )(self)) for k in range(3) ] for j in range(3)] for i in range(6)] fgoFunc.houguInfo = [[ int((lambda self: eval(f'self.ui.TXT_HOUGU_{i}_{j}.text()'))(self)) for j in range(2) ] for i in range(6)] fgoFunc.dangerPos = [ int((lambda self: eval(f'self.ui.TXT_DANGER_{i}.text()'))(self)) for i in range(3) ] fgoFunc.friendPos = int( self.ui.BTG_FRIEND.checkedButton().objectName()[-1]) fgoFunc.masterSkill = [[ int(( lambda self: eval(f'self.ui.TXT_MASTER_{i}_{j}.text()'))(self)) for j in range(4 if i == 2 else 3) ] for i in range(3)] def runOneBattle(self): self.runFunc(fgoFunc.battle) def runUser(self): self.runFunc(fgoFunc.userScript) def runGacha(self): self.runFunc(fgoFunc.gacha) def runJackpot(self): self.runFunc(fgoFunc.jackpot) def runMailFiltering(self): self.runFunc(fgoFunc.mailFiltering) def runMain(self): text, ok = QInputDialog.getItem(self, '肝哪个', '在下拉列表中选择战斗函数', ['battle', 'userScript']) if ok and text: self.runFunc(fgoFunc.main, self.ui.TXT_APPLE.value(), self.ui.CBX_APPLE.currentIndex(), eval('fgoFunc.' + text)) def pause(self): fgoFunc.suspendFlag = not fgoFunc.suspendFlag def stop(self): fgoFunc.terminateFlag = True def stopAfterBattle(self, x): fgoFunc.tobeTerminatedFlag = x def explorerHere(self): os.startfile('.') def psHere(self): os.system('start PowerShell -NoLogo') def stayOnTop(self): self.setWindowFlags(self.windowFlags() ^ Qt.WindowStaysOnTopHint) self.show() def mapKey(self, x): self.grabKeyboard() if x else self.releaseKeyboard() def about(self): QMessageBox.about( self, '关于', '作者:\thgjazhgj \n项目地址:https://github.com/hgjazhgj/FGO-py \n联系方式:[email protected]' )
class MyMainWindow(QMainWindow): def __init__(self, parent=None): super().__init__(parent) self.ui = Ui_fgoMainWindow() self.ui.setupUi(self) self.ui.CBX_PARTY.clear() self.ui.CBX_PARTY.addItems(config.sections()) self.ui.CBX_PARTY.setCurrentIndex(-1) self.loadParty('DEFAULT') self.serialno = fgoFunc.base.serialno self.IMG_FRIEND = fgoFunc.IMG_FRIEND def runFunc(self, func, *args, **kwargs): if self.serialno is None: QMessageBox.critical(self, 'Error', '无设备连接', QMessageBox.Ok) return self.ui.BTN_ONEBATTLE.setEnabled(False) self.ui.BTN_MAIN.setEnabled(False) self.ui.BTN_PAUSE.setEnabled(True) self.ui.BTN_STOP.setEnabled(True) self.applyAll() def f(): try: func(*args, **kwargs) except BaseException as e: if type(e) != SystemExit: traceback.print_exc() finally: self.ui.BTN_ONEBATTLE.setEnabled(True) self.ui.BTN_MAIN.setEnabled(True) self.ui.BTN_PAUSE.setEnabled(False) self.ui.BTN_STOP.setEnabled(False) fgoFunc.beep() threading.Thread(target=f).start() def loadParty(self, x): skillInfo = eval(config[x]['skillInfo']) houguInfo = eval(config[x]['houguInfo']) dangerPos = eval(config[x]['dangerPos']) for i, j, k in ((i, j, k) for i in range(6) for j in range(3) for k in range(3)): eval('self.ui.TXT_SKILL_' + str(i) + '_' + str(j) + '_' + str(k) + '.setText("' + str(skillInfo[i][j][k]) + '")') for i, j in ((i, j) for i in range(6) for j in range(2)): eval('self.ui.TXT_HOUGU_' + str(i) + '_' + str(j) + '.setText("' + str(houguInfo[i][j]) + '")') for i in range(3): eval('self.ui.TXT_DANGER_' + str(i) + '.setText("' + str(dangerPos[i]) + '")') eval('self.ui.RBT_FRIEND_' + config[x]['friendPos'] + '.setChecked(True)') masterSkill = eval(config[x]['masterSkill']) for i, j in ((i, j) for i in range(3) for j in range(3)): eval('self.ui.TXT_MASTER_' + str(i) + '_' + str(j) + '.setText("' + str(masterSkill[i][j]) + '")') def saveParty(self): config[self.ui.CBX_PARTY.currentText()] = { 'skillInfo': str([[[ int((lambda self: eval('self.ui.TXT_SKILL_' + str( i) + '_' + str(j) + '_' + str(k) + '.text()'))(self)) for k in range(3) ] for j in range(3)] for i in range(6)]).replace(' ', ''), 'houguInfo': str([[ int((lambda self: eval('self.ui.TXT_HOUGU_' + str( i) + '_' + str(j) + '.text()'))(self)) for j in range(2) ] for i in range(6)]).replace(' ', ''), 'dangerPos': str([ int((lambda self: eval('self.ui.TXT_DANGER_' + str(i) + '.text()'))(self)) for i in range(3) ]).replace(' ', ''), 'friendPos': self.ui.BTG_FRIEND.checkedButton().objectName()[-1], 'masterSkill': str([[ int((lambda self: eval('self.ui.TXT_MASTER_' + str( i) + '_' + str(j) + '.text()'))(self)) for j in range(3) ] for i in range(3)]).replace(' ', '') } with open('fgoConfig.ini', 'w') as f: config.write(f) def resetParty(self): self.loadParty('DEFAULT') def getDevice(self): text, ok = (lambda adbList: QInputDialog.getItem( self, '更改安卓设备', '在下拉列表中选择', adbList, adbList.index(self.serialno) if self.serialno and self.serialno in adbList else 0))( [i for i, j in ADB().devices() if j == 'device']) if ok and text: self.serialno = text def adbConnect(self): text, ok = QInputDialog.getText(self, '连接远程设备', 'adb connect', text='localhost:5555') if ok and text: ADB(text) def checkCheck(self): fgoFunc.Check(0).show() def getFriend(self): self.IMG_FRIEND = [[file[:-4], cv2.imread('image/friend/' + file)] for file in os.listdir('image/friend') if file.endswith('.png')] def applyAll(self): fgoFunc.suspendFlag = False fgoFunc.terminateFlag = False fgoFunc.fuse.reset() fgoFunc.skillInfo = [[[ int((lambda self: eval('self.ui.TXT_SKILL_' + str(i) + '_' + str( j) + '_' + str(k) + '.text()'))(self)) for k in range(3) ] for j in range(3)] for i in range(6)] fgoFunc.houguInfo = [[ int((lambda self: eval('self.ui.TXT_HOUGU_' + str(i) + '_' + str(j) + '.text()'))(self)) for j in range(2) ] for i in range(6)] fgoFunc.dangerPos = [ int((lambda self: eval('self.ui.TXT_DANGER_' + str(i) + '.text()') )(self)) for i in range(3) ] fgoFunc.friendPos = int( self.ui.BTG_FRIEND.checkedButton().objectName()[-1]) fgoFunc.masterSkill = [[ int((lambda self: eval('self.ui.TXT_MASTER_' + str(i) + '_' + str( j) + '.text()'))(self)) for j in range(3) ] for i in range(3)] if self.serialno != fgoFunc.base.serialno: fgoFunc.base = fgoFunc.Base(self.serialno) fgoFunc.IMG_FRIEND = self.IMG_FRIEND def runOneBattle(self): self.runFunc(fgoFunc.oneBattle) def runMain(self): self.runFunc(fgoFunc.main, self.ui.TXT_APPLE.value(), self.ui.CBX_APPLE.currentIndex()) def runUser(self): pass def pause(self): fgoFunc.suspendFlag = not fgoFunc.suspendFlag def stop(self): fgoFunc.terminateFlag = True def openFolder(self): os.startfile(os.getcwd()) def stayOnTop(self): self.setWindowFlags(self.windowFlags() ^ Qt.WindowStaysOnTopHint) self.show() def about(self): QMessageBox.about( self, '关于', '作者:\thgjazhgj\n项目地址:https://github.com/hgjazhgj/FGO-py\n联系方式:[email protected]' )
class MyMainWindow(QMainWindow): signalFuncBegin=pyqtSignal() signalFuncEnd=pyqtSignal() def __init__(self,parent=None): super().__init__(parent) self.ui=Ui_fgoMainWindow() self.ui.setupUi(self) self.ui.CBX_PARTY.addItems(config.sections()) self.ui.CBX_PARTY.setCurrentIndex(-1) self.ui.TXT_PARTY.setValidator(QRegExpValidator(QRegExp('10|[0-9]'),self)) self.loadParty('DEFAULT') self.serialno=fgoFunc.base.serialno self.getDevice() self.IMG_FRIEND=fgoFunc.IMG_FRIEND self.signalFuncBegin.connect(self.funcBegin)#,Qt.BlockingQueuedConnection) self.signalFuncEnd.connect(self.funcEnd) def keyPressEvent(self,key): if key.modifiers()==Qt.NoModifier: try:fgoFunc.base.press(QTK2VK[key.key()]) except:pass def runFunc(self,func,*args,**kwargs): if self.serialno is None:return QMessageBox.critical(self,'错误','无设备连接',QMessageBox.Ok) def f(): try: fgoFunc.suspendFlag=False fgoFunc.terminateFlag=False fgoFunc.fuse.reset() self.signalFuncBegin.emit() self.applyAll() func(*args,**kwargs) except Exception as e:logger.exception(e) finally: self.signalFuncEnd.emit() QApplication.beep() threading.Thread(target=f).start() def funcBegin(self): self.ui.BTN_ONEBATTLE.setEnabled(False) self.ui.BTN_MAIN.setEnabled(False) self.ui.BTN_USER.setEnabled(False) self.ui.MENU_SCRIPT_GACHA.setEnabled(False) self.ui.BTN_PAUSE.setEnabled(True) self.ui.BTN_STOP.setEnabled(True) self.ui.BTN_PAUSE.setChecked(False) #self.repaint() #self.applyAll() def funcEnd(self): self.ui.BTN_ONEBATTLE.setEnabled(True) self.ui.BTN_MAIN.setEnabled(True) self.ui.BTN_USER.setEnabled(True) self.ui.MENU_SCRIPT_GACHA.setEnabled(True) self.ui.BTN_PAUSE.setEnabled(False) self.ui.BTN_STOP.setEnabled(False) def loadParty(self,x): self.ui.TXT_PARTY.setText(config[x]['partyIndex']) skillInfo=eval(config[x]['skillInfo']) for i,j,k in((i,j,k)for i in range(6)for j in range(3)for k in range(3)):eval(f'self.ui.TXT_SKILL_{i}_{j}_{k}.setText("{skillInfo[i][j][k]}")') houguInfo=eval(config[x]['houguInfo']) for i,j in((i,j)for i in range(6)for j in range(2)):eval(f'self.ui.TXT_HOUGU_{i}_{j}.setText("{houguInfo[i][j]}")') dangerPos=eval(config[x]['dangerPos']) for i in range(3):eval(f'self.ui.TXT_DANGER_{i}.setText("{dangerPos[i]}")') eval(f'self.ui.RBT_FRIEND_{config[x]["friendPos"]}.setChecked(True)') masterSkill=eval(config[x]['masterSkill']) for i,j in((i,j)for i in range(3)for j in(range(4)if i==2else range(3))):eval(f'self.ui.TXT_MASTER_{i}_{j}.setText("{masterSkill[i][j]}")') def saveParty(self): config[self.ui.CBX_PARTY.currentText()]={ 'partyIndex':self.ui.TXT_PARTY.text(), 'skillInfo':str([[[int((lambda self:eval(f'self.ui.TXT_SKILL_{i}_{j}_{k}.text()'))(self))for k in range(3)]for j in range(3)]for i in range(6)]).replace(' ',''), 'houguInfo':str([[int((lambda self:eval(f'self.ui.TXT_HOUGU_{i}_{j}.text()'))(self))for j in range(2)]for i in range(6)]).replace(' ',''), 'dangerPos':str([int((lambda self:eval(f'self.ui.TXT_DANGER_{i}.text()'))(self))for i in range(3)]).replace(' ',''), 'friendPos':self.ui.BTG_FRIEND.checkedButton().objectName()[-1], 'masterSkill':str([[int((lambda self:eval(f'self.ui.TXT_MASTER_{i}_{j}.text()'))(self))for j in(range(4)if i==2else range(3))]for i in range(3)]).replace(' ','')} with open('fgoConfig.ini','w')as f:config.write(f) def resetParty(self):self.loadParty('DEFAULT') def getDevice(self): text,ok=(lambda adbList:QInputDialog.getItem(self,'选取安卓设备','在下拉列表中选择一个设备',adbList,adbList.index(self.serialno)if self.serialno and self.serialno in adbList else 0,True,Qt.WindowStaysOnTopHint))([i for i,j in ADB().devices()if j=='device']) if ok and text:self.serialno=text def adbConnect(self): text,ok=QInputDialog.getText(self,'连接远程设备','设备地址',text='localhost:5555') if ok and text:ADB(text) def refreshDevice(self):fgoFunc.base=fgoFunc.Base(fgoFunc.base.serialno) def checkCheck(self): if fgoFunc.base.serialno is None:return QMessageBox.critical(self,'错误','无设备连接',QMessageBox.Ok) fgoFunc.Check(0).show() def getFriend(self):self.IMG_FRIEND=[[file[:-4],cv2.imread(f'image/friend/{i}')]for i in os.listdir('image/friend')if i.endswith('.png')] def applyAll(self): fgoFunc.partyIndex=int(self.ui.TXT_PARTY.text()) fgoFunc.skillInfo=[[[int((lambda self:eval(f'self.ui.TXT_SKILL_{i}_{j}_{k}.text()'))(self))for k in range(3)]for j in range(3)]for i in range(6)] fgoFunc.houguInfo=[[int((lambda self:eval(f'self.ui.TXT_HOUGU_{i}_{j}.text()'))(self))for j in range(2)]for i in range(6)] fgoFunc.dangerPos=[int((lambda self:eval(f'self.ui.TXT_DANGER_{i}.text()'))(self))for i in range(3)] fgoFunc.friendPos=int(self.ui.BTG_FRIEND.checkedButton().objectName()[-1]) fgoFunc.masterSkill=[[int((lambda self:eval(f'self.ui.TXT_MASTER_{i}_{j}.text()'))(self))for j in(range(4)if i==2else range(3))]for i in range(3)] if self.serialno!=fgoFunc.base.serialno:fgoFunc.base=fgoFunc.Base(self.serialno) fgoFunc.IMG_FRIEND=self.IMG_FRIEND def runOneBattle(self):self.runFunc(fgoFunc.oneBattle) def runUser(self):self.runFunc(fgoFunc.userScript) def runGacha(self):self.runFunc(fgoFunc.gacha) def runMain(self): text,ok=QInputDialog.getItem(self,'肝哪个','在下拉列表中选择战斗函数',['oneBattle','userScript']) if ok and text:self.runFunc(fgoFunc.main,self.ui.TXT_APPLE.value(),self.ui.CBX_APPLE.currentIndex(),eval('fgoFunc.'+text)) def pause(self):fgoFunc.suspendFlag=not fgoFunc.suspendFlag def stop(self):fgoFunc.terminateFlag=True def openFolder(self):os.startfile(os.getcwd()) def cmdHere(self):os.system('start cmd') def stayOnTop(self): self.setWindowFlags(self.windowFlags()^Qt.WindowStaysOnTopHint) self.show() def mapKey(self,x):self.grabKeyboard()if x else self.releaseKeyboard() def about(self):QMessageBox.about(self,'关于','作者:\thgjazhgj \n项目地址:https://github.com/hgjazhgj/FGO-py \n联系方式:[email protected] \n防呆不放蠢,大力出奇迹!')