Java Code Examples for org.lwjgl.input.Mouse

The following are top voted examples for showing how to use org.lwjgl.input.Mouse. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: CustomWorldGen   File: GuiContainerCreative.java   View source code 6 votes vote down vote up
/**
 * Handles mouse input.
 */
public void handleMouseInput() throws IOException
{
    super.handleMouseInput();
    int i = Mouse.getEventDWheel();

    if (i != 0 && this.needsScrollBars())
    {
        int j = (((GuiContainerCreative.ContainerCreative)this.inventorySlots).itemList.size() + 9 - 1) / 9 - 5;

        if (i > 0)
        {
            i = 1;
        }

        if (i < 0)
        {
            i = -1;
        }

        this.currentScroll = (float)((double)this.currentScroll - (double)i / (double)j);
        this.currentScroll = MathHelper.clamp_float(this.currentScroll, 0.0F, 1.0F);
        ((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
    }
}
 
Example 2
Project: BaseClient   File: ClickGui.java   View source code 6 votes vote down vote up
public void drawScreen(int x, int y, float par3) {
    int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
    int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
    if (this.currentLayerType == Type.CATEGORY) {
        for (Button categoryButton : this.categoryList) {
            categoryButton.draw(mouseX, mouseY);
        }
    } else if (this.currentLayerType == Type.MODULE) {
        this.backButton.draw(mouseX, mouseY);
        for (Button moduleButton : this.moduleList) {
            moduleButton.draw(mouseX, mouseY);
        }
    } else if (this.currentLayerType == Type.OPTION) {
        this.backButton.draw(mouseX, mouseY);
        for (Button optionButton : this.optionList) {
            optionButton.draw(mouseX, mouseY);
        }
    } else if (this.currentLayerType == Type.SLIDER) {
        this.backButton.draw(mouseX, mouseY);
        slider.draw(mouseX, mouseY);
    }
}
 
Example 3
Project: pnc-repressurized   File: GuiSecurityStationHacking.java   View source code 6 votes vote down vote up
public void addExtraHackInfo(List<String> currenttip) {
    int mouseX = Mouse.getX() * this.width / this.mc.displayWidth;
    int mouseY = this.height - Mouse.getY() * this.height / this.mc.displayHeight - 1;
    Slot slot = getSlotAtPosition(mouseX, mouseY);
    if (slot != null) {
        if (hackerBridges.slotHacked[slot.slotNumber]) {
            if (!hackerBridges.slotFortified[slot.slotNumber]) {
                currenttip.add(TextFormatting.RED + "DETECTION: " + te.getDetectionChance() + "%");
                currenttip.add(TextFormatting.YELLOW + "Right-click to fortify");
            }
        } else if (hackerBridges.canHackSlot(slot.slotNumber)) {
            currenttip.add(TextFormatting.RED + "DETECTION: " + te.getDetectionChance() + "%");
            currenttip.add(TextFormatting.GREEN + "Left-click to hack");

        }
    }
}
 
Example 4
Project: Firma   File: ClayItem.java   View source code 6 votes vote down vote up
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
	Mouse.setGrabbed(false); // TODO Remove debug
	ItemStack is = player.getHeldItem(handIn);
	if (player.getHeldItemMainhand().getCount() > 4) {
		if (worldIn.isRemote) {
			GuiKnapping.staticMaterial = CraftMat.CLAY;
			GuiKnapping.staticMaterialSub = this.getSubName(is.getItemDamage());

			player.openGui(FirmaMod.instance, GuiHandler.GUI_KNAPPING, player.world, (int) player.posX, (int) player.posY, (int) player.posZ);
		} else {
			PlayerData pd = PlayerData.getPlayerData(player.getUniqueID());
			pd.resetKnapCraft();
			pd.setItemStack(player.getHeldItemMainhand());
			pd.setCraftingMaterial(CraftMat.CLAY);
		}
	}
	return new ActionResult<ItemStack>(EnumActionResult.PASS, is);
}
 
Example 5
Project: OpenGL-Bullet-engine   File: Renderer.java   View source code 6 votes vote down vote up
@Override
	public void onMouseButton(MouseButtonEvent e){
		Gui openGui=guiHandler.getOpenGui();
		if(openGui!=null) openGui.onMouseButton(e);
		else e.source.centerMouse();
		
		if(e.action==Action.DOWN){
			if(Shaders.ENTITY!=null){
				Shaders.ENTITY.load();
				Shaders.TERRAIN.load();
//				Shaders.SKYBOX.load();
//				Shaders.GUI_RECT.load();
//				Shaders.POST_COPY.load();
			}
		}
		
		Mouse.setGrabbed(!Game.isPaused());
	}
 
Example 6
Project: OpenGL-Bullet-engine   File: Camera.java   View source code 6 votes vote down vote up
@Override
public void onMouseMove(MouseMoveEvent e){
	if(!Game.win().isFocused()||!Mouse.isGrabbed()) return;
	if(noMouseMode){
		if(Keyboard.isKeyDown(Keyboard.KEY_Q)) rot.y-=0.1;
		if(Keyboard.isKeyDown(Keyboard.KEY_E)) rot.y+=0.1;
		if(Keyboard.isKeyDown(Keyboard.KEY_R)) rot.x-=0.1;
		if(Keyboard.isKeyDown(Keyboard.KEY_F)) rot.x+=0.1;
	}else{
		rot.x-=e.yDelta/200F;
		rot.y+=e.xDelta/200F;
		Game.win().centerMouse();
	}
	
	if(rot.x>Math.PI/2) rot.x=(float)(Math.PI/2);
	else if(rot.x<-Math.PI/2) rot.x=(float)(-Math.PI/2);
}
 
Example 7
Project: DecompiledMinecraft   File: GuiScreen.java   View source code 6 votes vote down vote up
/**
 * Delegates mouse and keyboard input.
 */
public void handleInput() throws IOException
{
    if (Mouse.isCreated())
    {
        while (Mouse.next())
        {
            this.handleMouseInput();
        }
    }

    if (Keyboard.isCreated())
    {
        while (Keyboard.next())
        {
            this.handleKeyboardInput();
        }
    }
}
 
Example 8
Project: BaseClient   File: GuiContainerCreative.java   View source code 6 votes vote down vote up
/**
 * Handles mouse input.
 */
public void handleMouseInput() throws IOException
{
    super.handleMouseInput();
    int i = Mouse.getEventDWheel();

    if (i != 0 && this.needsScrollBars())
    {
        int j = ((GuiContainerCreative.ContainerCreative)this.inventorySlots).itemList.size() / 9 - 5;

        if (i > 0)
        {
            i = 1;
        }

        if (i < 0)
        {
            i = -1;
        }

        this.currentScroll = (float)((double)this.currentScroll - (double)i / (double)j);
        this.currentScroll = MathHelper.clamp_float(this.currentScroll, 0.0F, 1.0F);
        ((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
    }
}
 
Example 9
Project: BaseClient   File: AppGameContainer.java   View source code 6 votes vote down vote up
/**
 * @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
 */
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
	try {
		Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
		Graphics g = temp.getGraphics();
		
		ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
		g.drawImage(image.getFlippedCopy(false, true), 0, 0);
		g.flush();
		g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
		
		Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
		Mouse.setNativeCursor(cursor);
	} catch (Throwable e) {
		Log.error("Failed to load and apply cursor.", e);
		throw new SlickException("Failed to set mouse cursor", e);
	}
}
 
Example 10
Project: BaseClient   File: GuiChat.java   View source code 6 votes vote down vote up
/**
 * Handles mouse input.
 */
public void handleMouseInput() throws IOException
{
    super.handleMouseInput();
    int i = Mouse.getEventDWheel();

    if (i != 0)
    {
        if (i > 1)
        {
            i = 1;
        }

        if (i < -1)
        {
            i = -1;
        }

        if (!isShiftKeyDown())
        {
            i *= 7;
        }

        this.mc.ingameGUI.getChatGUI().scroll(i);
    }
}
 
Example 11
Project: BaseClient   File: GuiChat.java   View source code 6 votes vote down vote up
/**
 * Handles mouse input.
 */
public void handleMouseInput() throws IOException
{
    super.handleMouseInput();
    int i = Mouse.getEventDWheel();

    if (i != 0)
    {
        if (i > 1)
        {
            i = 1;
        }

        if (i < -1)
        {
            i = -1;
        }

        if (!isShiftKeyDown())
        {
            i *= 7;
        }

        this.mc.ingameGUI.getChatGUI().scroll(i);
    }
}
 
Example 12
Project: Mods   File: TF2EventsClient.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void renderTick(TickEvent.RenderTickEvent event) {

	tickTime = event.renderTickTime;
	Minecraft minecraft = Minecraft.getMinecraft();
	if (event.phase == Phase.END)
		if (minecraft.player != null && minecraft.player.getHeldItemMainhand() != null)
			if (minecraft.player.getHeldItemMainhand().getItem() instanceof ItemUsable) {
				Mouse.poll();
				minecraft.player.rotationYawHead = minecraft.player.rotationYaw;
				moveEntities = true;
				keyPressUpdate(Mouse.isButtonDown(minecraft.gameSettings.keyBindAttack.getKeyCode() + 100),
						Mouse.isButtonDown(minecraft.gameSettings.keyBindUseItem.getKeyCode() + 100));
				moveEntities = false;
			}
}
 
Example 13
Project: Wurst-MC-1.12   File: NavigatorScreen.java   View source code 6 votes vote down vote up
@Override
public final void updateScreen()
{
	onUpdate();
	
	// scrollbar
	if(!scrollbarLocked)
	{
		scroll += Mouse.getDWheel() / 10;
		
		if(scroll > 0)
			scroll = 0;
		else if(scroll < maxScroll)
			scroll = maxScroll;
		
		if(maxScroll == 0)
			scrollKnobPosition = 0;
		else
			scrollKnobPosition =
				(int)((height - 131) * scroll / (float)maxScroll);
		scrollKnobPosition += 2;
	}
}
 
Example 14
Project: Progetto-C   File: AppGameContainer.java   View source code 6 votes vote down vote up
/**
 * @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.Image, int, int)
 */
public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
	try {
		Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
		Graphics g = temp.getGraphics();
		
		ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
		g.drawImage(image.getFlippedCopy(false, true), 0, 0);
		g.flush();
		g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
		
		Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),image.getHeight());
		Mouse.setNativeCursor(cursor);
	} catch (Throwable e) {
		Log.error("Failed to load and apply cursor.", e);
		throw new SlickException("Failed to set mouse cursor", e);
	}
}
 
