@@ -360,6 +360,11 @@ Graphics.printLoadingError = function(url) {
360360 if ( this . _errorPrinter && ! this . _errorShowed ) {
361361 this . _updateErrorPrinter ( ) ;
362362 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
363368 var button = document . createElement ( 'button' ) ;
364369 button . innerHTML = 'Retry' ;
365370 button . style . fontSize = '24px' ;
@@ -385,6 +390,11 @@ Graphics.printLoadingError = function(url) {
385390Graphics . eraseLoadingError = function ( ) {
386391 if ( this . _errorPrinter && ! this . _errorShowed ) {
387392 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 ; } ;
388398 this . startLoading ( ) ;
389399 }
390400} ;
@@ -405,27 +415,32 @@ Graphics.printError = function(name, message) {
405415 if ( this . _errorPrinter ) {
406416 this . _updateErrorPrinter ( ) ;
407417 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+ }
409426 }
410427 this . _applyCanvasFilter ( ) ;
411428 this . _clearUpperCanvas ( ) ;
412429} ;
413430
414431/**
415- * Shows the stacktrace of error.
432+ * Shows the detail of error.
416433 *
417434 * @static
418- * @method printStackTrace
435+ * @method printErrorDetail
419436 */
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 ) ;
429444 }
430445} ;
431446
@@ -439,6 +454,16 @@ Graphics.setErrorMessage = function(message) {
439454 this . _errorMessage = message ;
440455} ;
441456
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+
442467/**
443468 * Shows the FPSMeter element.
444469 *
@@ -862,16 +887,17 @@ Graphics._createErrorPrinter = function() {
862887 */
863888Graphics . _updateErrorPrinter = function ( ) {
864889 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+ }
866897 this . _errorPrinter . style . textAlign = 'center' ;
867898 this . _errorPrinter . style . textShadow = '1px 1px 3px #000' ;
868899 this . _errorPrinter . style . fontSize = '20px' ;
869900 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
875901 this . _centerElement ( this . _errorPrinter ) ;
876902} ;
877903
@@ -886,23 +912,82 @@ Graphics._makeErrorMessage = function() {
886912 style . color = 'white' ;
887913 style . textAlign = 'left' ;
888914 style . fontSize = '18px' ;
889- mainMessage . innerHTML = '<hr>' + ( this . _errorMessage || '' ) ;
915+ mainMessage . innerHTML = '<hr>' + this . _errorMessage ;
890916 this . _errorPrinter . appendChild ( mainMessage ) ;
891917} ;
892918
893919/**
894920 * @static
895- * @method _makeStackTrace
921+ * @method _makeErrorDetail
896922 * @private
897923 */
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 ;
901927 style . color = 'white' ;
902928 style . textAlign = 'left' ;
903929 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>' ) ) ;
906991} ;
907992
908993/**
0 commit comments