@Override protected void mouseClicked(int mouseX, int mouseY, int mouseState) { super.mouseClicked(mouseX, mouseY, mouseState); if (state.is(EXPORTING_IMAGE)) { return; // Don't remove the progress bar. } // If clicked on the map, start dragging int mapX = (width - MAP_WIDTH) / 2; int mapY = (height - MAP_HEIGHT) / 2; boolean isMouseOverMap = mouseX >= mapX && mouseX <= mapX + MAP_WIDTH && mouseY >= mapY && mouseY <= mapY + MAP_HEIGHT; if (!state.is(NORMAL) && !state.is(HIDING_MARKERS)) { if (state.is(PLACING_MARKER) // If clicked on the map, place marker: && isMouseOverMap && mouseState == 0 /* left click */) { markerFinalizer.setMarkerData( player.worldObj, stack.getItemDamage(), player.dimension, screenXToWorldX(mouseX), screenYToWorldZ(mouseY)); addChild(markerFinalizer); blinkingIcon.setTexture( MarkerTextureMap.instance().getTexture(markerFinalizer.selectedType), MARKER_SIZE, MARKER_SIZE); addChildBehind(markerFinalizer, blinkingIcon) .setRelativeCoords( mouseX - getGuiX() - MARKER_SIZE / 2, mouseY - getGuiY() - MARKER_SIZE / 2); // Need to intercept keyboard events to type in the label: setInterceptKeyboard(true); // Un-press all keys to prevent player from walking infinitely: KeyBinding.unPressAllKeys(); } else if (state.is(DELETING_MARKER) // If clicked on a marker, delete it: && toDelete != null && isMouseOverMap && mouseState == 0) { AtlasAPI.getMarkerAPI() .deleteMarker(player.worldObj, stack.getItemDamage(), toDelete.getId()); } state.switchTo(NORMAL); } else if (isMouseOverMap && selectedButton == null) { isDragging = true; dragMouseX = mouseX; dragMouseY = mouseY; dragMapOffsetX = mapOffsetX; dragMapOffsetY = mapOffsetY; } }
@Override public void initGui() { super.initGui(); state.switchTo( NORMAL); // TODO: his causes the Export PNG progress bar to disappear when resizing game // window Keyboard.enableRepeatEvents(true); screenScale = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight).getScaleFactor(); setCentered(); }
/** * Opens a dialog window to select which file to save to, then performs rendering of the map of * current dimension into a PNG image. */ private void exportImage(ItemStack stack) { boolean showMarkers = !state.is(HIDING_MARKERS); state.switchTo(EXPORTING_IMAGE); // Default file name is "Atlas <N>.png" File file = ExportImageUtil.selectPngFileToSave("Atlas " + stack.getItemDamage(), progressBar); if (file != null) { try { Log.info( "Exporting image from Atlas #%d to file %s", stack.getItemDamage(), file.getAbsolutePath()); ExportImageUtil.exportPngImage( biomeData, globalMarkersData, localMarkersData, file, progressBar, showMarkers); Log.info("Finished exporting image"); } catch (OutOfMemoryError e) { Log.error(e, "Image is too large"); progressBar.setStatusString(I18n.format("gui.antiqueatlas.export.tooLarge")); return; // Don't switch to normal state yet so that the error message can be read. } } state.switchTo(showMarkers ? NORMAL : HIDING_MARKERS); }