def __init__(self, Widgets, x, y,Info):
        super().__init__()
        self.Info = Info

        Width = 365
        Height = 50

        self.base = QtWidgets.QWidget(Widgets)
        self.base.setGeometry(QRect(x, y, Width, Height))
        self.base.setObjectName('QWidget_Base')
        self.base.setStyleSheet("QWidget#QWidget_Base{border-radius: 5px;background-color: rgb(255, 255, 255);border: 1px solid #e1e4e8;}")

        self.Label = QtWidgets.QLabel(self.base)
        self.Label.setGeometry(QRect(5, 5, 40, 40))
        self.Pix = QtGui.QPixmap(dir_mix(path,'UI','ExtraImage','cube.svg')).scaled(40, 40)
        self.Label.setPixmap(self.Pix)

        self.Label_TagName = QtWidgets.QLabel(self.base)
        self.Label_TagName.setGeometry(QRect(50, 15, 120, 20))
        self.Label_TagName.setText(self.Info["TagName"])

        self.pushButton_see = QPushButton(self.base)
        self.pushButton_see.setGeometry(QRect(180, 10, 30, 30))
        self.pushButton_see.setStyleSheet('border-radius: 5px;background-color: rgb(255, 255, 255);border: 1px solid #e1e4e8;')
        self.Pix_see = QtGui.QPixmap(dir_mix(path, 'UI', 'ExtraImage', 'see.svg')).scaled(25, 25)
        self.pushButton_see.setIcon(QtGui.QIcon(self.Pix_see))
        self.pushButton_see.setToolTip("查看更新日志")
        self.pushButton_see.clicked.connect(self.see)

        self.pushButton_download = QPushButton(self.base)
        self.pushButton_download.setGeometry(QRect(220, 10, 30, 30))
        self.pushButton_download.setStyleSheet(
            'border-radius: 5px;background-color: rgb(255, 255, 255);border: 1px solid #e1e4e8;')
        self.Pix_download = QtGui.QPixmap(dir_mix(path, 'UI', 'ExtraImage', 'download.svg')).scaled(25, 25)
        self.pushButton_download.setIcon(QtGui.QIcon(self.Pix_download))
        self.pushButton_download.setToolTip("下载该版本")
        self.pushButton_download.clicked.connect(self.download)

        self.pushButton_set = QPushButton(self.base)
        self.pushButton_set.setGeometry(QRect(260, 10, 30, 30))
        self.pushButton_set.setStyleSheet(
            'border-radius: 5px;background-color: rgb(255, 255, 255);border: 1px solid #e1e4e8;')
        self.Pix_set = QtGui.QPixmap(dir_mix(path, 'UI', 'ExtraImage', 'set.svg')).scaled(25, 25)
        self.pushButton_set.setIcon(QtGui.QIcon(self.Pix_set))
        self.pushButton_set.setToolTip("设置该版本为默认")
        self.pushButton_set.clicked.connect(self.setDefault)

        self.pushButton_del = QPushButton(self.base)
        self.pushButton_del.setGeometry(QRect(300, 10, 30, 30))
        self.pushButton_del.setStyleSheet(
            'border-radius: 5px;background-color: rgb(255, 255, 255);border: 1px solid #e1e4e8;')
        self.pushButton_del.setToolTip("删除该版本")
        self.pushButton_del.clicked.connect(self.Delete)
        self.Pix_del = QtGui.QPixmap(dir_mix(path, 'UI', 'ExtraImage', 'del.svg')).scaled(25, 25)
        self.pushButton_del.setIcon(QtGui.QIcon(self.Pix_del))
Exemple #2
0
    def __init__(self):
        self.config = {
            'PlayerVersion': "",
        }

        try:
            with open(dir_mix(root, 'QuickLauncher', 'config.json'),
                      'r+') as f:
                content = json.loads(f.read())
                self.config = content
        except:
            with open(dir_mix(root, 'QuickLauncher', 'config.json'),
                      'w+') as f:
                f.write(json.dumps(self.config))
