vanilladocs
vanillapunch.com
API / ui/uiconfirmwindow

ui/uiconfirmwindow

확인 창. (제목, 묻는 글, 취소와 확인 두 단추)

Confirm window. (title, question text, two buttons: cancel and confirm)

UIConfirmWindowextends UIWindow

짝Counterpart: vanilla-engine UIConfirmWindow

확인 창. (제목, 묻는 글, 취소와 확인 두 단추)

  • UIWindow 라 UIWindowLayer 로 띄운다. 묻는 글은 판의 너비에서 줄을 바꾸고 줄 수에 맞춰 판의 세로가 정해진다. 글이 길어 영역의 세로를 넘으면 글 칸만 스크롤되고 두 단추는 늘 보인다.
  • 단추는 왼쪽이 취소, 오른쪽이 확인(강조)이다. 오른쪽에서 왼쪽 언어(setRightToLeft)면 차례를 뒤집는다.
  • 확인을 누르면 확인 알림 뒤 닫힌다. 취소, 바깥 누르기, closeTopWindow, closeAllWindows 로 닫히면 취소 알림이다.
  • 판 모양은 UIWindow 와 같다. 단추와 글의 색은 getConfirmButtonNode() 들로 꺼내 바꾼다.
  • 사용:
const confirmWindow = new UIConfirmWindow("quit", { title: "나가기", message: "정말 나갈까요?", cancelText: "취소", confirmText: "나가기" });
confirmWindow.setConfirmEvent(() => { leave(); });
windowLayer.openWindow(confirmWindow);

Confirm window. (title, question text, two buttons: cancel and confirm)

  • Being a UIWindow, it is opened with UIWindowLayer. The question text wraps at the panel width and the panel height is set by the number of lines. If the text is long and exceeds the area height, only the text box scrolls and the two buttons are always visible.
  • The buttons are cancel on the left and confirm (emphasized) on the right. For right-to-left languages (setRightToLeft) the order is reversed.
  • Pressing confirm closes it after the confirm notification. Closing via cancel, pressing outside, closeTopWindow or closeAllWindows gives the cancel notification.
  • The panel look is the same as UIWindow. Button and text colors are changed by getting the nodes with getConfirmButtonNode() and the like.
  • Usage:
const confirmWindow = new UIConfirmWindow("quit", { title: "Quit", message: "Do you really want to quit?", cancelText: "Cancel", confirmText: "Quit" });
confirmWindow.setConfirmEvent(() => { leave(); });
windowLayer.openWindow(confirmWindow);
예제Example나가기를 묻는 확인 창A confirm window asking to quit
import { Engine, EngineConfiguration, UIScene, UIConfirmWindow, UIWindowLayer } from "./build/vanilla.js";

class ConfirmScene extends UIScene {
	initialize(engine) {
		super.initialize(engine);
		const root = this.getRoot();
		const rootSize = root.getContentSize();
		const windowLayer = new UIWindowLayer();
		root.addChild(windowLayer);
		windowLayer.setViewSize(rootSize.x, rootSize.y);

		const confirmWindow = new UIConfirmWindow("quit", { title: "Quit", message: "Your progress is saved. Quit the game now?", cancelText: "Stay", confirmText: "Quit" });
		confirmWindow.setConfirmEvent(() => {
			console.log("quit");
		});
		confirmWindow.setCancelEvent(() => {
			console.log("stay");
		});
		windowLayer.openWindow(confirmWindow);
	}
}

const engineConfiguration = new EngineConfiguration();
const engine = new Engine(engineConfiguration);
const scene = new ConfirmScene();
scene.setLoadingMinDurationMs(0);
engine.run(scene);
생성자constructorconstructor(name = "UIConfirmWindow", options = {})#0.4.0 부터since 0.4.0소스source

생성.

Constructor.

namestring
창 이름.Window name.
optionsobject
{ title = "", message = "", cancelText = "취소", confirmText = "확인" }
정적staticstatic createBoxNode(nodeName)#0.4.0 부터since 0.4.0소스source

왼쪽 위 피봇의 빈 노드 만들기.

Creates an empty node with a top-left pivot.

nodeNamestring
노드 이름.Node name.

반환ReturnsWorldNode 피봇과 앵커가 왼쪽 위인 새 노드.A new node with its pivot and anchor at the top left.

정적staticstatic createButtonNode(nodeName, labelText, fillColor)#0.4.0 부터since 0.4.0소스source

단추 노드 만들기. (둥근 Paint + UIButton + UILabel)

Creates a button node. (rounded Paint + UIButton + UILabel)

nodeNamestring
노드 이름.Node name.
labelTextstring
단추 글.Button text.
fillColorColor
단추 바탕 색.Button background color.

반환ReturnsWorldNode 단추 노드. (세로 52, 가로는 layoutContent 가 정한다)Button node. (height 52, the width is set by layoutContent)

메서드methodsetTitle(title)#0.4.0 부터since 0.4.0소스source

제목 설정. (빈 글이면 제목 줄을 없앤다, 떠 있으면 다시 놓는다)

Sets the title. (an empty string removes the title line, lays out again if open)

titlestring
제목 글.Title text.

짝Counterpart: vanilla-engine UIConfirmWindow.set_title

메서드methodsetMessage(message)#0.4.0 부터since 0.4.0소스source

묻는 글 설정. (떠 있으면 다시 놓는다)

Sets the question text. (lays out again if open)

messagestring
묻는 글. (판의 너비에서 줄을 바꾼다)Question text. (wrapped to the panel width)

