Java Code Examples for org.newdawn.slick.Input#MOUSE_MIDDLE_BUTTON

The following examples show how to use org.newdawn.slick.Input#MOUSE_MIDDLE_BUTTON . 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: UserSelectOverlay.java    From opsu with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void mousePressed(int button, int x, int y) {
	if (!active)
		return;

	if (!contains(x, y)) {
		if (consumeAndClose) {
			consumeEvent();
			listener.close(false);
		}
		return;
	}

	consumeEvent();

	if (button == Input.MOUSE_MIDDLE_BUTTON)
		return;

	scrolling.pressed();
	mousePressY = y;

	if (state == State.USER_SELECT)
		selectedButton = getButtonAtPosition(x, y);
}
 
Example 2
Source File: Game.java    From opsu with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void mouseReleased(int button, int x, int y) {
	if (gameFinished)
		return;

	if (Options.isMouseDisabled())
		return;

	if (button == Input.MOUSE_MIDDLE_BUTTON)
		return;

	int keys = ReplayFrame.KEY_NONE;
	if (button == Input.MOUSE_LEFT_BUTTON)
		keys = ReplayFrame.KEY_M1;
	else if (button == Input.MOUSE_RIGHT_BUTTON)
		keys = ReplayFrame.KEY_M2;
	if (keys != ReplayFrame.KEY_NONE)
		gameKeyReleased(keys, x, y, MusicController.getPosition(true));
}
 
Example 3
Source File: DropdownMenu.java    From opsu with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void mousePressed(int button, int x, int y) {
	if (!active)
		return;

	if (button == Input.MOUSE_MIDDLE_BUTTON)
		return;

	int idx = getIndexAt(x, y);
	if (idx == -2) {
		this.expanded = false;
		return;
	}
	if (!menuClicked(idx))
		return;
	this.expanded = (idx == -1) ? !expanded : false;
	if (idx >= 0 && itemIndex != idx) {
		this.itemIndex = idx;
		itemSelected(idx, items[idx]);
	}
	blockClick = true;
	consumeEvent();
}
 
Example 4
Source File: GamePauseMenu.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mousePressed(int button, int x, int y) {
	if (button == Input.MOUSE_MIDDLE_BUTTON)
		return;

	boolean loseState = (gameState.getPlayState() == Game.PlayState.LOSE);
	if (continueButton.contains(x, y) && !loseState) {
		if (!Options.isGameplaySoundDisabled())
			SoundController.playSound(SoundEffect.MENUBACK);
		gameState.setPlayState(Game.PlayState.NORMAL);
		game.enterState(Opsu.STATE_GAME);
	} else if (retryButton.contains(x, y)) {
		SoundController.playSound(SoundEffect.MENUHIT);
		gameState.setPlayState(Game.PlayState.RETRY);
		game.enterState(Opsu.STATE_GAME);
	} else if (backButton.contains(x, y)) {
		SoundController.playSound(SoundEffect.MENUBACK);
		((SongMenu) game.getState(Opsu.STATE_SONGMENU)).resetGameDataOnLoad();
		if (loseState)
			MusicController.playAt(MusicController.getBeatmap().previewTime, true);
		else
			MusicController.resume();
		if (UI.getCursor().isBeatmapSkinned())
			UI.getCursor().reset();
		MusicController.setPitch(1.0f);
		game.enterState(Opsu.STATE_SONGMENU, new EasedFadeOutTransition(), new FadeInTransition());
	}
}
 
Example 5
Source File: SongMenu.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mousePressed(int button, int x, int y) {
	// check mouse button
	if (button == Input.MOUSE_MIDDLE_BUTTON)
		return;

	// block input
	if (isInputBlocked())
		return;

	if (showOptionsOverlay || !optionsOverlayProgress.isFinished() ||
	    showUserOverlay || !userOverlayProgress.isFinished())
		return;

	if (isScrollingToFocusNode)
		return;

	if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) {
		songScrolling.setSpeedMultiplier(FAST_SCROLL_SPEED);

		// check if anything was clicked
		for (BeatmapGroup group : BeatmapGroup.values()) {
			if (group.contains(x, y))
				return;
		}
		if (UI.getBackButton().contains(x, y) ||
		    selectModsButton.contains(x, y) || selectRandomButton.contains(x, y) ||
		    selectMapOptionsButton.contains(x, y) || selectOptionsButton.contains(x, y) ||
		    focusNode == null || getNodeAtPosition(x, y) != null ||
		    footerLogoButton.contains(x, y, 0.25f) || ScoreData.areaContains(x, y))
			return;

		// scroll to the mouse position on the screen
		scrollSongsToPosition(y);
	} else
		songScrolling.pressed();
	startScorePos.pressed();
}
 
