2015-01-21 05:56:10 +01:00
|
|
|
/*
|
|
|
|
* opsu! - an open-source osu! client
|
|
|
|
* Copyright (C) 2014, 2015 Jeffrey Han
|
|
|
|
*
|
|
|
|
* opsu! is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* opsu! is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with opsu!. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package itdelatrisu.opsu.states;
|
|
|
|
|
|
|
|
import itdelatrisu.opsu.GameImage;
|
|
|
|
import itdelatrisu.opsu.Opsu;
|
|
|
|
import itdelatrisu.opsu.Options;
|
|
|
|
import itdelatrisu.opsu.Options.GameOption;
|
|
|
|
import itdelatrisu.opsu.Utils;
|
2015-03-08 01:04:45 +01:00
|
|
|
import itdelatrisu.opsu.audio.MusicController;
|
2015-01-21 05:56:10 +01:00
|
|
|
import itdelatrisu.opsu.audio.SoundController;
|
|
|
|
import itdelatrisu.opsu.audio.SoundEffect;
|
2015-08-21 03:02:23 +02:00
|
|
|
import itdelatrisu.opsu.ui.Colors;
|
2015-08-21 03:40:07 +02:00
|
|
|
import itdelatrisu.opsu.ui.Fonts;
|
2015-05-29 07:55:57 +02:00
|
|
|
import itdelatrisu.opsu.ui.MenuButton;
|
|
|
|
import itdelatrisu.opsu.ui.UI;
|
2015-01-21 05:56:10 +01:00
|
|
|
|
2016-09-27 17:36:10 +02:00
|
|
|
import java.util.*;
|
2015-01-22 06:44:45 +01:00
|
|
|
|
2015-01-21 05:56:10 +01:00
|
|
|
import org.newdawn.slick.Color;
|
|
|
|
import org.newdawn.slick.GameContainer;
|
|
|
|
import org.newdawn.slick.Graphics;
|
|
|
|
import org.newdawn.slick.Image;
|
|
|
|
import org.newdawn.slick.Input;
|
|
|
|
import org.newdawn.slick.SlickException;
|
|
|
|
import org.newdawn.slick.state.BasicGameState;
|
|
|
|
import org.newdawn.slick.state.StateBasedGame;
|
|
|
|
import org.newdawn.slick.state.transition.FadeInTransition;
|
2015-11-19 23:47:46 +01:00
|
|
|
import org.newdawn.slick.state.transition.EmptyTransition;
|
2016-09-27 17:36:10 +02:00
|
|
|
import yugecin.opsudance.ui.ItemList;
|
2016-10-04 14:40:41 +02:00
|
|
|
import yugecin.opsudance.ui.RWM;
|
2015-01-21 05:56:10 +01:00
|
|
|
|
|
|
|
/**
|
2015-01-21 07:38:02 +01:00
|
|
|
* "Game Options" state.
|
2015-09-19 01:20:18 +02:00
|
|
|
* <p>
|
|
|
|
* Players are able to view and change various game settings in this state.
|
2015-01-21 05:56:10 +01:00
|
|
|
*/
|
|
|
|
public class OptionsMenu extends BasicGameState {
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Option tabs. */
|
2015-01-21 05:56:10 +01:00
|
|
|
private enum OptionTab {
|
|
|
|
DISPLAY ("Display", new GameOption[] {
|
|
|
|
GameOption.SCREEN_RESOLUTION,
|
2016-10-11 11:22:32 +02:00
|
|
|
GameOption.FULLSCREEN,
|
2016-10-11 11:40:16 +02:00
|
|
|
GameOption.ALLOW_LARGER_RESOLUTIONS,
|
2015-05-24 05:48:28 +02:00
|
|
|
GameOption.SKIN,
|
2015-01-21 05:56:10 +01:00
|
|
|
GameOption.TARGET_FPS,
|
|
|
|
GameOption.SHOW_FPS,
|
|
|
|
GameOption.SHOW_UNICODE,
|
|
|
|
GameOption.SCREENSHOT_FORMAT,
|
|
|
|
GameOption.DYNAMIC_BACKGROUND,
|
2015-06-11 19:42:57 +02:00
|
|
|
GameOption.LOAD_HD_IMAGES,
|
2015-06-08 21:02:28 +02:00
|
|
|
GameOption.LOAD_VERBOSE
|
2015-01-21 05:56:10 +01:00
|
|
|
}),
|
|
|
|
MUSIC ("Music", new GameOption[] {
|
|
|
|
GameOption.MASTER_VOLUME,
|
|
|
|
GameOption.MUSIC_VOLUME,
|
|
|
|
GameOption.EFFECT_VOLUME,
|
|
|
|
GameOption.HITSOUND_VOLUME,
|
2016-10-01 10:46:28 +02:00
|
|
|
GameOption.SAMPLE_VOLUME_OVERRIDE,
|
2015-01-21 05:56:10 +01:00
|
|
|
GameOption.MUSIC_OFFSET,
|
|
|
|
GameOption.DISABLE_SOUNDS,
|
|
|
|
GameOption.ENABLE_THEME_SONG
|
|
|
|
}),
|
|
|
|
GAMEPLAY ("Gameplay", new GameOption[] {
|
|
|
|
GameOption.BACKGROUND_DIM,
|
|
|
|
GameOption.FORCE_DEFAULT_PLAYFIELD,
|
|
|
|
GameOption.IGNORE_BEATMAP_SKINS,
|
2015-09-16 17:19:23 +02:00
|
|
|
GameOption.SNAKING_SLIDERS,
|
2016-10-15 00:09:52 +02:00
|
|
|
GameOption.FALLBACK_SLIDERS,
|
2015-01-21 05:56:10 +01:00
|
|
|
GameOption.SHOW_HIT_LIGHTING,
|
|
|
|
GameOption.SHOW_COMBO_BURSTS,
|
2015-02-20 21:08:16 +01:00
|
|
|
GameOption.SHOW_PERFECT_HIT,
|
2015-03-19 04:23:34 +01:00
|
|
|
GameOption.SHOW_FOLLOW_POINTS,
|
2016-11-13 04:17:28 +01:00
|
|
|
GameOption.SHOW_HIT_ERROR_BAR,
|
|
|
|
GameOption.MAP_START_DELAY,
|
|
|
|
GameOption.MAP_END_DELAY,
|
2016-11-17 00:12:44 +01:00
|
|
|
GameOption.EPILEPSY_WARNING,
|
2015-01-21 05:56:10 +01:00
|
|
|
}),
|
2015-03-03 04:12:57 +01:00
|
|
|
INPUT ("Input", new GameOption[] {
|
|
|
|
GameOption.KEY_LEFT,
|
|
|
|
GameOption.KEY_RIGHT,
|
|
|
|
GameOption.DISABLE_MOUSE_WHEEL,
|
2015-06-14 19:30:33 +02:00
|
|
|
GameOption.DISABLE_MOUSE_BUTTONS,
|
|
|
|
GameOption.CURSOR_SIZE,
|
2015-09-11 17:43:19 +02:00
|
|
|
GameOption.NEW_CURSOR,
|
|
|
|
GameOption.DISABLE_CURSOR
|
2015-03-03 04:12:57 +01:00
|
|
|
}),
|
2015-01-21 05:56:10 +01:00
|
|
|
CUSTOM ("Custom", new GameOption[] {
|
|
|
|
GameOption.FIXED_CS,
|
|
|
|
GameOption.FIXED_HP,
|
|
|
|
GameOption.FIXED_AR,
|
|
|
|
GameOption.FIXED_OD,
|
2015-07-03 05:16:14 +02:00
|
|
|
GameOption.CHECKPOINT,
|
2015-07-08 02:03:54 +02:00
|
|
|
GameOption.REPLAY_SEEKING,
|
2015-08-21 17:25:52 +02:00
|
|
|
GameOption.DISABLE_UPDATER,
|
|
|
|
GameOption.ENABLE_WATCH_SERVICE
|
2016-09-27 17:55:41 +02:00
|
|
|
}),
|
|
|
|
DANCE ("Dance", new GameOption[] {
|
2016-09-27 22:02:49 +02:00
|
|
|
GameOption.DANCE_MOVER,
|
2016-12-04 13:49:35 +01:00
|
|
|
GameOption.DANCE_QUAD_BEZ_AGRESSIVE,
|
2016-09-30 21:45:19 +02:00
|
|
|
GameOption.DANCE_MOVER_DIRECTION,
|
2016-11-12 15:41:20 +01:00
|
|
|
GameOption.DANCE_SLIDER_MOVER_TYPE,
|
2016-09-27 22:02:49 +02:00
|
|
|
GameOption.DANCE_SPINNER,
|
2016-10-01 13:44:34 +02:00
|
|
|
GameOption.DANCE_SPINNER_DELAY,
|
2016-09-27 22:02:49 +02:00
|
|
|
GameOption.DANCE_LAZY_SLIDERS,
|
|
|
|
GameOption.DANCE_CIRCLE_STREAMS,
|
|
|
|
GameOption.DANCE_ONLY_CIRCLE_STACKS,
|
2016-10-01 14:46:39 +02:00
|
|
|
GameOption.DANCE_CIRLCE_IN_SLOW_SLIDERS,
|
2016-10-01 14:51:09 +02:00
|
|
|
GameOption.DANCE_CIRLCE_IN_LAZY_SLIDERS,
|
2016-09-29 23:29:20 +02:00
|
|
|
GameOption.DANCE_MIRROR,
|
2016-09-30 23:11:43 +02:00
|
|
|
}),
|
|
|
|
DANCEDISP ("Dance display", new GameOption[] {
|
2016-09-29 23:34:11 +02:00
|
|
|
GameOption.DANCE_DRAW_APPROACH,
|
2016-09-30 19:05:53 +02:00
|
|
|
GameOption.DANCE_OBJECT_COLOR_OVERRIDE,
|
|
|
|
GameOption.DANCE_OBJECT_COLOR_OVERRIDE_MIRRORED,
|
2016-10-01 11:59:03 +02:00
|
|
|
GameOption.DANCE_RGB_OBJECT_INC,
|
2016-10-01 11:53:33 +02:00
|
|
|
GameOption.DANCE_CURSOR_COLOR_OVERRIDE,
|
|
|
|
GameOption.DANCE_CURSOR_MIRROR_COLOR_OVERRIDE,
|
2016-10-04 15:22:13 +02:00
|
|
|
GameOption.DANCE_CURSOR_ONLY_COLOR_TRAIL,
|
2016-10-01 11:59:03 +02:00
|
|
|
GameOption.DANCE_RGB_CURSOR_INC,
|
2016-10-01 12:14:39 +02:00
|
|
|
GameOption.DANCE_CURSOR_TRAIL_OVERRIDE,
|
2016-09-30 09:35:21 +02:00
|
|
|
GameOption.DANCE_REMOVE_BG,
|
2016-09-30 23:11:43 +02:00
|
|
|
GameOption.DANCE_HIDE_OBJECTS,
|
2016-09-30 12:06:36 +02:00
|
|
|
GameOption.DANCE_HIDE_UI,
|
2016-11-13 01:45:06 +01:00
|
|
|
GameOption.DANCE_ENABLE_SB,
|
2016-10-04 14:40:41 +02:00
|
|
|
GameOption.DANCE_HIDE_WATERMARK,
|
2016-09-27 22:33:14 +02:00
|
|
|
}),
|
|
|
|
PIPPI ("Pippi", new GameOption[] {
|
|
|
|
GameOption.PIPPI_ENABLE,
|
2016-11-20 22:50:49 +01:00
|
|
|
GameOption.PIPPI_RADIUS_PERCENT,
|
2016-09-27 22:33:14 +02:00
|
|
|
GameOption.PIPPI_ANGLE_INC_MUL,
|
|
|
|
GameOption.PIPPI_ANGLE_INC_MUL_SLIDER,
|
|
|
|
GameOption.PIPPI_SLIDER_FOLLOW_EXPAND,
|
|
|
|
GameOption.PIPPI_PREVENT_WOBBLY_STREAMS,
|
2015-01-21 05:56:10 +01:00
|
|
|
});
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Total number of tabs. */
|
|
|
|
public static final int SIZE = values().length;
|
2015-01-21 05:56:10 +01:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Array of OptionTab objects in reverse order. */
|
|
|
|
public static final OptionTab[] VALUES_REVERSED;
|
|
|
|
static {
|
|
|
|
VALUES_REVERSED = values();
|
|
|
|
Collections.reverse(Arrays.asList(VALUES_REVERSED));
|
2015-01-21 05:56:10 +01:00
|
|
|
}
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Enum values. */
|
|
|
|
private static OptionTab[] values = values();
|
|
|
|
|
|
|
|
/** Tab name. */
|
2015-08-21 04:11:55 +02:00
|
|
|
private final String name;
|
2015-01-21 05:56:10 +01:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Options array. */
|
2015-08-21 04:11:55 +02:00
|
|
|
public final GameOption[] options;
|
2015-01-21 05:56:10 +01:00
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Associated tab button. */
|
2015-01-21 05:56:10 +01:00
|
|
|
public MenuButton button;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
* @param name the tab name
|
|
|
|
* @param options the options to display under the tab
|
|
|
|
*/
|
|
|
|
OptionTab(String name, GameOption[] options) {
|
|
|
|
this.name = name;
|
|
|
|
this.options = options;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the tab name.
|
|
|
|
*/
|
|
|
|
public String getName() { return name; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the next tab.
|
|
|
|
*/
|
|
|
|
public OptionTab next() { return values[(this.ordinal() + 1) % values.length]; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the previous tab.
|
|
|
|
*/
|
|
|
|
public OptionTab prev() { return values[(this.ordinal() + (SIZE - 1)) % values.length]; }
|
|
|
|
}
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Current tab. */
|
2015-01-21 05:56:10 +01:00
|
|
|
private OptionTab currentTab;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Key entry states. */
|
2015-01-21 05:56:10 +01:00
|
|
|
private boolean keyEntryLeft = false, keyEntryRight = false;
|
|
|
|
|
2015-01-22 06:44:45 +01:00
|
|
|
/** Game option coordinate modifiers (for drawing). */
|
2015-01-21 05:56:10 +01:00
|
|
|
private int textY, offsetY;
|
|
|
|
|
|
|
|
// game-related variables
|
|
|
|
private GameContainer container;
|
|
|
|
private StateBasedGame game;
|
|
|
|
private Input input;
|
|
|
|
private Graphics g;
|
2015-08-21 04:11:55 +02:00
|
|
|
private final int state;
|
2016-11-12 23:34:45 +01:00
|
|
|
private GameOption selectedOption;
|
2015-01-21 05:56:10 +01:00
|
|
|
|
2016-09-27 17:36:10 +02:00
|
|
|
private final ItemList list;
|
2016-10-04 14:40:41 +02:00
|
|
|
private final RWM rwm;
|
2016-09-27 17:36:10 +02:00
|
|
|
|
2015-01-21 05:56:10 +01:00
|
|
|
public OptionsMenu(int state) {
|
|
|
|
this.state = state;
|
2016-09-27 17:36:10 +02:00
|
|
|
list = new ItemList();
|
2016-10-04 14:40:41 +02:00
|
|
|
rwm = new RWM();
|
2015-01-21 05:56:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void init(GameContainer container, StateBasedGame game)
|
|
|
|
throws SlickException {
|
2016-09-27 17:36:10 +02:00
|
|
|
list.init(container);
|
2016-10-04 14:40:41 +02:00
|
|
|
rwm.init(container);
|
2016-09-27 17:36:10 +02:00
|
|
|
|
2015-01-21 05:56:10 +01:00
|
|
|
this.container = container;
|
|
|
|
this.game = game;
|
|
|
|
this.input = container.getInput();
|
|
|
|
this.g = container.getGraphics();
|
|
|
|
|
|
|
|
int width = container.getWidth();
|
|
|
|
int height = container.getHeight();
|
|
|
|
|
|
|
|
// option tabs
|
|
|
|
Image tabImage = GameImage.MENU_TAB.getImage();
|
2016-09-30 09:29:24 +02:00
|
|
|
float tabX = width * 0.032f + (tabImage.getWidth() / 3);
|
2015-08-21 03:40:07 +02:00
|
|
|
float tabY = Fonts.XLARGE.getLineHeight() + Fonts.DEFAULT.getLineHeight() +
|
2015-05-16 23:46:23 +02:00
|
|
|
height * 0.015f - (tabImage.getHeight() / 2f);
|
2015-03-05 03:21:53 +01:00
|
|
|
int tabOffset = Math.min(tabImage.getWidth(), width / OptionTab.SIZE);
|
2015-01-21 05:56:10 +01:00
|
|
|
for (OptionTab tab : OptionTab.values())
|
|
|
|
tab.button = new MenuButton(tabImage, tabX + (tab.ordinal() * tabOffset), tabY);
|
2015-02-16 23:53:24 +01:00
|
|
|
|
|
|
|
// game option coordinate modifiers
|
|
|
|
textY = (int) (tabY + tabImage.getHeight());
|
2016-09-30 12:18:34 +02:00
|
|
|
//int backHeight = GameImage.MENU_BACK.getAnimation(1).getHeight();
|
|
|
|
//offsetY = (height - textY - (backHeight * 4 / 5)) / maxOptionsScreen;
|
|
|
|
offsetY = (int) ((Fonts.MEDIUM.getLineHeight() + Fonts.SMALL.getLineHeight()) * 1.1f);
|
2015-01-21 05:56:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
|
|
|
throws SlickException {
|
|
|
|
int width = container.getWidth();
|
|
|
|
int height = container.getHeight();
|
|
|
|
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
2015-08-08 19:04:15 +02:00
|
|
|
|
|
|
|
// background
|
|
|
|
GameImage.OPTIONS_BG.getImage().draw();
|
2015-01-21 05:56:10 +01:00
|
|
|
|
|
|
|
// title
|
2015-05-16 23:46:23 +02:00
|
|
|
float marginX = width * 0.015f, marginY = height * 0.01f;
|
2015-08-21 03:40:07 +02:00
|
|
|
Fonts.XLARGE.drawString(marginX, marginY, "Options", Color.white);
|
2016-09-30 09:29:24 +02:00
|
|
|
Fonts.DEFAULT.drawString(marginX + Fonts.XLARGE.getWidth("Options") * 1.2f, marginY + Fonts.XLARGE.getLineHeight() * 0.9f - Fonts.DEFAULT.getLineHeight(),
|
2015-05-16 23:46:23 +02:00
|
|
|
"Change the way opsu! behaves", Color.white);
|
|
|
|
|
2015-01-21 05:56:10 +01:00
|
|
|
// game options
|
|
|
|
g.setLineWidth(1f);
|
2015-02-19 08:43:26 +01:00
|
|
|
GameOption hoverOption = (keyEntryLeft) ? GameOption.KEY_LEFT :
|
|
|
|
(keyEntryRight) ? GameOption.KEY_RIGHT :
|
|
|
|
getOptionAt(mouseY);
|
2016-11-12 23:34:45 +01:00
|
|
|
if (selectedOption != null) {
|
|
|
|
hoverOption = selectedOption;
|
|
|
|
}
|
2016-12-04 13:49:35 +01:00
|
|
|
for (int i = 0, j = 0; i < currentTab.options.length; i++) {
|
2015-02-19 08:43:26 +01:00
|
|
|
GameOption option = currentTab.options[i];
|
2016-12-04 13:49:35 +01:00
|
|
|
if (!option.showCondition()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
drawOption(option, j++, hoverOption == option);
|
2015-02-19 08:43:26 +01:00
|
|
|
}
|
2015-01-21 05:56:10 +01:00
|
|
|
|
|
|
|
// option tabs
|
|
|
|
OptionTab hoverTab = null;
|
|
|
|
for (OptionTab tab : OptionTab.values()) {
|
|
|
|
if (tab.button.contains(mouseX, mouseY)) {
|
|
|
|
hoverTab = tab;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-01-22 06:44:45 +01:00
|
|
|
for (OptionTab tab : OptionTab.VALUES_REVERSED) {
|
2015-01-21 05:56:10 +01:00
|
|
|
if (tab != currentTab)
|
2015-03-05 19:27:45 +01:00
|
|
|
UI.drawTab(tab.button.getX(), tab.button.getY(),
|
2016-09-27 17:36:10 +02:00
|
|
|
tab.getName(), false, tab == hoverTab && !list.isVisible());
|
2015-01-21 05:56:10 +01:00
|
|
|
}
|
2015-03-05 19:27:45 +01:00
|
|
|
UI.drawTab(currentTab.button.getX(), currentTab.button.getY(),
|
2015-01-21 05:56:10 +01:00
|
|
|
currentTab.getName(), true, false);
|
|
|
|
g.setColor(Color.white);
|
|
|
|
g.setLineWidth(2f);
|
2015-08-08 19:04:15 +02:00
|
|
|
float lineY = OptionTab.DISPLAY.button.getY() + (GameImage.MENU_TAB.getImage().getHeight() / 2f);
|
2015-01-21 05:56:10 +01:00
|
|
|
g.drawLine(0, lineY, width, lineY);
|
|
|
|
g.resetLineWidth();
|
|
|
|
|
2016-09-27 17:36:10 +02:00
|
|
|
if (list.isVisible()) {
|
|
|
|
list.render(container, game, g);
|
|
|
|
}
|
2016-10-04 14:40:41 +02:00
|
|
|
if (rwm.isVisible()) {
|
|
|
|
rwm.render(container, game, g);
|
|
|
|
}
|
2016-09-27 17:36:10 +02:00
|
|
|
|
2015-03-05 19:27:45 +01:00
|
|
|
UI.getBackButton().draw();
|
2015-01-21 05:56:10 +01:00
|
|
|
|
|
|
|
// key entry state
|
|
|
|
if (keyEntryLeft || keyEntryRight) {
|
2015-08-21 03:02:23 +02:00
|
|
|
g.setColor(Colors.BLACK_ALPHA);
|
2015-01-21 05:56:10 +01:00
|
|
|
g.fillRect(0, 0, width, height);
|
|
|
|
g.setColor(Color.white);
|
2015-03-07 20:24:26 +01:00
|
|
|
String prompt = (keyEntryLeft) ?
|
|
|
|
"Please press the new left-click key." :
|
|
|
|
"Please press the new right-click key.";
|
2015-08-21 03:40:07 +02:00
|
|
|
Fonts.LARGE.drawString(
|
|
|
|
(width / 2) - (Fonts.LARGE.getWidth(prompt) / 2),
|
|
|
|
(height / 2) - Fonts.LARGE.getLineHeight(), prompt
|
2015-01-21 05:56:10 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-03-05 19:27:45 +01:00
|
|
|
UI.draw(g);
|
2015-01-21 05:56:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void update(GameContainer container, StateBasedGame game, int delta)
|
|
|
|
throws SlickException {
|
2016-10-04 14:40:41 +02:00
|
|
|
rwm.update(delta);
|
2015-03-05 19:27:45 +01:00
|
|
|
UI.update(delta);
|
2015-03-08 01:04:45 +01:00
|
|
|
MusicController.loopTrackIfEnded(false);
|
2015-01-21 05:56:10 +01:00
|
|
|
int mouseX = input.getMouseX(), mouseY = input.getMouseY();
|
2015-03-05 19:27:45 +01:00
|
|
|
UI.getBackButton().hoverUpdate(delta, mouseX, mouseY);
|
2015-01-21 05:56:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getID() { return state; }
|
|
|
|
|
2016-09-27 17:36:10 +02:00
|
|
|
@Override
|
|
|
|
public void mouseReleased(int button, int x, int y) {
|
2016-11-12 23:34:45 +01:00
|
|
|
selectedOption = null;
|
2016-09-27 17:36:10 +02:00
|
|
|
if (list.isVisible()) {
|
|
|
|
list.mouseReleased(button, x, y);
|
|
|
|
}
|
2016-10-04 14:40:41 +02:00
|
|
|
if (rwm.isVisible()) {
|
|
|
|
rwm.mouseReleased(button, x, y);
|
|
|
|
}
|
2016-09-27 17:36:10 +02:00
|
|
|
}
|
|
|
|
|
2015-01-21 05:56:10 +01:00
|
|
|
@Override
|
|
|
|
public void mousePressed(int button, int x, int y) {
|
2016-09-27 17:36:10 +02:00
|
|
|
if (list.isVisible()) {
|
|
|
|
list.mousePressed(button, x, y);
|
|
|
|
return;
|
|
|
|
}
|
2016-10-04 14:40:41 +02:00
|
|
|
if (rwm.isVisible()) {
|
|
|
|
return;
|
|
|
|
}
|
2016-09-27 17:36:10 +02:00
|
|
|
|
2015-01-21 05:56:10 +01:00
|
|
|
// key entry state
|
|
|
|
if (keyEntryLeft || keyEntryRight) {
|
|
|
|
keyEntryLeft = keyEntryRight = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check mouse button
|
|
|
|
if (button == Input.MOUSE_MIDDLE_BUTTON)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// back
|
2015-03-05 19:27:45 +01:00
|
|
|
if (UI.getBackButton().contains(x, y)) {
|
2015-01-21 05:56:10 +01:00
|
|
|
SoundController.playSound(SoundEffect.MENUBACK);
|
2015-11-19 23:47:46 +01:00
|
|
|
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
|
2015-01-21 05:56:10 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// option tabs
|
|
|
|
for (OptionTab tab : OptionTab.values()) {
|
|
|
|
if (tab.button.contains(x, y)) {
|
|
|
|
if (tab != currentTab) {
|
|
|
|
currentTab = tab;
|
|
|
|
SoundController.playSound(SoundEffect.MENUCLICK);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// options (click only)
|
2016-09-27 17:36:10 +02:00
|
|
|
final GameOption option = getOptionAt(y);
|
|
|
|
if (option != null) {
|
2016-11-12 23:34:45 +01:00
|
|
|
selectedOption = option;
|
2016-09-27 17:36:10 +02:00
|
|
|
Object[] listItems = option.getListItems();
|
|
|
|
if (listItems == null) {
|
2016-10-04 14:40:41 +02:00
|
|
|
if (option.showRWM()) {
|
|
|
|
rwm.show();
|
|
|
|
} else {
|
|
|
|
option.click(container);
|
|
|
|
}
|
2016-09-27 17:36:10 +02:00
|
|
|
} else {
|
|
|
|
list.setItems(listItems);
|
|
|
|
list.setClickListener(new Observer() {
|
|
|
|
@Override
|
|
|
|
public void update(Observable o, Object arg) {
|
|
|
|
option.clickListItem((int) arg);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
list.show();
|
|
|
|
}
|
|
|
|
}
|
2015-01-21 05:56:10 +01:00
|
|
|
|
|
|
|
// special key entry states
|
|
|
|
if (option == GameOption.KEY_LEFT) {
|
|
|
|
keyEntryLeft = true;
|
|
|
|
keyEntryRight = false;
|
|
|
|
} else if (option == GameOption.KEY_RIGHT) {
|
|
|
|
keyEntryLeft = false;
|
|
|
|
keyEntryRight = true;
|
|
|
|
}
|
2016-11-20 23:19:13 +01:00
|
|
|
|
|
|
|
// ctrl+click to reset slider options
|
|
|
|
if (selectedOption != null && selectedOption.isDragOption() && (input.isKeyDown(Input.KEY_LCONTROL) || input.isKeyDown(Input.KEY_RCONTROL))) {
|
|
|
|
selectedOption.setValue(selectedOption.getDefaultVal() - 1);
|
|
|
|
// trigger update
|
|
|
|
selectedOption.drag(container, 1);
|
|
|
|
}
|
2015-01-21 05:56:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
|
2016-09-27 17:36:10 +02:00
|
|
|
if (list.isVisible()) {
|
|
|
|
list.mouseDragged(oldx, oldy, newx, newy);
|
|
|
|
return;
|
|
|
|
}
|
2016-10-04 14:40:41 +02:00
|
|
|
if (rwm.isVisible()) {
|
|
|
|
return;
|
|
|
|
}
|
2016-09-27 17:36:10 +02:00
|
|
|
|
2015-01-21 05:56:10 +01:00
|
|
|
// key entry state
|
|
|
|
if (keyEntryLeft || keyEntryRight)
|
|
|
|
return;
|
|
|
|
|
2016-11-20 23:19:13 +01:00
|
|
|
if (selectedOption == null || !selectedOption.isDragOption()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check control keys (reset to default value on ctrl+click)
|
|
|
|
if (input.isKeyDown(Input.KEY_LCONTROL) || input.isKeyDown(Input.KEY_RCONTROL)) {
|
|
|
|
selectedOption.setValue(selectedOption.getDefaultVal() - 1);
|
|
|
|
// trigger update
|
|
|
|
selectedOption.drag(container, 1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-21 05:56:10 +01:00
|
|
|
// check mouse button (right click scrolls faster)
|
|
|
|
int multiplier;
|
|
|
|
if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON))
|
|
|
|
multiplier = 4;
|
|
|
|
else if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON))
|
|
|
|
multiplier = 1;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
// get direction
|
|
|
|
int diff = newx - oldx;
|
|
|
|
if (diff == 0)
|
|
|
|
return;
|
|
|
|
diff = ((diff > 0) ? 1 : -1) * multiplier;
|
|
|
|
|
|
|
|
// options (drag only)
|
2016-11-20 23:19:13 +01:00
|
|
|
selectedOption.drag(container, diff);
|
2015-01-21 05:56:10 +01:00
|
|
|
}
|
|
|
|
|
2015-03-27 01:45:33 +01:00
|
|
|
@Override
|
|
|
|
public void mouseWheelMoved(int newValue) {
|
2016-09-27 17:36:10 +02:00
|
|
|
if (list.isVisible()) {
|
|
|
|
list.mouseWheelMoved(newValue);
|
|
|
|
}
|
2015-03-27 01:45:33 +01:00
|
|
|
if (input.isKeyDown(Input.KEY_LALT) || input.isKeyDown(Input.KEY_RALT))
|
|
|
|
UI.changeVolume((newValue < 0) ? -1 : 1);
|
|
|
|
}
|
|
|
|
|
2015-01-21 05:56:10 +01:00
|
|
|
@Override
|
|
|
|
public void keyPressed(int key, char c) {
|
2016-09-27 17:36:10 +02:00
|
|
|
if (list.isVisible()) {
|
|
|
|
list.keyPressed(key, c);
|
|
|
|
return;
|
|
|
|
}
|
2016-10-04 14:40:41 +02:00
|
|
|
if (rwm.isVisible()) {
|
|
|
|
rwm.keyPressed(key, c);
|
|
|
|
return;
|
|
|
|
}
|
2016-09-27 17:36:10 +02:00
|
|
|
|
2015-01-21 05:56:10 +01:00
|
|
|
// key entry state
|
|
|
|
if (keyEntryLeft || keyEntryRight) {
|
2015-03-07 05:49:59 +01:00
|
|
|
if (keyEntryLeft)
|
2015-03-07 05:30:48 +01:00
|
|
|
Options.setGameKeyLeft(key);
|
2015-03-07 05:49:59 +01:00
|
|
|
else
|
2015-03-07 05:30:48 +01:00
|
|
|
Options.setGameKeyRight(key);
|
2015-01-21 05:56:10 +01:00
|
|
|
keyEntryLeft = keyEntryRight = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (key) {
|
|
|
|
case Input.KEY_ESCAPE:
|
|
|
|
SoundController.playSound(SoundEffect.MENUBACK);
|
2015-11-19 23:47:46 +01:00
|
|
|
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition());
|
2015-01-21 05:56:10 +01:00
|
|
|
break;
|
|
|
|
case Input.KEY_F5:
|
|
|
|
// restart application
|
|
|
|
if ((input.isKeyDown(Input.KEY_RCONTROL) || input.isKeyDown(Input.KEY_LCONTROL)) &&
|
|
|
|
(input.isKeyDown(Input.KEY_RSHIFT) || input.isKeyDown(Input.KEY_LSHIFT))) {
|
|
|
|
container.setForceExit(false);
|
|
|
|
container.exit();
|
|
|
|
}
|
|
|
|
break;
|
2015-03-05 20:40:57 +01:00
|
|
|
case Input.KEY_F7:
|
|
|
|
Options.setNextFPS(container);
|
|
|
|
break;
|
|
|
|
case Input.KEY_F10:
|
|
|
|
Options.toggleMouseDisabled();
|
|
|
|
break;
|
2015-01-21 05:56:10 +01:00
|
|
|
case Input.KEY_F12:
|
|
|
|
Utils.takeScreenShot();
|
|
|
|
break;
|
|
|
|
case Input.KEY_TAB:
|
|
|
|
// change tabs
|
|
|
|
if (input.isKeyDown(Input.KEY_LSHIFT) || input.isKeyDown(Input.KEY_RSHIFT))
|
|
|
|
currentTab = currentTab.prev();
|
|
|
|
else
|
|
|
|
currentTab = currentTab.next();
|
|
|
|
SoundController.playSound(SoundEffect.MENUCLICK);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-20 13:24:37 +01:00
|
|
|
/**
|
|
|
|
* This string is built with option values when entering the options menu.
|
|
|
|
* When leaving the options menu, this string is checked against the new optionstring with the same options.
|
|
|
|
* If those do not match, it means some option has change which requires a restart
|
|
|
|
*/
|
|
|
|
private String restartOptions;
|
2016-10-11 11:47:46 +02:00
|
|
|
|
2015-01-21 05:56:10 +01:00
|
|
|
@Override
|
|
|
|
public void enter(GameContainer container, StateBasedGame game)
|
|
|
|
throws SlickException {
|
2015-03-05 19:27:45 +01:00
|
|
|
UI.enter();
|
2016-09-30 23:57:43 +02:00
|
|
|
currentTab = OptionTab.DANCE;
|
2016-11-20 13:24:37 +01:00
|
|
|
restartOptions = "" + Options.getResolutionIdx() + Options.isFullscreen() + Options.allowLargeResolutions() + Options.getSkinName();
|
2016-10-11 11:47:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void leave(GameContainer container, StateBasedGame game) throws SlickException {
|
2016-11-20 13:24:37 +01:00
|
|
|
if (!("" + Options.getResolutionIdx() + Options.isFullscreen() + Options.allowLargeResolutions() + Options.getSkinName()).equals(restartOptions)) {
|
2016-10-11 11:47:46 +02:00
|
|
|
container.setForceExit(false);
|
|
|
|
container.exit();
|
|
|
|
}
|
2015-01-21 05:56:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws a game option.
|
|
|
|
* @param option the option
|
|
|
|
* @param pos the position to draw at
|
2015-02-19 08:43:26 +01:00
|
|
|
* @param focus whether the option is currently focused
|
2015-01-21 05:56:10 +01:00
|
|
|
*/
|
2015-02-19 08:43:26 +01:00
|
|
|
private void drawOption(GameOption option, int pos, boolean focus) {
|
2015-01-21 05:56:10 +01:00
|
|
|
int width = container.getWidth();
|
2016-09-30 12:18:34 +02:00
|
|
|
int textHeight = Fonts.MEDIUM.getLineHeight();
|
2015-01-21 05:56:10 +01:00
|
|
|
float y = textY + (pos * offsetY);
|
2015-02-19 08:43:26 +01:00
|
|
|
Color color = (focus) ? Color.cyan : Color.white;
|
2015-01-21 05:56:10 +01:00
|
|
|
|
2016-09-30 12:18:34 +02:00
|
|
|
Fonts.MEDIUM.drawString(width / 30, y, option.getName(), color);
|
2015-08-21 03:40:07 +02:00
|
|
|
Fonts.SMALL.drawString(width / 30, y + textHeight, option.getDescription(), color);
|
2016-11-20 23:06:47 +01:00
|
|
|
Fonts.MEDIUM.drawString(width / 2, y, option.getValueString(), color);
|
2015-08-21 03:02:23 +02:00
|
|
|
g.setColor(Colors.WHITE_ALPHA);
|
2016-11-20 23:06:47 +01:00
|
|
|
if (option.isDragOption()) {
|
|
|
|
float availableWidth = width / 2 - width / 30;
|
|
|
|
g.fillRect(width / 2, y + textHeight, 20, 10);
|
|
|
|
g.fillRect(width / 2 + availableWidth - 20, y + textHeight, 20, 10);
|
|
|
|
availableWidth -= 40 + 100;
|
|
|
|
float optionPercent = (float) (option.getIntegerValue() - option.getMinValue()) / (option.getMaxValue() - option.getMinValue());
|
|
|
|
g.fillRect(width / 2 + 20 + optionPercent * availableWidth, y + textHeight, 100, 10);
|
|
|
|
}
|
2015-01-21 05:56:10 +01:00
|
|
|
g.drawLine(0, y + textHeight, width, y + textHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-02-19 08:43:26 +01:00
|
|
|
* Returns the option at the given y coordinate.
|
2015-01-21 05:56:10 +01:00
|
|
|
* @param y the y coordinate
|
2015-02-19 08:43:26 +01:00
|
|
|
* @return the option, or GameOption.NULL if no such option exists
|
2015-01-21 05:56:10 +01:00
|
|
|
*/
|
2015-02-19 08:43:26 +01:00
|
|
|
private GameOption getOptionAt(int y) {
|
2016-09-30 12:23:10 +02:00
|
|
|
if (y < textY)
|
2015-06-12 22:04:20 +02:00
|
|
|
return null;
|
2015-01-21 05:56:10 +01:00
|
|
|
|
2016-09-30 12:18:34 +02:00
|
|
|
int index = (y - textY) / offsetY;
|
2015-06-12 22:04:20 +02:00
|
|
|
if (index >= currentTab.options.length)
|
|
|
|
return null;
|
|
|
|
|
2016-12-04 13:49:35 +01:00
|
|
|
int i = index;
|
|
|
|
while (i >= 0) {
|
|
|
|
if (!currentTab.options[i--].showCondition()) {
|
|
|
|
if (++index >= currentTab.options.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-12 22:04:20 +02:00
|
|
|
return currentTab.options[index];
|
2015-01-21 05:56:10 +01:00
|
|
|
}
|
|
|
|
}
|