一键导入
dialogue-manager
Learn how to use the DialogManager system to display text, ask questions, and manage user interactions in the game.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Learn how to use the DialogManager system to display text, ask questions, and manage user interactions in the game.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | Dialogue Manager |
| description | Learn how to use the DialogManager system to display text, ask questions, and manage user interactions in the game. |
The DialogManager is a global system located in js/systems/dialog_manager.js that handles all text display, user prompts, and sequential dialogue flow. It replaces manual calls to UI.typeText when you need complex interactions like choices or guaranteed sequential execution.
DialogManager methods return a Promise. You MUST await them to pause execution until the dialogue is finished or a choice is made.awaiting is preferred).DialogManager.show)Use DialogManager.show() to display a standard message box. The promise resolves when the text has finished typing and (optionally) the user has pressed a key to advance.
// Simple message that waits for user input (A/Click) to continue
await DialogManager.show("It's a critical hit!");
await DialogManager.show("The wild POKEMON fled!", {
lock: true, // Locks Battle.uiLocked during this message
delay: 1000, // Auto-advance after 1000ms (no user input required if noSkip is true)
noSkip: true, // User cannot skip the delay/text manually
fast: true // Types text at double speed
});
DialogManager.ask)Use DialogManager.ask() to prompt the user with a choice. This is useful for "Yes/No" questions, switching Pokemon, or learning moves.
// Returns the string of the chosen option
const choice = await DialogManager.ask("Do you want to switch Pokemon?", ["Yes", "No"]);
if (choice === "Yes") {
// Handle Yes
} else {
// Handle No
}
const choice = await DialogManager.ask("Teach REST to SNORLAX?", ["Yes", "No"], {
lock: true // Prevents other inputs while the menu is open
});
Both show and ask accept an options object as the last argument:
| Option | Type | Default | Description |
|---|---|---|---|
lock | boolean | false | If true, sets Battle.uiLocked = true while the dialogue is active. Resets it to false (if it was false before) after completion. |
fast | boolean | false | If true, the text types out significantly faster. Good for system messages. |
delay | number | null | If set, the message will auto-advance after this many milliseconds. |
noSkip | boolean | false | If used with delay, prevents the user from skipping the wait time by pressing a key. |
skipWait | boolean | false | If true, the message resolves the moment typing finishes, without waiting for a user keypress or showing an advance arrow. The text remains on screen. Useful for secondary overlays that appear automatically (e.g., Level Up stats). |
targetId | string | 'text-content' | The ID of the HTML element where the text should be typed (e.g., 'evo-text'). |
arrowId | string | 'advance-arrow' | The ID of the blink-arrow element to show while waiting for input (e.g., 'evo-advance-arrow'). |
parentId | string | 'dialog-box' | The container element that should parent the Yes/No choice box (e.g., 'evo-dialog'). |
You can use DialogManager on any screen by providing the relevant target IDs. This ensures consistent typing speed, sounds, and input handling across the entire game.
const evoOptions = {
targetId: 'evo-text',
arrowId: 'evo-advance-arrow',
parentId: 'evo-dialog'
};
await DialogManager.show("Congratulations!", evoOptions);
const choice = await DialogManager.ask("Learn HYPER BEAM?", ["Yes", "No"], evoOptions);
When implementing move logic or turn events, always await the dialogue to ensure the battle doesn't continue while text is typing.
// BAD: Battle continues immediately
DialogManager.show("But it failed!");
return 'FAIL';
// GOOD: Battle pauses until user reads text
await DialogManager.show("But it failed!");
return 'FAIL';
You can simply await multiple calls in sequence.
await DialogManager.show("Welcome to the gym!");
await DialogManager.show("I'm the leader here.");
const ready = await DialogManager.ask("Are you ready?", ["Yes", "No"]);
The DialogManager uses a dynamic Z-index system to ensure prompts remain visible over any other game screen:
#dialog-box sits at z-index: 20.show() or ask() task, the manager lifts the container (default #dialog-box) to z-index: 5000.z-index: 3000.#evo-dialog) are not automatically lifted; their layering must be managed by their respective screens.#text-content).menu-style): An optional class for the dialogue box that provides a white background and black text.
box.classList.add('menu-style') before showing a prompt in non-battle menus (like "NEW GAME" confirmation).const box = document.getElementById('dialog-box');
box.classList.add('menu-style');
await DialogManager.ask("Really start over?", ["Yes", "No"]);
box.classList.remove('menu-style');
Guide for maintaining and adding new battle animations, focusing on specific sequence timing (Entry, Hits, Faints) and the data-driven Animation Framework.
Guide for adding new moves, items, or mechanics to the modular Pokemon Battle system.
Guide for creating new screens and managing transitions using the ScreenManager framework.
Guidelines for maintaining visual consistency across the UI, based on the Summary Screen reference.
Guide for maintaining the modular structure, script order, and global module patterns.