Exemple #3
0
 def update(self):
     try:
         with open(dir_mix(root, 'QuickLauncher', 'config.json'),
                   'w+') as f:
             f.write(json.dumps(self.config))
     except:
         pass
    def soundPlay(self, sound_name):
        path = dir_mix(Space["root"],
                       path_read(self.sound_Actions[sound_name]["path"]))

        url = QtCore.QUrl.fromLocalFile(path)
        self.sound.setMedia(QtMultimedia.QMediaContent(url))
        self.sound.play()
 def Find(self):
     # 检查是否存在该版本
     if os.path.exists(dir_mix(Player_path,self.Info["TagName"])):
         self.pushButton_set.setEnabled(True)
         self.pushButton_del.setVisible(True)
     else:
         self.pushButton_set.setEnabled(False)
         self.pushButton_del.setVisible(False)
    def Delete(self):
        try:
            shutil.rmtree(dir_mix(Player_path,self.Info["TagName"]))
        except:
            pass
        self.Find()

        if config.config["PlayerVersion"] == self.Info["TagName"]:
            config.config["PlayerVersion"] = "Wrong version"
            config.update()
            self.update.emit()
 def RunAll(self):
     v = config.config['PlayerVersion']
     if v == 'Wrong version' or not v:
         QtWidgets.QMessageBox.warning(self, 'error', '没有找到show组件,请点击右下角加号图包进行安装', QtWidgets.QMessageBox.Yes)
     elif not self.Card_List:
         QtWidgets.QMessageBox.warning(self, 'error', '没有图包,自行添加', QtWidgets.QMessageBox.Yes)
     elif not Space['select']:
         QtWidgets.QMessageBox.warning(self, 'error', '没有选择图包', QtWidgets.QMessageBox.Yes)
     else:
         choose = QtWidgets.QMessageBox.information(self, 'Success', '一切就绪', QtWidgets.QMessageBox.No,QtWidgets.QMessageBox.Yes)
         if choose == QtWidgets.QMessageBox.StandardButton.Yes:
             for i in Space['select']:
                 subprocess.Popen([wrapper_path,dir_mix(Player_path,v),self.Card_List[i]])
 def Animation_Information_Get(self, Item):
     self.ChooseItem = Item.text()
     Info = Space["Script"]["play"][Item.text()]
     fullpath = dir_mix(Space["root"], path_read(Info["path"]))
     self.Animation_Information_path_lineEdit.setText(fullpath)
     self.Animation_Information_front_lineEdit.setText(
         Info["turns"]["front"])
     self.Animation_Information_end_lineEdit.setText(Info["turns"]["end"])
     self.Animation_Information_start_lineEdit.setText(
         str(Info["turns"]["first"]))
     self.Animation_Information_last_lineEdit.setText(
         str(Info["turns"]["last"]))
     self.Animation_Information_fps_lineEdit.setText(
         str(Info["turns"]["fps"]))
    def run(self) -> None:
        Path = None  # 图包父目录
        Child_path = None  # 图包文件夹目录名[list]
        # 遍历图包目录
        for paths, child_path, j in os.walk(Package_path):
            Path = paths
            Child_path = child_path
            break

        now_Process = None

        try:
            for pkg_name in Child_path:
                now_Process = pkg_name
                config_file = dir_mix(
                    Path,
                    pkg_name,
                    'config.json'
                )
                # 合并多段数据 组成config文件的目录数据

                with open(config_file, 'r', encoding='utf-8') as f:
                    content = json.loads(f.read())
                    Package_root = dir_mix(Path, pkg_name)

                    To = {
                        "Package_root" : Package_root,
                        "cover" : dir_mix(Package_root, content["cover"]),
                        "name" : content["Name"],
                        "Description" : content["Description"]
                    }

                    self.Create.emit(json.dumps(To))

        except:
            self.error.emit('包:[' + now_Process + ']异常')
