@@ -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 *
@@ -759,6 +784,7 @@ Graphics._updateAllElements = function() {
759784 this . _updateUpperCanvas ( ) ;
760785 this . _updateRenderer ( ) ;
761786 this . _paintUpperCanvas ( ) ;
787+ this . _updateProgress ( ) ;
762788} ;
763789
764790/**
@@ -862,16 +888,17 @@ Graphics._createErrorPrinter = function() {
862888 */
863889Graphics . _updateErrorPrinter = function ( ) {
864890 this . _errorPrinter . width = this . _width * 0.9 ;
865- this . _errorPrinter . height = this . _errorShowed ? this . _height * 0.9 : 40 ;
891+ if ( this . _errorShowed && this . _showErrorDetail ) {
892+ this . _errorPrinter . height = this . _height * 0.9 ;
893+ } else if ( this . _errorShowed && this . _errorMessage ) {
894+ this . _errorPrinter . height = 100 ;
895+ } else {
896+ this . _errorPrinter . height = 40 ;
897+ }
866898 this . _errorPrinter . style . textAlign = 'center' ;
867899 this . _errorPrinter . style . textShadow = '1px 1px 3px #000' ;
868900 this . _errorPrinter . style . fontSize = '20px' ;
869901 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
875902 this . _centerElement ( this . _errorPrinter ) ;
876903} ;
877904
@@ -886,23 +913,82 @@ Graphics._makeErrorMessage = function() {
886913 style . color = 'white' ;
887914 style . textAlign = 'left' ;
888915 style . fontSize = '18px' ;
889- mainMessage . innerHTML = '<hr>' + ( this . _errorMessage || '' ) ;
916+ mainMessage . innerHTML = '<hr>' + this . _errorMessage ;
890917 this . _errorPrinter . appendChild ( mainMessage ) ;
891918} ;
892919
893920/**
894921 * @static
895- * @method _makeStackTrace
922+ * @method _makeErrorDetail
896923 * @private
897924 */
898- Graphics . _makeStackTrace = function ( stack ) {
899- var stackTrace = document . createElement ( 'div' ) ;
900- var style = stackTrace . style ;
925+ Graphics . _makeErrorDetail = function ( info , stack ) {
926+ var detail = document . createElement ( 'div' ) ;
927+ var style = detail . style ;
901928 style . color = 'white' ;
902929 style . textAlign = 'left' ;
903930 style . fontSize = '18px' ;
904- stackTrace . innerHTML = '<br><hr>' + stack + '<hr>' ;
905- this . _errorPrinter . appendChild ( stackTrace ) ;
931+ detail . innerHTML = '<br><hr>' + info + '<br><br>' + stack ;
932+ this . _errorPrinter . appendChild ( detail ) ;
933+ } ;
934+
935+ /**
936+ * @static
937+ * @method _formatEventInfo
938+ * @private
939+ */
940+ Graphics . _formatEventInfo = function ( error ) {
941+ switch ( String ( error . eventType ) ) {
942+ case "map_event" :
943+ return "MapID: %1, MapEventID: %2, page: %3, line: %4" . format ( error . mapId , error . mapEventId , error . page , error . line ) ;
944+ case "common_event" :
945+ return "CommonEventID: %1, line: %2" . format ( error . commonEventId , error . line ) ;
946+ case "battle_event" :
947+ return "TroopID: %1, page: %2, line: %3" . format ( error . troopId , error . page , error . line ) ;
948+ case "test_event" :
949+ return "TestEvent, line: %1" . format ( error . line ) ;
950+ default :
951+ return "No information" ;
952+ }
953+ } ;
954+
955+ /**
956+ * @static
957+ * @method _formatEventCommandInfo
958+ * @private
959+ */
960+ Graphics . _formatEventCommandInfo = function ( error ) {
961+ switch ( String ( error . eventCommand ) ) {
962+ case "plugin_command" :
963+ return "◆Plugin Command: " + error . content ;
964+ case "script" :
965+ return "◆Script: " + error . content ;
966+ case "control_variables" :
967+ return "◆Control Variables: Script: " + error . content ;
968+ case "conditional_branch_script" :
969+ return "◆If: Script: " + error . content ;
970+ case "set_route_script" :
971+ return "◆Set Movement Route: ◇Script: " + error . content ;
972+ case "auto_route_script" :
973+ return "Autonomous Movement Custom Route: ◇Script: " + error . content ;
974+ case "other" :
975+ default :
976+ return "" ;
977+ }
978+ } ;
979+
980+ /**
981+ * @static
982+ * @method _formatStackTrace
983+ * @private
984+ */
985+ Graphics . _formatStackTrace = function ( error ) {
986+ return decodeURIComponent ( ( error . stack || '' )
987+ . replace ( / f i l e : .* j s \/ / g, '' )
988+ . replace ( / h t t p : .* j s \/ / g, '' )
989+ . replace ( / h t t p s : .* j s \/ / g, '' )
990+ . replace ( / c h r o m e - e x t e n s i o n : .* j s \/ / g, '' )
991+ . replace ( / \n / g, '<br>' ) ) ;
906992} ;
907993
908994/**
0 commit comments