Example 6
Source File: SongMenu.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mouseReleased(int button, int x, int y) {
	// check mouse button
	if (button == Input.MOUSE_MIDDLE_BUTTON)
		return;

	if (isScrollingToFocusNode)
		return;

	songScrolling.setSpeedMultiplier(1f);
	songScrolling.released();
	startScorePos.released();
}
 
Example 7
Source File: DownloadsMenu.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mouseReleased(int button, int x, int y) {
	// check mouse button
	if (button == Input.MOUSE_MIDDLE_BUTTON)
		return;

	startDownloadIndexPos.released();
	startResultPos.released();
}
 
Example 8
Source File: ButtonMenu.java    From opsu with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void mousePressed(int button, int x, int y) {
	// check mouse button
	if (button == Input.MOUSE_MIDDLE_BUTTON)
		return;

	if (menuState != null)
		menuState.click(container, game, x, y);
}
 
Example 9
Source File: OptionsOverlay.java    From opsu with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void mousePressed(int button, int x, int y) {
	// key entry state
	if (keyEntryLeft || keyEntryRight) {
		keyEntryLeft = keyEntryRight = false;
		consumeEvent();
		return;
	}

	if (!active)
		return;

	if (!contains(x, y)) {
		if (consumeAndClose) {
			consumeEvent();
			listener.close();
		}
		return;
	}

	consumeEvent();

	if (button == Input.MOUSE_MIDDLE_BUTTON)
		return;

	// back button: close overlay
	if (backButton.contains(x, y)) {
		SoundController.playSound(SoundEffect.MENUCLICK);
		listener.close();
		return;
	}

	// restart button: restart game
	if (showRestartButton && restartButton.contains(x, y)) {
		container.setForceExit(false);
		container.exit();
		return;
	}

	scrolling.pressed();

	// clicked an option?
	mousePressY = y;
	if (x < (int) this.x + navWidth)
		return;
	hoverOption = selectedOption = getOptionAtPosition(x, y);
	if (hoverOption != null) {
		if (hoverOption.getType() == OptionType.NUMERIC) {
			isAdjustingSlider = sliderOptionStartX <= x && x < sliderOptionStartX + sliderOptionWidth;
			if (isAdjustingSlider) {
				SoundController.playSound(SoundEffect.MENUCLICK);
				updateSliderOption(x, y);
			}
		}
	}
}
 
Example 10
Source File: OptionsOverlay.java    From opsu with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void mouseReleased(int button, int x, int y) {
	if (!active)
		return;

	// check if associated mouse press was in the overlay
	if (mousePressY == -1)
		return;

	consumeEvent();

	if (button == Input.MOUSE_MIDDLE_BUTTON)
		return;

	// finish adjusting slider
	if (isAdjustingSlider) {
		isAdjustingSlider = false;
		adjustSlider(x, y);
	}

	// check if clicked, not dragged
	boolean mouseDragged = (Math.abs(y - mousePressY) >= 5);

	mousePressY = -1;
	selectedOption = null;
	sliderOptionWidth = 0;
	scrolling.released();

	if (mouseDragged)
		return;

	// update based on option type
	if (hoverOption != null) {
		if (hoverOption.getType() == OptionType.BOOLEAN) {
			SoundController.playSound(SoundEffect.MENUCLICK);
			boolean oldValue = hoverOption.getBooleanValue();
			hoverOption.toggle(container);

			// show restart button?
			if (oldValue != hoverOption.getBooleanValue() && hoverOption.isRestartRequired()) {
				showRestartButton = true;
				UI.getNotificationManager().sendBarNotification("Restart to apply changes.");
			}
		} else if (hoverOption.getItemList() != null) {
			SoundController.playSound(SoundEffect.MENUCLICK);
		} else if (hoverOption == GameOption.KEY_LEFT) {
			SoundController.playSound(SoundEffect.MENUCLICK);
			keyEntryLeft = true;
		} else if (hoverOption == GameOption.KEY_RIGHT) {
			SoundController.playSound(SoundEffect.MENUCLICK);
			keyEntryRight = true;
		}
	}

	if (hoveredNavigationGroup != null && hoveredNavigationGroup.isVisible()) {
		int sectionPosition = 0;
		for (OptionGroup group : groups) {
			if (group == hoveredNavigationGroup)
				break;
			if (!group.isVisible())
				continue;
			sectionPosition += optionGroupPadding;
			if (group.getOptions() == null)
				continue;
			for (GameOption option : group.getOptions()) {
				if (option.isVisible())
					sectionPosition += optionHeight;
			}
		}
		sectionPosition = Utils.clamp(sectionPosition, (int) scrolling.getMin(), (int) scrolling.getMax());
		scrolling.scrollToPosition(sectionPosition);
	}
}
 
