1+ interface ScreenEvents {
2+ /**
3+ * Calls on the screen being enabled.
4+ * @param ignoreAnimations If the screen should not have an opening animation.
5+ */
6+ "enable" : ( ignoreAnimations : boolean ) => void ,
7+
8+ /**
9+ * Called on the screen being disabled.
10+ */
11+ "disable" : ( ) => void ,
12+
13+ /**
14+ * Called on every frame; use this to render something arbitrary.
15+ * @note This gets called whether the screen is on or off - this may be useful for animations.
16+ */
17+ "render" : ( ) => void ,
18+
19+ /**
20+ * Calls when the screen receives a key event.
21+ * @param key The key code
22+ * @param state The key's state. (true = down, false = up)
23+ * @returns Return `true` to cancel, `false` to pass through
24+ */
25+ "key" : ( key : KeyCode , state : boolean ) => boolean | void ;
26+
27+ /**
28+ * Calls when the screen receives a mouse event.
29+ * @param button The mouse button
30+ * @param wheelDelta Scrolling direction and magnitude if it's a scroll event (positive = scroll up, negative = scroll down)
31+ * @param state The mouse's state (true = down, false = up)
32+ * @returns Return `true` to cancel, `false` to pass through
33+ */
34+ "mouse" : ( button : MouseButton , wheelDelta : number , state : boolean ) => boolean | void ;
35+ }
36+
37+ declare class Screen {
38+ /**
39+ * Creates a screen. Must be registered, otherwise leaks may happen.
40+ * @param name The internal screen name.
41+ */
42+ constructor ( name : string , key : KeyCode ) ;
43+
44+ /**
45+ * The name of the screen
46+ */
47+ readonly name : string ;
48+
49+ /**
50+ * Check if a certain point is hovered (usually by the mouse cursor).
51+ * @note Use this instead of doing your own bounds check, because this may prevent clicking through layered UIs.
52+ * @param rect The rectangle to check bounds
53+ * @param point The point to check (by default, mouse position.)
54+ */
55+ isHover ( rect : Rect , point ?: Vector2 ) : boolean ;
56+
57+ /**
58+ * If the screen is currently on or off
59+ */
60+ isActive ( ) : boolean ;
61+
62+ /**
63+ * Get the key used to activate the screen.
64+ */
65+ getKey ( ) : KeyCode ;
66+
67+ /**
68+ * Set the key used to activate the screen.
69+ * @param key The key code to set to
70+ */
71+ setKey ( key : KeyCode ) : void ;
72+
73+ on : < K extends keyof ScreenEvents > ( eventName : K , handler : ScreenEvents [ K ] ) => void ;
74+
75+
76+ toString ( ) : string ;
77+ }
0 commit comments