本文整理汇总了Java中org.lwjgl.input.Mouse类的典型用法代码示例。如果您正苦于以下问题:Java Mouse类的具体用法?Java Mouse怎么用?Java Mouse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mouse类属于org.lwjgl.input包,在下文中一共展示了Mouse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleMouseInput
import org.lwjgl.input.Mouse; //导入依赖的package包/类
/**
* 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);
}
}
示例2: drawScreen
import org.lwjgl.input.Mouse; //导入依赖的package包/类
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);
}
}
示例3: addExtraHackInfo
import org.lwjgl.input.Mouse; //导入依赖的package包/类
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");
}
}
}
示例4: onItemRightClick
import org.lwjgl.input.Mouse; //导入依赖的package包/类
@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);
}
示例5: onMouseButton
import org.lwjgl.input.Mouse; //导入依赖的package包/类
@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());
}
示例6: onMouseMove
import org.lwjgl.input.Mouse; //导入依赖的package包/类
@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);
}
示例7: handleInput
import org.lwjgl.input.Mouse; //导入依赖的package包/类
/**
* 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();
}
}
}
示例8: handleMouseInput
import org.lwjgl.input.Mouse; //导入依赖的package包/类
/**
* 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);
}
}
示例9: setMouseCursor
import org.lwjgl.input.Mouse; //导入依赖的package包/类
/**
* @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);
}
}
示例10: handleMouseInput
import org.lwjgl.input.Mouse; //导入依赖的package包/类
/**
* 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);
}
}
示例11: renderTick
import org.lwjgl.input.Mouse; //导入依赖的package包/类
@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;
}
}
示例12: updateScreen
import org.lwjgl.input.Mouse; //导入依赖的package包/类
@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;
}
}
示例13: handleMouseInput
import org.lwjgl.input.Mouse; //导入依赖的package包/类
@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();
}
}
}
示例14: setMouseCursor
import org.lwjgl.input.Mouse; //导入依赖的package包/类
/**
* {@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);
}
}
示例15: render
import org.lwjgl.input.Mouse; //导入依赖的package包/类
@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);
}