Java Code Examples for org.lwjgl.input.Mouse.isButtonDown()

The following are Jave code examples for showing how to use isButtonDown() of the org.lwjgl.input.Mouse class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: pnc-repressurized   File: WidgetVerticalScrollbar.java   Source Code and License Vote up 6 votes
@Override
public void render(int mouseX, int mouseY, float partialTick) {
    GL11.glColor4d(1, 1, 1, 1);
    if (!Mouse.isButtonDown(0)) dragging = false;
    if (!wasClicking && Mouse.isButtonDown(0) && getBounds().contains(mouseX, mouseY)) {
        dragging = true;
    }
    if (!enabled) dragging = false;
    wasClicking = Mouse.isButtonDown(0);
    if (dragging) currentScroll = (float) (mouseY - 7 - getBounds().y) / (getBounds().height - 17);
    currentScroll = MathHelper.clamp(currentScroll, 0, 1);
    Minecraft.getMinecraft().getTextureManager().bindTexture(scrollTexture);
    Gui.drawModalRectWithCustomSizedTexture(x, y, 12, 0, getBounds().width, 1, 26, 15);
    for (int i = 0; i < getBounds().height - 2; i++)
        Gui.drawModalRectWithCustomSizedTexture(x, y + 1 + i, 12, 1, getBounds().width, 1, 26, 15);
    Gui.drawModalRectWithCustomSizedTexture(x, y + getBounds().height - 1, 12, 14, getBounds().width, 1, 26, 15);

    if (!enabled) GL11.glColor4d(0.6, 0.6, 0.6, 1);
    Gui.drawModalRectWithCustomSizedTexture(x + 1, y + 1 + (int) ((getBounds().height - 17) * currentScroll), 0, 0, 12, 15, 26, 15);
    GL11.glColor4d(1, 1, 1, 1);
}
 
Example 2
Project: bit-client   File: OffsetScroller.java   Source Code and License Vote up 6 votes
public void update(float contentSize, float mouseX, float mouseY, VectorUtil position) {
    this.position = position;
    windowContentRatio = windowSize / contentSize;
    gripSize = MathUtil.clamp(trackSize * windowContentRatio, 10, trackSize);
    gripPosY = (trackSize - gripSize) * (offset / (contentSize - windowSize));

    if (mouseOverTrack(mouseX, mouseY) && Mouse.isButtonDown(0))
        scrolling = true;
    else if (!Mouse.isButtonDown(0))
        scrolling = false;

    float delta = scrolling ? mouseY - oldMouseY : -scrollVelocity;

    float trackScrollArea = trackSize - gripSize;
    float newGripPosY = MathUtil.clamp(gripPosY + delta, 0, trackScrollArea);
    float gripPosRatio = newGripPosY / trackScrollArea;
    offset = gripPosRatio * ((windowSize / windowContentRatio) - windowSize);

    scrollVelocity = 0;


    oldMouseY = mouseY;
}
 
Example 3
Project: HCMIU_PlantsAndZombies   File: SplashScreen.java   Source Code and License Vote up 6 votes
public void startButton(GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException {
	float rate = 0.9f;
	float width = playButton.getWidth() * PZGUI.getResolutionRateWidth() * rate;
	float height = playButton.getHeight() * PZGUI.getResolutionRateHeight() * rate;
	
	float posX = PZGUI.getWidth()  /2 - width/2;
	float posY = PZGUI.getHeight() * (float)(0.7) - height/2;
	
	float edgeX = posX + width;
	float edgeY = posY + height;

	playButton.draw(posX, posY, width, height);
	if (	Mouse.getX() >= posX && 
			Mouse.getX() <= edgeX && 
			PZGUI.getHeight() - Mouse.getY() >= posY	&& 
			PZGUI.getHeight() - Mouse.getY() <= edgeY) {
		playButton.draw(posX, posY, width, height, new Color(100, 100, 100, 60));
		
		if (Mouse.isButtonDown(0))
			sbg.enterState(1);
	}
}
 
Example 4
Project: trashjam2017   File: Input.java   Source Code and License Vote up 5 votes
/**
 * Check if any mouse button is down
 * 
 * @return True if any mouse button is down
 */
private boolean anyMouseDown() {
	for (int i=0;i<3;i++) {
		if (Mouse.isButtonDown(i)) {
			return true;
		}
	}
	
	return false;
}
 
Example 5
Project: GeneralLaymansAestheticSpyingScreen   File: GuiWirelessOrder.java   Source Code and License Vote up 5 votes
@Override
public void updateScreen()
{
    if(!hasClicked)
    {
        rotateX += 2.5F;
        releasedMouse = releasedMouse || !Mouse.isButtonDown(0);
    }
}
 
Example 6
Project: Elgin-Plant-Game   File: Camera.java   Source Code and License Vote up 5 votes
private void calculatePitch() {
	if (Mouse.isButtonDown(1)) {
		float pitchChange = Mouse.getDY() * 0.1f;
		pitch -= pitchChange;

		if (pitch > 90)
			pitch = 90;
	}
}
 
Example 7
Project: BaseClient   File: TriggerBot.java   Source Code and License Vote up 5 votes
@EventTarget
private void onPostUpdate(UpdateEvent event) {
    if (event.state == Event.State.POST && (autoclicker && Mouse.isButtonDown((int)0) || !autoclicker) && this.mc.objectMouseOver != null && this.mc.objectMouseOver.entityHit != null && this.attackChecks(this.mc.objectMouseOver.entityHit) && this.timer.delay((float)(1000.0 / this.speed))) {
        if (this.criticals) {
            this.crit();
        }
        this.mc.thePlayer.swingItem();
        this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C02PacketUseEntity(this.mc.objectMouseOver.entityHit, C02PacketUseEntity.Action.ATTACK));
        this.timer.reset();
    }
}
 
