2014-06-30 04:17:04 +02:00
|
|
|
/*
|
|
|
|
* opsu! - an open-source osu! client
|
|
|
|
* Copyright (C) 2014 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.GUIMenuButton;
|
2014-07-16 22:01:36 +02:00
|
|
|
import itdelatrisu.opsu.GameMod;
|
2014-06-30 04:17:04 +02:00
|
|
|
import itdelatrisu.opsu.Opsu;
|
2014-07-03 00:24:19 +02:00
|
|
|
import itdelatrisu.opsu.SoundController;
|
2014-07-02 01:32:03 +02:00
|
|
|
import itdelatrisu.opsu.Utils;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.BufferedWriter;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
import java.io.FileReader;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.OutputStreamWriter;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.Date;
|
2014-07-19 09:31:54 +02:00
|
|
|
import java.util.Locale;
|
2014-07-09 04:17:48 +02:00
|
|
|
import java.util.concurrent.TimeUnit;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2014-07-18 05:58:37 +02:00
|
|
|
import org.lwjgl.input.Keyboard;
|
2014-07-11 02:35:07 +02:00
|
|
|
import org.newdawn.slick.AppGameContainer;
|
2014-06-30 04:17:04 +02: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.EmptyTransition;
|
|
|
|
import org.newdawn.slick.state.transition.FadeInTransition;
|
|
|
|
import org.newdawn.slick.util.Log;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* "Game Options" state.
|
|
|
|
*/
|
|
|
|
public class Options extends BasicGameState {
|
|
|
|
/**
|
|
|
|
* Temporary folder for file conversions, auto-deleted upon successful exit.
|
|
|
|
*/
|
2014-07-02 07:53:42 +02:00
|
|
|
public static final File TMP_DIR = new File(".opsu_tmp/");
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
|
|
|
* File for logging errors.
|
|
|
|
*/
|
|
|
|
public static final File LOG_FILE = new File(".opsu.log");
|
|
|
|
|
2014-07-02 07:53:42 +02:00
|
|
|
/**
|
|
|
|
* File for storing user options.
|
|
|
|
*/
|
|
|
|
private static final File OPTIONS_FILE = new File(".opsu.cfg");
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
|
|
|
* Beatmap directories (where to search for files).
|
|
|
|
*/
|
|
|
|
private static final String[] BEATMAP_DIRS = {
|
|
|
|
"C:/Program Files (x86)/osu!/Songs/",
|
|
|
|
"C:/Program Files/osu!/Songs/",
|
2014-07-02 07:53:42 +02:00
|
|
|
"Songs/"
|
2014-06-30 04:17:04 +02:00
|
|
|
};
|
|
|
|
|
2014-08-25 18:47:10 +02:00
|
|
|
/**
|
|
|
|
* Font file name.
|
|
|
|
*/
|
|
|
|
public static final String FONT_NAME = "kochi-gothic.ttf";
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
2014-07-06 07:58:44 +02:00
|
|
|
* The beatmap directory.
|
2014-06-30 04:17:04 +02:00
|
|
|
*/
|
|
|
|
private static File beatmapDir;
|
|
|
|
|
2014-07-06 07:58:44 +02:00
|
|
|
/**
|
|
|
|
* The OSZ archive directory.
|
|
|
|
*/
|
|
|
|
private static File oszDir;
|
|
|
|
|
2014-07-18 06:56:37 +02:00
|
|
|
/**
|
|
|
|
* The screenshot directory (created when needed).
|
|
|
|
*/
|
|
|
|
private static File screenshotDir;
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
2014-07-02 07:53:42 +02:00
|
|
|
* The current skin directory (for user skins).
|
2014-06-30 04:17:04 +02:00
|
|
|
*/
|
2014-07-02 07:53:42 +02:00
|
|
|
private static File skinDir;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
/**
|
2014-07-03 00:24:19 +02:00
|
|
|
* Game options.
|
|
|
|
*/
|
2014-07-09 19:36:42 +02:00
|
|
|
private static enum GameOption {
|
2014-07-03 00:24:19 +02:00
|
|
|
NULL,
|
|
|
|
SCREEN_RESOLUTION,
|
|
|
|
// FULLSCREEN,
|
|
|
|
TARGET_FPS,
|
|
|
|
MUSIC_VOLUME,
|
|
|
|
EFFECT_VOLUME,
|
|
|
|
HITSOUND_VOLUME,
|
|
|
|
MUSIC_OFFSET,
|
|
|
|
SCREENSHOT_FORMAT,
|
|
|
|
SHOW_FPS,
|
|
|
|
SHOW_HIT_LIGHTING,
|
|
|
|
SHOW_COMBO_BURSTS,
|
|
|
|
NEW_CURSOR,
|
|
|
|
DYNAMIC_BACKGROUND,
|
|
|
|
SHOW_PERFECT_HIT,
|
2014-07-03 07:05:23 +02:00
|
|
|
BACKGROUND_DIM,
|
2014-07-04 22:41:52 +02:00
|
|
|
FORCE_DEFAULT_PLAYFIELD,
|
2014-07-05 07:24:01 +02:00
|
|
|
IGNORE_BEATMAP_SKINS,
|
|
|
|
FIXED_CS,
|
|
|
|
FIXED_HP,
|
|
|
|
FIXED_AR,
|
2014-07-06 03:00:52 +02:00
|
|
|
FIXED_OD,
|
2014-07-09 04:17:48 +02:00
|
|
|
LOAD_VERBOSE,
|
2014-07-11 04:01:39 +02:00
|
|
|
CHECKPOINT,
|
2014-07-18 05:58:37 +02:00
|
|
|
DISABLE_SOUNDS,
|
|
|
|
KEY_LEFT,
|
2014-08-25 05:48:52 +02:00
|
|
|
KEY_RIGHT,
|
|
|
|
SHOW_UNICODE;
|
2014-07-03 00:24:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Option tab constants.
|
2014-06-30 04:17:04 +02:00
|
|
|
*/
|
|
|
|
private static final int
|
2014-07-03 00:24:19 +02:00
|
|
|
TAB_DISPLAY = 0,
|
|
|
|
TAB_MUSIC = 1,
|
|
|
|
TAB_GAMEPLAY = 2,
|
2014-07-05 07:24:01 +02:00
|
|
|
TAB_CUSTOM = 3,
|
|
|
|
TAB_MAX = 4; // not a tab
|
2014-07-03 00:24:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Option tab names.
|
|
|
|
*/
|
|
|
|
private static final String[] TAB_NAMES = {
|
|
|
|
"Display",
|
|
|
|
"Music",
|
2014-07-05 07:24:01 +02:00
|
|
|
"Gameplay",
|
|
|
|
"Custom"
|
2014-07-03 00:24:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Option tab buttons.
|
|
|
|
*/
|
2014-07-09 19:36:42 +02:00
|
|
|
private static GUIMenuButton[] optionTabs = new GUIMenuButton[TAB_MAX];
|
2014-07-03 00:24:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Current tab.
|
|
|
|
*/
|
|
|
|
private static int currentTab;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display options.
|
|
|
|
*/
|
|
|
|
private static final GameOption[] displayOptions = {
|
|
|
|
GameOption.SCREEN_RESOLUTION,
|
|
|
|
// GameOption.FULLSCREEN,
|
|
|
|
GameOption.TARGET_FPS,
|
|
|
|
GameOption.SHOW_FPS,
|
2014-08-25 05:48:52 +02:00
|
|
|
GameOption.SHOW_UNICODE,
|
2014-07-03 00:24:19 +02:00
|
|
|
GameOption.SCREENSHOT_FORMAT,
|
|
|
|
GameOption.NEW_CURSOR,
|
2014-07-06 03:00:52 +02:00
|
|
|
GameOption.DYNAMIC_BACKGROUND,
|
|
|
|
GameOption.LOAD_VERBOSE
|
2014-07-03 00:24:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Music options.
|
|
|
|
*/
|
|
|
|
private static final GameOption[] musicOptions = {
|
|
|
|
GameOption.MUSIC_VOLUME,
|
|
|
|
GameOption.EFFECT_VOLUME,
|
|
|
|
GameOption.HITSOUND_VOLUME,
|
2014-07-11 04:01:39 +02:00
|
|
|
GameOption.MUSIC_OFFSET,
|
|
|
|
GameOption.DISABLE_SOUNDS
|
2014-07-03 00:24:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gameplay options.
|
|
|
|
*/
|
|
|
|
private static final GameOption[] gameplayOptions = {
|
2014-07-18 05:58:37 +02:00
|
|
|
GameOption.KEY_LEFT,
|
|
|
|
GameOption.KEY_RIGHT,
|
2014-07-03 00:24:19 +02:00
|
|
|
GameOption.BACKGROUND_DIM,
|
2014-07-03 07:05:23 +02:00
|
|
|
GameOption.FORCE_DEFAULT_PLAYFIELD,
|
2014-07-04 22:41:52 +02:00
|
|
|
GameOption.IGNORE_BEATMAP_SKINS,
|
2014-07-03 00:24:19 +02:00
|
|
|
GameOption.SHOW_HIT_LIGHTING,
|
|
|
|
GameOption.SHOW_COMBO_BURSTS,
|
|
|
|
GameOption.SHOW_PERFECT_HIT
|
|
|
|
};
|
|
|
|
|
2014-07-05 07:24:01 +02:00
|
|
|
/**
|
|
|
|
* Custom options.
|
|
|
|
*/
|
|
|
|
private static final GameOption[] customOptions = {
|
|
|
|
GameOption.FIXED_CS,
|
|
|
|
GameOption.FIXED_HP,
|
|
|
|
GameOption.FIXED_AR,
|
2014-07-09 04:17:48 +02:00
|
|
|
GameOption.FIXED_OD,
|
|
|
|
GameOption.CHECKPOINT
|
2014-07-05 07:24:01 +02:00
|
|
|
};
|
|
|
|
|
2014-07-03 00:24:19 +02:00
|
|
|
/**
|
|
|
|
* Max number of options displayed on one screen.
|
|
|
|
*/
|
|
|
|
private static int maxOptionsScreen = Math.max(
|
|
|
|
Math.max(displayOptions.length, musicOptions.length),
|
2014-07-05 07:24:01 +02:00
|
|
|
Math.max(gameplayOptions.length, customOptions.length));
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Screen resolutions.
|
|
|
|
*/
|
|
|
|
private static final int[][] resolutions = {
|
|
|
|
{ 800, 600 },
|
|
|
|
{ 1024, 600 },
|
|
|
|
{ 1024, 768 },
|
|
|
|
{ 1280, 800 },
|
|
|
|
{ 1280, 960 },
|
|
|
|
{ 1366, 768 },
|
|
|
|
{ 1440, 900 },
|
2014-07-11 02:35:07 +02:00
|
|
|
{ 1600, 900 },
|
2014-06-30 04:17:04 +02:00
|
|
|
{ 1680, 1050 },
|
2014-07-11 02:35:07 +02:00
|
|
|
{ 1920, 1080 },
|
|
|
|
{ 1920, 1200 },
|
|
|
|
{ 2560, 1440 },
|
|
|
|
{ 2560, 1600 }
|
2014-06-30 04:17:04 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Index (row) in resolutions[][] array.
|
|
|
|
*/
|
|
|
|
private static int resolutionIndex = 3;
|
|
|
|
|
|
|
|
// /**
|
|
|
|
// * Whether or not the game should run in fullscreen mode.
|
|
|
|
// */
|
|
|
|
// private static boolean fullscreen = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Frame limiters.
|
|
|
|
*/
|
|
|
|
private static final int[] targetFPS = { 60, 120, 240 };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Index in targetFPS[] array.
|
|
|
|
*/
|
|
|
|
private static int targetFPSindex = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not to show the FPS.
|
|
|
|
*/
|
|
|
|
private static boolean showFPS = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not to show hit lighting effects.
|
|
|
|
*/
|
|
|
|
private static boolean showHitLighting = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether or not to show combo burst images.
|
|
|
|
*/
|
|
|
|
private static boolean showComboBursts = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default music volume.
|
|
|
|
*/
|
2014-07-01 07:14:03 +02:00
|
|
|
private static int musicVolume = 30;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default sound effect volume.
|
|
|
|
*/
|
|
|
|
private static int effectVolume = 20;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2014-07-03 00:24:19 +02:00
|
|
|
/**
|
|
|
|
* Default hit sound volume.
|
|
|
|
*/
|
|
|
|
private static int hitSoundVolume = 20;
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
|
|
|
* Offset time, in milliseconds, for music position-related elements.
|
|
|
|
*/
|
|
|
|
private static int musicOffset = -150;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Screenshot file format.
|
|
|
|
*/
|
|
|
|
private static String[] screenshotFormat = { "png", "jpg", "bmp" };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Index in screenshotFormat[] array.
|
|
|
|
*/
|
|
|
|
private static int screenshotFormatIndex = 0;
|
|
|
|
|
2014-06-30 18:37:37 +02:00
|
|
|
/**
|
|
|
|
* Port binding.
|
|
|
|
*/
|
2014-07-02 01:32:03 +02:00
|
|
|
private static int port = 49250;
|
2014-06-30 18:37:37 +02:00
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
2014-07-02 01:32:03 +02:00
|
|
|
* Whether or not to use the new cursor type.
|
2014-06-30 04:17:04 +02:00
|
|
|
*/
|
2014-07-02 01:32:03 +02:00
|
|
|
private static boolean newCursor = true;
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2014-07-02 09:02:11 +02:00
|
|
|
/**
|
|
|
|
* Whether or not dynamic backgrounds are enabled.
|
|
|
|
*/
|
|
|
|
private static boolean dynamicBackground = true;
|
|
|
|
|
2014-07-03 00:24:19 +02:00
|
|
|
/**
|
|
|
|
* Whether or not to display perfect hit results.
|
|
|
|
*/
|
|
|
|
private static boolean showPerfectHit = true;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Percentage to dim background images during gameplay.
|
|
|
|
*/
|
|
|
|
private static int backgroundDim = 30;
|
|
|
|
|
2014-07-03 07:05:23 +02:00
|
|
|
/**
|
|
|
|
* Whether or not to always display the default playfield background.
|
|
|
|
*/
|
|
|
|
private static boolean forceDefaultPlayfield = false;
|
|
|
|
|
2014-07-04 22:41:52 +02:00
|
|
|
/**
|
|
|
|
* Whether or not to ignore resources in the beatmap folders.
|
|
|
|
*/
|
|
|
|
private static boolean ignoreBeatmapSkins = false;
|
|
|
|
|
2014-07-05 07:24:01 +02:00
|
|
|
/**
|
|
|
|
* Fixed difficulty overrides.
|
|
|
|
*/
|
|
|
|
private static float
|
|
|
|
fixedCS = 0f, fixedHP = 0f,
|
|
|
|
fixedAR = 0f, fixedOD = 0f;
|
|
|
|
|
2014-07-06 03:00:52 +02:00
|
|
|
/**
|
2014-07-15 19:21:37 +02:00
|
|
|
* Whether or not to display the files being loaded in the splash screen.
|
2014-07-06 03:00:52 +02:00
|
|
|
*/
|
2014-07-15 19:21:37 +02:00
|
|
|
private static boolean loadVerbose = false;
|
2014-07-06 03:00:52 +02:00
|
|
|
|
2014-07-09 04:17:48 +02:00
|
|
|
/**
|
|
|
|
* Track checkpoint time, in seconds.
|
|
|
|
*/
|
|
|
|
private static int checkpoint = 0;
|
|
|
|
|
2014-07-11 04:01:39 +02:00
|
|
|
/**
|
|
|
|
* Whether or not to disable all sounds.
|
|
|
|
* This will prevent SoundController from loading sound files.
|
|
|
|
* <p>
|
|
|
|
* By default, sound is disabled on Linux due to possible driver issues.
|
|
|
|
*/
|
|
|
|
private static boolean disableSound =
|
2014-07-18 05:58:37 +02:00
|
|
|
(System.getProperty("os.name").toLowerCase().indexOf("linux") > -1);
|
|
|
|
|
2014-08-25 05:48:52 +02:00
|
|
|
/**
|
|
|
|
* Whether or not to display non-English metadata.
|
|
|
|
*/
|
|
|
|
private static boolean showUnicode = false;
|
|
|
|
|
2014-07-18 05:58:37 +02:00
|
|
|
/**
|
|
|
|
* Left and right game keys.
|
|
|
|
*/
|
|
|
|
private static int
|
|
|
|
keyLeft = Keyboard.KEY_NONE,
|
|
|
|
keyRight = Keyboard.KEY_NONE;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Key entry states.
|
|
|
|
*/
|
|
|
|
private boolean keyEntryLeft = false, keyEntryRight = false;
|
2014-07-11 04:01:39 +02:00
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
|
|
|
* Game option coordinate modifiers (for drawing).
|
|
|
|
*/
|
|
|
|
private int textY, offsetY;
|
|
|
|
|
|
|
|
// game-related variables
|
2014-07-02 01:32:03 +02:00
|
|
|
private GameContainer container;
|
|
|
|
private StateBasedGame game;
|
2014-06-30 04:17:04 +02:00
|
|
|
private Input input;
|
2014-07-03 00:24:19 +02:00
|
|
|
private Graphics g;
|
2014-06-30 04:17:04 +02:00
|
|
|
private int state;
|
|
|
|
|
|
|
|
public Options(int state) {
|
|
|
|
this.state = state;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void init(GameContainer container, StateBasedGame game)
|
|
|
|
throws SlickException {
|
2014-07-02 01:32:03 +02:00
|
|
|
this.container = container;
|
|
|
|
this.game = game;
|
2014-06-30 04:17:04 +02:00
|
|
|
this.input = container.getInput();
|
2014-07-03 00:24:19 +02:00
|
|
|
this.g = container.getGraphics();
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
int width = container.getWidth();
|
|
|
|
int height = container.getHeight();
|
|
|
|
|
|
|
|
// game option coordinate modifiers
|
2014-07-03 00:24:19 +02:00
|
|
|
textY = 20 + (Utils.FONT_XLARGE.getLineHeight() * 3 / 2);
|
|
|
|
offsetY = (int) (((height * 0.8f) - textY) / maxOptionsScreen);
|
|
|
|
|
|
|
|
// option tabs
|
|
|
|
Image tab = Utils.getTabImage();
|
2014-07-05 07:24:01 +02:00
|
|
|
int subtextWidth = Utils.FONT_DEFAULT.getWidth("Click or drag an option to change it.");
|
2014-07-03 00:24:19 +02:00
|
|
|
float tabX = (width / 50) + (tab.getWidth() / 2f);
|
2014-08-24 20:48:27 +02:00
|
|
|
float tabY = 15 + Utils.FONT_XLARGE.getLineHeight() + (tab.getHeight() / 2f);
|
2014-07-05 07:24:01 +02:00
|
|
|
float tabOffset = (float) Math.min(tab.getWidth(),
|
|
|
|
((width - subtextWidth - tab.getWidth()) / 2) / TAB_MAX);
|
2014-07-03 00:24:19 +02:00
|
|
|
for (int i = 0; i < optionTabs.length; i++)
|
|
|
|
optionTabs[i] = new GUIMenuButton(tab, tabX + (i * tabOffset), tabY);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
|
|
|
throws SlickException {
|
2014-07-02 01:32:03 +02:00
|
|
|
g.setBackground(Utils.COLOR_BLACK_ALPHA);
|
2014-06-30 04:17:04 +02:00
|
|
|
g.setColor(Color.white);
|
|
|
|
|
|
|
|
int width = container.getWidth();
|
|
|
|
int height = container.getHeight();
|
|
|
|
|
|
|
|
// title
|
2014-07-02 01:32:03 +02:00
|
|
|
Utils.FONT_XLARGE.drawString(
|
|
|
|
(width / 2) - (Utils.FONT_XLARGE.getWidth("GAME OPTIONS") / 2),
|
2014-06-30 04:17:04 +02:00
|
|
|
10, "GAME OPTIONS"
|
|
|
|
);
|
2014-07-02 01:32:03 +02:00
|
|
|
Utils.FONT_DEFAULT.drawString(
|
|
|
|
(width / 2) - (Utils.FONT_DEFAULT.getWidth("Click or drag an option to change it.") / 2),
|
2014-08-24 20:48:27 +02:00
|
|
|
10 + Utils.FONT_XLARGE.getLineHeight(), "Click or drag an option to change it."
|
2014-06-30 04:17:04 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// game options
|
|
|
|
g.setLineWidth(1f);
|
2014-07-02 01:32:03 +02:00
|
|
|
g.setFont(Utils.FONT_LARGE);
|
2014-07-03 00:24:19 +02:00
|
|
|
switch (currentTab) {
|
|
|
|
case TAB_DISPLAY:
|
|
|
|
for (int i = 0; i < displayOptions.length; i++)
|
|
|
|
drawOption(displayOptions[i], i);
|
|
|
|
break;
|
|
|
|
case TAB_MUSIC:
|
|
|
|
for (int i = 0; i < musicOptions.length; i++)
|
|
|
|
drawOption(musicOptions[i], i);
|
|
|
|
break;
|
|
|
|
case TAB_GAMEPLAY:
|
|
|
|
for (int i = 0; i < gameplayOptions.length; i++)
|
|
|
|
drawOption(gameplayOptions[i], i);
|
|
|
|
break;
|
2014-07-05 07:24:01 +02:00
|
|
|
case TAB_CUSTOM:
|
|
|
|
for (int i = 0; i < customOptions.length; i++)
|
|
|
|
drawOption(customOptions[i], i);
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// option tabs
|
|
|
|
g.setColor(Color.white);
|
|
|
|
Image tab = optionTabs[0].getImage();
|
|
|
|
float tabTextY = optionTabs[0].getY() - (tab.getHeight() / 2f);
|
|
|
|
for (int i = optionTabs.length - 1; i >= 0; i--) {
|
|
|
|
tab.setAlpha((i == currentTab) ? 1.0f : 0.7f);
|
|
|
|
optionTabs[i].draw();
|
|
|
|
float tabTextX = optionTabs[i].getX() - (Utils.FONT_MEDIUM.getWidth(TAB_NAMES[i]) / 2);
|
|
|
|
Utils.FONT_MEDIUM.drawString(tabTextX, tabTextY, TAB_NAMES[i], Color.white);
|
|
|
|
}
|
|
|
|
g.setLineWidth(2f);
|
|
|
|
float lineY = optionTabs[0].getY() + (tab.getHeight() / 2f);
|
|
|
|
g.drawLine(0, lineY, width, lineY);
|
|
|
|
g.resetLineWidth();
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
// game mods
|
2014-07-03 00:24:19 +02:00
|
|
|
Utils.FONT_LARGE.drawString(width / 30, height * 0.8f, "Game Mods:", Color.white);
|
2014-07-16 22:01:36 +02:00
|
|
|
for (GameMod mod : GameMod.values())
|
|
|
|
mod.draw();
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2014-07-02 01:32:03 +02:00
|
|
|
Utils.getBackButton().draw();
|
2014-06-30 04:17:04 +02:00
|
|
|
|
2014-07-18 05:58:37 +02:00
|
|
|
// key entry state
|
|
|
|
if (keyEntryLeft || keyEntryRight) {
|
|
|
|
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
|
|
|
g.fillRect(0, 0, width, height);
|
|
|
|
g.setColor(Color.white);
|
|
|
|
Utils.FONT_LARGE.drawString(
|
|
|
|
(width / 2) - (Utils.FONT_LARGE.getWidth("Please enter a letter or digit.") / 2),
|
2014-08-24 20:48:27 +02:00
|
|
|
(height / 2) - Utils.FONT_LARGE.getLineHeight(), "Please enter a letter or digit."
|
2014-07-18 05:58:37 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-07-02 01:32:03 +02:00
|
|
|
Utils.drawFPS();
|
|
|
|
Utils.drawCursor();
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void update(GameContainer container, StateBasedGame game, int delta)
|
|
|
|
throws SlickException {
|
2014-07-07 05:13:33 +02:00
|
|
|
Utils.updateCursor(delta);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getID() { return state; }
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void mousePressed(int button, int x, int y) {
|
2014-07-18 05:58:37 +02:00
|
|
|
// key entry state
|
|
|
|
if (keyEntryLeft || keyEntryRight) {
|
|
|
|
keyEntryLeft = keyEntryRight = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
// check mouse button
|
|
|
|
if (button == Input.MOUSE_MIDDLE_BUTTON)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// back
|
2014-07-02 01:32:03 +02:00
|
|
|
if (Utils.getBackButton().contains(x, y)) {
|
2014-07-03 00:24:19 +02:00
|
|
|
SoundController.playSound(SoundController.SOUND_MENUBACK);
|
2014-06-30 04:17:04 +02:00
|
|
|
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-03 00:24:19 +02:00
|
|
|
// option tabs
|
|
|
|
for (int i = 0; i < optionTabs.length; i++) {
|
|
|
|
if (optionTabs[i].contains(x, y)) {
|
|
|
|
if (i != currentTab) {
|
|
|
|
currentTab = i;
|
|
|
|
SoundController.playSound(SoundController.SOUND_MENUCLICK);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
// game mods
|
2014-07-16 22:01:36 +02:00
|
|
|
for (GameMod mod : GameMod.values()) {
|
|
|
|
if (mod.contains(x, y)) {
|
|
|
|
boolean prevState = mod.isActive();
|
|
|
|
mod.toggle(true);
|
|
|
|
if (mod.isActive() != prevState)
|
2014-07-03 00:24:19 +02:00
|
|
|
SoundController.playSound(SoundController.SOUND_MENUCLICK);
|
2014-06-30 04:17:04 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// options (click only)
|
2014-07-03 00:24:19 +02:00
|
|
|
switch (getClickedOption(y)) {
|
|
|
|
case SCREEN_RESOLUTION:
|
2014-07-11 02:35:07 +02:00
|
|
|
do {
|
|
|
|
resolutionIndex = (resolutionIndex + 1) % resolutions.length;
|
|
|
|
} while (resolutionIndex != 0 &&
|
|
|
|
(container.getScreenWidth() < resolutions[resolutionIndex][0] ||
|
|
|
|
container.getScreenHeight() < resolutions[resolutionIndex][1]));
|
2014-07-03 00:24:19 +02:00
|
|
|
break;
|
|
|
|
// case FULLSCREEN:
|
2014-06-30 04:17:04 +02:00
|
|
|
// fullscreen = !fullscreen;
|
2014-07-03 00:24:19 +02:00
|
|
|
// break;
|
|
|
|
case TARGET_FPS:
|
2014-06-30 04:17:04 +02:00
|
|
|
targetFPSindex = (targetFPSindex + 1) % targetFPS.length;
|
2014-07-02 01:32:03 +02:00
|
|
|
container.setTargetFrameRate(getTargetFPS());
|
2014-07-03 00:24:19 +02:00
|
|
|
break;
|
|
|
|
case SCREENSHOT_FORMAT:
|
2014-06-30 04:17:04 +02:00
|
|
|
screenshotFormatIndex = (screenshotFormatIndex + 1) % screenshotFormat.length;
|
2014-07-03 00:24:19 +02:00
|
|
|
break;
|
|
|
|
case SHOW_FPS:
|
2014-06-30 04:17:04 +02:00
|
|
|
showFPS = !showFPS;
|
2014-07-03 00:24:19 +02:00
|
|
|
break;
|
|
|
|
case SHOW_HIT_LIGHTING:
|
2014-06-30 04:17:04 +02:00
|
|
|
showHitLighting = !showHitLighting;
|
2014-07-03 00:24:19 +02:00
|
|
|
break;
|
|
|
|
case SHOW_COMBO_BURSTS:
|
2014-06-30 04:17:04 +02:00
|
|
|
showComboBursts = !showComboBursts;
|
2014-07-03 00:24:19 +02:00
|
|
|
break;
|
|
|
|
case NEW_CURSOR:
|
|
|
|
newCursor = !newCursor;
|
|
|
|
try {
|
|
|
|
Utils.loadCursor();
|
|
|
|
} catch (SlickException e) {
|
|
|
|
Log.error("Failed to load cursor.", e);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DYNAMIC_BACKGROUND:
|
|
|
|
dynamicBackground = !dynamicBackground;
|
|
|
|
break;
|
|
|
|
case SHOW_PERFECT_HIT:
|
|
|
|
showPerfectHit = !showPerfectHit;
|
|
|
|
break;
|
2014-07-03 07:05:23 +02:00
|
|
|
case FORCE_DEFAULT_PLAYFIELD:
|
|
|
|
forceDefaultPlayfield = !forceDefaultPlayfield;
|
|
|
|
break;
|
2014-07-04 22:41:52 +02:00
|
|
|
case IGNORE_BEATMAP_SKINS:
|
|
|
|
ignoreBeatmapSkins = !ignoreBeatmapSkins;
|
|
|
|
break;
|
2014-07-06 03:00:52 +02:00
|
|
|
case LOAD_VERBOSE:
|
|
|
|
loadVerbose = !loadVerbose;
|
|
|
|
break;
|
2014-07-11 04:01:39 +02:00
|
|
|
case DISABLE_SOUNDS:
|
|
|
|
disableSound = !disableSound;
|
|
|
|
break;
|
2014-07-18 05:58:37 +02:00
|
|
|
case KEY_LEFT:
|
|
|
|
keyEntryLeft = true;
|
|
|
|
keyEntryRight = false;
|
|
|
|
break;
|
|
|
|
case KEY_RIGHT:
|
|
|
|
keyEntryLeft = false;
|
|
|
|
keyEntryRight = true;
|
|
|
|
break;
|
2014-08-25 05:48:52 +02:00
|
|
|
case SHOW_UNICODE:
|
|
|
|
showUnicode = !showUnicode;
|
|
|
|
if (showUnicode) {
|
|
|
|
try {
|
|
|
|
Utils.FONT_LARGE.loadGlyphs();
|
|
|
|
Utils.FONT_MEDIUM.loadGlyphs();
|
|
|
|
Utils.FONT_DEFAULT.loadGlyphs();
|
|
|
|
} catch (SlickException e) {
|
|
|
|
Log.warn("Failed to load glyphs.", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
default:
|
|
|
|
break;
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
|
2014-07-18 05:58:37 +02:00
|
|
|
// key entry state
|
|
|
|
if (keyEntryLeft || keyEntryRight)
|
|
|
|
return;
|
|
|
|
|
2014-06-30 04:17:04 +02: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)
|
2014-07-03 00:24:19 +02:00
|
|
|
switch (getClickedOption(oldy)) {
|
|
|
|
case MUSIC_VOLUME:
|
2014-07-05 07:24:01 +02:00
|
|
|
musicVolume = getBoundedValue(musicVolume, diff, 0, 100);
|
2014-06-30 04:17:04 +02:00
|
|
|
container.setMusicVolume(getMusicVolume());
|
2014-07-03 00:24:19 +02:00
|
|
|
break;
|
|
|
|
case EFFECT_VOLUME:
|
2014-07-05 07:24:01 +02:00
|
|
|
effectVolume = getBoundedValue(effectVolume, diff, 0, 100);
|
2014-07-03 00:24:19 +02:00
|
|
|
break;
|
|
|
|
case HITSOUND_VOLUME:
|
2014-07-05 07:24:01 +02:00
|
|
|
hitSoundVolume = getBoundedValue(hitSoundVolume, diff, 0, 100);
|
2014-07-03 00:24:19 +02:00
|
|
|
break;
|
|
|
|
case MUSIC_OFFSET:
|
2014-07-05 07:24:01 +02:00
|
|
|
musicOffset = getBoundedValue(musicOffset, diff, -500, 500);
|
2014-07-03 00:24:19 +02:00
|
|
|
break;
|
|
|
|
case BACKGROUND_DIM:
|
2014-07-05 07:24:01 +02:00
|
|
|
backgroundDim = getBoundedValue(backgroundDim, diff, 0, 100);
|
|
|
|
break;
|
|
|
|
case FIXED_CS:
|
|
|
|
fixedCS = getBoundedValue(fixedCS, diff / 10f, 0f, 10f);
|
|
|
|
break;
|
|
|
|
case FIXED_HP:
|
|
|
|
fixedHP = getBoundedValue(fixedHP, diff / 10f, 0f, 10f);
|
|
|
|
break;
|
|
|
|
case FIXED_AR:
|
|
|
|
fixedAR = getBoundedValue(fixedAR, diff / 10f, 0f, 10f);
|
|
|
|
break;
|
|
|
|
case FIXED_OD:
|
|
|
|
fixedOD = getBoundedValue(fixedOD, diff / 10f, 0f, 10f);
|
2014-07-03 00:24:19 +02:00
|
|
|
break;
|
2014-07-09 04:17:48 +02:00
|
|
|
case CHECKPOINT:
|
|
|
|
checkpoint = getBoundedValue(checkpoint, diff * multiplier, 0, 3599);
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
default:
|
|
|
|
break;
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-05 07:24:01 +02:00
|
|
|
/**
|
|
|
|
* Returns a bounded value for when an option is dragged.
|
|
|
|
* @param var the initial value
|
|
|
|
* @param diff the value change
|
|
|
|
* @param min the minimum value
|
|
|
|
* @param max the maximum value
|
|
|
|
* @return the bounded value
|
|
|
|
*/
|
|
|
|
private int getBoundedValue(int var, int diff, int min, int max) {
|
|
|
|
int val = var + diff;
|
|
|
|
if (val < min)
|
|
|
|
val = min;
|
|
|
|
else if (val > max)
|
|
|
|
val = max;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a bounded value for when an option is dragged.
|
|
|
|
* @param var the initial value
|
|
|
|
* @param diff the value change
|
|
|
|
* @param min the minimum value
|
|
|
|
* @param max the maximum value
|
|
|
|
* @return the bounded value
|
|
|
|
*/
|
|
|
|
private float getBoundedValue(float var, float diff, float min, float max) {
|
|
|
|
float val = var + diff;
|
|
|
|
if (val < min)
|
|
|
|
val = min;
|
|
|
|
else if (val > max)
|
|
|
|
val = max;
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
@Override
|
|
|
|
public void keyPressed(int key, char c) {
|
2014-07-18 05:58:37 +02:00
|
|
|
// key entry state
|
|
|
|
if (keyEntryLeft || keyEntryRight) {
|
|
|
|
if (Character.isLetterOrDigit(c)) {
|
|
|
|
if (keyEntryLeft && keyRight != key)
|
|
|
|
keyLeft = key;
|
|
|
|
else if (keyEntryRight && keyLeft != key)
|
|
|
|
keyRight = key;
|
|
|
|
}
|
|
|
|
keyEntryLeft = keyEntryRight = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
switch (key) {
|
|
|
|
case Input.KEY_ESCAPE:
|
2014-07-03 00:24:19 +02:00
|
|
|
SoundController.playSound(SoundController.SOUND_MENUBACK);
|
2014-06-30 04:17:04 +02:00
|
|
|
game.enterState(Opsu.STATE_SONGMENU, new EmptyTransition(), new FadeInTransition(Color.black));
|
|
|
|
break;
|
|
|
|
case Input.KEY_F12:
|
2014-07-02 01:32:03 +02:00
|
|
|
Utils.takeScreenShot();
|
2014-06-30 04:17:04 +02:00
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
case Input.KEY_TAB:
|
|
|
|
int i = 1;
|
|
|
|
if (input.isKeyDown(Input.KEY_LSHIFT) || input.isKeyDown(Input.KEY_RSHIFT))
|
|
|
|
i = TAB_MAX - 1;
|
|
|
|
currentTab = (currentTab + i) % TAB_MAX;
|
|
|
|
SoundController.playSound(SoundController.SOUND_MENUCLICK);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void enter(GameContainer container, StateBasedGame game)
|
|
|
|
throws SlickException {
|
|
|
|
currentTab = TAB_DISPLAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws a game option.
|
|
|
|
* @param option the option (OPTION_* constant)
|
|
|
|
* @param pos the position to draw at
|
|
|
|
*/
|
|
|
|
private void drawOption(GameOption option, int pos) {
|
|
|
|
switch (option) {
|
|
|
|
case SCREEN_RESOLUTION:
|
|
|
|
drawOption(pos, "Screen Resolution",
|
|
|
|
String.format("%dx%d", resolutions[resolutionIndex][0], resolutions[resolutionIndex][1]),
|
|
|
|
"Restart to apply resolution changes."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
// case FULLSCREEN:
|
|
|
|
// drawOption(pos, "Fullscreen Mode",
|
|
|
|
// fullscreen ? "Yes" : "No",
|
|
|
|
// "Restart to apply changes."
|
|
|
|
// );
|
|
|
|
// break;
|
|
|
|
case TARGET_FPS:
|
|
|
|
drawOption(pos, "Frame Limiter",
|
|
|
|
String.format("%dfps", getTargetFPS()),
|
|
|
|
"Higher values may cause high CPU usage."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case SCREENSHOT_FORMAT:
|
|
|
|
drawOption(pos, "Screenshot Format",
|
|
|
|
screenshotFormat[screenshotFormatIndex].toUpperCase(),
|
|
|
|
"Press F12 to take a screenshot."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case SHOW_FPS:
|
|
|
|
drawOption(pos, "Show FPS Counter",
|
|
|
|
showFPS ? "Yes" : "No",
|
|
|
|
"Show an FPS counter in the bottom-right hand corner."
|
|
|
|
);
|
|
|
|
break;
|
2014-08-25 05:48:52 +02:00
|
|
|
case SHOW_UNICODE:
|
|
|
|
drawOption(pos, "Prefer Non-English Metadata",
|
|
|
|
showUnicode ? "Yes" : "No",
|
|
|
|
"Where available, song titles will be shown in their native language."
|
|
|
|
);
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
case NEW_CURSOR:
|
|
|
|
drawOption(pos, "Enable New Cursor",
|
|
|
|
newCursor ? "Yes" : "No",
|
|
|
|
"Use the new cursor style (may cause higher CPU usage)."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case DYNAMIC_BACKGROUND:
|
|
|
|
drawOption(pos, "Enable Dynamic Backgrounds",
|
|
|
|
dynamicBackground ? "Yes" : "No",
|
|
|
|
"The song background will be used as the main menu background."
|
|
|
|
);
|
|
|
|
break;
|
2014-07-06 03:00:52 +02:00
|
|
|
case LOAD_VERBOSE:
|
2014-07-15 19:21:37 +02:00
|
|
|
drawOption(pos, "Show Detailed Loading Progress",
|
2014-07-06 03:00:52 +02:00
|
|
|
loadVerbose ? "Yes" : "No",
|
2014-07-15 19:21:37 +02:00
|
|
|
"Display more specific loading information in the splash screen."
|
2014-07-06 03:00:52 +02:00
|
|
|
);
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
case MUSIC_VOLUME:
|
|
|
|
drawOption(pos, "Music Volume",
|
|
|
|
String.format("%d%%", musicVolume),
|
|
|
|
"Global music volume."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case EFFECT_VOLUME:
|
|
|
|
drawOption(pos, "Effect Volume",
|
|
|
|
String.format("%d%%", effectVolume),
|
|
|
|
"Volume of menu and game sounds."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case HITSOUND_VOLUME:
|
|
|
|
drawOption(pos, "Hit Sound Volume",
|
|
|
|
String.format("%d%%", hitSoundVolume),
|
|
|
|
"Volume of hit sounds."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case MUSIC_OFFSET:
|
|
|
|
drawOption(pos, "Music Offset",
|
|
|
|
String.format("%dms", musicOffset),
|
|
|
|
"Adjust this value if hit objects are out of sync."
|
|
|
|
);
|
|
|
|
break;
|
2014-07-11 04:01:39 +02:00
|
|
|
case DISABLE_SOUNDS:
|
|
|
|
drawOption(pos, "Disable All Sound Effects",
|
|
|
|
disableSound ? "Yes" : "No",
|
|
|
|
"May resolve Linux sound driver issues. Requires a restart."
|
|
|
|
);
|
|
|
|
break;
|
2014-07-18 05:58:37 +02:00
|
|
|
case KEY_LEFT:
|
|
|
|
drawOption(pos, "Left Game Key",
|
|
|
|
Keyboard.getKeyName(getGameKeyLeft()),
|
|
|
|
"Select this option to input a key."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case KEY_RIGHT:
|
|
|
|
drawOption(pos, "Right Game Key",
|
|
|
|
Keyboard.getKeyName(getGameKeyRight()),
|
|
|
|
"Select this option to input a key."
|
|
|
|
);
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
case BACKGROUND_DIM:
|
|
|
|
drawOption(pos, "Background Dim",
|
|
|
|
String.format("%d%%", backgroundDim),
|
|
|
|
"Percentage to dim the background image during gameplay."
|
|
|
|
);
|
|
|
|
break;
|
2014-07-03 07:05:23 +02:00
|
|
|
case FORCE_DEFAULT_PLAYFIELD:
|
|
|
|
drawOption(pos, "Force Default Playfield",
|
|
|
|
forceDefaultPlayfield ? "Yes" : "No",
|
|
|
|
"Override the song background with the default playfield background."
|
|
|
|
);
|
|
|
|
break;
|
2014-07-04 22:41:52 +02:00
|
|
|
case IGNORE_BEATMAP_SKINS:
|
|
|
|
drawOption(pos, "Ignore All Beatmap Skins",
|
|
|
|
ignoreBeatmapSkins ? "Yes" : "No",
|
|
|
|
"Never use skin element overrides provided by beatmaps."
|
|
|
|
);
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
case SHOW_HIT_LIGHTING:
|
|
|
|
drawOption(pos, "Show Hit Lighting",
|
|
|
|
showHitLighting ? "Yes" : "No",
|
|
|
|
"Adds an effect behind hit explosions."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case SHOW_COMBO_BURSTS:
|
|
|
|
drawOption(pos, "Show Combo Bursts",
|
|
|
|
showComboBursts ? "Yes" : "No",
|
|
|
|
"A character image is displayed at combo milestones."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case SHOW_PERFECT_HIT:
|
|
|
|
drawOption(pos, "Show Perfect Hits",
|
|
|
|
showPerfectHit ? "Yes" : "No",
|
|
|
|
"Whether to show perfect hit result bursts (300s, slider ticks)."
|
|
|
|
);
|
|
|
|
break;
|
2014-07-05 07:24:01 +02:00
|
|
|
case FIXED_CS:
|
|
|
|
drawOption(pos, "Fixed Circle Size (CS)",
|
|
|
|
(fixedCS == 0f) ? "Disabled" : String.format("%.1f", fixedCS),
|
|
|
|
"Determines the size of circles and sliders."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case FIXED_HP:
|
|
|
|
drawOption(pos, "Fixed HP Drain Rate (HP)",
|
|
|
|
(fixedHP == 0f) ? "Disabled" : String.format("%.1f", fixedHP),
|
|
|
|
"Determines the rate at which health decreases."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case FIXED_AR:
|
|
|
|
drawOption(pos, "Fixed Approach Rate (AR)",
|
|
|
|
(fixedAR == 0f) ? "Disabled" : String.format("%.1f", fixedAR),
|
|
|
|
"Determines how long hit circles stay on the screen."
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case FIXED_OD:
|
|
|
|
drawOption(pos, "Fixed Overall Difficulty (OD)",
|
|
|
|
(fixedOD == 0f) ? "Disabled" : String.format("%.1f", fixedOD),
|
|
|
|
"Determines the time window for hit results."
|
|
|
|
);
|
|
|
|
break;
|
2014-07-09 04:17:48 +02:00
|
|
|
case CHECKPOINT:
|
|
|
|
drawOption(pos, "Track Checkpoint",
|
|
|
|
(checkpoint == 0) ? "Disabled" : String.format("%02d:%02d",
|
|
|
|
TimeUnit.SECONDS.toMinutes(checkpoint),
|
2014-07-09 19:36:42 +02:00
|
|
|
checkpoint - TimeUnit.MINUTES.toSeconds(TimeUnit.SECONDS.toMinutes(checkpoint))),
|
2014-07-09 04:17:48 +02:00
|
|
|
"Press CTRL+L while playing to load a checkpoint, and CTRL+S to set one."
|
|
|
|
);
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
default:
|
|
|
|
break;
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws a game option.
|
2014-07-03 00:24:19 +02:00
|
|
|
* @param pos the element position
|
2014-06-30 04:17:04 +02:00
|
|
|
* @param label the option name
|
|
|
|
* @param value the option value
|
2014-07-03 07:05:23 +02:00
|
|
|
* @param notes additional notes
|
2014-06-30 04:17:04 +02:00
|
|
|
*/
|
2014-07-03 00:24:19 +02:00
|
|
|
private void drawOption(int pos, String label, String value, String notes) {
|
2014-06-30 04:17:04 +02:00
|
|
|
int width = container.getWidth();
|
2014-08-24 20:48:27 +02:00
|
|
|
int textHeight = Utils.FONT_LARGE.getLineHeight();
|
2014-06-30 04:17:04 +02:00
|
|
|
float y = textY + (pos * offsetY);
|
|
|
|
|
2014-07-03 00:24:19 +02:00
|
|
|
g.setColor(Color.white);
|
|
|
|
g.drawString(label, width / 30, y);
|
2014-06-30 04:17:04 +02:00
|
|
|
g.drawString(value, width / 2, y);
|
2014-07-03 07:05:23 +02:00
|
|
|
Utils.FONT_SMALL.drawString(width / 30, y + textHeight, notes);
|
2014-07-03 00:24:19 +02:00
|
|
|
g.setColor(Utils.COLOR_WHITE_ALPHA);
|
|
|
|
g.drawLine(0, y + textHeight, width, y + textHeight);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-03 00:24:19 +02:00
|
|
|
* Returns the option clicked.
|
|
|
|
* If no option clicked, -1 will be returned.
|
|
|
|
* @param y the y coordinate
|
|
|
|
* @return the option (OPTION_* constant)
|
2014-06-30 04:17:04 +02:00
|
|
|
*/
|
2014-07-03 00:24:19 +02:00
|
|
|
private GameOption getClickedOption(int y) {
|
|
|
|
GameOption option = GameOption.NULL;
|
|
|
|
|
|
|
|
if (y < textY || y > textY + (offsetY * maxOptionsScreen))
|
|
|
|
return option;
|
|
|
|
|
2014-08-24 20:48:27 +02:00
|
|
|
int index = (y - textY + Utils.FONT_LARGE.getLineHeight()) / offsetY;
|
2014-07-03 00:24:19 +02:00
|
|
|
switch (currentTab) {
|
|
|
|
case TAB_DISPLAY:
|
|
|
|
if (index < displayOptions.length)
|
|
|
|
option = displayOptions[index];
|
|
|
|
break;
|
|
|
|
case TAB_MUSIC:
|
|
|
|
if (index < musicOptions.length)
|
|
|
|
option = musicOptions[index];
|
|
|
|
break;
|
|
|
|
case TAB_GAMEPLAY:
|
|
|
|
if (index < gameplayOptions.length)
|
|
|
|
option = gameplayOptions[index];
|
|
|
|
break;
|
2014-07-05 07:24:01 +02:00
|
|
|
case TAB_CUSTOM:
|
|
|
|
if (index < customOptions.length)
|
|
|
|
option = customOptions[index];
|
2014-07-03 00:24:19 +02:00
|
|
|
}
|
|
|
|
return option;
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-07-02 01:32:03 +02:00
|
|
|
* Returns the target frame rate.
|
|
|
|
* @return the target FPS
|
2014-06-30 04:17:04 +02:00
|
|
|
*/
|
2014-07-02 01:32:03 +02:00
|
|
|
public static int getTargetFPS() { return targetFPS[targetFPSindex]; }
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the default music volume.
|
|
|
|
* @return the volume [0, 1]
|
|
|
|
*/
|
|
|
|
public static float getMusicVolume() { return musicVolume / 100f; }
|
|
|
|
|
2014-07-01 07:14:03 +02:00
|
|
|
/**
|
|
|
|
* Returns the default sound effect volume.
|
|
|
|
* @return the sound volume [0, 1]
|
|
|
|
*/
|
|
|
|
public static float getEffectVolume() { return effectVolume / 100f; }
|
|
|
|
|
2014-07-03 00:24:19 +02:00
|
|
|
/**
|
2014-07-09 19:36:42 +02:00
|
|
|
* Returns the default hit sound volume.
|
|
|
|
* @return the hit sound volume [0, 1]
|
2014-07-03 00:24:19 +02:00
|
|
|
*/
|
|
|
|
public static float getHitSoundVolume() { return hitSoundVolume / 100f; }
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
|
|
|
* Returns the music offset time.
|
|
|
|
* @return the offset (in milliseconds)
|
|
|
|
*/
|
|
|
|
public static int getMusicOffset() { return musicOffset; }
|
|
|
|
|
|
|
|
/**
|
2014-07-02 01:32:03 +02:00
|
|
|
* Returns the screenshot file format.
|
|
|
|
* @return the file extension ("png", "jpg", "bmp")
|
2014-06-30 04:17:04 +02:00
|
|
|
*/
|
2014-07-02 01:32:03 +02:00
|
|
|
public static String getScreenshotFormat() { return screenshotFormat[screenshotFormatIndex]; }
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
/**
|
2014-07-11 02:35:07 +02:00
|
|
|
* Sets the container size and makes the window borderless if the container
|
|
|
|
* size is identical to the screen resolution.
|
|
|
|
* <p>
|
|
|
|
* If the configured resolution is larger than the screen size, the smallest
|
|
|
|
* available resolution will be used.
|
|
|
|
* @param app the game container
|
|
|
|
* @throws SlickException failure to set display mode
|
|
|
|
*/
|
|
|
|
public static void setDisplayMode(AppGameContainer app) throws SlickException {
|
|
|
|
int screenWidth = app.getScreenWidth();
|
|
|
|
int screenHeight = app.getScreenHeight();
|
|
|
|
if (screenWidth < resolutions[resolutionIndex][0] || screenHeight < resolutions[resolutionIndex][1])
|
|
|
|
resolutionIndex = 0;
|
|
|
|
|
|
|
|
int containerWidth = resolutions[resolutionIndex][0];
|
|
|
|
int containerHeight = resolutions[resolutionIndex][1];
|
|
|
|
app.setDisplayMode(containerWidth, containerHeight, false);
|
|
|
|
if (screenWidth == containerWidth && screenHeight == containerHeight)
|
|
|
|
System.setProperty("org.lwjgl.opengl.Window.undecorated", "true");
|
|
|
|
}
|
2014-06-30 04:17:04 +02:00
|
|
|
|
|
|
|
// /**
|
|
|
|
// * Returns whether or not fullscreen mode is enabled.
|
|
|
|
// * @return true if enabled
|
|
|
|
// */
|
|
|
|
// public static boolean isFullscreen() { return fullscreen; }
|
|
|
|
|
2014-07-02 01:32:03 +02:00
|
|
|
/**
|
|
|
|
* Returns whether or not the FPS counter display is enabled.
|
|
|
|
* @return true if enabled
|
|
|
|
*/
|
|
|
|
public static boolean isFPSCounterEnabled() { return showFPS; }
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
|
|
|
* Returns whether or not hit lighting effects are enabled.
|
|
|
|
* @return true if enabled
|
|
|
|
*/
|
|
|
|
public static boolean isHitLightingEnabled() { return showHitLighting; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not combo burst effects are enabled.
|
|
|
|
* @return true if enabled
|
|
|
|
*/
|
|
|
|
public static boolean isComboBurstEnabled() { return showComboBursts; }
|
|
|
|
|
2014-06-30 18:37:37 +02:00
|
|
|
/**
|
|
|
|
* Returns the port number to bind to.
|
|
|
|
* @return the port
|
|
|
|
*/
|
2014-07-02 01:32:03 +02:00
|
|
|
public static int getPort() { return port; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether or not the new cursor type is enabled.
|
|
|
|
* @return true if enabled
|
|
|
|
*/
|
|
|
|
public static boolean isNewCursorEnabled() { return newCursor; }
|
2014-06-30 18:37:37 +02:00
|
|
|
|
2014-07-02 09:02:11 +02:00
|
|
|
/**
|
|
|
|
* Returns whether or not the main menu background should be the current track image.
|
|
|
|
* @return true if enabled
|
|
|
|
*/
|
|
|
|
public static boolean isDynamicBackgroundEnabled() { return dynamicBackground; }
|
|
|
|
|
2014-07-03 00:24:19 +02:00
|
|
|
/**
|
|
|
|
* Returns whether or not to show perfect hit result bursts.
|
|
|
|
* @return true if enabled
|
|
|
|
*/
|
|
|
|
public static boolean isPerfectHitBurstEnabled() { return showPerfectHit; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the background dim level.
|
|
|
|
* @return the alpha level [0, 1]
|
|
|
|
*/
|
|
|
|
public static float getBackgroundDim() { return (100 - backgroundDim) / 100f; }
|
|
|
|
|
2014-07-03 07:05:23 +02:00
|
|
|
/**
|
|
|
|
* Returns whether or not to override the song background with the default playfield background.
|
|
|
|
* @return true if forced
|
|
|
|
*/
|
|
|
|
public static boolean isDefaultPlayfieldForced() { return forceDefaultPlayfield; }
|
|
|
|
|
2014-07-04 22:41:52 +02:00
|
|
|
/**
|
|
|
|
* Returns whether or not beatmap skins are ignored.
|
|
|
|
* @return true if ignored
|
|
|
|
*/
|
|
|
|
public static boolean isBeatmapSkinIgnored() { return ignoreBeatmapSkins; }
|
|
|
|
|
2014-07-05 07:24:01 +02:00
|
|
|
/**
|
|
|
|
* Returns the fixed circle size override, if any.
|
|
|
|
* @return the CS value (0, 10], 0 if disabled
|
|
|
|
*/
|
|
|
|
public static float getFixedCS() { return fixedCS; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the fixed HP drain rate override, if any.
|
|
|
|
* @return the HP value (0, 10], 0 if disabled
|
|
|
|
*/
|
|
|
|
public static float getFixedHP() { return fixedHP; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the fixed approach rate override, if any.
|
|
|
|
* @return the AR value (0, 10], 0 if disabled
|
|
|
|
*/
|
|
|
|
public static float getFixedAR() { return fixedAR; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the fixed overall difficulty override, if any.
|
|
|
|
* @return the OD value (0, 10], 0 if disabled
|
|
|
|
*/
|
|
|
|
public static float getFixedOD() { return fixedOD; }
|
|
|
|
|
2014-07-06 03:00:52 +02:00
|
|
|
/**
|
|
|
|
* Returns whether or not to render loading text in the splash screen.
|
|
|
|
* @return true if enabled
|
|
|
|
*/
|
|
|
|
public static boolean isLoadVerbose() { return loadVerbose; }
|
|
|
|
|
2014-07-09 04:17:48 +02:00
|
|
|
/**
|
|
|
|
* Returns the track checkpoint time.
|
|
|
|
* @return the checkpoint time (in ms)
|
|
|
|
*/
|
|
|
|
public static int getCheckpoint() { return checkpoint * 1000; }
|
|
|
|
|
2014-07-11 04:01:39 +02:00
|
|
|
/**
|
|
|
|
* Returns whether or not all sound effects are disabled.
|
|
|
|
* @return true if disabled
|
|
|
|
*/
|
|
|
|
public static boolean isSoundDisabled() { return disableSound; }
|
|
|
|
|
2014-08-25 05:48:52 +02:00
|
|
|
/**
|
|
|
|
* Returns whether or not to use non-English metadata where available.
|
|
|
|
* @return true if Unicode preferred
|
|
|
|
*/
|
|
|
|
public static boolean useUnicodeMetadata() { return showUnicode; }
|
|
|
|
|
2014-07-09 04:17:48 +02:00
|
|
|
/**
|
|
|
|
* Sets the track checkpoint time, if within bounds.
|
|
|
|
* @param time the track position (in ms)
|
|
|
|
* @return true if within bounds
|
|
|
|
*/
|
|
|
|
public static boolean setCheckpoint(int time) {
|
|
|
|
if (time >= 0 && time < 3600) {
|
|
|
|
checkpoint = time;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-07-18 05:58:37 +02:00
|
|
|
/**
|
|
|
|
* Returns the left game key.
|
|
|
|
* @return the left key code
|
|
|
|
*/
|
|
|
|
public static int getGameKeyLeft() {
|
|
|
|
if (keyLeft == Keyboard.KEY_NONE)
|
|
|
|
keyLeft = Input.KEY_Z;
|
|
|
|
return keyLeft;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the right game key.
|
|
|
|
* @return the right key code
|
|
|
|
*/
|
|
|
|
public static int getGameKeyRight() {
|
|
|
|
if (keyRight == Keyboard.KEY_NONE)
|
|
|
|
keyRight = Input.KEY_X;
|
|
|
|
return keyRight;
|
|
|
|
}
|
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
2014-07-06 07:58:44 +02:00
|
|
|
* Returns the beatmap directory.
|
2014-06-30 04:17:04 +02:00
|
|
|
* If invalid, this will attempt to search for the directory,
|
|
|
|
* and if nothing found, will create one.
|
2014-07-02 07:53:42 +02:00
|
|
|
* @return the beatmap directory
|
2014-06-30 04:17:04 +02:00
|
|
|
*/
|
|
|
|
public static File getBeatmapDir() {
|
|
|
|
if (beatmapDir != null && beatmapDir.isDirectory())
|
|
|
|
return beatmapDir;
|
|
|
|
|
|
|
|
// search for directory
|
|
|
|
for (int i = 0; i < BEATMAP_DIRS.length; i++) {
|
|
|
|
beatmapDir = new File(BEATMAP_DIRS[i]);
|
2014-07-02 01:32:03 +02:00
|
|
|
if (beatmapDir.isDirectory())
|
2014-06-30 04:17:04 +02:00
|
|
|
return beatmapDir;
|
|
|
|
}
|
|
|
|
beatmapDir.mkdir(); // none found, create new directory
|
|
|
|
return beatmapDir;
|
|
|
|
}
|
|
|
|
|
2014-07-06 07:58:44 +02:00
|
|
|
/**
|
|
|
|
* Returns the OSZ archive directory.
|
2014-07-18 06:56:37 +02:00
|
|
|
* If invalid, this will create and return a "SongPacks" directory.
|
2014-07-06 07:58:44 +02:00
|
|
|
* @return the OSZ archive directory
|
|
|
|
*/
|
|
|
|
public static File getOSZDir() {
|
|
|
|
if (oszDir != null && oszDir.isDirectory())
|
|
|
|
return oszDir;
|
|
|
|
|
2014-07-15 06:20:36 +02:00
|
|
|
oszDir = new File("SongPacks/");
|
|
|
|
oszDir.mkdir();
|
2014-07-06 07:58:44 +02:00
|
|
|
return oszDir;
|
|
|
|
}
|
|
|
|
|
2014-07-18 06:56:37 +02:00
|
|
|
/**
|
|
|
|
* Returns the screenshot directory.
|
|
|
|
* If invalid, this will return a "Screenshot" directory.
|
|
|
|
* @return the screenshot directory
|
|
|
|
*/
|
|
|
|
public static File getScreenshotDir() {
|
|
|
|
if (screenshotDir != null && screenshotDir.isDirectory())
|
|
|
|
return screenshotDir;
|
|
|
|
|
|
|
|
screenshotDir = new File("Screenshots/");
|
|
|
|
return screenshotDir;
|
|
|
|
}
|
|
|
|
|
2014-07-02 07:53:42 +02:00
|
|
|
/**
|
|
|
|
* Returns the current skin directory.
|
|
|
|
* If invalid, this will create a "Skins" folder in the root directory.
|
|
|
|
* @return the skin directory
|
|
|
|
*/
|
|
|
|
public static File getSkinDir() {
|
|
|
|
if (skinDir != null && skinDir.isDirectory())
|
|
|
|
return skinDir;
|
|
|
|
|
|
|
|
skinDir = new File("Skins/");
|
|
|
|
skinDir.mkdir();
|
|
|
|
return skinDir;
|
|
|
|
}
|
2014-07-02 01:32:03 +02:00
|
|
|
|
2014-06-30 04:17:04 +02:00
|
|
|
/**
|
|
|
|
* Reads user options from the options file, if it exists.
|
|
|
|
*/
|
|
|
|
public static void parseOptions() {
|
|
|
|
// if no config file, use default settings
|
2014-07-02 07:53:42 +02:00
|
|
|
if (!OPTIONS_FILE.isFile()) {
|
2014-06-30 04:17:04 +02:00
|
|
|
saveOptions();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-02 07:53:42 +02:00
|
|
|
try (BufferedReader in = new BufferedReader(new FileReader(OPTIONS_FILE))) {
|
2014-06-30 04:17:04 +02:00
|
|
|
String line;
|
|
|
|
String name, value;
|
|
|
|
int i;
|
|
|
|
while ((line = in.readLine()) != null) {
|
|
|
|
line = line.trim();
|
|
|
|
if (line.length() < 2 || line.charAt(0) == '#')
|
|
|
|
continue;
|
|
|
|
int index = line.indexOf('=');
|
|
|
|
if (index == -1)
|
|
|
|
continue;
|
|
|
|
name = line.substring(0, index).trim();
|
|
|
|
value = line.substring(index + 1).trim();
|
|
|
|
switch (name) {
|
|
|
|
case "BeatmapDirectory":
|
|
|
|
beatmapDir = new File(value);
|
|
|
|
break;
|
2014-07-06 07:58:44 +02:00
|
|
|
case "OSZDirectory":
|
|
|
|
oszDir = new File(value);
|
|
|
|
break;
|
2014-07-18 06:56:37 +02:00
|
|
|
case "ScreenshotDirectory":
|
|
|
|
screenshotDir = new File(value);
|
|
|
|
break;
|
2014-07-02 07:53:42 +02:00
|
|
|
case "Skin":
|
|
|
|
skinDir = new File(value);
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
case "Port":
|
|
|
|
i = Integer.parseInt(value);
|
|
|
|
if (i > 0 && i <= 65535)
|
|
|
|
port = i;
|
|
|
|
break;
|
2014-06-30 04:17:04 +02:00
|
|
|
case "ScreenResolution":
|
|
|
|
i = Integer.parseInt(value);
|
|
|
|
if (i >= 0 && i < resolutions.length)
|
|
|
|
resolutionIndex = i;
|
|
|
|
break;
|
|
|
|
// case "Fullscreen":
|
|
|
|
// fullscreen = Boolean.parseBoolean(value);
|
|
|
|
// break;
|
|
|
|
case "FrameSync":
|
|
|
|
i = Integer.parseInt(value);
|
|
|
|
if (i >= 0 && i <= targetFPS.length)
|
|
|
|
targetFPSindex = i;
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
case "ScreenshotFormat":
|
|
|
|
i = Integer.parseInt(value);
|
|
|
|
if (i >= 0 && i < screenshotFormat.length)
|
|
|
|
screenshotFormatIndex = i;
|
|
|
|
break;
|
|
|
|
case "FpsCounter":
|
|
|
|
showFPS = Boolean.parseBoolean(value);
|
|
|
|
break;
|
2014-08-25 05:48:52 +02:00
|
|
|
case "ShowUnicode":
|
|
|
|
showUnicode = Boolean.parseBoolean(value);
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
case "NewCursor":
|
|
|
|
newCursor = Boolean.parseBoolean(value);
|
|
|
|
break;
|
|
|
|
case "DynamicBackground":
|
|
|
|
dynamicBackground = Boolean.parseBoolean(value);
|
|
|
|
break;
|
2014-07-06 03:00:52 +02:00
|
|
|
case "LoadVerbose":
|
|
|
|
loadVerbose = Boolean.parseBoolean(value);
|
|
|
|
break;
|
2014-06-30 04:17:04 +02:00
|
|
|
case "VolumeMusic":
|
|
|
|
i = Integer.parseInt(value);
|
|
|
|
if (i >= 0 && i <= 100)
|
|
|
|
musicVolume = i;
|
|
|
|
break;
|
2014-07-01 07:14:03 +02:00
|
|
|
case "VolumeEffect":
|
|
|
|
i = Integer.parseInt(value);
|
|
|
|
if (i >= 0 && i <= 100)
|
|
|
|
effectVolume = i;
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
case "VolumeHitSound":
|
|
|
|
i = Integer.parseInt(value);
|
|
|
|
if (i >= 0 && i <= 100)
|
|
|
|
hitSoundVolume = i;
|
|
|
|
break;
|
2014-06-30 04:17:04 +02:00
|
|
|
case "Offset":
|
|
|
|
i = Integer.parseInt(value);
|
|
|
|
if (i >= -500 && i <= 500)
|
|
|
|
musicOffset = i;
|
|
|
|
break;
|
2014-07-11 04:01:39 +02:00
|
|
|
case "DisableSound":
|
|
|
|
disableSound = Boolean.parseBoolean(value);
|
|
|
|
break;
|
2014-07-18 05:58:37 +02:00
|
|
|
case "keyOsuLeft":
|
|
|
|
if ((value.length() == 1 && Character.isLetterOrDigit(value.charAt(0))) ||
|
|
|
|
(value.length() == 7 && value.startsWith("NUMPAD"))) {
|
|
|
|
i = Keyboard.getKeyIndex(value);
|
|
|
|
if (keyRight != i)
|
|
|
|
keyLeft = i;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "keyOsuRight":
|
|
|
|
if ((value.length() == 1 && Character.isLetterOrDigit(value.charAt(0))) ||
|
|
|
|
(value.length() == 7 && value.startsWith("NUMPAD"))) {
|
|
|
|
i = Keyboard.getKeyIndex(value);
|
|
|
|
if (keyLeft != i)
|
|
|
|
keyRight = i;
|
|
|
|
}
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
case "DimLevel":
|
2014-06-30 04:17:04 +02:00
|
|
|
i = Integer.parseInt(value);
|
2014-07-03 00:24:19 +02:00
|
|
|
if (i >= 0 && i <= 100)
|
|
|
|
backgroundDim = i;
|
2014-06-30 04:17:04 +02:00
|
|
|
break;
|
2014-07-03 07:05:23 +02:00
|
|
|
case "ForceDefaultPlayfield":
|
|
|
|
forceDefaultPlayfield = Boolean.parseBoolean(value);
|
|
|
|
break;
|
2014-07-04 22:41:52 +02:00
|
|
|
case "IgnoreBeatmapSkins":
|
|
|
|
ignoreBeatmapSkins = Boolean.parseBoolean(value);
|
|
|
|
break;
|
2014-06-30 04:17:04 +02:00
|
|
|
case "HitLighting":
|
|
|
|
showHitLighting = Boolean.parseBoolean(value);
|
|
|
|
break;
|
|
|
|
case "ComboBurst":
|
|
|
|
showComboBursts = Boolean.parseBoolean(value);
|
|
|
|
break;
|
2014-07-03 00:24:19 +02:00
|
|
|
case "PerfectHit":
|
|
|
|
showPerfectHit = Boolean.parseBoolean(value);
|
2014-07-02 09:02:11 +02:00
|
|
|
break;
|
2014-07-05 07:24:01 +02:00
|
|
|
case "FixedCS":
|
|
|
|
fixedCS = Float.parseFloat(value);
|
|
|
|
break;
|
|
|
|
case "FixedHP":
|
|
|
|
fixedHP = Float.parseFloat(value);
|
|
|
|
break;
|
|
|
|
case "FixedAR":
|
|
|
|
fixedAR = Float.parseFloat(value);
|
|
|
|
break;
|
|
|
|
case "FixedOD":
|
|
|
|
fixedOD = Float.parseFloat(value);
|
|
|
|
break;
|
2014-07-09 04:17:48 +02:00
|
|
|
case "Checkpoint":
|
|
|
|
setCheckpoint(Integer.parseInt(value));
|
|
|
|
break;
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
2014-07-02 07:53:42 +02:00
|
|
|
Log.error(String.format("Failed to read file '%s'.", OPTIONS_FILE.getAbsolutePath()), e);
|
2014-06-30 04:17:04 +02:00
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
Log.warn("Format error in options file.", e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* (Over)writes user options to a file.
|
|
|
|
*/
|
|
|
|
public static void saveOptions() {
|
|
|
|
try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
|
|
|
|
new FileOutputStream(OPTIONS_FILE), "utf-8"))) {
|
|
|
|
// header
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("EEEE, MMMM dd, yyyy");
|
|
|
|
String date = dateFormat.format(new Date());
|
|
|
|
writer.write("# opsu! configuration");
|
|
|
|
writer.newLine();
|
|
|
|
writer.write("# last updated on ");
|
|
|
|
writer.write(date);
|
|
|
|
writer.newLine();
|
|
|
|
writer.newLine();
|
|
|
|
|
|
|
|
// options
|
2014-07-02 07:53:42 +02:00
|
|
|
writer.write(String.format("BeatmapDirectory = %s", getBeatmapDir().getAbsolutePath()));
|
|
|
|
writer.newLine();
|
2014-07-06 07:58:44 +02:00
|
|
|
writer.write(String.format("OSZDirectory = %s", getOSZDir().getAbsolutePath()));
|
|
|
|
writer.newLine();
|
2014-07-18 06:56:37 +02:00
|
|
|
writer.write(String.format("ScreenshotDirectory = %s", getScreenshotDir().getAbsolutePath()));
|
|
|
|
writer.newLine();
|
2014-07-02 07:53:42 +02:00
|
|
|
writer.write(String.format("Skin = %s", getSkinDir().getAbsolutePath()));
|
|
|
|
writer.newLine();
|
2014-07-03 00:24:19 +02:00
|
|
|
writer.write(String.format("Port = %d", port));
|
|
|
|
writer.newLine();
|
2014-06-30 04:17:04 +02:00
|
|
|
writer.write(String.format("ScreenResolution = %d", resolutionIndex));
|
|
|
|
writer.newLine();
|
|
|
|
// writer.write(String.format("Fullscreen = %b", fullscreen));
|
|
|
|
// writer.newLine();
|
|
|
|
writer.write(String.format("FrameSync = %d", targetFPSindex));
|
|
|
|
writer.newLine();
|
2014-07-03 00:24:19 +02:00
|
|
|
writer.write(String.format("FpsCounter = %b", showFPS));
|
|
|
|
writer.newLine();
|
2014-08-25 05:48:52 +02:00
|
|
|
writer.write(String.format("ShowUnicode = %b", showUnicode));
|
|
|
|
writer.newLine();
|
2014-07-03 00:24:19 +02:00
|
|
|
writer.write(String.format("ScreenshotFormat = %d", screenshotFormatIndex));
|
|
|
|
writer.newLine();
|
|
|
|
writer.write(String.format("NewCursor = %b", newCursor));
|
|
|
|
writer.newLine();
|
|
|
|
writer.write(String.format("DynamicBackground = %b", dynamicBackground));
|
|
|
|
writer.newLine();
|
2014-07-06 03:00:52 +02:00
|
|
|
writer.write(String.format("LoadVerbose = %b", loadVerbose));
|
|
|
|
writer.newLine();
|
2014-06-30 04:17:04 +02:00
|
|
|
writer.write(String.format("VolumeMusic = %d", musicVolume));
|
|
|
|
writer.newLine();
|
2014-07-01 07:14:03 +02:00
|
|
|
writer.write(String.format("VolumeEffect = %d", effectVolume));
|
|
|
|
writer.newLine();
|
2014-07-03 00:24:19 +02:00
|
|
|
writer.write(String.format("VolumeHitSound = %d", hitSoundVolume));
|
2014-06-30 04:17:04 +02:00
|
|
|
writer.newLine();
|
2014-07-03 00:24:19 +02:00
|
|
|
writer.write(String.format("Offset = %d", musicOffset));
|
2014-06-30 04:17:04 +02:00
|
|
|
writer.newLine();
|
2014-07-11 04:01:39 +02:00
|
|
|
writer.write(String.format("DisableSound = %b", disableSound));
|
|
|
|
writer.newLine();
|
2014-07-19 03:33:07 +02:00
|
|
|
writer.write(String.format("keyOsuLeft = %s", Keyboard.getKeyName(getGameKeyLeft())));
|
2014-07-18 05:58:37 +02:00
|
|
|
writer.newLine();
|
2014-07-19 03:33:07 +02:00
|
|
|
writer.write(String.format("keyOsuRight = %s", Keyboard.getKeyName(getGameKeyRight())));
|
2014-07-18 05:58:37 +02:00
|
|
|
writer.newLine();
|
2014-07-03 00:24:19 +02:00
|
|
|
writer.write(String.format("DimLevel = %d", backgroundDim));
|
2014-06-30 04:17:04 +02:00
|
|
|
writer.newLine();
|
2014-07-03 07:05:23 +02:00
|
|
|
writer.write(String.format("ForceDefaultPlayfield = %b", forceDefaultPlayfield));
|
|
|
|
writer.newLine();
|
2014-07-04 22:41:52 +02:00
|
|
|
writer.write(String.format("IgnoreBeatmapSkins = %b", ignoreBeatmapSkins));
|
|
|
|
writer.newLine();
|
2014-06-30 04:17:04 +02:00
|
|
|
writer.write(String.format("HitLighting = %b", showHitLighting));
|
|
|
|
writer.newLine();
|
|
|
|
writer.write(String.format("ComboBurst = %b", showComboBursts));
|
|
|
|
writer.newLine();
|
2014-07-03 00:24:19 +02:00
|
|
|
writer.write(String.format("PerfectHit = %b", showPerfectHit));
|
2014-07-02 01:32:03 +02:00
|
|
|
writer.newLine();
|
2014-07-19 09:31:54 +02:00
|
|
|
writer.write(String.format(Locale.US, "FixedCS = %.1f", fixedCS));
|
2014-07-05 07:24:01 +02:00
|
|
|
writer.newLine();
|
2014-07-19 09:31:54 +02:00
|
|
|
writer.write(String.format(Locale.US, "FixedHP = %.1f", fixedHP));
|
2014-07-05 07:24:01 +02:00
|
|
|
writer.newLine();
|
2014-07-19 09:31:54 +02:00
|
|
|
writer.write(String.format(Locale.US, "FixedAR = %.1f", fixedAR));
|
2014-07-05 07:24:01 +02:00
|
|
|
writer.newLine();
|
2014-07-19 09:31:54 +02:00
|
|
|
writer.write(String.format(Locale.US, "FixedOD = %.1f", fixedOD));
|
2014-07-05 07:24:01 +02:00
|
|
|
writer.newLine();
|
2014-07-09 04:17:48 +02:00
|
|
|
writer.write(String.format("Checkpoint = %d", checkpoint));
|
|
|
|
writer.newLine();
|
2014-06-30 04:17:04 +02:00
|
|
|
writer.close();
|
|
|
|
} catch (IOException e) {
|
2014-07-02 07:53:42 +02:00
|
|
|
Log.error(String.format("Failed to write to file '%s'.", OPTIONS_FILE.getAbsolutePath()), e);
|
2014-06-30 04:17:04 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|