Add servers back, but this time fix a bug

This commit is contained in:
leha-code 2022-03-13 20:36:24 -04:00
parent 43ab63e69a
commit ef8539a25c
No known key found for this signature in database
GPG Key ID: 15227A6455DDF7EE
1 changed files with 24 additions and 0 deletions

View File

@ -158,6 +158,8 @@ class Planet(QMainWindow):
tabs.setTabIcon(play_tab, QIcon("assets/logo512.png"))
features_tab = tabs.addTab(self.features_tab(), "Features")
tabs.setTabIcon(features_tab, QIcon("assets/heart512.png"))
servers_tab = tabs.addTab(self.servers_tab(), "Servers")
tabs.setTabIcon(servers_tab, QIcon("assets/multiplayer512.png"))
mods_tab = tabs.addTab(self.custom_mods_tab(), "Mods")
tabs.setTabIcon(mods_tab, QIcon("assets/portal512.png"))
changelog_tab = tabs.addTab(self.changelog_tab(), "Changelog")
@ -304,6 +306,24 @@ class Planet(QMainWindow):
widget.setLayout(fakelayout)
return widget
def servers_tab(self) -> QWidget:
widget = QWidget()
layout = QGridLayout()
self.serversedit = QTextEdit()
self.serversedit.textChanged.connect(self.save_servers)
with open(f"/home/{USER}/.minecraft-pi/servers.txt") as servers:
self.serversedit.setPlainText(servers.read())
infolabel = QLabel("Servers are stored in the format of <font color=\"gold\">IP: </font><font color=\"blue\">Port</font>")
layout.addWidget(self.serversedit, 0, 0)
layout.addWidget(infolabel, 6, 0)
widget.setLayout(layout)
return widget
def custom_mods_tab(self) -> QWidget:
layout = QVBoxLayout()
@ -358,6 +378,10 @@ class Planet(QMainWindow):
with open(f"/home/{USER}/.planet-launcher/config.json", "w") as file:
file.write(json.dumps(self.conf))
def save_servers(self):
with open(f"/home/{USER}/.minecraft-pi/servers.txt", "w") as file:
file.write(self.serversedit.toPlainText())
def launch(self):
self.save_profile()