Example 8
Project: HCMIU_PlantsAndZombies   File: Sun.java   Source Code and License Vote up 5 votes
protected void clickOn() {
	if (Mouse.getX() >= posX && Mouse.getX() <= posX + width && PZGUI.getHeight() - Mouse.getY() >= posY && PZGUI.getHeight() - Mouse.getY() <= posY + height) {
		
		if (Mouse.isButtonDown(0) && isClicked == false)
		{
			onClicked();
		}
	}
}
 
Example 9
Project: LowPolyTerrain   File: Camera.java   Source Code and License Vote up 5 votes
/**
 * Calculate the pitch and change the pitch if the user is moving the mouse
 * up or down with the LMB pressed.
 */
private void calculatePitch() {
	if (Mouse.isButtonDown(0)) {
		float pitchChange = Mouse.getDY() * PITCH_SENSITIVITY;
		pitch.increaseTarget(-pitchChange);
		clampPitch();
	}
	pitch.update(1f / 60);
}
 
Example 10
Project: rezolve   File: SecurityServerGuiContainer.java   Source Code and License Vote up 4 votes
@Override
protected void drawSubWindows(int mouseX, int mouseY) {
	
	int x = this.listX;
	int y = this.listY + this.listScrollPosition;
	
	for (Rule rule : this.entity.getRules()) {
		
		boolean mouseOver = 
			(x < mouseX && mouseX < x + this.listWidth) 
			&& (y < mouseY && mouseY < y + this.entryHeight)
			&& (listY < mouseY && mouseY < listY + this.listHeight)
		;
		
		if (!mouseDown && Mouse.isButtonDown(0) && mouseOver) {
			this.mouseDown = true;
			
			// We were clicked.
			
			this.selectRule(rule);
			
		}
		
		if (!Mouse.isButtonDown(0))
			mouseDown = false;
		
		if (y > 0 && y < this.listY + this.listHeight) {
			if (mouseOver) {
				drawRect(x, y, x + listWidth, y + entryHeight, 0xFF999999);
			}

			String modeStr = "";
			String nameStr = rule.getName();
			
			modeStr = this.getUserPolicyMode(rule.getMode());
			
			if ("<machines>".equals(rule.getName())) {
				nameStr = "Default Machine Policy";
				modeStr = this.getMachinePolicyMode(rule.getMode());
			} else if ("<players>".equals(rule.getName())) {
				nameStr = "Default User Policy";
			}
			
			if (this.entity.rootUser != null && this.entity.rootUser.equals(rule.getName())) {
				modeStr = modeStr + " [root]";
			}
			
			this.fontRendererObj.drawString(
				nameStr, 
				x + 2, y + 4, 
				0x000000
			);
			this.fontRendererObj.drawString(
				modeStr, 
				x + 2, y + 16, 
				0x666666
			);
		}
		
		y += this.entryHeight;
	}
}
 
