/** * Returns the {@link Log} service. */ public static Log log() { return platform.log(); }
protected void execute (Platform plat, Runnable runnable) { try { runnable.run(); } catch (Exception e) { plat.log().warn("Action failed", e); } }
@Override public void drawString(float x, float y, String s, Color3f color) { plat.log().info("drawString not yet implemented in DebugDrawBox2D: " + s); }
protected Log log () { return game().plat.log(); } }
public void log (Level level, String ident, String message, Throwable t) { String msg = ident + ": " + message; switch (level) { case DEBUG: if (t != null) plat.log().debug(msg, t); else plat.log().debug(msg); break; default: case INFO: if (t != null) plat.log().info(msg, t); else plat.log().info(msg); break; case WARNING: if (t != null) plat.log().warn(msg, t); else plat.log().warn(msg); break; case ERROR: if (t != null) plat.log().error(msg, t); else plat.log().error(msg); break; } } }
protected void takeFocus (ActiveScreen as) { try { as.screen.lostFocus(); } catch (Exception e) { _game.plat.log().warn("Screen choked in lostFocus() [screen=" + as.screen + "]", e); } }
/** * Informs the graphics system that the main framebuffer size has changed. The supplied size * should be in physical pixels. */ protected void viewportChanged (int pixelWidth, int pixelHeight) { viewPixelWidth = pixelWidth; viewPixelHeight = pixelHeight; viewSizeM.width = scale.invScaled(pixelWidth); viewSizeM.height = scale.invScaled(pixelHeight); plat.log().info("viewPortChanged " + pixelWidth + "x" + pixelHeight + " / " + scale.factor + " -> " + viewSize); }
/** * 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); }
/** * Informs the graphics system that the main framebuffer size has changed. The supplied size * should be in physical pixels. */ protected void viewportChanged (int pixelWidth, int pixelHeight) { viewPixelWidth = pixelWidth; viewPixelHeight = pixelHeight; viewSizeM.width = scale.invScaled(pixelWidth); viewSizeM.height = scale.invScaled(pixelHeight); plat.log().info("viewPortChanged " + pixelWidth + "x" + pixelHeight + " / " + scale.factor + " -> " + viewSize); }
@Override public void wasShown () { super.wasShown(); game().plat.log().info(this + ".wasShown()"); }
@Override public void showTransitionCompleted () { super.showTransitionCompleted(); game().plat.log().info(this + ".showTransitionCompleted()"); }
@Override public void hideTransitionStarted () { super.hideTransitionStarted(); game().plat.log().info(this + ".hideTransitionStarted()"); }
@Override public void wasHidden () { super.wasHidden(); game().plat.log().info(this + ".wasHidden()"); }
@Override public void wasRemoved () { super.wasRemoved(); game().plat.log().info(this + ".wasRemoved()"); iface.disposeRoots(); layer.close(); }
protected void giveFocus (ActiveScreen as) { try { _current = as; as.screen.gainedFocus(); // if we have a previous screen, and the direction supports manual untransitioning, // set up a listener to handle that ActiveScreen previous = (_screens.size() <= 1) ? null : _screens.get(1); _onPointer.close(); if (previous == null || !as.dir.canUntrans()) _onPointer = Closeable.Util.NOOP; else _onPointer = as.screen.layer.events().connect(new UntransListener(as, previous)); } catch (Exception e) { _game.plat.log().warn("Screen choked in gainedFocus() [screen=" + as.screen + "]", e); } checkSleep(); }
@Override protected void upload (Graphics gfx, Texture tex) { int width = pixelWidth, height = pixelHeight; if (width == 0 || height == 0) { ((RoboGraphics)gfx).plat.log().info("Ignoring texture update for empty image (" + width + "x" + height + ")."); return; } CGBitmapContext bctx = RoboGraphics.createCGBitmap(width, height); CGRect rect = new CGRect(0, 0, width, height); bctx.clearRect(rect); bctx.drawImage(rect, image); upload(gfx, tex.id, width, height, bctx.getData()); bctx.dispose(); }
public TripleDemo (Platform plat) { super(plat, 25); // update our "simulation" 40 times per second game = this; // jam ourselves into a global variable, woo! new Pointer(plat, rootLayer, true); // wire up event dispatch screens.push(new DemoMenuScreen(screens)); // start off with our menu screen // show debug rectangles when D key is pressed; dump scene graph on shift-D plat.input().keyboardEvents.collect(Keyboard.isKey(Key.D)).connect(event -> { Layer.DEBUG_RECTS = event.down; if (event.down && event.isShiftDown()) { rootLayer.debugPrint(plat.log()); } }); } }
else plat.log().warn("Platform has neither mouse nor touch events?", "type", plat.type());
else plat.log().warn("Platform has neither mouse nor touch events?", "type", plat.type());