Part of #41: the first of five `benilla-app` pieces. This one is the UI script layer: `ui_script` with its test harnesses, the text engine and layout (`ui_text`), the UI pass and the UI model panes. Its comments are rewritten to the rule in `docs/METHOD.md`, which is what the code does and the reference fact behind it, in a line. 22,041 comment lines become 7,133. - **The mechanical strip.** The citations that were only a private record number go first, and each edit is shown to be a pure removal. - **Wrong facts corrected.** The rewrite corrects the comments that stated wrong facts. Among them: - On a fresh login the reference fires `PLAYER_LOGIN` and `PLAYER_ENTERING_WORLD` from the player's create (`0x5deb60` → `0x4908c0`); only a `/reload` goes through `0x490168`. The comments now state both paths. - `ComputeStep` (`0x5ca2d0`) applies negative pair kerns and rounds up. It does have a kerning term. - A fallback icon global and the retired `UiPanels.xml` panels no longer exist. The comments that named them now describe the stock FrameXML mechanism that replaced them. - Stock FrameXML line citations are checked against the stock 1.12 files and corrected, and several misattributed files are fixed (`MainMenuBarArtFrame` lives in `MainMenuBar.xml`). - Dozens more turned up on the way: docs sitting on the wrong item, removed functions, stale counts and links. - **Deviation labels.** "Deviation:" now marks only a choice with a reason. An unbuilt behaviour says so plainly. - **Verification.** Every file strips to identical code, and `cargo fmt --check` is clean. Five second readers compared every file old against new, restored the facts the rewrite had dropped, and checked each new citation against the code, the stock files, vmangos and the reference. Behaviour differences the rewrite surfaced are filed as their own issues (#183 among them). The comments here state what the code does. String literals are untouched; they are #92. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
101 lines
3.6 KiB
Rust
101 lines
3.6 KiB
Rust
//! The stock escort-quest confirm, `QUEST_ACCEPT`, raised by the `QUEST_ACCEPT_CONFIRM` that
|
|
//! `ui_quest_share`'s feed fires. Yes sends; there is no decline packet.
|
|
|
|
use benilla_ui::script::{ScriptValue, UiScript};
|
|
|
|
use super::test_ui::load_ui as load_xml;
|
|
|
|
fn setup() -> UiScript {
|
|
let mut s = UiScript::new().unwrap();
|
|
s.set_screen_size(1024.0, 768.0);
|
|
load_xml(&s, "Interface\\FrameXML\\Fonts.xml");
|
|
load_xml(&s, r"Interface\FrameXML\MoneyFrame.lua");
|
|
load_xml(&s, r"Interface\FrameXML\MoneyFrame.xml");
|
|
load_xml(&s, r"Interface\FrameXML\UIParent.xml");
|
|
load_xml(&s, r"Interface\FrameXML\UIPanelTemplates.lua");
|
|
load_xml(&s, r"Interface\FrameXML\UIPanelTemplates.xml");
|
|
load_xml(&s, r"Interface\FrameXML\GlobalStrings.lua");
|
|
load_xml(&s, r"Interface\FrameXML\BasicControls.xml");
|
|
load_xml(&s, r"Interface\FrameXML\LocaleProperties.lua");
|
|
load_xml(&s, r"Interface\FrameXML\StaticPopup.xml");
|
|
s
|
|
}
|
|
|
|
fn confirm(s: &mut UiScript, who: &str, quest: &str) {
|
|
s.fire_event(
|
|
"QUEST_ACCEPT_CONFIRM",
|
|
vec![
|
|
ScriptValue::Str(who.to_string()),
|
|
ScriptValue::Str(quest.to_string()),
|
|
],
|
|
);
|
|
}
|
|
|
|
/// `QUEST_ACCEPT` takes the player's name, then the quest title (`GlobalStrings.lua:3227`).
|
|
#[test]
|
|
fn the_confirm_names_the_player_first_and_the_quest_second() {
|
|
benilla_formats::wow_data_or_skip!();
|
|
let mut s = setup();
|
|
confirm(&mut s, "Thrall", "Escort Duty");
|
|
assert!(
|
|
s.eval::<bool>("return StaticPopup1:IsVisible()").unwrap(),
|
|
"QUEST_ACCEPT_CONFIRM shows the confirm popup"
|
|
);
|
|
assert_eq!(
|
|
s.eval::<String>("return StaticPopup1Text:GetText()")
|
|
.unwrap(),
|
|
"Thrall is starting Escort Duty\nWould you like to as well?"
|
|
);
|
|
assert!(s.errors().is_empty(), "script errors: {:?}", s.errors());
|
|
}
|
|
|
|
#[test]
|
|
fn yes_answers_once() {
|
|
benilla_formats::wow_data_or_skip!();
|
|
let mut s = setup();
|
|
confirm(&mut s, "Thrall", "Escort Duty");
|
|
s.run("StaticPopup_OnClick(StaticPopup1, 1)").unwrap();
|
|
assert_eq!(s.take_quest_confirms(), 1);
|
|
assert_eq!(s.take_quest_confirms(), 0, "drained");
|
|
assert!(
|
|
!s.eval::<bool>("return StaticPopup1:IsVisible()").unwrap(),
|
|
"answering closes it"
|
|
);
|
|
}
|
|
|
|
/// The entry has no OnCancel (`StaticPopup.lua:727`): the server's pending latch clears on the
|
|
/// next thing that touches it.
|
|
#[test]
|
|
fn no_and_escape_send_nothing() {
|
|
benilla_formats::wow_data_or_skip!();
|
|
let mut s = setup();
|
|
confirm(&mut s, "Thrall", "Escort Duty");
|
|
s.run("StaticPopup_OnClick(StaticPopup1, 2)").unwrap();
|
|
assert_eq!(s.take_quest_confirms(), 0, "No must not answer the server");
|
|
assert!(!s.eval::<bool>("return StaticPopup1:IsVisible()").unwrap());
|
|
|
|
confirm(&mut s, "Thrall", "Escort Duty");
|
|
s.run("StaticPopup_EscapePressed()").unwrap();
|
|
assert_eq!(s.take_quest_confirms(), 0, "ESC must not answer the server");
|
|
assert!(!s.eval::<bool>("return StaticPopup1:IsVisible()").unwrap());
|
|
}
|
|
|
|
/// The entry is `exclusive` (`StaticPopup.lua:735`), matching the server's one share latch per
|
|
/// player: a newer question replaces the older.
|
|
#[test]
|
|
fn a_second_confirm_replaces_the_first() {
|
|
benilla_formats::wow_data_or_skip!();
|
|
let mut s = setup();
|
|
confirm(&mut s, "Thrall", "Escort Duty");
|
|
confirm(&mut s, "Jaina", "Deeper Still");
|
|
assert_eq!(
|
|
s.eval::<String>("return StaticPopup1Text:GetText()")
|
|
.unwrap(),
|
|
"Jaina is starting Deeper Still\nWould you like to as well?"
|
|
);
|
|
assert!(
|
|
!s.eval::<bool>("return StaticPopup2:IsVisible()").unwrap(),
|
|
"the confirm is exclusive — it reuses the one slot"
|
|
);
|
|
}
|