Example 11
Project: DecompiledMinecraft   File: GuiContainerCreative.java   Source Code and License Vote up 4 votes
/**
 * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
 */
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
    boolean flag = Mouse.isButtonDown(0);
    int i = this.guiLeft;
    int j = this.guiTop;
    int k = i + 175;
    int l = j + 18;
    int i1 = k + 14;
    int j1 = l + 112;

    if (!this.wasClicking && flag && mouseX >= k && mouseY >= l && mouseX < i1 && mouseY < j1)
    {
        this.isScrolling = this.needsScrollBars();
    }

    if (!flag)
    {
        this.isScrolling = false;
    }

    this.wasClicking = flag;

    if (this.isScrolling)
    {
        this.currentScroll = ((float)(mouseY - l) - 7.5F) / ((float)(j1 - l) - 15.0F);
        this.currentScroll = MathHelper.clamp_float(this.currentScroll, 0.0F, 1.0F);
        ((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
    }

    super.drawScreen(mouseX, mouseY, partialTicks);

    for (CreativeTabs creativetabs : CreativeTabs.creativeTabArray)
    {
        if (this.renderCreativeInventoryHoveringText(creativetabs, mouseX, mouseY))
        {
            break;
        }
    }

    if (this.field_147064_C != null && selectedTabIndex == CreativeTabs.tabInventory.getTabIndex() && this.isPointInRegion(this.field_147064_C.xDisplayPosition, this.field_147064_C.yDisplayPosition, 16, 16, mouseX, mouseY))
    {
        this.drawCreativeTabHoveringText(I18n.format("inventory.binSlot", new Object[0]), mouseX, mouseY);
    }

    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableLighting();
}
 
Example 12
Project: lwjgl_collection   File: Boot.java   Source Code and License Vote up 4 votes
private void input() {
	if (mouseEnabled || Mouse.isButtonDown(0)) {
		mouseEnabled = true;
		int mousex = Mouse.getX();
		int mousey = 480 - Mouse.getY() - 1;
		boolean mouseClicked = Mouse.isButtonDown(0);
		selector_x = Math.round(mousex / World.BLOCK_SIZE);
		selector_y = Math.round(mousey / World.BLOCK_SIZE);
		if (mouseClicked) {
			grid.setAt(selector_x, selector_y, selection);
		}
	}
	
	while (Keyboard.next()) {
		if (Keyboard.getEventKey() == Keyboard.KEY_RIGHT && Keyboard.getEventKeyState()) {
			if (!(selector_x + 1 > World.BLOCKS_WIDTH - 2)) {
				mouseEnabled = false;
				selector_x++;
			}
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_LEFT && Keyboard.getEventKeyState()) {
			if (!(selector_x - 1 < 0)) {
				mouseEnabled = false;
				selector_x--;
			}
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_UP && Keyboard.getEventKeyState()) {
			if (!(selector_y - 1 < 0)) {
				mouseEnabled = false;
				selector_y--;
			}
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_DOWN && Keyboard.getEventKeyState()) {
			if (!(selector_y + 1 > World.BLOCKS_HEIGHT - 2)) {
				mouseEnabled = false;
				selector_y++;
			}
		}
		
		if (Keyboard.getEventKey() == Keyboard.KEY_S) {
			grid.save(new File("save.xml"));
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_L) {
			grid.load(new File("save.xml"));
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_1) {
			selection = BlockType.STONE;
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_2) {
			selection = BlockType.DIRT;
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_3) {
			selection = BlockType.GRASS;
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_4) {
			selection = BlockType.AIR;
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_C) {
			grid.clear();
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_SPACE) {
			grid.setAt(selector_x, selector_y, selection);
		}
		if (Keyboard.getEventKey() == Keyboard.KEY_ESCAPE) {
			Display.destroy();
			System.exit(0);
		}
	}
}
 
Example 13
Project: EcoSystem-Official   File: Camera.java   Source Code and License Vote up 4 votes
private void calculatePan() {
    if (Mouse.isButtonDown(0) && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL)) {
        cameraPosZ += Mouse.getDY() * -PAN_SENSITIVITY;
        cameraPosX += Mouse.getDX() * PAN_SENSITIVITY;
    }
}
 
