Skip to content
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

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ rlbot==1.*
pip

gevent
eel
Copy link
Contributor

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.

Copy link
Member

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

eel==0.9.*
PyQt5
41 changes: 39 additions & 2 deletions rlbot_gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand All @@ -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)
Expand Down Expand Up @@ -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


Expand All @@ -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()
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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.

Expand All @@ -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)
Binary file added rlbot_gui/gui/imgs/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rlbot_gui/gui/imgs/frame.webm
Binary file not shown.
Binary file added rlbot_gui/gui/imgs/johnnyboi_i.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rlbot_gui/gui/imgs/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rlbot_gui/gui/imgs/save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rlbot_gui/gui/imgs/shot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rlbot_gui/gui/imgs/socials.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rlbot_gui/gui/imgs/top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added rlbot_gui/gui/imgs/votes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading