Skip to content

Commit aa1541d

Browse files
committed
feat: Add debug command to toggle debug options via controller
1 parent 7ec7678 commit aa1541d

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

BF2AutoSpectator/common/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ def get_resolution(self) -> str:
140140
def debug_screenshot(self) -> bool:
141141
return self.__debug_screenshot
142142

143+
def set_debug_screenshot(self, debug_screenshot: bool) -> None:
144+
self.__debug_screenshot = debug_screenshot
145+
143146
def get_min_iterations_on_player(self) -> int:
144147
return self.__min_iterations_on_player
145148

BF2AutoSpectator/spectate.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ def run():
8989
with open(os.path.join(config.ROOT_DIR, 'pickle', 'histograms.pickle'), 'rb') as histogramFile:
9090
histograms = pickle.load(histogramFile)
9191

92-
# Init debug directory if debugging is enabled
93-
if config.debug_screenshot():
92+
# Init debug directory if debugging is/could be enabled
93+
if config.debug_screenshot() or config.use_controller():
9494
# Create debug output dir if needed
9595
if not os.path.isdir(config.DEBUG_DIR):
9696
os.mkdir(Config.DEBUG_DIR)
@@ -230,6 +230,16 @@ def run():
230230
logger.info('Rejoin requested via controller, queuing disconnect')
231231
gis.set_spectator_on_server(False)
232232

233+
if cs.pop('debug'):
234+
if logger.level != logging.DEBUG or not config.debug_screenshot():
235+
logger.info('Debug toggle issued via controller, enabling debug options')
236+
logger.setLevel(logging.DEBUG)
237+
config.set_debug_screenshot(True)
238+
else:
239+
logger.info('Debug toggle issued via controller, disabling debug options')
240+
logger.setLevel(logging.INFO)
241+
config.set_debug_screenshot(False)
242+
233243
if config.control_obs():
234244
streaming = None
235245
try:

0 commit comments

Comments
 (0)