@@ -1175,6 +1175,25 @@ class Monogatari {
11751175 return Promise . all ( promises ) ;
11761176 }
11771177
1178+ static skip ( enable ) {
1179+ if ( enable === true ) {
1180+ if ( Monogatari . setting ( 'Skip' ) > 0 ) {
1181+ Monogatari . global ( 'skip' , setTimeout ( ( ) => {
1182+ Monogatari . canProceed ( ) . then ( ( ) => {
1183+ Monogatari . next ( ) ;
1184+ } ) . catch ( ( ) => {
1185+ // An action waiting for user interaction or something else
1186+ // is blocking the game.
1187+ } ) ;
1188+ Monogatari . skip ( true ) ;
1189+ } , Monogatari . setting ( 'Skip' ) ) ) ;
1190+ }
1191+ } else {
1192+ clearTimeout ( Monogatari . global ( 'skip' ) ) ;
1193+ Monogatari . global ( 'skip' , null ) ;
1194+ }
1195+ }
1196+
11781197 /**
11791198 * Every event listener should be binded in this function.
11801199 */
@@ -1279,6 +1298,25 @@ class Monogatari {
12791298 Monogatari . autoPlay ( Monogatari . global ( '_AutoPlayTimer' ) === null ) ;
12801299 } ) ;
12811300
1301+ $_ ( document ) . keydown ( function ( e ) {
1302+ if ( e . target . tagName . toLowerCase ( ) != 'input' ) {
1303+ switch ( e . which ) {
1304+
1305+ case 83 :
1306+ if ( Monogatari . global ( 'skip' ) !== null ) {
1307+ Monogatari . skip ( false ) ;
1308+ } else {
1309+ Monogatari . skip ( true ) ;
1310+ }
1311+ break ;
1312+
1313+ default :
1314+ return ;
1315+
1316+ }
1317+ }
1318+ } ) ;
1319+
12821320 $_ ( document ) . keyup ( ( e ) => {
12831321 if ( e . target . tagName . toLowerCase ( ) != 'input' ) {
12841322 switch ( e . which ) {
@@ -1500,7 +1538,14 @@ Monogatari._settings = {
15001538 // to portrait or landscape, a warning message will be displayed so the
15011539 // player rotates its device.
15021540 // Possible values: any, portrait or landscape.
1503- 'Orientation' : 'any'
1541+ 'Orientation' : 'any' ,
1542+
1543+ // Allow players to skip through the game. Similar to the auto play feature,
1544+ // skipping will allow players to go through the game really fast.
1545+ // If this value is set to 0, no skipping will be allowed but if it's set
1546+ // to a higher number, skipping will be allowed and that value will be taken
1547+ // as the speed in milliseconds with which the game will skip through the script
1548+ 'Skip' : 0
15041549} ;
15051550
15061551Monogatari . _preferences = {
@@ -1536,7 +1581,8 @@ Monogatari.globals ({
15361581 block : false ,
15371582 playing : false ,
15381583 currentAutoSaveSlot : 1 ,
1539- _AutoPlayTimer : null
1584+ _AutoPlayTimer : null ,
1585+ skip : null
15401586} ) ;
15411587
15421588Monogatari . Storage = new Space ( ) ;
0 commit comments