diff --git a/README.md b/README.md index 637a139..c3534c2 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,8 @@ In addition to the recording specific config file, Eddienput also loads some set * `default_recording`: A path to a recording file to load as the program starts. * `rec_start_end_sound`: Either set to `true` or `false`, sets whether to play a sound when a recording starts/ends playing. +* `hot_reload`: Either set to `true` to `false`, sets whether the recording file is to be +reloaded automatically upon play. * `side`: Set to either `P1` or `P2`, sets which player side to use as the program starts up. ## Known Issues: diff --git a/src/config.json b/src/config.json index b919924..e02c63d 100644 --- a/src/config.json +++ b/src/config.json @@ -1,5 +1,6 @@ { "default_recording": "recordings\\gg_test.txt", "rec_start_end_sound": "true", - "side": "P2" + "side": "P2", + "hot_reload": "true" } diff --git a/src/eddiecontroller.py b/src/eddiecontroller.py index 4ca50e2..90b3628 100644 --- a/src/eddiecontroller.py +++ b/src/eddiecontroller.py @@ -34,6 +34,7 @@ playing = False mute = False +hot_reload = True P1_directions_map = {} P2_directions_map = {} direction_maps = [P1_directions_map, P2_directions_map] @@ -125,7 +126,6 @@ def play_queue(): playing = False # for button, val, t in log_queue: # print("pressed:", button, val, t) - return # parse a string into a series of frame commands diff --git a/src/gui.py b/src/gui.py index 90be4e5..095a4e8 100644 --- a/src/gui.py +++ b/src/gui.py @@ -72,13 +72,14 @@ def load_config(): eddiecontroller.recordings_file = default_rec set_recording_file(default_rec) if 'side' in config: - side = config['side'].lower() - if side == 'p1': + if config['side'].lower() == 'p1': set_side(0) if 'rec_start_end_sound' in config: - sound = config['rec_start_end_sound'].lower() - if sound == 'false': + if config['rec_start_end_sound'].lower() == 'false': eddiecontroller.toggle_mute() + if 'hot_reload' in config: + if config['hot_reload'].lower() == 'false': + eddiecontroller.hot_reload = False except IOError as e: print('Failed to open config file:', e, file=writer) @@ -110,30 +111,40 @@ def on_press(key): return key_val = str(key) #print("received", key_val) + # Ignore all hotkeys but F4 while a recording is playing if key_val == "Key.f4": # F4 eddiecontroller.playing = False + return elif eddiecontroller.playing: return - if capture_activation_key: + # Handled here to not allow setting F9 as the playback button + if key_val == "Key.f9": # F9 + activation_key = None + capture_activation_key = True + print('Capturing playback button...', file=writer) + return + elif capture_activation_key: capture_activation_key = False activation_key = key_val print('Playback button set to', key_val, file=writer) w.playback_button_label.setText('Playback button: \n' + activation_key) - elif key_val == activation_key: - worker = Worker(eddiecontroller.run_scenario) - eddiecontroller.threadpool.start(worker) return if eddiecontroller.recordings_file: - if key_val == "Key.f5": # F5 - print("Reloading script", file=writer) - eddiecontroller.reset() + # Activation key takes precedence + if key_val == activation_key or key_val == "Key.f3": # F3 + if eddiecontroller.hot_reload: + print("Reloading script", file=writer) + eddiecontroller.reset() + worker = Worker(eddiecontroller.run_scenario) + eddiecontroller.threadpool.start(worker) + return if key_val == "Key.f1": # F1 set_side(0) if key_val == "Key.f2": # F2 set_side(1) - if key_val == "Key.f3": # F3 - worker = Worker(eddiecontroller.run_scenario) - eddiecontroller.threadpool.start(worker) + if key_val == "Key.f5": # F5 + print("Reloading script", file=writer) + eddiecontroller.reset() if key_val == "Key.f6": # F6 set_repetitions(max(1, eddiecontroller.repetitions - 1)) if key_val == "Key.f7": # F7 @@ -145,10 +156,6 @@ def on_press(key): if key_val == "Key.f8": # F8 eddiecontroller.toggle_mute() w.mute_label.setText('Start/End Sequence Sound: ' + on_off_map[eddiecontroller.mute]) - if key_val == "Key.f9": # F9 - activation_key = None - capture_activation_key = True - print('Capturing playback button...', file=writer) if key_val == "Key.insert": # insert global manual_mode if not manual_mode: @@ -287,7 +294,7 @@ def __init__(self): self.toggle_image_signal.connect(self.toggleImage) self.setMinimumWidth(1050) self.setAcceptDrops(True) - self.setWindowTitle('Eddienput v1.1') + self.setWindowTitle('Eddienput v1.2') self.setWindowIcon(QtGui.QIcon('icon.ico')) self.setStyleSheet("QWidget { background-color : rgb(54, 57, 63); color : rgb(220, 221, 222); }") v_layout = QVBoxLayout()