@@ -869,7 +869,7 @@ class Monogatari {
869869 this . trigger ( 'willLocalize' ) ;
870870
871871 // Setup the correct locale for the momentjs dates
872- moment . locale ( this . _languageCodes [ this . preference ( 'Language' ) ] ) ;
872+ moment . locale ( this . _languageMetadata [ this . preference ( 'Language' ) . code ] ) ;
873873
874874 this . element ( ) . find ( '[data-string]' ) . each ( ( element ) => {
875875 const string_translation = this . string ( $_ ( element ) . data ( 'string' ) ) ;
@@ -2439,10 +2439,14 @@ class Monogatari {
24392439 // Set the initial settings if they don't exist or load them from the
24402440 // Storage if they do.
24412441 this . Storage . get ( 'Settings' ) . then ( ( local_settings ) => {
2442+ this . global ( '_first_run' , false ) ;
24422443 this . _preferences = merge ( this . _preferences , local_settings ) ;
24432444 } ) . catch ( ( e ) => {
2445+ this . global ( '_first_run' , true ) ;
2446+ if ( this . setting ( 'MultiLanguage' ) !== true || this . setting ( 'LanguageSelectionScreen' ) !== true ) {
2447+ this . Storage . set ( 'Settings' , this . _preferences ) ;
2448+ }
24442449 console . warn ( 'There was no settings saved. This may be the first time this game was opened, we\'ll create them now.' , e ) ;
2445- this . Storage . set ( 'Settings' , this . _preferences ) ;
24462450 } ) ;
24472451
24482452 // Define all the components that were registered to this point
@@ -2909,6 +2913,31 @@ class Monogatari {
29092913 }
29102914 }
29112915
2916+ static displayInitialScreen ( ) {
2917+ // Preload all the game assets
2918+ this . preload ( ) . then ( ( ) => {
2919+
2920+ } ) . catch ( ( e ) => {
2921+ console . error ( e ) ;
2922+ } ) . finally ( ( ) => {
2923+ if ( this . label ( ) ) {
2924+ this . showSplashScreen ( ) ;
2925+ } else {
2926+ FancyError . show (
2927+ `"${ this . setting ( 'Label' ) } " Label was not found` ,
2928+ 'Monogatari tried to get your start label but it couldn\'t find it in your script.' ,
2929+ {
2930+ 'Start Label on your Settings' : this . setting ( 'Label' ) ,
2931+ 'Labels Available' : Object . keys ( this . script ( ) ) ,
2932+ 'Help' : {
2933+ '_' : 'Please check that the label exists in your script.'
2934+ }
2935+ }
2936+ ) ;
2937+ }
2938+ } ) ;
2939+ }
2940+
29122941 static init ( selector = '#monogatari' ) {
29132942 this . _selector = selector ;
29142943
@@ -2990,28 +3019,20 @@ class Monogatari {
29903019 this . global ( '_didInit' , true ) ;
29913020 this . trigger ( 'didInit' ) ;
29923021
2993- // Preload all the game assets
2994- this . preload ( ) . then ( ( ) => {
3022+ if ( this . setting ( 'MultiLanguage' ) === true && this . setting ( 'LanguageSelectionScreen' ) === true && this . global ( '_first_run' ) === true ) {
3023+ this . showScreen ( 'language-selection' ) ;
29953024
2996- } ) . catch ( ( e ) => {
2997- console . error ( e ) ;
2998- } ) . finally ( ( ) => {
2999- if ( this . label ( ) ) {
3000- this . showSplashScreen ( ) ;
3001- } else {
3002- FancyError . show (
3003- `"${ this . setting ( 'Label' ) } " Label was not found` ,
3004- 'Monogatari tried to get your start label but it couldn\'t find it in your script.' ,
3005- {
3006- 'Start Label on your Settings' : this . setting ( 'Label' ) ,
3007- 'Labels Available' : Object . keys ( this . script ( ) ) ,
3008- 'Help' : {
3009- '_' : 'Please check that the label exists in your script.'
3010- }
3011- }
3012- ) ;
3013- }
3014- } ) ;
3025+ this . on ( 'didLocalize' , ( ) => {
3026+ this . Storage . set ( 'Settings' , this . _preferences ) ;
3027+ const languageSelectionScreen = this . element ( ) . find ( '[data-screen="language-selection"]' ) ;
3028+ if ( languageSelectionScreen . isVisible ( ) ) {
3029+ this . displayInitialScreen ( ) ;
3030+
3031+ }
3032+ } ) ;
3033+ } else {
3034+ this . displayInitialScreen ( ) ;
3035+ }
30153036 } ) ;
30163037 } ) ;
30173038 } ) ;
@@ -3111,6 +3132,12 @@ Monogatari._settings = {
31113132 // Change to true for a MultiLanguage GameScreen.
31123133 'MultiLanguage' : false ,
31133134
3135+ // If the 'Multilanguage' setting is set to `true`. This will enable a
3136+ // language selection screen that will be shown before the asset loading
3137+ // screen. If set to false, the loading screen will appear first instead and
3138+ // players will have to change the language from the settings screen.
3139+ 'LanguageSelectionScreen' : true ,
3140+
31143141 // Music for the Main Menu.
31153142 'MainScreenMusic' : '' ,
31163143
0 commit comments