Example 14
Project: BaseClient   File: GuiStats.java   Source Code and License Vote up 4 votes
protected void drawListHeader(int p_148129_1_, int p_148129_2_, Tessellator p_148129_3_)
{
    if (!Mouse.isButtonDown(0))
    {
        this.field_148218_l = -1;
    }

    if (this.field_148218_l == 0)
    {
        GuiStats.this.drawSprite(p_148129_1_ + 115 - 18, p_148129_2_ + 1, 0, 0);
    }
    else
    {
        GuiStats.this.drawSprite(p_148129_1_ + 115 - 18, p_148129_2_ + 1, 0, 18);
    }

    if (this.field_148218_l == 1)
    {
        GuiStats.this.drawSprite(p_148129_1_ + 165 - 18, p_148129_2_ + 1, 0, 0);
    }
    else
    {
        GuiStats.this.drawSprite(p_148129_1_ + 165 - 18, p_148129_2_ + 1, 0, 18);
    }

    if (this.field_148218_l == 2)
    {
        GuiStats.this.drawSprite(p_148129_1_ + 215 - 18, p_148129_2_ + 1, 0, 0);
    }
    else
    {
        GuiStats.this.drawSprite(p_148129_1_ + 215 - 18, p_148129_2_ + 1, 0, 18);
    }

    if (this.field_148217_o != -1)
    {
        int i = 79;
        int j = 18;

        if (this.field_148217_o == 1)
        {
            i = 129;
        }
        else if (this.field_148217_o == 2)
        {
            i = 179;
        }

        if (this.field_148215_p == 1)
        {
            j = 36;
        }

        GuiStats.this.drawSprite(p_148129_1_ + i, p_148129_2_ + 1, j, 0);
    }
}
 
