mirror of
https://scm.osdn.net/gitroot/planet/planet-launcher.git
synced 2024-08-15 03:28:13 +00:00
Basic launcher
This commit is contained in:
parent
711aefe243
commit
49b842941f
3 changed files with 37 additions and 11 deletions
|
@ -1,3 +1,4 @@
|
|||
import subprocess
|
||||
import os
|
||||
|
||||
FEATURES = [
|
||||
|
@ -69,20 +70,20 @@ DEFAULT_FEATURES = {
|
|||
}
|
||||
|
||||
|
||||
def set_username(env, username: str):
|
||||
def set_username(env, username: str = "StevePi"):
|
||||
env["MCPI_USERNAME"] = username
|
||||
return env
|
||||
|
||||
|
||||
def set_render_distance(env, distance: str):
|
||||
def set_render_distance(env, distance: str = "SHORT"):
|
||||
if distance.upper() not in ["TINY", "SHORT", "NORMAL", "FAR"]:
|
||||
raise Exception("Invalid render distance")
|
||||
else:
|
||||
env["MCPI_RENDER_DISTANCE"] = distance.upper()
|
||||
env["MCPI_RENDER_DISTANCE"] = distance
|
||||
return env
|
||||
|
||||
|
||||
def set_hud(env, options: str):
|
||||
def set_hud(env, options: str = "fps,simple"):
|
||||
env["GALLIUM_HUD"] = options
|
||||
return env
|
||||
|
||||
|
@ -90,7 +91,11 @@ def set_hud(env, options: str):
|
|||
def set_options(env, options: dict = DEFAULT_FEATURES):
|
||||
output = str()
|
||||
for option in options:
|
||||
output += f"{str(options[option]).upper()} {option}\n"
|
||||
if options[option]:
|
||||
output += f"{option}|"
|
||||
|
||||
env["MCPI_FEATURE_FLAGS"] = output
|
||||
return env
|
||||
|
||||
def run(env):
|
||||
return subprocess.Popen(['/usr/bin/minecraft-pi-reborn-client'], env=env, preexec_fn=os.setsid)
|
||||
|
|
|
@ -28,6 +28,7 @@ import os
|
|||
import random
|
||||
from datetime import date
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
|
||||
from PyQt5.QtCore import *
|
||||
|
@ -47,6 +48,10 @@ else:
|
|||
|
||||
|
||||
class Planet(QMainWindow):
|
||||
|
||||
launchfeatures = dict()
|
||||
env = os.environ.copy()
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
|
@ -112,6 +117,9 @@ class Planet(QMainWindow):
|
|||
|
||||
self.playbutton = QPushButton("Play")
|
||||
|
||||
self.playbutton.setCheckable(True)
|
||||
self.playbutton.clicked.connect(self.launch)
|
||||
|
||||
layout.addWidget(namelabel, 0, 0, 2, 6)
|
||||
layout.addWidget(splashlabel, 2, 0, 1, 6)
|
||||
|
||||
|
@ -147,6 +155,8 @@ class Planet(QMainWindow):
|
|||
else:
|
||||
checkbox.setCheckState(Qt.Unchecked)
|
||||
|
||||
checkbox.clicked.connect(self.set_features)
|
||||
|
||||
self.features[feature] = checkbox
|
||||
|
||||
layout.addWidget(checkbox)
|
||||
|
@ -198,9 +208,21 @@ class Planet(QMainWindow):
|
|||
|
||||
return widget
|
||||
|
||||
def set_features(self):
|
||||
for feature in self.features:
|
||||
if self.features[feature].isChecked():
|
||||
self.launchfeatures[feature] = True
|
||||
else:
|
||||
self.launchfeatures[feature] = False
|
||||
|
||||
def launch(self):
|
||||
pass
|
||||
self.env = launcher.set_username(self.env, self.usernameedit.text())
|
||||
self.env = launcher.set_options(self.env, self.launchfeatures)
|
||||
self.env = launcher.set_render_distance(self.env, self.distancebox.currentText())
|
||||
|
||||
print(self.env)
|
||||
|
||||
launcher.run(self.env)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -10,5 +10,4 @@ SPLASHES = [
|
|||
"Snowball",
|
||||
"Robo",
|
||||
"If I could, I would. But I can't, so I shan't.",
|
||||
"I make a launcher! I break the launcher! Everyone hates it! Everyone hates it?",
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue