# HG changeset patch # User Matti Hamalainen # Date 1556013625 -10800 # Node ID 8dbaa093c56252d38efe4193e233f1765c4d3dfb # Parent edf4081fecd61eea1041ecc21bb1c81b275ef679 Improve debug message handling. diff -r edf4081fecd6 -r 8dbaa093c562 game/Engine.java --- a/game/Engine.java Thu Apr 04 12:47:29 2019 +0300 +++ b/game/Engine.java Tue Apr 23 13:00:25 2019 +0300 @@ -571,13 +571,13 @@ public void dbg(String msg) { - System.out.print("Engine: " + msg); + G.debug("Engine: " + msg); } public Engine() { // Initialize globals - System.out.print("Engine() constructor\n"); + G.debug("Engine() constructor\n"); // Sound system G.smgr = new SoundManager(new AudioFormat(22050, 16, 1, true, false), 1); diff -r edf4081fecd6 -r 8dbaa093c562 game/G.java --- a/game/G.java Thu Apr 04 12:47:29 2019 +0300 +++ b/game/G.java Tue Apr 23 13:00:25 2019 +0300 @@ -31,4 +31,9 @@ public static Dimension screenDim; public static BufferedImage lautaBG = null, lautaBGScaled = null; + + public static void debug(String msg) + { + System.out.print(msg); + } } diff -r edf4081fecd6 -r 8dbaa093c562 game/IDMButton.java --- a/game/IDMButton.java Thu Apr 04 12:47:29 2019 +0300 +++ b/game/IDMButton.java Tue Apr 23 13:00:25 2019 +0300 @@ -66,7 +66,7 @@ } catch (IOException e) { - System.out.print(e.getMessage()); + G.debug(e.getMessage()); } } diff -r edf4081fecd6 -r 8dbaa093c562 game/ResourceLoader.java --- a/game/ResourceLoader.java Thu Apr 04 12:47:29 2019 +0300 +++ b/game/ResourceLoader.java Tue Apr 23 13:00:25 2019 +0300 @@ -22,7 +22,7 @@ if (resourceURL != null) stream = getClass().getClassLoader().getResourceAsStream(name); - System.out.print("ResourceLoader('"+ name +"'): "+ resourceURL +" - "+ stream +"\n"); + G.debug("ResourceLoader('"+ name +"'): "+ resourceURL +" - "+ stream +"\n"); } public InputStream getStream() diff -r edf4081fecd6 -r 8dbaa093c562 game/SoundManager.java --- a/game/SoundManager.java Thu Apr 04 12:47:29 2019 +0300 +++ b/game/SoundManager.java Tue Apr 23 13:00:25 2019 +0300 @@ -36,7 +36,7 @@ int numThreads = Math.min(maxSounds, getMaxSimultaneousSounds(playbackFormat)); - System.out.print("SMGR.SoundManager() initializing with " + numThreads +" max sounds\n"); + G.debug("SMGR.SoundManager() initializing with " + numThreads +" max sounds\n"); setDaemon(true); alive = true; @@ -62,11 +62,11 @@ DataLine.Info lineInfo = new DataLine.Info(SourceDataLine.class, playbackFormat); Mixer.Info[] info = AudioSystem.getMixerInfo(); - System.out.print("SMGR.getMaxSimultaneousSounds() mixer information:\n"); + G.debug("SMGR.getMaxSimultaneousSounds() mixer information:\n"); Mixer.Info select = null; for (Mixer.Info i : info) { - System.out.print(" - '"+i.getName()+"'\n"); + G.debug(" - '"+i.getName()+"'\n"); if (i.getName().equals("Java Sound Audio Engine")) select = i; } @@ -74,13 +74,13 @@ Mixer mixer = AudioSystem.getMixer(select); Mixer.Info i = mixer.getMixerInfo(); - System.out.print(" * selected='"+i.getName()+"'\n"); + G.debug(" * selected='"+i.getName()+"'\n"); int maxLines = mixer.getMaxLines(lineInfo); if (maxLines == AudioSystem.NOT_SPECIFIED) maxLines = 8; - System.out.print(" * maxLines="+maxLines+"\n"); + G.debug(" * maxLines="+maxLines+"\n"); return maxLines; } @@ -88,18 +88,18 @@ protected void cleanUp() { - System.out.print("SMGR.cleanUp()\n"); + G.debug("SMGR.cleanUp()\n"); // signal to unpause setPaused(false); - System.out.print("SMGR.cleanUp(): closing mixer\n"); + G.debug("SMGR.cleanUp(): closing mixer\n"); // close the mixer (stops any running sounds) Mixer mixer = AudioSystem.getMixer(null); if (mixer.isOpen()) mixer.close(); - System.out.print("SMGR.cleanUp(): leaving\n"); + G.debug("SMGR.cleanUp(): leaving\n"); } @@ -168,7 +168,7 @@ ResourceLoader res = new ResourceLoader(filename); if (res == null || res.getStream() == null) { - System.out.print("Could not load audio resource '"+ filename +"'.\n"); + G.debug("Could not load audio resource '"+ filename +"'.\n"); return null; } try { @@ -176,7 +176,7 @@ } catch (Exception ex) { - System.out.print("Could not get AudioInputStream for '"+ filename +"'\n"); + G.debug("Could not get AudioInputStream for '"+ filename +"'\n"); return null; } } @@ -223,7 +223,7 @@ public InputStream play(InputStream is) { - System.out.print("SMGR.play(is="+is+")\n"); + G.debug("SMGR.play(is="+is+")\n"); if (is != null) { runTask(new SoundPlayer(is)); @@ -251,7 +251,7 @@ SourceDataLine line; DataLine.Info lineInfo = new DataLine.Info(SourceDataLine.class, playbackFormat); - System.out.print("SMGR.threadStarted(): "+lineInfo.toString()+"\n"); + G.debug("SMGR.threadStarted(): "+lineInfo.toString()+"\n"); try { line = (SourceDataLine) AudioSystem.getLine(lineInfo); @@ -259,7 +259,7 @@ } catch (LineUnavailableException ex) { - System.out.print("SMGR.threadStarted() line unavailable!\n"); + G.debug("SMGR.threadStarted() line unavailable!\n"); // the line is unavailable - signal to end this thread Thread.currentThread().interrupt(); return; @@ -286,7 +286,7 @@ protected void threadStopped() { - System.out.print("SMGR.threadStopped()\n"); + G.debug("SMGR.threadStopped()\n"); SourceDataLine line = (SourceDataLine) localLine.get(); if (line != null) { @@ -382,11 +382,11 @@ public synchronized void close() { - System.out.print("SMGR.close()\n"); + G.debug("SMGR.close()\n"); if (alive) { - System.out.print("SMGR.close(): alive queue clear\n"); + G.debug("SMGR.close(): alive queue clear\n"); // Clear queue alive = false; queue.clear(); @@ -394,13 +394,13 @@ } cleanUp(); - System.out.print("SMGR.close(): leaving\n"); + G.debug("SMGR.close(): leaving\n"); } public void join() { - System.out.print("SMGR.join()\n"); + G.debug("SMGR.join()\n"); cleanUp(); synchronized (this)