public void onLoadComplete(SoundPool soundPool, int soundId, int status) { PooledSound sound = loadingSounds.remove(soundId); if (sound == null) { platform.log().warn("Got load complete for unknown sound [id=" + soundId + "]"); } else if (status == 0) { dispatchLoaded(sound, soundId); } else { dispatchLoadError(sound, new Exception("Sound load failed [errcode=" + status + "]")); } } });
@Override public void invoke(long window, int keyCode, int scancode, int action, int mods) { double time = System.currentTimeMillis(); Key key = translateKey(keyCode); boolean pressed = action == GLFW_PRESS || action == GLFW_REPEAT; if (key != null) emitKeyPress(toModifierFlags(mods), time, key, pressed); else plat.log().warn("Unknown keyCode:" + keyCode); } };
@Override public Iterable<String> keys() { try { return Arrays.asList(preferences.keys()); } catch (Exception e) { log.warn("Error reading preferences: " + e.getMessage()); return Collections.emptyList(); } }
@Override public Iterable<String> keys() { try { return Arrays.asList(preferences.keys()); } catch (Exception e) { log.warn("Error reading preferences: " + e.getMessage()); return Collections.emptyList(); } }
public void onLoadComplete(SoundPool soundPool, int soundId, int status) { PooledSound sound = loadingSounds.remove(soundId); if (sound == null) { platform.log().warn("Got load complete for unknown sound [id=" + soundId + "]"); } else if (status == 0) { dispatchLoaded(sound, soundId); } else { dispatchLoadError(sound, new Exception("Sound load failed [errcode=" + status + "]")); } } });
protected void execute (Platform plat, Runnable runnable) { try { runnable.run(); } catch (Exception e) { plat.log().warn("Action failed", e); } }
@Override public Iterable<String> keys() { try { return Arrays.asList(preferences.keys()); } catch (Exception e) { platform.log().warn("Error reading preferences: " + e.getMessage()); return Collections.emptyList(); } }
@Override public Iterable<String> keys() { try { return Arrays.asList(preferences.keys()); } catch (Exception e) { platform.log().warn("Error reading preferences: " + e.getMessage()); return Collections.emptyList(); } }
@Override public void checkGLError(String op) { if (checkErrors) { int error; while ((error = gl.glGetError()) != GL_NO_ERROR) { platform.log().warn(this.getClass().getName() + " -- " + op + ": glError " + error); } } }
/** Logs {@code msg} at the warn level. * @param args additional arguments formatted via {@link #format} and appended to the message. * {@code args} may contain an exception as its lone final argument which will be logged long * with the formatted message. */ public void warn (String msg, Object... args) { warn(format(msg, args), getCause(args)); }
public void run () { try { AVAudioPlayer player = new AVAudioPlayer(url); dispatchLoaded(sound, player); } catch (NSErrorException e) { platform.log().warn("Error loading sound [" + url + "]: " + e); dispatchLoadError(sound, e); } } });
/** Logs {@code msg} at the warn level. * @param args additional arguments formatted via {@link #format} and appended to the message. * {@code args} may contain an exception as its lone final argument which will be logged long * with the formatted message. */ public void warn (String msg, Object... args) { warn(format(msg, args), getCause(args)); }
protected void takeFocus (ActiveScreen as) { try { as.screen.lostFocus(); } catch (Exception e) { _game.plat.log().warn("Screen choked in lostFocus() [screen=" + as.screen + "]", e); } }
private Sound createSound(String path, boolean isMusic) { // look for .caf (uncompressed), .aifc (compressed, but fast), then .mp3 for (String encpath : new String[] { path + ".caf", path + ".aifc", path + ".mp3" }) { File fullPath = resolvePath(encpath); if (!fullPath.exists()) continue; return platform.audio().createSound(fullPath, isMusic); } platform.log().warn("Missing sound: " + path); return new Sound.Error(new FileNotFoundException(path)); } }
private Sound createSound(String path, boolean isMusic) { // look for .caf (uncompressed), .aifc (compressed, but fast), then .mp3 for (String encpath : new String[] { path + ".caf", path + ".aifc", path + ".mp3" }) { File fullPath = resolvePath(encpath); if (!fullPath.exists()) continue; return plat.audio().createSound(fullPath, isMusic); } plat.log().warn("Missing sound: " + path); return new Sound.Error(new FileNotFoundException(path)); }
/** * Called when a backend (or other framework code) encounters an exception that it can recover * from, but which it would like to report in some orderly fashion. <em>NOTE:</em> this method * may be called from threads other than the main PlayN thread. */ public void reportError (String message, Throwable cause) { errors.emit(new Error(message, cause)); log().warn(message, cause); }
/** * Called when a backend (or other framework code) encounters an exception that it can recover * from, but which it would like to report in some orderly fashion. <em>NOTE:</em> this method * may be called from threads other than the main PlayN thread. */ public void reportError (String message, Throwable cause) { errors.emit(new Error(message, cause)); log().warn(message, cause); }
@Override public void openURL(String url) { if (!UIApplication.getSharedApplication().openURL(new NSURL(url))) { log().warn("Failed to open URL: " + url); } }
public void run () { try { sound.succeed(new AVAudioPlayer(url)); } catch (Exception e) { plat.log().warn("Error loading sound [" + url + "]", e); sound.fail(e); } } });
@Override public void openURL(String url) { if (!UIApplication.getSharedApplication().openURL(new NSURL(url))) { log().warn("Failed to open URL: " + url); } }