@@ -360,6 +360,11 @@ Graphics.printLoadingError = function(url) {
360
360
if ( this . _errorPrinter && ! this . _errorShowed ) {
361
361
this . _updateErrorPrinter ( ) ;
362
362
this . _errorPrinter . innerHTML = this . _makeErrorHtml ( 'Loading Error' , 'Failed to load: ' + url ) ;
363
+ this . _errorPrinter . style . userSelect = 'text' ;
364
+ this . _errorPrinter . style . webkitUserSelect = 'text' ;
365
+ this . _errorPrinter . style . msUserSelect = 'text' ;
366
+ this . _errorPrinter . style . mozUserSelect = 'text' ;
367
+ this . _errorPrinter . oncontextmenu = null ; // enable context menu
363
368
var button = document . createElement ( 'button' ) ;
364
369
button . innerHTML = 'Retry' ;
365
370
button . style . fontSize = '24px' ;
@@ -385,6 +390,11 @@ Graphics.printLoadingError = function(url) {
385
390
Graphics . eraseLoadingError = function ( ) {
386
391
if ( this . _errorPrinter && ! this . _errorShowed ) {
387
392
this . _errorPrinter . innerHTML = '' ;
393
+ this . _errorPrinter . style . userSelect = 'none' ;
394
+ this . _errorPrinter . style . webkitUserSelect = 'none' ;
395
+ this . _errorPrinter . style . msUserSelect = 'none' ;
396
+ this . _errorPrinter . style . mozUserSelect = 'none' ;
397
+ this . _errorPrinter . oncontextmenu = function ( ) { return false ; } ;
388
398
this . startLoading ( ) ;
389
399
}
390
400
} ;
@@ -405,27 +415,32 @@ Graphics.printError = function(name, message) {
405
415
if ( this . _errorPrinter ) {
406
416
this . _updateErrorPrinter ( ) ;
407
417
this . _errorPrinter . innerHTML = this . _makeErrorHtml ( name , message ) ;
408
- this . _makeErrorMessage ( ) ;
418
+ this . _errorPrinter . style . userSelect = 'text' ;
419
+ this . _errorPrinter . style . webkitUserSelect = 'text' ;
420
+ this . _errorPrinter . style . msUserSelect = 'text' ;
421
+ this . _errorPrinter . style . mozUserSelect = 'text' ;
422
+ this . _errorPrinter . oncontextmenu = null ; // enable context menu
423
+ if ( this . _errorMessage ) {
424
+ this . _makeErrorMessage ( ) ;
425
+ }
409
426
}
410
427
this . _applyCanvasFilter ( ) ;
411
428
this . _clearUpperCanvas ( ) ;
412
429
} ;
413
430
414
431
/**
415
- * Shows the stacktrace of error.
432
+ * Shows the detail of error.
416
433
*
417
434
* @static
418
- * @method printStackTrace
435
+ * @method printErrorDetail
419
436
*/
420
- Graphics . printStackTrace = function ( stack ) {
421
- if ( this . _errorPrinter ) {
422
- stack = ( stack || '' )
423
- . replace ( / f i l e : .* j s \/ / g, '' )
424
- . replace ( / h t t p : .* j s \/ / g, '' )
425
- . replace ( / h t t p s : .* j s \/ / g, '' )
426
- . replace ( / c h r o m e - e x t e n s i o n : .* j s \/ / g, '' )
427
- . replace ( / \n / g, '<br>' ) ;
428
- this . _makeStackTrace ( decodeURIComponent ( stack ) ) ;
437
+ Graphics . printErrorDetail = function ( error ) {
438
+ if ( this . _errorPrinter && this . _showErrorDetail ) {
439
+ var eventInfo = this . _formatEventInfo ( error ) ;
440
+ var eventCommandInfo = this . _formatEventCommandInfo ( error ) ;
441
+ var info = eventCommandInfo ? eventInfo + ", " + eventCommandInfo : eventInfo ;
442
+ var stack = this . _formatStackTrace ( error ) ;
443
+ this . _makeErrorDetail ( info , stack ) ;
429
444
}
430
445
} ;
431
446
@@ -439,6 +454,16 @@ Graphics.setErrorMessage = function(message) {
439
454
this . _errorMessage = message ;
440
455
} ;
441
456
457
+ /**
458
+ * Sets whether shows the detail of error.
459
+ *
460
+ * @static
461
+ * @method setShowErrorDetail
462
+ */
463
+ Graphics . setShowErrorDetail = function ( showErrorDetail ) {
464
+ this . _showErrorDetail = showErrorDetail ;
465
+ } ;
466
+
442
467
/**
443
468
* Shows the FPSMeter element.
444
469
*
@@ -862,16 +887,17 @@ Graphics._createErrorPrinter = function() {
862
887
*/
863
888
Graphics . _updateErrorPrinter = function ( ) {
864
889
this . _errorPrinter . width = this . _width * 0.9 ;
865
- this . _errorPrinter . height = this . _errorShowed ? this . _height * 0.9 : 40 ;
890
+ if ( this . _errorShowed && this . _showErrorDetail ) {
891
+ this . _errorPrinter . height = this . _height * 0.9 ;
892
+ } else if ( this . _errorShowed && this . _errorMessage ) {
893
+ this . _errorPrinter . height = 100 ;
894
+ } else {
895
+ this . _errorPrinter . height = 40 ;
896
+ }
866
897
this . _errorPrinter . style . textAlign = 'center' ;
867
898
this . _errorPrinter . style . textShadow = '1px 1px 3px #000' ;
868
899
this . _errorPrinter . style . fontSize = '20px' ;
869
900
this . _errorPrinter . style . zIndex = 99 ;
870
- this . _errorPrinter . style . userSelect = 'text' ;
871
- this . _errorPrinter . style . webkitUserSelect = 'text' ;
872
- this . _errorPrinter . style . msUserSelect = 'text' ;
873
- this . _errorPrinter . style . mozUserSelect = 'text' ;
874
- this . _errorPrinter . oncontextmenu = null ; // enable context menu
875
901
this . _centerElement ( this . _errorPrinter ) ;
876
902
} ;
877
903
@@ -886,23 +912,82 @@ Graphics._makeErrorMessage = function() {
886
912
style . color = 'white' ;
887
913
style . textAlign = 'left' ;
888
914
style . fontSize = '18px' ;
889
- mainMessage . innerHTML = '<hr>' + ( this . _errorMessage || '' ) ;
915
+ mainMessage . innerHTML = '<hr>' + this . _errorMessage ;
890
916
this . _errorPrinter . appendChild ( mainMessage ) ;
891
917
} ;
892
918
893
919
/**
894
920
* @static
895
- * @method _makeStackTrace
921
+ * @method _makeErrorDetail
896
922
* @private
897
923
*/
898
- Graphics . _makeStackTrace = function ( stack ) {
899
- var stackTrace = document . createElement ( 'div' ) ;
900
- var style = stackTrace . style ;
924
+ Graphics . _makeErrorDetail = function ( info , stack ) {
925
+ var detail = document . createElement ( 'div' ) ;
926
+ var style = detail . style ;
901
927
style . color = 'white' ;
902
928
style . textAlign = 'left' ;
903
929
style . fontSize = '18px' ;
904
- stackTrace . innerHTML = '<br><hr>' + stack + '<hr>' ;
905
- this . _errorPrinter . appendChild ( stackTrace ) ;
930
+ detail . innerHTML = '<br><hr>' + info + '<br><br>' + stack ;
931
+ this . _errorPrinter . appendChild ( detail ) ;
932
+ } ;
933
+
934
+ /**
935
+ * @static
936
+ * @method _formatEventInfo
937
+ * @private
938
+ */
939
+ Graphics . _formatEventInfo = function ( error ) {
940
+ switch ( String ( error . eventType ) ) {
941
+ case "map_event" :
942
+ return "MapID: %1, MapEventID: %2, page: %3, line: %4" . format ( error . mapId , error . mapEventId , error . page , error . line ) ;
943
+ case "common_event" :
944
+ return "CommonEventID: %1, line: %2" . format ( error . commonEventId , error . line ) ;
945
+ case "battle_event" :
946
+ return "TroopID: %1, page: %2, line: %3" . format ( error . troopId , error . page , error . line ) ;
947
+ case "test_event" :
948
+ return "TestEvent, line: %1" . format ( error . line ) ;
949
+ default :
950
+ return "No information" ;
951
+ }
952
+ } ;
953
+
954
+ /**
955
+ * @static
956
+ * @method _formatEventCommandInfo
957
+ * @private
958
+ */
959
+ Graphics . _formatEventCommandInfo = function ( error ) {
960
+ switch ( String ( error . eventCommand ) ) {
961
+ case "plugin_command" :
962
+ return "◆Plugin Command: " + error . content ;
963
+ case "script" :
964
+ return "◆Script: " + error . content ;
965
+ case "control_variables" :
966
+ return "◆Control Variables: Script: " + error . content ;
967
+ case "conditional_branch_script" :
968
+ return "◆If: Script: " + error . content ;
969
+ case "set_route_script" :
970
+ return "◆Set Movement Route: ◇Script: " + error . content ;
971
+ case "auto_route_script" :
972
+ return "Autonomous Movement Custom Route: ◇Script: " + error . content ;
973
+ case "other" :
974
+ default :
975
+ return "" ;
976
+ }
977
+ } ;
978
+
979
+ /**
980
+ * @static
981
+ * @method _formatStackTrace
982
+ * @private
983
+ */
984
+ Graphics . _formatStackTrace = function ( error ) {
985
+ return decodeURIComponent ( ( error . stack || '' )
986
+ . replace ( / f i l e : .* j s \/ / g, '' )
987
+ . replace ( / h t t p : .* j s \/ / g, '' )
988
+ . replace ( / h t t p s : .* j s \/ / g, '' )
989
+ . replace ( / c h r o m e - e x t e n s i o n : .* j s \/ / g, '' )
990
+ . replace ( / \n / g, '<br>' ) ) ;
906
991
} ;
907
992
908
993
/**
0 commit comments