-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
221 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,64 @@ | ||
import json | ||
import params | ||
import os | ||
import json | ||
|
||
|
||
class Config: | ||
def __init__(self): | ||
self.server_port = 9001 | ||
self.owo_ip = "" | ||
self.intensity = 10 | ||
self.frequency = 100 | ||
|
||
self.APP_NAME = 'VRChatOWOSuit' | ||
self.default_config = { | ||
"server_port": 9001, | ||
"owo_ip": "", | ||
"should_detect_ip": True, | ||
"should_connect_on_startup": False, | ||
"frequency": 100, | ||
"intensities": { | ||
params.owo_suit_Pectoral_L: 60, | ||
params.owo_suit_Pectoral_R: 60, | ||
params.owo_suit_Abdominal_L: 60, | ||
params.owo_suit_Abdominal_R: 60, | ||
params.owo_suit_Arm_L: 60, | ||
params.owo_suit_Arm_R: 60, | ||
params.owo_suit_Dorsal_L: 60, | ||
params.owo_suit_Dorsal_R: 60, | ||
params.owo_suit_Lumbar_L: 60, | ||
params.owo_suit_Lumbar_R: 60, | ||
} | ||
} | ||
self.current_config = None | ||
|
||
def get_by_key(self, key: str): | ||
return self.current_config.get(key) | ||
|
||
def update(self, key: str, nextValue): | ||
if (key in self.current_config): | ||
self.current_config[key] = nextValue | ||
|
||
def read_config_from_disk(self): | ||
appdata_path = os.environ.get('LOCALAPPDATA') | ||
app_directory = os.path.join(appdata_path, self.APP_NAME) | ||
print(app_directory) | ||
os.makedirs(app_directory, exist_ok=True) | ||
config_path = os.path.join(app_directory, 'config.json') | ||
if os.path.exists(config_path): | ||
with open(config_path, 'r') as file: | ||
data = json.load(file) | ||
return data | ||
else: | ||
with open(config_path, 'w') as file: | ||
json.dump(self.default_config, file, indent=4) | ||
return self.default_config | ||
|
||
def write_config_to_disk(self): | ||
if self.current_config == None: | ||
return | ||
appdata_path = os.environ.get('LOCALAPPDATA') | ||
app_directory = os.path.join(appdata_path, self.APP_NAME) | ||
os.makedirs(app_directory, exist_ok=True) | ||
config_path = os.path.join(app_directory, 'config.json') | ||
with open(config_path, 'w') as file: | ||
json.dump(self.current_config, file, indent=4) | ||
|
||
def init(self): | ||
try: | ||
f = open('./vrc-owo-suit.config.json') | ||
data = json.load(f) | ||
f.close() | ||
if ("server_port" in data and type(data['server_port']) is int): | ||
print(f"Using server_port {data['server_port']}.") | ||
self.server_port = data['server_port'] | ||
if ("owo_ip" in data and type(data['owo_ip']) is str): | ||
print(f"Using owo_ip {data['owo_ip']}.") | ||
self.owo_ip = data['owo_ip'] | ||
if ("intensity" in data and type(data['intensity']) is int): | ||
print(f"Using intensity {data['intensity']}.") | ||
self.intensity = data['intensity'] | ||
if ("frequency" in data and type(data['frequency']) is int): | ||
print(f"Using frequency {data['frequency']}.") | ||
self.frequency = data['frequency'] | ||
except: | ||
print("Config file not found, using default settings") | ||
self.current_config = self.read_config_from_disk() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.