11// @ts -nocheck - Weird usage of `this` in this file. Should be refactored.
22
33namespace gdjs {
4+ const logger = new gdjs . Logger ( 'Dialogue tree' ) ;
5+
46 gdjs . dialogueTree = { } ;
57 gdjs . dialogueTree . runner = new bondage . Runner ( ) ;
68
@@ -21,7 +23,7 @@ namespace gdjs {
2123 gdjs . dialogueTree . startFrom ( startDialogueNode ) ;
2224 }
2325 } catch ( e ) {
24- console . error ( e ) ;
26+ logger . error ( 'Error while loading from scene variable: ' , e ) ;
2527 }
2628 } ;
2729
@@ -42,10 +44,7 @@ namespace gdjs {
4244 . getJsonManager ( )
4345 . loadJson ( jsonResourceName , function ( error , content ) {
4446 if ( error ) {
45- console . error (
46- 'An error happened while loading JSON resource:' ,
47- error
48- ) ;
47+ logger . error ( 'An error happened while loading JSON resource:' , error ) ;
4948 } else {
5049 if ( ! content ) {
5150 return ;
@@ -54,7 +53,7 @@ namespace gdjs {
5453 try {
5554 gdjs . dialogueTree . runner . load ( gdjs . dialogueTree . yarnData ) ;
5655 } catch ( error ) {
57- console . error (
56+ logger . error (
5857 'An error happened while loading parsing the dialogue tree data:' ,
5958 error
6059 ) ;
@@ -155,7 +154,7 @@ namespace gdjs {
155154 this . clipTextEnd >= this . dialogueText . length
156155 ) {
157156 if ( gdjs . dialogueTree . getVariable ( 'debug' ) ) {
158- console . warn (
157+ logger . warn (
159158 'Scroll completed:' ,
160159 this . clipTextEnd ,
161160 '/' ,
@@ -244,15 +243,15 @@ namespace gdjs {
244243 gdjs . dialogueTree . pauseScrolling = false ;
245244 commandCalls . splice ( index , 1 ) ;
246245 if ( gdjs . dialogueTree . getVariable ( 'debug' ) ) {
247- console . info ( 'CMD:' , call ) ;
246+ logger . info ( 'CMD:' , call ) ;
248247 }
249248 } , parseInt ( call . params [ 1 ] , 10 ) ) ;
250249 }
251250 if ( call . cmd === command ) {
252251 gdjs . dialogueTree . commandParameters = call . params ;
253252 commandCalls . splice ( index , 1 ) ;
254253 if ( gdjs . dialogueTree . getVariable ( 'debug' ) ) {
255- console . info ( 'CMD:' , call ) ;
254+ logger . info ( 'CMD:' , call ) ;
256255 }
257256 return true ;
258257 }
@@ -366,7 +365,7 @@ namespace gdjs {
366365 this . dialogueData = this . dialogue . next ( ) . value ;
367366 gdjs . dialogueTree . goToNextDialogueLine ( ) ;
368367 } catch ( error ) {
369- console . error (
368+ logger . error (
370369 `An error happened when trying to access the dialogue branch!` ,
371370 error
372371 ) ;
@@ -562,7 +561,7 @@ namespace gdjs {
562561 this . selectedOption = - 1 ;
563562 this . selectedOptionUpdated = false ;
564563 if ( gdjs . dialogueTree . getVariable ( 'debug' ) ) {
565- console . info ( 'parsing :' , this . dialogueData ) ;
564+ logger . info ( 'Parsing :' , this . dialogueData ) ;
566565 }
567566 if ( ! this . dialogueData ) {
568567 gdjs . dialogueTree . stopRunningDialogue ( ) ;
@@ -797,7 +796,7 @@ namespace gdjs {
797796 gdjs . dialogueTree . loadState = function ( inputVariable : gdjs . Variable ) {
798797 const loadedState = inputVariable . toJSObject ( ) ;
799798 if ( ! loadedState ) {
800- console . error ( 'Load state variable is empty:' , inputVariable ) ;
799+ logger . error ( 'Load state variable is empty:' , inputVariable ) ;
801800 return ;
802801 }
803802 try {
@@ -808,7 +807,7 @@ namespace gdjs {
808807 gdjs . dialogueTree . runner . variables . set ( key , value ) ;
809808 } ) ;
810809 } catch ( e ) {
811- console . error ( 'Failed to load state from variable:' , inputVariable , e ) ;
810+ logger . error ( 'Failed to load state from variable:' , inputVariable , e ) ;
812811 }
813812 } ;
814813
0 commit comments