Java Code Examples for org.lwjgl.opengl.Display#isActive()

The following examples show how to use org.lwjgl.opengl.Display#isActive() . 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: GuiListChat.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = this.i;
	int mouseY = this.j;

	if (this.g(mouseY)) {
		if (Mouse.isButtonDown(0) && this.q()) {
			int y = mouseY - this.d - this.t + (int) this.n - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example 2
Source File: LwjglAbstractDisplay.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void run(){
    if (listener == null)
        throw new IllegalStateException("SystemListener is not set on context!"
                                      + "Must set with JmeContext.setSystemListner().");

    logger.log(Level.INFO, "Using LWJGL {0}", Sys.getVersion());
    initInThread();
    while (true){
        if (renderable.get()){
            if (Display.isCloseRequested())
                listener.requestClose(false);

            if (wasActive != Display.isActive()) {
                if (!wasActive) {
                    listener.gainFocus();
                    timer.reset();
                    wasActive = true;
                } else {
                    listener.loseFocus();
                    wasActive = false;
                }
            }
        }

        runLoop();

        if (needClose.get())
            break;
    }
    deinitInThread();
}
 
Example 3
Source File: LwjglAbstractDisplay.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void run(){
    if (listener == null) {
        throw new IllegalStateException("SystemListener is not set on context!"
                                      + "Must set with JmeContext.setSystemListener().");
    }

    loadNatives();
    logger.log(Level.FINE, "Using LWJGL {0}", Sys.getVersion());
    if (!initInThread()) {
        logger.log(Level.SEVERE, "Display initialization failed. Cannot continue.");
        return;
    }
    while (true){
        if (renderable.get()){
            if (Display.isCloseRequested())
                listener.requestClose(false);

            if (wasActive != Display.isActive()) {
                if (!wasActive) {
                    listener.gainFocus();
                    timer.reset();
                    wasActive = true;
                } else {
                    listener.loseFocus();
                    wasActive = false;
                }
            }
        }

        runLoop();

        if (needClose.get())
            break;
    }
    deinitInThread();
}
 
Example 4
Source File: FPSLock.java    From ForgeHax with MIT License 5 votes vote down vote up
private int getFps() {
  if (no_focus_fps.get() > 0 && !Display.isActive()) {
    return no_focus_fps.get();
  } else if (MC.currentScreen != null) {
    return menu_fps.get() > 0 ? menu_fps.get() : defaultFps.get();
  } else {
    return fps.get() > 0 ? fps.get() : defaultFps.get();
  }
}
 
Example 5
Source File: HyperiumSoundManager.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void playSound(ISound sound, CallbackInfo ci) {
    if (Settings.SMART_SOUNDS && !Display.isActive()) {
        ci.cancel(); // does not stop music from being played but whatever
        return;
    }

    SoundPlayEvent e = new SoundPlayEvent(sound);
    EventBus.INSTANCE.post(e);

    if (e.isCancelled()) ci.cancel();
}
 
Example 6
Source File: HyperiumEntityRenderer.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void updatePerspectiveCamera() {
    if (Hyperium.INSTANCE.getHandlers() == null || Hyperium.INSTANCE.getHandlers().getPerspectiveHandler() == null) {
        return;
    }

    PerspectiveModifierHandler perspectiveHandler = Hyperium.INSTANCE.getHandlers().getPerspectiveHandler();
    boolean flag2 = Display.isActive();
    if (Minecraft.getMinecraft().inGameHasFocus && flag2) {
        if (perspectiveHandler.enabled && Minecraft.getMinecraft().gameSettings.thirdPersonView != 1) {
            perspectiveHandler.onDisable();
        }

        if (perspectiveHandler.enabled) {
            Minecraft.getMinecraft().mouseHelper.mouseXYChange();

            float f = Minecraft.getMinecraft().gameSettings.mouseSensitivity * 0.6F + 0.2F;
            float f1 = f * f * f * 8.0F;
            float f2 = (float) Minecraft.getMinecraft().mouseHelper.deltaX * f1;
            float f3 = (float) Minecraft.getMinecraft().mouseHelper.deltaY * f1;

            // Modifying pitch and yaw values.
            perspectiveHandler.modifiedYaw += f2 / 8.0F;
            perspectiveHandler.modifiedPitch += f3 / 8.0F;

            // Checking if pitch exceeds maximum range.
            if (Math.abs(perspectiveHandler.modifiedPitch) > 90.0F) {
                if (perspectiveHandler.modifiedPitch > 0.0F) {
                    perspectiveHandler.modifiedPitch = 90.0F;
                } else {
                    perspectiveHandler.modifiedPitch = -90.0F;
                }
            }
        }
    }
}
 
Example 7
Source File: GuiListChat.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = getMouseX();
	int mouseY = getMouseY();

	if (this.isMouseYWithinSlotBounds(mouseY)) {
		if (Mouse.isButtonDown(0) && this.i()) {
			int y = mouseY - getRight() - this.j + (int) getCurrentScroll() - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example 8
Source File: GuiListChat.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = this.i;
	int mouseY = this.j;

	if (this.g(mouseY)) {
		if (Mouse.isButtonDown(0) && this.q()) {
			int y = mouseY - this.d - this.t + (int) this.n - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example 9
Source File: GuiListChat.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = this.i;
	int mouseY = this.j;

	if (this.g(mouseY)) {
		if (Mouse.isButtonDown(0) && this.q()) {
			int y = mouseY - this.d - this.t + (int) this.n - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example 10
Source File: GuiListChat.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = this.i;
	int mouseY = this.j;

	if (this.g(mouseY)) {
		if (Mouse.isButtonDown(0) && this.q()) {
			int y = mouseY - this.d - this.t + (int) this.n - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example 11
Source File: GuiListChat.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = this.i;
	int mouseY = this.j;

	if (this.g(mouseY)) {
		if (Mouse.isButtonDown(0) && this.q()) {
			int y = mouseY - this.d - this.t + (int) this.n - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example 12
Source File: GuiListChat.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = this.i;
	int mouseY = this.j;

	if (this.g(mouseY)) {
		if (Mouse.isButtonDown(0) && this.q()) {
			int y = mouseY - this.d - this.t + (int) this.n - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example 13
Source File: GuiListChat.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = this.i;
	int mouseY = this.j;

	if (this.g(mouseY)) {
		if (Mouse.isButtonDown(0) && this.q()) {
			int y = mouseY - this.d - this.t + (int) this.n - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example 14
Source File: GuiListChat.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = this.i;
	int mouseY = this.j;

	if (this.f(mouseY)) {
		if (Mouse.isButtonDown(0) && this.q()) {
			int y = mouseY - this.d - this.t + (int) this.n - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example 15
Source File: GuiListChat.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = this.i;
	int mouseY = this.j;

	if (this.g(mouseY)) {
		if (Mouse.isButtonDown(0) && this.q()) {
			int y = mouseY - this.d - this.t + (int) this.n - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example 16
Source File: GuiListChat.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = this.i;
	int mouseY = this.j;

	if (this.g(mouseY)) {
		if (Mouse.isButtonDown(0) && this.q()) {
			int y = mouseY - this.d - this.t + (int) this.n - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example 17
Source File: GuiListChat.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
/**
 * Handle Mouse Input
 */
@Override
public void handleMouseInput() {
	super.handleMouseInput();

	if (!Display.isActive()) // Don't allow multiple URL-Clicks if Display is not focused.
		return;

	int mouseX = this.i;
	int mouseY = this.j;

	if (this.g(mouseY)) {
		if (Mouse.isButtonDown(0) && this.q()) {
			int y = mouseY - this.d - this.t + (int) this.n - 4;
			int id = -1;
			int minY = -1;
			// Search for the right ChatLine-ID
			for (int i1 = 0; i1 < heightMap.size(); i1++) {
				Integer integer = heightMap.get(i1);
				Row line = rows.get(i1);
				if (y >= integer - 2 && y <= integer + line.getLineHeight() - 2) {
					id = i1;
					minY = integer;
					break;
				}
			}

			if (id < 0 || id >= rows.size())
				return;

			callback.chatLineClicked(rows.get(id), mouseX, y, minY, getLeft());
		}
	}
}
 
Example 18
Source File: FPSLimiter.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public boolean limit() {
    long secondsWait = 5;
    return (!Display.isActive() || limbo) && Settings.FPS_LIMITER && time * 20 >= secondsWait;
}
 
Example 19
Source File: AppGameContainer.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * @see org.newdawn.slick.GameContainer#hasFocus()
 */
public boolean hasFocus() {
	// hmm, not really the right thing, talk to the LWJGL guys
	return Display.isActive();
}
 
Example 20
Source File: Lwjgl2GameWrapper.java    From mini2Dx with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isGameWindowReady() {
	return Display.isActive();
}