pmcl/pmcl.py

145 lines
6.5 KiB
Python
Raw Normal View History

2024-01-17 13:42:40 +08:00
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'pmcl_main.ui'
#
# Created by: PyQt5 UI code generator 5.15.9
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
import os
2024-01-18 08:11:23 +08:00
import shelve
import sys
from PyQt5 import QtCore, QtWidgets
from PyQt5.QtWidgets import QMessageBox
2024-01-17 13:42:40 +08:00
class Ui_MainWindow(QtWidgets.QMainWindow):
def __init__(self):
2024-01-18 08:11:23 +08:00
super(Ui_MainWindow, self).__init__()
2024-01-17 13:42:40 +08:00
self.setupUi(self)
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(475, 226)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout.setObjectName("gridLayout")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
self.label_4.setObjectName("label_4")
self.horizontalLayout_3.addWidget(self.label_4)
self.maxmb_t = QtWidgets.QLineEdit(self.centralwidget)
self.maxmb_t.setObjectName("maxmb_t")
self.horizontalLayout_3.addWidget(self.maxmb_t)
self.gridLayout.addLayout(self.horizontalLayout_3, 2, 1, 1, 1)
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
self.pushButton.setObjectName("pushButton")
self.gridLayout.addWidget(self.pushButton, 4, 4, 1, 1)
self.label = QtWidgets.QLabel(self.centralwidget)
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 1, 1, 4)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
self.label_3.setObjectName("label_3")
self.horizontalLayout_2.addWidget(self.label_3)
self.username = QtWidgets.QLineEdit(self.centralwidget)
self.username.setObjectName("username")
self.horizontalLayout_2.addWidget(self.username)
self.gridLayout.addLayout(self.horizontalLayout_2, 2, 2, 1, 3)
spacerItem = QtWidgets.QSpacerItem(454, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem, 1, 1, 1, 4)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
self.label_2.setObjectName("label_2")
self.horizontalLayout.addWidget(self.label_2)
self.game_c = QtWidgets.QComboBox(self.centralwidget)
self.game_c.setObjectName("game_c")
self.game_c.addItem("")
self.game_c.addItem("")
self.horizontalLayout.addWidget(self.game_c)
self.gridLayout.addLayout(self.horizontalLayout, 3, 1, 1, 2)
self.run_game = QtWidgets.QPushButton(self.centralwidget)
self.run_game.setObjectName("run_game")
self.gridLayout.addWidget(self.run_game, 4, 3, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.label_3.setBuddy(self.username)
self.label_2.setBuddy(self.game_c)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
# def
2024-01-18 08:11:23 +08:00
2024-01-17 13:42:40 +08:00
def run(self):
maxmb = self.maxmb_t.text()
username_text = self.username.text()
2024-01-18 08:11:23 +08:00
version = self.game_c.currentText()
2024-01-17 13:42:40 +08:00
with open("username.txt", "w") as file:
file.write(username_text)
pass
with open('maxmb.txt', 'w') as maxmb_f:
maxmb_f.write(maxmb)
2024-01-18 08:11:23 +08:00
with open('version.txt', 'w') as version_f:
version_f.write(version)
print(maxmb, username_text, version)
2024-01-17 13:42:40 +08:00
if version == '1.8.9 Forge':
2024-01-18 08:11:23 +08:00
version = 'vapeV4.04'
with open('version.txt', 'w') as version_f:
version_f.write(version)
try:
with shelve.open('main') as db:
db['startgame'] = True
db.close()
os.startfile('start_game.bat')
except:
QMessageBox.critical(self, 'ERROR', '无法启动游戏,请尝试重新安装。')
2024-01-17 13:42:40 +08:00
else:
QMessageBox.critical(self, 'ERROR', '暂未做完......', QMessageBox.Close)
2024-01-18 08:11:23 +08:00
2024-01-17 13:42:40 +08:00
def kg(self):
2024-01-18 08:11:23 +08:00
# run
2024-01-17 13:42:40 +08:00
QMessageBox.information(self, 'warning', '启动后请不要关闭server.exe这个程序!!!!', QMessageBox.Ok)
2024-01-18 08:11:23 +08:00
QMessageBox.warning(self, '注意!', '可能有病毒,请小心使用!!')
2024-01-17 13:42:40 +08:00
try:
os.startfile('kg.exe')
except:
2024-01-18 08:11:23 +08:00
QMessageBox.critical(self, 'ERROR', '无法启动,请尝试重新安装!', QMessageBox.Ok)
2024-01-17 13:42:40 +08:00
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
2024-01-18 08:11:23 +08:00
MainWindow.setWindowTitle(_translate("MainWindow", "Pmcl 1.0.1"))
2024-01-17 13:42:40 +08:00
self.label_4.setText(_translate("MainWindow", "最大内存:"))
self.maxmb_t.setText(_translate("MainWindow", "1145"))
self.pushButton.setText(_translate("MainWindow", "开vape"))
2024-01-18 08:11:23 +08:00
self.label.setText(_translate("MainWindow",
"<html><head/><body><p><span style=\" font-size:18pt; font-weight:600; color:#1c33fe;\">Python minecraft launcher V1.0.1</span></p></body></html>"))
2024-01-17 13:42:40 +08:00
self.label_3.setText(_translate("MainWindow", "游戏姓名:"))
self.username.setText(_translate("MainWindow", "sb001"))
2024-01-18 08:11:23 +08:00
self.label_2.setText(_translate("MainWindow",
"<html><head/><body><p><span style=\" font-size:11pt;\">游戏版本:</span></p></body></html>"))
2024-01-17 13:42:40 +08:00
self.game_c.setItemText(0, _translate("MainWindow", "1.8.9 Forge"))
self.game_c.setItemText(1, _translate("MainWindow", "1.12.2 Forge"))
self.run_game.setText(_translate("MainWindow", "开始游戏"))
self.pushButton.clicked.connect(self.kg)
self.run_game.clicked.connect(self.run)
2024-01-18 08:11:23 +08:00
2024-01-17 13:42:40 +08:00
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
mainloop = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(mainloop)
mainloop.show()
2024-01-18 08:11:23 +08:00
sys.exit(app.exec_())