Skip to content

Commit 3248c13

Browse files
tarehartDarxeal
andauthored
Allowing users to set their launcher preferences (steam vs epic). (#123)
Co-authored-by: Darxeal <[email protected]>
1 parent 7ef50f7 commit 3248c13

14 files changed

+148
-35
lines changed

rlbot_gui/gui.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
from rlbot_gui.match_runner.match_runner import hot_reload_bots, shut_down, start_match_helper, \
2929
do_infinite_loop_content, spawn_car_in_showroom, set_game_state, fetch_game_tick_packet
3030
from rlbot_gui.type_translation.packet_translation import convert_packet_to_dict
31+
from rlbot_gui.persistence.settings import load_settings, BOT_FOLDER_SETTINGS_KEY, MATCH_SETTINGS_KEY, \
32+
LAUNCHER_SETTINGS_KEY, TEAM_SETTINGS_KEY, load_launcher_settings, launcher_preferences_from_map
3133

3234
#### LOAD JUST TO EXPOSE STORY_MODE
3335
from rlbot_gui.story import story_runner
@@ -40,20 +42,15 @@
4042
BOTPACK_REPO_NAME = 'RLBotPack'
4143
BOTPACK_REPO_BRANCH = 'master'
4244
CREATED_BOTS_FOLDER = 'MyBots'
43-
BOT_FOLDER_SETTINGS_KEY = 'bot_folder_settings'
44-
MATCH_SETTINGS_KEY = 'match_settings'
45-
TEAM_SETTINGS_KEY = 'team_settings'
4645
COMMIT_ID_KEY = 'latest_botpack_commit_id'
4746
bot_folder_settings = None
4847

4948

50-
def load_settings() -> QSettings:
51-
return QSettings('rlbotgui', 'preferences')
52-
53-
5449
@eel.expose
5550
def start_match(bot_list, match_settings):
56-
eel.spawn(start_match_helper, bot_list, match_settings)
51+
launcher_preference_map = load_launcher_settings()
52+
launcher_prefs = launcher_preferences_from_map(launcher_preference_map)
53+
eel.spawn(start_match_helper, bot_list, match_settings, launcher_prefs)
5754

5855

5956
@eel.expose
@@ -68,7 +65,7 @@ def pick_bot_folder():
6865
if filename:
6966
global bot_folder_settings
7067
bot_folder_settings['folders'][filename] = {'visible': True}
71-
settings = QSettings('rlbotgui', 'preferences')
68+
settings = load_settings()
7269
settings.setValue(DEFAULT_BOT_FOLDER, filename)
7370
settings.setValue(BOT_FOLDER_SETTINGS_KEY, bot_folder_settings)
7471
settings.sync()
@@ -171,6 +168,11 @@ def get_match_settings():
171168
return match_settings if match_settings else None
172169

173170

171+
@eel.expose
172+
def get_launcher_settings():
173+
return load_launcher_settings()
174+
175+
174176
@eel.expose
175177
def get_team_settings():
176178
settings = load_settings()
@@ -190,6 +192,12 @@ def save_match_settings(match_settings):
190192
settings.setValue(MATCH_SETTINGS_KEY, match_settings)
191193

192194

195+
@eel.expose
196+
def save_launcher_settings(launcher_settings_map):
197+
settings = load_settings()
198+
settings.setValue(LAUNCHER_SETTINGS_KEY, launcher_settings_map)
199+
200+
193201
@eel.expose
194202
def save_team_settings(blue_bots, orange_bots):
195203
settings = load_settings()
@@ -281,7 +289,9 @@ def save_looks(looks: dict, path: str):
281289
def spawn_car_for_viewing(looks: dict, team: int, showcase_type: str, map_name: str):
282290
looks_config = convert_to_looks_config(looks)
283291
loadout_config = load_bot_appearance(looks_config, team)
284-
spawn_car_in_showroom(loadout_config, team, showcase_type, map_name)
292+
launcher_settings_map = get_launcher_settings()
293+
launcher_prefs = launcher_preferences_from_map(launcher_settings_map)
294+
spawn_car_in_showroom(loadout_config, team, showcase_type, map_name, launcher_prefs)
285295

286296

287297
@eel.expose

rlbot_gui/gui/css/style.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ button.icon-button {
296296
width: initial;
297297
}
298298

299-
#javascript-trouble {
299+
.platform-icon {
300+
height: 1em;
301+
}
300302

303+
.btn-dark .platform-icon {
304+
filter: invert()
301305
}

rlbot_gui/gui/imgs/epic.png

8.43 KB
Loading

rlbot_gui/gui/imgs/steam.png

5.89 KB
Loading
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
export default {
2+
name: 'launcher-preference',
3+
props: ['modalId'],
4+
template: `
5+
<div>
6+
<div>
7+
<b-form-group>
8+
<b-form-radio v-model="launcherSettings.preferred_launcher" name="launcher-radios" value="steam">Steam</b-form-radio>
9+
<b-form-radio v-model="launcherSettings.preferred_launcher" name="launcher-radios" value="epic">Epic Games</b-form-radio>
10+
<b-form-checkbox
11+
class="ml-4"
12+
v-model="launcherSettings.use_login_tricks"
13+
:disabled="launcherSettings.preferred_launcher !== 'epic'">
14+
15+
Use Epic Login Tricks <b-icon class="warning-icon" icon="exclamation-triangle-fill" v-b-tooltip.hover
16+
title="If you choose this, we'll do some fancy things to make sure your Epic account logs in successfully and loads your car + camera settings.
17+
It might look slightly weird on the Epic login server but they probably won't care."></b-icon>
18+
</b-form-checkbox>
19+
</b-form-group>
20+
</div>
21+
<b-button variant="primary" class="mt-3" @click="saveLauncherSettings()">Save</b-button>
22+
</div>
23+
`,
24+
data () {
25+
return {
26+
launcherSettings: { preferred_launcher: 'epic', use_login_tricks: false },
27+
}
28+
},
29+
30+
methods: {
31+
launcherSettingsReceived: function (launcherSettings) {
32+
if (launcherSettings) {
33+
Object.assign(this.launcherSettings, launcherSettings);
34+
}
35+
},
36+
saveLauncherSettings: function () {
37+
eel.save_launcher_settings(this.launcherSettings);
38+
this.$bvModal.hide(this.modalId);
39+
},
40+
},
41+
created: function () {
42+
eel.get_launcher_settings()(this.launcherSettingsReceived);
43+
},
44+
watch: {
45+
'launcherSettings.preferred_launcher': function(newVal) {
46+
if (newVal === 'steam') {
47+
this.launcherSettings.use_login_tricks = false;
48+
}
49+
}
50+
},
51+
}

rlbot_gui/gui/js/main-vue.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import AppearanceEditor from './appearance-editor-vue.js'
22
import MutatorField from './mutator-field-vue.js'
33
import BotCard from './bot-card-vue.js'
4+
import LauncherPreferenceModal from './launcher-preference-vue.js'
45

56
const HUMAN = {'name': 'Human', 'type': 'human', 'image': 'imgs/human.png'};
67
const STARTING_BOT_POOL = [
@@ -25,7 +26,7 @@ export default {
2526
<b-spinner v-if="showProgressSpinner" variant="success" label="Spinning" class="mr-2"></b-spinner>
2627
<span id="sandbox-button-wrapper">
2728
<b-button
28-
@click="$router.replace('/sandbox')" variant="dark"
29+
@click="$router.replace('/sandbox')" variant="dark" class="ml-2"
2930
:disabled="!matchSettings.enable_state_setting">
3031
State Setting Sandbox
3132
</b-button>
@@ -194,6 +195,10 @@ export default {
194195
195196
<b-button class="ml-4" v-b-modal.mutators-modal>Mutators</b-button>
196197
<b-button class="ml-2" v-b-modal.extra-modal>Extra</b-button>
198+
<b-button class="ml-2" v-b-modal.launcher-modal>
199+
<img class="platform-icon" src="imgs/steam.png" /> /
200+
<img class="platform-icon" src="imgs/epic.png" />
201+
</b-button>
197202
198203
<span style="flex-grow: 1"></span>
199204
@@ -208,13 +213,13 @@ export default {
208213
</div>
209214
210215
<b-modal title="Extra Options" id="extra-modal" size="md" hide-footer centered>
211-
<div><b-form-checkbox v-model="matchSettings.enable_rendering">Enable Rendering (bots can draw on screen)</b-form-checkbox></div>
212-
<div><b-form-checkbox v-model="matchSettings.enable_state_setting">Enable State Setting (bots can teleport)</b-form-checkbox></div>
213-
<div><b-form-checkbox v-model="matchSettings.auto_save_replay">Auto Save Replay</b-form-checkbox></div>
214-
<div><b-form-checkbox v-model="matchSettings.skip_replays">Skip Replays</b-form-checkbox></div>
215-
<div><b-form-checkbox v-model="matchSettings.instant_start">Instant Start</b-form-checkbox></div>
216-
<div><b-form-checkbox v-model="matchSettings.enable_lockstep">Enable Lockstep</b-form-checkbox></div>
217-
<mutator-field label="Existing Match Behaviour" :options="matchOptions.match_behaviours" v-model="matchSettings.match_behavior" class="mt-3"></mutator-field>
216+
<div><b-form-checkbox v-model="matchSettings.enable_rendering">Enable Rendering (bots can draw on screen)</b-form-checkbox></div>
217+
<div><b-form-checkbox v-model="matchSettings.enable_state_setting">Enable State Setting (bots can teleport)</b-form-checkbox></div>
218+
<div><b-form-checkbox v-model="matchSettings.auto_save_replay">Auto Save Replay</b-form-checkbox></div>
219+
<div><b-form-checkbox v-model="matchSettings.skip_replays">Skip Replays</b-form-checkbox></div>
220+
<div><b-form-checkbox v-model="matchSettings.instant_start">Instant Start</b-form-checkbox></div>
221+
<div><b-form-checkbox v-model="matchSettings.enable_lockstep">Enable Lockstep</b-form-checkbox></div>
222+
<mutator-field label="Existing Match Behaviour" :options="matchOptions.match_behaviours" v-model="matchSettings.match_behavior" class="mt-3"></mutator-field>
218223
</b-modal>
219224
220225
<b-modal id="mutators-modal" title="Mutators" size="lg" hide-footer centered>
@@ -375,6 +380,10 @@ export default {
375380
v-bind:path="appearancePath"
376381
v-bind:map="matchSettings.map"
377382
id="appearance-editor-dialog" />
383+
384+
<b-modal title="Preferred Rocket League Launcher" id="launcher-modal" size="md" hide-footer centered>
385+
<launcher-preference-modal modal-id="launcher-modal" />
386+
</b-modal>
378387
379388
</div>
380389
@@ -385,6 +394,7 @@ export default {
385394
'appearance-editor': AppearanceEditor,
386395
'mutator-field': MutatorField,
387396
'bot-card': BotCard,
397+
'launcher-preference-modal': LauncherPreferenceModal,
388398
},
389399
data () {
390400
return {
@@ -710,5 +720,5 @@ export default {
710720
self.downloadStatus = status;
711721
self.downloadProgressPercent = progress;
712722
}
713-
},
723+
}
714724
};

rlbot_gui/gui/js/story-mode-start.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import Colorpicker from './colorpicker-vue.js'
2+
import LauncherPreferenceModal from './launcher-preference-vue.js'
23

34
export default {
45
name: 'story-start',
56
components: {
67
'colorpicker': Colorpicker,
8+
'launcher-preference-modal': LauncherPreferenceModal,
79
},
810
template: /*html*/`
911
<b-container class="pt-5">
@@ -36,12 +38,21 @@ export default {
3638
<span>{{this.form.custom_story.storyPath}}</span>
3739
</b-form-group>
3840
</b-form-group>
39-
41+
42+
<b-form-group label="Launcher" label-cols="auto">
43+
<b-button v-b-modal.launcher-modal-story>
44+
Choose Steam or Epic
45+
</b-button>
46+
</b-form-group>
4047
4148
<b-button type="submit" variant="primary" class="mt-2">Get Started</b-button>
4249
</b-form>
4350
</b-card-text>
4451
</b-card>
52+
<b-modal title="Preferred Rocket League Launcher" id="launcher-modal-story" size="md" hide-footer centered>
53+
<!-- Modal id is intentionally different from the one on the main page in main-vue.js-->
54+
<launcher-preference-modal modal-id="launcher-modal-story" />
55+
</b-modal>
4556
</b-container>
4657
`,
4758
data() {

rlbot_gui/gui/js/story-pick-team.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default {
2424
>
2525
<div class="d-block text-center">
2626
<div v-if="!enoughAvailableTeammates">
27-
<p>You do not have enough teamamtes to create a team for this challenge.
27+
<p>You do not have enough teammates to create a team for this challenge.
2828
Recruit teammates from the "teammate" tab or play older matches to earn
2929
more currency</p>
3030
@@ -91,4 +91,4 @@ export default {
9191
this.pickedTeammates = [];
9292
}
9393
}
94-
};
94+
};

rlbot_gui/match_runner/match_runner.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from math import pi
2+
from typing import List
23

34
from rlbot.gateway_util import NetworkingRole
45
from rlbot.matchconfig.loadout_config import LoadoutConfig
56
from rlbot.matchconfig.match_config import PlayerConfig, MatchConfig, MutatorConfig, ScriptConfig
67
from rlbot.parsing.incrementing_integer import IncrementingInteger
7-
from rlbot.setup_manager import SetupManager
8+
from rlbot.setup_manager import SetupManager, RocketLeagueLauncherPreference
89
from rlbot.utils.structures.bot_input_struct import PlayerInput
910
from rlbot.utils.game_state_util import GameState, CarState, BallState, Physics, Vector3, Rotator
1011
from rlbot.utils.structures.game_data_struct import GameTickPacket
@@ -14,7 +15,7 @@
1415
sm: SetupManager = None
1516

1617

17-
def create_player_config(bot, human_index_tracker: IncrementingInteger):
18+
def create_player_config(bot: dict, human_index_tracker: IncrementingInteger):
1819
player_config = PlayerConfig()
1920
player_config.bot = bot['type'] in ('rlbot', 'psyonix')
2021
player_config.rlbot_controlled = bot['type'] in ('rlbot', 'party_member_bot')
@@ -30,7 +31,8 @@ def create_script_config(script):
3031
return ScriptConfig(script['path'])
3132

3233

33-
def spawn_car_in_showroom(loadout_config: LoadoutConfig, team: int, showcase_type: str, map_name: str):
34+
def spawn_car_in_showroom(loadout_config: LoadoutConfig, team: int, showcase_type: str, map_name: str,
35+
launcher_prefs: RocketLeagueLauncherPreference):
3436
match_config = MatchConfig()
3537
match_config.game_mode = 'Soccer'
3638
match_config.game_map = map_name
@@ -54,7 +56,7 @@ def spawn_car_in_showroom(loadout_config: LoadoutConfig, team: int, showcase_typ
5456
global sm
5557
if sm is None:
5658
sm = SetupManager()
57-
sm.connect_to_game()
59+
sm.connect_to_game(launcher_preference=launcher_prefs)
5860
sm.load_match_config(match_config)
5961
sm.start_match()
6062

@@ -129,7 +131,7 @@ def get_fresh_setup_manager():
129131
return sm
130132

131133

132-
def start_match_helper(bot_list, match_settings):
134+
def start_match_helper(bot_list: List[dict], match_settings: dict, launcher_prefs: RocketLeagueLauncherPreference):
133135
print(bot_list)
134136
print(match_settings)
135137

@@ -169,7 +171,7 @@ def start_match_helper(bot_list, match_settings):
169171

170172
sm = get_fresh_setup_manager()
171173
sm.early_start_seconds = 5
172-
sm.connect_to_game()
174+
sm.connect_to_game(launcher_preference=launcher_prefs)
173175
sm.load_match_config(match_config)
174176
sm.launch_early_start_bot_processes()
175177
sm.start_match()

rlbot_gui/persistence/__init__.py

Whitespace-only changes.

rlbot_gui/persistence/settings.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from PyQt5.QtCore import QSettings
2+
from rlbot.setup_manager import DEFAULT_LAUNCHER_PREFERENCE, RocketLeagueLauncherPreference
3+
4+
BOT_FOLDER_SETTINGS_KEY = 'bot_folder_settings'
5+
MATCH_SETTINGS_KEY = 'match_settings'
6+
LAUNCHER_SETTINGS_KEY = 'launcher_settings'
7+
TEAM_SETTINGS_KEY = 'team_settings'
8+
9+
10+
def load_settings() -> QSettings:
11+
return QSettings('rlbotgui', 'preferences')
12+
13+
14+
def launcher_preferences_from_map(launcher_preference_map: dict) -> RocketLeagueLauncherPreference:
15+
return RocketLeagueLauncherPreference(launcher_preference_map['preferred_launcher'],
16+
launcher_preference_map['use_login_tricks'])
17+
18+
19+
def load_launcher_settings():
20+
settings = load_settings()
21+
launcher_settings = settings.value(LAUNCHER_SETTINGS_KEY, type=dict)
22+
return launcher_settings if launcher_settings else DEFAULT_LAUNCHER_PREFERENCE.__dict__

rlbot_gui/story/story_challenge_setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
MutatorConfig,
2828
Team,
2929
)
30-
from rlbot.setup_manager import SetupManager
30+
from rlbot.setup_manager import SetupManager, RocketLeagueLauncherPreference
3131

3232
from rlbot_gui.match_runner.match_runner import get_fresh_setup_manager
3333
from rlbot_gui import gui as rlbot_gui # TODO: Need to remove circular import
@@ -430,12 +430,12 @@ def manage_game_state(
430430

431431

432432
def run_challenge(
433-
match_config: MatchConfig, challenge: dict, upgrades: dict
433+
match_config: MatchConfig, challenge: dict, upgrades: dict, launcher_pref: RocketLeagueLauncherPreference
434434
) -> Tuple[bool, dict]:
435435
"""Launch the game and keep track of the state"""
436436
setup_manager = get_fresh_setup_manager()
437437
setup_manager.early_start_seconds = 5
438-
setup_manager.connect_to_game()
438+
setup_manager.connect_to_game(launcher_preference=launcher_pref)
439439
setup_manager.load_match_config(match_config)
440440
setup_manager.launch_early_start_bot_processes()
441441
setup_manager.start_match()

0 commit comments

Comments
 (0)