@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; } }
private void renderMarker(Marker marker, double scale) { int markerX = worldXToScreenX(marker.getX()); int markerY = worldZToScreenY(marker.getZ()); if (!marker.isVisibleAhead() && !biomeData.hasTileAt(marker.getChunkX(), marker.getChunkZ())) { return; } boolean mouseIsOverMarker = isMouseInRadius(markerX, markerY, (int) Math.ceil(MARKER_RADIUS * scale)); if (state.is(PLACING_MARKER)) { GL11.glColor4f(1, 1, 1, 0.5f); } else if (state.is(DELETING_MARKER)) { if (marker.isGlobal()) { GL11.glColor4f(1, 1, 1, 0.5f); } else { if (mouseIsOverMarker) { GL11.glColor4f(0.5f, 0.5f, 0.5f, 1); toDelete = marker; } else { GL11.glColor4f(1, 1, 1, 1); if (toDelete == marker) { toDelete = null; } } } } else { GL11.glColor4f(1, 1, 1, 1); } AtlasRenderHelper.drawFullTexture( MarkerTextureMap.instance().getTexture(marker.getType()), markerX - (double) MARKER_SIZE / 2 * scale, markerY - (double) MARKER_SIZE / 2 * scale, (int) Math.round(MARKER_SIZE * scale), (int) Math.round(MARKER_SIZE * scale)); if (isMouseOver && mouseIsOverMarker && marker.getLabel().length() > 0) { drawTooltip(Arrays.asList(marker.getLocalizedLabel()), mc.fontRenderer); } }