Example 15
Project: BaseClient   File: GuiContainerCreative.java   Source Code and License Vote up 4 votes
/**
 * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
 */
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
    boolean flag = Mouse.isButtonDown(0);
    int i = this.guiLeft;
    int j = this.guiTop;
    int k = i + 175;
    int l = j + 18;
    int i1 = k + 14;
    int j1 = l + 112;

    if (!this.wasClicking && flag && mouseX >= k && mouseY >= l && mouseX < i1 && mouseY < j1)
    {
        this.isScrolling = this.needsScrollBars();
    }

    if (!flag)
    {
        this.isScrolling = false;
    }

    this.wasClicking = flag;

    if (this.isScrolling)
    {
        this.currentScroll = ((float)(mouseY - l) - 7.5F) / ((float)(j1 - l) - 15.0F);
        this.currentScroll = MathHelper.clamp_float(this.currentScroll, 0.0F, 1.0F);
        ((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
    }

    super.drawScreen(mouseX, mouseY, partialTicks);

    for (CreativeTabs creativetabs : CreativeTabs.creativeTabArray)
    {
        if (this.renderCreativeInventoryHoveringText(creativetabs, mouseX, mouseY))
        {
            break;
        }
    }

    if (this.field_147064_C != null && selectedTabIndex == CreativeTabs.tabInventory.getTabIndex() && this.isPointInRegion(this.field_147064_C.xDisplayPosition, this.field_147064_C.yDisplayPosition, 16, 16, mouseX, mouseY))
    {
        this.drawCreativeTabHoveringText(I18n.format("inventory.binSlot", new Object[0]), mouseX, mouseY);
    }

    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableLighting();
}
 
Example 16
Project: CustomWorldGen   File: GuiContainerCreative.java   Source Code and License Vote up 4 votes
/**
 * Draws the screen and all the components in it.
 */
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
    boolean flag = Mouse.isButtonDown(0);
    int i = this.guiLeft;
    int j = this.guiTop;
    int k = i + 175;
    int l = j + 18;
    int i1 = k + 14;
    int j1 = l + 112;

    if (!this.wasClicking && flag && mouseX >= k && mouseY >= l && mouseX < i1 && mouseY < j1)
    {
        this.isScrolling = this.needsScrollBars();
    }

    if (!flag)
    {
        this.isScrolling = false;
    }

    this.wasClicking = flag;

    if (this.isScrolling)
    {
        this.currentScroll = ((float)(mouseY - l) - 7.5F) / ((float)(j1 - l) - 15.0F);
        this.currentScroll = MathHelper.clamp_float(this.currentScroll, 0.0F, 1.0F);
        ((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
    }

    super.drawScreen(mouseX, mouseY, partialTicks);
    int start = tabPage * 10;
    int end = Math.min(CreativeTabs.CREATIVE_TAB_ARRAY.length, ((tabPage + 1) * 10) + 2);
    if (tabPage != 0) start += 2;
    boolean rendered = false;

    for (CreativeTabs creativetabs : java.util.Arrays.copyOfRange(CreativeTabs.CREATIVE_TAB_ARRAY,start,end))
    {
        if (creativetabs == null) continue;
        if (this.renderCreativeInventoryHoveringText(creativetabs, mouseX, mouseY))
        {
            rendered = true;
            break;
        }
    }

    if (!rendered && !renderCreativeInventoryHoveringText(CreativeTabs.SEARCH, mouseX, mouseY))
    {
        renderCreativeInventoryHoveringText(CreativeTabs.INVENTORY, mouseX, mouseY);
    }

    if (this.destroyItemSlot != null && selectedTabIndex == CreativeTabs.INVENTORY.getTabIndex() && this.isPointInRegion(this.destroyItemSlot.xDisplayPosition, this.destroyItemSlot.yDisplayPosition, 16, 16, mouseX, mouseY))
    {
        this.drawCreativeTabHoveringText(I18n.format("inventory.binSlot", new Object[0]), mouseX, mouseY);
    }

    if (maxPages != 0)
    {
        String page = String.format("%d / %d", tabPage + 1, maxPages + 1);
        int width = fontRendererObj.getStringWidth(page);
        GlStateManager.disableLighting();
        this.zLevel = 300.0F;
        itemRender.zLevel = 300.0F;
        fontRendererObj.drawString(page, guiLeft + (xSize / 2) - (width / 2), guiTop - 44, -1);
        this.zLevel = 0.0F;
        itemRender.zLevel = 0.0F;
    }

    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableLighting();
}
 
Example 17
Project: BaseClient   File: GameSettings.java   Source Code and License Vote up 4 votes
/**
 * Returns whether the specified key binding is currently being pressed.
 */
public static boolean isKeyDown(KeyBinding p_100015_0_)
{
    int i = p_100015_0_.getKeyCode();
    return i >= -100 && i <= 255 ? (p_100015_0_.getKeyCode() == 0 ? false : (p_100015_0_.getKeyCode() < 0 ? Mouse.isButtonDown(p_100015_0_.getKeyCode() + 100) : Keyboard.isKeyDown(p_100015_0_.getKeyCode()))) : false;
}
 
Example 18
Project: Backmemed   File: GuiContainerCreative.java   Source Code and License Vote up 4 votes
/**
 * Draws the screen and all the components in it.
 */
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
    boolean flag = Mouse.isButtonDown(0);
    int i = this.guiLeft;
    int j = this.guiTop;
    int k = i + 175;
    int l = j + 18;
    int i1 = k + 14;
    int j1 = l + 112;

    if (!this.wasClicking && flag && mouseX >= k && mouseY >= l && mouseX < i1 && mouseY < j1)
    {
        this.isScrolling = this.needsScrollBars();
    }

    if (!flag)
    {
        this.isScrolling = false;
    }

    this.wasClicking = flag;

    if (this.isScrolling)
    {
        this.currentScroll = ((float)(mouseY - l) - 7.5F) / ((float)(j1 - l) - 15.0F);
        this.currentScroll = MathHelper.clamp(this.currentScroll, 0.0F, 1.0F);
        ((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
    }

    super.drawScreen(mouseX, mouseY, partialTicks);

    for (CreativeTabs creativetabs : CreativeTabs.CREATIVE_TAB_ARRAY)
    {
        if (this.renderCreativeInventoryHoveringText(creativetabs, mouseX, mouseY))
        {
            break;
        }
    }

    if (this.destroyItemSlot != null && selectedTabIndex == CreativeTabs.INVENTORY.getTabIndex() && this.isPointInRegion(this.destroyItemSlot.xDisplayPosition, this.destroyItemSlot.yDisplayPosition, 16, 16, mouseX, mouseY))
    {
        this.drawCreativeTabHoveringText(I18n.format("inventory.binSlot", new Object[0]), mouseX, mouseY);
    }

    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableLighting();
}
 
Example 19
Project: trashjam2017   File: Input.java   Source Code and License Vote up 2 votes
/**
 * Check if a given mouse button is down
 * 
 * @param button The index of the button to check (starting at 0)
 * @return True if the mouse button is down
 */
public boolean isMouseButtonDown(int button) {
	return Mouse.isButtonDown(button);
}
 
Example 20
Project: Progetto-C   File: Input.java   Source Code and License Vote up 2 votes
/**
 * Check if a given mouse button is down
 * 
 * @param button The index of the button to check (starting at 0)
 * @return True if the mouse button is down
 */
public boolean isMouseButtonDown(int button) {
	return Mouse.isButtonDown(button);
}