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

rlbot hub alpha #43

Open
wants to merge 63 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
b2c0a57
Add files via upload
Ard2025 Jul 13, 2019
99982e6
Add files via upload
Ard2025 Jul 13, 2019
e44c30a
first alpha hub and update to mainstream
Ard2025 Jul 23, 2019
c0bd06b
replacing browserfs by fetch api
Ard2025 Jul 24, 2019
b084963
Update botmanager.html
Ard2025 Jul 24, 2019
c06e22a
download / delete button improvement
Ard2025 Jul 24, 2019
0ec4f15
Update botmanager.html
Ard2025 Jul 24, 2019
1afcb68
Update botmanager.html
Ard2025 Jul 24, 2019
478bfb6
function to pass bot packaging to js
Ard2025 Jul 24, 2019
526d650
update functionallity
Ard2025 Jul 24, 2019
7717a4a
Update gui.py
Ard2025 Jul 24, 2019
066659e
change to botpackage.json
Ard2025 Jul 25, 2019
f195343
Update botmanager.html
Ard2025 Jul 27, 2019
35f06cc
Update main.html
Ard2025 Jul 27, 2019
51a6319
Update botmanager.html
Ard2025 Jul 27, 2019
8512f3f
changes to shorten json in repofile (change in repo repo)
Ard2025 Jul 27, 2019
78a8948
botmanager js to seperate file
Ard2025 Jul 28, 2019
4816f8f
Update botmanager.html
Ard2025 Jul 28, 2019
d72cfc1
some canges to make the diff tool happy
Ard2025 Jul 28, 2019
6fbdc09
Merge branch 'master' into master
Ard2025 Jul 29, 2019
4fb7d6f
Update gui.py
Ard2025 Jul 29, 2019
5a29b42
Update gui.py
Ard2025 Jul 29, 2019
728b928
Update bot_creation.py
Ard2025 Jul 29, 2019
d660a22
Update gui.py
Ard2025 Jul 29, 2019
e27fe26
Update gui.py
Ard2025 Jul 29, 2019
6bf26ea
Update botmanager.js
Ard2025 Jul 29, 2019
86baed1
Update botmanager.js
Ard2025 Jul 29, 2019
cb3fd72
Create hubTodo.md
Ard2025 Jul 29, 2019
5b7be30
small style changes
Ard2025 Jul 30, 2019
d99a1ce
inaccurate closing times
Ard2025 Jul 30, 2019
97be127
Update hubTodo.md
Ard2025 Jul 30, 2019
7346ce0
copy download bot folder stabillity improvement
Ard2025 Jul 30, 2019
1b41e6c
Merge branch 'master' of https://github.com/ard1998/RLBotGUI
Ard2025 Jul 30, 2019
19e3cb7
Update botmanager.js
Ard2025 Jul 30, 2019
90bc89a
Bracket consistency
Ard2025 Jul 30, 2019
f0651a4
Update style.css
Ard2025 Jul 31, 2019
829086a
Update botmanager.css
Ard2025 Jul 31, 2019
6699b9d
Update botmanager.js
Ard2025 Jul 31, 2019
65e9a58
Update botmanager.js
Ard2025 Jul 31, 2019
937082b
Update botmanager.js
Ard2025 Jul 31, 2019
2034b74
Update botmanager.js
Ard2025 Jul 31, 2019
2ca152c
shoren the refresh time
Ard2025 Jul 31, 2019
ddd041f
Update botmanager.js
Ard2025 Jul 31, 2019
afedc4f
Converting the rlbot hub to vue, mostly.
tarehart Aug 2, 2019
def288a
multi repo functions for vue
Ard2025 Aug 26, 2019
709b020
small changes to indicate download safety
Ard2025 Aug 26, 2019
3dc55f9
deleting botpack functions and giving repo downloads own folder
Ard2025 Aug 26, 2019
a95e82c
Add files via upload
Ard2025 Aug 27, 2019
a2f4a82
Add files via upload
Ard2025 Aug 27, 2019
639973d
vue code fixes and some changes
Ard2025 Aug 29, 2019
ec63692
add sideloading via url
Ard2025 Aug 30, 2019
cfc2052
Update botmanager.html
Ard2025 Aug 30, 2019
284cfff
add news support and some small layout stuff
Ard2025 Aug 30, 2019
b54a6eb
small changes
Ard2025 Aug 30, 2019
ef75592
Delete hubTodo.md
Ard2025 Aug 31, 2019
22ffd71
few bugfixes
Ard2025 Aug 31, 2019
3572ce7
embed hub in main
Ard2025 Sep 26, 2019
59eea5d
Update gui.py
Ard2025 Sep 26, 2019
0bfd8c7
Update style.css
Ard2025 Sep 26, 2019
a59b284
Update gui.py
Ard2025 Sep 27, 2019
2681fec
Update botmanager.html
Ard2025 Sep 27, 2019
e93bb10
hub download section to 3 column
Ard2025 Sep 27, 2019
532e01c
undo last commit
Ard2025 Sep 28, 2019
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
23 changes: 21 additions & 2 deletions rlbot_gui/bot_management/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import urllib
import zipfile
from pathlib import Path
from shutil import rmtree
import shutil

