diff --git a/requirements.txt b/requirements.txt index 43ef3074..b99b4ea8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,5 @@ rlbot==1.* pip gevent -eel +eel==0.9.* PyQt5 diff --git a/rlbot_gui/gui.py b/rlbot_gui/gui.py index 0799bddf..da9f991f 100644 --- a/rlbot_gui/gui.py +++ b/rlbot_gui/gui.py @@ -1,9 +1,16 @@ import os +import time +from threading import Thread +import webbrowser import eel 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 +27,22 @@ 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 +208,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 +235,18 @@ 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(): + webbrowser.open("steam://rungameid/252950//-rlbot") # Open rocket league if not already opened + gui_folder = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'gui') eel.init(gui_folder) - options = {} + packet_reader = GameTickReader() + + 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. @@ -215,6 +256,17 @@ def start(): eel.start('main.html', size=(1000, 800), block=False, callback=on_websocket_close, options=options, disable_cache=True) + def reload_packet(): + while True: + global game_tick_packet + game_tick_packet = packet_reader.get_packet() + time.sleep(1/120) + + th = Thread(target=reload_packet) + th.start() + while not should_quit: do_infinite_loop_content() eel.sleep(1.0) + + th.join() diff --git a/rlbot_gui/gui/imgs/demo.png b/rlbot_gui/gui/imgs/demo.png new file mode 100644 index 00000000..7bd52a06 Binary files /dev/null and b/rlbot_gui/gui/imgs/demo.png differ diff --git a/rlbot_gui/gui/imgs/frame.webm b/rlbot_gui/gui/imgs/frame.webm new file mode 100644 index 00000000..40b93d0d Binary files /dev/null and b/rlbot_gui/gui/imgs/frame.webm differ diff --git a/rlbot_gui/gui/imgs/johnnyboi_i.png b/rlbot_gui/gui/imgs/johnnyboi_i.png new file mode 100644 index 00000000..f839b01b Binary files /dev/null and b/rlbot_gui/gui/imgs/johnnyboi_i.png differ diff --git a/rlbot_gui/gui/imgs/logo.png b/rlbot_gui/gui/imgs/logo.png new file mode 100644 index 00000000..46dc2b8f Binary files /dev/null and b/rlbot_gui/gui/imgs/logo.png differ diff --git a/rlbot_gui/gui/imgs/save.png b/rlbot_gui/gui/imgs/save.png new file mode 100644 index 00000000..8cd92437 Binary files /dev/null and b/rlbot_gui/gui/imgs/save.png differ diff --git a/rlbot_gui/gui/imgs/shot.png b/rlbot_gui/gui/imgs/shot.png new file mode 100644 index 00000000..5ae77fa0 Binary files /dev/null and b/rlbot_gui/gui/imgs/shot.png differ diff --git a/rlbot_gui/gui/imgs/socials.png b/rlbot_gui/gui/imgs/socials.png new file mode 100644 index 00000000..1fe51c93 Binary files /dev/null and b/rlbot_gui/gui/imgs/socials.png differ diff --git a/rlbot_gui/gui/imgs/top.png b/rlbot_gui/gui/imgs/top.png new file mode 100644 index 00000000..376a8561 Binary files /dev/null and b/rlbot_gui/gui/imgs/top.png differ diff --git a/rlbot_gui/gui/imgs/votes.png b/rlbot_gui/gui/imgs/votes.png new file mode 100644 index 00000000..1d135176 Binary files /dev/null and b/rlbot_gui/gui/imgs/votes.png differ diff --git a/rlbot_gui/gui/overlay.html b/rlbot_gui/gui/overlay.html new file mode 100644 index 00000000..94e9d64e --- /dev/null +++ b/rlbot_gui/gui/overlay.html @@ -0,0 +1,514 @@ + + + Overlay Endpoint + + + + + + + + + + +
+
Blue Team
+
+
Orange Team
+
+ +
+
+
+
+ + + + + + + + + +
+ +
+ + + + + + diff --git a/run.bat b/run.bat new file mode 100644 index 00000000..c2b01439 --- /dev/null +++ b/run.bat @@ -0,0 +1 @@ +python run.py \ No newline at end of file diff --git a/runRLBotInsideEnv.bat b/runRLBotInsideEnv.bat deleted file mode 100644 index 912039c8..00000000 --- a/runRLBotInsideEnv.bat +++ /dev/null @@ -1,22 +0,0 @@ -@echo off -set "VIRTUAL_ENV=\env" - -REM Don't use () to avoid problems with them in %PATH% -if defined _OLD_VIRTUAL_PYTHONHOME goto ENDIFVHOME - set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%" -:ENDIFVHOME - -set PYTHONHOME= - -REM if defined _OLD_VIRTUAL_PATH ( -if not defined _OLD_VIRTUAL_PATH goto ENDIFVPATH1 - set "PATH=%_OLD_VIRTUAL_PATH%" -:ENDIFVPATH1 -REM ) else ( -if defined _OLD_VIRTUAL_PATH goto ENDIFVPATH2 - set "_OLD_VIRTUAL_PATH=%PATH%" -:ENDIFVPATH2 - -set "PATH=%VIRTUAL_ENV%\Scripts;%PATH%" - -.\env\Scripts\python.exe run.py