Java Code Examples for org.newdawn.slick.util.Log#warn()
The following examples show how to use
org.newdawn.slick.util.Log#warn() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Utils.java From opsu with GNU General Public License v3.0 | 6 votes |
/** * Deletes a file or directory. If a system trash directory is available, * the file or directory will be moved there instead. * @param file the file or directory to delete * @return true if moved to trash, and false if deleted * @throws IOException if given file does not exist */ public static boolean deleteToTrash(File file) throws IOException { if (file == null) throw new IOException("File cannot be null."); if (!file.exists()) throw new IOException(String.format("File '%s' does not exist.", file.getAbsolutePath())); // move to system trash, if possible FileUtils fileUtils = FileUtils.getInstance(); if (fileUtils.hasTrash()) { try { fileUtils.moveToTrash(new File[] { file }); return true; } catch (IOException e) { Log.warn(String.format("Failed to move file '%s' to trash.", file.getAbsolutePath()), e); } } // delete otherwise if (file.isDirectory()) deleteDirectory(file); else file.delete(); return false; }
Example 2
Source File: Fonts.java From opsu with GNU General Public License v3.0 | 6 votes |
/** * Adds and loads glyphs for a font. * @param font the font to add the glyphs to * @param s the string containing the glyphs to load */ public static void loadGlyphs(UnicodeFont font, String s) { if (s == null || s.isEmpty()) return; // get set of added strings HashSet<String> set = loadedGlyphs.get(font); if (set == null) { set = new HashSet<String>(); loadedGlyphs.put(font, set); } else if (set.contains(s)) return; // string already in set // load glyphs font.addGlyphs(s); set.add(s); try { font.loadGlyphs(); } catch (SlickException e) { Log.warn(String.format("Failed to load glyphs for string '%s'.", s), e); } }
Example 3
Source File: ParticleSystem.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Get a new particle from the system. This should be used by emitters to * request particles * * @param emitter The emitter requesting the particle * @param life The time the new particle should live for * @return A particle from the system */ public Particle getNewParticle(ParticleEmitter emitter, float life) { ParticlePool pool = (ParticlePool) particlesByEmitter.get(emitter); ArrayList available = pool.available; if (available.size() > 0) { Particle p = (Particle) available.remove(available.size()-1); p.init(emitter, life); p.setImage(sprite); return p; } Log.warn("Ran out of particles (increase the limit)!"); return dummy; }
Example 4
Source File: BeatmapDifficultyCalculator.java From opsu with GNU General Public License v3.0 | 6 votes |
/** * Computes the strain values for the beatmap. * @return true if successful, false otherwise */ private boolean calculateStrainValues() { // Traverse hitObjects in pairs to calculate the strain value of NextHitObject from // the strain value of CurrentHitObject and environment. if (tpHitObjects.length == 0) { Log.warn("Can not compute difficulty of empty beatmap."); return false; } tpHitObject currentHitObject = tpHitObjects[0]; tpHitObject nextHitObject; int index = 0; // First hitObject starts at strain 1. 1 is the default for strain values, // so we don't need to set it here. See tpHitObject. while (++index < tpHitObjects.length) { nextHitObject = tpHitObjects[index]; nextHitObject.calculateStrains(currentHitObject); currentHitObject = nextHitObject; } return true; }
Example 5
Source File: BeatmapDifficultyCalculator.java From opsu-dance with GNU General Public License v3.0 | 6 votes |
/** * Computes the strain values for the beatmap. * @return true if successful, false otherwise */ private boolean calculateStrainValues() { // Traverse hitObjects in pairs to calculate the strain value of NextHitObject from // the strain value of CurrentHitObject and environment. if (tpHitObjects.length == 0) { Log.warn("Can not compute difficulty of empty beatmap."); return false; } tpHitObject currentHitObject = tpHitObjects[0]; tpHitObject nextHitObject; int index = 0; // First hitObject starts at strain 1. 1 is the default for strain values, // so we don't need to set it here. See tpHitObject. while (++index < tpHitObjects.length) { nextHitObject = tpHitObjects[index]; nextHitObject.calculateStrains(currentHitObject); currentHitObject = nextHitObject; } return true; }
Example 6
Source File: Fonts.java From opsu-dance with GNU General Public License v3.0 | 6 votes |
/** * Adds and loads glyphs for a font. * @param font the font to add the glyphs to * @param s the string containing the glyphs to load */ public static void loadGlyphs(UnicodeFont font, String s) { if (s == null || s.isEmpty()) return; // get set of added strings HashSet<String> set = loadedGlyphs.get(font); if (set == null) { set = new HashSet<String>(); loadedGlyphs.put(font, set); } else if (set.contains(s)) return; // string already in set // load glyphs font.addGlyphs(s); set.add(s); try { font.loadGlyphs(); } catch (SlickException e) { Log.warn(String.format("Failed to load glyphs for string '%s'.", s), e); } }
Example 7
Source File: GraphicsFactory.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Create an underlying graphics context for the given image * * @param image The image we want to render to * @return The graphics context created * @throws SlickException */ private static Graphics createGraphics(Image image) throws SlickException { init(); if (fbo) { try { return new FBOGraphics(image); } catch (Exception e) { fbo = false; Log.warn("FBO failed in use, falling back to PBuffer"); } } if (pbuffer) { if (pbufferRT) { return new PBufferGraphics(image); } else { return new PBufferUniqueGraphics(image); } } throw new SlickException("Failed to create offscreen buffer even though the card reports it's possible"); }
Example 8
Source File: Fonts.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Adds and loads glyphs for a font. * @param font the font to add the glyphs to * @param c the character to load */ public static void loadGlyphs(UnicodeFont font, char c) { font.addGlyphs(c, c); try { font.loadGlyphs(); } catch (SlickException e) { Log.warn(String.format("Failed to load glyphs for codepoint '%d'.", (int) c), e); } }
Example 9
Source File: OpenALStreamPlayer.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Seeks to a position in the music. * * @param position Position in seconds. * @return True if the setting of the position was successful */ public synchronized boolean setPosition(float position) { try { long samplePos = (long) (position * sampleRate) * sampleSize; if (streamPos > samplePos) initStreams(); long skipped = audio.skip(samplePos - streamPos); if (skipped >= 0) streamPos += skipped; else Log.warn("OpenALStreamPlayer: setPosition: failed to skip."); while (streamPos + buffer.length < samplePos) { int count = audio.read(buffer); if (count != -1) { streamPos += count; } else { if (loop) { initStreams(); } else { done = true; } return false; } } playedPos = streamPos; syncStartTime = (long) (getTime() - (playedPos * 1000 / sampleSize / sampleRate) / pitch); startPlayback(); return true; } catch (IOException e) { Log.error(e); return false; } }
Example 10
Source File: ImageLoader.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Releases all resources. */ public void destroy() { interrupt(); loaderThread = null; if (image != null && !image.isDestroyed()) { try { image.destroy(); } catch (SlickException e) { Log.warn(String.format("Failed to destroy image '%s'.", image.getResourceReference()), e); } image = null; } data = null; }
Example 11
Source File: ParticleIO.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Create an XML element based on a configured value * * @param document * The document the element will be part of * @param name * The name to give the new element * @param value * The configured value * @return A configure XML element based on the value */ private static Element createValueElement(Document document, String name, ConfigurableEmitter.Value value) { Element element = document.createElement(name); // void: now writes the value type if (value instanceof SimpleValue) { element.setAttribute("type", "simple"); element.setAttribute("value", "" + value.getValue(0)); } else if (value instanceof RandomValue) { element.setAttribute("type", "random"); element .setAttribute("value", "" + ((RandomValue) value).getValue()); } else if (value instanceof LinearInterpolator) { element.setAttribute("type", "linear"); element.setAttribute("min", "" + ((LinearInterpolator) value).getMin()); element.setAttribute("max", "" + ((LinearInterpolator) value).getMax()); element.setAttribute("active", "" + ((LinearInterpolator) value).isActive()); ArrayList curve = ((LinearInterpolator) value).getCurve(); for (int i = 0; i < curve.size(); i++) { Vector2f point = (Vector2f) curve.get(i); Element pointElement = document.createElement("point"); pointElement.setAttribute("x", "" + point.x); pointElement.setAttribute("y", "" + point.y); element.appendChild(pointElement); } } else { Log.warn("unkown value type ignored: " + value.getClass()); } return element; }
Example 12
Source File: ImageLoader.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
@Override public void run() { // load image data into a ByteBuffer to use constructor Image(ImageData) LoadableImageData imageData = ImageDataFactory.getImageDataFor(file.getAbsolutePath()); try (BufferedInputStream in = this.in = new BufferedInputStream(new FileInputStream(file))) { ByteBuffer textureBuffer = imageData.loadImage(in, false, null); if (!isInterrupted()) data = new LoadedImageData(imageData, textureBuffer); } catch (IOException e) { if (!isInterrupted()) Log.warn(String.format("Failed to load background image '%s'.", file), e); } this.in = null; }
Example 13
Source File: CompositeImageData.java From slick2d-maven with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @see org.newdawn.slick.opengl.LoadableImageData#loadImage(java.io.InputStream, boolean, boolean, int[]) */ public ByteBuffer loadImage(InputStream is, boolean flipped, boolean forceAlpha, int[] transparent) throws IOException { CompositeIOException exception = new CompositeIOException(); ByteBuffer buffer = null; BufferedInputStream in = new BufferedInputStream(is, is.available()); in.mark(is.available()); // cycle through our source until one of them works for (int i=0;i<sources.size();i++) { in.reset(); try { LoadableImageData data = (LoadableImageData) sources.get(i); buffer = data.loadImage(in, flipped, forceAlpha, transparent); picked = data; break; } catch (Exception e) { Log.warn(sources.get(i).getClass()+" failed to read the data", e); exception.addException(e); } } if (picked == null) { throw exception; } return buffer; }
Example 14
Source File: Curve.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Set the width and height of the container that Curves get drawn into. * Should be called before any curves are drawn. * @param width the container width * @param height the container height * @param circleDiameter the circle diameter * @param borderColor the curve border color */ public static void init(int width, int height, float circleDiameter, Color borderColor) { Curve.borderColor = borderColor; ContextCapabilities capabilities = GLContext.getCapabilities(); mmsliderSupported = capabilities.OpenGL30; if (mmsliderSupported) { CurveRenderState.init(width, height, circleDiameter); LegacyCurveRenderState.init(width, height, circleDiameter); } else { if (Options.getSkin().getSliderStyle() != Skin.STYLE_PEPPYSLIDER) Log.warn("New slider style requires OpenGL 3.0."); } }
Example 15
Source File: Splash.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCloseRequest() { if (thread == null || !thread.isAlive()) { return true; } thread.interrupt(); try { thread.join(); } catch (InterruptedException e) { Log.warn("InterruptedException while waiting for splash thread to die", e); } return true; }
Example 16
Source File: Curve.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
/** * Init curves for given circle diameter * Should be called before any curves are drawn. * @param circleDiameter the circle diameter * @param borderColor the curve border color */ public static void init(float circleDiameter, Color borderColor) { Curve.borderColor = borderColor; ContextCapabilities capabilities = GLContext.getCapabilities(); mmsliderSupported = capabilities.OpenGL30; if (mmsliderSupported) { CurveRenderState.init(circleDiameter); } else if (SkinService.skin.getSliderStyle() != Skin.STYLE_PEPPYSLIDER) { Log.warn("New slider style requires OpenGL 3.0."); } }
Example 17
Source File: NativeLoader.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
private static void setNativePath(String path) { System.setProperty("org.lwjgl.librarypath", path); System.setProperty("java.library.path", path); try { // reset variable so it will re-read the properties that were just set // http://stackoverflow.com/a/24988095 Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths"); fieldSysPath.setAccessible(true); fieldSysPath.set(null, null); } catch (Exception e) { Log.warn("Failed to reset 'sys_paths' field.", e); } }
Example 18
Source File: ErrorHandler.java From opsu-dance with GNU General Public License v3.0 | 5 votes |
private static URI createGithubIssueUrl(String customMessage, Throwable cause) { String issueTitle = ""; String issueBody = ""; try { issueTitle = URLEncoder.encode("*** Unhandled " + cause.getClass().getSimpleName() + ": " + customMessage, "UTF-8"); issueBody = URLEncoder.encode("PASTE THE DUMP HERE", "UTF-8"); } catch (UnsupportedEncodingException e) { Log.warn("URLEncoder failed to encode the auto-filled issue report URL.", e); } return URI.create(String.format(Constants.ISSUES_URL, issueTitle, issueBody)); }
Example 19
Source File: ErrorHandler.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Returns the issue reporting URI with the given title and body. * @param title the issue title * @param body the issue body * @return the encoded URI */ public static URI getIssueURI(String title, String body) { try { return URI.create(String.format(OpsuConstants.ISSUES_URL, URLEncoder.encode(title, "UTF-8"), URLEncoder.encode(body, "UTF-8")) ); } catch (UnsupportedEncodingException e) { Log.warn("URLEncoder failed to encode the auto-filled issue report URL."); return URI.create(String.format(OpsuConstants.ISSUES_URL, "", "")); } }
Example 20
Source File: UI.java From opsu with GNU General Public License v3.0 | 5 votes |
/** * Shows a confirmation dialog (used before exiting the game). * @param message the message to display * @return true if user selects "yes", false otherwise */ public static boolean showExitConfirmation(String message) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { Log.warn("Could not set system look and feel for exit confirmation.", e); } int n = JOptionPane.showConfirmDialog(null, message, "Warning", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE); return (n != JOptionPane.YES_OPTION); }