Initial Commit

master
Hofei90 4 years ago
commit cabf9cb842

@ -0,0 +1,121 @@
import sys
from PyQt5 import QtWidgets, uic, QtGui
import toml
import os
import shutil
import subprocess
class EmpyrionLauncher(QtWidgets.QDialog):
def __init__(self, parent=None):
super().__init__(parent)
uidatei = os.path.join(PFAD, "empyrion_launcher.ui")
self.ui = uic.loadUi(uidatei, self)
self.text_status_pfade = None
self.status_pfade = False
self.spiel_aktiv = True
# Slots
# Buttons Tag Launcher
self.ui.button_beenden.clicked.connect(self.on_beenden)
# Buttons Tab Einstellungen
self.ui.button_ok.clicked.connect(self.on_ok)
self.ui.button_abbrechen.clicked.connect(self.on_abbrechen)
# Inlines ausfüllen
self.on_abbrechen()
self.cloud_lokal_verschieben()
def on_spiel_starten(self):
dateiname = os.path.join(CONFIG["pfad_cloud"], "aktiv_{}".format(CONFIG["username"]))
with open(dateiname, "w") as file:
file.write("")
subprocess.call(CONFIG["pfad_game"])
os.remove(dateiname)
def on_beenden(self):
self.close()
def on_ok(self):
CONFIG["username"] = self.ui.username.text()
CONFIG["pfad_lokal"] = self.ui.pfad_lokal.text()
CONFIG["pfad_cloud"] = self.ui.pfad_cloud.text()
CONFIG["pfad_game"] = self.ui.pfad_game.text()
CONFIG["savegame"] = self.ui.savegame.text()
ausgabe = {"config": CONFIG}
with open(DATEITOML, "w") as file:
file.write(toml.dumps(ausgabe))
self.check_pfad()
"{} - gespeichert".format(self.text_status_pfade)
self.label_status_pfade.setText("{} - gespeichert".format(self.text_status_pfade))
def on_abbrechen(self):
self.ui.username.setText(CONFIG["username"])
self.ui.pfad_lokal.setText(CONFIG["pfad_lokal"])
self.ui.pfad_cloud.setText(CONFIG["pfad_cloud"])
self.ui.pfad_game.setText(CONFIG["pfad_game"])
self.ui.savegame.setText(CONFIG["savegame"])
self.label_status_pfade.setText(self.text_status_pfade)
def cloud_lokal_verschieben(self):
self.check_pfad()
if self.status_pfade:
ordnerinhalt = os.listdir(CONFIG["pfad_cloud"])
self.spiel_aktiv = True
for ordner in ordnerinhalt:
if ordner.startswith(CONFIG["savegame"]):
self.spiel_aktiv = False
quelle = os.path.join(CONFIG["pfad_cloud"], ordner)
shutil.move(quelle, CONFIG["pfad_lokal"])
if self.spiel_aktiv:
user = "unbekannt"
for datei in ordnerinhalt:
if datei.startswith("aktiv"):
user = datei.split("_")[1]
self.label_spiel_aktiv.setText("Spiel schon aktiv von {}".format(user))
else:
self.label_spiel_aktiv.setText("Kein Spiel aktiv")
self.ui.button_spiel_starten.clicked.connect(self.on_spiel_starten)
def lokal_cloud_verschieben(self):
self.check_pfad()
if self.status_pfade:
ordnerinhalt = os.listdir(CONFIG["pfad_lokal"])
for ordner in ordnerinhalt:
if ordner.startswith(CONFIG["savegame"]):
quelle = os.path.join(CONFIG["pfad_lokal"], ordner)
shutil.move(quelle, CONFIG["pfad_cloud"])
def check_pfad(self):
self.status_pfade = False
pfad_lokal = os.path.isdir(CONFIG["pfad_lokal"])
pfad_cloud = os.path.isdir(CONFIG["pfad_cloud"])
pfad_game = os.path.isfile(CONFIG["pfad_game"])
textausgabe = ""
if not pfad_lokal:
textausgabe = "{}Pfad Lokal, ".format(textausgabe)
if not pfad_cloud:
textausgabe = "{}Pfad Cloud, ".format(textausgabe)
if not pfad_game:
textausgabe = "{}Pfad Game, ".format(textausgabe)
if not pfad_lokal or not pfad_cloud or not pfad_game:
textausgabe = "{} existiert nicht".format(textausgabe)
else:
textausgabe = "Alle Pfade ok!"
self.status_pfade = True
self.text_status_pfade = textausgabe
self.ui.label_status_pfade.setText(self.text_status_pfade)
def closeEvent(self, a0: QtGui.QCloseEvent):
self.lokal_cloud_verschieben()
PFAD = os.path.abspath(os.path.dirname(__file__))
DATEITOML = os.path.join(PFAD, "config.toml")
with open(DATEITOML) as file:
CONFIG = toml.loads(file.read())["config"]
app = QtWidgets.QApplication(sys.argv)
dialog = EmpyrionLauncher()
dialog.setWindowTitle("Empyrion Launcher")
dialog.show()
sys.exit(app.exec_())

@ -0,0 +1,207 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>386</width>
<height>318</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_launcher">
<attribute name="title">
<string>Launcher</string>
</attribute>
<widget class="QFrame" name="frame_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>271</width>
<height>181</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label_spiel_aktiv">
<property name="text">
<string>spiel_aktiv</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_status_start">
<property name="text">
<string>status start</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_spiel_starten">
<property name="text">
<string>Spiel starten!</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="button_beenden">
<property name="text">
<string>Beenden</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<widget class="QWidget" name="tab_einstellungen">
<attribute name="title">
<string>Einstellungen</string>
</attribute>
<widget class="QFrame" name="frame">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>361</width>
<height>201</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="1" column="1">
<widget class="QLineEdit" name="username"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Pfad Lokal</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="pfad_lokal"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Pfad Cloud</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="pfad_cloud"/>
</item>
<item row="6" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_status_pfade">
<property name="text">
<string>Status Pfade</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_ok">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_abbrechen">
<property name="text">
<string>Abbrechen</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_username">
<property name="text">
<string>Username</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Pfad+EXE Game</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="pfad_game"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Savegame</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="savegame"/>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Loading…
Cancel
Save