Removed some unnecessary SlickException throwing/catching.
Mostly leftovers from moving Image creation to GameImage. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
parent
e02cf60312
commit
d6c7476b88
|
@ -110,9 +110,24 @@ public enum GameImage {
|
||||||
SLIDER_TICK ("sliderscorepoint", "png"),
|
SLIDER_TICK ("sliderscorepoint", "png"),
|
||||||
|
|
||||||
// Spinner
|
// Spinner
|
||||||
SPINNER_CIRCLE ("spinner-circle", "png"),
|
SPINNER_CIRCLE ("spinner-circle", "png") {
|
||||||
SPINNER_APPROACHCIRCLE ("spinner-approachcircle", "png"),
|
@Override
|
||||||
SPINNER_METRE ("spinner-metre", "png"),
|
protected Image process_sub(Image img, int w, int h) {
|
||||||
|
return img.getScaledCopy(h * 9 / 10, h * 9 / 10);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SPINNER_APPROACHCIRCLE ("spinner-approachcircle", "png") {
|
||||||
|
@Override
|
||||||
|
protected Image process_sub(Image img, int w, int h) {
|
||||||
|
return img.getScaledCopy(h * 9 / 10, h * 9 / 10);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SPINNER_METRE ("spinner-metre", "png") {
|
||||||
|
@Override
|
||||||
|
protected Image process_sub(Image img, int w, int h) {
|
||||||
|
return img.getScaledCopy(w, h);
|
||||||
|
}
|
||||||
|
},
|
||||||
SPINNER_SPIN ("spinner-spin", "png"),
|
SPINNER_SPIN ("spinner-spin", "png"),
|
||||||
SPINNER_CLEAR ("spinner-clear", "png"),
|
SPINNER_CLEAR ("spinner-clear", "png"),
|
||||||
SPINNER_OSU ("spinner-osu", "png"),
|
SPINNER_OSU ("spinner-osu", "png"),
|
||||||
|
|
|
@ -31,7 +31,6 @@ import java.util.LinkedList;
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import org.newdawn.slick.Image;
|
import org.newdawn.slick.Image;
|
||||||
import org.newdawn.slick.SlickException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds score data and renders all score-related elements.
|
* Holds score data and renders all score-related elements.
|
||||||
|
@ -245,9 +244,8 @@ public class GameScore {
|
||||||
/**
|
/**
|
||||||
* Loads all game score images.
|
* Loads all game score images.
|
||||||
* @param dir the image directory
|
* @param dir the image directory
|
||||||
* @throws SlickException
|
|
||||||
*/
|
*/
|
||||||
public void loadImages(File dir) throws SlickException {
|
public void loadImages(File dir) {
|
||||||
// combo burst images
|
// combo burst images
|
||||||
if (GameImage.COMBO_BURST.hasSkinImages() ||
|
if (GameImage.COMBO_BURST.hasSkinImages() ||
|
||||||
(!GameImage.COMBO_BURST.hasSkinImage() && GameImage.COMBO_BURST.getImages() != null))
|
(!GameImage.COMBO_BURST.hasSkinImage() && GameImage.COMBO_BURST.getImages() != null))
|
||||||
|
|
|
@ -680,9 +680,8 @@ public class Options {
|
||||||
* If the configured resolution is larger than the screen size, the smallest
|
* If the configured resolution is larger than the screen size, the smallest
|
||||||
* available resolution will be used.
|
* available resolution will be used.
|
||||||
* @param app the game container
|
* @param app the game container
|
||||||
* @throws SlickException failure to set display mode
|
|
||||||
*/
|
*/
|
||||||
public static void setDisplayMode(Container app) throws SlickException {
|
public static void setDisplayMode(Container app) {
|
||||||
int screenWidth = app.getScreenWidth();
|
int screenWidth = app.getScreenWidth();
|
||||||
int screenHeight = app.getScreenHeight();
|
int screenHeight = app.getScreenHeight();
|
||||||
|
|
||||||
|
@ -690,7 +689,11 @@ public class Options {
|
||||||
if (screenWidth < resolution.getWidth() || screenHeight < resolution.getHeight())
|
if (screenWidth < resolution.getWidth() || screenHeight < resolution.getHeight())
|
||||||
resolution = Resolution.RES_800_600;
|
resolution = Resolution.RES_800_600;
|
||||||
|
|
||||||
app.setDisplayMode(resolution.getWidth(), resolution.getHeight(), false);
|
try {
|
||||||
|
app.setDisplayMode(resolution.getWidth(), resolution.getHeight(), false);
|
||||||
|
} catch (SlickException e) {
|
||||||
|
ErrorHandler.error("Failed to set display mode.", e, true);
|
||||||
|
}
|
||||||
|
|
||||||
// set borderless window if dimensions match screen size
|
// set borderless window if dimensions match screen size
|
||||||
boolean borderless = (screenWidth == resolution.getWidth() && screenHeight == resolution.getHeight());
|
boolean borderless = (screenWidth == resolution.getWidth() && screenHeight == resolution.getHeight());
|
||||||
|
|
|
@ -29,7 +29,6 @@ import itdelatrisu.opsu.states.Game;
|
||||||
import org.newdawn.slick.Color;
|
import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.GameContainer;
|
import org.newdawn.slick.GameContainer;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import org.newdawn.slick.SlickException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data type representing a circle object.
|
* Data type representing a circle object.
|
||||||
|
@ -64,9 +63,8 @@ public class Circle implements HitObject {
|
||||||
* Initializes the Circle data type with map modifiers, images, and dimensions.
|
* Initializes the Circle data type with map modifiers, images, and dimensions.
|
||||||
* @param container the game container
|
* @param container the game container
|
||||||
* @param circleSize the map's circleSize value
|
* @param circleSize the map's circleSize value
|
||||||
* @throws SlickException
|
|
||||||
*/
|
*/
|
||||||
public static void init(GameContainer container, float circleSize) throws SlickException {
|
public static void init(GameContainer container, float circleSize) {
|
||||||
int diameter = (int) (96 - (circleSize * 8));
|
int diameter = (int) (96 - (circleSize * 8));
|
||||||
diameter = diameter * container.getWidth() / 640; // convert from Osupixels (640x480)
|
diameter = diameter * container.getWidth() / 640; // convert from Osupixels (640x480)
|
||||||
GameImage.HITCIRCLE.setImage(GameImage.HITCIRCLE.getImage().getScaledCopy(diameter, diameter));
|
GameImage.HITCIRCLE.setImage(GameImage.HITCIRCLE.getImage().getScaledCopy(diameter, diameter));
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.GameContainer;
|
import org.newdawn.slick.GameContainer;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import org.newdawn.slick.Image;
|
import org.newdawn.slick.Image;
|
||||||
import org.newdawn.slick.SlickException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data type representing a slider object.
|
* Data type representing a slider object.
|
||||||
|
@ -273,9 +272,8 @@ public class Slider implements HitObject {
|
||||||
* @param container the game container
|
* @param container the game container
|
||||||
* @param circleSize the map's circleSize value
|
* @param circleSize the map's circleSize value
|
||||||
* @param osu the associated OsuFile object
|
* @param osu the associated OsuFile object
|
||||||
* @throws SlickException
|
|
||||||
*/
|
*/
|
||||||
public static void init(GameContainer container, float circleSize, OsuFile osu) throws SlickException {
|
public static void init(GameContainer container, float circleSize, OsuFile osu) {
|
||||||
int diameter = (int) (96 - (circleSize * 8));
|
int diameter = (int) (96 - (circleSize * 8));
|
||||||
diameter = diameter * container.getWidth() / 640; // convert from Osupixels (640x480)
|
diameter = diameter * container.getWidth() / 640; // convert from Osupixels (640x480)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.newdawn.slick.Color;
|
||||||
import org.newdawn.slick.GameContainer;
|
import org.newdawn.slick.GameContainer;
|
||||||
import org.newdawn.slick.Graphics;
|
import org.newdawn.slick.Graphics;
|
||||||
import org.newdawn.slick.Image;
|
import org.newdawn.slick.Image;
|
||||||
import org.newdawn.slick.SlickException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data type representing a spinner object.
|
* Data type representing a spinner object.
|
||||||
|
@ -71,17 +70,10 @@ public class Spinner implements HitObject {
|
||||||
/**
|
/**
|
||||||
* Initializes the Spinner data type with images and dimensions.
|
* Initializes the Spinner data type with images and dimensions.
|
||||||
* @param container the game container
|
* @param container the game container
|
||||||
* @throws SlickException
|
|
||||||
*/
|
*/
|
||||||
public static void init(GameContainer container) throws SlickException {
|
public static void init(GameContainer container) {
|
||||||
width = container.getWidth();
|
width = container.getWidth();
|
||||||
height = container.getHeight();
|
height = container.getHeight();
|
||||||
|
|
||||||
Image spinnerCircle = GameImage.SPINNER_CIRCLE.getImage();
|
|
||||||
GameImage.SPINNER_CIRCLE.setImage(spinnerCircle.getScaledCopy(height * 9 / 10, height * 9 / 10));
|
|
||||||
GameImage.SPINNER_APPROACHCIRCLE.setImage(GameImage.SPINNER_APPROACHCIRCLE.getImage().getScaledCopy(
|
|
||||||
spinnerCircle.getWidth(), spinnerCircle.getHeight()));
|
|
||||||
GameImage.SPINNER_METRE.setImage(GameImage.SPINNER_METRE.getImage().getScaledCopy(width, height));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,7 +101,7 @@ public class Spinner implements HitObject {
|
||||||
boolean spinnerComplete = (rotations >= rotationsNeeded);
|
boolean spinnerComplete = (rotations >= rotationsNeeded);
|
||||||
|
|
||||||
// TODO: draw "OSU!" image after spinner ends
|
// TODO: draw "OSU!" image after spinner ends
|
||||||
//spinnerOsuImage.drawCentered(width / 2, height / 4);
|
//GameImage.SPINNER_OSU.getImage().drawCentered(width / 2, height / 4);
|
||||||
|
|
||||||
// darken screen
|
// darken screen
|
||||||
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
g.setColor(Utils.COLOR_BLACK_ALPHA);
|
||||||
|
|
|
@ -848,74 +848,66 @@ public class Game extends BasicGameState {
|
||||||
|
|
||||||
// load other images...
|
// load other images...
|
||||||
((GamePauseMenu) game.getState(Opsu.STATE_GAMEPAUSEMENU)).loadImages();
|
((GamePauseMenu) game.getState(Opsu.STATE_GAMEPAUSEMENU)).loadImages();
|
||||||
try {
|
score.loadImages(osu.getFile().getParentFile());
|
||||||
score.loadImages(osu.getFile().getParentFile());
|
|
||||||
} catch (Exception e) {
|
|
||||||
ErrorHandler.error("Failed to load GameScore images.", e, false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set map modifiers.
|
* Set map modifiers.
|
||||||
*/
|
*/
|
||||||
private void setMapModifiers() {
|
private void setMapModifiers() {
|
||||||
try {
|
// map-based properties, re-initialized each game
|
||||||
// map-based properties, re-initialized each game
|
float circleSize = osu.circleSize;
|
||||||
float circleSize = osu.circleSize;
|
float approachRate = osu.approachRate;
|
||||||
float approachRate = osu.approachRate;
|
float overallDifficulty = osu.overallDifficulty;
|
||||||
float overallDifficulty = osu.overallDifficulty;
|
float HPDrainRate = osu.HPDrainRate;
|
||||||
float HPDrainRate = osu.HPDrainRate;
|
|
||||||
|
|
||||||
// "Hard Rock" modifiers
|
// "Hard Rock" modifiers
|
||||||
if (GameMod.HARD_ROCK.isActive()) {
|
if (GameMod.HARD_ROCK.isActive()) {
|
||||||
circleSize = Math.min(circleSize * 1.4f, 10);
|
circleSize = Math.min(circleSize * 1.4f, 10);
|
||||||
approachRate = Math.min(approachRate * 1.4f, 10);
|
approachRate = Math.min(approachRate * 1.4f, 10);
|
||||||
overallDifficulty = Math.min(overallDifficulty * 1.4f, 10);
|
overallDifficulty = Math.min(overallDifficulty * 1.4f, 10);
|
||||||
HPDrainRate = Math.min(HPDrainRate * 1.4f, 10);
|
HPDrainRate = Math.min(HPDrainRate * 1.4f, 10);
|
||||||
}
|
|
||||||
|
|
||||||
// "Easy" modifiers
|
|
||||||
else if (GameMod.EASY.isActive()) {
|
|
||||||
circleSize /= 2f;
|
|
||||||
approachRate /= 2f;
|
|
||||||
overallDifficulty /= 2f;
|
|
||||||
HPDrainRate /= 2f;
|
|
||||||
}
|
|
||||||
|
|
||||||
// fixed difficulty overrides
|
|
||||||
if (Options.getFixedCS() > 0f)
|
|
||||||
circleSize = Options.getFixedCS();
|
|
||||||
if (Options.getFixedAR() > 0f)
|
|
||||||
approachRate = Options.getFixedAR();
|
|
||||||
if (Options.getFixedOD() > 0f)
|
|
||||||
overallDifficulty = Options.getFixedOD();
|
|
||||||
if (Options.getFixedHP() > 0f)
|
|
||||||
HPDrainRate = Options.getFixedHP();
|
|
||||||
|
|
||||||
// initialize objects
|
|
||||||
Circle.init(container, circleSize);
|
|
||||||
Slider.init(container, circleSize, osu);
|
|
||||||
Spinner.init(container);
|
|
||||||
|
|
||||||
// approachRate (hit object approach time)
|
|
||||||
if (approachRate < 5)
|
|
||||||
approachTime = (int) (1800 - (approachRate * 120));
|
|
||||||
else
|
|
||||||
approachTime = (int) (1200 - ((approachRate - 5) * 150));
|
|
||||||
|
|
||||||
// overallDifficulty (hit result time offsets)
|
|
||||||
hitResultOffset = new int[GameScore.HIT_MAX];
|
|
||||||
hitResultOffset[GameScore.HIT_300] = (int) (78 - (overallDifficulty * 6));
|
|
||||||
hitResultOffset[GameScore.HIT_100] = (int) (138 - (overallDifficulty * 8));
|
|
||||||
hitResultOffset[GameScore.HIT_50] = (int) (198 - (overallDifficulty * 10));
|
|
||||||
hitResultOffset[GameScore.HIT_MISS] = (int) (500 - (overallDifficulty * 10));
|
|
||||||
|
|
||||||
// HPDrainRate (health change), overallDifficulty (scoring)
|
|
||||||
score.setDrainRate(HPDrainRate);
|
|
||||||
score.setDifficulty(overallDifficulty);
|
|
||||||
} catch (SlickException e) {
|
|
||||||
ErrorHandler.error("Error while setting map modifiers.", e, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "Easy" modifiers
|
||||||
|
else if (GameMod.EASY.isActive()) {
|
||||||
|
circleSize /= 2f;
|
||||||
|
approachRate /= 2f;
|
||||||
|
overallDifficulty /= 2f;
|
||||||
|
HPDrainRate /= 2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fixed difficulty overrides
|
||||||
|
if (Options.getFixedCS() > 0f)
|
||||||
|
circleSize = Options.getFixedCS();
|
||||||
|
if (Options.getFixedAR() > 0f)
|
||||||
|
approachRate = Options.getFixedAR();
|
||||||
|
if (Options.getFixedOD() > 0f)
|
||||||
|
overallDifficulty = Options.getFixedOD();
|
||||||
|
if (Options.getFixedHP() > 0f)
|
||||||
|
HPDrainRate = Options.getFixedHP();
|
||||||
|
|
||||||
|
// initialize objects
|
||||||
|
Circle.init(container, circleSize);
|
||||||
|
Slider.init(container, circleSize, osu);
|
||||||
|
Spinner.init(container);
|
||||||
|
|
||||||
|
// approachRate (hit object approach time)
|
||||||
|
if (approachRate < 5)
|
||||||
|
approachTime = (int) (1800 - (approachRate * 120));
|
||||||
|
else
|
||||||
|
approachTime = (int) (1200 - ((approachRate - 5) * 150));
|
||||||
|
|
||||||
|
// overallDifficulty (hit result time offsets)
|
||||||
|
hitResultOffset = new int[GameScore.HIT_MAX];
|
||||||
|
hitResultOffset[GameScore.HIT_300] = (int) (78 - (overallDifficulty * 6));
|
||||||
|
hitResultOffset[GameScore.HIT_100] = (int) (138 - (overallDifficulty * 8));
|
||||||
|
hitResultOffset[GameScore.HIT_50] = (int) (198 - (overallDifficulty * 10));
|
||||||
|
hitResultOffset[GameScore.HIT_MISS] = (int) (500 - (overallDifficulty * 10));
|
||||||
|
|
||||||
|
// HPDrainRate (health change), overallDifficulty (scoring)
|
||||||
|
score.setDrainRate(HPDrainRate);
|
||||||
|
score.setDifficulty(overallDifficulty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user