mirror of
https://github.com/nixietab/picodulce.git
synced 2025-04-10 10:28:56 +01:00
fixed bugs
This commit is contained in:
parent
bb957f07e3
commit
4c608d6ab0
34
picodulce.py
34
picodulce.py
@ -116,7 +116,8 @@ class PicomcVersionSelector(QWidget):
|
|||||||
config_path = "config.json"
|
config_path = "config.json"
|
||||||
default_config = {
|
default_config = {
|
||||||
"IsRCPenabled": False,
|
"IsRCPenabled": False,
|
||||||
"CheckUpdate": False
|
"CheckUpdate": False,
|
||||||
|
"LastPlayed": ""
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if config file exists
|
# Check if config file exists
|
||||||
@ -187,6 +188,16 @@ class PicomcVersionSelector(QWidget):
|
|||||||
|
|
||||||
|
|
||||||
def populate_installed_versions(self):
|
def populate_installed_versions(self):
|
||||||
|
config_path = "config.json"
|
||||||
|
# Check if config file exists
|
||||||
|
if not os.path.exists(config_path):
|
||||||
|
logging.error("Config file not found.")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Load config from file
|
||||||
|
with open(config_path, "r") as config_file:
|
||||||
|
self.config = json.load(config_file)
|
||||||
|
|
||||||
# Run the command and get the output
|
# Run the command and get the output
|
||||||
try:
|
try:
|
||||||
process = subprocess.Popen(['picomc', 'version', 'list'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
process = subprocess.Popen(['picomc', 'version', 'list'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||||
@ -204,10 +215,19 @@ class PicomcVersionSelector(QWidget):
|
|||||||
versions = output.splitlines()
|
versions = output.splitlines()
|
||||||
versions = [version.replace('[local]', ' ').strip() for version in versions]
|
versions = [version.replace('[local]', ' ').strip() for version in versions]
|
||||||
|
|
||||||
|
# Get last played version from config
|
||||||
|
last_played = self.config.get("LastPlayed", "")
|
||||||
|
|
||||||
|
# If lastplayed is not empty and is in the versions list, move it to the top
|
||||||
|
if last_played and last_played in versions:
|
||||||
|
versions.remove(last_played)
|
||||||
|
versions.insert(0, last_played)
|
||||||
|
|
||||||
# Populate installed versions combo box
|
# Populate installed versions combo box
|
||||||
self.installed_version_combo.clear()
|
self.installed_version_combo.clear()
|
||||||
self.installed_version_combo.addItems(versions)
|
self.installed_version_combo.addItems(versions)
|
||||||
|
|
||||||
|
|
||||||
def open_marroc_script(self):
|
def open_marroc_script(self):
|
||||||
try:
|
try:
|
||||||
# Replace 'path_to_marroc.py' with the actual path to marroc.py
|
# Replace 'path_to_marroc.py' with the actual path to marroc.py
|
||||||
@ -232,11 +252,21 @@ class PicomcVersionSelector(QWidget):
|
|||||||
def run_game(self, selected_instance):
|
def run_game(self, selected_instance):
|
||||||
try:
|
try:
|
||||||
subprocess.run(['picomc', 'play', selected_instance], check=True)
|
subprocess.run(['picomc', 'play', selected_instance], check=True)
|
||||||
|
# Update lastplayed field in config.json
|
||||||
|
self.update_last_played(selected_instance)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
error_message = f"Error playing {selected_instance}: {e.stderr.decode()}"
|
error_message = f"Error playing {selected_instance}: {e.stderr.decode()}"
|
||||||
logging.error(error_message)
|
logging.error(error_message)
|
||||||
QMessageBox.critical(self, "Error", error_message)
|
QMessageBox.critical(self, "Error", error_message)
|
||||||
|
|
||||||
|
def update_last_played(self, selected_instance):
|
||||||
|
config_path = "config.json"
|
||||||
|
self.config["LastPlayed"] = selected_instance
|
||||||
|
with open(config_path, "w") as config_file:
|
||||||
|
json.dump(self.config, config_file, indent=4)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def open_version_menu(self):
|
def open_version_menu(self):
|
||||||
dialog = QDialog(self)
|
dialog = QDialog(self)
|
||||||
dialog.setWindowTitle('Download Version')
|
dialog.setWindowTitle('Download Version')
|
||||||
@ -687,7 +717,7 @@ class PicomcVersionSelector(QWidget):
|
|||||||
|
|
||||||
presence.update(
|
presence.update(
|
||||||
state="In the menu",
|
state="In the menu",
|
||||||
details="",
|
details="best launcher to exist",
|
||||||
large_image="launcher_icon", # Replace with your image key for the launcher image
|
large_image="launcher_icon", # Replace with your image key for the launcher image
|
||||||
large_text="PicoDulce Launcher", # Replace with the text for the launcher image
|
large_text="PicoDulce Launcher", # Replace with the text for the launcher image
|
||||||
start=time.time()
|
start=time.time()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "0.5",
|
"version": "0.6",
|
||||||
"links": [
|
"links": [
|
||||||
"https://raw.githubusercontent.com/nixietab/picodulce/main/version.json",
|
"https://raw.githubusercontent.com/nixietab/picodulce/main/version.json",
|
||||||
"https://raw.githubusercontent.com/nixietab/picodulce/main/picodulce.py",
|
"https://raw.githubusercontent.com/nixietab/picodulce/main/picodulce.py",
|
||||||
|
Loading…
Reference in New Issue
Block a user