@@ -420,27 +420,32 @@ Graphics.printError = function(name, message) {
420420 this . _errorPrinter . style . msUserSelect = 'text' ;
421421 this . _errorPrinter . style . mozUserSelect = 'text' ;
422422 this . _errorPrinter . oncontextmenu = null ; // enable context menu
423- this . _makeErrorMessage ( ) ;
423+ if ( this . _errorMessage ) {
424+ this . _makeErrorMessage ( ) ;
425+ }
424426 }
425427 this . _applyCanvasFilter ( ) ;
426428 this . _clearUpperCanvas ( ) ;
427429} ;
428430
429431/**
430- * Shows the stacktrace of error.
432+ * Shows the detail of error.
431433 *
432434 * @static
433- * @method printStackTrace
435+ * @method printErrorDetail
434436 */
435- Graphics . printStackTrace = function ( stack ) {
436- if ( this . _errorPrinter ) {
437- stack = ( 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 = ( error . stack || '' )
438443 . replace ( / f i l e : .* j s \/ / g, '' )
439444 . replace ( / h t t p : .* j s \/ / g, '' )
440445 . replace ( / h t t p s : .* j s \/ / g, '' )
441446 . replace ( / c h r o m e - e x t e n s i o n : .* j s \/ / g, '' )
442447 . replace ( / \n / g, '<br>' ) ;
443- this . _makeStackTrace ( decodeURIComponent ( stack ) ) ;
448+ this . _makeErrorDetail ( info , decodeURIComponent ( stack ) ) ;
444449 }
445450} ;
446451
@@ -454,6 +459,16 @@ Graphics.setErrorMessage = function(message) {
454459 this . _errorMessage = message ;
455460} ;
456461
462+ /**
463+ * Sets whether shows the detail of error.
464+ *
465+ * @static
466+ * @method setShowErrorDetail
467+ */
468+ Graphics . setShowErrorDetail = function ( showErrorDetail ) {
469+ this . _showErrorDetail = showErrorDetail ;
470+ } ;
471+
457472/**
458473 * Shows the FPSMeter element.
459474 *
@@ -877,7 +892,13 @@ Graphics._createErrorPrinter = function() {
877892 */
878893Graphics . _updateErrorPrinter = function ( ) {
879894 this . _errorPrinter . width = this . _width * 0.9 ;
880- this . _errorPrinter . height = this . _errorShowed ? this . _height * 0.9 : 40 ;
895+ if ( this . _errorShowed && this . _showErrorDetail ) {
896+ this . _errorPrinter . height = this . _height * 0.9 ;
897+ } else if ( this . _errorShowed && this . _errorMessage ) {
898+ this . _errorPrinter . height = 100 ;
899+ } else {
900+ this . _errorPrinter . height = 40 ;
901+ }
881902 this . _errorPrinter . style . textAlign = 'center' ;
882903 this . _errorPrinter . style . textShadow = '1px 1px 3px #000' ;
883904 this . _errorPrinter . style . fontSize = '20px' ;
@@ -896,23 +917,66 @@ Graphics._makeErrorMessage = function() {
896917 style . color = 'white' ;
897918 style . textAlign = 'left' ;
898919 style . fontSize = '18px' ;
899- mainMessage . innerHTML = '<hr>' + ( this . _errorMessage || '' ) ;
920+ mainMessage . innerHTML = '<hr>' + this . _errorMessage ;
900921 this . _errorPrinter . appendChild ( mainMessage ) ;
901922} ;
902923
903924/**
904925 * @static
905- * @method _makeStackTrace
926+ * @method _makeErrorDetail
906927 * @private
907928 */
908- Graphics . _makeStackTrace = function ( stack ) {
909- var stackTrace = document . createElement ( 'div' ) ;
910- var style = stackTrace . style ;
929+ Graphics . _makeErrorDetail = function ( info , stack ) {
930+ var detail = document . createElement ( 'div' ) ;
931+ var style = detail . style ;
911932 style . color = 'white' ;
912933 style . textAlign = 'left' ;
913934 style . fontSize = '18px' ;
914- stackTrace . innerHTML = '<br><hr>' + stack + '<hr>' ;
915- this . _errorPrinter . appendChild ( stackTrace ) ;
935+ detail . innerHTML = '<br><hr>' + info + '<br><br>' + stack ;
936+ this . _errorPrinter . appendChild ( detail ) ;
937+ } ;
938+
939+ /**
940+ * @static
941+ * @method _formatEventInfo
942+ * @private
943+ */
944+ Graphics . _formatEventInfo = function ( error ) {
945+ switch ( String ( error . eventType ) ) {
946+ case "map_event" :
947+ return "MapID: %1, MapEventID: %2, page: %3, line: %4" . format ( error . mapId , error . mapEventId , error . page , error . line ) ;
948+ case "common_event" :
949+ return "CommonEventID: %1, line: %2" . format ( error . commonEventId , error . line ) ;
950+ case "battle_event" :
951+ return "TroopID: %1, page: %2, line: %3" . format ( error . troopId , error . page , error . line ) ;
952+ case "test_event" :
953+ return "TestEvent, line: %1" . format ( error . line ) ;
954+ default :
955+ return "No information" ;
956+ }
957+ } ;
958+
959+ /**
960+ * @static
961+ * @method _formatEventCommandInfo
962+ * @private
963+ */
964+ Graphics . _formatEventCommandInfo = function ( error ) {
965+ switch ( String ( error . eventCommand ) ) {
966+ case "plugin_command" :
967+ return "◆Plugin Command: " + error . content ;
968+ case "script" :
969+ return "◆Script: " + error . content ;
970+ case "conditional_branch_script" :
971+ return "◆Conditional Branch(Script): " + error . content ;
972+ case "set_route_script" :
973+ return "◆Set Movement Route(Script): " + error . content ;
974+ case "auto_route_script" :
975+ return "Autonomous Movement Custom Route(Script): " + error . content ;
976+ case "other" :
977+ default :
978+ return "" ;
979+ }
916980} ;
917981
918982/**
0 commit comments