Merge branch 'master' into replaystuff
# Conflicts: # src/itdelatrisu/opsu/states/Game.java
This commit is contained in:
@@ -20,36 +20,31 @@ package yugecin.opsudance.options;
|
||||
import com.sun.jna.platform.win32.Advapi32Util;
|
||||
import com.sun.jna.platform.win32.Win32Exception;
|
||||
import com.sun.jna.platform.win32.WinReg;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
import itdelatrisu.opsu.beatmap.Beatmap;
|
||||
import itdelatrisu.opsu.beatmap.TimingPoint;
|
||||
import itdelatrisu.opsu.ui.Colors;
|
||||
import org.lwjgl.BufferUtils;
|
||||
import org.lwjgl.opengl.Display;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import yugecin.opsudance.core.errorhandling.ErrorHandler;
|
||||
import yugecin.opsudance.core.events.EventBus;
|
||||
import yugecin.opsudance.core.inject.Inject;
|
||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
||||
import org.newdawn.slick.util.Log;
|
||||
import yugecin.opsudance.events.BubNotifListener;
|
||||
import yugecin.opsudance.utils.ManifestWrapper;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static yugecin.opsudance.core.errorhandling.ErrorHandler.*;
|
||||
import static yugecin.opsudance.options.Options.*;
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
||||
public class Configuration {
|
||||
|
||||
@@ -67,13 +62,6 @@ public class Configuration {
|
||||
public final File LOG_FILE;
|
||||
public final File OPTIONS_FILE;
|
||||
|
||||
public final String FONT_NAME;
|
||||
public final String VERSION_FILE;
|
||||
public final URI REPOSITORY_URI;
|
||||
public final URI DANCE_REPOSITORY_URI;
|
||||
public final String ISSUES_URL;
|
||||
public final String VERSION_REMOTE;
|
||||
|
||||
public final File osuInstallationDirectory;
|
||||
|
||||
public final Beatmap themeBeatmap;
|
||||
@@ -85,9 +73,8 @@ public class Configuration {
|
||||
public File replayImportDir;
|
||||
public File skinRootDir;
|
||||
|
||||
@Inject
|
||||
public Configuration() {
|
||||
USE_XDG = areXDGDirectoriesEnabled();
|
||||
public Configuration(ManifestWrapper jarmanifest) {
|
||||
USE_XDG = jarmanifest.valueOrDefault(null, "Use-XDG", "").equalsIgnoreCase("true");
|
||||
|
||||
CONFIG_DIR = getXDGBaseDir("XDG_CONFIG_HOME", ".config");
|
||||
DATA_DIR = getXDGBaseDir("XDG_DATA_HOME", ".local/share");
|
||||
@@ -103,13 +90,6 @@ public class Configuration {
|
||||
LOG_FILE = new File(CONFIG_DIR, ".opsu.log");
|
||||
OPTIONS_FILE = new File(CONFIG_DIR, ".opsu.cfg");
|
||||
|
||||
FONT_NAME = "DroidSansFallback.ttf";
|
||||
VERSION_FILE = "version";
|
||||
REPOSITORY_URI = URI.create("https://github.com/itdelatrisu/opsu");
|
||||
DANCE_REPOSITORY_URI = URI.create("https://github.com/yugecin/opsu-dance");
|
||||
ISSUES_URL = "https://github.com/yugecin/opsu-dance/issues/new?title=%s&body=%s";
|
||||
VERSION_REMOTE = "https://raw.githubusercontent.com/yugecin/opsu-dance/master/version";
|
||||
|
||||
osuInstallationDirectory = loadOsuInstallationDirectory();
|
||||
|
||||
themeBeatmap = createThemeBeatmap();
|
||||
@@ -117,14 +97,14 @@ public class Configuration {
|
||||
|
||||
private Beatmap createThemeBeatmap() {
|
||||
try {
|
||||
String[] tokens = {"theme.mp3", "Rainbows", "Kevin MacLeod", "219350"};
|
||||
String[] tokens = {"theme.ogg", "On the Bach", "Jingle Punks", "66000"};
|
||||
Beatmap beatmap = new Beatmap(null);
|
||||
beatmap.audioFilename = new File(tokens[0]);
|
||||
beatmap.title = tokens[1];
|
||||
beatmap.artist = tokens[2];
|
||||
beatmap.endTime = Integer.parseInt(tokens[3]);
|
||||
beatmap.timingPoints = new ArrayList<>(1);
|
||||
beatmap.timingPoints.add(new TimingPoint("1080,545.454545454545,4,1,0,100,0,0"));
|
||||
beatmap.timingPoints.add(new TimingPoint("-44,631.578947368421,4,1,0,100,1,0"));
|
||||
return beatmap;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
@@ -170,12 +150,12 @@ public class Configuration {
|
||||
}
|
||||
|
||||
private File loadDirectory(File dir, File defaultDir, String kind) {
|
||||
if (dir.exists() && dir.isDirectory()) {
|
||||
if (dir != null && dir.exists() && dir.isDirectory()) {
|
||||
return dir;
|
||||
}
|
||||
if (!defaultDir.isDirectory() && !defaultDir.mkdir()) {
|
||||
String msg = String.format("Failed to create %s directory at '%s'.", kind, defaultDir.getAbsolutePath());
|
||||
EventBus.post(new BubbleNotificationEvent(msg, BubbleNotificationEvent.COMMONCOLOR_RED));
|
||||
BubNotifListener.EVENT.make().onBubNotif(msg, Colors.BUB_RED);
|
||||
}
|
||||
return defaultDir;
|
||||
}
|
||||
@@ -195,49 +175,24 @@ public class Configuration {
|
||||
return loadDirectory(dir, defaultDir, kind);
|
||||
}
|
||||
|
||||
private boolean areXDGDirectoriesEnabled() {
|
||||
JarFile jarFile = Utils.getJarFile();
|
||||
if (jarFile == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Manifest manifest = jarFile.getManifest();
|
||||
if (manifest == null) {
|
||||
return false;
|
||||
}
|
||||
Attributes attributes = manifest.getMainAttributes();
|
||||
String value = attributes.getValue("Use-XDG");
|
||||
return (value != null && value.equalsIgnoreCase("true"));
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the directory based on the XDG base directory specification for
|
||||
* Unix-like operating systems, only if the "XDG" flag is enabled.
|
||||
* @param env the environment variable to check (XDG_*_*)
|
||||
* @param envvar 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 File getXDGBaseDir(String env, String fallback) {
|
||||
File workingdir;
|
||||
if (Utils.isJarRunning()) {
|
||||
workingdir = Utils.getRunningDirectory().getParentFile();
|
||||
} else {
|
||||
workingdir = Paths.get(".").toAbsolutePath().normalize().toFile();
|
||||
}
|
||||
|
||||
private File getXDGBaseDir(String envvar, String fallback) {
|
||||
if (!USE_XDG) {
|
||||
return workingdir;
|
||||
return env.workingdir;
|
||||
}
|
||||
|
||||
String OS = System.getProperty("os.name").toLowerCase();
|
||||
if (OS.indexOf("nix") == -1 && OS.indexOf("nux") == -1 && OS.indexOf("aix") == -1){
|
||||
return workingdir;
|
||||
return env.workingdir;
|
||||
}
|
||||
|
||||
String rootPath = System.getenv(env);
|
||||
String rootPath = System.getenv(envvar);
|
||||
if (rootPath == null) {
|
||||
String home = System.getProperty("user.home");
|
||||
if (home == null) {
|
||||
@@ -247,7 +202,8 @@ public class Configuration {
|
||||
}
|
||||
File dir = new File(rootPath, "opsu");
|
||||
if (!dir.isDirectory() && !dir.mkdir()) {
|
||||
ErrorHandler.error(String.format("Failed to create configuration folder at '%s/opsu'.", rootPath), new Exception("empty")).preventReport().show();
|
||||
explode(String.format("Failed to create configuration folder at '%s/opsu'.", rootPath),
|
||||
new Exception("empty"), PREVENT_REPORT);
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
@@ -259,7 +215,9 @@ public class Configuration {
|
||||
// TODO: get a decent place for this
|
||||
// create the screenshot directory
|
||||
if (!screenshotDir.isDirectory() && !screenshotDir.mkdir()) {
|
||||
EventBus.post(new BubbleNotificationEvent(String.format("Failed to create screenshot directory at '%s'.", screenshotDir.getAbsolutePath()), BubbleNotificationEvent.COMMONCOLOR_RED));
|
||||
BubNotifListener.EVENT.make().onBubNotif(
|
||||
String.format( "Failed to create screenshot directory at '%s'.",
|
||||
screenshotDir.getAbsolutePath()), Colors.BUB_RED);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -293,9 +251,13 @@ public class Configuration {
|
||||
}
|
||||
}
|
||||
ImageIO.write(image, OPTION_SCREENSHOT_FORMAT.getValueString().toLowerCase(), file);
|
||||
EventBus.post(new BubbleNotificationEvent("Created " + fileName, BubbleNotificationEvent.COMMONCOLOR_PURPLE));
|
||||
BubNotifListener.EVENT.make().onBubNotif("Created " + fileName,
|
||||
Colors.BUB_PURPLE);
|
||||
} catch (Exception e) {
|
||||
ErrorHandler.error("Failed to take a screenshot.", e).show();
|
||||
Log.error("Could not take screenshot", e);
|
||||
BubNotifListener.EVENT.make().onBubNotif(
|
||||
"Failed to take a screenshot. See log file for details",
|
||||
Colors.BUB_PURPLE);
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
package yugecin.opsudance.options;
|
||||
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import yugecin.opsudance.core.events.EventBus;
|
||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
||||
import itdelatrisu.opsu.ui.Colors;
|
||||
import yugecin.opsudance.events.BubNotifListener;
|
||||
|
||||
public class NumericOption extends Option {
|
||||
|
||||
@@ -53,7 +53,8 @@ public class NumericOption extends Option {
|
||||
try {
|
||||
val = Utils.clamp(Integer.parseInt(s), min, max);
|
||||
} catch (Exception ignored) {
|
||||
EventBus.post(new BubbleNotificationEvent("Failed to parse " + configurationName + " option", BubbleNotificationEvent.COMMONCOLOR_RED));
|
||||
BubNotifListener.EVENT.make().onBubNotif("Failed to parse " + configurationName + " option",
|
||||
Colors.BUB_RED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,22 +17,10 @@
|
||||
*/
|
||||
package yugecin.opsudance.options;
|
||||
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
import yugecin.opsudance.core.inject.InstanceContainer;
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
||||
public class Option {
|
||||
|
||||
// keep a reference to the instancecontainer so that not every option instance needs to be injected
|
||||
protected static InstanceContainer instanceContainer;
|
||||
// caching some commonly used classes
|
||||
protected static Configuration config;
|
||||
protected static DisplayContainer displayContainer;
|
||||
public static void setInstanceContainer(InstanceContainer instanceContainer) {
|
||||
Option.instanceContainer = instanceContainer;
|
||||
Option.config = instanceContainer.provide(Configuration.class);
|
||||
Option.displayContainer = instanceContainer.provide(DisplayContainer.class);
|
||||
}
|
||||
|
||||
public final String name;
|
||||
public final String configurationName;
|
||||
public final String description;
|
||||
@@ -54,7 +42,7 @@ public class Option {
|
||||
this.name = name;
|
||||
this.configurationName = configurationName;
|
||||
this.description = description;
|
||||
OptionsService.registerOption(this);
|
||||
optionservice.registerOption(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,6 +78,10 @@ public class Option {
|
||||
return filtered;
|
||||
}
|
||||
|
||||
public void setFiltered(boolean flag) {
|
||||
this.filtered = flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this option should be filtered (= not shown) because it does not
|
||||
* match the search string.
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
|
||||
package yugecin.opsudance.options;
|
||||
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
|
||||
import static yugecin.opsudance.options.Options.*;
|
||||
|
||||
public class OptionGroups {
|
||||
|
||||
public static final OptionTab[] normalOptions = new OptionTab[] {
|
||||
new OptionTab("GENERAL", null),
|
||||
new OptionTab("General", GameImage.MENU_NAV_GENERAL),
|
||||
new OptionTab("GENERAL", new Option[]{
|
||||
OPTION_DISABLE_UPDATER,
|
||||
OPTION_ENABLE_WATCH_SERVICE
|
||||
@@ -31,7 +33,7 @@ public class OptionGroups {
|
||||
new OptionTab("LANGUAGE", new Option[]{
|
||||
OPTION_SHOW_UNICODE,
|
||||
}),
|
||||
new OptionTab("GRAPHICS", null),
|
||||
new OptionTab("Graphics", GameImage.MENU_NAV_GRAPHICS),
|
||||
new OptionTab("RENDERER", new Option[] {
|
||||
OPTION_SCREEN_RESOLUTION,
|
||||
OPTION_ALLOW_LARGER_RESOLUTIONS,
|
||||
@@ -54,7 +56,7 @@ public class OptionGroups {
|
||||
OPTION_DANCING_CIRCLES,
|
||||
OPTION_DANCING_CIRCLES_MULTIPLIER,
|
||||
}),
|
||||
new OptionTab("SKIN", null),
|
||||
new OptionTab("Skin", GameImage.MENU_NAV_SKIN),
|
||||
new OptionTab("SKIN", new Option[]{
|
||||
OPTION_SKIN,
|
||||
OPTION_IGNORE_BEATMAP_SKINS,
|
||||
@@ -69,7 +71,7 @@ public class OptionGroups {
|
||||
OPTION_DISABLE_CURSOR
|
||||
// TODO use combo colour as tint for slider ball option
|
||||
}),
|
||||
new OptionTab("AUDIO", null),
|
||||
new OptionTab("Audio", GameImage.MENU_NAV_AUDIO),
|
||||
new OptionTab("VOLUME", new Option[]{
|
||||
OPTION_MASTER_VOLUME,
|
||||
OPTION_MUSIC_VOLUME,
|
||||
@@ -82,7 +84,7 @@ public class OptionGroups {
|
||||
OPTION_DISABLE_SOUNDS,
|
||||
OPTION_ENABLE_THEME_SONG
|
||||
}),
|
||||
new OptionTab("GAMEPLAY", null),
|
||||
new OptionTab("Gameplay", GameImage.MENU_NAV_GAMEPLAY),
|
||||
new OptionTab("GENERAL", new Option[] {
|
||||
OPTION_BACKGROUND_DIM,
|
||||
OPTION_FORCE_DEFAULT_PLAYFIELD,
|
||||
@@ -96,7 +98,7 @@ public class OptionGroups {
|
||||
OPTION_MAP_END_DELAY,
|
||||
OPTION_EPILEPSY_WARNING,
|
||||
}),
|
||||
new OptionTab("INPUT", null),
|
||||
new OptionTab("Input", GameImage.MENU_NAV_INPUT),
|
||||
new OptionTab("KEY MAPPING", new Option[]{
|
||||
OPTION_KEY_LEFT,
|
||||
OPTION_KEY_RIGHT,
|
||||
@@ -105,7 +107,7 @@ public class OptionGroups {
|
||||
OPTION_DISABLE_MOUSE_WHEEL,
|
||||
OPTION_DISABLE_MOUSE_BUTTONS,
|
||||
}),
|
||||
new OptionTab("CUSTOM", null),
|
||||
new OptionTab("Custom", GameImage.MENU_NAV_CUSTOM),
|
||||
new OptionTab("DIFFICULTY", new Option[]{
|
||||
OPTION_FIXED_CS,
|
||||
OPTION_FIXED_HP,
|
||||
@@ -116,7 +118,7 @@ public class OptionGroups {
|
||||
OPTION_CHECKPOINT,
|
||||
OPTION_REPLAY_SEEKING,
|
||||
}),
|
||||
new OptionTab("DANCE", null),
|
||||
new OptionTab("Dance", GameImage.MENU_NAV_DANCE),
|
||||
new OptionTab("MOVER", new Option[]{
|
||||
OPTION_DANCE_MOVER,
|
||||
OPTION_DANCE_EXGON_DELAY,
|
||||
@@ -143,7 +145,7 @@ public class OptionGroups {
|
||||
new OptionTab("MIRROR", new Option[] {
|
||||
OPTION_DANCE_MIRROR,
|
||||
}),
|
||||
new OptionTab("ADVANCED DISPLAY", null),
|
||||
new OptionTab("Advanced Display", GameImage.MENU_NAV_ADVANCED),
|
||||
new OptionTab("OBJECTS", new Option[]{
|
||||
OPTION_DANCE_DRAW_APPROACH,
|
||||
OPTION_DANCE_OBJECT_COLOR_OVERRIDE,
|
||||
@@ -163,7 +165,7 @@ public class OptionGroups {
|
||||
OPTION_DANCE_REMOVE_BG,
|
||||
OPTION_DANCE_ENABLE_SB,
|
||||
}),
|
||||
new OptionTab ("PIPPI", null),
|
||||
new OptionTab ("Pippi", GameImage.MENU_NAV_PIPPI),
|
||||
new OptionTab ("GENERAL", new Option[]{
|
||||
OPTION_PIPPI_ENABLE,
|
||||
OPTION_PIPPI_RADIUS_PERCENT,
|
||||
|
||||
@@ -17,15 +17,25 @@
|
||||
*/
|
||||
package yugecin.opsudance.options;
|
||||
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
|
||||
public class OptionTab {
|
||||
|
||||
public final String name;
|
||||
public final Option[] options;
|
||||
public final GameImage icon;
|
||||
public boolean filtered;
|
||||
|
||||
public OptionTab(String name, GameImage icon) {
|
||||
this.name = name;
|
||||
this.icon = icon;
|
||||
this.options = null;
|
||||
}
|
||||
|
||||
public OptionTab(String name, Option[] options) {
|
||||
this.name = name;
|
||||
this.options = options;
|
||||
this.icon = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,118 +23,101 @@ import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.states.Game;
|
||||
import itdelatrisu.opsu.ui.Fonts;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.newdawn.slick.Input;
|
||||
import org.newdawn.slick.SlickException;
|
||||
import org.newdawn.slick.openal.SoundStore;
|
||||
import org.newdawn.slick.util.Log;
|
||||
import yugecin.opsudance.*;
|
||||
import yugecin.opsudance.core.events.EventBus;
|
||||
import yugecin.opsudance.core.events.EventListener;
|
||||
import yugecin.opsudance.events.BarNotificationEvent;
|
||||
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
|
||||
import yugecin.opsudance.events.BarNotifListener;
|
||||
import yugecin.opsudance.movers.factories.ExgonMoverFactory;
|
||||
import yugecin.opsudance.movers.factories.QuadraticBezierMoverFactory;
|
||||
import yugecin.opsudance.movers.slidermovers.DefaultSliderMoverController;
|
||||
import yugecin.opsudance.skinning.SkinService;
|
||||
import yugecin.opsudance.utils.CachedVariable;
|
||||
import yugecin.opsudance.utils.CachedVariable.Getter;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
||||
/**
|
||||
* @author itdelatrisu (https://github.com/itdelatrisu) most functions are copied from itdelatrisu.opsu.Options.java
|
||||
*/
|
||||
public class Options {
|
||||
|
||||
// TODO remove this?
|
||||
public static int width;
|
||||
public static int height;
|
||||
|
||||
static {
|
||||
EventBus.subscribe(ResolutionOrSkinChangedEvent.class, new EventListener<ResolutionOrSkinChangedEvent>() {
|
||||
@Override
|
||||
public void onEvent(ResolutionOrSkinChangedEvent event) {
|
||||
if (event.width > 0) {
|
||||
width = event.width;
|
||||
height = event.height;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// internal options (not displayed in-game)
|
||||
public static final Option OPTION_BEATMAP_DIRECTORY = new Option("BeatmapDirectory") {
|
||||
@Override
|
||||
public String write() {
|
||||
return config.BEATMAP_DIR.getAbsolutePath();
|
||||
}
|
||||
static {
|
||||
new Option("BeatmapDirectory") {
|
||||
@Override
|
||||
public String write() {
|
||||
return config.BEATMAP_DIR.getAbsolutePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(String s) {
|
||||
config.beatmapDir = new File(s);
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void read(String s) {
|
||||
config.beatmapDir = new File(s);
|
||||
}
|
||||
};
|
||||
|
||||
public static final Option OPTION_OSZ_DIRECTORY = new Option("OSZDirectory") {
|
||||
@Override
|
||||
public String write() {
|
||||
return config.oszDir.getAbsolutePath();
|
||||
}
|
||||
new Option("OSZDirectory") {
|
||||
@Override
|
||||
public String write() {
|
||||
return config.oszDir.getAbsolutePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(String s) {
|
||||
config.oszDir = new File(s);
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void read(String s) {
|
||||
config.oszDir = new File(s);
|
||||
}
|
||||
};
|
||||
|
||||
public static final Option OPTION_SCREENSHOT_DIRECTORY = new Option("ScreenshotDirectory") {
|
||||
@Override
|
||||
public String write() {
|
||||
return config.screenshotDir.getAbsolutePath();
|
||||
}
|
||||
new Option("ScreenshotDirectory") {
|
||||
@Override
|
||||
public String write() {
|
||||
return config.screenshotDir.getAbsolutePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(String s) {
|
||||
config.screenshotDir = new File(s);
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void read(String s) {
|
||||
config.screenshotDir = new File(s);
|
||||
}
|
||||
};
|
||||
|
||||
public static final Option OPTION_REPLAY_DIRECTORY = new Option("ReplayDirectory") {
|
||||
@Override
|
||||
public String write() {
|
||||
return config.replayDir.getAbsolutePath();
|
||||
}
|
||||
new Option("ReplayDirectory") {
|
||||
@Override
|
||||
public String write() {
|
||||
return config.replayDir.getAbsolutePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(String s) {
|
||||
config.replayDir = new File(s);
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void read(String s) {
|
||||
config.replayDir = new File(s);
|
||||
}
|
||||
};
|
||||
|
||||
public static final Option OPTION_REPLAY_IMPORT_DIRECTORY = new Option("ReplayImportDirectory") {
|
||||
@Override
|
||||
public String write() {
|
||||
return config.replayImportDir.getAbsolutePath();
|
||||
}
|
||||
new Option("ReplayImportDirectory") {
|
||||
@Override
|
||||
public String write() {
|
||||
return config.replayImportDir.getAbsolutePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(String s) {
|
||||
config.replayImportDir = new File(s);
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void read(String s) {
|
||||
config.replayImportDir = new File(s);
|
||||
}
|
||||
};
|
||||
|
||||
public static final Option OPTION_SKIN_DIRECTORY = new Option("SkinDirectory") {
|
||||
@Override
|
||||
public String write() {
|
||||
return config.skinRootDir.getAbsolutePath();
|
||||
}
|
||||
new Option("SkinDirectory") {
|
||||
@Override
|
||||
public String write() {
|
||||
return config.skinRootDir.getAbsolutePath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(String s) {
|
||||
config.skinRootDir = new File(s);
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void read(String s) {
|
||||
config.skinRootDir = new File(s);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static final NumericOption OPTION_PORT = new NumericOption("-", "Port", "-", 49250, 1024, 65535) {
|
||||
@Override
|
||||
@@ -146,7 +129,7 @@ public class Options {
|
||||
public static final ToggleOption OPTION_NOSINGLEINSTANCE = new ToggleOption("-", "NoSingleInstance", "-", false);
|
||||
|
||||
// in-game options
|
||||
public static final Option OPTION_SCREEN_RESOLUTION = new ListOption("Screen Resolution", "ScreenResolution", "Change the size of the game.") {
|
||||
public static final ListOption OPTION_SCREEN_RESOLUTION = new ListOption("Screen Resolution", "ScreenResolution", "Change the size of the game.") {
|
||||
private final String[] resolutions = {
|
||||
null,
|
||||
"800x600",
|
||||
@@ -188,7 +171,6 @@ public class Options {
|
||||
|
||||
@Override
|
||||
public void read (String s){
|
||||
resolutions[0] = displayContainer.nativeDisplayMode.getWidth() + "x" + displayContainer.nativeDisplayMode.getHeight();
|
||||
try {
|
||||
idx = Integer.parseInt(s);
|
||||
} catch (Exception ignored) {
|
||||
@@ -205,37 +187,31 @@ public class Options {
|
||||
public static final ToggleOption OPTION_ALLOW_LARGER_RESOLUTIONS = new ToggleOption("Allow large resolutions", "AllowLargeRes", "Allow resolutions larger than the native resolution", false);
|
||||
public static final ToggleOption OPTION_FULLSCREEN = new ToggleOption("Fullscreen Mode", "Fullscreen", "Restart to apply changes.", false);
|
||||
public static final ListOption OPTION_SKIN = new ListOption("Skin", "Skin", "Change how the game looks.") {
|
||||
private CachedVariable<SkinService> skinService = new CachedVariable<>(new Getter<SkinService>() {
|
||||
@Override
|
||||
public SkinService get() {
|
||||
return instanceContainer.provide(SkinService.class);
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
public String getValueString () {
|
||||
return skinService.get().usedSkinName;
|
||||
return skinservice.usedSkinName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getListItems () {
|
||||
return skinService.get().availableSkinDirectories;
|
||||
return skinservice.availableSkinDirectories;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clickListItem(int index){
|
||||
skinService.get().usedSkinName = skinService.get().availableSkinDirectories[index];
|
||||
skinService.get().reloadSkin();
|
||||
skinservice.usedSkinName = skinservice.availableSkinDirectories[index];
|
||||
skinservice.reloadSkin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read (String s){
|
||||
skinService.get().usedSkinName = s;
|
||||
skinservice.usedSkinName = s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String write() {
|
||||
return skinService.get().usedSkinName;
|
||||
return skinservice.usedSkinName;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -418,7 +394,7 @@ public class Options {
|
||||
};
|
||||
|
||||
public static final ToggleOption OPTION_DISABLE_SOUNDS = new ToggleOption("Disable All Sound Effects", "DisableSound", "May resolve Linux sound driver issues. Requires a restart.", (System.getProperty("os.name").toLowerCase().contains("linux")));
|
||||
public static final GenericOption OPTION_KEY_LEFT = new GenericOption("Left Game Key", "keyOsuLeft", "Select this option to input a key.", Input.KEY_Z, null, false) {
|
||||
public static final GenericOption OPTION_KEY_LEFT = new GenericOption("Left Game Key", "keyOsuLeft", "Select this option to input a key.", Keyboard.KEY_Z, null, false) {
|
||||
@Override
|
||||
public String getValueString () {
|
||||
return Keyboard.getKeyName(intval);
|
||||
@@ -433,12 +409,12 @@ public class Options {
|
||||
public void read(String s){
|
||||
intval = Keyboard.getKeyIndex(s);
|
||||
if (intval == Keyboard.KEY_NONE) {
|
||||
intval = Input.KEY_Y;
|
||||
intval = Keyboard.KEY_Y;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static final GenericOption OPTION_KEY_RIGHT = new GenericOption("Right Game Key", "keyOsuRight", "Select this option to input a key.", Input.KEY_X, null, false) {
|
||||
public static final GenericOption OPTION_KEY_RIGHT = new GenericOption("Right Game Key", "keyOsuRight", "Select this option to input a key.", Keyboard.KEY_X, null, false) {
|
||||
@Override
|
||||
public String getValueString () {
|
||||
return Keyboard.getKeyName(intval);
|
||||
@@ -453,7 +429,7 @@ public class Options {
|
||||
public void read(String s){
|
||||
intval = Keyboard.getKeyIndex(s);
|
||||
if (intval == Keyboard.KEY_NONE) {
|
||||
intval = Input.KEY_X;
|
||||
intval = Keyboard.KEY_X;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -463,7 +439,8 @@ public class Options {
|
||||
public static final ToggleOption OPTION_DISABLE_MOUSE_BUTTONS = new ToggleOption("Disable mouse buttons in play mode", "MouseDisableButtons", "This option will disable all mouse buttons. Specifically for people who use their keyboard to click.", false) {
|
||||
@Override
|
||||
public void toggle() {
|
||||
EventBus.post(new BarNotificationEvent(state ? "Mouse buttons are disabled." : "Mouse buttons are enabled."));
|
||||
BarNotifListener.EVENT.make().onBarNotif(state ?
|
||||
"Mouse buttons are disabled." : "Mouse buttons are enabled.");
|
||||
}
|
||||
};
|
||||
public static final ToggleOption OPTION_DISABLE_CURSOR = new ToggleOption("Disable Cursor", "DisableCursor", "Hide the cursor sprite.", false);
|
||||
@@ -503,7 +480,6 @@ public class Options {
|
||||
|
||||
public static final ToggleOption OPTION_SHOW_HIT_LIGHTING = new ToggleOption("Show Hit Lighting", "HitLighting", "Adds an effect behind hit explosions.", true);
|
||||
public static final ToggleOption OPTION_SHOW_HIT_ANIMATIONS = new ToggleOption("Show Hit Animations", "HitAnimations", "Fade out circles and curves.", true);
|
||||
public static final ToggleOption OPTION_SHOW_REVERSEARROW_ANIMATIONS = new ToggleOption("Show reverse arrow animations", "ReverseArrowAnimations", "Fade out reverse arrows after passing.", true);
|
||||
public static final ToggleOption OPTION_SHOW_COMBO_BURSTS = new ToggleOption("Show Combo Bursts", "ComboBurst", "A character image is displayed at combo milestones.", true);
|
||||
public static final ToggleOption OPTION_SHOW_PERFECT_HIT = new ToggleOption("Show Perfect Hits", "PerfectHit", "Whether to show perfect hit result bursts (300s, slider ticks).", true);
|
||||
public static final ToggleOption OPTION_SHOW_FOLLOW_POINTS = new ToggleOption("Show Follow Points", "FollowPoints", "Whether to show follow points between hit objects.", true);
|
||||
@@ -632,7 +608,7 @@ public class Options {
|
||||
public void clickListItem(int index){
|
||||
if (Game.isInGame && Dancer.moverFactories[index] instanceof PolyMoverFactory) {
|
||||
// TODO remove this when #79 is fixed
|
||||
EventBus.post(new BarNotificationEvent("This mover is disabled in the storyboard right now"));
|
||||
BarNotifListener.EVENT.make().onBarNotif("This mover is disabled in the storyboard right now");
|
||||
return;
|
||||
}
|
||||
Dancer.instance.setMoverFactoryIndex(index);
|
||||
|
||||
@@ -17,39 +17,37 @@
|
||||
*/
|
||||
package yugecin.opsudance.options;
|
||||
|
||||
import itdelatrisu.opsu.ui.Colors;
|
||||
import org.newdawn.slick.util.Log;
|
||||
import yugecin.opsudance.core.events.EventBus;
|
||||
import yugecin.opsudance.core.inject.Inject;
|
||||
import yugecin.opsudance.core.inject.InstanceContainer;
|
||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
||||
import yugecin.opsudance.events.BubNotifListener;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import static yugecin.opsudance.core.InstanceContainer.*;
|
||||
|
||||
/**
|
||||
* @author itdelatrisu (https://github.com/itdelatrisu) most functions are copied from itdelatrisu.opsu.Options.java
|
||||
* @author itdelatrisu (https://github.com/itdelatrisu)
|
||||
* most functions are copied from itdelatrisu.opsu.Options.java
|
||||
*/
|
||||
public class OptionsService {
|
||||
|
||||
@Inject
|
||||
private Configuration config;
|
||||
public final HashMap<String, Option> optionMap;
|
||||
|
||||
public static final HashMap<String, Option> optionMap = new HashMap<>();
|
||||
|
||||
@Inject
|
||||
public OptionsService(InstanceContainer instanceContainer) {
|
||||
Option.setInstanceContainer(instanceContainer);
|
||||
public OptionsService() {
|
||||
optionMap = new HashMap<>();
|
||||
}
|
||||
|
||||
public static void registerOption(Option option) {
|
||||
public void registerOption(Option option) {
|
||||
optionMap.put(option.configurationName, option);
|
||||
}
|
||||
|
||||
public void loadOptions() {
|
||||
// if no config file, use default settings
|
||||
if (!config.OPTIONS_FILE.isFile()) {
|
||||
config.loadDirectories();
|
||||
saveOptions();
|
||||
return;
|
||||
}
|
||||
@@ -82,7 +80,7 @@ public class OptionsService {
|
||||
} catch (IOException e) {
|
||||
String err = String.format("Failed to read option file '%s'.", config.OPTIONS_FILE.getAbsolutePath());
|
||||
Log.error(err, e);
|
||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
||||
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
|
||||
}
|
||||
config.loadDirectories();
|
||||
}
|
||||
@@ -111,7 +109,7 @@ public class OptionsService {
|
||||
} catch (IOException e) {
|
||||
String err = String.format("Failed to write to file '%s'.", config.OPTIONS_FILE.getAbsolutePath());
|
||||
Log.error(err, e);
|
||||
EventBus.post(new BubbleNotificationEvent(err, BubbleNotificationEvent.COMMONCOLOR_RED));
|
||||
BubNotifListener.EVENT.make().onBubNotif(err, Colors.BUB_RED);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user