짝Counterpart: vanilla-engine UIConfirmWindow.set_message

메서드methodsetButtonTexts(cancelText, confirmText)#0.4.0 부터since 0.4.0소스source

단추 글 설정.

Sets the button texts.

cancelTextstring
취소 단추 글.Cancel button text.
confirmTextstring
확인 단추 글.Confirm button text.

짝Counterpart: vanilla-engine UIConfirmWindow.set_button_texts

메서드methodsetRightToLeft(isRightToLeft)#0.4.0 부터since 0.4.0소스source

오른쪽에서 왼쪽 언어인지 설정. (참이면 취소가 오른쪽, 확인이 왼쪽, 글은 오른쪽에서 왼쪽으로)

Sets whether the language is right-to-left. (if true, cancel is on the right, confirm on the left, and text runs right to left)

isRightToLeftboolean
참이면 오른쪽에서 왼쪽 언어.If true, a right-to-left language.

짝Counterpart: vanilla-engine UIConfirmWindow.set_right_to_left

메서드methodisRightToLeft()#0.4.0 부터since 0.4.0소스source

오른쪽에서 왼쪽 언어인지.

Whether the language is right-to-left.

반환Returnsboolean 오른쪽에서 왼쪽 언어면 참.True if a right-to-left language.

짝Counterpart: vanilla-engine UIConfirmWindow.is_right_to_left

메서드methodsetConfirmEvent(confirmEvent)#0.4.0 부터since 0.4.0소스source

확인 알림 설정.

Sets the confirm notification.

confirmEventFunction | null
() => void

짝Counterpart: vanilla-engine UIConfirmWindow.set_confirm_event

메서드methodsetCancelEvent(cancelEvent)#0.4.0 부터since 0.4.0소스source

취소 알림 설정. (취소 단추, 바깥 누르기, 창 층이 닫을 때)

Sets the cancel notification. (cancel button, pressing outside, when the window layer closes it)

cancelEventFunction | null
() => void

짝Counterpart: vanilla-engine UIConfirmWindow.set_cancel_event

메서드methodconfirm()#0.4.0 부터since 0.4.0소스source

확인. (확인 알림을 부르고 닫는다, 떠 있지 않으면 아무 일도 없다)

Confirms. (calls the confirm notification and closes, does nothing if not open)

메서드methodhandleClosed()#0.4.0 부터since 0.4.0소스source

창 층에서 내려감. (확인이 아니면 취소 알림)

Removed from the window layer. (cancel notification unless confirmed)

메서드methodrefreshIfOpen()#0.4.0 부터since 0.4.0소스source

떠 있으면 다시 놓기.

Lays out again if open.

메서드methodgetTitleNode()#0.4.0 부터since 0.4.0소스source

제목 노드 반환.

Returns the title node.

반환ReturnsWorldNode 제목 노드. (UILabel 이 붙어 있다)Title node. (has a UILabel attached)

짝Counterpart: vanilla-engine UIConfirmWindow.get_title_node

메서드methodgetMessageNode()#0.4.0 부터since 0.4.0소스source

묻는 글 노드 반환.

Returns the question text node.

반환ReturnsWorldNode 묻는 글 노드. (UILabel 이 붙어 있다)Question text node. (has a UILabel attached)

짝Counterpart: vanilla-engine UIConfirmWindow.get_message_node

메서드methodgetMessageScrollView()#0.4.0 부터since 0.4.0소스source

묻는 글의 스크롤 칸 반환.

Returns the scroll box of the question text.

반환ReturnsUIScrollView 묻는 글의 스크롤 칸. (세로로만 끈다)Scroll view for the question text. (drags only vertically)

메서드methodgetCancelButtonNode()#0.4.0 부터since 0.4.0소스source

취소 단추 노드 반환.

Returns the cancel button node.

반환ReturnsWorldNode 취소 단추 노드. (Paint, UIButton, UILabel 이 붙어 있다)Cancel button node. (has Paint, UIButton and UILabel attached)

짝Counterpart: vanilla-engine UIConfirmWindow.get_cancel_button_node

메서드methodgetConfirmButtonNode()#0.4.0 부터since 0.4.0소스source

확인 단추 노드 반환.

Returns the confirm button node.

반환ReturnsWorldNode 확인 단추 노드. (Paint, UIButton, UILabel 이 붙어 있다)Confirm button node. (has Paint, UIButton and UILabel attached)

짝Counterpart: vanilla-engine UIConfirmWindow.get_confirm_button_node

메서드methodmeasureMessageHeight(textWidth)#0.4.0 부터since 0.4.0소스source

그 너비로 줄을 바꿨을 때 묻는 글의 세로.

Height of the question text when wrapped at that width.

textWidthnumber
줄을 바꿀 너비. (UI 층 단위, 글의 줄바꿈 너비로도 넣는다)Width to wrap at. (UI layer units, also set as the text's word wrap width)

반환Returnsnumber 묻는 글의 세로. (UI 층 단위, 올림)Height of the question text. (UI layer units, rounded up)

메서드methodlayoutContent(panelWidth)#0.4.0 부터since 0.4.0소스source

내용 놓기. (제목 → 글 스크롤 칸 → 두 단추, 판의 세로를 돌려준다)

Lays out the content. (title → text scroll box → two buttons, returns the panel's height)

panelWidthnumber
판의 너비. (UI 층 단위)Panel width. (UI layer units)

반환Returnsnumber 판의 세로. (UI 층 단위, 여백, 제목, 글 칸, 단추 줄을 더한 값)Panel height. (UI layer units, the sum of the padding, title, text area and button row)