Exemple #10
0
def Importer():
    try:
        Imports = Space["Script"]["Import"]
        Add("Plugin")
        Space["Plugin"] = {}
    except:
        return
    for Action_name in Imports:
        Path = dir_mix(Space["root"],
                       path_read(Imports[Action_name]["WorkPath"]))
        if Path not in sys.path:
            sys.path.append(Path)
            # 引入模块路径
        Space["Plugin"][Action_name] = Plugin(
            Imports[Action_name]["module_name"])
        Space["Plugin"][Action_name].start()
        try:
            Space["Plugin"][Action_name].Call(
                Imports[Action_name]['init'])  # Plugin类提供的函数执行方法
        except:
            pass
    def download(self):
        Tag = self.Info["TagName"]

        self.Text = '<h1>正在下载 :{}</h1>'.format(Tag)

        def Change_Text(Url): # 更新下载文件的Text显示
            self.Text += '\n'
            self.Text += "<p>下载:{}</p>".format(Url)
            self.change.emit(self.Text)

        def end():
            self.Text += '\n'
            self.Text += '<h2>下载完成<h2>'
            self.change.emit(self.Text)
            self.Find()

        Object = Space["jsdelivr_Data"].version(Tag)
        if Object == ValueError:
            self.error.emit("网络错误,无法获取目录结构")
        else:
            Space["jsdelivr_Data"].DownloadUnit.end.connect(end)
            Space["jsdelivr_Data"].DownloadUnit.PackDownload(Object,Tag,dir_mix(Player_path,Tag),Change_Text)
    def __init__(self, config, root, app):
        # mainwindow 初始化 ======================================================================
        super().__init__()
        self.app = app
        # 保存传入的初始化数据
        Add('config')
        Space["config"] = config
        Add('root')
        Space["root"] = root

        TrayIcon_img = dir_mix(Space["root"],
                               Space["config"]['cover'])  # 用人物预览图作为托盘图标 和 显示图标

        with open(dir_mix(Space["root"], Space["config"]['Script']),
                  'r',
                  encoding='utf-8') as f:
            Add('Script')
            Space["Script"] = json.loads(f.read())  # 获取Script的参数
        Setting = Space["Script"]["Setting"]  # 获取Setting的数据集合

        self.ImageSize = Setting["ImageSize"]
        Add('Change')
        Space['Change'] = Setting["Change"]

        try:
            self.sound_Actions = Space["Script"]["sound"]
        except:
            pass

        Add('Info')
        Space['Info'] = {}
        Space['Info']["Play_complete"] = {}  # 播放组件是否播放完毕设置
        Space['Info']["Move"] = {}
        Space['Info']["Move"]["Window"] = {}

        Add('Control_Api')
        Space['Control_Api'] = {}

        # 核心控制器类
        Add("CoreControl")
        Space["CoreControl"] = Special_Control.CoreControl()

        self.setupUi(self)  # 创建标准窗口
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)  # 设置窗口背景透明
        self.setWindowTitle(
            Space["config"]['Name'])  # 把窗口名称设置成config.json中的Name键的值
        self.setWindowIcon(QtGui.QIcon(TrayIcon_img))  # 设置Icon

        self.Cache = {}  # 图片缓存字典

        # 组件创建
        self.label = Special_Label(self)  # 创建特殊的Label
        self.PlayBoard = PlayBoard()  # 创建播放器
        self.PlayBoard.play.connect(self.graph)
        self.Find = Find()  # 实例化指令查询插件
        self.sound = QtMultimedia.QMediaPlayer()  # 创立音频播放组件

        Space['BGMPlayer'] = QtMultimedia.QMediaPlayer()
        Space['BGMPlaylist'] = QtMultimedia.QMediaPlaylist()

        self.User = User()  # User组件 (会创建CommonSet,在Setbox前加载)

        self.Setbox = Setbox(self)

        self.ChangeWindowFlags(True)

        # 核心控制器绑定组件 ============================================
        Space["CoreControl"].play.connect(self.PlayNew)
        Space["CoreControl"].sound.connect(self.soundPlay)
        Space["CoreControl"].ChangeSize.connect(self.ChangeSize)
        Space["CoreControl"].Move.connect(self.MovePeson)

        Space["CoreControl"].clean.connect(self.PlayBoard.terminate)
        Space["CoreControl"].clean.connect(self.Setbox.close)
        Space["CoreControl"].clean.connect(self.close)
        Space["CoreControl"].clean.connect(self.app.exit)

        # Special_Label组件事件绑定 ============================================
        self.label.LeftButton_release.connect(
            self.LeftButton_release)  # 绑定鼠标左键点击事件[松开左键]
        self.label.LeftButton_click.connect(
            self.LeftButton_click)  # 绑定鼠标左键点击事件[松开左键]

        self.label.RightButton_release.connect(
            self.RightButton_release)  # 绑定鼠标右键点击事件[松开右键]
        self.label.RightButton_Move.connect(self.RightButton_Move)

        # 设置事件绑定 ===========================
        self.Setbox.MovePeson.connect(self.MovePeson)
        self.Setbox.ResetWindowFlag.connect(self.ChangeWindowFlags)
        # 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.PlayBoard.start()

        if Space['CommonSet']["Change"] != None:
            Space['Change'] = Space['CommonSet']["Change"]
        self.ChangeSize()  # 设置窗口初始大小

        # Importer
        plugin.Importer()