Example 11
Source File: Game.java    From opsu with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void mousePressed(int button, int x, int y) {
	if (gameFinished)
		return;

	// watching replay
	if (isReplay || GameMod.AUTO.isActive()) {
		if (button == Input.MOUSE_MIDDLE_BUTTON)
			return;

		// skip button
		if (skipButton.contains(x, y))
			skipIntro();

		// playback speed button
		else if (playbackSpeed.getButton().contains(x, y)) {
			playbackSpeed = playbackSpeed.next();
			MusicController.setPitch(getCurrentPitch());
		}

		// replay seeking
		else if (Options.isReplaySeekingEnabled() && !GameMod.AUTO.isActive() && musicPositionBarContains(x, y)) {
			SoundController.mute(true);  // mute sounds while seeking
			float pos = (y - musicBarY) / musicBarHeight * beatmap.endTime;
			MusicController.setPosition((int) pos);
			lastTrackPosition = (int) pos;
			isSeeking = true;
		}
		return;
	}

	if (Options.isMouseDisabled())
		return;

	// mouse wheel: pause the game
	if (button == Input.MOUSE_MIDDLE_BUTTON && !Options.isMouseWheelDisabled()) {
		int trackPosition = MusicController.getPosition(true);
		if (pauseTime < 0 && breakTime <= 0 && trackPosition >= beatmap.objects[0].getTime()) {
			pausedMousePosition = new Vec2f(x, y);
			pausePulse = 0f;
		}
		if (MusicController.isPlaying() || isLeadIn())
			pauseTime = trackPosition;
		if (video != null)
			video.pause();
		game.enterState(Opsu.STATE_GAMEPAUSEMENU, new EmptyTransition(), new FadeInTransition());
		return;
	}

	// game keys
	int keys = ReplayFrame.KEY_NONE;
	if (button == Input.MOUSE_LEFT_BUTTON)
		keys = ReplayFrame.KEY_M1;
	else if (button == Input.MOUSE_RIGHT_BUTTON)
		keys = ReplayFrame.KEY_M2;
	if (keys != ReplayFrame.KEY_NONE)
		gameKeyPressed(keys, x, y, MusicController.getPosition(true));
}
 
Example 12
Source File: GameRanking.java    From opsu with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void mousePressed(int button, int x, int y) {
	// check mouse button
	if (button == Input.MOUSE_MIDDLE_BUTTON)
		return;

	// back to menu
	if (UI.getBackButton().contains(x, y)) {
		returnToSongMenu();
		return;
	}

	// replay
	Game gameState = (Game) game.getState(Opsu.STATE_GAME);
	boolean returnToGame = false;
	boolean replayButtonPressed = replayButton.contains(x, y);
	if (replayButtonPressed && !(data.isGameplay() && GameMod.AUTO.isActive())) {
		if (replay != null) {
			gameState.setReplay(replay);
			gameState.setPlayState((data.isGameplay()) ? Game.PlayState.REPLAY : Game.PlayState.FIRST_LOAD);
			returnToGame = true;
		} else
			UI.getNotificationManager().sendBarNotification("Replay file not found.");
	}

	// retry
	else if (data.isGameplay() &&
	         (!GameMod.AUTO.isActive() && retryButton.contains(x, y)) ||
	         (GameMod.AUTO.isActive() && replayButtonPressed)) {
		gameState.setReplay(null);
		gameState.setPlayState(Game.PlayState.RETRY);
		returnToGame = true;
	}

	if (returnToGame) {
		Beatmap beatmap = MusicController.getBeatmap();
		gameState.loadBeatmap(beatmap);
		SoundController.playSound(SoundEffect.MENUHIT);
		game.enterState(Opsu.STATE_GAME, new EasedFadeOutTransition(), new FadeInTransition());
		return;
	}

	// otherwise, finish the animation
	animationProgress.setTime(animationProgress.getDuration());
}