got rid of dependency injection, it doesn't add anything at this point and only slows down things and makes a mess. Also some refactoring.

This commit is contained in:
yugecin
2017-05-21 11:12:55 +02:00
parent 1ebf2c2dcb
commit ec53f531c8
72 changed files with 675 additions and 929 deletions

View File

@@ -40,6 +40,7 @@ import yugecin.opsudance.spinners.*;
import java.awt.*;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*;
public class Dancer {
@@ -194,12 +195,12 @@ public class Dancer {
}
isCurrentLazySlider = false;
// detect lazy sliders, should work pretty good
if (c.isSlider() && OPTION_DANCE_LAZY_SLIDERS.state && Utils.distance(c.start.x, c.start.y, c.end.x, c.end.y) <= GameObjectRenderer.instance.getCircleDiameter() * 0.8f) {
if (c.isSlider() && OPTION_DANCE_LAZY_SLIDERS.state && Utils.distance(c.start.x, c.start.y, c.end.x, c.end.y) <= gameObjectRenderer.circleDiameter * 0.8f) {
Slider s = (Slider) c;
Vec2f mid = s.getCurve().pointAt(1f);
if (s.getRepeats() == 1 || Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= GameObjectRenderer.instance.getCircleDiameter() * 0.8f) {
if (s.getRepeats() == 1 || Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= gameObjectRenderer.circleDiameter * 0.8f) {
mid = s.getCurve().pointAt(0.5f);
if (Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= GameObjectRenderer.instance.getCircleDiameter() * 0.8f) {
if (Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= gameObjectRenderer.circleDiameter * 0.8f) {
isCurrentLazySlider = true;
}
}
@@ -251,8 +252,8 @@ public class Dancer {
}
}
Pippi.dance(time, c, isCurrentLazySlider);
x = Utils.clamp(x, 10, width - 10);
y = Utils.clamp(y, 10, height - 10);
x = Utils.clamp(x, 10, displayContainer.width - 10);
y = Utils.clamp(y, 10, displayContainer.height - 10);
}
private void createNewMover() {

View File

@@ -21,22 +21,16 @@ import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.beatmap.BeatmapWatchService;
import itdelatrisu.opsu.db.DBController;
import itdelatrisu.opsu.downloads.DownloadList;
import itdelatrisu.opsu.downloads.Updater;
import itdelatrisu.opsu.states.Splash;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.errorhandling.ErrorHandler;
import yugecin.opsudance.core.inject.Inject;
import yugecin.opsudance.options.Configuration;
import yugecin.opsudance.options.OptionsService;
import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.UnknownHostException;
import static yugecin.opsudance.core.Entrypoint.sout;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*;
/*
@@ -44,30 +38,13 @@ import static yugecin.opsudance.options.Options.*;
*/
public class OpsuDance {
@Inject
private DisplayContainer container;
@Inject
private OptionsService optionsService;
@Inject
private Configuration config;
@Inject
private Updater updater;
private ServerSocket singleInstanceSocket;
@Inject
public OpsuDance() {
}
public void start(String[] args) {
try {
sout("initialized");
checkRunningDirectory();
optionsService.loadOptions();
optionservice.loadOptions();
ensureSingleInstance();
sout("prechecks done and options parsed");
@@ -75,15 +52,15 @@ public class OpsuDance {
initUpdater(args);
sout("database & updater initialized");
container.init(Splash.class);
displayContainer.init(splashState);
} catch (Exception e) {
errorAndExit("startup failure", e);
}
while (rungame());
container.teardownAL();
displayContainer.teardownAL();
optionsService.saveOptions();
optionservice.saveOptions();
closeSingleInstanceSocket();
DBController.closeConnections();
DownloadList.get().cancelAllDownloads();
@@ -95,20 +72,20 @@ public class OpsuDance {
private boolean rungame() {
try {
container.setup();
container.resume();
displayContainer.setup();
displayContainer.resume();
} catch (Exception e) {
ErrorHandler.error("could not initialize GL", e).allowTerminate().preventContinue().show();
return false;
}
Exception caughtException = null;
try {
container.run();
displayContainer.run();
} catch (Exception e) {
caughtException = e;
}
container.teardown();
container.pause();
displayContainer.teardown();
displayContainer.pause();
return caughtException != null && ErrorHandler.error("update/render error", caughtException).allowTerminate().show().shouldIgnoreAndContinue();
}
@@ -142,20 +119,6 @@ public class OpsuDance {
}.start();
}
private void checkRunningDirectory() {
if (!Utils.isJarRunning()) {
return;
}
File runningDir = Utils.getRunningDirectory();
if (runningDir == null) {
return;
}
if (runningDir.getAbsolutePath().indexOf('!') == -1) {
return;
}
errorAndExit("Cannot run from a path that contains a '!'. Please move or rename the jar and try again.");
}
private void ensureSingleInstance() {
if (OPTION_NOSINGLEINSTANCE.state) {
return;

View File

@@ -19,9 +19,9 @@ package yugecin.opsudance;
import itdelatrisu.opsu.objects.GameObject;
import itdelatrisu.opsu.objects.Slider;
import yugecin.opsudance.render.GameObjectRenderer;
import static yugecin.opsudance.options.Options.*;
import static yugecin.opsudance.core.InstanceContainer.*;
public class Pippi {
@@ -38,14 +38,14 @@ public class Pippi {
public static void setRadiusPercent(int radiusPercent) {
Pippi.radiusPercent = radiusPercent;
pippiminrad = pippirad = (GameObjectRenderer.instance.getCircleDiameter() / 2d - 10d) * radiusPercent / 100d;
pippiminrad = pippirad = (gameObjectRenderer.circleDiameter / 2d - 10d) * radiusPercent / 100d;
}
public static void reset() {
angle = 0;
currentdelta = 0;
setRadiusPercent(radiusPercent);
pippimaxrad = GameObjectRenderer.instance.getCircleDiameter() - 10d;
pippimaxrad = gameObjectRenderer.circleDiameter - 10d;
}
public static void dance(int time, GameObject c, boolean isCurrentLazySlider) {
@@ -92,7 +92,7 @@ public class Pippi {
}
public static boolean shouldPreventWobblyStream(double distance) {
return OPTION_PIPPI_ENABLE.state && distance < GameObjectRenderer.instance.getCircleDiameter() * 0.93f && OPTION_PIPPI_PREVENT_WOBBLY_STREAMS.state;
return OPTION_PIPPI_ENABLE.state && distance < gameObjectRenderer.circleDiameter * 0.93f && OPTION_PIPPI_PREVENT_WOBBLY_STREAMS.state;
}
}

View File

@@ -1,73 +0,0 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance 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!dance 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!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance;
import itdelatrisu.opsu.NativeLoader;
import org.newdawn.slick.util.FileSystemLocation;
import org.newdawn.slick.util.Log;
import org.newdawn.slick.util.ResourceLoader;
import yugecin.opsudance.core.inject.Inject;
import yugecin.opsudance.options.Configuration;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
public class PreStartupInitializer {
private final Configuration config;
@Inject
public PreStartupInitializer(Configuration config) {
this.config = config;
loadNatives();
setResourcePath();
}
private void loadNatives() {
File nativeDir = loadNativesUsingOptionsPath();
System.setProperty("org.lwjgl.librarypath", nativeDir.getAbsolutePath());
System.setProperty("java.library.path", nativeDir.getAbsolutePath());
try {
// Workaround for "java.library.path" property being read-only.
// http://stackoverflow.com/a/24988095
Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
fieldSysPath.setAccessible(true);
fieldSysPath.set(null, null);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
Log.warn("Failed to set 'sys_paths' field.", e);
}
}
private File loadNativesUsingOptionsPath() {
File nativeDir = config.NATIVE_DIR;
try {
new NativeLoader(nativeDir).loadNatives();
} catch (IOException e) {
Log.error("Error loading natives.", e);
}
return nativeDir;
}
private void setResourcePath() {
ResourceLoader.addResourceLocation(new FileSystemLocation(new File("./res/")));
}
}

View File

@@ -0,0 +1,32 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance 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!dance 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!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.core;
import java.net.URI;
public class Constants {
public static final String PROJECT_NAME = "opsu!dance";
public static final String FONT_NAME = "DroidSansFallback.ttf";
public static final String VERSION_FILE = "version";
public static final URI REPOSITORY_URI = URI.create("https://github.com/itdelatrisu/opsu");
public static final URI DANCE_REPOSITORY_URI = URI.create("https://github.com/yugecin/opsu-dance");
public static final String ISSUES_URL = "https://github.com/yugecin/opsu-dance/issues/new?title=%s&body=%s";
public static final String VERSION_REMOTE = "https://raw.githubusercontent.com/yugecin/opsu-dance/master/version";
}

View File

@@ -42,21 +42,18 @@ import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.errorhandling.ErrorDumpable;
import yugecin.opsudance.core.events.EventListener;
import yugecin.opsudance.core.inject.Inject;
import yugecin.opsudance.core.inject.InstanceContainer;
import yugecin.opsudance.core.state.OpsuState;
import yugecin.opsudance.core.state.specialstates.BarNotificationState;
import yugecin.opsudance.core.state.specialstates.BubbleNotificationState;
import yugecin.opsudance.core.state.specialstates.FpsRenderState;
import yugecin.opsudance.events.BubbleNotificationEvent;
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
import yugecin.opsudance.options.Configuration;
import yugecin.opsudance.skinning.SkinService;
import yugecin.opsudance.utils.GLHelper;
import java.io.StringWriter;
import static yugecin.opsudance.core.Entrypoint.sout;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*;
/**
@@ -64,16 +61,8 @@ import static yugecin.opsudance.options.Options.*;
*/
public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListener {
@Inject
private SkinService skinService;
@Inject
private Configuration config;
private static SGL GL = Renderer.get();
private final InstanceContainer instanceContainer;
private FpsRenderState fpsState;
private BarNotificationState barNotifState;
private BubbleNotificationState bubNotifState;
@@ -156,9 +145,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
private final Transition transition = new Transition();
@Inject
public DisplayContainer(InstanceContainer instanceContainer) {
this.instanceContainer = instanceContainer;
public DisplayContainer() {
this.cursor = new Cursor();
drawCursor = true;
@@ -183,7 +170,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
setFPS(targetFPS[targetFPSIndex]);
MusicController.setMusicVolume(OPTION_MUSIC_VOLUME.val / 100f * OPTION_MASTER_VOLUME.val / 100f);
skinService.loadSkin();
skinservice.loadSkin();
// initialize game images
for (GameImage img : GameImage.values()) {
@@ -210,16 +197,16 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
targetRenderInterval = 1000 / targetRendersPerSecond;
}
public void init(Class<? extends OpsuState> startingState) {
public void init(OpsuState startingState) {
setUPS(OPTION_TARGET_UPS.val);
setFPS(targetFPS[targetFPSIndex]);
state = instanceContainer.provide(startingState);
state = startingState;
state.enter();
fpsState = instanceContainer.provide(FpsRenderState.class);
bubNotifState = instanceContainer.provide(BubbleNotificationState.class);
barNotifState = instanceContainer.provide(BarNotificationState.class);
fpsState = new FpsRenderState();
bubNotifState = new BubbleNotificationState();
barNotifState = new BarNotificationState();
}
@@ -352,7 +339,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
exitconfirmation = System.currentTimeMillis();
return false;
}
if (Updater.get().getStatus() == Updater.Status.UPDATE_DOWNLOADING) {
if (updater.getStatus() == Updater.Status.UPDATE_DOWNLOADING) {
EventBus.post(new BubbleNotificationEvent(Updater.EXIT_CONFIRMATION, BubbleNotificationEvent.COMMONCOLOR_PURPLE));
exitRequested = false;
exitconfirmation = System.currentTimeMillis();
@@ -447,7 +434,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
sout("GL ready");
GameImage.init(width, height);
Fonts.init(config);
Fonts.init();
EventBus.post(new ResolutionOrSkinChangedEvent(null, width, height));
}
@@ -478,33 +465,25 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
return state.isInstance(state);
}
public void switchState(Class<? extends OpsuState> newState, int outtime, int intime) {
public void switchState(OpsuState state) {
switchState(state, 200, 300);
}
public void switchState(OpsuState newstate, int outtime, int intime) {
if (transition.progress != -1) {
return;
}
// TODO remove this v
OpsuState _newstate = instanceContainer.provide(newState);
if (outtime == 0) {
switchStateInstantly(_newstate);
_newstate = null;
switchStateInstantly(newstate);
newstate = null;
}
transition.nextstate = _newstate;
transition.nextstate = newstate;
transition.total = transition.in = intime;
transition.out = outtime;
transition.total += outtime;
transition.progress = 0;
}
@Deprecated // TODO instcontainer
public void switchState(Class<? extends OpsuState> state) {
switchState(state, 200, 300);
}
@Deprecated // TODO instcontainer
public void switchStateInstantly(Class<? extends OpsuState> state) {
switchStateInstantly(instanceContainer.provide(state));
}
public void switchStateInstantly(OpsuState state) {
this.state.leave();
this.state = state;

View File

@@ -19,7 +19,11 @@ package yugecin.opsudance.core;
import itdelatrisu.opsu.downloads.Updater;
import yugecin.opsudance.OpsuDance;
import yugecin.opsudance.core.inject.OpsuDanceInjector;
import javax.swing.*;
import static yugecin.opsudance.core.Constants.PROJECT_NAME;
import static yugecin.opsudance.core.InstanceContainer.*;
public class Entrypoint {
@@ -27,10 +31,18 @@ public class Entrypoint {
public static void main(String[] args) {
sout("launched");
(new OpsuDanceInjector()).provide(OpsuDance.class).start(args);
if (Updater.get().getStatus() == Updater.Status.UPDATE_FINAL) {
Updater.get().runUpdate();
try {
InstanceContainer.kickstart();
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e.getMessage(), "Cannot start " + PROJECT_NAME, JOptionPane.ERROR_MESSAGE);
// TODO replace with errorhandler
}
new OpsuDance().start(args);
if (updater.getStatus() == Updater.Status.UPDATE_FINAL) {
updater.runUpdate();
}
}
@@ -39,7 +51,7 @@ public class Entrypoint {
}
public static void sout(String message) {
System.out.println(String.format("[%7d] %s", runtime(), message));
System.out.println(String.format("[%8d] %s", runtime(), message));
}
}

View File

@@ -0,0 +1,62 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance 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!dance 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!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.core;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.jar.JarFile;
import static yugecin.opsudance.core.Constants.PROJECT_NAME;
public class Environment {
public final boolean isJarRunning;
public final File workingdir;
public final JarFile jarfile;
public Environment() {
Class thiz = Environment.class;
String thisClassLocation = thiz.getResource(thiz.getSimpleName() + ".class").toString();
this.isJarRunning = thisClassLocation.startsWith("jar:");
if (!isJarRunning) {
this.workingdir = Paths.get(".").toAbsolutePath().normalize().toFile();
this.jarfile = null;
} else {
String wdir = thisClassLocation.substring(6); // remove the jar://
String separator = "!/";
int separatorIdx = wdir.indexOf(separator);
int lastSeparatorIdx = wdir.lastIndexOf(separator);
if (separatorIdx != lastSeparatorIdx) {
String msg = String.format("%s cannot run from paths containing '!/', please move the file. Current directory: %s",
PROJECT_NAME, thisClassLocation.substring(0, lastSeparatorIdx));
throw new RuntimeException(msg);
}
File jar = new File(wdir.substring(0, separatorIdx));
this.workingdir = jar.getParentFile();
try {
this.jarfile = new JarFile(jar);
} catch (IOException e) {
String msg = String.format("Cannot read from jarfile (%s): %s", jar.getAbsolutePath(),
e.getMessage());
throw new RuntimeException(msg, e);
}
}
}
}

View File

@@ -0,0 +1,89 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance 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!dance 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!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.core;
import itdelatrisu.opsu.NativeLoader;
import itdelatrisu.opsu.beatmap.BeatmapParser;
import itdelatrisu.opsu.beatmap.OszUnpacker;
import itdelatrisu.opsu.downloads.Updater;
import itdelatrisu.opsu.replay.ReplayImporter;
import itdelatrisu.opsu.states.*;
import org.newdawn.slick.util.FileSystemLocation;
import org.newdawn.slick.util.ResourceLoader;
import yugecin.opsudance.options.Configuration;
import yugecin.opsudance.options.OptionsService;
import yugecin.opsudance.render.GameObjectRenderer;
import yugecin.opsudance.skinning.SkinService;
import java.io.File;
public class InstanceContainer {
public static Environment env;
public static Configuration config;
public static OptionsService optionservice;
public static SkinService skinservice;
public static OszUnpacker oszunpacker;
public static ReplayImporter replayImporter;
public static BeatmapParser beatmapParser;
public static Updater updater;
public static DisplayContainer displayContainer;
public static GameObjectRenderer gameObjectRenderer;
public static Splash splashState;
public static MainMenu mainmenuState;
public static ButtonMenu buttonState;
public static SongMenu songMenuState;
public static DownloadsMenu downloadState;
public static Game gameState;
public static GameRanking gameRankingState;
public static GamePauseMenu pauseState;
public static void kickstart() {
updater = new Updater();
env = new Environment();
config = new Configuration();
NativeLoader.loadNatives();
ResourceLoader.addResourceLocation(new FileSystemLocation(new File("./res/")));
optionservice = new OptionsService();
skinservice = new SkinService();
oszunpacker = new OszUnpacker();
replayImporter = new ReplayImporter();
beatmapParser = new BeatmapParser();
updater = new Updater();
displayContainer = new DisplayContainer();
gameObjectRenderer = new GameObjectRenderer();
splashState = new Splash();
mainmenuState = new MainMenu();
buttonState = new ButtonMenu();
songMenuState = new SongMenu();
downloadState = new DownloadsMenu();
gameState = new Game();
gameRankingState = new GameRanking();
pauseState = new GamePauseMenu();
}
}

View File

@@ -0,0 +1,23 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance 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!dance 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!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.core;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.SOURCE) public @interface NotNull {}

View File

@@ -0,0 +1,23 @@
/*
* opsu!dance - fork of opsu! with cursordance auto
* Copyright (C) 2017 yugecin
*
* opsu!dance 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!dance 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!dance. If not, see <http://www.gnu.org/licenses/>.
*/
package yugecin.opsudance.core;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.SOURCE) public @interface Nullable {}

View File

@@ -19,6 +19,7 @@ package yugecin.opsudance.core.errorhandling;
import itdelatrisu.opsu.Utils;
import org.newdawn.slick.util.Log;
import yugecin.opsudance.core.Constants;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.options.Configuration;
import yugecin.opsudance.utils.MiscUtils;
@@ -232,7 +233,7 @@ public class ErrorHandler {
} catch (UnsupportedEncodingException e) {
Log.warn("URLEncoder failed to encode the auto-filled issue report URL.", e);
}
return URI.create(String.format(config.ISSUES_URL, issueTitle, issueBody));
return URI.create(String.format(Constants.ISSUES_URL, issueTitle, issueBody));
}
private String truncateGithubIssueBody(String body) {

View File

@@ -23,7 +23,6 @@ import itdelatrisu.opsu.beatmap.OszUnpacker;
import itdelatrisu.opsu.downloads.Updater;
import itdelatrisu.opsu.replay.ReplayImporter;
import itdelatrisu.opsu.states.*;
import yugecin.opsudance.PreStartupInitializer;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.state.specialstates.BarNotificationState;
import yugecin.opsudance.core.state.specialstates.BubbleNotificationState;
@@ -46,7 +45,7 @@ public class OpsuDanceInjector extends Injector {
bind(Updater.class).asLazySingleton();
bind(SkinService.class).asEagerSingleton();
bind(PreStartupInitializer.class).asEagerSingleton();
//bind(PreStartupInitializer.class).asEagerSingleton();
bind(DisplayContainer.class).asEagerSingleton();
bind(ErrorHandler.class).asEagerSingleton();

View File

@@ -21,30 +21,18 @@ import itdelatrisu.opsu.states.Game;
import itdelatrisu.opsu.ui.UI;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.events.EventListener;
import yugecin.opsudance.core.inject.Inject;
import yugecin.opsudance.events.BarNotificationEvent;
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
import yugecin.opsudance.options.Configuration;
import yugecin.opsudance.skinning.SkinService;
import java.io.StringWriter;
import static yugecin.opsudance.options.Options.*;
import static yugecin.opsudance.core.InstanceContainer.*;
public abstract class BaseOpsuState implements OpsuState, EventListener<ResolutionOrSkinChangedEvent> {
@Inject
protected DisplayContainer displayContainer;
@Inject
protected Configuration config;
@Inject
protected SkinService skinService;
/**
* state is dirty when resolution or skin changed but hasn't rendered yet
*/
@@ -120,7 +108,7 @@ public abstract class BaseOpsuState implements OpsuState, EventListener<Resoluti
}
Input input = displayContainer.input;
if (key == Input.KEY_S && input.isKeyDown(Input.KEY_LMENU) && input.isKeyDown(Input.KEY_LSHIFT) &&input.isKeyDown(Input.KEY_LCONTROL) && !displayContainer.isInState(Game.class)) {
skinService.reloadSkin();
skinservice.reloadSkin();
}
return false;
}

View File

@@ -23,6 +23,8 @@ import yugecin.opsudance.core.components.Component;
import java.util.LinkedList;
import static yugecin.opsudance.core.InstanceContainer.*;
public abstract class ComplexOpsuState extends BaseOpsuState {
protected final LinkedList<Component> components;

View File

@@ -21,7 +21,6 @@ import itdelatrisu.opsu.ui.Fonts;
import itdelatrisu.opsu.ui.animations.AnimationEquation;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.events.EventListener;
import yugecin.opsudance.events.BarNotificationEvent;
@@ -29,6 +28,8 @@ import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
import java.util.List;
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
public class BarNotificationState implements EventListener<BarNotificationEvent> {
private final int IN_TIME = 200;
@@ -36,7 +37,6 @@ public class BarNotificationState implements EventListener<BarNotificationEvent>
private final int OUT_TIME = 200;
private final int TOTAL_TIME = DISPLAY_TIME + OUT_TIME;
private final DisplayContainer displayContainer;
private final Color bgcol;
private final Color textCol;
@@ -49,8 +49,7 @@ public class BarNotificationState implements EventListener<BarNotificationEvent>
private int barHalfTargetHeight;
private int barHalfHeight;
public BarNotificationState(DisplayContainer displayContainer) {
this.displayContainer = displayContainer;
public BarNotificationState() {
this.bgcol = new Color(Color.black);
this.textCol = new Color(Color.white);
this.timeShown = TOTAL_TIME;

View File

@@ -21,7 +21,6 @@ import itdelatrisu.opsu.ui.Fonts;
import itdelatrisu.opsu.ui.animations.AnimationEquation;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.events.EventListener;
import yugecin.opsudance.events.BubbleNotificationEvent;
@@ -31,6 +30,8 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
public class BubbleNotificationState implements EventListener<BubbleNotificationEvent> {
public static final int IN_TIME = 633;
@@ -38,14 +39,12 @@ public class BubbleNotificationState implements EventListener<BubbleNotification
public static final int OUT_TIME = 433;
public static final int TOTAL_TIME = DISPLAY_TIME + OUT_TIME;
private final DisplayContainer displayContainer;
private final LinkedList<Notification> bubbles;
private int addAnimationTime;
private int addAnimationHeight;
public BubbleNotificationState(DisplayContainer displayContainer) {
this.displayContainer = displayContainer;
public BubbleNotificationState() {
this.bubbles = new LinkedList<>();
this.addAnimationTime = IN_TIME;
EventBus.subscribe(BubbleNotificationEvent.class, this);

View File

@@ -20,13 +20,13 @@ package yugecin.opsudance.core.state.specialstates;
import itdelatrisu.opsu.ui.Fonts;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.events.EventListener;
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
import yugecin.opsudance.utils.FPSMeter;
import static yugecin.opsudance.options.Options.*;
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
public class FpsRenderState implements EventListener<ResolutionOrSkinChangedEvent> {
@@ -34,7 +34,6 @@ public class FpsRenderState implements EventListener<ResolutionOrSkinChangedEven
private final static Color ORANGE = new Color(255, 204, 34);
private final static Color DARKORANGE = new Color(255, 149, 24);
private final DisplayContainer displayContainer;
private final FPSMeter fpsMeter;
private final FPSMeter upsMeter;
@@ -42,8 +41,7 @@ public class FpsRenderState implements EventListener<ResolutionOrSkinChangedEven
private int y;
private int singleHeight;
public FpsRenderState(DisplayContainer displayContainer) {
this.displayContainer = displayContainer;
public FpsRenderState() {
fpsMeter = new FPSMeter(10);
upsMeter = new FPSMeter(10);
EventBus.subscribe(ResolutionOrSkinChangedEvent.class, this);

View File

@@ -19,7 +19,8 @@ package yugecin.opsudance.movers;
import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.objects.GameObject;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.*;
public class CircleMover extends Mover {
@@ -63,7 +64,7 @@ public class CircleMover extends Mover {
double a = ang + SOME_CONSTANT * t;
pos[0] = (startX + (endX - startX) * t) - middlexoffset - Math.cos(a) * radius;
pos[1] = (startY + (endY - startY) * t) - middleyoffset - Math.sin(a) * radius;
if (pos[0] < 0 || Options.width < pos[0] || pos[1] < 0 || Options.height < pos[1]) {
if (pos[0] < 0 || displayContainer.width < pos[0] || pos[1] < 0 || displayContainer.height < pos[1]) {
pass = false;
break;
}

View File

@@ -18,11 +18,11 @@
package yugecin.opsudance.movers;
import itdelatrisu.opsu.objects.GameObject;
import yugecin.opsudance.options.Options;
import java.util.Random;
import static yugecin.opsudance.options.Options.*;
import static yugecin.opsudance.core.InstanceContainer.*;
public class ExgonMover extends Mover {
@@ -44,8 +44,8 @@ public class ExgonMover extends Mover {
pos[0] = endX;
pos[1] = endY;
} else {
pos[0] = randgen.nextInt(Options.width);
pos[1] = randgen.nextInt(Options.height);
pos[0] = randgen.nextInt(displayContainer.width);
pos[1] = randgen.nextInt(displayContainer.height);
}
}
return pos;

View File

@@ -22,9 +22,8 @@ import itdelatrisu.opsu.beatmap.HitObject;
import itdelatrisu.opsu.objects.GameObject;
import yugecin.opsudance.Pippi;
import yugecin.opsudance.movers.*;
import yugecin.opsudance.options.Options;
import yugecin.opsudance.render.GameObjectRenderer;
import static yugecin.opsudance.core.InstanceContainer.*;
import static yugecin.opsudance.options.Options.*;
public class AutoMoverFactory implements MoverFactory {
@@ -45,7 +44,7 @@ public class AutoMoverFactory implements MoverFactory {
// stacked: circles if not too quick
int circle_stream = OPTION_DANCE_CIRCLE_STREAMS.state ? 58: 85;
if (distance < GameObjectRenderer.instance.getCircleDiameter() && ((dt > circle_stream && !OPTION_DANCE_ONLY_CIRCLE_STACKS.state) || distance < HitObject.getStackOffset() * 5.2f)) { // TODO get the correct multiplier for stackoffsets
if (distance < gameObjectRenderer.circleDiameter && ((dt > circle_stream && !OPTION_DANCE_ONLY_CIRCLE_STACKS.state) || distance < HitObject.getStackOffset() * 5.2f)) { // TODO get the correct multiplier for stackoffsets
return new CircleMover(start, end, dir);
}
@@ -103,7 +102,8 @@ public class AutoMoverFactory implements MoverFactory {
}
private boolean checkBounds( double[] pos ) {
return 0 < pos[0] && pos[0] < Options.width - Options.width / 8 && 0 < pos[1] && pos[1] < Options.height - Options.height / 8;
return 0 < pos[0] && pos[0] < displayContainer.width - displayContainer.width / 8 &&
0 < pos[1] && pos[1] < displayContainer.height - displayContainer.height / 8;
}
@Override

View File

@@ -20,7 +20,6 @@ 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;
@@ -30,31 +29,26 @@ 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 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.options.Options.*;
import static yugecin.opsudance.core.InstanceContainer.*;
public class Configuration {
public static Configuration instance;
public final boolean USE_XDG;
public final File CONFIG_DIR;
public final File DATA_DIR;
@@ -69,13 +63,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;
@@ -87,10 +74,7 @@ public class Configuration {
public File replayImportDir;
public File skinRootDir;
@Inject
public Configuration() {
instance = this;
USE_XDG = areXDGDirectoriesEnabled();
CONFIG_DIR = getXDGBaseDir("XDG_CONFIG_HOME", ".config");
@@ -107,13 +91,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();
@@ -200,12 +177,11 @@ public class Configuration {
}
private boolean areXDGDirectoriesEnabled() {
JarFile jarFile = Utils.getJarFile();
if (jarFile == null) {
if (env.jarfile == null) {
return false;
}
try {
Manifest manifest = jarFile.getManifest();
Manifest manifest = env.jarfile.getManifest();
if (manifest == null) {
return false;
}
@@ -220,28 +196,21 @@ public class Configuration {
/**
* 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) {

View File

@@ -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);
}
/**

View File

@@ -29,40 +29,23 @@ 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.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
@@ -204,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;
}
};

View File

@@ -19,8 +19,6 @@ package yugecin.opsudance.options;
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 java.io.*;
@@ -28,22 +26,21 @@ 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);
}

View File

@@ -26,33 +26,21 @@ import itdelatrisu.opsu.ui.Colors;
import itdelatrisu.opsu.ui.animations.AnimationEquation;
import org.newdawn.slick.Color;
import org.newdawn.slick.Image;
import yugecin.opsudance.core.DisplayContainer;
import yugecin.opsudance.core.inject.Inject;
import yugecin.opsudance.skinning.SkinService;
import static yugecin.opsudance.options.Options.*;
public class GameObjectRenderer {
@Inject
private DisplayContainer displayContainer;
public GameData gameData;
private GameData gameData;
private float circleDiameter;
private int circleDiameterInt;
public float circleDiameter;
public int circleDiameterInt;
private Image hitcircle;
private Image hitcircleOverlay;
private Image approachCircle;
@Deprecated
public static GameObjectRenderer instance;
public GameObjectRenderer() {
instance = this; // TODO get rid of this
}
public void initForGame(GameData gameData, float circleDiameter) {
this.gameData = gameData;
this.circleDiameter = circleDiameter * HitObject.getXMultiplier(); // convert from Osupixels (640x480)
@@ -65,14 +53,6 @@ public class GameObjectRenderer {
approachCircle = GameImage.APPROACHCIRCLE.getImage();
}
public float getCircleDiameter() {
return circleDiameter;
}
public void setGameData(GameData gameData) {
this.gameData = gameData;
}
public void initForFrame() {
if (!OPTION_DANCING_CIRCLES.state) {
return;

View File

@@ -24,28 +24,20 @@ import org.newdawn.slick.util.ClasspathLocation;
import org.newdawn.slick.util.FileSystemLocation;
import org.newdawn.slick.util.ResourceLoader;
import yugecin.opsudance.core.events.EventBus;
import yugecin.opsudance.core.inject.Inject;
import yugecin.opsudance.events.ResolutionOrSkinChangedEvent;
import yugecin.opsudance.options.Configuration;
import java.io.File;
import static yugecin.opsudance.core.InstanceContainer.*;
/**
* @author itdelatrisu (https://github.com/itdelatrisu) most functions are copied from itdelatrisu.opsu.Options.java
*/
public class SkinService {
@Inject
private Configuration config;
public String[] availableSkinDirectories;
public String usedSkinName = "Default";
public static Skin skin;
@Inject
public SkinService() {
}
public void reloadSkin() {
loadSkin();
SoundController.init();

View File

@@ -17,7 +17,7 @@
*/
package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.*;
public class ApproachCircleSpinner extends Spinner {
@@ -38,10 +38,10 @@ public class ApproachCircleSpinner extends Spinner {
ang += 15;
}
double rad = Options.width / 4.0f * (1d - Spinner.PROGRESS);
double rad = displayContainer.width / 4.0f * (1d - Spinner.PROGRESS);
point[0] = Options.width / 2.0f + rad * Math.sin(ang / 180d * Math.PI);
point[1] = Options.height / 2.0f - rad * Math.cos(ang / 180d * Math.PI);
point[0] = displayContainer.width / 2.0f + rad * Math.sin(ang / 180d * Math.PI);
point[1] = displayContainer.height / 2.0f - rad * Math.cos(ang / 180d * Math.PI);
return point;
}

View File

@@ -17,7 +17,7 @@
*/
package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.*;
public class BeamSpinner extends Spinner {
@@ -26,16 +26,14 @@ public class BeamSpinner extends Spinner {
private int index;
@Override
public void init()
{
public void init() {
ang = 0;
index = 0;
point = new double[2];
}
@Override
public double[] getPoint()
{
public double[] getPoint() {
if (!waitForDelay()) {
return point;
}
@@ -43,26 +41,19 @@ public class BeamSpinner extends Spinner {
index = ++index % 4;
final int MOD = 60;
point[0] = Options.width / 2d;
point[1] = Options.height / 2d;
point[0] = displayContainer.width / 2d;
point[1] = displayContainer.height / 2d;
if( index == 0 )
{
if( index == 0 ) {
add( MOD, 90 );
add( MOD, 180 );
}
else if( index == 1 )
{
} else if( index == 1 ) {
add( MOD, 90 );
add( Options.height / 2 * 0.8d, 0 );
}
else if( index == 2 )
{
add( displayContainer.height / 2 * 0.8d, 0 );
} else if( index == 2 ) {
add( MOD, -90 );
add( Options.height / 2 * 0.8d, 0 );
}
else if( index == 3 )
{
add( displayContainer.height / 2 * 0.8d, 0 );
} else if( index == 3 ) {
add( MOD, -90 );
add( MOD, 180 );
ang += 0.3;
@@ -71,8 +62,7 @@ public class BeamSpinner extends Spinner {
return point;
}
private void add( double rad, double ang )
{
private void add( double rad, double ang ) {
point[0] += rad * Math.cos( (this.ang + ang) / 180d * Math.PI);
point[1] -= rad * Math.sin( (this.ang + ang) / 180d * Math.PI);
}

View File

@@ -17,7 +17,7 @@
*/
package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.*;
public class CircleSpinner extends Spinner {
@@ -26,22 +26,20 @@ public class CircleSpinner extends Spinner {
private double[] point = new double[2];
@Override
public void init()
{
public void init() {
ang = 0;
}
@Override
public double[] getPoint()
{
public double[] getPoint() {
if (waitForDelay()) {
ang += 15;
}
double rad = Options.width / 4.0f;
double rad = displayContainer.width / 4.0f;
point[0] = Options.width / 2.0f + rad * Math.sin(ang / 180d * Math.PI);
point[1] = Options.height / 2.0f - rad * Math.cos(ang / 180d * Math.PI);
point[0] = displayContainer.width / 2.0f + rad * Math.sin(ang / 180d * Math.PI);
point[1] = displayContainer.height / 2.0f - rad * Math.cos(ang / 180d * Math.PI);
return point;
}

View File

@@ -17,7 +17,7 @@
*/
package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
public class CubeSpinner extends Spinner {
@@ -90,10 +90,10 @@ public class CubeSpinner extends Spinner {
x *= 3.0d / ( z + 3.0d + 5.0d + 0.5 );
y *= 3.0d / ( z + 3.0d + 5.0d + 0.5 );
double scale = Options.width / (3.0f + 0.5f * Math.cos(size / 180f * Math.PI));
double scale = displayContainer.width / (3.0f + 0.5f * Math.cos(size / 180f * Math.PI));
//double scale = Options.width / (3.0f + -1f * ((float)(Options.s.ElapsedMilliseconds % Options.beatTimeMs)/(float)Options.beatTimeMs));
point[0] = (int) ( Options.width / 2.0f + scale * x );
point[1] = (int) ( Options.height / 2.0f - scale * y );
point[0] = (int) ( displayContainer.width / 2.0f + scale * x );
point[1] = (int) ( displayContainer.height / 2.0f - scale * y );
return point;
}

View File

@@ -17,7 +17,7 @@
*/
package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.*;
public class DonutSpinner extends Spinner {
@@ -38,10 +38,10 @@ public class DonutSpinner extends Spinner {
ang += 15;
}
double rad = Options.width / 4.0f;
double rad = displayContainer.width / 4.0f;
point[0] = Options.width / 2.0f + rad * Math.sin(ang);
point[1] = Options.height / 2.0f - rad * Math.cos(ang);
point[0] = displayContainer.width / 2.0f + rad * Math.sin(ang);
point[1] = displayContainer.height / 2.0f - rad * Math.cos(ang);
return point;
}

View File

@@ -17,7 +17,7 @@
*/
package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.*;
public class FivePointStarApproachSpinner extends Spinner {
@@ -39,12 +39,12 @@ public class FivePointStarApproachSpinner extends Spinner {
odd = !odd;
}
double rad = Options.width / 4.0f * (1d - Spinner.PROGRESS);
double rad = displayContainer.width / 4.0f * (1d - Spinner.PROGRESS);
if (!odd) {
rad /= 3d;
}
point[0] = Options.width / 2d + Math.cos(ang) * rad;
point[1] = Options.height / 2d + Math.sin(ang) * rad;
point[0] = displayContainer.width / 2d + Math.cos(ang) * rad;
point[1] = displayContainer.height / 2d + Math.sin(ang) * rad;
return point;
}

View File

@@ -17,18 +17,18 @@
*/
package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.*;
public class FivePointStarSpinner extends Spinner {
@Override
public void init() {
double[][] points = new double[10][];
double midx = Options.width / 2d;
double midy = Options.height / 2d;
double midx = displayContainer.width / 2d;
double midy = displayContainer.height / 2d;
double angleIncRads = Math.PI * 36d / 180d;
double ang = -Math.PI / 2d;
double maxrad = Options.width / 4d;
double maxrad = displayContainer.width / 4d;
double minrad = maxrad / 3d;
for (int i = 0; i < 10; i++) {
double rad = maxrad;

View File

@@ -19,6 +19,8 @@ package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.displayContainer;
public class HalfCircleSpinner extends Spinner {
private int ang = 0;
@@ -45,8 +47,8 @@ public class HalfCircleSpinner extends Spinner {
skipang += 359;
}
point[0] = Options.width / 2.0d + Options.height / 2 * 0.8d * Math.cos(ang/180d*Math.PI);
point[1] = Options.height / 2.0d + Options.height / 2 * 0.8d * Math.sin(ang/180d*Math.PI);
point[0] = displayContainer.width / 2.0d + displayContainer.height / 2 * 0.8d * Math.cos(ang/180d*Math.PI);
point[1] = displayContainer.height / 2.0d + displayContainer.height / 2 * 0.8d * Math.sin(ang/180d*Math.PI);
return point;
}

View File

@@ -17,17 +17,16 @@
*/
package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.*;
public class IlluminatiSpinner extends Spinner {
@Override
public void init()
{
public void init() {
init( new double[][] {
new double[] { Options.width / 2d - 120, Options.height / 2d + 80 },
new double[] { Options.width / 2d, Options.height / 2d - 160 },
new double[] { Options.width / 2d + 120, Options.height / 2d + 80 }
new double[] { displayContainer.width / 2d - 120, displayContainer.height / 2d + 80 },
new double[] { displayContainer.width / 2d, displayContainer.height / 2d - 160 },
new double[] { displayContainer.width / 2d + 120, displayContainer.height / 2d + 80 }
} );
}

View File

@@ -17,7 +17,7 @@
*/
package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.*;
public class LessThanThreeSpinner extends Spinner {
@@ -38,8 +38,8 @@ public class LessThanThreeSpinner extends Spinner {
if( angle > 360 ) angle = 0;
double theta = angle / 180d * Math.PI;
double[] pos = new double[] {
Options.width / 2d,
Options.height / 2d
displayContainer.width / 2d,
displayContainer.height / 2d
};
double r = 2 - 2 * Math.sin( theta ) + Math.sin( theta ) * Math.sqrt( Math.abs( Math.cos( theta ) ) ) / ( Math.sin( theta ) + 1.4 );

View File

@@ -17,7 +17,7 @@
*/
package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.*;
public class RektCircleSpinner extends Spinner {
@@ -25,51 +25,39 @@ public class RektCircleSpinner extends Spinner {
private int index;
private int pos;
private double size;
private int delay = 0;
@Override
public void init()
{
public void init() {
index = 0;
size = Options.height * 0.8d;
size = displayContainer.height * 0.8d;
point = new double[2];
}
@Override
public double[] getPoint()
{
public double[] getPoint() {
if (!waitForDelay()) {
return point;
}
delay = 0;
final int INC = 50;
if( index == 0 )
{
point[0] = Options.width / 2d + size / 2d - pos;
point[1] = Options.height / 2d - size / 2d;
if( index == 0 ) {
point[0] = displayContainer.width / 2d + size / 2d - pos;
point[1] = displayContainer.height / 2d - size / 2d;
index++;
}
else if( index == 1 )
{
point[0] = Options.width / 2 - size / 2;
point[1] = Options.height / 2 - size / 2 + pos;
} else if( index == 1 ) {
point[0] = displayContainer.width / 2 - size / 2;
point[1] = displayContainer.height / 2 - size / 2 + pos;
index++;
}
else if( index == 2 )
{
point[0] = Options.width / 2 - size / 2 + pos;
point[1] = Options.height / 2 + size / 2;
} else if( index == 2 ) {
point[0] = displayContainer.width / 2 - size / 2 + pos;
point[1] = displayContainer.height / 2 + size / 2;
index++;
}
else if( index == 3 )
{
point[0] = Options.width / 2 + size / 2;
point[1] = Options.height / 2 + size / 2 - pos;
} else if( index == 3 ) {
point[0] = displayContainer.width / 2 + size / 2;
point[1] = displayContainer.height / 2 + size / 2 - pos;
pos += INC;
if( pos > size )
{
if( pos > size ) {
pos = INC;
}
index = 0;

View File

@@ -17,7 +17,7 @@
*/
package yugecin.opsudance.spinners;
import yugecin.opsudance.options.Options;
import static yugecin.opsudance.core.InstanceContainer.*;
public class RektSpinner extends Spinner {
@@ -25,11 +25,11 @@ public class RektSpinner extends Spinner {
public void init() {
init(new double[][] {
{ 10, 10 },
{ Options.width / 2d, 10 },
{ Options.width - 10, 10 },
{ Options.width - 10, Options.height - 10 },
{ Options.width / 2d, Options.height - 10 },
{ 10, Options.height - 10 }
{ displayContainer.width / 2d, 10 },
{ displayContainer.width - 10, 10 },
{ displayContainer.width - 10, displayContainer.height - 10 },
{ displayContainer.width / 2d, displayContainer.height - 10 },
{ 10, displayContainer.height - 10 }
});
}

View File

@@ -19,7 +19,7 @@ package yugecin.opsudance.utils;
import org.newdawn.slick.util.Log;
import org.newdawn.slick.util.ResourceLoader;
import yugecin.opsudance.options.Configuration;
import yugecin.opsudance.core.Constants;
import java.io.IOException;
import java.util.Properties;
@@ -31,7 +31,7 @@ public class MiscUtils {
public Properties get() {
Properties props = new Properties();
try {
props.load(ResourceLoader.getResourceAsStream(Configuration.instance.VERSION_FILE));
props.load(ResourceLoader.getResourceAsStream(Constants.VERSION_FILE));
} catch (IOException e) {
Log.error("Could not read version file", e);
}