2014-06-30 04:17:04 +02:00
/ *
* opsu ! - an open - source osu ! client
2015-01-16 18:05:44 +01:00
* Copyright ( C ) 2014 , 2015 Jeffrey Han
2014-06-30 04:17:04 +02:00
*
* 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/>.
* /
2015-01-21 05:56:10 +01:00
package itdelatrisu.opsu ;
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 ;
2015-01-16 19:42:54 +01:00
import java.net.URI ;
import java.net.URISyntaxException ;
2014-06-30 04:17:04 +02:00
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-06-30 04:17:04 +02:00
import org.newdawn.slick.GameContainer ;
import org.newdawn.slick.Input ;
import org.newdawn.slick.SlickException ;
import org.newdawn.slick.util.Log ;
/ * *
2015-01-21 05:56:10 +01:00
* Handles all user options .
2014-06-30 04:17:04 +02:00
* /
2015-01-21 05:56:10 +01:00
public class Options {
2015-02-13 21:03:17 +01:00
/** The config directory. */
private static final File CONFIG_DIR = getXDGBaseDir ( " XDG_CONFIG_HOME " , " .config " ) ;
/** The data directory. */
private static final File DATA_DIR = getXDGBaseDir ( " XDG_DATA_HOME " , " .local/share " ) ;
2015-01-22 06:44:45 +01:00
/** File for logging errors. */
2015-02-13 21:03:17 +01:00
public static final File LOG_FILE = new File ( CONFIG_DIR , " .opsu.log " ) ;
2014-06-30 04:17:04 +02:00
2015-01-22 06:44:45 +01:00
/** File for storing user options. */
2015-02-13 21:03:17 +01:00
private static final File OPTIONS_FILE = new File ( CONFIG_DIR , " .opsu.cfg " ) ;
2014-07-02 07:53:42 +02:00
2015-01-22 06:44:45 +01:00
/** Beatmap directories (where to search for files). */
2014-06-30 04:17:04 +02:00
private static final String [ ] BEATMAP_DIRS = {
" C:/Program Files (x86)/osu!/Songs/ " ,
" C:/Program Files/osu!/Songs/ " ,
2015-02-13 21:03:17 +01:00
new File ( DATA_DIR , " Songs/ " ) . getPath ( )
2014-06-30 04:17:04 +02:00
} ;
2015-01-28 09:47:24 +01:00
/** Score database name. */
2015-02-13 21:03:17 +01:00
public static final File SCORE_DB = new File ( DATA_DIR , " .opsu_scores.db " ) ;
2015-01-28 09:47:24 +01:00
2015-01-22 06:44:45 +01:00
/** Font file name. */
2014-08-25 18:47:10 +02:00
public static final String FONT_NAME = " kochi-gothic.ttf " ;
2015-01-22 06:44:45 +01:00
/** Repository address. */
2015-01-16 19:42:54 +01:00
public static URI REPOSITORY_URI ;
2015-01-22 06:44:45 +01:00
/** Issue reporting address. */
2015-01-16 19:42:54 +01:00
public static URI ISSUES_URI ;
static {
try {
REPOSITORY_URI = new URI ( " https://github.com/itdelatrisu/opsu " ) ;
ISSUES_URI = new URI ( " https://github.com/itdelatrisu/opsu/issues/new " ) ;
} catch ( URISyntaxException e ) {
Log . error ( " Problem loading URIs. " , e ) ;
}
}
2015-01-22 06:44:45 +01:00
/** The beatmap directory. */
2014-06-30 04:17:04 +02:00
private static File beatmapDir ;
2015-01-22 06:44:45 +01:00
/** The OSZ archive directory. */
2014-07-06 07:58:44 +02:00
private static File oszDir ;
2015-01-22 06:44:45 +01:00
/** The screenshot directory (created when needed). */
2014-07-18 06:56:37 +02:00
private static File screenshotDir ;
2015-01-22 06:44:45 +01:00
/** The current skin directory (for user skins). */
2014-07-02 07:53:42 +02:00
private static File skinDir ;
2014-06-30 04:17:04 +02:00
2015-02-13 21:03:17 +01:00
/ * *
* Returns the directory based on the XDG base directory specification for
* Unix - like operating systems , only if the system property " XDG " has been defined .
* @param env the environment variable to check ( XDG_ * _ * )
* @param fallback the fallback directory relative to ~ home
* @return the XDG base directory , or the working directory if unavailable
* /
private static File getXDGBaseDir ( String env , String fallback ) {
if ( System . getProperty ( " XDG " ) = = null )
return new File ( " ./ " ) ;
String OS = System . getProperty ( " os.name " ) . toLowerCase ( ) ;
if ( OS . indexOf ( " nix " ) > = 0 | | OS . indexOf ( " nux " ) > = 0 | | OS . indexOf ( " aix " ) > 0 ) {
String rootPath = System . getenv ( env ) ;
if ( rootPath = = null ) {
String home = System . getProperty ( " user.home " ) ;
if ( home = = null )
return new File ( " ./ " ) ;
rootPath = String . format ( " %s/%s " , home , fallback ) ;
}
File dir = new File ( rootPath , " opsu " ) ;
if ( ! dir . isDirectory ( ) )
dir . mkdir ( ) ;
return dir ;
} else
return new File ( " ./ " ) ;
}
2014-12-21 03:35:18 +01:00
/ * *
* The theme song string :
2015-01-22 06:44:45 +01:00
* { @code filename , title , artist , length ( ms ) }
2014-12-21 03:35:18 +01:00
* /
2015-02-04 09:43:23 +01:00
private static String themeString = " theme.ogg,On the Bach,Jingle Punks,66000 " ;
2014-12-21 03:35:18 +01:00
2015-01-22 06:44:45 +01:00
/** Game options. */
public enum GameOption {
2015-01-11 19:05:32 +01:00
NULL ( null , null ) ,
2015-01-21 01:01:18 +01:00
SCREEN_RESOLUTION ( " Screen Resolution " , " Restart (Ctrl+Shift+F5) to apply resolution changes. " ) {
2015-01-11 19:05:32 +01:00
@Override
2015-01-15 07:52:16 +01:00
public String getValueString ( ) { return resolution . toString ( ) ; }
2015-01-11 19:05:32 +01:00
@Override
public void click ( GameContainer container ) {
do {
2015-01-15 07:52:16 +01:00
resolution = resolution . next ( ) ;
} while ( resolution ! = Resolution . RES_800_600 & &
( container . getScreenWidth ( ) < resolution . getWidth ( ) | |
container . getScreenHeight ( ) < resolution . getHeight ( ) ) ) ;
2015-01-11 19:05:32 +01:00
}
} ,
// FULLSCREEN ("Fullscreen Mode", "Restart to apply changes.") {
// @Override
// public String getValueString() { return fullscreen ? "Yes" : "No"; }
//
// @Override
// public void click(GameContainer container) { fullscreen = !fullscreen; }
// },
TARGET_FPS ( " Frame Limiter " , " Higher values may cause high CPU usage. " ) {
@Override
2015-01-15 07:52:16 +01:00
public String getValueString ( ) {
return String . format ( ( getTargetFPS ( ) = = 60 ) ? " %dfps (vsync) " : " %dfps " , getTargetFPS ( ) ) ;
}
2015-01-11 19:05:32 +01:00
@Override
public void click ( GameContainer container ) {
targetFPSindex = ( targetFPSindex + 1 ) % targetFPS . length ;
container . setTargetFrameRate ( getTargetFPS ( ) ) ;
2015-01-15 07:52:16 +01:00
container . setVSync ( getTargetFPS ( ) = = 60 ) ;
2015-01-11 19:05:32 +01:00
}
} ,
2015-01-20 20:52:02 +01:00
MASTER_VOLUME ( " Master Volume " , " Global volume level. " ) {
@Override
public String getValueString ( ) { return String . format ( " %d%% " , masterVolume ) ; }
@Override
public void drag ( GameContainer container , int d ) {
masterVolume = Utils . getBoundedValue ( masterVolume , d , 0 , 100 ) ;
container . setMusicVolume ( getMasterVolume ( ) * getMusicVolume ( ) ) ;
}
} ,
MUSIC_VOLUME ( " Music Volume " , " Volume of music. " ) {
2015-01-11 19:05:32 +01:00
@Override
public String getValueString ( ) { return String . format ( " %d%% " , musicVolume ) ; }
@Override
public void drag ( GameContainer container , int d ) {
musicVolume = Utils . getBoundedValue ( musicVolume , d , 0 , 100 ) ;
2015-01-20 20:52:02 +01:00
container . setMusicVolume ( getMasterVolume ( ) * getMusicVolume ( ) ) ;
2015-01-11 19:05:32 +01:00
}
} ,
EFFECT_VOLUME ( " Effect Volume " , " Volume of menu and game sounds. " ) {
@Override
public String getValueString ( ) { return String . format ( " %d%% " , effectVolume ) ; }
@Override
public void drag ( GameContainer container , int d ) { effectVolume = Utils . getBoundedValue ( effectVolume , d , 0 , 100 ) ; }
} ,
HITSOUND_VOLUME ( " Hit Sound Volume " , " Volume of hit sounds. " ) {
@Override
public String getValueString ( ) { return String . format ( " %d%% " , hitSoundVolume ) ; }
@Override
public void drag ( GameContainer container , int d ) { hitSoundVolume = Utils . getBoundedValue ( hitSoundVolume , d , 0 , 100 ) ; }
} ,
MUSIC_OFFSET ( " Music Offset " , " Adjust this value if hit objects are out of sync. " ) {
@Override
public String getValueString ( ) { return String . format ( " %dms " , musicOffset ) ; }
@Override
public void drag ( GameContainer container , int d ) { musicOffset = Utils . getBoundedValue ( musicOffset , d , - 500 , 500 ) ; }
} ,
SCREENSHOT_FORMAT ( " Screenshot Format " , " Press F12 to take a screenshot. " ) {
@Override
public String getValueString ( ) { return screenshotFormat [ screenshotFormatIndex ] . toUpperCase ( ) ; }
@Override
public void click ( GameContainer container ) { screenshotFormatIndex = ( screenshotFormatIndex + 1 ) % screenshotFormat . length ; }
} ,
SHOW_FPS ( " Show FPS Counter " , " Show an FPS counter in the bottom-right hand corner. " ) {
@Override
public String getValueString ( ) { return showFPS ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { showFPS = ! showFPS ; }
} ,
SHOW_HIT_LIGHTING ( " Show Hit Lighting " , " Adds an effect behind hit explosions. " ) {
@Override
public String getValueString ( ) { return showHitLighting ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { showHitLighting = ! showHitLighting ; }
} ,
SHOW_COMBO_BURSTS ( " Show Combo Bursts " , " A character image is displayed at combo milestones. " ) {
@Override
public String getValueString ( ) { return showComboBursts ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { showComboBursts = ! showComboBursts ; }
} ,
SHOW_PERFECT_HIT ( " Show Perfect Hits " , " Whether to show perfect hit result bursts (300s, slider ticks). " ) {
@Override
public String getValueString ( ) { return showPerfectHit ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { showPerfectHit = ! showPerfectHit ; }
} ,
NEW_CURSOR ( " Enable New Cursor " , " Use the new cursor style (may cause higher CPU usage). " ) {
@Override
public String getValueString ( ) { return newCursor ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) {
newCursor = ! newCursor ;
2015-01-25 04:23:49 +01:00
Utils . resetCursor ( ) ;
2015-01-11 19:05:32 +01:00
}
} ,
DYNAMIC_BACKGROUND ( " Enable Dynamic Backgrounds " , " The song background will be used as the main menu background. " ) {
@Override
public String getValueString ( ) { return dynamicBackground ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { dynamicBackground = ! dynamicBackground ; }
} ,
BACKGROUND_DIM ( " Background Dim " , " Percentage to dim the background image during gameplay. " ) {
@Override
public String getValueString ( ) { return String . format ( " %d%% " , backgroundDim ) ; }
@Override
public void drag ( GameContainer container , int d ) { backgroundDim = Utils . getBoundedValue ( backgroundDim , d , 0 , 100 ) ; }
} ,
FORCE_DEFAULT_PLAYFIELD ( " Force Default Playfield " , " Override the song background with the default playfield background. " ) {
@Override
public String getValueString ( ) { return forceDefaultPlayfield ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { forceDefaultPlayfield = ! forceDefaultPlayfield ; }
} ,
IGNORE_BEATMAP_SKINS ( " Ignore All Beatmap Skins " , " Never use skin element overrides provided by beatmaps. " ) {
@Override
public String getValueString ( ) { return ignoreBeatmapSkins ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { ignoreBeatmapSkins = ! ignoreBeatmapSkins ; }
} ,
FIXED_CS ( " Fixed Circle Size (CS) " , " Determines the size of circles and sliders. " ) {
@Override
public String getValueString ( ) { return ( fixedCS = = 0f ) ? " Disabled " : String . format ( " %.1f " , fixedCS ) ; }
@Override
public void drag ( GameContainer container , int d ) { fixedCS = Utils . getBoundedValue ( fixedCS , d / 10f , 0f , 10f ) ; }
} ,
FIXED_HP ( " Fixed HP Drain Rate (HP) " , " Determines the rate at which health decreases. " ) {
@Override
public String getValueString ( ) { return ( fixedHP = = 0f ) ? " Disabled " : String . format ( " %.1f " , fixedHP ) ; }
@Override
public void drag ( GameContainer container , int d ) { fixedHP = Utils . getBoundedValue ( fixedHP , d / 10f , 0f , 10f ) ; }
} ,
FIXED_AR ( " Fixed Approach Rate (AR) " , " Determines how long hit circles stay on the screen. " ) {
@Override
public String getValueString ( ) { return ( fixedAR = = 0f ) ? " Disabled " : String . format ( " %.1f " , fixedAR ) ; }
@Override
public void drag ( GameContainer container , int d ) { fixedAR = Utils . getBoundedValue ( fixedAR , d / 10f , 0f , 10f ) ; }
} ,
FIXED_OD ( " Fixed Overall Difficulty (OD) " , " Determines the time window for hit results. " ) {
@Override
public String getValueString ( ) { return ( fixedOD = = 0f ) ? " Disabled " : String . format ( " %.1f " , fixedOD ) ; }
@Override
public void drag ( GameContainer container , int d ) { fixedOD = Utils . getBoundedValue ( fixedOD , d / 10f , 0f , 10f ) ; }
} ,
LOAD_VERBOSE ( " Show Detailed Loading Progress " , " Display more specific loading information in the splash screen. " ) {
@Override
public String getValueString ( ) { return loadVerbose ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { loadVerbose = ! loadVerbose ; }
} ,
2015-01-21 01:01:18 +01:00
CHECKPOINT ( " Track Checkpoint " , " Press Ctrl+L while playing to load a checkpoint, and Ctrl+S to set one. " ) {
2015-01-11 19:05:32 +01:00
@Override
public String getValueString ( ) {
return ( checkpoint = = 0 ) ? " Disabled " : String . format ( " %02d:%02d " ,
TimeUnit . SECONDS . toMinutes ( checkpoint ) ,
checkpoint - TimeUnit . MINUTES . toSeconds ( TimeUnit . SECONDS . toMinutes ( checkpoint ) ) ) ;
}
@Override
public void drag ( GameContainer container , int d ) { checkpoint = Utils . getBoundedValue ( checkpoint , d , 0 , 3599 ) ; }
} ,
DISABLE_SOUNDS ( " Disable All Sound Effects " , " May resolve Linux sound driver issues. Requires a restart. " ) {
@Override
public String getValueString ( ) { return disableSound ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { disableSound = ! disableSound ; }
} ,
KEY_LEFT ( " Left Game Key " , " Select this option to input a key. " ) {
@Override
public String getValueString ( ) { return Keyboard . getKeyName ( getGameKeyLeft ( ) ) ; }
} ,
KEY_RIGHT ( " Right Game Key " , " Select this option to input a key. " ) {
@Override
public String getValueString ( ) { return Keyboard . getKeyName ( getGameKeyRight ( ) ) ; }
} ,
SHOW_UNICODE ( " Prefer Non-English Metadata " , " Where available, song titles will be shown in their native language. " ) {
@Override
public String getValueString ( ) { return showUnicode ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) {
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 ) ;
}
}
}
} ,
ENABLE_THEME_SONG ( " Enable Theme Song " , " Whether to play the theme song upon starting opsu! " ) {
@Override
public String getValueString ( ) { return themeSongEnabled ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { themeSongEnabled = ! themeSongEnabled ; }
2015-02-15 07:40:01 +01:00
} ,
2015-02-20 21:08:16 +01:00
SHOW_HIT_ERROR_BAR ( " Show Hit Error Bar " , " Shows precisely how accurate you were with each hit. " ) {
2015-02-15 07:40:01 +01:00
@Override
public String getValueString ( ) { return showHitErrorBar ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { showHitErrorBar = ! showHitErrorBar ; }
2015-03-03 04:12:57 +01:00
} ,
DISABLE_MOUSE_WHEEL ( " Disable mouse wheel in play mode " , " During play, you can use the mouse wheel to adjust the volume and pause the game. \ nThis will disable that functionality. " ) {
@Override
public String getValueString ( ) { return disableMouseWheel ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { disableMouseWheel = ! disableMouseWheel ; }
} ,
DISABLE_MOUSE_BUTTONS ( " Disable mouse buttons in play mode " , " This option will disable all mouse buttons. \ nSpecifically for people who use their keyboard to click. " ) {
@Override
public String getValueString ( ) { return disableMouseButtons ? " Yes " : " No " ; }
@Override
public void click ( GameContainer container ) { disableMouseButtons = ! disableMouseButtons ; }
2015-01-11 19:05:32 +01:00
} ;
2015-01-22 06:44:45 +01:00
/** Option name. */
2015-01-11 19:05:32 +01:00
private String name ;
2015-01-22 06:44:45 +01:00
/** Option description. */
2015-01-11 19:05:32 +01:00
private String description ;
/ * *
* Constructor .
* @param name the option name
* @param description the option description
* /
GameOption ( String name , String description ) {
this . name = name ;
this . description = description ;
}
/ * *
* Returns the option name .
* @return the name string
* /
public String getName ( ) { return name ; }
/ * *
* Returns the option description
* @return the description string
* /
public String getDescription ( ) { return description ; }
/ * *
* Returns the value of the option as a string ( via override ) .
* @return the value string
* /
public String getValueString ( ) { return " " ; }
/ * *
* Processes a mouse click action ( via override ) .
* @param container the game container
* /
public void click ( GameContainer container ) { }
/ * *
* Processes a mouse drag action ( via override ) .
* @param container the game container
* @param d the dragged distance ( modified by multiplier )
* /
public void drag ( GameContainer container , int d ) { }
2014-07-03 00:24:19 +02:00
} ;
2015-01-22 06:44:45 +01:00
/** Screen resolutions. */
2015-01-15 07:52:16 +01:00
private enum Resolution {
RES_800_600 ( 800 , 600 ) ,
RES_1024_600 ( 1024 , 600 ) ,
RES_1024_768 ( 1024 , 768 ) ,
2015-02-14 20:10:47 +01:00
RES_1280_720 ( 1280 , 720 ) ,
2015-01-15 07:52:16 +01:00
RES_1280_800 ( 1280 , 800 ) ,
RES_1280_960 ( 1280 , 960 ) ,
2015-02-14 20:10:47 +01:00
RES_1280_1024 ( 1280 , 1024 ) ,
2015-01-15 07:52:16 +01:00
RES_1366_768 ( 1366 , 768 ) ,
RES_1440_900 ( 1440 , 900 ) ,
RES_1600_900 ( 1600 , 900 ) ,
2015-02-10 03:40:38 +01:00
RES_1600_1200 ( 1600 , 1200 ) ,
2015-02-10 05:22:58 +01:00
RES_1680_1050 ( 1680 , 1050 ) ,
2015-01-15 07:52:16 +01:00
RES_1920_1080 ( 1920 , 1080 ) ,
RES_1920_1200 ( 1920 , 1200 ) ,
RES_2560_1440 ( 2560 , 1440 ) ,
2015-02-14 20:10:47 +01:00
RES_2560_1600 ( 2560 , 1600 ) ,
RES_3840_2160 ( 3840 , 2160 ) ;
2015-01-15 07:52:16 +01:00
2015-01-22 06:44:45 +01:00
/** Screen dimensions. */
2015-01-15 07:52:16 +01:00
private int width , height ;
2015-01-22 06:44:45 +01:00
/** Enum values. */
2015-01-15 07:52:16 +01:00
private static Resolution [ ] values = Resolution . values ( ) ;
/ * *
* Constructor .
* @param width the screen width
* @param height the screen height
* /
Resolution ( int width , int height ) {
this . width = width ;
this . height = height ;
}
/ * *
* Returns the screen width .
* /
public int getWidth ( ) { return width ; }
/ * *
* Returns the screen height .
* /
public int getHeight ( ) { return height ; }
/ * *
* Returns the next ( larger ) Resolution .
* /
public Resolution next ( ) { return values [ ( this . ordinal ( ) + 1 ) % values . length ] ; }
@Override
public String toString ( ) { return String . format ( " %sx%s " , width , height ) ; }
}
2014-06-30 04:17:04 +02:00
2015-01-22 06:44:45 +01:00
/** Current screen resolution. */
2015-01-16 19:42:54 +01:00
private static Resolution resolution = Resolution . RES_1024_768 ;
2014-06-30 04:17:04 +02:00
2015-01-22 06:44:45 +01:00
// /** Whether or not the game should run in fullscreen mode. */
2014-06-30 04:17:04 +02:00
// private static boolean fullscreen = false;
2015-01-22 06:44:45 +01:00
/** Frame limiters. */
2014-06-30 04:17:04 +02:00
private static final int [ ] targetFPS = { 60 , 120 , 240 } ;
2015-01-16 21:44:13 +01:00
2015-01-22 06:44:45 +01:00
/** Index in targetFPS[] array. */
2014-06-30 04:17:04 +02:00
private static int targetFPSindex = 0 ;
2015-01-22 06:44:45 +01:00
/** Whether or not to show the FPS. */
2015-02-22 04:27:16 +01:00
private static boolean showFPS = true ;
2014-06-30 04:17:04 +02:00
2015-01-22 06:44:45 +01:00
/** Whether or not to show hit lighting effects. */
2014-06-30 04:17:04 +02:00
private static boolean showHitLighting = true ;
2015-01-22 06:44:45 +01:00
/** Whether or not to show combo burst images. */
2014-06-30 04:17:04 +02:00
private static boolean showComboBursts = true ;
2015-01-22 06:44:45 +01:00
/** Global volume level. */
2015-01-20 20:52:02 +01:00
private static int masterVolume = 35 ;
2015-01-22 06:44:45 +01:00
/** Default music volume. */
2015-01-20 20:52:02 +01:00
private static int musicVolume = 80 ;
2014-07-01 07:14:03 +02:00
2015-01-22 06:44:45 +01:00
/** Default sound effect volume. */
2015-01-20 20:52:02 +01:00
private static int effectVolume = 70 ;
2014-06-30 04:17:04 +02:00
2015-01-22 06:44:45 +01:00
/** Default hit sound volume. */
2015-02-22 04:27:16 +01:00
private static int hitSoundVolume = 30 ;
2014-07-03 00:24:19 +02:00
2015-01-22 06:44:45 +01:00
/** Offset time, in milliseconds, for music position-related elements. */
2014-06-30 04:17:04 +02:00
private static int musicOffset = - 150 ;
2015-01-22 06:44:45 +01:00
/** Screenshot file formats. */
2014-06-30 04:17:04 +02:00
private static String [ ] screenshotFormat = { " png " , " jpg " , " bmp " } ;
2015-01-22 06:44:45 +01:00
/** Index in screenshotFormat[] array. */
2014-06-30 04:17:04 +02:00
private static int screenshotFormatIndex = 0 ;
2015-01-22 06:44:45 +01:00
/** Port binding. */
2014-07-02 01:32:03 +02:00
private static int port = 49250 ;
2014-06-30 18:37:37 +02:00
2015-01-22 06:44:45 +01:00
/** Whether or not to use the new cursor type. */
2014-07-02 01:32:03 +02:00
private static boolean newCursor = true ;
2014-06-30 04:17:04 +02:00
2015-01-22 06:44:45 +01:00
/** Whether or not dynamic backgrounds are enabled. */
2014-07-02 09:02:11 +02:00
private static boolean dynamicBackground = true ;
2015-01-22 06:44:45 +01:00
/** Whether or not to display perfect hit results. */
2014-07-03 00:24:19 +02:00
private static boolean showPerfectHit = true ;
2015-01-22 06:44:45 +01:00
/** Percentage to dim background images during gameplay. */
2015-02-22 04:27:16 +01:00
private static int backgroundDim = 50 ;
2014-07-03 00:24:19 +02:00
2015-01-22 06:44:45 +01:00
/** Whether or not to always display the default playfield background. */
2014-07-03 07:05:23 +02:00
private static boolean forceDefaultPlayfield = false ;
2015-01-22 06:44:45 +01:00
/** Whether or not to ignore resources in the beatmap folders. */
2014-07-04 22:41:52 +02:00
private static boolean ignoreBeatmapSkins = false ;
2015-01-22 06:44:45 +01:00
/** Whether or not to play the theme song. */
2014-12-21 00:17:04 +01:00
private static boolean themeSongEnabled = true ;
2015-02-15 07:40:01 +01:00
/** Whether or not to show the hit error bar. */
private static boolean showHitErrorBar = false ;
2015-03-03 04:12:57 +01:00
/** Whether or not to disable the mouse wheel during gameplay. */
private static boolean disableMouseWheel = false ;
/** Whether or not to disable the mouse buttons during gameplay. */
private static boolean disableMouseButtons = false ;
2015-01-22 06:44:45 +01:00
/** Fixed difficulty overrides. */
2014-07-05 07:24:01 +02:00
private static float
fixedCS = 0f , fixedHP = 0f ,
fixedAR = 0f , fixedOD = 0f ;
2015-01-22 06:44:45 +01:00
/** Whether or not to display the files being loaded in the splash screen. */
2014-07-15 19:21:37 +02:00
private static boolean loadVerbose = false ;
2014-07-06 03:00:52 +02:00
2015-01-22 06:44:45 +01:00
/** Track checkpoint time, in seconds. */
2014-07-09 04:17:48 +02:00
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 ) ;
2015-01-22 06:44:45 +01:00
/** Whether or not to display non-English metadata. */
2014-08-25 05:48:52 +02:00
private static boolean showUnicode = false ;
2015-01-22 06:44:45 +01:00
/** Left and right game keys. */
2014-07-18 05:58:37 +02:00
private static int
keyLeft = Keyboard . KEY_NONE ,
keyRight = Keyboard . KEY_NONE ;
2015-01-21 05:56:10 +01:00
// This class should not be instantiated.
private Options ( ) { }
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
2015-01-20 20:52:02 +01:00
/ * *
* Returns the master volume level .
* @return the volume [ 0 , 1 ]
* /
public static float getMasterVolume ( ) { return masterVolume / 100f ; }
/ * *
* Sets the master volume level ( if within valid range ) .
* @param container the game container
* @param volume the volume [ 0 , 1 ]
* /
public static void setMasterVolume ( GameContainer container , float volume ) {
if ( volume > = 0f & & volume < = 1f ) {
masterVolume = ( int ) ( volume * 100f ) ;
container . setMusicVolume ( getMasterVolume ( ) * getMusicVolume ( ) ) ;
}
}
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
* /
2015-01-22 00:56:53 +01:00
public static void setDisplayMode ( Container app ) {
2014-07-11 02:35:07 +02:00
int screenWidth = app . getScreenWidth ( ) ;
int screenHeight = app . getScreenHeight ( ) ;
2015-01-18 21:26:00 +01:00
2015-01-15 07:52:16 +01:00
// check for larger-than-screen dimensions
if ( screenWidth < resolution . getWidth ( ) | | screenHeight < resolution . getHeight ( ) )
resolution = Resolution . RES_800_600 ;
2015-01-22 00:56:53 +01:00
try {
app . setDisplayMode ( resolution . getWidth ( ) , resolution . getHeight ( ) , false ) ;
} catch ( SlickException e ) {
ErrorHandler . error ( " Failed to set display mode. " , e , true ) ;
}
2015-01-15 07:52:16 +01:00
// set borderless window if dimensions match screen size
2015-01-21 01:01:18 +01:00
boolean borderless = ( screenWidth = = resolution . getWidth ( ) & & screenHeight = = resolution . getHeight ( ) ) ;
System . setProperty ( " org.lwjgl.opengl.Window.undecorated " , Boolean . toString ( borderless ) ) ;
2014-07-11 02:35:07 +02:00
}
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-12-21 00:17:04 +01:00
/ * *
* Returns whether or not to play the theme song .
* @return true if enabled
* /
2015-02-15 07:40:01 +01:00
public static boolean isThemeSongEnabled ( ) { return themeSongEnabled ; }
2014-12-21 00:17:04 +01:00
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 ;
}
2015-02-15 07:40:01 +01:00
/ * *
* Returns whether or not to show the hit error bar .
* @return true if enabled
* /
public static boolean isHitErrorBarEnabled ( ) { return showHitErrorBar ; }
2015-03-03 04:12:57 +01:00
/ * *
* Returns whether or not the mouse wheel is disabled during gameplay .
* @return true if disabled
* /
public static boolean isMouseWheelDisabled ( ) { return disableMouseWheel ; }
/ * *
* Returns whether or not the mouse buttons are disabled during gameplay .
* @return true if disabled
* /
public static boolean isMouseDisabled ( ) { return disableMouseButtons ; }
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 ;
}
2015-01-21 05:56:10 +01:00
/ * *
* Sets the left game key .
* @param key the keyboard key
* /
public static void setGameKeyLeft ( int key ) { keyLeft = key ; }
/ * *
* Sets the right game key .
* @param key the keyboard key
* /
public static void setGameKeyRight ( int key ) { keyRight = key ; }
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 ;
2015-02-13 21:03:17 +01:00
oszDir = new File ( DATA_DIR , " SongPacks/ " ) ;
2014-07-15 06:20:36 +02:00
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 ;
2015-02-13 21:03:17 +01:00
screenshotDir = new File ( DATA_DIR , " Screenshots/ " ) ;
2014-07-18 06:56:37 +02:00
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 ;
2015-02-13 21:03:17 +01:00
skinDir = new File ( DATA_DIR , " Skins/ " ) ;
2014-07-02 07:53:42 +02:00
skinDir . mkdir ( ) ;
return skinDir ;
}
2014-07-02 01:32:03 +02:00
2014-12-21 03:35:18 +01:00
/ * *
* Returns a dummy OsuFile containing the theme song .
* @return the theme song OsuFile
* /
public static OsuFile getOsuTheme ( ) {
String [ ] tokens = themeString . split ( " , " ) ;
if ( tokens . length ! = 4 ) {
2015-01-16 03:55:26 +01:00
ErrorHandler . error ( " Theme song string is malformed. " , null , false ) ;
2014-12-21 03:35:18 +01:00
return null ;
}
OsuFile osu = new OsuFile ( null ) ;
osu . audioFilename = new File ( tokens [ 0 ] ) ;
osu . title = tokens [ 1 ] ;
osu . artist = tokens [ 2 ] ;
try {
osu . endTime = Integer . parseInt ( tokens [ 3 ] ) ;
} catch ( NumberFormatException e ) {
2015-01-16 03:55:26 +01:00
ErrorHandler . error ( " Theme song length is not a valid integer " , e , false ) ;
2014-12-21 03:35:18 +01:00
return null ;
}
return osu ;
}
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-12-21 03:35:18 +01:00
case " ThemeSong " :
themeString = 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 " :
2015-01-15 07:52:16 +01:00
try {
Resolution res = Resolution . valueOf ( String . format ( " RES_%s " , value . replace ( 'x' , '_' ) ) ) ;
resolution = res ;
} catch ( IllegalArgumentException e ) { }
2014-06-30 04:17:04 +02:00
break ;
// case "Fullscreen":
// fullscreen = Boolean.parseBoolean(value);
// break;
case " FrameSync " :
i = Integer . parseInt ( value ) ;
2015-01-15 07:52:16 +01:00
for ( int j = 0 ; j < targetFPS . length ; j + + ) {
if ( i = = targetFPS [ j ] )
targetFPSindex = j ;
}
2014-06-30 04:17:04 +02:00
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 ;
2015-01-20 20:52:02 +01:00
case " VolumeUniversal " :
i = Integer . parseInt ( value ) ;
if ( i > = 0 & & i < = 100 )
masterVolume = i ;
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 ;
2015-03-03 04:12:57 +01:00
case " MouseDisableWheel " :
disableMouseWheel = Boolean . parseBoolean ( value ) ;
break ;
case " MouseDisableButtons " :
disableMouseButtons = Boolean . parseBoolean ( value ) ;
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 ;
2015-02-20 21:08:16 +01:00
case " ScoreMeter " :
2015-02-15 07:40:01 +01:00
showHitErrorBar = Boolean . parseBoolean ( value ) ;
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-12-21 00:17:04 +01:00
case " MenuMusic " :
themeSongEnabled = Boolean . parseBoolean ( value ) ;
break ;
2014-06-30 04:17:04 +02:00
}
}
} catch ( IOException e ) {
2015-01-16 03:55:26 +01:00
ErrorHandler . error ( String . format ( " Failed to read file '%s'. " , OPTIONS_FILE . getAbsolutePath ( ) ) , e , false ) ;
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-12-21 03:35:18 +01:00
writer . write ( String . format ( " ThemeSong = %s " , themeString ) ) ;
writer . newLine ( ) ;
2014-07-03 00:24:19 +02:00
writer . write ( String . format ( " Port = %d " , port ) ) ;
writer . newLine ( ) ;
2015-01-15 07:52:16 +01:00
writer . write ( String . format ( " ScreenResolution = %s " , resolution . toString ( ) ) ) ;
2014-06-30 04:17:04 +02:00
writer . newLine ( ) ;
// writer.write(String.format("Fullscreen = %b", fullscreen));
// writer.newLine();
2015-01-15 07:52:16 +01:00
writer . write ( String . format ( " FrameSync = %d " , targetFPS [ targetFPSindex ] ) ) ;
2014-06-30 04:17:04 +02:00
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 ( ) ;
2015-01-20 20:52:02 +01:00
writer . write ( String . format ( " VolumeUniversal = %d " , masterVolume ) ) ;
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 ( ) ;
2015-03-03 04:12:57 +01:00
writer . write ( String . format ( " MouseDisableWheel = %b " , disableMouseWheel ) ) ;
writer . newLine ( ) ;
writer . write ( String . format ( " MouseDisableButtons = %b " , disableMouseButtons ) ) ;
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 ( ) ;
2015-02-20 21:08:16 +01:00
writer . write ( String . format ( " ScoreMeter = %b " , showHitErrorBar ) ) ;
2015-02-15 07:40:01 +01: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-12-21 00:17:04 +01:00
writer . write ( String . format ( " MenuMusic = %b " , themeSongEnabled ) ) ;
writer . newLine ( ) ;
2014-06-30 04:17:04 +02:00
writer . close ( ) ;
} catch ( IOException e ) {
2015-01-16 03:55:26 +01:00
ErrorHandler . error ( String . format ( " Failed to write to file '%s'. " , OPTIONS_FILE . getAbsolutePath ( ) ) , e , false ) ;
2014-06-30 04:17:04 +02:00
}
}
}