Example 15
Project: Whoosh   File: GuiTransporter.java   View source code 6 votes vote down vote up
@Override
public void handleMouseInput() throws IOException {

    super.handleMouseInput();

    int textAreaX = taPoints.xPos - guiLeft;
    int textAreaY = taPoints.yPos - guiTop;

    if (textAreaX <= mouseX && mouseX < textAreaX + taPoints.width && mouseY >= textAreaY && mouseY < textAreaY + taPoints.height) {
        int wheelDir = Mouse.getEventDWheel();

        if (wheelDir < 0) {
            taPoints.scrollUp();
        }

        if (wheelDir > 0) {
            taPoints.scrollDown();
        }
    }
}
 
Example 16
Project: BaseClient   File: AppletGameContainer.java   View source code 6 votes vote down vote up
/**
  * {@inheritDoc}
  */
 public void setMouseCursor(Image image, int hotSpotX, int hotSpotY) throws SlickException {
     try {
        Image temp = new Image(get2Fold(image.getWidth()), get2Fold(image.getHeight()));
        Graphics g = temp.getGraphics();
        
        ByteBuffer buffer = BufferUtils.createByteBuffer(temp.getWidth() * temp.getHeight() * 4);
        g.drawImage(image.getFlippedCopy(false, true), 0, 0);
        g.flush();
        g.getArea(0,0,temp.getWidth(),temp.getHeight(),buffer);
        
        Cursor cursor = CursorLoader.get().getCursor(buffer, hotSpotX, hotSpotY,temp.getWidth(),temp.getHeight());
        Mouse.setNativeCursor(cursor);
     } catch (Throwable e) {
        Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
     }
  }
 
