Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
69 changes: 57 additions & 12 deletions rlbot_gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
from rlbot.parsing.agent_config_parser import create_looks_configurations, BOT_CONFIG_LOADOUT_HEADER, \
BOT_CONFIG_LOADOUT_ORANGE_HEADER, BOT_CONFIG_LOADOUT_PAINT_BLUE_HEADER, BOT_CONFIG_LOADOUT_PAINT_ORANGE_HEADER, \
load_bot_appearance
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.bot_config_bundle import get_bot_config_bundle, get_script_config_bundle, RunnableConfigBundle
from rlbot.parsing.directory_scanner import scan_directory_for_bot_configs, scan_directory_for_script_configs
from rlbot.parsing.match_settings_config_parser import map_types, game_mode_types, \
boost_amount_mutator_types, match_length_types, max_score_types, overtime_mutator_types, \
series_length_mutator_types, game_speed_mutator_types, ball_max_speed_mutator_types, ball_type_mutator_types, \
ball_weight_mutator_types, ball_size_mutator_types, ball_bounciness_mutator_types, rumble_mutator_types, \
boost_strength_mutator_types, gravity_mutator_types, demolish_mutator_types, respawn_time_mutator_types, \
existing_match_behavior_types

from rlbot_gui.bot_management.bot_creation import bootstrap_python_bot, bootstrap_scratch_bot, bootstrap_python_hivemind, convert_to_filename
from rlbot_gui.bot_management.bot_creation import bootstrap_python_bot, bootstrap_scratch_bot, \
bootstrap_python_hivemind, convert_to_filename
from rlbot_gui.bot_management.downloader import BotpackDownloader, get_json_from_url
from rlbot_gui.match_runner.match_runner import hot_reload_bots, shut_down, start_match_helper, \
do_infinite_loop_content, spawn_car_in_showroom, set_game_state, fetch_game_tick_packet
Expand Down Expand Up @@ -80,7 +81,18 @@ def serialize_bundle(bundle):
}


def load_bundle(filename):
def serialize_script_bundle(bundle):
return {
'name': bundle.name,
'type': 'script',
'image': 'imgs/rlbot.png',
'path': bundle.config_path,
'info': read_info(bundle),
'logo': try_copy_logo(bundle)
}


def load_bot_bundle(filename):
try:
bundle = get_bot_config_bundle(filename)
return [serialize_bundle(bundle)]
Expand All @@ -90,10 +102,20 @@ def load_bundle(filename):
return []


def load_script_bundle(filename):
try:
bundle = get_script_config_bundle(filename)
return [serialize_script_bundle(bundle)]
except Exception as e:
print(e)

return []


@eel.expose
def pick_bot_config():
filename = pick_location(False)
bundle = load_bundle(filename)
bundle = load_script_bundle(filename) or load_bot_bundle(filename)

if bundle:
bot_folder_settings["files"][filename] = {"visible": True}
Expand Down Expand Up @@ -124,7 +146,7 @@ def validate_bots(bots):

for bot in bots:
if bot["type"] in ('rlbot', 'party_member_bot'):
valid_bots += load_bundle(bot["path"])
valid_bots += load_bot_bundle(bot["path"])
else:
valid_bots.append(bot)

Expand Down Expand Up @@ -186,7 +208,7 @@ def pick_location(is_folder):
return filename


