Skip to content

Commit

Permalink
Setup function UI and allow intensity based muscle groups, along with…
Browse files Browse the repository at this point in the history
… some other featuresuy
  • Loading branch information
shadorki committed Sep 25, 2023
1 parent 738bf3a commit db099dc
Show file tree
Hide file tree
Showing 9 changed files with 481 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
pip install -r requirements.txt
- name: Build with pyinstaller
run: pyinstaller --hidden-import=clr --add-binary "./owo/OWO.dll;owo" --onefile --distpath ./build --name=vrc-owo-suit main.py
run: pyinstaller --hidden-import=clr --add-data "./img/logo.png;img" --add-binary "./owo/OWO.dll;owo" --onefile --distpath ./build --name=vrc-owo-suit main.py

- name: Deploy EXE
uses: actions/upload-artifact@v3
Expand Down
87 changes: 57 additions & 30 deletions config.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,63 @@
import json
import params
import os
import json


class Config:
def __init__(self, server_port: int, owo_ip: str, intensity: int, frequency: int):
self.server_port = server_port
self.owo_ip = owo_ip
self.intensity = intensity
self.frequency = frequency
def __init__(self):
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)
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 get() -> Config:
server_port = 9001
owo_ip = ""
intensity = 10
frequency = 100
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']}.")
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']}.")
owo_ip = data['owo_ip']
if ("intensity" in data and type(data['intensity']) is int):
print(f"Using intensity {data['intensity']}.")
intensity = data['intensity']
if ("frequency" in data and type(data['frequency']) is int):
print(f"Using frequency {data['frequency']}.")
frequency = data['frequency']
except:
print("Config file not found, using default settings")
finally:
return Config(server_port, owo_ip, intensity, frequency)
def init(self):
self.current_config = self.read_config_from_disk()
19 changes: 19 additions & 0 deletions event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import atexit
from concurrent.futures import ThreadPoolExecutor


class Event:
def __init__(self, max_workers=3):
self.listeners = []
self.executor = ThreadPoolExecutor(max_workers=max_workers)
atexit.register(self.executor.shutdown)

def add_listener(self, func):
self.listeners.append(func)

def remove_listener(self, func):
self.listeners.remove(func)

def dispatch(self, *args, **kwargs):
for listener in self.listeners:
self.executor.submit(listener, *args, **kwargs)
Loading

0 comments on commit db099dc

Please sign in to comment.