Example 17
Project: bit-client   File: NoThemeButtonComponent.java   View source code 6 votes vote down vote up
@Override
public void render(float mouseX, float mouseY, boolean mouseOver, VectorUtil position, VectorUtil size, Object... payload) {
    String title = (String) payload[0];
    int alpha = (int) payload[1];
    boolean color = (boolean) payload[2];
    boolean centered = (boolean) payload[3];

    if (mouseOver)
        TessRenderUtil.drawRect(position.getX() + (centered ? 15 + 18 - 1 : 6), position.getY() + 3.5f,
                (float) (position.getX() + (centered ? 15 + 18 : 6) + Wrapper.getStringWidth(title) / 2
                        + 3),
                position.getY() + size.getY() + 1,
                new ColorBuilder(20, 20, 20, 145).build_hex());

    TessRenderUtil.drawBorderedRect(position.getX() + (centered ? 15 + 18 : 6) - 1, position.getY() + 3.5f,
            (float) (position.getX() + (centered ? 15 + 18 : 6) + Wrapper.getStringWidth(title) / 2
                    + 3),
            position.getY() + size.getY() + 1, Mouse.isButtonDown(0) && mouseOver ? 0.8f : 0.6f,
            new ColorBuilder(20, 20, 20, 145).build_hex(), new ColorBuilder(255, 255, 255, alpha).build_hex());


    Wrapper.drawStringWithShadow_scaled(title, (int) (position.getX() + (centered ? 15 + 18 : 6) + 1),
            (int) (position.getY() + 6), color ? ColorUtil.getClientColor() : -1, 0.5);
}
 
