diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..df03a38 --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Find.py b/Find.py index 6fe3d1f..2084646 100644 --- a/Find.py +++ b/Find.py @@ -52,20 +52,3 @@ def Action_run(self, Action, x, y, Change): if (x >= locate_tmp[0] and x <= locate_tmp[1] and y >= locate_tmp[2] and y <= locate_tmp[3]) != True: return 'Your mouse is not in place [sound]' self.soundPlay.emit(Action["Action"]) - - # def Find(self, Action): - # try: - # self.ActionGroup = self.Script["ActionGroup"] - # if Action in self.ActionGroup: # 检查动作是否在动作组 - # Actions = self.ActionGroup[Action] - # for From in Actions: # 遍历动作组,获得相应定义的动作 类 - # if From == 'play': - # for runs in Actions[From]: # 遍历动作 类 ,获得类中动作 - # print('PlayAction', runs) - # self.play.emit(runs) - # - # return True - # - # except: - # if Action in self.Script["play"]: # 检查动作是否在play组 - # self.play.emit(Action) diff --git a/PlayBoard.py b/PlayBoard.py index fa69dc6..5d36f5a 100644 --- a/PlayBoard.py +++ b/PlayBoard.py @@ -30,19 +30,24 @@ def init(self): def run(self): def In_Play(): + First_time = time.time() wait = 1/self.turns["fps"] Picture = 0 - sleep_time = 0.8/self.turns["fps"] - while (Picture < self.turns["last"]): - if self.stop == True: - return 'Jump' + while (self.stop == False): Now_time = time.time() - Picture = int((Now_time - First_time) / wait) + self.turns["first"] # 利用当前经过的时间来确定当前帧 + Picture = int((Now_time - First_time) / wait )+ self.turns["first"] # 利用当前经过的时间来确定当前帧 + if Picture > self.turns["last"]: + break name = self.turns["front"] + str(Picture) + self.turns["end"] # 拼合图片名称 self.play.emit(dir_mix(self.root, self.child_path, name)) # 发出图片显示指令 - time.sleep(sleep_time) - return 'PlayOver' + time.sleep(wait) + + if self.stop == True: + return 'Jump' + else: + return 'PlayOver' + # 把跳出检查集中到下方可以避免出现因为图片过少导致的忽略跳出 bug出现:v0.0.0.2 while True: if self.stop == True: diff --git a/Setbox.py b/Setbox.py new file mode 100644 index 0000000..12930e5 --- /dev/null +++ b/Setbox.py @@ -0,0 +1,25 @@ +from UI.Setbox import Ui_Setbox +from PyQt5 import QtCore, QtGui, QtWidgets +from PyQt5.QtCore import pyqtSignal + +class Setbox(QtWidgets.QMainWindow,Ui_Setbox): + ChangeSize = pyqtSignal(float) + def __init__(self,parent = None): + super(Setbox,self).__init__(parent) + self.setupUi(self) + self.config = None + self.Script = None + # self.show() + def init(self): + self.Name_show.setText(self.config['Name']) + self.Introduction_show.setPlainText(self.config['Description']) + + Setting = self.Script['Setting'] + print(str(Setting['Change'])) + self.ImgSize_text_percent.setText(str(Setting['Change'])) + self.ImgSize_control.setValue(Setting['Change']*20) + def ImgSize_control_valueChange(self): + # Change 的值从0 - 5 + Change = self.ImgSize_control.value()/20 + self.ImgSize_text_percent.setText(str(Change)) + self.ChangeSize.emit(Change) diff --git a/Special_Label.py b/Special_Label.py index 4328fa9..426fdb9 100644 --- a/Special_Label.py +++ b/Special_Label.py @@ -1,6 +1,6 @@ -from PyQt5 import QtCore,QtWidgets,QtGui +from PyQt5 import QtCore,QtWidgets from PyQt5.QtCore import pyqtSignal -import threading + class Special_Label(QtWidgets.QLabel): LeftButton_release = pyqtSignal(int, int) LeftButton_click = pyqtSignal(int, int) @@ -14,19 +14,6 @@ class Special_Label(QtWidgets.QLabel): def __init__(self,window): super().__init__(window) - self.popMenu = QtWidgets.QMenu() - self.MenuActions = {} - self.popMenu.show() - self.popMenu.setVisible(False) - - self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) - - - def AddActions(self, name, job): - self.MenuActions[name] = QtWidgets.QAction(name, self) - self.MenuActions[name].triggered.connect(job) - self.popMenu.addAction(self.MenuActions[name]) - def mousePressEvent(self, QMouseEvent): ##重载一下鼠标点击事件 if QMouseEvent.button() == QtCore.Qt.LeftButton: @@ -55,8 +42,7 @@ def mouseReleaseEvent(self, QMouseEvent): # 右键移动且松开 elif self.RightOn == True: self.RightOn = False - self.popMenu.move(QtGui.QCursor.pos()) - self.popMenu.setVisible(True) + # 右键事件 [松开] def mouseMoveEvent(self, QMouseEvent): diff --git a/TrayIcon.py b/TrayIcon.py new file mode 100644 index 0000000..d19451f --- /dev/null +++ b/TrayIcon.py @@ -0,0 +1,21 @@ +from PyQt5 import QtGui, QtWidgets + +class TrayIcon(QtWidgets.QSystemTrayIcon): + def __init__(self,parent = None): + super(TrayIcon,self).__init__(parent) + + self.popMenu = QtWidgets.QMenu() + self.MenuActions = {} + self.popMenu.show() + self.popMenu.setVisible(False) + + self.activated.connect(self.Click) + + def AddActions(self, name, job): + self.MenuActions[name] = QtWidgets.QAction(name, self) + self.MenuActions[name].triggered.connect(job) + self.popMenu.addAction(self.MenuActions[name]) + + def Click(self): + self.popMenu.move(QtGui.QCursor.pos()) + self.popMenu.setVisible(True) diff --git a/UI/Setbox.py b/UI/Setbox.py new file mode 100644 index 0000000..9ce52aa --- /dev/null +++ b/UI/Setbox.py @@ -0,0 +1,85 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'E:\Codes\独立项目\Cardinal\show\UI\Setbox.ui' +# +# Created by: PyQt5 UI code generator 5.14.2 +# +# WARNING! All changes made in this file will be lost! + + +from PyQt5 import QtCore, QtGui, QtWidgets + + +class Ui_Setbox(object): + def setupUi(self, Setbox): + Setbox.setObjectName("Setbox") + Setbox.resize(800, 500) + Setbox.setMinimumSize(QtCore.QSize(800, 500)) + Setbox.setMaximumSize(QtCore.QSize(800, 500)) + self.centralwidget = QtWidgets.QWidget(Setbox) + self.centralwidget.setObjectName("centralwidget") + self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) + self.gridLayout.setObjectName("gridLayout") + self.tabWidget = QtWidgets.QTabWidget(self.centralwidget) + self.tabWidget.setObjectName("tabWidget") + self.tab = QtWidgets.QWidget() + self.tab.setObjectName("tab") + self.verticalLayout = QtWidgets.QVBoxLayout(self.tab) + self.verticalLayout.setObjectName("verticalLayout") + self.groupBox = QtWidgets.QGroupBox(self.tab) + self.groupBox.setObjectName("groupBox") + self.ImgSize_text = QtWidgets.QLabel(self.groupBox) + self.ImgSize_text.setGeometry(QtCore.QRect(10, 20, 31, 21)) + self.ImgSize_text.setObjectName("ImgSize_text") + self.ImgSize_control = QtWidgets.QSlider(self.groupBox) + self.ImgSize_control.setGeometry(QtCore.QRect(40, 20, 191, 22)) + self.ImgSize_control.setMaximum(100) + self.ImgSize_control.setPageStep(0) + self.ImgSize_control.setProperty("value", 0) + self.ImgSize_control.setSliderPosition(0) + self.ImgSize_control.setOrientation(QtCore.Qt.Horizontal) + self.ImgSize_control.setObjectName("ImgSize_control") + self.ImgSize_text_percent = QtWidgets.QLabel(self.groupBox) + self.ImgSize_text_percent.setGeometry(QtCore.QRect(240, 20, 31, 21)) + self.ImgSize_text_percent.setObjectName("ImgSize_text_percent") + self.verticalLayout.addWidget(self.groupBox) + self.groupBox_2 = QtWidgets.QGroupBox(self.tab) + self.groupBox_2.setObjectName("groupBox_2") + self.Name_show = QtWidgets.QLineEdit(self.groupBox_2) + self.Name_show.setGeometry(QtCore.QRect(40, 20, 241, 20)) + self.Name_show.setObjectName("Name_show") + self.Name_text = QtWidgets.QLabel(self.groupBox_2) + self.Name_text.setGeometry(QtCore.QRect(10, 21, 31, 21)) + self.Name_text.setObjectName("Name_text") + self.Introduction_text = QtWidgets.QLabel(self.groupBox_2) + self.Introduction_text.setGeometry(QtCore.QRect(10, 50, 31, 21)) + self.Introduction_text.setObjectName("Introduction_text") + self.Introduction_show = QtWidgets.QPlainTextEdit(self.groupBox_2) + self.Introduction_show.setGeometry(QtCore.QRect(40, 50, 241, 91)) + self.Introduction_show.setPlainText("") + self.Introduction_show.setPlaceholderText("") + self.Introduction_show.setObjectName("Introduction_show") + self.verticalLayout.addWidget(self.groupBox_2) + self.tabWidget.addTab(self.tab, "") + self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1) + Setbox.setCentralWidget(self.centralwidget) + self.menubar = QtWidgets.QMenuBar(Setbox) + self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 23)) + self.menubar.setObjectName("menubar") + Setbox.setMenuBar(self.menubar) + + self.retranslateUi(Setbox) + self.tabWidget.setCurrentIndex(0) + self.ImgSize_control.valueChanged['int'].connect(Setbox.ImgSize_control_valueChange) + QtCore.QMetaObject.connectSlotsByName(Setbox) + + def retranslateUi(self, Setbox): + _translate = QtCore.QCoreApplication.translate + Setbox.setWindowTitle(_translate("Setbox", "MainWindow")) + self.groupBox.setTitle(_translate("Setbox", "显示")) + self.ImgSize_text.setText(_translate("Setbox", "缩放")) + self.ImgSize_text_percent.setText(_translate("Setbox", "0")) + self.groupBox_2.setTitle(_translate("Setbox", "基本参数")) + self.Name_text.setText(_translate("Setbox", "名称")) + self.Introduction_text.setText(_translate("Setbox", "介绍")) + self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("Setbox", "基本参数")) diff --git a/UI/Setbox.ui b/UI/Setbox.ui new file mode 100644 index 0000000..c46e518 --- /dev/null +++ b/UI/Setbox.ui @@ -0,0 +1,196 @@ + + + Setbox + + + + 0 + 0 + 800 + 500 + + + + + 800 + 500 + + + + + 800 + 500 + + + + MainWindow + + + + + + + 0 + + + + 基本参数 + + + + + + 显示 + + + + + 10 + 20 + 31 + 21 + + + + 缩放 + + + + + + 40 + 20 + 191 + 22 + + + + 100 + + + 0 + + + 0 + + + 0 + + + Qt::Horizontal + + + + + + 240 + 20 + 31 + 21 + + + + 0 + + + + + + + + 基本参数 + + + + + 40 + 20 + 241 + 20 + + + + + + + 10 + 21 + 31 + 21 + + + + 名称 + + + + + + 10 + 50 + 31 + 21 + + + + 介绍 + + + + + + 40 + 50 + 241 + 91 + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 800 + 23 + + + + + + + + ImgSize_control + valueChanged(int) + Setbox + ImgSize_control_valueChange() + + + 127 + 93 + + + 313 + -8 + + + + + + ImgSize_control_valueChange() + + diff --git a/UI/graphics.py b/UI/graphics.py index 9cbb0e0..15f89b4 100644 --- a/UI/graphics.py +++ b/UI/graphics.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Form implementation generated from reading ui file 'E:\Codes\独立项目\Cardinal\UI\graphics.ui' +# Form implementation generated from reading ui file 'E:\Codes\独立项目\Cardinal\show\UI\graphics.ui' # # Created by: PyQt5 UI code generator 5.14.2 # diff --git a/window_graphics.py b/window_graphics.py index b4df141..7a56189 100644 --- a/window_graphics.py +++ b/window_graphics.py @@ -4,6 +4,8 @@ from Find import Find from PlayBoard import PlayBoard from Special_Label import Special_Label +from TrayIcon import TrayIcon +from Setbox import Setbox import json class window_graphics(QtWidgets.QMainWindow, graphics_window): @@ -13,6 +15,7 @@ def __init__(self, config, root): self.config = config self.root = root # 保存传入的初始化数据 + TrayIcon_img = dir_mix(root, config['cover']) # 用人物预览图作为托盘图标 with open(dir_mix(root, config['Script']), 'r', encoding='utf-8') as f: self.Script = json.loads(f.read()) # 获取Script的参数 self.Setting = self.Script["Setting"] # 获取Setting的数据集合 @@ -43,7 +46,7 @@ def __init__(self, config, root): # Special_Label组件 ============================================ self.label = Special_Label(self) # 创建特殊的Label - self.label.AddActions("退出",self.close) + self.label.LeftButton_release.connect(self.LeftButton_release) # 绑定鼠标左键点击事件[松开左键] self.label.LeftButton_click.connect(self.LeftButton_click) # 绑定鼠标左键点击事件[松开左键] @@ -51,6 +54,18 @@ def __init__(self, config, root): self.label.RightButton_release.connect(self.RightButton_release) # 绑定鼠标右键点击事件[松开右键] self.label.RightButton_Move.connect(self.RightButton_Move) + # 设置 =========================== + self.Setbox = Setbox(self) + self.Setbox.config = self.config + self.Setbox.Script = self.Script + self.Setbox.init() + self.Setbox.ChangeSize.connect(self.ChangeSize) + # TrayIcon 组件 ===================================== + self.TrayIcon = TrayIcon(self) + self.TrayIcon.setIcon(QtGui.QIcon(TrayIcon_img)) + self.TrayIcon.show() + self.TrayIcon.AddActions("退出",self.close) + self.TrayIcon.AddActions("设置", self.Setbox.show) self.sound = QtMultimedia.QMediaPlayer() # 创立音频播放组件 @@ -60,7 +75,9 @@ def __init__(self, config, root): self.ChangeSize() # 设置窗口初始大小 - + def PlayNew(self,name): # 播放新的动作 + self.PlayBoard.Action = name + self.PlayBoard.stop = True def close(self): super().close() @@ -88,15 +105,14 @@ def LeftButton_release(self, x, y): self.Find.LeftRelease(x, y,self.Change) # self.PlayBoard.stop = True - def PlayNew(self,name): # 播放新的动作 - self.PlayBoard.Action = name - self.PlayBoard.stop = True - - def ChangeSize(self): - # self.Change:图片缩放系数,>0 [理论是多大都可以,但是你改100看我不打死你] - width = int(self.ImageSize[0] * self.Change) - height = int(self.ImageSize[1] * self.Change) - print('ChangeSize', width, height) + def ChangeSize(self,Change = None): + # self.Change:图片缩放系数,>0 [理论是多大都可以,但是你改100看我不 *%*&%] + if Change == None: + Change = self.Change + else: + self.Change = Change + width = int(self.ImageSize[0] * Change) + height = int(self.ImageSize[1] * Change) self.resize(width, height) self.label.setGeometry(0, 0, width, height)