from distutils.dir_util import copy_tree



def download_and_extract_zip(download_url: str, local_folder_path: Path, clobber: bool = False):
Expand All @@ -17,7 +20,7 @@ def download_and_extract_zip(download_url: str, local_folder_path: Path, clobber
urllib.request.urlretrieve(download_url, downloadedZip)

if clobber and os.path.exists(local_folder_path):
rmtree(local_folder_path)
shutil.rmtree(local_folder_path)

with zipfile.ZipFile(downloadedZip, 'r') as zip_ref:
zip_ref.extractall(local_folder_path)
Expand All @@ -43,3 +46,19 @@ def download_gitlfs(repo_url: str, checkout_folder: Path, branch_name: str):
file.close()

print('Done downloading git repo.')

def download_botfs(repo_url: str, checkout_folder: Path, branch_name: str, bot_path: str, bot_dir_name: str):
print('Starting download of a git repo... this might take a while.')
dtracers marked this conversation as resolved.
Show resolved Hide resolved

shutil.rmtree(checkout_folder, ignore_errors=True)

# Download the most of the files eg. https://github.com/RLBot/RLBotPack/archive/master.zip
download_and_extract_zip(
download_url=repo_url + '/archive/' + branch_name + '.zip',
local_folder_path=checkout_folder, clobber=True)

repo_extraction_name = '/' + repo_url.split('/')[-1] + '-' + branch_name + '/'

shutil.copytree(checkout_folder + repo_extraction_name + '/' + bot_dir_name, bot_path + '/' + bot_dir_name)

print('Done downloading git repo.')
87 changes: 69 additions & 18 deletions rlbot_gui/gui.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import shutil

import eel
from PyQt5.QtCore import QSettings
Expand All @@ -15,15 +16,17 @@

from rlbot_gui.bot_management.bot_creation import bootstrap_python_bot
from rlbot_gui.bot_management.downloader import download_gitlfs
from rlbot_gui.bot_management.downloader import download_botfs
from rlbot_gui.match_runner.match_runner import hot_reload_bots, shut_down, start_match_helper, do_infinite_loop_content
import getpass

DEFAULT_BOT_FOLDER = 'default_bot_folder'
BOTPACK_FOLDER = 'RLBotPackDeletable'
OLD_BOTPACK_FOLDER = 'RLBotPack'
CREATED_BOTS_FOLDER = 'MyBots'
HUB_FOLDER = 'repos'
BOT_FOLDER_SETTINGS_KEY = 'bot_folder_settings'
settings = QSettings('rlbotgui', 'preferences')


bot_folder_settings = settings.value(BOT_FOLDER_SETTINGS_KEY, type=dict)

if not bot_folder_settings:
Expand Down Expand Up @@ -147,17 +150,23 @@ def scan_for_bots():
for bot in bots:
bot_hash[bot['path']] = bot

bots = get_bots_from_directory("C:/Users/"+getpass.getuser()+"/AppData/Local/RLBotGUI/repos")
for bot in bots:
bot_hash[bot['path']] = bot

return list(bot_hash.values())


def get_bots_from_directory(bot_directory):
return [
{
'name': bundle.name,
'safe': 1 if bundle.config_path.split('\\')[7] != 'unferifiedCommunity' and bundle.config_path.split('\\')[7] != 'localRepo' else 0,
'type': 'rlbot',
'skill': 1,
'image': 'imgs/rlbot.png',
'path': bundle.config_path,
'display_path': bundle.config_path.split('\\')[7],
'info': read_info(bundle)
}
for bundle in scan_directory_for_bot_configs(bot_directory)]
Expand Down Expand Up @@ -208,24 +217,66 @@ def install_package(package_string):


@eel.expose
def download_bot_pack():
# The bot pack in now hosted at https://github.com/RLBot/RLBotPack
download_gitlfs(
repo_url="https://github.com/RLBot/RLBotPack",
checkout_folder=BOTPACK_FOLDER,
branch_name='master')
def download_bot(repo_path, repo, bot_dir):
print(repo)
branch = ""
if "tree" in repo:
branch = repo.split('/')[-1]
repo = repo.split('/tree')[0]
else:
branch = "master"

# Configure the folder settings.
bot_folder_settings['folders'][os.path.abspath(BOTPACK_FOLDER)] = {'visible': True}
download_botfs(
repo_url=repo,
checkout_folder='download',
branch_name=branch,
bot_path=os.path.abspath(HUB_FOLDER) + '/' + repo_path,
bot_dir_name=bot_dir)
return 0;

if os.path.abspath(OLD_BOTPACK_FOLDER) in bot_folder_settings['folders']:
# Toggle off the old one since it's been replaced.
bot_folder_settings['folders'][os.path.abspath(OLD_BOTPACK_FOLDER)] = {'visible': False}

settings.setValue(BOT_FOLDER_SETTINGS_KEY, bot_folder_settings)
settings.sync()
@eel.expose
def delete_bot(repo_path, name):
shutil.rmtree(os.path.abspath(HUB_FOLDER + "/" + repo_path + '/' + name))
return 0;


@eel.expose
def is_bot_installed(repo_path, bot_name):
if os.path.exists(HUB_FOLDER + "/" + repo_path + '/' + bot_name):
return True
else:
return False


@eel.expose
def get_bot_packaging(repo_path, bot_name):
bot_directory = HUB_FOLDER + "/" + repo_path
if os.path.exists(bot_directory+'/'+bot_name):
file = open(bot_directory+'/'+bot_name+'/botpackage.json',"r")
filestr = file.read()
file.close()
return filestr
else:
return False


@eel.expose
def read_local_repofile():
if os.path.exists('localRepo.json'):
file = open('localRepo.json',"r")
filestr = file.read()
file.close()
return filestr
else:
return False

@eel.expose
def write_local_repofile(jsonstr):
file = open('localRepo.json',"w")
file.write(jsonstr)
file.close()

@eel.expose
def show_bot_in_explorer(bot_cfg_path):
import subprocess
Expand Down Expand Up @@ -261,7 +312,7 @@ def begin_python_bot(bot_name):

def on_websocket_close(page, sockets):
global should_quit
eel.sleep(3.0) # We might have just refreshed. Give the websocket a moment to reconnect.
eel.sleep(10.0) # We might have just refreshed. Give the websocket a moment to reconnect.
if not len(eel._websockets):
# At this point we think the browser window has been closed.
should_quit = True
Expand Down Expand Up @@ -296,7 +347,7 @@ def launch_eel(use_chrome):
# installed to pip locally using this technique https://stackoverflow.com/a/49684835
# The suppress_error=True avoids the error "'options' argument deprecated in v1.0.0", we need to keep the
# options argument since a lot of our user base has an older version of eel.
eel.start('main.html', size=(1000, 800), block=False, callback=on_websocket_close, options=options,
eel.start('main.html', size=(1000, 830), block=False, callback=on_websocket_close, options=options,
disable_cache=True, mode=browser_mode, port=port, suppress_error=True)


Expand All @@ -314,4 +365,4 @@ def start():

while not should_quit:
do_infinite_loop_content()
eel.sleep(1.0)
eel.sleep(1.0)
188 changes: 188 additions & 0 deletions rlbot_gui/gui/botmanager.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<!DOCTYPE html>
<html>
<head>

<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1,minimal-ui" name="viewport">

<link rel="icon" type="image/png" sizes="192x192" href="imgs/rlbot_logo.png">

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/>
<link rel="stylesheet" href="css/vue-material.min.css"/>
<link rel="stylesheet" href="css/vue-fonts.css"/>
<link rel="stylesheet" href="css/black-green-light.css"/>
<link rel="stylesheet" href="css/style.css"/>
<link rel="stylesheet" href="css/botmanager.css"/>

<title>Hub</title>

</head>
<body id="rlbotgui">
<div id="app">

<aside>
<md-card class="settings-card">
<md-card-header>
<div class="md-title">Filters</div>
</md-card-header>

<md-card-content>

<label for="searchBotName">search</label>
<input id="searchBotName" onkeyup="reloadCards()" type="text" name="" class="" placeholder="search on bot name"><br>

<hr>

<div class="center-flex">

<div class="md-layout">
<div class="md-layout-item">
<label for="gamemodes">Gamemode</label>
<div id="gamemodes" class="list">
<p><input onclick="reloadCards()" type="checkbox" name="gamemode" value="soccar">soccar</p>
<p><input onclick="reloadCards()" type="checkbox" name="gamemode" value="Hoops">Hoops</p>
<p><input onclick="reloadCards()" type="checkbox" name="gamemode" value="Dropshot">Dropshot</p>
<p><input onclick="reloadCards()" type="checkbox" name="gamemode" value="Rumble">Rumble</p>
<p><input onclick="reloadCards()" type="checkbox" name="gamemode" value="Snowday">Snowday</p>
</div>
</div>
<div class="md-layout-item">
<label for="gamemodes">Repo</label>
<div id="gamemodes" class="list">
<p><input onclick="reloadCards()" type="radio" name="source" value="all" checked>all</p>
<p><input onclick="reloadCards()" type="radio" name="source" value="Trusted">Trusted</p>
<p><input onclick="reloadCards()" type="radio" name="source" value="UnverifiedCommunity">UnverifiedCommunity</p>
<p><input onclick="reloadCards()" type="radio" name="source" value="localRepo">localRepo</p>
</div>
</div>
</div>
</div>

<button @click="showNewRepoDialog = true;">Add custom repo</button>

</md-card-content>
</md-card>

<md-card class="settings-card">
<md-card-header>
<div class="md-title">Beta notice</div>
</md-card-header>

<md-card-content>

<div class="center-flex">

<div class="md-layout">
<p>The hub is an beta preview. bugs can occur more often then expected.</p>
</div>
</div>

</md-card-content>
</md-card>

<md-card class="settings-card">
<md-card-header>
<div class="md-title">News</div>
</md-card-header>

<md-card-content>

<div class="center-flex">

<table>
<tr v-for="newsItem in newsItems">
<td>{{newsItem.date}}</td>
<td>{{newsItem.content}}</td>
</tr>
</table>
</div>

</md-card-content>
</md-card>
</aside>

<div id="main">

<div v-for="repo in repos" class="md-card settings-card md-theme-default" :key="repo.ID" v-if="repo.display">
<div class="md-card-header">
<div class="md-title">{{repo.name}}
<small v-if="!repo.is_installed || repo.is_installed && repo.localVersion === repo.onlineVersion" >Version {{repo.onlineVersion}}</small>
<small v-if="repo.is_installed && repo.localVersion !== repo.onlineVersion" >Version {{repo.localVersion}}, an update to version Version {{repo.onlineVersion}} is available</small>
</div>
</div>
<div class="md-card-content">
<div class="center-flex">
<div class="md-layout md-gutter">
<div class="md-layout-item botinfo-short"><label for="gamemodes-0"><b>Gamemode</b></label>
<p id="gamemodes-0" class="managerInfo">
<span class="gamemode" v-for="mode in repo.gamemodes">{{mode.name}} </span>
</p>
</div>
<div class="md-layout-item botinfo-short"><label for="type-0"><b>Categories</b></label>
<p id="type-0" class="managerInfo">
<span class="category" v-for="category in repo.categories">{{category.name}} </span>
</p>
</div>
<div class="md-layout-item botinfo-long"><label for="type-0"><b>Description</b></label>
<p id="type-0" class="managerInfo">
<span>{{repo.description}} </span>
</p>
</div>
<div class="md-layout-item botinfo-short"><label for="type-0"><b>Source</b></label>
<p id="type-0" class="managerInfo">
<span>{{repo.repoName}} </span>
</p>
</div>
</div>
<span style="flex-grow: 1;"></span>
<button type="button" class="md-button md-primary md-raised md-theme-default">
<div class="md-ripple">
<div v-if="!repo.is_installed" class="md-button-content"
@click="downloadBot(repo)">
Download
</div>
<div v-if="repo.is_installed && repo.localVersion === repo.onlineVersion"
class="md-button-content"
@click="deleteBot(repo)">
Delete
</div>
<div v-if="repo.is_installed && repo.localVersion !== repo.onlineVersion"
class="md-button-content"
@click="updateBot(repo)">
Update
</div>
</div>
</button>
</div>
</div>
</div>
</div>
<md-dialog :md-active.sync="showNewRepoDialog">
<md-dialog-title>Add bot to local repo</md-dialog-title>

<md-dialog-content>
<md-field>
<label>Repo url</label>
<md-input v-model="newRepoUrl"></md-input>
</md-field>
<md-field>
<label>Folder Name</label>
<md-input v-model="newRepoFolder"></md-input>
</md-field>
</md-dialog-content>

<md-dialog-actions>
<md-button class="md-raised md-primary" @click="addBotToLocalRepofile(newRepoUrl, newRepoFolder)">Begin</md-button>
<md-button @click="showNewRepoDialog = false">Close</md-button>
</md-dialog-actions>
</md-dialog>
</div>

<script type="text/javascript" src="/eel.js"></script>
<script type="text/javascript" src="js/vue.js"></script>
<script type="text/javascript" src="js/vue-material.min.js"></script>
<script type="text/javascript" src="js/Sortable.min.js"></script>
<script type="text/javascript" src="js/vuedraggable.min.js"></script>
<script type="text/javascript" src="js/botmanager.js"></script>
</body>
</html>
Loading