Example 18
Project: Backmemed   File: GuiScreen.java   View source code 6 votes vote down vote up
/**
 * Delegates mouse and keyboard input.
 */
public void handleInput() throws IOException
{
    if (Mouse.isCreated())
    {
        while (Mouse.next())
        {
            this.handleMouseInput();
        }
    }

    if (Keyboard.isCreated())
    {
        while (Keyboard.next())
        {
            this.handleKeyboardInput();
        }
    }
}
 
Example 19
Project: HCMIU_PlantsAndZombies   File: GameOver.java   View source code 6 votes vote down vote up
private void showExitGameButton(GameContainer gc, Graphics g) throws SlickException {
	float rate = 1.14f;
	float posX = 885 * PZGUI.getResolutionRateWidth();
	float posY = 430 * PZGUI.getResolutionRateHeight();
	float width = newGameButton.getWidth() * PZGUI.getResolutionRateWidth() * rate;
	float height = newGameButton.getHeight() * PZGUI.getResolutionRateHeight() * rate;
	
	exitGameButton.draw(posX, posY, width, height);
	
	if (Controller.mouseInArea(posX, posY, posX + width, posY + height)) {
		exitGameButton.draw(posX, posY, width, height, new Color(0, 0, 0, 100));
		if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
			gc.exit();
			try {
				TimeUnit.MILLISECONDS.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
 
Example 20
Project: HCMIU_PlantsAndZombies   File: PlayUI.java   View source code 6 votes vote down vote up
/**
 * Draw Pause button
 * @param gc	GameContainer
 * @param g	Graphics
 * @throws SlickException
 */
public static void showPauseButton(GameContainer gc, Graphics g) throws SlickException {
	pauseButton.draw(pauseButtonPosX, pauseButtonPosY, pauseButtonWidth, pauseButtonHeight);

	if (Controller.mouseInArea(pauseButtonPosX, pauseButtonPosY, pauseButtonPosX + pauseButtonHeight,
								pauseButtonPosY + pauseButtonHeight)) {
		pauseButton.draw(pauseButtonPosX, pauseButtonPosY, pauseButtonWidth, pauseButtonHeight, new Color(0, 0, 0, 50));

		if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
			gc.setPaused(!gc.isPaused());
			try {
				TimeUnit.MILLISECONDS.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
 
Example 21
Project: HCMIU_PlantsAndZombies   File: PlayUI.java   View source code 6 votes vote down vote up
/**
 * Show Shovel button
 * @param gc	GameContainer
 * @param g Graphics
 */
public static void showShovel(GameContainer gc, Graphics g) {
	shovel.draw(shovelButtonPosX, shovelButtonPosY, shovelButtonWidth, shovelButtonHeight);
	if (Controller.mouseInArea(shovelButtonPosX, shovelButtonPosY, shovelButtonPosX + shovelButtonWidth, shovelButtonPosY + shovelButtonHeight)) {
		shovel.draw(shovelButtonPosX, shovelButtonPosY, shovelButtonWidth, shovelButtonHeight, new Color(0, 0, 0, 100));
		if (Mouse.getEventButtonState() && Mouse.getEventButton() == 0) {
			isShovelClicked = !isShovelClicked;
			try {
				TimeUnit.MILLISECONDS.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
	if (isShovelClicked) {
		shovel.draw(Controller.getMouseX() - (20 * PZGUI.getResolutionRateWidth()), 
				    Controller.getMouseY() - (30 * PZGUI.getResolutionRateHeight()), 
				    shovelButtonWidth, 
				    shovelButtonHeight);
	}		
}
 
Example 22
Project: HCMIU_PlantsAndZombies   File: SplashScreen.java   View source code 6 votes vote down vote up
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 23
Project: BaseClient   File: GuiChat.java   View source code 6 votes vote down vote up
/**
 * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
 */
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
{
    if (mouseButton == 0)
    {
        IChatComponent ichatcomponent = this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY());

        if (this.handleComponentClick(ichatcomponent))
        {
            return;
        }
    }

    this.inputField.mouseClicked(mouseX, mouseY, mouseButton);
    super.mouseClicked(mouseX, mouseY, mouseButton);
}
 
Example 24
Project: Backmemed   File: GuiContainerCreative.java   View source code 6 votes vote down vote up
/**
 * Handles mouse input.
 */
public void handleMouseInput() throws IOException
{
    super.handleMouseInput();
    int i = Mouse.getEventDWheel();

    if (i != 0 && this.needsScrollBars())
    {
        int j = (((GuiContainerCreative.ContainerCreative)this.inventorySlots).itemList.size() + 9 - 1) / 9 - 5;

        if (i > 0)
        {
            i = 1;
        }

        if (i < 0)
        {
            i = -1;
        }

        this.currentScroll = (float)((double)this.currentScroll - (double)i / (double)j);
        this.currentScroll = MathHelper.clamp(this.currentScroll, 0.0F, 1.0F);
        ((GuiContainerCreative.ContainerCreative)this.inventorySlots).scrollTo(this.currentScroll);
    }
}
 
Example 25
Project: PurificatiMagicae   File: GuiMicroscopeResearch.java   View source code 6 votes vote down vote up
private void performAction(int x, int y, boolean checkPos)
{
    x = x - maxLeft;
    y = y - maxUp;
    if(x > 0 && y > 0)
    {
        int col = x / buttSize;
        int row = y / buttSize;
        if(!checkPos || (prevC != col || prevR != row))
        {
            prevC = col;
            prevR = row;
            if (Mouse.isButtonDown(0))
            {
                current[row][col] = !current[row][col];
                Minecraft.getMinecraft().player.playSound(SoundRegistry.MAGICAL_CLICK, 1, 1);
            } else if (Mouse.isButtonDown(1))
            {
                crosses[row][col] = !crosses[row][col];
                Minecraft.getMinecraft().player.playSound(SoundRegistry.MAGICAL_CLICK, 1, 1);
            }
        }
    }
}
 
Example 26
Project: trashjam2017   File: AppletGameContainer.java   View source code 5 votes vote down vote up
/**
* @see org.newdawn.slick.GameContainer#setMouseCursor(java.lang.String,
*      int, int)
*/
   public void setMouseCursor(String ref, int hotSpotX, int hotSpotY) throws SlickException {
      try {
         Cursor cursor = CursorLoader.get().getCursor(ref, hotSpotX, hotSpotY);
         Mouse.setNativeCursor(cursor);
      } catch (Throwable e) {
         Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
      }
   }
 
Example 27
Project: trashjam2017   File: AppletGameContainer.java   View source code 5 votes vote down vote up
/**
    * @see org.newdawn.slick.GameContainer#setMouseCursor(org.lwjgl.input.Cursor, int, int)
    */
   public void setMouseCursor(Cursor cursor, int hotSpotX, int hotSpotY) throws SlickException {
      try {
         Mouse.setNativeCursor(cursor);
      } catch (Throwable e) {
         Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
      }
   }
 
Example 28
Project: Backmemed   File: GuiChat.java   View source code 5 votes vote down vote up
/**
 * Draws the screen and all the components in it.
 */
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
    drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
    this.inputField.drawTextBox();
    ITextComponent itextcomponent = this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY());

    if (itextcomponent != null && itextcomponent.getStyle().getHoverEvent() != null)
    {
        this.handleComponentHover(itextcomponent, mouseX, mouseY);
    }

    super.drawScreen(mouseX, mouseY, partialTicks);
}
 
Example 29
Project: OcclusionQueries   File: Camera.java   View source code 5 votes vote down vote up
private void calculateAngleAroundPlayer(){
	if(Mouse.isButtonDown(0)){
		float angleChange = Mouse.getDX() * 0.3f;
		angleAroundPlayer.increaseTarget(-angleChange);;
	}else if(Keyboard.isKeyDown(Keyboard.KEY_R)){
		angleAroundPlayer.increaseTarget(0.05f);
	}
	angleAroundPlayer.update(0.01f);
}
 
Example 30
Project: trashjam2017   File: Input.java   View source code 5 votes vote down vote up
/**
 * 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 31
Project: BaseClient   File: AppGameContainer.java   View source code 5 votes vote down vote up
/**
 * @see org.newdawn.slick.GameContainer#setDefaultMouseCursor()
 */
public void setDefaultMouseCursor() {
	try {
		Mouse.setNativeCursor(null);
	} catch (LWJGLException e) {
		Log.error("Failed to reset mouse cursor", e);
	}
}
 
Example 32
Project: CustomWorldGen   File: MouseEvent.java   View source code 5 votes vote down vote up
public MouseEvent()
{
    this.x = Mouse.getEventX();
    this.y = Mouse.getEventY();
    this.dx = Mouse.getEventDX();
    this.dy = Mouse.getEventDY();
    this.dwheel = Mouse.getEventDWheel();
    this.button = Mouse.getEventButton();
    this.buttonstate = Mouse.getEventButtonState();
    this.nanoseconds = Mouse.getEventNanoseconds();
}
 
Example 33
Project: Proyecto-DASI   File: MalmoModClient.java   View source code 5 votes vote down vote up
@Override
/**
 * Ungrabs the mouse cursor so it can be moved and set it to the center of the screen
 */
public void ungrabMouseCursor()
{
    // Vanilla Minecraft calls Mouse.setCursorPosition(Display.getWidth() / 2, Display.getHeight() / 2) at this point...
    // but it's seriously annoying, so we don't.
    Mouse.setGrabbed(false);
}
 
Example 34
Project: BaseClient   File: MouseHelper.java   View source code 5 votes vote down vote up
/**
 * Grabs the mouse cursor it doesn't move and isn't seen.
 */
public void grabMouseCursor()
{
    Mouse.setGrabbed(true);
    this.deltaX = 0;
    this.deltaY = 0;
}
 
Example 35
Project: bit-client   File: ComponentList.java   View source code 5 votes vote down vote up
@Override
public void render(float mouseX, float mouseY) {
    Bit.getInstance().getThemeManager().getRenderComponent(ComponentList.class).render(mouseX, mouseY, mouseOver(mouseX, mouseY), getPosition(), getSize(), drawBackground, totalPosY, (parent instanceof Window ? ((Window) parent).isDragging() && Mouse.isButtonDown(0) : (parent instanceof ModComponent && ((ModComponent) parent).getParent().isDragging()) && Mouse.isButtonDown(0)));
    try {
        this.components.forEach(comp -> {
            comp.render(mouseX, mouseY);
        });
    } catch (Exception e) {
    }
}
 
Example 36
Project: BaseClient   File: AppletGameContainer.java   View source code 5 votes vote down vote up
/**
    * @see org.newdawn.slick.GameContainer#setMouseCursor(org.newdawn.slick.opengl.ImageData, int, int)
    */
   public void setMouseCursor(ImageData data, int hotSpotX, int hotSpotY) throws SlickException {
      try {
         Cursor cursor = CursorLoader.get().getCursor(data, hotSpotX, hotSpotY);
         Mouse.setNativeCursor(cursor);
      } catch (Throwable e) {
         Log.error("Failed to load and apply cursor.", e);
throw new SlickException("Failed to set mouse cursor", e);
      }
   }
 
Example 37
Project: rezolve   File: RemoteShellGuiContainer.java   View source code 5 votes vote down vote up
@Override
public void handleMouseInput() throws IOException {
	super.handleMouseInput();
	
	BlockPos[] machines = this.entity.getConnectedMachines();
	
	this.listScrollPosition += Mouse.getEventDWheel() / 10;
	this.listScrollPosition = Math.min(0, this.listScrollPosition);
	this.listScrollPosition = Math.max(Math.min(0, machines.length * this.slotHeight * -1 + this.listHeight), this.listScrollPosition);
}
 
Example 38
Project: Clef   File: GuiPlayTrack.java   View source code 5 votes vote down vote up
@Override
public void handleMouseInput() throws IOException
{
    int mouseX = Mouse.getEventX() * this.width / this.mc.displayWidth;
    int mouseY = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;

    super.handleMouseInput();
    if(syncTrack == 0 || !disableListWhenSyncTrack)
    {
        this.trackList.handleMouseInput(mouseX, mouseY);
    }
    bandNameString = bandName.getText();
}
 
Example 39
Project: CustomWorldGen   File: GuiChat.java   View source code 5 votes vote down vote up
/**
 * Draws the screen and all the components in it.
 */
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
    drawRect(2, this.height - 14, this.width - 2, this.height - 2, Integer.MIN_VALUE);
    this.inputField.drawTextBox();
    ITextComponent itextcomponent = this.mc.ingameGUI.getChatGUI().getChatComponent(Mouse.getX(), Mouse.getY());

    if (itextcomponent != null && itextcomponent.getStyle().getHoverEvent() != null)
    {
        this.handleComponentHover(itextcomponent, mouseX, mouseY);
    }

    super.drawScreen(mouseX, mouseY, partialTicks);
}
 
Example 40
Project: Elgin-Plant-Game   File: Camera.java   View source code 5 votes vote down vote up
private void calculateZoom() {
	float zoomLevel = Mouse.getDWheel() * 0.1f;
	distanceFromPlayer -= zoomLevel;
	if (distanceFromPlayer < 12f)
		distanceFromPlayer = 12f;
	if (distanceFromPlayer > 100f)
		distanceFromPlayer = 100f;
}