MCPcopy Create free account
hub / github.com/Monogatari/Monogatari / apply

Method apply

src/actions/InputModal.ts:113–157  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

111 }
112
113 override async apply(): Promise<void> {
114 InputModal.blocking = true;
115
116 const input = document.createElement('text-input') as TextInputComponent;
117
118 const { Text, Warning, Save, Validation, actionString, Class, Type, Options, Default, Timer, Attributes } = this.statement;
119
120 input.setProps({
121 text: this.engine.replaceVariables(Text),
122 type: Type,
123 options: Options,
124 default: Default,
125 warning: Warning,
126 onSubmit: Save,
127 validate: Validation,
128 attributes: Attributes,
129 actionString,
130 callback: () => {
131 const timer = this.engine.global('_InputTimer');
132
133 if (typeof timer !== 'undefined' && timer !== null) {
134 if (timer.props?.timer) {
135 clearTimeout(timer.props.timer);
136 }
137 if (timer.parentNode !== null && timer.element) {
138 timer.element().remove();
139 }
140 this.engine.global('_InputTimer', null);
141 }
142
143 InputModal.blocking = false;
144 this.engine.proceed({ userInitiated: true, skip: false, autoPlay: false });
145 },
146 classes: Class.trim()
147 });
148
149 if (Timer !== null) {
150 const timer_display = document.createElement('timer-display') as TimerDisplayComponent;
151 timer_display.setProps(Timer);
152 this.engine.global('_InputTimer', timer_display);
153 this.engine.element().find('[data-screen="game"]').prepend(timer_display);
154 }
155
156 this.engine.element().find('[data-screen="game"]').append(input);
157 }
158
159 override async willRevert(): Promise<void> {
160 if (typeof this.statement.Revert === 'function') {

Callers 1

revertMethod · 0.95

Calls 5

replaceVariablesMethod · 0.80
globalMethod · 0.80
proceedMethod · 0.80
removeMethod · 0.65
elementMethod · 0.45

Tested by

no test coverage detected