Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
差不多快好了
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryZeng committed May 1, 2020
1 parent 43cd603 commit a28cfbb
Show file tree
Hide file tree
Showing 19 changed files with 3,466 additions and 3,157 deletions.
4 changes: 3 additions & 1 deletion Data/白金_站立_互动 - 语音/config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"Name": "白金(语音)",
"Description": "来自明日方舟-白金(语音) ,60fps"
"Description": "来自明日方舟-白金(语音) ,60fps",
"cover":"preview.png",
"Script":"run.json"
}

This file was deleted.

This file was deleted.

15 changes: 15 additions & 0 deletions Data/白金_站立_互动 - 语音/run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"usualy_play":"common",
"play":{
"common":{
"path":["resources","I"],
"turns":{
"front":"F (",
"first":"1",
"last":"121",
"end":").png",
"fps": 60
}
}
}
}
17 changes: 17 additions & 0 deletions Environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
path = Workpath = os.path.dirname(os.path.abspath(__file__))
# 工程根目录

next_ = None
if os.name == 'nt':
next_ = '\\'
else:
next_ = '/'
# 针对 Linux 和 windows 的不同,更改路径中的 反斜杠(\) 或 斜杠(/)

def dir_mix(*dirs):
mix = ''
for i in dirs:
mix += i+next_
return mix[:-1]
# 路径拼合函数
43 changes: 27 additions & 16 deletions GDI.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QWidget, QApplication
from PyQt5.QtGui import QPixmap, QPainter, QBitmap, QCursor
import PyQt5.QtCore as QtCore


class PixWindow(QWidget): # 不规则窗体
def __init__(self, parent=None):
super().__init__(parent)
class MyLabel(QLabel):
def __init__(self, *args, **kw):
super().__init__(*args, **kw)
self.setContextMenuPolicy(Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self.rightMenuShow) # 开放右键策略

self.pix = QBitmap('x.png') # 蒙版
self.resize(self.pix.size())
self.setMask(self.pix)
def rightMenuShow(self, pos): # 添加右键菜单
menu = QMenu(self)
menu.addAction(QAction('动作1', menu))
menu.addAction(QAction('动作2', menu))
menu.addAction(QAction('动作3', menu))
menu.triggered.connect(self.menuSlot)
menu.exec_(QCursor.pos())

self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) # 设置无边框和置顶窗口样式
def menuSlot(self, act):
print(act.text())

def paintEvent(self, QPaintEvent): # 绘制窗口
paint = QPainter(self)
paint.drawPixmap(0, 0, self.pix.width(), self.pix.height(), QPixmap('C:\\Users\\28799\\Desktop\\白金_站立_互动 - 语音\\resources\\R\\F (1).png'))

class Demo(QWidget):
def __init__(self, *args, **kw):
super().__init__(*args, **kw)
label = MyLabel('右击这里', self)
label.setGeometry(0, 0, 60, 30)

self.resize(100, 100)
self.show()


if __name__ == '__main__':
app = QApplication(sys.argv)
win = PixWindow()
win.show()
ecs = Demo()
sys.exit(app.exec_())
21 changes: 18 additions & 3 deletions Process/Mix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
from .window_about import window_about
from .window_loading import window_loading
from .window_main import window_main
from .window_graphics import window_graphics


class window_graphics_(window_graphics):
pass


class window_loading_(window_loading):
Expand All @@ -19,13 +24,23 @@ class window_main_(window_main):
def About_Window(self):
about.show()

def Play_selected(self):
super().selected()
for select in self.selected:
graphics[select] = window_graphics_(config=self.configs[select], root=self.pkg_root[select])
graphics[select].show()


debug = 2
app = QtWidgets.QApplication(sys.argv)

main = window_main_()
about = window_about_()

graphics = {}
loading = window_loading_()
loading.show()

# 加载各个窗体
if debug == 1:
loading.show()
elif debug == 2:
main.show()
sys.exit(app.exec_())
3 changes: 1 addition & 2 deletions Process/imports.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import pyqtSignal
import sys,time
import os
import sys,time,os,json
66 changes: 66 additions & 0 deletions Process/window_graphics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from .imports import *
from UI.graphics import Ui_Form as graphics_window
from Environment import path, dir_mix


class Special_Label(QtWidgets.QLabel):
def __init__(self):
super().__init__()

def mousePressEvent(self, e): ##重载一下鼠标点击事件
print("you clicked the label")

def mouseReleaseEvent(self, QMouseEvent):
print('you have release the mouse')


class PlayBoard(QtCore.QThread):
# 创建了一个子线程,用来渲染动画
play = pyqtSignal(str)

def __init__(self):
super().__init__()

def run(self):
dirs = 'E:\\Codes\\独立项目\\Cardinal\\Data\\白金_站立_互动 - 语音\\resources\\R\\'
while True:
for i in range(1, 122):
front = 'F ('
end = ').png'
name = front + str(i) + end
print(name)
print(dir_mix(dirs[:-1], name))
time.sleep(1 / 64)
self.play.emit(dir_mix(dirs[:-1], name))


class window_graphics(QtWidgets.QMainWindow, graphics_window):
def __init__(self, config, root):
super().__init__()
self.config = config
self.root = root
# 保存传入的初始化数据
with open(dir_mix(root,config['Script']),'r',encoding='utf-8') as f:
print(json.loads(f.read()))
self.setupUi(self)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint) # 去掉窗口标题栏和按钮
self.setAttribute(QtCore.Qt.WA_TranslucentBackground) # 设置窗口背景透明

self.label = QtWidgets.QLabel(self)
self.label.setObjectName("label")
width = 711
height = 496
self.resize(width, height)

self.label.setGeometry(0, 0, width, height)

def show(self) -> None:
super().show()
self.PlayBoard = PlayBoard()
self.PlayBoard.play.connect(self.graph)
self.PlayBoard.start()

def graph(self, paths):
print(paths)
pixmap = QtGui.QPixmap(paths).scaled(self.label.width(), self.label.height())
self.label.setPixmap(pixmap)
10 changes: 9 additions & 1 deletion Process/window_loading.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
from .imports import *
from UI.Loading import Ui_Form as Loading_window


class wait(QtCore.QThread):
# 创建了一个子线程,用来防止等待带来的界面卡死
comm = pyqtSignal()

def __init__(self):
super().__init__()

def run(self):
time.sleep(5)
# 等待5秒
self.comm.emit()

class window_loading(QtWidgets.QMainWindow,Loading_window):

class window_loading(QtWidgets.QMainWindow, Loading_window):
def __init__(self):
super().__init__()
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setupUi(self)

def show(self) -> None:
super().show()
self.waits = wait()
self.waits.comm.connect(self.run)
self.waits.start()
# 执行QThread子线程,进行等待,等待结束后回调run(self)函数

def run(self):
pass
Loading

0 comments on commit a28cfbb

Please sign in to comment.