ui/uidialog
확인 대화 상자.
Confirmation dialog.
UIDialogextends WorldNode
확인 대화 상자.
- 어둡게 가리는 막 + 가운데 카드 + 확인 / 취소 단추를 한 번의 show() 로 띄운다. 등장 / 퇴장은 PopupMotion(되튕김 확대 / 수축)으로 움직인다.
- 막을 누르면 취소로 처리한다. onCancel 을 넘기지 않으면 확인만 있는 알림이 된다.
- 씬 뿌리의 맨 위(마지막 자식)에 addChild 해 두고 쓴다.
- 사용:
const dialog = new UIDialog();
scene.getRoot().addChild(dialog);
dialog.show("정말 삭제할까요?", { onConfirm: () => remove(), onCancel: () => {} });Confirmation dialog.
- Pops up a darkening overlay + a centered card + confirm / cancel buttons with a single show(). Entrance / exit animate with PopupMotion (bounce scale up / shrink).
- Pressing the overlay counts as cancel. If onCancel is not passed, it becomes a confirm-only alert.
- addChild it at the top (last child) of the scene root before use.
- Usage:
const dialog = new UIDialog();
scene.getRoot().addChild(dialog);
dialog.show("Really delete?", { onConfirm: () => remove(), onCancel: () => {} });import { Engine, EngineConfiguration, UIScene, UIDialog } from "./build/vanilla.js";
class DialogScene extends UIScene {
initialize(engine) {
super.initialize(engine);
const dialog = new UIDialog({ width: 360, height: 200, confirmText: "Delete", cancelText: "Keep" });
const root = this.getRoot();
root.addChild(dialog);
dialog.show("Delete this save file?", {
onConfirm: () => {
console.log("deleted");
},
onCancel: () => {
console.log("kept");
},
});
}
}
const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
const scene = new DialogScene();
scene.setLoadingMinDurationMs(0);
engine.run(scene);생성.
Constructor.
- optionsobject
- { width = 420, height = 240, confirmText = "확인", cancelText = "취소", panelColor?, accentColor?, textColor? }
짝Counterpart: vanilla-engine UIDialog.new
대화 상자 열기.
- onCancel 을 넘기지 않으면 취소 단추를 감추고 확인 단추를 가운데로 넓힌다.
Opens the dialog.
- If onCancel is not passed, hides the cancel button and widens the confirm button to the center.
- messageTextstring
- 본문 글. (카드 너비에 맞춰 줄을 바꾼다)Body text. (wrapped to the card width)
- optionsobject
- { onConfirm?, onCancel?, confirmText?, cancelText? }
짝Counterpart: vanilla-engine UIDialog.show
닫기. (isConfirmed 에 따라 확인 / 취소 처리를 부른다)
Close. (calls the confirm / cancel handler depending on isConfirmed)
- isConfirmedboolean
- 참이면 onConfirm, 거짓이면 onCancel 을 부른다. (다 열리기 전이면 아무것도 하지 않는다)If true, calls onConfirm, if false, calls onCancel. (does nothing before it has fully opened)
짝Counterpart: vanilla-engine UIDialog.dismiss
다음 tick 에 닫기. (tick 밖에서 닫기를 미룰 때)
Closes on the next tick. (to defer closing from outside tick)
- isConfirmedboolean
- 참이면 확인, 거짓이면 취소로 닫는다.If true, closes as confirmed, if false, as cancelled.
짝Counterpart: vanilla-engine UIDialog.request_dismiss
갱신.
Update.
- timeDeltanumber
- 지난 프레임부터의 시간. (초)Time since the last frame. (Seconds)
표시 중 여부.
Whether it is showing.
반환Returnsboolean 닫힘 상태가 아니면 참. (여는 중, 닫는 중도 참)True unless in the closed state. (also true while opening or closing)
짝Counterpart: vanilla-engine UIDialog.is_showing
즉시 전환 여부 설정. (연출 없는 UI 톤)
Sets whether to switch instantly. (UI tone without effects)
- isInstantEnabledboolean
- 참이면 연출 없이 바로 열고 닫는다.If true, opens and closes immediately without animation.
짝Counterpart: vanilla-engine UIDialog.set_instant_enabled
연출 반환.
Returns the motion.
반환ReturnsPopupMotion 여닫는 연출.Open and close motion.
짝Counterpart: vanilla-engine UIDialog.get_popup_motion
뒤를 덮는 막 노드 반환.
Returns the overlay node that covers what is behind.
반환ReturnsWorldNode 막 노드.Overlay node.
짝Counterpart: vanilla-engine UIDialog.get_overlay_node
판 노드 반환.
Returns the panel node.
반환ReturnsWorldNode 판 노드.Panel node.
짝Counterpart: vanilla-engine UIDialog.get_panel_node
확인 단추 노드 반환.
Returns the confirm button node.
반환ReturnsWorldNode 확인 단추 노드.Confirm button node.
짝Counterpart: vanilla-engine UIDialog.get_confirm_node
import { UIDialog } from "./build/vanilla.js";
const dialog = new UIDialog({ confirmText: "OK", cancelText: "Cancel" });
const confirmNode = dialog.getConfirmNode();
const cancelNode = dialog.getCancelNode();
console.log(confirmNode.getName(), cancelNode.getName(), dialog.getPanelNode().getName());취소 단추 노드 반환.
Returns the cancel button node.
반환ReturnsWorldNode 취소 단추 노드.Cancel button node.
짝Counterpart: vanilla-engine UIDialog.get_cancel_node