narraleaf-react 0.8.2 → 0.8.3
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/dist/game/nlcore/action/actionTypes.d.ts +1 -1
- package/dist/game/nlcore/elements/menu.d.ts +53 -1
- package/dist/game/nlcore/elements/persistent.d.ts +3 -3
- package/dist/game/player/elements/menu/PlayerMenu.d.ts +1 -1
- package/dist/game/player/elements/menu/UIMenu/context.d.ts +2 -6
- package/dist/game/player/elements/menu/type.d.ts +3 -0
- package/dist/main.js +41 -41
- package/package.json +1 -1
|
@@ -118,7 +118,7 @@ export declare const PersistentActionTypes: {
|
|
|
118
118
|
readonly assign: "persistent:assign";
|
|
119
119
|
};
|
|
120
120
|
export type PersistentActionContentType = {
|
|
121
|
-
[K in typeof PersistentActionTypes[keyof typeof PersistentActionTypes]]: K extends "persistent:action" ? any : K extends "persistent:set" ? [string, unknown | ((value: unknown) => unknown)] : K extends "persistent:assign" ? [Partial<unknown>] : any;
|
|
121
|
+
[K in typeof PersistentActionTypes[keyof typeof PersistentActionTypes]]: K extends "persistent:action" ? any : K extends "persistent:set" ? [string, unknown | ((value: unknown) => unknown)] : K extends "persistent:assign" ? [Partial<unknown> | ((value: unknown) => Partial<unknown>)] : any;
|
|
122
122
|
};
|
|
123
123
|
export declare const LayerActionTypes: {
|
|
124
124
|
readonly action: "layer:action";
|
|
@@ -3,20 +3,30 @@ import { Actionable } from "../action/actionable";
|
|
|
3
3
|
import { Chained, Proxied } from "../action/chain";
|
|
4
4
|
import { Sentence, SentencePrompt } from "../elements/character/sentence";
|
|
5
5
|
import Actions = LogicAction.Actions;
|
|
6
|
-
import { ActionStatements } from "./type";
|
|
6
|
+
import { ActionStatements, LambdaHandler } from "./type";
|
|
7
|
+
import { Lambda } from "./condition";
|
|
7
8
|
export type MenuConfig = {};
|
|
8
9
|
export type MenuChoice = {
|
|
9
10
|
action: ActionStatements;
|
|
10
11
|
prompt: SentencePrompt | Sentence;
|
|
12
|
+
config?: {
|
|
13
|
+
disabled?: Lambda<boolean> | LambdaHandler<boolean>;
|
|
14
|
+
hidden?: Lambda<boolean> | LambdaHandler<boolean>;
|
|
15
|
+
};
|
|
11
16
|
};
|
|
12
17
|
export type Choice = {
|
|
13
18
|
action: Actions[];
|
|
14
19
|
prompt: Sentence;
|
|
20
|
+
config: ChoiceConfig;
|
|
15
21
|
};
|
|
16
22
|
export type MenuData = {
|
|
17
23
|
prompt: Sentence | null;
|
|
18
24
|
choices: Choice[];
|
|
19
25
|
};
|
|
26
|
+
export type ChoiceConfig = {
|
|
27
|
+
disabled?: Lambda<boolean>;
|
|
28
|
+
hidden?: Lambda<boolean>;
|
|
29
|
+
};
|
|
20
30
|
export declare class Menu extends Actionable<any, Menu> {
|
|
21
31
|
/**
|
|
22
32
|
* Create a menu with a prompt
|
|
@@ -42,4 +52,46 @@ export declare class Menu extends Actionable<any, Menu> {
|
|
|
42
52
|
choose(prompt: Sentence, action: ActionStatements): Proxied<Menu, Chained<LogicAction.Actions>>;
|
|
43
53
|
choose(prompt: SentencePrompt, action: ActionStatements): Proxied<Menu, Chained<LogicAction.Actions>>;
|
|
44
54
|
choose(arg0: Sentence | MenuChoice | SentencePrompt, arg1?: ActionStatements): Proxied<Menu, Chained<LogicAction.Actions>>;
|
|
55
|
+
/**
|
|
56
|
+
* Magic method to hide the last choice if the condition is true
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* menu.choose(
|
|
60
|
+
* // ...
|
|
61
|
+
* ).hideIf(persis.isTrue("flag"));
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* **Note**: This method will override the last choice's config.hidden
|
|
65
|
+
*/
|
|
66
|
+
hideIf(condition: Lambda<boolean> | LambdaHandler<boolean>): Proxied<Menu, Chained<LogicAction.Actions>>;
|
|
67
|
+
/**
|
|
68
|
+
* Magic method to disable the last choice if the condition is true
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* menu.choose(
|
|
72
|
+
* // ...
|
|
73
|
+
* ).disableIf(persis.isTrue("flag"));
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
disableIf(condition: Lambda<boolean> | LambdaHandler<boolean>): Proxied<Menu, Chained<LogicAction.Actions>>;
|
|
77
|
+
/**
|
|
78
|
+
* Add a choice, only enable when the condition is true
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* menu.enableWhen(persis.isTrue("flag"), "Go left", [
|
|
82
|
+
* character.say("I went left")
|
|
83
|
+
* ]);
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
enableWhen(condition: Lambda<boolean> | LambdaHandler<boolean>, prompt: Sentence, action: ActionStatements): Proxied<Menu, Chained<LogicAction.Actions>>;
|
|
87
|
+
/**
|
|
88
|
+
* Add a choice, only show when the condition is true
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* menu.showWhen(persis.isTrue("flag"), "Go left", [
|
|
92
|
+
* character.say("I went left")
|
|
93
|
+
* ]);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
showWhen(condition: Lambda<boolean> | LambdaHandler<boolean>, prompt: Sentence, action: ActionStatements): Proxied<Menu, Chained<LogicAction.Actions>>;
|
|
45
97
|
}
|
|
@@ -21,15 +21,15 @@ export declare class Persistent<T extends PersistentContent> extends Actionable<
|
|
|
21
21
|
* @param value - The value to assign
|
|
22
22
|
* @returns A chainable persistent action
|
|
23
23
|
*/
|
|
24
|
-
assign(value: Partial<T>): ChainedPersistent<T>;
|
|
24
|
+
assign(value: Partial<T> | ((value: T) => Partial<T>)): ChainedPersistent<T>;
|
|
25
25
|
/**
|
|
26
26
|
* Determine whether the values are equal, can be used in {@link Condition}
|
|
27
27
|
*/
|
|
28
|
-
equals<K extends StringKeyOf<T>>(key: K, value: T[K]): Lambda<boolean>;
|
|
28
|
+
equals<K extends StringKeyOf<T>>(key: K, value: T[K] | ((value: T[K]) => T[K])): Lambda<boolean>;
|
|
29
29
|
/**
|
|
30
30
|
* Determine whether the values aren't equal, can be used in {@link Condition}
|
|
31
31
|
*/
|
|
32
|
-
notEquals<K extends StringKeyOf<T>>(key: K, value: T[K]): Lambda<boolean>;
|
|
32
|
+
notEquals<K extends StringKeyOf<T>>(key: K, value: T[K] | ((value: T[K]) => T[K])): Lambda<boolean>;
|
|
33
33
|
/**
|
|
34
34
|
* Determine whether the value is true, can be used in {@link Condition}
|
|
35
35
|
*/
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { Pausing } from "../../../../nlcore/elements/character/pause";
|
|
2
|
-
import { Word } from "../../../../nlcore/elements/character/word";
|
|
3
|
-
import { Choice } from "../../../../nlcore/elements/menu";
|
|
4
1
|
import { GameState } from "../../../../../game/player/gameState";
|
|
5
2
|
import { Chosen } from "../../../type";
|
|
6
3
|
import React from "react";
|
|
4
|
+
import { ChoiceEvaluated } from "../type";
|
|
7
5
|
interface UIMenuContext {
|
|
8
|
-
evaluated:
|
|
9
|
-
words: Word<Pausing | string>[];
|
|
10
|
-
})[];
|
|
6
|
+
evaluated: ChoiceEvaluated[];
|
|
11
7
|
choose: (choice: Chosen) => void;
|
|
12
8
|
gameState: GameState;
|
|
13
9
|
}
|