Enabled application restarts.
- Pressing Ctrl+Shift+F5 in the options menu restarts the game. Beatmaps and sounds are not reloaded. - Use GameContainer.setForceExit(false) to trigger a restart after exiting. Other changes: - Fixed general issues with track pausing/pause states. - Store all background images loaded in OsuFiles in a static hash table, instead of in individual objects. This allows easier access to the allocated memory. - Only delete OSZ files if they were unzipped. (They were previously deleted in all cases.) - Moved more images (mods, playfield, lighting) into GameImage. - Moved OsuHitObject initialization inside Utils. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -23,22 +23,21 @@ import java.util.Collections;
|
||||
|
||||
import org.newdawn.slick.Image;
|
||||
import org.newdawn.slick.Input;
|
||||
import org.newdawn.slick.SlickException;
|
||||
|
||||
/**
|
||||
* Game mods.
|
||||
*/
|
||||
public enum GameMod {
|
||||
EASY (0, "selection-mod-easy.png", Input.KEY_Q, 0.5f),
|
||||
NO_FAIL (1, "selection-mod-nofail.png", Input.KEY_W, 0.5f),
|
||||
HARD_ROCK (2, "selection-mod-hardrock.png", Input.KEY_A, 1.06f),
|
||||
SUDDEN_DEATH (3, "selection-mod-suddendeath.png", Input.KEY_S),
|
||||
SPUN_OUT (4, "selection-mod-spunout.png", Input.KEY_V, 0.9f),
|
||||
AUTO (5, "selection-mod-autoplay.png", Input.KEY_B);
|
||||
// HALF_TIME (, "selection-mod-halftime.png", Input.KEY_E, 0.3f),
|
||||
// DOUBLE_TIME (, "selection-mod-doubletime.png", Input.KEY_D, 1.12f),
|
||||
// HIDDEN (, "selection-mod-hidden.png", Input.KEY_F, 1.06f),
|
||||
// FLASHLIGHT (, "selection-mod-flashlight.png", Input.KEY_G, 1.12f);
|
||||
EASY (0, GameImage.MOD_EASY, Input.KEY_Q, 0.5f),
|
||||
NO_FAIL (1, GameImage.MOD_NO_FAIL, Input.KEY_W, 0.5f),
|
||||
HARD_ROCK (2, GameImage.MOD_HARD_ROCK, Input.KEY_A, 1.06f),
|
||||
SUDDEN_DEATH (3, GameImage.MOD_SUDDEN_DEATH, Input.KEY_S),
|
||||
SPUN_OUT (4, GameImage.MOD_SPUN_OUT, Input.KEY_V, 0.9f),
|
||||
AUTO (5, GameImage.MOD_AUTO, Input.KEY_B);
|
||||
// HALF_TIME (, GameImage.MOD_HALF_TIME, Input.KEY_E, 0.3f),
|
||||
// DOUBLE_TIME (, GameImage.MOD_DOUBLE_TIME, Input.KEY_D, 1.12f),
|
||||
// HIDDEN (, GameImage.MOD_HIDDEN, Input.KEY_F, 1.06f),
|
||||
// FLASHLIGHT (, GameImage.MOD_FLASHLIGHT, Input.KEY_G, 1.12f);
|
||||
|
||||
/**
|
||||
* The ID of the mod (used for positioning).
|
||||
@@ -48,7 +47,7 @@ public enum GameMod {
|
||||
/**
|
||||
* The file name of the mod image.
|
||||
*/
|
||||
private String filename;
|
||||
private GameImage image;
|
||||
|
||||
/**
|
||||
* The shortcut key associated with the mod.
|
||||
@@ -94,12 +93,12 @@ public enum GameMod {
|
||||
/**
|
||||
* Constructor.
|
||||
* @param id the ID of the mod (for positioning).
|
||||
* @param filename the image file name
|
||||
* @param image the GameImage
|
||||
* @param key the shortcut key
|
||||
*/
|
||||
GameMod(int id, String filename, int key) {
|
||||
GameMod(int id, GameImage image, int key) {
|
||||
this.id = id;
|
||||
this.filename = filename;
|
||||
this.image = image;
|
||||
this.key = key;
|
||||
this.multiplier = 1f;
|
||||
}
|
||||
@@ -107,13 +106,13 @@ public enum GameMod {
|
||||
/**
|
||||
* Constructor.
|
||||
* @param id the ID of the mod (for positioning).
|
||||
* @param filename the image file name
|
||||
* @param image the GameImage
|
||||
* @param key the shortcut key
|
||||
* @param multiplier the score multiplier
|
||||
*/
|
||||
GameMod(int id, String filename, int key, float multiplier) {
|
||||
GameMod(int id, GameImage image, int key, float multiplier) {
|
||||
this.id = id;
|
||||
this.filename = filename;
|
||||
this.image = image;
|
||||
this.key = key;
|
||||
this.multiplier = multiplier;
|
||||
}
|
||||
@@ -124,24 +123,17 @@ public enum GameMod {
|
||||
* @param height the container height
|
||||
*/
|
||||
public void init(int width, int height) {
|
||||
try {
|
||||
// create and scale image
|
||||
Image img = new Image(filename);
|
||||
float scale = (height * 0.12f) / img.getHeight();
|
||||
img = img.getScaledCopy(scale);
|
||||
Image img = image.getImage();
|
||||
|
||||
// find coordinates
|
||||
float offsetX = img.getWidth() * 1.5f;
|
||||
float x = (width / 2f) - (offsetX * SIZE / 2.75f);
|
||||
float y = (height * 0.8f) + (img.getHeight() / 2);
|
||||
// find coordinates
|
||||
float offsetX = img.getWidth() * 1.5f;
|
||||
float x = (width / 2f) - (offsetX * SIZE / 2.75f);
|
||||
float y = (height * 0.8f) + (img.getHeight() / 2);
|
||||
|
||||
// create button
|
||||
img.setAlpha(0.5f);
|
||||
this.button = new MenuButton(img, x + (offsetX * id), y);
|
||||
this.button.setHoverScale(1.15f);
|
||||
} catch (SlickException e) {
|
||||
ErrorHandler.error(String.format("Failed to initialize game mod '%s'.", this), e, false);
|
||||
}
|
||||
// create button
|
||||
img.setAlpha(0.5f);
|
||||
this.button = new MenuButton(img, x + (offsetX * id), y);
|
||||
this.button.setHoverScale(1.15f);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,7 +194,7 @@ public enum GameMod {
|
||||
* Returns the image associated with the mod.
|
||||
* @return the associated image
|
||||
*/
|
||||
public Image getImage() { return button.getImage(); }
|
||||
public Image getImage() { return image.getImage(); }
|
||||
|
||||
/**
|
||||
* Returns the mod ID.
|
||||
|
||||
Reference in New Issue
Block a user