def read_info(bundle: BotConfigBundle):
def read_info(bundle: RunnableConfigBundle):
details_header = 'Details'
if bundle.base_agent_config.has_section(details_header):
return {
Expand Down Expand Up @@ -263,14 +285,33 @@ def scan_for_bots():

for file, props in bot_folder_settings['files'].items():
if props['visible']:
bots = load_bundle(file) # Returns a list of size 1
bots = load_bot_bundle(file) # Returns a list of size 1
for bot in bots:
bot_hash[bot['path']] = bot

return list(bot_hash.values())


def try_copy_logo(bundle: BotConfigBundle):
@eel.expose
def scan_for_scripts():
script_hash = {}

for folder, props in bot_folder_settings['folders'].items():
if props['visible']:
bots = get_scripts_from_directory(folder)
for bot in bots:
script_hash[bot['path']] = bot

for file, props in bot_folder_settings['files'].items():
if props['visible']:
bots = load_script_bundle(file) # Returns a list of size 1
for bot in bots:
script_hash[bot['path']] = bot

return list(script_hash.values())


def try_copy_logo(bundle: RunnableConfigBundle):
logo_path = bundle.get_logo_file()
if logo_path is not None and os.path.exists(logo_path):
web_url = 'imgs/logos/' + convert_to_filename(bundle.name) + '/' + convert_to_filename(logo_path)
Expand All @@ -285,6 +326,10 @@ def get_bots_from_directory(bot_directory):
return [serialize_bundle(bundle) for bundle in scan_directory_for_bot_configs(bot_directory)]


def get_scripts_from_directory(bot_directory):
return [serialize_script_bundle(bundle) for bundle in scan_directory_for_script_configs(bot_directory)]


@eel.expose
def get_language_support():
java_return_code = os.system("java -version")
Expand Down Expand Up @@ -402,7 +447,7 @@ def begin_python_bot(bot_name):

try:
config_file = bootstrap_python_bot(bot_name, bot_directory)
return {'bots': load_bundle(config_file)}
return {'bots': load_bot_bundle(config_file)}
except FileExistsError as e:
return {'error': str(e)}

Expand All @@ -414,7 +459,7 @@ def begin_scratch_bot(bot_name):
try:
config_file = bootstrap_scratch_bot(bot_name, bot_directory)
install_package('webdriver_manager') # Scratch bots need this, and the GUI's python doesn't have it by default.
return {'bots': load_bundle(config_file)}
return {'bots': load_bot_bundle(config_file)}
except FileExistsError as e:
return {'error': str(e)}

Expand All @@ -425,7 +470,7 @@ def begin_python_hivemind(hive_name):

try:
config_file = bootstrap_python_hivemind(hive_name, bot_directory)
return {'bots': load_bundle(config_file)}
return {'bots': load_bot_bundle(config_file)}
except FileExistsError as e:
return {'error': str(e)}

Expand Down
9 changes: 8 additions & 1 deletion rlbot_gui/gui/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ body {
opacity: 0.4;
}

.draggable {
cursor: move;
}

.bot-card {
margin: 5px;
cursor: move;
}

.bot-card .md-switch {
margin: 5px 8px;
}

.center-flex {
Expand Down
40 changes: 32 additions & 8 deletions rlbot_gui/gui/main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
</md-card-header>

<draggable v-model="botPool" :options="{group: {name:'bots', pull:'clone', put:false}, sort: false}">
<md-card class="bot-card md-elevation-3" v-for="bot in botPool" :class="{'filtered': !passesFilter(bot.name)}">
<md-card class="bot-card draggable md-elevation-3" v-for="bot in botPool" :class="{'filtered': !passesFilter(bot.name)}">
<button class="center-flex secret-button" @click="addToTeam(bot, teamSelection)">
<img v-if="!bot.logo" class="darkened" v-bind:src="bot.image">
<img v-if="bot.logo" v-bind:src="bot.logo">
Expand All @@ -114,6 +114,13 @@
</button>
</md-card>
</draggable>
<md-card class="bot-card md-elevation-3" v-for="script in scriptPool">
<md-switch v-model="script.enabled">{{script.name}}</md-switch>
<md-button class="md-icon-button md-dense bot-hover-reveal" v-if="script.info"
@click.stop="activeBot = script; showBotInfo = true;">
<md-icon>blur_on</md-icon>
</md-button>
</md-card>
</md-card>

<div id="teamSwitcher" style="text-align: center;">
Expand All @@ -130,7 +137,7 @@
<div class="md-title">Blue Team</div>
</md-card-header>
<draggable v-model="blueTeam" class="team-entries" :options="{group:'bots'}">
<md-card class="bot-card center-flex md-elevation-3" v-for="(bot, index) in blueTeam">
<md-card class="bot-card draggable center-flex md-elevation-3" v-for="(bot, index) in blueTeam">
<img v-if="!bot.logo" class="darkened" v-bind:src="bot.image">
<img v-if="bot.logo" v-bind:src="bot.logo">
<span class="bot-name">{{ bot.name }}</span>
Expand All @@ -148,7 +155,7 @@
<div class="md-title">Orange Team</div>
</md-card-header>
<draggable v-model="orangeTeam" class="team-entries" :options="{group:'bots'}">
<md-card class="bot-card center-flex md-elevation-3" v-for="(bot, index) in orangeTeam">
<md-card class="bot-card draggable center-flex md-elevation-3" v-for="(bot, index) in orangeTeam">
<img v-if="!bot.logo" class="darkened" v-bind:src="bot.image">
<img v-if="bot.logo" v-bind:src="bot.logo">
<span class="bot-name">{{ bot.name }}</span>
Expand Down Expand Up @@ -301,7 +308,7 @@
</md-dialog-content>

<md-dialog-actions>
<md-button @click="showAppearanceEditor(activeBot.looks_path)">
<md-button v-if="activeBot.type !== 'script'" @click="showAppearanceEditor(activeBot.looks_path)">
<md-icon>palette</md-icon> Edit Appearance
</md-button>
<md-button v-if="activeBot.path" @click="showBotInExplorer(activeBot.path)">
Expand Down Expand Up @@ -446,6 +453,7 @@
data () {
return {
botPool: STARTING_BOT_POOL,
scriptPool: [],
blueTeam: [],
orangeTeam: [],
teamSelection: "blue",
Expand Down Expand Up @@ -479,6 +487,7 @@
enable_rendering: false,
enable_state_setting: false,
auto_save_replay: false,
scripts: [],
},
randomMapPool: [],
showMutatorDialog: false,
Expand Down Expand Up @@ -514,6 +523,7 @@
startMatch: async function (event) {
if (this.matchSettings.randomizeMap) await this.setRandomMap();

this.matchSettings.scripts = this.scriptPool.filter((val) => { return val.enabled });
eel.save_match_settings(this.matchSettings);
eel.save_team_settings(this.blueTeam, this.orangeTeam);

Expand Down Expand Up @@ -571,6 +581,7 @@
this.matchSettings.enable_rendering = false;
this.matchSettings.enable_state_setting = true;
this.matchSettings.auto_save_replay = false;
this.matchSettings.scripts = [];
this.resetMutatorsToDefault();

this.updateBGImage(this.matchSettings.map);
Expand Down Expand Up @@ -621,10 +632,12 @@
eel.get_folder_settings()(this.folderSettingsReceived);
this.showFolderSettingsDialog = true;
},
applyFolderSettings: function() {
eel.save_folder_settings(this.folderSettings);
applyFolderSettings: async function() {
await eel.save_folder_settings(this.folderSettings)();
this.botPool = STARTING_BOT_POOL;
this.scriptPool = [];
eel.scan_for_bots()(this.botsReceived);
eel.scan_for_scripts()(this.scriptsReceived);
},
passesFilter: function(botName) {
return botName.toLowerCase().includes(this.botNameFilter.toLowerCase());
Expand All @@ -651,6 +664,16 @@
this.showProgressSpinner = false;
},

scriptsReceived: function (scripts) {
const freshScripts = scripts.filter( (script) =>
!this.scriptPool.find( (element) => element.path === script.path ));
freshScripts.forEach((script) => {script.enabled = !!this.matchSettings.scripts.find( (element) => element.path === script.path )});

this.scriptPool = this.scriptPool.concat(freshScripts).sort((a, b) => a.name.localeCompare(b.name));

this.showProgressSpinner = false;
},

applyLanguageWarnings: function () {
if (this.languageSupport) {
this.botPool.forEach((bot) => {
Expand All @@ -674,6 +697,7 @@
if (matchSettings) {
Object.assign(this.matchSettings, matchSettings);
this.updateBGImage(this.matchSettings.map);
this.scriptPool.forEach((script) => {script.enabled = !!this.matchSettings.scripts.find( (element) => element.path === script.path )});
} else {
this.resetMatchSettingsToDefault();
}
Expand All @@ -687,6 +711,8 @@

folderSettingsReceived: function (folderSettings) {
this.folderSettings = folderSettings;
eel.scan_for_bots()(this.botsReceived);
eel.scan_for_scripts()(this.scriptsReceived);
},
botpackUpdateChecked: function (isBotpackUpToDate) {
this.showBotpackUpdateSnackbar = !isBotpackUpToDate;
Expand All @@ -697,7 +723,6 @@
this.showSnackbar = true;
this.showDownloadProgressDialog = false;
eel.get_folder_settings()(this.folderSettingsReceived);
eel.scan_for_bots()(this.botsReceived);
},

onInstallationComplete: function (result) {
Expand All @@ -714,7 +739,6 @@
},
created: function () {
eel.get_folder_settings()(this.folderSettingsReceived);
eel.scan_for_bots()(this.botsReceived);
eel.get_match_options()(this.matchOptionsReceived);
eel.get_match_settings()(this.matchSettingsReceived);
eel.get_team_settings()(this.teamSettingsReceived);
Expand Down
6 changes: 5 additions & 1 deletion rlbot_gui/match_runner/match_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from rlbot.gateway_util import NetworkingRole
from rlbot.matchconfig.loadout_config import LoadoutConfig
from rlbot.matchconfig.match_config import PlayerConfig, MatchConfig, MutatorConfig
from rlbot.matchconfig.match_config import PlayerConfig, MatchConfig, MutatorConfig, ScriptConfig
from rlbot.parsing.incrementing_integer import IncrementingInteger
from rlbot.setup_manager import SetupManager
from rlbot.utils.structures.bot_input_struct import PlayerInput
Expand All @@ -26,6 +26,9 @@ def create_player_config(bot, human_index_tracker: IncrementingInteger):
player_config.config_path = bot['path']
return player_config

def create_script_config(script):
return ScriptConfig(script['path'])


def spawn_car_in_showroom(loadout_config: LoadoutConfig, team: int, showcase_type: str, map_name: str):
match_config = MatchConfig()
Expand Down Expand Up @@ -150,6 +153,7 @@ def start_match_helper(bot_list, match_settings):

human_index_tracker = IncrementingInteger(0)
match_config.player_configs = [create_player_config(bot, human_index_tracker) for bot in bot_list]
match_config.script_configs = [create_script_config(script) for script in match_settings['scripts']]

global sm
if sm is not None:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import setuptools

__version__ = '0.0.58'
__version__ = '0.0.59'

with open("README.md", "r") as readme_file:
long_description = readme_file.read()
Expand Down