Skip to content
Draft
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
5 changes: 5 additions & 0 deletions crates/core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ pub struct Config {
/// honoured only when [`crate::battlenet::signs_in_by_itself`].
#[serde(default = "yes")]
pub battle_net_minimized: bool,
/// Route the main Play button through Battle.net to reuse its saved sign-in.
/// Direct launches remain the default for existing installations.
#[serde(default)]
pub play_via_battle_net: bool,
/// Whether PLAY closes a running Battle.net first. Off by default, so
/// friends and chat stay up.
#[serde(default)]
Expand Down Expand Up @@ -185,6 +189,7 @@ impl Default for Config {
pause_downloads_while_playing: true,
minimize_on_launch: false,
battle_net_minimized: true,
play_via_battle_net: false,
close_battle_net_on_play: false,
battle_net_in_background: false,
battle_net_tweaks: crate::tweaks::Tweaks::default(),
Expand Down
16 changes: 16 additions & 0 deletions crates/launcher-gui/evals/play-login.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Deterministic behavior evaluation. No credentials or live game launch.
set -euo pipefail
cd "$(dirname "$0")/../../.."
checks=(
play_uses_the_configured_login_path
play_login_preference_survives_saving_and_old_configs_stay_direct
saved_login_play_does_not_offer_a_loop_when_battle_net_wants_an_update
a_hand_off_waits_while_the_background_client_signs_in
a_game_lightforge_manages_is_never_updated_through_the_client
stop_asks_first_and_play_comes_back_when_the_game_is_gone
)
for check in "${checks[@]}"; do
cargo test --release --locked -p lightforge-gui "tests::$check" -- --exact
done
printf 'PASS: %s/%s saved-login behavior checks\n' "${#checks[@]}" "${#checks[@]}"
54 changes: 54 additions & 0 deletions crates/launcher-gui/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2131,3 +2131,57 @@ fn a_battle_net_repair_waits_for_a_running_setup() {
let _ = app.update(Message::RepairBattleNet);
assert!(app.error.is_some());
}

/// Exercise the real Play event without executing Proton: addon completion
/// holds the chosen launch intent at the same boundary as a normal launch.
#[test]
fn play_uses_the_configured_login_path() {
for via_client in [false, true] {
let (mut app, _scratch) = test_app();
app.dirs = None;
app.queue.clear();
app.config.play_via_battle_net = via_client;
app.addon_auto_running = true;
app.local = Local {
build_key: Some("abc".to_owned()),
version: Some("11.2.7.65000".to_owned()),
executable: Some(PathBuf::from("/nowhere/Wow.exe")),
store_files: 12,
staged: None,
portal: None,
};
assert!(matches!(app.action(), ActionState::Play));
let _ = app.update(Message::Primary);
assert_eq!(app.launch_after_addons, Some(if via_client {
Launch::BattleNet
} else {
Launch::Game
}));
}
}

#[test]
fn play_login_preference_survives_saving_and_old_configs_stay_direct() {
let (app, _scratch) = test_app();
let file = app.dirs.as_ref().unwrap().config_file();
let legacy = std::fs::read_to_string(&file).unwrap()
.replace("play_via_battle_net = false\n", "");
assert!(!legacy.contains("play_via_battle_net"));
std::fs::write(&file, legacy).unwrap();
assert!(!Config::load_or_default(&file).unwrap().play_via_battle_net);
let mut config = app.config.clone();
config.play_via_battle_net = true;
config.save(&file).unwrap();
assert!(Config::load_or_default(&file).unwrap().play_via_battle_net);
}

#[test]
fn saved_login_play_does_not_offer_a_loop_when_battle_net_wants_an_update() {
let (mut app, _scratch) = test_app();
app.dirs = None;
app.config.play_via_battle_net = true;
let _ = app.update(Message::HandoffStarted(Ok(tasks::Handoff::NeedsUpdate)));
let error = app.error.as_ref().unwrap().to_string();
assert!(error.contains("refresh Lightforge"), "{error}");
assert!(!error.contains("press Play"), "{error}");
}
16 changes: 14 additions & 2 deletions crates/launcher-gui/src/update/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,14 @@ impl Lightforge {
self.pause(&self.selected.code.clone());
Task::none()
}
ActionState::Play => self.preflight(Launch::Game),
ActionState::Play => {
let launch = if self.config.play_via_battle_net {
Launch::BattleNet
} else {
Launch::Game
};
self.preflight(launch)
},
ActionState::Unknown => Task::none(),
// Nothing to download and nothing to repair: look for the
// drive again, and reload the product if it came back.
Expand Down Expand Up @@ -169,7 +176,12 @@ impl Lightforge {
match (Kind::of(&code), self.config.battle_net_in_background) {
// Its store is ours: Agent must not patch it.
(Kind::Managed, _) => {
self.launch_failed("Battle.net wants to update this game — press Play to start it here")
let why = if self.config.play_via_battle_net {
"Battle.net requires a game update — refresh Lightforge and update the game before playing"
} else {
"Battle.net wants to update this game — press Play to start it here"
};
self.launch_failed(why)
}
(Kind::HandOff, false) => {
self.launch_failed("Battle.net has an update for this game — open Battle.net to install it")
Expand Down
31 changes: 31 additions & 0 deletions docs/local-play-login.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Saved login from Play

Set `play_via_battle_net = true` in the top level of Lightforge's
`config.toml` while Lightforge is closed. Play then uses the existing
Battle.net hand-off, including preflight, addon waits and game tracking.
Install, update, pause and Stop retain their existing actions. The default
is false; removing the setting restores direct launches.

Battle.net must have a saved sign-in. Also enable
`battle_net_in_background = true` (Seamless Battle.net Mode), so hiding its
window during the hand-off sends it to the tray instead of quitting it.
Keep `battle_net_minimized = true`
to start it minimized when that saved sign-in is available. Authentication
expiry, two-factor challenges and Battle.net outages can still require
interaction. Lightforge does not store your password.

Verification: the GUI tests exercise both Play routes and configuration
persistence. Existing preflight and Battle.net tests cover readiness and
session tracking. The live check is to restart Lightforge, click Play,
and confirm WoW reaches character selection without entering a password.
A package update can replace this locally built binary; the source branch
retains the change for rebuilding.

Run the deterministic behavior evaluation with
`bash crates/launcher-gui/evals/play-login.sh`. All six checks must pass.

If Battle.net marks a current Lightforge installation as Update, open its
WoW page and let that update finish once. Matching build numbers alone do
not mean Battle.net considers an adopted installation playable. Wait until
its state is UpToDate, then retry Play in Lightforge. Do not work around
this by skipping its update guard or falling back to a password prompt.