Java Code Examples for net.minecraft.client.gui.ScaledResolution#getScaledHeight()
The following examples show how to use
net.minecraft.client.gui.ScaledResolution#getScaledHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HyperiumOverlay.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
public void handleMouseInput() { ScaledResolution sr = ResolutionUtil.current(); int sw = sr.getScaledWidth(); int sh = sr.getScaledHeight(); int mx = Mouse.getX() * sw / Minecraft.getMinecraft().displayWidth; int my = sh - Mouse.getY() * sh / Minecraft.getMinecraft().displayHeight - 1; Integer[] counter = new Integer[]{0}; components.forEach(c -> c.handleMouseInput(mx, my, sr.getScaledWidth() / 6 * 2, sr.getScaledHeight() / 4 + 20 * counter[0]++ + offsetY, sr.getScaledWidth() / 6 * 2, 20)); int i = Mouse.getEventDWheel(); if (i > 0 && offsetY != 0) offsetY += 5; else if (i < 0) offsetY -= 5; }
Example 2
Source File: HudElementBase.java From Cyberware with MIT License | 6 votes |
@Override public void render(EntityPlayer player, ScaledResolution resolution, boolean hudjackAvailable, boolean isConfigOpen, float partialTicks) { int x = getX(); int y = getY(); if (getHorizontalAnchor() == EnumAnchorHorizontal.RIGHT) { x = resolution.getScaledWidth() - x - getWidth(); } if (getVerticalAnchor() == EnumAnchorVertical.BOTTOM) { y = resolution.getScaledHeight() - y - getHeight(); } renderElement(x, y, player, resolution, hudjackAvailable, isConfigOpen, partialTicks); }
Example 3
Source File: Particle.java From LiquidBounce with GNU General Public License v3.0 | 6 votes |
void fall() { final Minecraft mc = Minecraft.getMinecraft(); final ScaledResolution scaledResolution = new ScaledResolution(mc); y = (y + ySpeed); x = (x + xSpeed); if(y > mc.displayHeight) y = 1; if(x > mc.displayWidth) x = 1; if(x < 1) x = scaledResolution.getScaledWidth(); if(y < 1) y = scaledResolution.getScaledHeight(); }
Example 4
Source File: DisplayElementConfig.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void updateScreen() { ScaledResolution current = ResolutionUtil.current(); if (current.getScaledWidth() != lastWidth || current.getScaledHeight() != lastHeight) { repack(); lastWidth = current.getScaledWidth(); lastHeight = current.getScaledHeight(); } if (element.isRGB()) element.recalculateColor(); buttonList.forEach(guiButton -> { Consumer<GuiButton> guiButtonConsumer = updates.get(guiButton); if (guiButtonConsumer != null) guiButtonConsumer.accept(guiButton); }); }
Example 5
Source File: TacoCmd.java From ForgeWurst with GNU General Public License v3.0 | 6 votes |
@SubscribeEvent public void onRenderGUI(RenderGameOverlayEvent.Post event) { if(event.getType() != ElementType.ALL || mc.gameSettings.showDebugInfo) return; if(wurst.getHax().rainbowUiHack.isEnabled()) { float[] acColor = wurst.getGui().getAcColor(); GL11.glColor4f(acColor[0], acColor[1], acColor[2], 1); }else GL11.glColor4f(1, 1, 1, 1); int tacoId = WMinecraft.getPlayer().ticksExisted % 32 / 8; ResourceLocation tacoLocation = tacos[tacoId]; mc.getTextureManager().bindTexture(tacoLocation); ScaledResolution sr = new ScaledResolution(mc); int x = sr.getScaledWidth() / 2 + 44; int y = sr.getScaledHeight() - 51; int w = 64; int h = 32; Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 0, w, h, w, h); }
Example 6
Source File: VanillaEnhancementsHud.java From Hyperium with GNU Lesser General Public License v3.0 | 6 votes |
@InvokeEvent public void renderDamage(RenderHUDEvent e) { if (Settings.DAMAGE_ABOVE_HOTBAR) { ItemStack heldItemStack = mc.thePlayer.inventory.getCurrentItem(); if (heldItemStack != null) { GL11.glPushMatrix(); GL11.glScalef(0.5f, 0.5f, 0.5f); ScaledResolution res = ResolutionUtil.current(); String attackDamage = getAttackDamageString(heldItemStack); int y = res.getScaledHeight() - 59; y += (mc.playerController.shouldDrawHUD() ? -1 : 14); y = y + mc.fontRendererObj.FONT_HEIGHT; y <<= 1; y += mc.fontRendererObj.FONT_HEIGHT; int x = res.getScaledWidth() - (mc.fontRendererObj.getStringWidth(attackDamage) >> 1); mc.fontRendererObj.drawString(attackDamage, x, y, 13421772); GL11.glScalef(2.0f, 2.0f, 2.0f); GL11.glPopMatrix(); } } }
Example 7
Source File: RocketEventHandler.java From AdvancedRocketry with MIT License | 5 votes |
public int getRenderY() { ScaledResolution scaledresolution = new ScaledResolution(Minecraft.getMinecraft()); int i = scaledresolution.getScaledHeight(); if( modeY == 1) { return i - getRawY(); } else if (modeY == 0) { return i/2 - getRawY(); } return this.getRawY(); }
Example 8
Source File: ConfigValues.java From SkyblockAddons with MIT License | 5 votes |
public EnumUtils.AnchorPoint getClosestAnchorPoint(float x, float y) { ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); int maxX = sr.getScaledWidth(); int maxY = sr.getScaledHeight(); double shortestDistance = -1; EnumUtils.AnchorPoint closestAnchorPoint = EnumUtils.AnchorPoint.BOTTOM_MIDDLE; // default for (EnumUtils.AnchorPoint point : EnumUtils.AnchorPoint.values()) { double distance = Point2D.distance(x, y, point.getX(maxX), point.getY(maxY)); if (shortestDistance == -1 || distance < shortestDistance) { closestAnchorPoint = point; shortestDistance = distance; } } return closestAnchorPoint; }
Example 9
Source File: VanillaEnhancementsHud.java From Hyperium with GNU Lesser General Public License v3.0 | 5 votes |
@InvokeEvent public void renderHotbarNumbers(RenderHUDEvent event) { if (Settings.HOTBAR_KEYS) { ScaledResolution resolution = ResolutionUtil.current(); int x = resolution.getScaledWidth() / 2 - 87; int y = resolution.getScaledHeight() - 18; int[] hotbarKeys = getHotbarKeys(); for (int slot = 0; slot < 9; slot++) { mc.fontRendererObj.drawString(getKeyString(hotbarKeys[slot]), x + slot * 20, y, -1); } } }
Example 10
Source File: HackButton.java From ForgeWurst with GNU General Public License v3.0 | 4 votes |
@Override public void handleMouseClick(int mouseX, int mouseY, int mouseButton) { if(mouseButton != 0) return; if(!hack.getSettings().isEmpty() && mouseX > getX() + getWidth() - 12) { if(settingsWindow != null && !settingsWindow.isClosing()) { settingsWindow.close(); settingsWindow = null; return; } settingsWindow = new Window(hack.getName() + " Settings"); for(Setting setting : hack.getSettings().values()) settingsWindow.add(setting.getComponent()); settingsWindow.setClosable(true); settingsWindow.setMinimizable(false); settingsWindow.pack(); int scroll = getParent().isScrollingEnabled() ? getParent().getScrollOffset() : 0; int x = getParent().getX() + getParent().getWidth() + 5; int y = getParent().getY() + 12 + getY() + scroll; ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft()); if(x + settingsWindow.getWidth() > sr.getScaledWidth()) x = getParent().getX() - settingsWindow.getWidth() - 5; if(y + settingsWindow.getHeight() > sr.getScaledHeight()) y -= settingsWindow.getHeight() - 14; settingsWindow.setX(x); settingsWindow.setY(y); ClickGui gui = ForgeWurst.getForgeWurst().getGui(); gui.addWindow(settingsWindow); return; } hack.setEnabled(!hack.isEnabled()); }
Example 11
Source File: MixinLoadingScreenRenderer.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
/** * @author ConorTheDev * @reason Custom screen when loading to a new world */ @Inject(method = "setLoadingProgress", at = @At("HEAD"), cancellable = true) private void setLoadingProgress(CallbackInfo ci) { if (Settings.HYPERIUM_LOADING_SCREEN) { long nanoTime = Minecraft.getSystemTime(); if (nanoTime - systemTime >= 100L) { systemTime = nanoTime; ScaledResolution scaledresolution = new ScaledResolution(mc); int scaleFactor = scaledresolution.getScaleFactor(); int scaledWidth = scaledresolution.getScaledWidth(); int scaledHeight = scaledresolution.getScaledHeight(); if (OpenGlHelper.isFramebufferEnabled()) { framebuffer.framebufferClear(); } else { GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT); } framebuffer.bindFramebuffer(false); GlStateManager.matrixMode(GL11.GL_PROJECTION); GlStateManager.loadIdentity(); GlStateManager.ortho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 100.0D, 300.0D); GlStateManager.matrixMode(GL11.GL_MODELVIEW); GlStateManager.loadIdentity(); GlStateManager.translate(0.0F, 0.0F, -200.0F); if (!OpenGlHelper.isFramebufferEnabled()) GlStateManager.clear(16640); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); mc.getTextureManager().bindTexture(new ResourceLocation("textures/world-loading.png")); Gui.drawModalRectWithCustomSizedTexture(0, 0, 0.0f, 0.0f, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight()); int progress; if ("Loading world".equals(currentlyDisplayedText)) { if (message.isEmpty()) { progress = 33; } else if (message.equals("Converting world")) { progress = 66; } else if (message.equals("Building terrain")) { progress = 90; } else { progress = 100; } } else { progress = -1; } if (progress >= 0) { int maxProgress = 100; int barTop = 2; int barHeight = scaledResolution.getScaledHeight() - 15; GlStateManager.disableTexture2D(); worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); worldrenderer.pos(maxProgress, barHeight, 0.0D).color(128, 128, 128, 255).endVertex(); worldrenderer.pos(maxProgress, barHeight + barTop, 0.0D).color(128, 128, 128, 255).endVertex(); worldrenderer.pos(maxProgress + maxProgress, barHeight + barTop, 0.0D).color(128, 128, 128, 255).endVertex(); worldrenderer.pos(maxProgress + maxProgress, barHeight, 0.0D).color(128, 128, 128, 255).endVertex(); worldrenderer.pos(maxProgress, barHeight, 0.0D).color(128, 255, 128, 255).endVertex(); worldrenderer.pos(maxProgress, barHeight + barTop, 0.0D).color(128, 255, 128, 255).endVertex(); worldrenderer.pos(maxProgress + progress, barHeight + barTop, 0.0D).color(128, 255, 128, 255).endVertex(); worldrenderer.pos(maxProgress + progress, barHeight, 0.0D).color(128, 255, 128, 255).endVertex(); tessellator.draw(); GlStateManager.enableAlpha(); GlStateManager.enableBlend(); Gui.drawRect(0, scaledResolution.getScaledHeight() - 35, scaledResolution.getScaledWidth(), scaledResolution.getScaledHeight(), new Color(0, 0, 0, 50).getRGB()); GlStateManager.disableAlpha(); GlStateManager.disableBlend(); GlStateManager.enableTexture2D(); } GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); mc.fontRendererObj.drawString(currentlyDisplayedText, 5, scaledResolution.getScaledHeight() - 30, -1); mc.fontRendererObj.drawString(message, 5, scaledResolution.getScaledHeight() - 15, -1); framebuffer.unbindFramebuffer(); if (OpenGlHelper.isFramebufferEnabled()) { framebuffer.framebufferRender(scaledWidth * scaleFactor, scaledHeight * scaleFactor); } mc.updateDisplay(); try { Thread.yield(); } catch (Exception ignored) { } } ci.cancel(); } }
Example 12
Source File: DisplayElementConfig.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
private int availableSpace() { ScaledResolution current = ResolutionUtil.current(); int yMin = current.getScaledHeight() - 15 - startY(); if (yMin + 20 > current.getScaledWidth()) return yMin - 50; return yMin; }
Example 13
Source File: WidgetRedstoneModes.java From ExtraCells1 with MIT License | 4 votes |
@Override public void drawButton(Minecraft minecraftInstance, int x, int y) { if (this.drawButton) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mouseDragged(minecraftInstance, x, y); minecraftInstance.getTextureManager().bindTexture(new ResourceLocation("extracells", "textures/gui/redstonemodes.png")); drawTexturedModalRect(xPosition, yPosition, 0, 16, 16, 16); List<String> description = new ArrayList<String>(); description.add(StatCollector.translateToLocal("AppEng.GuiITooltip.RedstoneMode")); String explaination = ""; switch (redstoneMode) { case WhenOn: drawTexturedModalRect(xPosition, yPosition, 16, 0, 16, 16); explaination = StatCollector.translateToLocal(emitter ? "AppEng.GuiITooltip.EmitLevelAbove" : "AppEng.GuiITooltip.ActiveWithSignal"); break; case WhenOff: drawTexturedModalRect(xPosition, yPosition, 0, 0, 16, 16); explaination = StatCollector.translateToLocal(emitter ? "AppEng.GuiITooltip.EmitLevelsBelow" : "AppEng.GuiITooltip.ActiveWithoutSignal"); break; case OnPulse: drawTexturedModalRect(xPosition, yPosition, 32, 0, 16, 16); explaination = StatCollector.translateToLocal("AppEng.GuiITooltip.ActiveOnPulse"); break; case Ignore: drawTexturedModalRect(xPosition, yPosition, 48, 0, 16, 16); explaination = StatCollector.translateToLocal("AppEng.GuiITooltip.AlwaysActive"); break; default: break; } for (String current : Splitter.fixedLength(30).split(explaination)) { description.add(EnumChatFormatting.GRAY + current); } Minecraft mc = Minecraft.getMinecraft(); ScaledResolution scaledresolution = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight); int mouseX = Mouse.getX() * scaledresolution.getScaledWidth() / mc.displayWidth; int mouseY = scaledresolution.getScaledHeight() - Mouse.getY() * scaledresolution.getScaledHeight() / mc.displayHeight - 1; if (mouseX >= xPosition && mouseX <= xPosition + width && mouseY >= yPosition && mouseY <= yPosition + height) { drawHoveringText(description, mouseX, mouseY, mc.fontRenderer); } } }
Example 14
Source File: MoveElementGui.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { ScaledResolution current = ResolutionUtil.current(); drawRect(0, 0, current.getScaledWidth(), current.getScaledHeight(), new Color(0, 0, 0, 150).getRGB()); mouseLock = mouseLock && Mouse.isButtonDown(0); super.drawScreen(mouseX, mouseY, partialTicks); ElementRenderer.startDrawing(element); element.drawForConfig(); ElementRenderer.endDrawing(element); ScaledResolution resolution = new ScaledResolution(Minecraft.getMinecraft()); double offset = element.isRightSided() ? element.getDimensions().getWidth() : 0; double x1 = element.getXloc() * resolution.getScaledWidth_double() - offset; double x2 = element.getXloc() * resolution.getScaledWidth_double() + element.getDimensions().getWidth() - offset; double y1 = element.getYloc() * resolution.getScaledHeight_double(); double y2 = element.getYloc() * resolution.getScaledHeight_double() + element.getDimensions().getHeight(); //Left top right bottom //Outline drawHorizontalLine((int) (x1 - 5), (int) (x2 + 5), (int) y1 - 5, Color.RED.getRGB()); drawHorizontalLine((int) (x1 - 5), (int) (x2 + 5), (int) y2 + 5, Color.RED.getRGB()); drawVerticalLine((int) x1 - 5, (int) (y1 - 5), (int) (y2 + 5), Color.RED.getRGB()); drawVerticalLine((int) x2 + 5, (int) (y1 - 5), (int) (y2 + 5), Color.RED.getRGB()); int propX = (int) x1 - 5; int propY = (int) y1 - 30; if (propX < 10 || propX > resolution.getScaledWidth() - 200) propX = resolution.getScaledWidth() / 2; if (propY > resolution.getScaledHeight() - 5 || propY < 0) propY = resolution.getScaledHeight() / 2; edit.xPosition = propX; edit.yPosition = propY; if (Mouse.isButtonDown(0) && !mouseLock) { if (mouseX > x1 - 2 && mouseX < x2 + 2 && mouseY > y1 - 2 && mouseY < y2 + 2 || lastD) { //inside double x3 = Mouse.getX() / ResolutionUtil.current().getScaledWidth_double(); double y3 = Mouse.getY() / ResolutionUtil.current().getScaledHeight_double(); element.setXloc(element.getXloc() - (lastX - x3) / ((double) ResolutionUtil.current().getScaleFactor())); element.setYloc(element.getYloc() + (lastY - y3) / ((double) ResolutionUtil.current().getScaleFactor())); //Math to keep it inside screen if (element.getXloc() * resolution.getScaledWidth_double() - offset < 0) { if (element.isRightSided()) element.setXloc(offset / resolution.getScaledWidth_double()); else element.setXloc(0); } if (element.getYloc() < 0) element.setYloc(0); if (element.getXloc() * resolution.getScaledWidth() + element.getDimensions().getWidth() - offset > resolution.getScaledWidth()) { element.setXloc(element.isRightSided() ? 1.0 : (resolution.getScaledWidth_double() - element.getDimensions().getWidth()) / resolution.getScaledWidth_double()); } if (element.getYloc() * resolution.getScaledHeight() + element.getDimensions().getHeight() > resolution.getScaledHeight()) { element.setYloc((resolution.getScaledHeight_double() - element.getDimensions().getHeight()) / resolution.getScaledHeight_double()); } lastD = true; } } else { lastD = false; } lastX = Mouse.getX() / ResolutionUtil.current().getScaledWidth_double(); lastY = Mouse.getY() / ResolutionUtil.current().getScaledHeight_double(); }
Example 15
Source File: VectorUtils.java From ForgeHax with MIT License | 4 votes |
/** * Convert 3D coord into 2D coordinate projected onto the screen */ public static Plane toScreen(double x, double y, double z) { Entity view = MC.getRenderViewEntity(); if (view == null) { return new Plane(0.D, 0.D, false); } Vec3d camPos = FastReflection.Fields.ActiveRenderInfo_position.getStatic(); Vec3d eyePos = ActiveRenderInfo.projectViewFromEntity(view, MC.getRenderPartialTicks()); float vecX = (float) ((camPos.x + eyePos.x) - (float) x); float vecY = (float) ((camPos.y + eyePos.y) - (float) y); float vecZ = (float) ((camPos.z + eyePos.z) - (float) z); Vector4f pos = new Vector4f(vecX, vecY, vecZ, 1.f); modelMatrix.load( FastReflection.Fields.ActiveRenderInfo_MODELVIEW.getStatic().asReadOnlyBuffer()); projectionMatrix.load( FastReflection.Fields.ActiveRenderInfo_PROJECTION.getStatic().asReadOnlyBuffer()); VecTransformCoordinate(pos, modelMatrix); VecTransformCoordinate(pos, projectionMatrix); if (pos.w > 0.f) { pos.x *= -100000; pos.y *= -100000; } else { float invert = 1.f / pos.w; pos.x *= invert; pos.y *= invert; } ScaledResolution res = new ScaledResolution(MC); float halfWidth = (float) res.getScaledWidth() / 2.f; float halfHeight = (float) res.getScaledHeight() / 2.f; pos.x = halfWidth + (0.5f * pos.x * res.getScaledWidth() + 0.5f); pos.y = halfHeight - (0.5f * pos.y * res.getScaledHeight() + 0.5f); boolean bVisible = true; if (pos.x < 0 || pos.y < 0 || pos.x > res.getScaledWidth() || pos.y > res.getScaledHeight()) { bVisible = false; } return new Plane(pos.x, pos.y, bVisible); }
Example 16
Source File: GuiContainerBase.java From Signals with GNU General Public License v3.0 | 4 votes |
public void refreshScreen(){ ScaledResolution scaledresolution = new ScaledResolution(mc); int i = scaledresolution.getScaledWidth(); int j = scaledresolution.getScaledHeight(); setWorldAndResolution(mc, i, j); }
Example 17
Source File: GuiSidebar.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
public void drawSidebar(ScoreObjective sidebar, ScaledResolution res) { if (!enabled) { return; } FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; Scoreboard scoreboard = sidebar.getScoreboard(); List<Score> scores = new ArrayList<>(); sidebarWidth = fr.getStringWidth(sidebar.getDisplayName()); for (Score score : scoreboard.getSortedScores(sidebar)) { String name = score.getPlayerName(); if (scores.size() < 15 && name != null && !name.startsWith("#")) { Team team = scoreboard.getPlayersTeam(name); String s2 = redNumbers ? (": " + EnumChatFormatting.RED + score.getScorePoints()) : ""; String str = ScorePlayerTeam.formatPlayerName(team, name) + s2; sidebarWidth = Math.max(sidebarWidth, fr.getStringWidth(str)); scores.add(score); } } sidebarHeight = scores.size() * fr.FONT_HEIGHT; sidebarX = res.getScaledWidth() - sidebarWidth - 3 + offsetX; sidebarY = res.getScaledHeight() / 2 + sidebarHeight / 3 + offsetY; int scalePointX = sidebarX + sidebarWidth; int scalePointY = sidebarY - sidebarHeight / 2; float mscale = scale - 1.0f; GlStateManager.translate(-scalePointX * mscale, -scalePointY * mscale, 0.0f); GlStateManager.scale(scale, scale, 1.0F); int index = 0; for (Score score2 : scores) { ++index; ScorePlayerTeam team2 = scoreboard.getPlayersTeam(score2.getPlayerName()); String s3 = ScorePlayerTeam.formatPlayerName(team2, score2.getPlayerName()); String s4 = EnumChatFormatting.RED + "" + score2.getScorePoints(); if (!redNumbers) { s4 = ""; } int scoreX = sidebarX + sidebarWidth + 1; int scoreY = sidebarY - index * fr.FONT_HEIGHT; drawRect(sidebarX - 2, scoreY, scoreX, scoreY + fr.FONT_HEIGHT, getColor(false, true)); drawString(s3, sidebarX, scoreY, getColor(false, false)); drawString(s4, scoreX - fr.getStringWidth(s4), scoreY, getColor(false, false)); if (index == scores.size()) { String s5 = sidebar.getDisplayName(); drawRect(sidebarX - 2, scoreY - fr.FONT_HEIGHT - 1, scoreX, scoreY - 1, getColor(true, true)); drawRect(sidebarX - 2, scoreY - 1, scoreX, scoreY, getColor(false, true)); drawString(s5, sidebarX + (sidebarWidth - fr.getStringWidth(s5)) / 2, scoreY - fr.FONT_HEIGHT, chromaEnabled ? getColor(false, false) : 553648127); } } GlStateManager.scale(1.0F / scale, 1.0F / scale, 1.0F); GlStateManager.translate(scalePointX * mscale, scalePointY * mscale, 0.0f); }
Example 18
Source File: PurchaseCarousel.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
public void mouseClicked(int x, int y, int centerX) { ScaledResolution current = ResolutionUtil.current(); int totalWidth = current.getScaledWidth() / 3; int panel = totalWidth / 5; int mainWidth = panel * 3; int centerY = current.getScaledHeight() / 2; int leftX = centerX - mainWidth / 2; int rightX = centerX + mainWidth / 2; if (x >= leftX - 8 && x <= leftX && y >= centerY - 5 && y <= centerY + 5) { rotateLeft(); } else if (x >= rightX && x <= rightX + 8 && y >= centerY - 5 && y <= centerY + 5) { rotateRight(); } int objLeft = centerX - mainWidth / 2; int purchaseLeft = objLeft + 5; int purchaseRight = (objLeft + 50); int mainHeight = current.getScaledHeight() / 5 * 3; int objBottom = centerY + mainHeight / 2; int barHeight = 16; int purchaseTop = objBottom - 20; int purchaseBottom = purchaseTop + barHeight; if (x >= purchaseLeft && x <= purchaseRight && y <= purchaseBottom && y >= purchaseTop) { getCurrent().getOnPurchase().accept(getCurrent()); } int settingsLeft = purchaseRight + barHeight / 2; int settingsRight = settingsLeft + barHeight; if (x >= settingsLeft && x <= settingsRight && y <= purchaseBottom && y >= purchaseTop) { getCurrent().getOnSettingsClick().accept(getCurrent()); } if (activeBlock != null && activeBlock.isMouseOver(x, y)) { getCurrent().getOnActivate().accept(getCurrent()); } }
Example 19
Source File: PurchaseCarousel.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
public void render(int centerX, int centerY, int mouseX, int mouseY) { activeBlock = null; ScaledResolution current = ResolutionUtil.current(); int totalWidth = current.getScaledWidth() / 3; int panel = totalWidth / 5; int mainWidth = panel * 3; int sideHeight = current.getScaledHeight() / 5 * 2; int mainHeight = current.getScaledHeight() / 5 * 3; int objLeft = centerX - mainWidth / 2; int objBottom = centerY + mainHeight / 2; int objRight = centerX + mainWidth / 2; if (index > 0) { //Draw left side RenderUtils.drawSmoothRect(centerX - panel * 2, centerY - sideHeight / 2, centerX, centerY + sideHeight / 2, 4, new Color(23, 23, 23, 100).getRGB()); } if (index < items.length - 1) { RenderUtils.drawSmoothRect(centerX, centerY - sideHeight / 2, centerX + panel * 2, centerY + sideHeight / 2, 4, new Color(23, 23, 23, 100).getRGB()); } RenderUtils.drawSmoothRect(objLeft, centerY - mainHeight / 2, objRight, objBottom, 10, new Color(23, 23, 23, 255).getRGB()); CarouselItem item = items[index]; GlStateManager.scale(.5, .5, .5); int barHeight = 16; fr.drawString(item.getName(), (objLeft + 5) * 2, (objBottom - 50) * 2, Color.WHITE.getRGB()); int purchaseRight = (objLeft + 50) * 2; RenderUtils.drawSmoothRect((objLeft + 5) * 2, (objBottom - 20) * 2, purchaseRight, (objBottom - 20 + barHeight) * 2, 10, Color.WHITE.getRGB()); GlStateManager.scale(2 / 3F, 2 / 3F, 2 / 3F); fr.drawString(item.isPurchased() ? I18n.format("gui.purchase.purchased") : I18n.format("gui.purchase.purchase"), (objLeft + 5) * 3, (objBottom - 18) * 3, new Color(23, 23, 23, 255).getRGB()); GlStateManager.scale(3 / 2F, 3 / 2f, 3 / 2F); RenderUtils.drawFilledCircle(purchaseRight + barHeight * 2, (objBottom - 12) * 2, barHeight, Color.WHITE.getRGB()); GlStateManager.color(0, 0, 0); Icons.SETTINGS.bind(); Gui.drawScaledCustomSizeModalRect(purchaseRight + barHeight, (objBottom - 20) * 2, 0, 0, 144, 144, barHeight * 2, barHeight * 2, 144, 144); GlStateManager.scale(2.0, 2.0, 2.0); if (mouseX >= objLeft - 8 && mouseX <= objLeft && mouseY >= centerY - 5 && mouseY <= centerY + 5) { if (!lhover) { lhover = true; larrow = new SimpleAnimValue(500L, larrow.getValue(), 0.3f); } } else if (lhover) { lhover = false; larrow = new SimpleAnimValue(500L, larrow.getValue(), 0.5f); } float v = larrow.getValue(); GlStateManager.scale(v, v, v); fr.drawCenteredString("<", (objLeft - 5) / v, centerY / v - 10, 0xffffff); GlStateManager.scale(1 / v, 1 / v, 1 / v); if (mouseX >= objRight && mouseX <= objRight + 8 && mouseY >= centerY - 5 && mouseY <= centerY + 5) { if (!rhover) { rhover = true; rarrow = new SimpleAnimValue(500L, rarrow.getValue(), 0.3f); } } else if (rhover) { rhover = false; rarrow = new SimpleAnimValue(500L, rarrow.getValue(), 0.5f); } v = rarrow.getValue(); GlStateManager.scale(v, v, v); fr.drawCenteredString(">", (objRight + 5) / v, centerY / v - 10, 0xffffff); GlStateManager.scale(1 / v, 1 / v, 1 / v); String s = I18n.format("gui.purchase.state") + ": " + (getCurrent().isPurchased() ? (getCurrent().isActive() ? I18n.format("gui.purchase.active") : I18n.format("gui.purchase.inactive")) : I18n.format("gui.purchase.notpurchased")); float e = .5F; GlStateManager.scale(e, e, e); fr.drawString(s, (centerX - fr.getWidth(s) / 4) / e, (centerY - mainHeight / 2f + 15) / e, Color.GREEN.getRGB()); if (getCurrent().isPurchased() && !getCurrent().isActive()) { s = I18n.format("gui.purchase.clicktouse"); float width = fr.getWidth(s); float x = centerX - width / 4; int i = centerY - mainHeight / 2 + 35; activeBlock = new GuiBlock((int) x, (int) (x + width * 2), i, i + 10); fr.drawString(s, x / e, i / e, Color.GREEN.getRGB()); } GlStateManager.scale(1 / e, 1 / e, 1 / e); }
Example 20
Source File: AbstractTab.java From Hyperium with GNU Lesser General Public License v3.0 | 4 votes |
/** * Render - Renders the Tab * * @param x - Given X Position * @param y - Given Y Position * @param width - Given Width * @param height - Given Height */ public void render(int x, int y, int width, int height) { ScaledResolution sr = ResolutionUtil.current(); int sw = sr.getScaledWidth(); int sh = sr.getScaledHeight(); int xg = width / 9; // X grid /* Begin new scissor state */ ScissorState.scissor(x, y, width, height, true); /* Get mouse X and Y */ final int mx = Mouse.getX() * sw / Minecraft.getMinecraft().displayWidth; // Mouse X final int my = sh - Mouse.getY() * sh / Minecraft.getMinecraft().displayHeight - 1; // Mouse Y if (scrollAnim.getValue() != scroll * 18 && scrollAnim.isFinished()) { scrollAnim = new SimpleAnimValue(1000L, scrollAnim.getValue(), scroll * 18); } y += scrollAnim.getValue(); /* Render each tab component */ for (AbstractTabComponent comp : filter == null ? components : components.stream().filter(c -> c.filter(filter)).collect(Collectors.toList())) { comp.render(x, y, width, mx, my); /* If mouse is over component, set as hovered */ if (mx >= x && mx <= x + width && my > y && my <= y + comp.getHeight()) { comp.hover = true; //For slider comp.mouseEvent(mx - xg, my - y /* Make the Y relevant to the component */); if (Mouse.isButtonDown(0)) { if (!clickStates.computeIfAbsent(comp, ignored -> false)) { comp.onClick(mx, my - y /* Make the Y relevant to the component */); clickStates.put(comp, true); } } else if (clickStates.computeIfAbsent(comp, ignored -> false)) clickStates.put(comp, false); } else { comp.hover = false; } y += comp.getHeight(); } /* End scissor state */ ScissorState.endScissor(); }