use of net.minecraft.client.gui.ScaledResolution in project PneumaticCraft by MineMaarten.
the class GuiUnitProgrammer method render.
public void render(int x, int y, boolean showFlow, boolean showInfo, boolean translate) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
int origX = x;
int origY = y;
x -= translatedX;
y -= translatedY;
float scale = getScale();
x = (int) (x / scale);
y = (int) (y / scale);
if (scaleScroll.getState() != lastZoom) {
float shift = SCALE_PER_STEP * (scaleScroll.getState() - lastZoom);
if (new Rectangle(guiLeft + startX, guiTop + startY, areaWidth, areaHeight).contains(origX, origY)) {
translatedX += shift * x;
translatedY += shift * y;
} else {
translatedX += areaWidth / 2 * shift;
translatedY += areaHeight / 2 * shift;
}
}
lastZoom = scaleScroll.getState();
ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft(), Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
GL11.glScissor((guiLeft + startX) * sr.getScaleFactor(), (sr.getScaledHeight() - areaHeight - (guiTop + startY)) * sr.getScaleFactor(), areaWidth * sr.getScaleFactor(), areaHeight * sr.getScaleFactor());
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glPushMatrix();
GL11.glTranslated(translatedX, translatedY, 0);
GL11.glScaled(scale, scale, 1);
if (showFlow)
showFlow();
GL11.glEnable(GL11.GL_TEXTURE_2D);
for (IProgWidget widget : progWidgets) {
GL11.glPushMatrix();
GL11.glTranslated(widget.getX() + guiLeft, widget.getY() + guiTop, 0);
GL11.glScaled(0.5, 0.5, 1);
widget.render();
GL11.glPopMatrix();
}
for (IProgWidget widget : progWidgets) {
List<String> errors = new ArrayList<String>();
widget.addErrors(errors, progWidgets);
if (errors.size() > 0) {
drawBorder(widget, 0xFFFF0000);
} else {
List<String> warnings = new ArrayList<String>();
widget.addWarnings(warnings, progWidgets);
if (warnings.size() > 0) {
drawBorder(widget, 0xFFFFFF00);
}
}
}
renderAdditionally();
GL11.glColor4d(1, 1, 1, 1);
if (showInfo) {
for (IProgWidget widget : progWidgets) {
GL11.glPushMatrix();
GL11.glTranslated(widget.getX() + guiLeft, widget.getY() + guiTop, 0);
GL11.glScaled(0.5, 0.5, 1);
widget.renderExtraInfo();
GL11.glPopMatrix();
}
}
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_SCISSOR_TEST);
boolean isLeftClicking = Mouse.isButtonDown(0);
if (translate && isLeftClicking && wasClicking && new Rectangle(guiLeft + startX, guiTop + startY, areaWidth, areaHeight).contains(origX, origY)) {
translatedX += origX - lastMouseX;
translatedY += origY - lastMouseY;
}
wasClicking = isLeftClicking;
lastMouseX = origX;
lastMouseY = origY;
}
use of net.minecraft.client.gui.ScaledResolution in project PneumaticCraft by MineMaarten.
the class HUDHandler method render2D.
private void render2D(float partialTicks) {
Minecraft minecraft = FMLClientHandler.instance().getClient();
EntityPlayer player = minecraft.thePlayer;
ItemStack helmetStack = player.inventory.armorInventory[3];
if (helmetStack != null && minecraft.inGameHasFocus && helmetStack.getItem() == Itemss.pneumaticHelmet) {
ScaledResolution sr = new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight);
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glPushMatrix();
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GL11.glColor4d(0, 1, 0, 0.8D);
CommonHUDHandler comHudHandler = CommonHUDHandler.getHandlerForPlayer(player);
if (comHudHandler.ticksExisted <= comHudHandler.getStartupTime()) {
// blockTrackInfo = null;
gaveEmptyWarning = false;
gaveNearlyEmptyWarning = false;
RenderProgressBar.render(sr.getScaledWidth() / 2, 10, sr.getScaledWidth() - 10, 30, -90F, comHudHandler.ticksExisted * 100 / comHudHandler.getStartupTime());
} else {
if (comHudHandler.helmetPressure < 0.05F && !gaveEmptyWarning) {
addMessage(new ArmorMessage("The helmet is out of air!", new ArrayList<String>(), 100, 0x70FF0000));
gaveEmptyWarning = true;
}
if (comHudHandler.helmetPressure > 0.2F && comHudHandler.helmetPressure < 0.5F && !gaveNearlyEmptyWarning) {
addMessage(new ArmorMessage("The helmet almost out of air!", new ArrayList<String>(), 60, 0x70FF0000));
gaveNearlyEmptyWarning = true;
}
if (GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked) {
for (int i = 0; i < UpgradeRenderHandlerList.instance().upgradeRenderers.size(); i++) {
IUpgradeRenderHandler upgradeRenderHandler = UpgradeRenderHandlerList.instance().upgradeRenderers.get(i);
if (comHudHandler.upgradeRenderersInserted[i] && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + upgradeRenderHandler.getUpgradeName()).checked) {
IGuiAnimatedStat stat = upgradeRenderHandler.getAnimatedStat();
if (stat != null) {
stat.render(-1, -1, partialTicks);
}
upgradeRenderHandler.render2D(partialTicks, comHudHandler.helmetPressure > 0F);
}
}
}
}
// render every item in the list.
for (ArmorMessage message : messageList) {
message.renderMessage(minecraft.fontRenderer, partialTicks);
}
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_TEXTURE_2D);
if (comHudHandler.ticksExisted <= comHudHandler.getStartupTime())
minecraft.fontRenderer.drawString(CommonHUDHandler.getHandlerForPlayer().ticksExisted * 100 / comHudHandler.getStartupTime() + "%", sr.getScaledWidth() * 3 / 4 - 8, 16, 0x000000);
} else if (helmetStack == null) {
messageList.clear();
}
}
use of net.minecraft.client.gui.ScaledResolution in project PneumaticCraft by MineMaarten.
the class MainHelmetHandler method getAnimatedStat.
@Override
@SideOnly(Side.CLIENT)
public IGuiAnimatedStat getAnimatedStat() {
if (powerStat == null) {
Minecraft minecraft = Minecraft.getMinecraft();
ScaledResolution sr = new ScaledResolution(minecraft, minecraft.displayWidth, minecraft.displayHeight);
powerStat = new GuiAnimatedStat(null, "Helmet Pressure: ", "", powerStatX != -1 ? powerStatX : sr.getScaledWidth() - 2, powerStatY, 0x3000AA00, null, powerStatLeftSided);
powerStat.setMinDimensionsAndReset(0, 0);
powerStat.openWindow();
}
return powerStat;
}
use of net.minecraft.client.gui.ScaledResolution in project Minechem by iopleke.
the class RenderHelper method setScissor.
/**
* Start a GL_SCISSOR_TEST
*
* @param guiWidth {@link net.minecraft.client.gui.GuiScreen#width}
* @param guiHeight {@link net.minecraft.client.gui.GuiScreen#height}
* @param x xPos to start scissor
* @param y yPos to start scissor
* @param w width of the scissor
* @param h height of the scissor
*/
public static void setScissor(int guiWidth, int guiHeight, float x, float y, int w, int h) {
Minecraft mc = Minecraft.getMinecraft();
ScaledResolution scaledRes = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int scale = scaledRes.getScaleFactor();
x *= scale;
y *= scale;
w *= scale;
h *= scale;
float guiScaledWidth = (guiWidth * scale);
float guiScaledHeight = (guiHeight * scale);
float guiLeft = ((mc.displayWidth / 2) - guiScaledWidth / 2);
float guiTop = ((mc.displayHeight / 2) + guiScaledHeight / 2);
int scissorX = Math.round((guiLeft + x));
int scissorY = Math.round(((guiTop - h) - y));
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor(scissorX, scissorY, w, h);
}
use of net.minecraft.client.gui.ScaledResolution in project ArsMagica2 by Mithion.
the class AMIngameGUI method renderGameOverlay.
public void renderGameOverlay() {
ItemStack ci = Minecraft.getMinecraft().thePlayer.getCurrentEquippedItem();
boolean drawAMHud = !AMCore.config.showHudMinimally() || (ci != null && (ci.getItem() == ItemsCommonProxy.spellBook || ci.getItem() == ItemsCommonProxy.spell || ci.getItem() == ItemsCommonProxy.arcaneSpellbook || ci.getItem() instanceof IBoundItem));
ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int i = scaledresolution.getScaledWidth();
int j = scaledresolution.getScaledHeight();
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_TEXTURE_BIT);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (drawAMHud)
RenderBuffs(i, j);
mc.renderEngine.bindTexture(items);
if (drawAMHud)
RenderContingency(i, j);
if (drawAMHud)
RenderArsMagicaGUIItems(i, j, mc.fontRenderer);
if (drawAMHud)
RenderAffinity(i, j);
RenderArmorStatus(i, j, mc, mc.fontRenderer);
if (drawAMHud)
RenderMagicXP(i, j);
ItemStack item = mc.thePlayer.getCurrentEquippedItem();
if (item != null && item.getItem() instanceof ItemSpellBook) {
RenderSpellBookUI(i, j, mc.fontRenderer, mc.thePlayer.getCurrentEquippedItem());
}
GL11.glPopAttrib();
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glColor4f(1, 1, 1, 1);
}
Aggregations