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

Function skip

src/engine/ui.ts:314–354  ·  view source on GitHub ↗
(engine: VisualNovelEngine, enable: boolean)

Source from the content-addressed store, hash-verified

312}
313
314export function skip (engine: VisualNovelEngine, enable: boolean): void {
315 const skipSetting = engine.setting ('Skip') as number;
316
317 if (enable === true) {
318 // Check if Skip was enabled on the settings, if it has a value greater
319 // than 0, it represents the speed with which the game will skip through
320 // statements. If it's lesser or equal to 0 then it's disabled.
321 if (skipSetting > 0) {
322
323 const button = engine.element ().find ('[data-component="quick-menu"] [data-action="skip"] [data-icon]');
324
325 if (button.data ('icon') !== 'play-circle') {
326 button.replaceWith ('<span class="far fa-play-circle"></span>');
327 }
328
329 // Start the timeout with the time specified on the settings. We
330 // save it on a global variable so that we can disable later.
331 engine.global ('skip', setTimeout (() => {
332 if (engine.element ().find ('[data-screen="game"]').isVisible () && engine.global ('playing') === true) {
333 engine.proceed ({ userInitiated: false, skip: true, autoPlay: false }).then (() => {
334 // Nothing to do here
335 }).catch ((e) => {
336 engine.debug.log (`Proceed Prevented\nReason: ${e}`);
337 // An action waiting for user interaction or something else
338 // is blocking the game.
339 });
340 }
341 // Start all over again
342 skip (engine, true);
343 }, skipSetting));
344 }
345 } else {
346 clearTimeout (engine.global ('skip') as ReturnType<typeof setTimeout>);
347 engine.global ('skip', null);
348 const button = engine.element ().find ('[data-component="quick-menu"] [data-action="skip"] [data-icon]');
349
350 if (button.data ('icon') !== 'fast-forward') {
351 button.replaceWith ('<span class="fas fa-fast-forward"></span>');
352 }
353 }
354}
355
356// ============================================================================
357// Resize & Navigation

Callers 1

revealScreenFunction · 0.85

Calls 4

settingMethod · 0.80
globalMethod · 0.80
proceedMethod · 0.80
elementMethod · 0.45

Tested by

no test coverage detected