-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tournament overlay #23
base: master
Are you sure you want to change the base?
Changes from 16 commits
3cbb87f
bdf96ea
0c2834a
ed85f69
591fb83
b10326d
40b65a9
2b8ef2f
a1cf293
81013ea
63a8c58
8375ad8
0d871b6
8c05b4d
d58fcc2
ff86164
236b0e0
54bedc4
ccfbde3
286a776
8eb0967
591c370
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,5 @@ rlbot==1.* | |
pip | ||
|
||
gevent | ||
eel | ||
eel==0.9.* | ||
PyQt5 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,10 @@ | |
from PyQt5.QtCore import QSettings | ||
from PyQt5.QtWidgets import QApplication, QFileDialog | ||
from pip._internal import main as pipmain | ||
from rlbot.utils import rate_limiter | ||
from rlbot.utils.logging_utils import get_logger | ||
from rlbot.utils.structures.game_interface import GameInterface | ||
from rlbot.utils.structures import game_data_struct | ||
from rlbot.parsing.bot_config_bundle import get_bot_config_bundle, BotConfigBundle | ||
from rlbot.parsing.directory_scanner import scan_directory_for_bot_configs | ||
from rlbot.parsing.match_settings_config_parser import map_types, game_mode_types, \ | ||
|
@@ -20,6 +24,21 @@ | |
settings = QSettings('rlbotgui', 'preferences') | ||
|
||
|
||
game_tick_packet = None | ||
|
||
class GameTickReader: | ||
def __init__(self): | ||
self.logger = get_logger('packet reader') | ||
self.game_interface = GameInterface(self.logger) | ||
self.game_interface.inject_dll() | ||
self.game_interface.load_interface() | ||
self.game_tick_packet = game_data_struct.GameTickPacket() | ||
|
||
def get_packet(self): | ||
self.game_interface.update_live_data_packet(self.game_tick_packet) | ||
return self.game_tick_packet | ||
|
||
|
||
@eel.expose | ||
def start_match(bot_list, match_settings): | ||
eel.spawn(start_match_helper, bot_list, match_settings) | ||
|
@@ -185,6 +204,20 @@ def begin_python_bot(bot_name): | |
return {'bots': load_bundle(config_file)} | ||
|
||
|
||
def as_jsonifyable(obj): | ||
if isinstance(obj, (int, float, str)): | ||
return obj | ||
elif "Array" in obj.__class__.__name__: | ||
return list(map(as_jsonifyable, obj)) | ||
else: | ||
return {attr: as_jsonifyable(getattr(obj, attr)) for attr in dir(obj) if not attr.startswith("_")} | ||
|
||
|
||
@eel.expose | ||
def get_game_tick_packet(): | ||
return as_jsonifyable(game_tick_packet) | ||
|
||
|
||
should_quit = False | ||
|
||
|
||
|
@@ -198,14 +231,16 @@ def on_websocket_close(page, sockets): | |
|
||
|
||
def is_chrome_installed(): | ||
return eel.browsers.chr.get_instance_path() is not None | ||
return getattr(eel.browsers, "chm", getattr(eel.browsers, "chr", None)).get_instance_path() is not None | ||
|
||
|
||
def start(): | ||
gui_folder = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'gui') | ||
eel.init(gui_folder) | ||
|
||
options = {} | ||
packet_reader = GameTickReader() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If Rocket League is not running, the GUI will hang forever on startup waiting for the dll to be injected. I'd very much like for the GUI to be able to open without any dependency on Rocket League or successful injection, both for the sake of the user experience, and also to avoid having every single bug related to those get blamed on the GUI. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any clue how to implement this better? |
||
|
||
options = {"chromeFlags": ["--autoplay-policy=no-user-gesture-required"]} | ||
if not is_chrome_installed(): | ||
options = {'mode': 'system-default'} # Use the system default browser if the user doesn't have chrome. | ||
|
||
|
@@ -216,5 +251,7 @@ def start(): | |
disable_cache=True) | ||
|
||
while not should_quit: | ||
global game_tick_packet | ||
game_tick_packet = packet_reader.get_packet() | ||
do_infinite_loop_content() | ||
eel.sleep(1.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't need to be part of this PR, just reminding myself: We should probably copy my branch of the eel source code right into this repo until it gets merged in and published.
If we accidentally publish an installer without my special branch, html, css and js will get cached for a long time on our users' browsers and it'll be a real mess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/tarehart/eel/archive/master.zip
should be used instead then