narraleaf-react 0.4.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -33
- package/dist/game/nlcore/action/action.d.ts +29 -24
- package/dist/game/nlcore/action/actionHistory.d.ts +48 -37
- package/dist/game/nlcore/action/actionTypes.d.ts +142 -140
- package/dist/game/nlcore/action/actionable.d.ts +5 -5
- package/dist/game/nlcore/action/actions/characterAction.d.ts +19 -17
- package/dist/game/nlcore/action/actions/conditionAction.d.ts +26 -17
- package/dist/game/nlcore/action/actions/controlAction.d.ts +26 -38
- package/dist/game/nlcore/action/actions/displayableAction.d.ts +26 -22
- package/dist/game/nlcore/action/actions/imageAction.d.ts +25 -22
- package/dist/game/nlcore/action/actions/layerAction.d.ts +16 -12
- package/dist/game/nlcore/action/actions/menuAction.d.ts +21 -16
- package/dist/game/nlcore/action/actions/persistentAction.d.ts +17 -13
- package/dist/game/nlcore/action/actions/sceneAction.d.ts +47 -44
- package/dist/game/nlcore/action/actions/scriptAction.d.ts +14 -10
- package/dist/game/nlcore/action/actions/soundAction.d.ts +20 -18
- package/dist/game/nlcore/action/actions/storyAction.d.ts +8 -8
- package/dist/game/nlcore/action/actions/textAction.d.ts +16 -14
- package/dist/game/nlcore/action/actions/videoAction.d.ts +26 -22
- package/dist/game/nlcore/action/actions.d.ts +20 -13
- package/dist/game/nlcore/action/baseElement.d.ts +2 -2
- package/dist/game/nlcore/action/chain.d.ts +17 -17
- package/dist/game/nlcore/action/constructable.d.ts +5 -5
- package/dist/game/nlcore/action/gameHistory.d.ts +32 -28
- package/dist/game/nlcore/action/logicAction.d.ts +52 -52
- package/dist/game/nlcore/action/serviceAction.d.ts +24 -11
- package/dist/game/nlcore/action/srcManager.d.ts +47 -47
- package/dist/game/nlcore/action/stackModel.d.ts +106 -0
- package/dist/game/nlcore/action/tree/actionTree.d.ts +56 -56
- package/dist/game/nlcore/common/Utils.d.ts +25 -25
- package/dist/game/nlcore/common/core.d.ts +8 -8
- package/dist/game/nlcore/common/elements.d.ts +19 -19
- package/dist/game/nlcore/common/game.d.ts +8 -7
- package/dist/game/nlcore/common/player.d.ts +7 -7
- package/dist/game/nlcore/common/position.d.ts +2 -2
- package/dist/game/nlcore/common/transition.d.ts +6 -6
- package/dist/game/nlcore/common/types.d.ts +9 -9
- package/dist/game/nlcore/elements/character/pause.d.ts +8 -8
- package/dist/game/nlcore/elements/character/sentence.d.ts +25 -25
- package/dist/game/nlcore/elements/character/word.d.ts +18 -18
- package/dist/game/nlcore/elements/character.d.ts +56 -51
- package/dist/game/nlcore/elements/condition.d.ts +20 -20
- package/dist/game/nlcore/elements/control.d.ts +76 -76
- package/dist/game/nlcore/elements/displayable/displayable.d.ts +76 -76
- package/dist/game/nlcore/elements/displayable/image.d.ts +102 -91
- package/dist/game/nlcore/elements/displayable/text.d.ts +74 -74
- package/dist/game/nlcore/elements/layer.d.ts +33 -23
- package/dist/game/nlcore/elements/menu.d.ts +45 -43
- package/dist/game/nlcore/elements/persistent/storable.d.ts +24 -24
- package/dist/game/nlcore/elements/persistent/type.d.ts +3 -3
- package/dist/game/nlcore/elements/persistent.d.ts +86 -86
- package/dist/game/nlcore/elements/scene.d.ts +76 -76
- package/dist/game/nlcore/elements/script.d.ts +16 -16
- package/dist/game/nlcore/elements/service.d.ts +59 -59
- package/dist/game/nlcore/elements/sound.d.ts +89 -75
- package/dist/game/nlcore/elements/story.d.ts +92 -78
- package/dist/game/nlcore/elements/transform/position.d.ts +99 -101
- package/dist/game/nlcore/elements/transform/transform.d.ts +119 -119
- package/dist/game/nlcore/elements/transform/type.d.ts +32 -32
- package/dist/game/nlcore/elements/transition/transition.d.ts +29 -29
- package/dist/game/nlcore/elements/transition/transitions/image/darkness.d.ts +20 -0
- package/dist/game/nlcore/elements/transition/transitions/image/dissolve.d.ts +17 -17
- package/dist/game/nlcore/elements/transition/transitions/image/fadeIn.d.ts +20 -20
- package/dist/game/nlcore/elements/transition/transitions/image/imageTransition.d.ts +28 -28
- package/dist/game/nlcore/elements/transition/transitions/text/fontSize.d.ts +13 -13
- package/dist/game/nlcore/elements/transition/transitions/text/textTransition.d.ts +10 -10
- package/dist/game/nlcore/elements/transition/type.d.ts +51 -51
- package/dist/game/nlcore/elements/type.d.ts +16 -15
- package/dist/game/nlcore/elements/video.d.ts +23 -23
- package/dist/game/nlcore/game/liveGame.d.ts +148 -124
- package/dist/game/nlcore/game/plugin/plugin.d.ts +16 -16
- package/dist/game/nlcore/game/preference.d.ts +32 -32
- package/dist/game/nlcore/game.d.ts +79 -90
- package/dist/game/nlcore/gameTypes.d.ts +439 -334
- package/dist/game/nlcore/types.d.ts +67 -66
- package/dist/game/player/Tasks.d.ts +125 -106
- package/dist/game/player/elements/Player.d.ts +4 -4
- package/dist/game/player/elements/displayable/Displayable.d.ts +1 -1
- package/dist/game/player/elements/displayable/Displayables.d.ts +1 -1
- package/dist/game/player/elements/displayable/Text.d.ts +1 -1
- package/dist/game/player/elements/displayable/type.d.ts +1 -1
- package/dist/game/player/elements/elements.d.ts +8 -8
- package/dist/game/player/elements/image/AspectScaleImage.d.ts +1 -1
- package/dist/game/player/elements/image/Image.d.ts +3 -3
- package/dist/game/player/elements/menu/PlayerMenu.d.ts +3 -3
- package/dist/game/player/elements/menu/UIMenu/Item.d.ts +12 -12
- package/dist/game/player/elements/menu/UIMenu/Menu.d.ts +6 -6
- package/dist/game/player/elements/menu/UIMenu/context.d.ts +23 -23
- package/dist/game/player/elements/menu/type.d.ts +16 -16
- package/dist/game/player/elements/notification/Notifications.d.ts +3 -3
- package/dist/game/player/elements/notification/PlayerNotification.d.ts +4 -4
- package/dist/game/player/elements/notification/context.d.ts +11 -11
- package/dist/game/player/elements/notification/type.d.ts +18 -19
- package/dist/game/player/elements/player/KeyEventAnnouncer.d.ts +1 -1
- package/dist/game/player/elements/player/Layer.d.ts +8 -8
- package/dist/game/player/elements/player/PreferenceUpdateAnnouncer.d.ts +4 -0
- package/dist/game/player/elements/player/RenderEventAnnoucer.d.ts +4 -0
- package/dist/game/player/elements/player/SizeUpdateAnnouncer.d.ts +1 -1
- package/dist/game/player/elements/preload/Preload.d.ts +1 -1
- package/dist/game/player/elements/say/Dialog.d.ts +13 -13
- package/dist/game/player/elements/say/Nametag.d.ts +2 -2
- package/dist/game/player/elements/say/Sentence.d.ts +37 -37
- package/dist/game/player/elements/say/UIDialog.d.ts +72 -69
- package/dist/game/player/elements/say/context.d.ts +4 -4
- package/dist/game/player/elements/say/type.d.ts +53 -53
- package/dist/game/player/elements/say/useDialog.d.ts +18 -16
- package/dist/game/player/elements/scene/Scene.d.ts +1 -1
- package/dist/game/player/elements/type.d.ts +53 -53
- package/dist/game/player/elements/video/video.d.ts +1 -1
- package/dist/game/player/gameState.d.ts +193 -186
- package/dist/game/player/gameState.type.d.ts +1 -1
- package/dist/game/player/guard.d.ts +24 -24
- package/dist/game/player/lib/AspectRatio.d.ts +7 -7
- package/dist/game/player/lib/AudioManager.d.ts +50 -42
- package/dist/game/player/lib/Cursor.d.ts +6 -6
- package/dist/game/player/lib/ErrorBoundary.d.ts +24 -24
- package/dist/game/player/lib/ErrorFallback.d.ts +5 -5
- package/dist/game/player/lib/ImageCacheManager.d.ts +26 -26
- package/dist/game/player/lib/Inspect.d.ts +36 -36
- package/dist/game/player/lib/PageRouter/AnimatePresence.d.ts +4 -0
- package/dist/game/player/lib/PageRouter/Page.d.ts +9 -9
- package/dist/game/player/lib/PageRouter/PageRouter.d.ts +27 -27
- package/dist/game/player/lib/PageRouter/Stage.d.ts +6 -6
- package/dist/game/player/lib/PageRouter/router.d.ts +28 -23
- package/dist/game/player/lib/PlayerFrames.d.ts +10 -10
- package/dist/game/player/lib/Preloaded.d.ts +48 -48
- package/dist/game/player/lib/flush.d.ts +5 -5
- package/dist/game/player/lib/isolated.d.ts +7 -7
- package/dist/game/player/lib/notification.d.ts +47 -47
- package/dist/game/player/lib/preferences.d.ts +8 -8
- package/dist/game/player/lib/useElementVisibility.d.ts +5 -5
- package/dist/game/player/lib/useExposeState.d.ts +10 -10
- package/dist/game/player/lib/useLiveGame.d.ts +1 -1
- package/dist/game/player/libElements.d.ts +12 -12
- package/dist/game/player/provider/game-state.d.ts +24 -24
- package/dist/game/player/provider/preloaded.d.ts +1 -1
- package/dist/game/player/provider/providers.d.ts +7 -7
- package/dist/game/player/provider/ratio.d.ts +1 -1
- package/dist/game/player/type.d.ts +68 -64
- package/dist/index.d.ts +3 -3
- package/dist/main.js +54 -53
- package/dist/util/config.d.ts +37 -37
- package/dist/util/data.d.ts +346 -308
- package/dist/util/logger.d.ts +21 -21
- package/dist/util/singleton.d.ts +5 -5
- package/package.json +5 -3
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
import { Actionable } from "../../action/actionable";
|
|
2
|
-
import { Transform } from "../../elements/transform/transform";
|
|
3
|
-
import { Chained, Proxied } from "../../action/chain";
|
|
4
|
-
import { LogicAction } from "../../action/logicAction";
|
|
5
|
-
import { EventfulDisplayable } from "../../../player/elements/displayable/type";
|
|
6
|
-
import type { TransformDefinitions } from "../../elements/transform/type";
|
|
7
|
-
export declare abstract class Displayable<StateData extends Record<string, any>, Self extends Displayable<any, any, any>, TransformType extends TransformDefinitions.Types = TransformDefinitions.Types> extends Actionable<StateData, Self> implements EventfulDisplayable {
|
|
8
|
-
/**
|
|
9
|
-
* Set Image Position
|
|
10
|
-
*
|
|
11
|
-
* @param position - The position of the image, expected {@link RawPosition} or {@link IPosition}
|
|
12
|
-
* @param duration - The duration of the position animation
|
|
13
|
-
* @param easing - The easing of the position animation
|
|
14
|
-
* @chainable
|
|
15
|
-
*/
|
|
16
|
-
pos(position: TransformDefinitions.ImageTransformProps["position"], duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
17
|
-
/**
|
|
18
|
-
* Set Image Scale
|
|
19
|
-
* @param scale - The scale of the image, between 0 and 1
|
|
20
|
-
* @param duration - The duration of the scale animation
|
|
21
|
-
* @param easing - The easing of the scale animation
|
|
22
|
-
* @chainable
|
|
23
|
-
*/
|
|
24
|
-
scale(scale: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
25
|
-
/**
|
|
26
|
-
* Set Image Rotation
|
|
27
|
-
* @param rotation - The rotation of the image, in degrees
|
|
28
|
-
* @param duration - The duration of the rotation animation
|
|
29
|
-
* @param easing - The easing of the rotation animation
|
|
30
|
-
* @chainable
|
|
31
|
-
*/
|
|
32
|
-
rotate(rotation: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
33
|
-
/**
|
|
34
|
-
* Set Image Opacity
|
|
35
|
-
* @param opacity - The opacity of the image, between 0 and 1
|
|
36
|
-
* @param duration - The duration of the opacity animation
|
|
37
|
-
* @param easing - The easing of the opacity animation
|
|
38
|
-
* @chainable
|
|
39
|
-
*/
|
|
40
|
-
opacity(opacity: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
41
|
-
/**
|
|
42
|
-
* Apply a transform to the Displayable
|
|
43
|
-
* @chainable
|
|
44
|
-
*/
|
|
45
|
-
transform(transform: Transform<TransformType>): Proxied<Self, Chained<LogicAction.Actions, Self>>;
|
|
46
|
-
/**
|
|
47
|
-
* Show the Displayable
|
|
48
|
-
*
|
|
49
|
-
* if options are provided, the displayable will show with the provided transform options
|
|
50
|
-
* @example
|
|
51
|
-
* ```ts
|
|
52
|
-
* text.show({
|
|
53
|
-
* duration: 1000,
|
|
54
|
-
* });
|
|
55
|
-
* ```
|
|
56
|
-
* @chainable
|
|
57
|
-
*/
|
|
58
|
-
show(): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
59
|
-
show(options: Transform<TransformType>): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
60
|
-
show(options: Partial<TransformDefinitions.CommonTransformProps>): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
61
|
-
/**
|
|
62
|
-
* Hide the Displayable
|
|
63
|
-
*
|
|
64
|
-
* if options are provided, the displayable will hide with the provided transform options
|
|
65
|
-
* @example
|
|
66
|
-
* ```ts
|
|
67
|
-
* text.hide({
|
|
68
|
-
* duration: 1000,
|
|
69
|
-
* });
|
|
70
|
-
* ```
|
|
71
|
-
* @chainable
|
|
72
|
-
*/
|
|
73
|
-
hide(): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
74
|
-
hide(options: Transform<TransformType>): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
75
|
-
hide(options: Partial<TransformDefinitions.CommonTransformProps>): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
76
|
-
}
|
|
1
|
+
import { Actionable } from "../../action/actionable";
|
|
2
|
+
import { Transform } from "../../elements/transform/transform";
|
|
3
|
+
import { Chained, Proxied } from "../../action/chain";
|
|
4
|
+
import { LogicAction } from "../../action/logicAction";
|
|
5
|
+
import { EventfulDisplayable } from "../../../player/elements/displayable/type";
|
|
6
|
+
import type { TransformDefinitions } from "../../elements/transform/type";
|
|
7
|
+
export declare abstract class Displayable<StateData extends Record<string, any>, Self extends Displayable<any, any, any>, TransformType extends TransformDefinitions.Types = TransformDefinitions.Types> extends Actionable<StateData, Self> implements EventfulDisplayable {
|
|
8
|
+
/**
|
|
9
|
+
* Set Image Position
|
|
10
|
+
*
|
|
11
|
+
* @param position - The position of the image, expected {@link RawPosition} or {@link IPosition}
|
|
12
|
+
* @param duration - The duration of the position animation
|
|
13
|
+
* @param easing - The easing of the position animation
|
|
14
|
+
* @chainable
|
|
15
|
+
*/
|
|
16
|
+
pos(position: TransformDefinitions.ImageTransformProps["position"], duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
17
|
+
/**
|
|
18
|
+
* Set Image Scale
|
|
19
|
+
* @param scale - The scale of the image, between 0 and 1
|
|
20
|
+
* @param duration - The duration of the scale animation
|
|
21
|
+
* @param easing - The easing of the scale animation
|
|
22
|
+
* @chainable
|
|
23
|
+
*/
|
|
24
|
+
scale(scale: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
25
|
+
/**
|
|
26
|
+
* Set Image Rotation
|
|
27
|
+
* @param rotation - The rotation of the image, in degrees
|
|
28
|
+
* @param duration - The duration of the rotation animation
|
|
29
|
+
* @param easing - The easing of the rotation animation
|
|
30
|
+
* @chainable
|
|
31
|
+
*/
|
|
32
|
+
rotate(rotation: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
33
|
+
/**
|
|
34
|
+
* Set Image Opacity
|
|
35
|
+
* @param opacity - The opacity of the image, between 0 and 1
|
|
36
|
+
* @param duration - The duration of the opacity animation
|
|
37
|
+
* @param easing - The easing of the opacity animation
|
|
38
|
+
* @chainable
|
|
39
|
+
*/
|
|
40
|
+
opacity(opacity: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
41
|
+
/**
|
|
42
|
+
* Apply a transform to the Displayable
|
|
43
|
+
* @chainable
|
|
44
|
+
*/
|
|
45
|
+
transform(transform: Transform<TransformType>): Proxied<Self, Chained<LogicAction.Actions, Self>>;
|
|
46
|
+
/**
|
|
47
|
+
* Show the Displayable
|
|
48
|
+
*
|
|
49
|
+
* if options are provided, the displayable will show with the provided transform options
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* text.show({
|
|
53
|
+
* duration: 1000,
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
* @chainable
|
|
57
|
+
*/
|
|
58
|
+
show(): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
59
|
+
show(options: Transform<TransformType>): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
60
|
+
show(options: Partial<TransformDefinitions.CommonTransformProps>): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
61
|
+
/**
|
|
62
|
+
* Hide the Displayable
|
|
63
|
+
*
|
|
64
|
+
* if options are provided, the displayable will hide with the provided transform options
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* text.hide({
|
|
68
|
+
* duration: 1000,
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
* @chainable
|
|
72
|
+
*/
|
|
73
|
+
hide(): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
74
|
+
hide(options: Transform<TransformType>): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
75
|
+
hide(options: Partial<TransformDefinitions.CommonTransformProps>): Proxied<Self, Chained<LogicAction.Actions>>;
|
|
76
|
+
}
|
|
@@ -1,91 +1,102 @@
|
|
|
1
|
-
import type { TransformDefinitions } from "../../elements/transform/type";
|
|
2
|
-
import { Color, CommonDisplayableConfig, ImageSrc } from "../../types";
|
|
3
|
-
import { LogicAction } from "../../game";
|
|
4
|
-
import { FlexibleTuple, SelectElementFromEach } from "../../../../util/data";
|
|
5
|
-
import { Chained, Proxied } from "../../action/chain";
|
|
6
|
-
import { Displayable } from "../../elements/displayable/displayable";
|
|
7
|
-
import { EventfulDisplayable } from "../../../player/elements/displayable/type";
|
|
8
|
-
import { ImageTransition } from "../../elements/transition/transitions/image/imageTransition";
|
|
9
|
-
import { Layer } from "../../elements/layer";
|
|
10
|
-
export type TagDefinition<T extends TagGroupDefinition | null> = T extends TagGroupDefinition ? TagDefinitionObject<T> : never;
|
|
11
|
-
export type TagDefinitionObject<T extends TagGroupDefinition> = {
|
|
12
|
-
groups: T;
|
|
13
|
-
defaults: SelectElementFromEach<T>;
|
|
14
|
-
resolve: TagSrcResolver<T>;
|
|
15
|
-
};
|
|
16
|
-
type ImageSrcType<T extends TagGroupDefinition | null = TagGroupDefinition | null> = T extends TagGroupDefinition ? TagDefinition<T> : (Color | ImageSrc);
|
|
17
|
-
export interface IImageUserConfig<Tag extends TagGroupDefinition | null = TagGroupDefinition | null> extends CommonDisplayableConfig {
|
|
18
|
-
/**
|
|
19
|
-
* The name of the image, only for debugging purposes
|
|
20
|
-
*/
|
|
21
|
-
name: string;
|
|
22
|
-
/**
|
|
23
|
-
* If set to false, the image won't be initialized unless you call `init` method
|
|
24
|
-
* @default true
|
|
25
|
-
*/
|
|
26
|
-
autoInit: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Image Src, see [Image](https://react.narraleaf.com/documentation/core/elements/image) for more information
|
|
29
|
-
*/
|
|
30
|
-
src: ImageSrcType<Tag>;
|
|
31
|
-
/**
|
|
32
|
-
* Auto resize image's width to fit the screen
|
|
33
|
-
* @default false
|
|
34
|
-
*/
|
|
35
|
-
autoFit: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* layer of the image
|
|
38
|
-
*/
|
|
39
|
-
layer?: Layer;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
*
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
*
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
*
|
|
88
|
-
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
1
|
+
import type { TransformDefinitions } from "../../elements/transform/type";
|
|
2
|
+
import { Color, CommonDisplayableConfig, ImageSrc } from "../../types";
|
|
3
|
+
import { LogicAction } from "../../game";
|
|
4
|
+
import { FlexibleTuple, SelectElementFromEach } from "../../../../util/data";
|
|
5
|
+
import { Chained, Proxied } from "../../action/chain";
|
|
6
|
+
import { Displayable } from "../../elements/displayable/displayable";
|
|
7
|
+
import { EventfulDisplayable } from "../../../player/elements/displayable/type";
|
|
8
|
+
import { ImageTransition } from "../../elements/transition/transitions/image/imageTransition";
|
|
9
|
+
import { Layer } from "../../elements/layer";
|
|
10
|
+
export type TagDefinition<T extends TagGroupDefinition | null> = T extends TagGroupDefinition ? TagDefinitionObject<T> : never;
|
|
11
|
+
export type TagDefinitionObject<T extends TagGroupDefinition> = {
|
|
12
|
+
groups: T;
|
|
13
|
+
defaults: SelectElementFromEach<T>;
|
|
14
|
+
resolve: TagSrcResolver<T>;
|
|
15
|
+
};
|
|
16
|
+
type ImageSrcType<T extends TagGroupDefinition | null = TagGroupDefinition | null> = T extends TagGroupDefinition ? TagDefinition<T> : (Color | ImageSrc);
|
|
17
|
+
export interface IImageUserConfig<Tag extends TagGroupDefinition | null = TagGroupDefinition | null> extends CommonDisplayableConfig {
|
|
18
|
+
/**
|
|
19
|
+
* The name of the image, only for debugging purposes
|
|
20
|
+
*/
|
|
21
|
+
name: string;
|
|
22
|
+
/**
|
|
23
|
+
* If set to false, the image won't be initialized unless you call `init` method
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
autoInit: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Image Src, see [Image](https://react.narraleaf.com/documentation/core/elements/image) for more information
|
|
29
|
+
*/
|
|
30
|
+
src: ImageSrcType<Tag>;
|
|
31
|
+
/**
|
|
32
|
+
* Auto resize image's width to fit the screen
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
autoFit: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* layer of the image
|
|
38
|
+
*/
|
|
39
|
+
layer?: Layer;
|
|
40
|
+
/**
|
|
41
|
+
* Darkness of the image, between 0 and 1
|
|
42
|
+
* @default 0
|
|
43
|
+
*/
|
|
44
|
+
darkness?: number;
|
|
45
|
+
}
|
|
46
|
+
export type TagGroupDefinition = string[][];
|
|
47
|
+
export type TagSrcResolver<T extends TagGroupDefinition> = (...tags: SelectElementFromEach<T>) => string;
|
|
48
|
+
export declare class Image<Tags extends TagGroupDefinition | null = TagGroupDefinition | null> extends Displayable<ImageDataRaw, Image, TransformDefinitions.ImageTransformProps> implements EventfulDisplayable {
|
|
49
|
+
constructor(config?: Partial<IImageUserConfig<Tags>>);
|
|
50
|
+
/**
|
|
51
|
+
* Set the source of the image
|
|
52
|
+
*
|
|
53
|
+
* - Tag-based image: the src will be resolved from the tags
|
|
54
|
+
* - Static image: the src will be a string or StaticImageData
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* image.char("path/to/image.png", new Dissolve(1000));
|
|
58
|
+
* ```
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* image.char(["happy", "t-shirt", "shorts"], new Dissolve(1000));
|
|
62
|
+
* ```
|
|
63
|
+
* @chainable
|
|
64
|
+
*/
|
|
65
|
+
char(src: ImageSrc | Color, transition?: ImageTransition): Proxied<Image, Chained<LogicAction.Actions>>;
|
|
66
|
+
char(tags: SelectElementFromEach<Tags> | FlexibleTuple<SelectElementFromEach<Tags>>, transition?: ImageTransition): Proxied<Image, Chained<LogicAction.Actions>>;
|
|
67
|
+
/**
|
|
68
|
+
* Set the darkness of the image
|
|
69
|
+
* @param darkness - The darkness of the image, between 0 and 1
|
|
70
|
+
* @chainable
|
|
71
|
+
*/
|
|
72
|
+
darken(darkness: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Image, Chained<LogicAction.Actions>>;
|
|
73
|
+
/**
|
|
74
|
+
* Add a wearable to the image
|
|
75
|
+
* @param children - Wearable image or images
|
|
76
|
+
*/
|
|
77
|
+
addWearable(children: Image | Image[]): this;
|
|
78
|
+
/**
|
|
79
|
+
* Add a wearable to the image
|
|
80
|
+
*
|
|
81
|
+
* Alias of {@link Image.addWearable}
|
|
82
|
+
* @param children - Wearable image or images
|
|
83
|
+
*/
|
|
84
|
+
wear(children: Image | Image[]): this;
|
|
85
|
+
/**
|
|
86
|
+
* Bind this image to a parent image as a wearable
|
|
87
|
+
* @param parent - The parent image
|
|
88
|
+
*/
|
|
89
|
+
bindWearable(parent: Image): this;
|
|
90
|
+
/**
|
|
91
|
+
* Bind this image to a parent image as a wearable
|
|
92
|
+
*
|
|
93
|
+
* Alias of {@link Image.bindWearable}
|
|
94
|
+
* @param parent - The parent image
|
|
95
|
+
*/
|
|
96
|
+
asWearableOf(parent: Image): this;
|
|
97
|
+
/**
|
|
98
|
+
* Use layer for the image, will override the layer in the image config
|
|
99
|
+
*/
|
|
100
|
+
useLayer(layer: Layer | null): this;
|
|
101
|
+
}
|
|
102
|
+
export {};
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
import { Color, CommonDisplayableConfig } from "../../types";
|
|
2
|
-
import { Chained, Proxied } from "../../action/chain";
|
|
3
|
-
import { LogicAction } from "../../action/logicAction";
|
|
4
|
-
import type { TransformDefinitions } from "../../elements/transform/type";
|
|
5
|
-
import { Displayable } from "../../elements/displayable/displayable";
|
|
6
|
-
import { EventfulDisplayable } from "../../../player/elements/displayable/type";
|
|
7
|
-
import { Layer } from "../../elements/layer";
|
|
8
|
-
export type TextConfig = {
|
|
9
|
-
alignX: "left" | "center" | "right";
|
|
10
|
-
alignY: "top" | "center" | "bottom";
|
|
11
|
-
className?: string;
|
|
12
|
-
layer: Layer | undefined;
|
|
13
|
-
};
|
|
14
|
-
export type TextState = {
|
|
15
|
-
fontSize: number;
|
|
16
|
-
display: boolean;
|
|
17
|
-
text: string;
|
|
18
|
-
};
|
|
19
|
-
export interface ITextUserConfig extends CommonDisplayableConfig {
|
|
20
|
-
/**
|
|
21
|
-
* Where to align the text horizontally
|
|
22
|
-
* @default "center"
|
|
23
|
-
*/
|
|
24
|
-
alignX: "left" | "center" | "right";
|
|
25
|
-
/**
|
|
26
|
-
* Where to align the text vertically
|
|
27
|
-
* @default "center"
|
|
28
|
-
*/
|
|
29
|
-
alignY: "top" | "center" | "bottom";
|
|
30
|
-
className?: string;
|
|
31
|
-
/**
|
|
32
|
-
* The font size of the text, see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size)
|
|
33
|
-
*
|
|
34
|
-
* **Only supports px unit**
|
|
35
|
-
* @default 16
|
|
36
|
-
*/
|
|
37
|
-
fontSize: number;
|
|
38
|
-
/**
|
|
39
|
-
* The color of the text, supports {@link Color} and hex string
|
|
40
|
-
* @default "#000000"
|
|
41
|
-
*/
|
|
42
|
-
fontColor: Color;
|
|
43
|
-
/**
|
|
44
|
-
* The text content
|
|
45
|
-
*/
|
|
46
|
-
text: string;
|
|
47
|
-
/**
|
|
48
|
-
* Layer of the text
|
|
49
|
-
*/
|
|
50
|
-
layer?: Layer;
|
|
51
|
-
}
|
|
52
|
-
export declare class Text extends Displayable<TextDataRaw, Text, TransformDefinitions.TextTransformProps> implements EventfulDisplayable {
|
|
53
|
-
constructor(config: Partial<ITextUserConfig>);
|
|
54
|
-
constructor(text: string, config?: Partial<ITextUserConfig>);
|
|
55
|
-
/**
|
|
56
|
-
* Set the text of the Text
|
|
57
|
-
* @chainable
|
|
58
|
-
*/
|
|
59
|
-
setText(text: string): Proxied<Text, Chained<LogicAction.Actions>>;
|
|
60
|
-
/**
|
|
61
|
-
* Set the font color of the Text
|
|
62
|
-
* @chainable
|
|
63
|
-
*/
|
|
64
|
-
setFontColor(color: Color, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Text, Chained<LogicAction.Actions>>;
|
|
65
|
-
/**
|
|
66
|
-
* Set the font color of the Text
|
|
67
|
-
* @chainable
|
|
68
|
-
*/
|
|
69
|
-
setFontSize(fontSize: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Text, Chained<LogicAction.Actions>>;
|
|
70
|
-
/**
|
|
71
|
-
* Use a layer for the Text, will override the layer in the text config
|
|
72
|
-
*/
|
|
73
|
-
useLayer(layer: Layer): this;
|
|
74
|
-
}
|
|
1
|
+
import { Color, CommonDisplayableConfig } from "../../types";
|
|
2
|
+
import { Chained, Proxied } from "../../action/chain";
|
|
3
|
+
import { LogicAction } from "../../action/logicAction";
|
|
4
|
+
import type { TransformDefinitions } from "../../elements/transform/type";
|
|
5
|
+
import { Displayable } from "../../elements/displayable/displayable";
|
|
6
|
+
import { EventfulDisplayable } from "../../../player/elements/displayable/type";
|
|
7
|
+
import { Layer } from "../../elements/layer";
|
|
8
|
+
export type TextConfig = {
|
|
9
|
+
alignX: "left" | "center" | "right";
|
|
10
|
+
alignY: "top" | "center" | "bottom";
|
|
11
|
+
className?: string;
|
|
12
|
+
layer: Layer | undefined;
|
|
13
|
+
};
|
|
14
|
+
export type TextState = {
|
|
15
|
+
fontSize: number;
|
|
16
|
+
display: boolean;
|
|
17
|
+
text: string;
|
|
18
|
+
};
|
|
19
|
+
export interface ITextUserConfig extends CommonDisplayableConfig {
|
|
20
|
+
/**
|
|
21
|
+
* Where to align the text horizontally
|
|
22
|
+
* @default "center"
|
|
23
|
+
*/
|
|
24
|
+
alignX: "left" | "center" | "right";
|
|
25
|
+
/**
|
|
26
|
+
* Where to align the text vertically
|
|
27
|
+
* @default "center"
|
|
28
|
+
*/
|
|
29
|
+
alignY: "top" | "center" | "bottom";
|
|
30
|
+
className?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The font size of the text, see [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size)
|
|
33
|
+
*
|
|
34
|
+
* **Only supports px unit**
|
|
35
|
+
* @default 16
|
|
36
|
+
*/
|
|
37
|
+
fontSize: number;
|
|
38
|
+
/**
|
|
39
|
+
* The color of the text, supports {@link Color} and hex string
|
|
40
|
+
* @default "#000000"
|
|
41
|
+
*/
|
|
42
|
+
fontColor: Color;
|
|
43
|
+
/**
|
|
44
|
+
* The text content
|
|
45
|
+
*/
|
|
46
|
+
text: string;
|
|
47
|
+
/**
|
|
48
|
+
* Layer of the text
|
|
49
|
+
*/
|
|
50
|
+
layer?: Layer;
|
|
51
|
+
}
|
|
52
|
+
export declare class Text extends Displayable<TextDataRaw, Text, TransformDefinitions.TextTransformProps> implements EventfulDisplayable {
|
|
53
|
+
constructor(config: Partial<ITextUserConfig>);
|
|
54
|
+
constructor(text: string, config?: Partial<ITextUserConfig>);
|
|
55
|
+
/**
|
|
56
|
+
* Set the text of the Text
|
|
57
|
+
* @chainable
|
|
58
|
+
*/
|
|
59
|
+
setText(text: string): Proxied<Text, Chained<LogicAction.Actions>>;
|
|
60
|
+
/**
|
|
61
|
+
* Set the font color of the Text
|
|
62
|
+
* @chainable
|
|
63
|
+
*/
|
|
64
|
+
setFontColor(color: Color, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Text, Chained<LogicAction.Actions>>;
|
|
65
|
+
/**
|
|
66
|
+
* Set the font color of the Text
|
|
67
|
+
* @chainable
|
|
68
|
+
*/
|
|
69
|
+
setFontSize(fontSize: number, duration?: number, easing?: TransformDefinitions.EasingDefinition): Proxied<Text, Chained<LogicAction.Actions>>;
|
|
70
|
+
/**
|
|
71
|
+
* Use a layer for the Text, will override the layer in the text config
|
|
72
|
+
*/
|
|
73
|
+
useLayer(layer: Layer): this;
|
|
74
|
+
}
|
|
@@ -1,23 +1,33 @@
|
|
|
1
|
-
import { CommonDisplayableConfig } from "../types";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { CommonDisplayableConfig } from "../types";
|
|
2
|
+
import { LogicAction } from "../action/logicAction";
|
|
3
|
+
import { TransformDefinitions } from "../elements/transform/type";
|
|
4
|
+
import { Displayable } from "../elements/displayable/displayable";
|
|
5
|
+
import { EventfulDisplayable } from "../../player/elements/displayable/type";
|
|
6
|
+
import { Image } from "../elements/displayable/image";
|
|
7
|
+
import { Text } from "../elements/displayable/text";
|
|
8
|
+
import { Chained, Proxied } from "../action/chain";
|
|
9
|
+
export interface ILayerUserConfig extends CommonDisplayableConfig {
|
|
10
|
+
/**
|
|
11
|
+
* The z-index of the layer, higher z-index will be rendered on top of the lower z-index, allows negative values.
|
|
12
|
+
*
|
|
13
|
+
* **Note**: the default background layer has a z-index of -1, and the default displayable layer has a z-index of 0.
|
|
14
|
+
*/
|
|
15
|
+
zIndex: number;
|
|
16
|
+
}
|
|
17
|
+
export declare class Layer extends Displayable<LayerDataRaw, Layer, TransformDefinitions.ImageTransformProps> implements EventfulDisplayable {
|
|
18
|
+
constructor(name?: string, config?: Partial<ILayerUserConfig>);
|
|
19
|
+
/**
|
|
20
|
+
* Include displayables in the layer.
|
|
21
|
+
*
|
|
22
|
+
* Same as {@link Displayable.useLayer}
|
|
23
|
+
*/
|
|
24
|
+
include(elements: (Image | Text)[] | Image | Text): this;
|
|
25
|
+
/**
|
|
26
|
+
* Set the z-index of the layer
|
|
27
|
+
*
|
|
28
|
+
* @chainable
|
|
29
|
+
* @param zIndex - The z-index of the layer
|
|
30
|
+
* @returns The layer itself
|
|
31
|
+
*/
|
|
32
|
+
setZIndex(zIndex: number): Proxied<Layer, Chained<LogicAction.Actions>>;
|
|
33
|
+
}
|