private void onMouseClicked(Player player, Mouse button, boolean pressed, int x, int y) { PlayerClickEvent event = Spout.getEventManager() .callEvent(new PlayerClickEvent(player, button, pressed, new IntVector2(x, y))); if (event.isCancelled()) { return; } if (Spout.debugMode()) { Spout.log("Mouse clicked at {" + x + "," + y + "} was " + (pressed ? "pressed" : "released")); } Screen s = getInputScreen(); if (s != null) { Widget w = s.getWidgetAt(x, y); if (w != null) { Widget fw = s.getFocusedWidget(); if (fw != null && !fw.equals(w)) { s.setFocus(w, FocusReason.CLICKED); } w.onClicked(event); } } executeBindings(getMouseBindingsFor(button), player, pressed); }
private void onKeyPressed(Player player, Keyboard key, boolean pressed, char ch) { final PlayerKeyEvent event = Spout.getEventManager().callEvent(new PlayerKeyEvent(player, key, pressed, ch)); if (event.isCancelled()) { return; } if (Spout.debugMode()) { Spout.log("Key " + key + " was " + (pressed ? "pressed" : "released")); } // SHIFT + TAB changes the focus index Screen in = getInputScreen(); if (key == FOCUS_KEY && pressed) { if (in != null) { if (org.lwjgl.input.Keyboard.isKeyDown(Keyboard.KEY_LSHIFT.getId()) || org.lwjgl.input.Keyboard.isKeyDown(Keyboard.KEY_RSHIFT.getId())) { in.previousFocus(FocusReason.KEYBOARD_TAB); } else { in.nextFocus(FocusReason.KEYBOARD_TAB); } } } // send event to the focused widget if (in != null) { Widget w = in.getFocusedWidget(); if (w != null) { w.onKey(event); } } executeBindings(getKeyBindingsFor(key), player, pressed); }
public ClientRenderTexture() { super( null, (int) ((SpoutClient) Spout.getEngine()).getResolution().getX(), (int) ((SpoutClient) Spout.getEngine()).getResolution().getY()); // Detect which path we should use to create framebuffers. // if both of these are false, we cannot use framebuffers so throw an exception boolean arb = GLContext.getCapabilities().GL_ARB_framebuffer_object; boolean ext = GLContext.getCapabilities().GL_EXT_framebuffer_object; if (!arb && !ext) throw new ComputerIsPotatoException("Does not support Framebuffers"); // if arb is false, use ext if (!arb) useEXT = true; Spout.log("Using EXT: " + useEXT); }
@Override public boolean register(Recipe recipe) { boolean failed = false; if (recipe instanceof ShapedRecipe) { failed = !registerShaped((ShapedRecipe) recipe); } else if (recipe instanceof ShapelessRecipe) { failed = !registerShapeless((ShapelessRecipe) recipe); } else if (recipe instanceof SmeltedRecipe) { failed = !registerSmelted((SmeltedRecipe) recipe); } else { Spout.log("Unknown recipe type!"); } if (allRecipes.get(recipe.getIngredients().size()) == null) { allRecipes.put( recipe.getIngredients().size(), Collections.newSetFromMap(new ConcurrentHashMap<Recipe, Boolean>())); } failed = !allRecipes.get(recipe.getIngredients().size()).add(recipe) || failed; return !failed; }