launcher.py: Add feature detection, useful when new features get added

This commit is contained in:
leha-code 2022-03-09 21:17:29 -04:00
parent ce8d345142
commit c01fcee606
No known key found for this signature in database
GPG Key ID: 15227A6455DDF7EE
5 changed files with 33 additions and 211 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.

View File

@ -1,73 +1,33 @@
import subprocess
import os
FEATURES = [
"Touch GUI",
"Fix Bow & Arrow",
"Fix Attacking",
"Force Mob Spawning",
"Fancy Graphics",
"Disable Autojump By Default",
"Display Nametags By Default",
"Fix Sign Placement",
"Show Block Outlines",
"Expand Creative Inventory",
"Remove Creative Mode Restrictions",
"Peaceful Mode",
"Animated Water",
"Remove Invalid Item Background",
'Disable "gui_blocks" Atlas',
"Smooth Lighting",
"3D Anaglyph",
"Fix Camera Rendering",
"Implement Chat",
"Hide Chat Messages",
"Implement Death Messages",
"Implement Game-Mode Switching",
"Allow Joining Survival Servers",
"Miscellaneous Input Fixes",
'Bind "Q" Key To Item Dropping',
"Bind Common Toggleable Options To Function Keys",
"Render Selected Item Text",
"External Server Support",
"Load Language Files",
"Implement Sound Engine",
"Close Current Screen On Death",
]
DEFAULT_FEATURES = {
"Touch GUI": True,
"Fix Bow & Arrow": True,
"Fix Attacking": True,
"Force Mob Spawning": False,
"Fancy Graphics": True,
"Disable Autojump By Default": True,
"Display Nametags By Default": True,
"Fix Sign Placement": True,
"Show Block Outlines": True,
"Expand Creative Inventory": True,
"Remove Creative Mode Restrictions": True,
"Peaceful Mode": False,
"Animated Water": True,
"Remove Invalid Item Background": True,
'Disable "gui_blocks" Atlas': True,
"Smooth Lighting": True,
"3D Anaglyph": False,
"Fix Camera Rendering": True,
"Implement Chat": True,
"Hide Chat Messages": False,
"Implement Death Messages": True,
"Implement Game-Mode Switching": True,
"Allow Joining Survival Servers": True,
"Miscellaneous Input Fixes": True,
'Bind "Q" Key To Item Dropping': True,
"Bind Common Toggleable Options To Function Keys": True,
"Render Selected Item Text": True,
"External Server Support": True,
"Load Language Files": True,
"Implement Sound Engine": True,
"Close Current Screen On Death": True,
}
def get_features_list() -> list:
features = subprocess.run(["minecraft-pi-reborn-client", '--print-available-feature-flags'], stdout=subprocess.PIPE).stdout.decode('utf-8')
features = features.split("\n")
returnlist = list()
for feature in features:
if feature.startswith("TRUE"):
feature = feature[5:]
if feature.startswith("FALSE"):
feature = feature[6:]
returnlist.append(feature)
return returnlist
def get_features_dict() -> dict:
features = subprocess.run(["minecraft-pi-reborn-client", '--print-available-feature-flags'], stdout=subprocess.PIPE).stdout.decode('utf-8')
features = features.split("\n")
returndict = dict()
for feature in features:
if feature.startswith("TRUE"):
feature = feature[5:]
returndict[feature] = True
if feature.startswith("FALSE"):
feature = feature[6:]
returndict[feature] = False
return returndict
def set_username(env, username: str = "StevePi"):
@ -88,7 +48,7 @@ def set_hud(env, options: str = "fps,simple"):
return env
def set_options(env, options: dict = DEFAULT_FEATURES):
def set_options(env, options: dict):
output = str()
for option in options:
if options[option]:

View File

@ -44,11 +44,12 @@ USER = os.getenv("USER")
if not os.path.exists(f"/home/{USER}/.planet-launcher/mods"):
os.makedirs(f"/home/{USER}/.planet-launcher/mods")
if os.path.exists(f"/home/{USER}/.gmcpil.json"):
with open(f"/home/{USER}/.gmcpil.json") as f:
DEFAULT_FEATURES = json.loads(f.read())["features"]
else:
DEFAULT_FEATURES = launcher.DEFAULT_FEATURES
#if os.path.exists(f"/home/{USER}/.gmcpil.json"):
# with open(f"/home/{USER}/.gmcpil.json") as f:
# DEFAULT_FEATURES = json.loads(f.read())["features"]
#else:
#TODO: Add a tab with a button to import features from gMCPIL
DEFAULT_FEATURES = launcher.get_features_dict()
class Planet(QMainWindow):

View File

