Added a BlueStacks instance selector in the GUI with Refresh, persist…#616
Added a BlueStacks instance selector in the GUI with Refresh, persist…#616AlanDCE wants to merge 9 commits intopyclashbot:masterfrom
Conversation
…ing your choice. Implemented list_bluestacks_instances() to fetch instances without launching anything, and threaded instance_name through to the controller. Bot now starts on the chosen instance and proceeds with ADB + Clash Royale. Thanks to Macadan (Discord) for testing help.
There was a problem hiding this comment.
Pull request overview
This pull request adds a BlueStacks instance selector to the GUI, allowing users to choose which BlueStacks instance the bot should run on. The selected instance is persisted across sessions and the list of available instances can be refreshed via a button in the UI.
Key changes:
- Added a new
list_bluestacks_instances()function that reads BlueStacks configuration files to enumerate available instances without launching anything - Enhanced the BlueStacks controller to accept and use a user-specified instance name, with fallback logic to select the first available instance if the requested one isn't found
- Created GUI components (combobox and refresh button) for instance selection in the emulator settings tab
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pyclashbot/interface/ui.py | Added BlueStacks instance selector UI components, callback registration, and value persistence logic |
| pyclashbot/interface/enums.py | Added BLUESTACKS_INSTANCE enum field for configuration storage |
| pyclashbot/emulators/bluestacks.py | Implemented list_bluestacks_instances() function, added instance_name parameter to constructor, added _ensure_target_instance() method with fallback logic, and updated instance detection logic |
| pyclashbot/bot/worker.py | Threaded instance_name from configuration to BlueStacks controller constructor |
| pyclashbot/main.py | Added callback implementations for getting and refreshing BlueStacks instances list, integrated with UI components |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| self.logger.change_status(f"Error refreshing BlueStacks instances: {e}") | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Extra blank lines. There should only be one blank line between method definitions and two blank lines before top-level function definitions according to PEP 8 style guidelines.
| @@ -1,4 +1,3 @@ | |||
| import csv | |||
| import io | |||
There was a problem hiding this comment.
The csv module import was removed from the imports section but is still being used at line 684 with csv.reader(). This will cause a NameError at runtime when the _is_this_instance_running() method is called on Windows. The csv import must be added back to the imports at the top of the file.
| if elapsed > soft_wait: | ||
| self.logger.log("[BlueStacks 5] Proceeding without window title match; assuming launched.") | ||
| break | ||
| if elapsed > boot_timeout: | ||
| self.logger.change_status("Timeout waiting for pyclashbot instance to start - retrying...") | ||
| return False |
There was a problem hiding this comment.
The soft_wait check will always break the loop after 15 seconds, making the boot_timeout check at line 768 unreachable. The condition order should be reversed so that boot_timeout is checked first to ensure proper timeout behavior. The logic should fail after boot_timeout but proceed optimistically after soft_wait if the instance hasn't been detected yet.
| if elapsed > soft_wait: | |
| self.logger.log("[BlueStacks 5] Proceeding without window title match; assuming launched.") | |
| break | |
| if elapsed > boot_timeout: | |
| self.logger.change_status("Timeout waiting for pyclashbot instance to start - retrying...") | |
| return False | |
| if elapsed > boot_timeout: | |
| self.logger.change_status("Timeout waiting for pyclashbot instance to start - retrying...") | |
| return False | |
| if elapsed > soft_wait: | |
| self.logger.log("[BlueStacks 5] Proceeding without window title match; assuming launched.") | |
| break |
| # Fallback: if any BlueStacks player is running, assume ours to avoid hanging | ||
| if any_player: |
There was a problem hiding this comment.
The fallback logic that returns True if any BlueStacks player is running will incorrectly report that the specific instance is running even when it is not. This defeats the purpose of instance-specific checking and could cause the bot to attempt to connect to the wrong instance. Consider removing this fallback or making it conditional on whether a specific instance name was requested.
| # Fallback: if any BlueStacks player is running, assume ours to avoid hanging | |
| if any_player: | |
| # Fallback: if any BlueStacks player is running, assume ours only when no specific title is requested | |
| if any_player and not title: |
|
|
||
| The callback should return a list of available instance names. | ||
| """ | ||
| self._bluestacks_refresh_callback = callback |
There was a problem hiding this comment.
Missing blank line after the method definition. There should be a blank line between the register_bluestacks_refresh_callback method and the get_all_values method to follow PEP 8 style guidelines for spacing between method definitions.
| self._bluestacks_refresh_callback = callback | |
| self._bluestacks_refresh_callback = callback |
| """Handle the BlueStacks refresh button click.""" | ||
| self._update_bluestacks_instances() | ||
|
|
||
|
|
There was a problem hiding this comment.
Extra blank line. There should only be one blank line between method definitions according to PEP 8 style guidelines.
|
Added BlueStacks instance selector and bug fixes This update adds a GUI instance selector for BlueStacks, letting users choose which BlueStacks instance to run the bot on. The selector includes a refresh button to update the list of available instances, and your choice is saved in the config. Also implemented list_bluestacks_instances() to fetch instances without launching anything, and threaded the instance_name through to the controller so the bot starts on your chosen instance. Bug fixes:
The bot now starts on the selected BlueStacks instance and proceeds with ADB + Clash Royale as expected. Thanks to Macadan (Discord) for testing help. |
deleted: .vscode/settings.json Changes not staged for commit: modified: .gitignore Untracked files: .vscode/settings.json
- Added ScheduleConfig class for time-based scheduling (start/end times) - Integrated scheduler UI in Misc tab with hour/minute spinboxes - Added ColoredFormatter for terminal log output (color-coded messages) - LogColorMap auto-detects message type and applies appropriate color - Supports Success (green), Error (red), Warning (yellow), Info (blue), Debug (cyan) - Removed Presets feature after initial implementation - All new modules import correctly and test successfully
- Added _check_scheduler() method in worker.py to verify schedule after each battle - Bot now stops gracefully when outside configured time window - Integrated ColoredFormatter into Logger class for terminal output - Added colored output to log() and error() methods - Logs now display with automatic color detection based on keywords
…ing your choice.
Implemented list_bluestacks_instances() to fetch instances without launching anything, and threaded instance_name through to the controller. Bot now starts on the chosen instance and proceeds with ADB + Clash Royale. Thanks to Macadan (Discord) for testing help.