@ -1,139 +0,0 @@
DEFAULT_FEATURES = {
"Touch GUI": True,
"Fix Bow & Arrow": True,
"Fix Attacking": True,
"Force Mob Spawning": False,
"Fancy Graphics": True,
"Disable Autojump By Default": True,
"Display Nametags By Default": True,
"Fix Sign Placement": True,
"Show Block Outlines": True,
"Expand Creative Inventory": True,
"Remove Creative Mode Restrictions": True,
"Peaceful Mode": False,
"Animated Water": True,
"Remove Invalid Item Background": True,
'Disable "gui_blocks" Atlas': True,
"Smooth Lighting": True,
"3D Anaglyph": False,
"Fix Camera Rendering": True,
"Implement Chat": True,
"Hide Chat Messages": False,
"Implement Death Messages": True,
"Implement Game-Mode Switching": True,
"Allow Joining Survival Servers": True,
"Miscellaneous Input Fixes": True,
'Bind "Q" Key To Item Dropping': True,
"Bind Common Toggleable Options To Function Keys": True,
"Render Selected Item Text": True,
"External Server Support": True,
"Load Language Files": True,
"Implement Sound Engine": True,
"Close Current Screen On Death": True,
}
MINIMAL_FEATURES = {
"Touch GUI": True,
"Fix Bow & Arrow": True,
"Fix Attacking": True,
"Force Mob Spawning": False,
"Fancy Graphics": False,
"Disable Autojump By Default": True,
"Display Nametags By Default": True,
"Fix Sign Placement": True,
"Show Block Outlines": True,
"Expand Creative Inventory": True,
"Remove Creative Mode Restrictions": True,
"Peaceful Mode": False,
"Animated Water": False,
"Remove Invalid Item Background": True,
'Disable "gui_blocks" Atlas': False,
"Smooth Lighting": False,
"3D Anaglyph": False,
"Fix Camera Rendering": True,
"Implement Chat": True,
"Hide Chat Messages": False,
"Implement Death Messages": True,
"Implement Game-Mode Switching": True,
"Allow Joining Survival Servers": True,
"Miscellaneous Input Fixes": True,
'Bind "Q" Key To Item Dropping': True,
"Bind Common Toggleable Options To Function Keys": True,
"Render Selected Item Text": True,
"External Server Support": True,
"Load Language Files": True,
"Implement Sound Engine": True,
"Close Current Screen On Death": True,
}
MODDED_MCPE_FEATURES = DEFAULT_FEATURES
CLASSIC_MCPI = dict()
MODDED_MCPI = {
"Touch GUI": False,
"Fix Bow & Arrow": True,
"Fix Attacking": True,
"Force Mob Spawning": False,
"Fancy Graphics": True,
"Disable Autojump By Default": True,
"Display Nametags By Default": True,
"Fix Sign Placement": True,
"Show Block Outlines": True,
"Expand Creative Inventory": True,
"Remove Creative Mode Restrictions": True,
"Peaceful Mode": False,
"Animated Water": True,
"Remove Invalid Item Background": True,
'Disable "gui_blocks" Atlas': True,
"Smooth Lighting": True,
"3D Anaglyph": False,
"Fix Camera Rendering": True,
"Implement Chat": True,
"Hide Chat Messages": False,
"Implement Death Messages": True,
"Implement Game-Mode Switching": True,
"Allow Joining Survival Servers": True,
"Miscellaneous Input Fixes": True,
'Bind "Q" Key To Item Dropping': True,
"Bind Common Toggleable Options To Function Keys": True,
"Render Selected Item Text": True,
"External Server Support": True,
"Load Language Files": True,
"Implement Sound Engine": True,
"Close Current Screen On Death": True,
}
PROFILE_3D = {
"Touch GUI": True,
"Fix Bow & Arrow": True,
"Fix Attacking": True,
"Force Mob Spawning": False,
"Fancy Graphics": True,
"Disable Autojump By Default": True,
"Display Nametags By Default": True,
"Fix Sign Placement": True,
"Show Block Outlines": True,
"Expand Creative Inventory": True,
"Remove Creative Mode Restrictions": True,
"Peaceful Mode": False,
"Animated Water": True,
"Remove Invalid Item Background": True,
'Disable "gui_blocks" Atlas': True,
"Smooth Lighting": True,
"3D Anaglyph": True,
"Fix Camera Rendering": True,
"Implement Chat": True,
"Hide Chat Messages": False,
"Implement Death Messages": True,
"Implement Game-Mode Switching": True,
"Allow Joining Survival Servers": True,
"Miscellaneous Input Fixes": True,
'Bind "Q" Key To Item Dropping': True,
"Bind Common Toggleable Options To Function Keys": True,
"Render Selected Item Text": True,
"External Server Support": True,
"Load Language Files": True,
"Implement Sound Engine": True,
"Close Current Screen On Death": True,
}