working splash state
This commit is contained in:
parent
5e09a1d24a
commit
8b226f3afc
|
@ -85,7 +85,7 @@ public class Opsu extends StateBasedGame {
|
|||
|
||||
@Override
|
||||
public void initStatesList(GameContainer container) throws SlickException {
|
||||
addState(new Splash(STATE_SPLASH));
|
||||
//addState(new Splash(STATE_SPLASH));
|
||||
addState(new MainMenu(STATE_MAINMENU));
|
||||
addState(new ButtonMenu(STATE_BUTTONMENU));
|
||||
addState(new SongMenu(STATE_SONGMENU));
|
||||
|
@ -206,7 +206,7 @@ public class Opsu extends StateBasedGame {
|
|||
Container app = new Container(opsu);
|
||||
|
||||
// basic game settings
|
||||
Options.setDisplayMode(app);
|
||||
//Options.setDisplayMode(app);
|
||||
String[] icons = { "icon16.png", "icon32.png" };
|
||||
try {
|
||||
app.setIcons(icons);
|
||||
|
|
|
@ -59,6 +59,8 @@ import com.sun.jna.platform.win32.Advapi32Util;
|
|||
import com.sun.jna.platform.win32.Win32Exception;
|
||||
import com.sun.jna.platform.win32.WinReg;
|
||||
import yugecin.opsudance.*;
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
import yugecin.opsudance.events.BubbleNotificationEvent;
|
||||
import yugecin.opsudance.movers.factories.ExgonMoverFactory;
|
||||
import yugecin.opsudance.movers.factories.QuadraticBezierMoverFactory;
|
||||
import yugecin.opsudance.movers.slidermovers.DefaultSliderMoverController;
|
||||
|
@ -1294,10 +1296,9 @@ public class Options {
|
|||
|
||||
/**
|
||||
* Sets the master volume level (if within valid range).
|
||||
* @param container the game container
|
||||
* @param volume the volume [0, 1]
|
||||
*/
|
||||
public static void setMasterVolume(GameContainer container, float volume) {
|
||||
public static void setMasterVolume(float volume) {
|
||||
if (volume >= 0f && volume <= 1f) {
|
||||
GameOption.MASTER_VOLUME.setValue((int) (volume * 100f));
|
||||
MusicController.setVolume(getMasterVolume() * getMusicVolume());
|
||||
|
@ -1346,11 +1347,10 @@ public class Options {
|
|||
* <p>
|
||||
* If the configured resolution is larger than the screen size, the smallest
|
||||
* available resolution will be used.
|
||||
* @param app the game container
|
||||
*/
|
||||
public static void setDisplayMode(Container app) {
|
||||
int screenWidth = app.getScreenWidth();
|
||||
int screenHeight = app.getScreenHeight();
|
||||
public static void setDisplayMode(DisplayContainer container) {
|
||||
int screenWidth = container.nativeDisplayMode.getWidth();
|
||||
int screenHeight = container.nativeDisplayMode.getHeight();
|
||||
|
||||
resolutions[0] = screenWidth + "x" + screenHeight;
|
||||
if (resolutionIdx < 0 || resolutionIdx > resolutions.length) {
|
||||
|
@ -1370,9 +1370,10 @@ public class Options {
|
|||
}
|
||||
|
||||
try {
|
||||
app.setDisplayMode(width, height, isFullscreen());
|
||||
} catch (SlickException e) {
|
||||
ErrorHandler.error("Failed to set display mode.", e, true);
|
||||
container.setDisplayMode(width, height, isFullscreen());
|
||||
} catch (Exception e) {
|
||||
container.eventBus.post(new BubbleNotificationEvent("Failed to change resolution", BubbleNotificationEvent.COMMONCOLOR_RED));
|
||||
Log.error("Failed to set display mode.", e);
|
||||
}
|
||||
|
||||
if (!isFullscreen()) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package itdelatrisu.opsu;
|
||||
|
||||
import itdelatrisu.opsu.audio.MusicController;
|
||||
import itdelatrisu.opsu.audio.SoundController;
|
||||
import itdelatrisu.opsu.audio.SoundEffect;
|
||||
import itdelatrisu.opsu.beatmap.HitObject;
|
||||
|
@ -71,6 +72,7 @@ import org.newdawn.slick.state.StateBasedGame;
|
|||
import org.newdawn.slick.util.Log;
|
||||
|
||||
import com.sun.jna.platform.FileUtils;
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
|
||||
/**
|
||||
* Contains miscellaneous utilities.
|
||||
|
@ -89,40 +91,18 @@ public class Utils {
|
|||
Arrays.sort(illegalChars);
|
||||
}
|
||||
|
||||
// game-related variables
|
||||
private static Input input;
|
||||
|
||||
// This class should not be instantiated.
|
||||
private Utils() {}
|
||||
|
||||
/**
|
||||
* Initializes game settings and class data.
|
||||
* @param container the game container
|
||||
* @param game the game object
|
||||
*/
|
||||
public static void init(GameContainer container, StateBasedGame game) {
|
||||
input = container.getInput();
|
||||
int width = container.getWidth();
|
||||
int height = container.getHeight();
|
||||
public static void init(DisplayContainer displayContainer) {
|
||||
// TODO clean this up
|
||||
|
||||
// game settings
|
||||
container.setTargetFrameRate(Options.getTargetFPS());
|
||||
container.setVSync(Options.getTargetFPS() == 60);
|
||||
container.setMusicVolume(Options.getMusicVolume() * Options.getMasterVolume());
|
||||
container.setShowFPS(false);
|
||||
container.getInput().enableKeyRepeat();
|
||||
container.setAlwaysRender(true);
|
||||
container.setUpdateOnlyWhenVisible(false);
|
||||
|
||||
// calculate UI scale
|
||||
GameImage.init(width, height);
|
||||
|
||||
// create fonts
|
||||
try {
|
||||
Fonts.init();
|
||||
} catch (Exception e) {
|
||||
ErrorHandler.error("Failed to load fonts.", e, true);
|
||||
}
|
||||
displayContainer.setFPS(Options.getTargetFPS()); // TODO move this elsewhere
|
||||
MusicController.setMusicVolume(Options.getMusicVolume() * Options.getMasterVolume());
|
||||
|
||||
// load skin
|
||||
Options.loadSkin();
|
||||
|
@ -134,19 +114,19 @@ public class Utils {
|
|||
}
|
||||
|
||||
// initialize game mods
|
||||
GameMod.init(width, height);
|
||||
GameMod.init(displayContainer.width, displayContainer.height);
|
||||
|
||||
// initialize playback buttons
|
||||
PlaybackSpeed.init(width, height);
|
||||
PlaybackSpeed.init(displayContainer.width, displayContainer.height);
|
||||
|
||||
// initialize hit objects
|
||||
HitObject.init(width, height);
|
||||
HitObject.init(displayContainer.width, displayContainer.height);
|
||||
|
||||
// initialize download nodes
|
||||
DownloadNode.init(width, height);
|
||||
DownloadNode.init(displayContainer.width, displayContainer.height);
|
||||
|
||||
// initialize UI components
|
||||
UI.init(container, game);
|
||||
UI.init(displayContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -246,12 +226,15 @@ public class Utils {
|
|||
* @return true if pressed
|
||||
*/
|
||||
public static boolean isGameKeyPressed() {
|
||||
/*
|
||||
boolean mouseDown = !Options.isMouseDisabled() && (
|
||||
input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) ||
|
||||
input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON));
|
||||
return (mouseDown ||
|
||||
input.isKeyDown(Options.getGameKeyLeft()) ||
|
||||
input.isKeyDown(Options.getGameKeyRight()));
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -578,4 +578,13 @@ public class MusicController {
|
|||
ErrorHandler.error("Failed to destroy OpenAL.", e, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default volume for music
|
||||
* @param volume the new default value for music volume
|
||||
*/
|
||||
public static void setMusicVolume(float volume) {
|
||||
SoundStore.get().setMusicVolume(volume);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package itdelatrisu.opsu.states;
|
||||
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.Opsu;
|
||||
import itdelatrisu.opsu.Options;
|
||||
import itdelatrisu.opsu.Utils;
|
||||
import itdelatrisu.opsu.audio.MusicController;
|
||||
|
@ -36,19 +35,18 @@ import itdelatrisu.opsu.ui.animations.AnimationEquation;
|
|||
import java.io.File;
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Input;
|
||||
import org.newdawn.slick.SlickException;
|
||||
import org.newdawn.slick.state.BasicGameState;
|
||||
import org.newdawn.slick.state.StateBasedGame;
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
import yugecin.opsudance.core.state.BaseOpsuState;
|
||||
|
||||
/**
|
||||
* "Splash Screen" state.
|
||||
* <p>
|
||||
* Loads game resources and enters "Main Menu" state.
|
||||
*/
|
||||
public class Splash extends BasicGameState {
|
||||
public class Splash extends BaseOpsuState {
|
||||
|
||||
/** Minimum time, in milliseconds, to display the splash screen (and fade in the logo). */
|
||||
private static final int MIN_SPLASH_TIME = 400;
|
||||
|
||||
|
@ -71,18 +69,15 @@ public class Splash extends BasicGameState {
|
|||
private AnimatedValue logoAlpha;
|
||||
|
||||
// game-related variables
|
||||
private final int state;
|
||||
private GameContainer container;
|
||||
private boolean init = false;
|
||||
|
||||
public Splash(int state) {
|
||||
this.state = state;
|
||||
public Splash(DisplayContainer displayContainer) {
|
||||
super(displayContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(GameContainer container, StateBasedGame game)
|
||||
throws SlickException {
|
||||
this.container = container;
|
||||
protected void revalidate() {
|
||||
super.revalidate();
|
||||
|
||||
// check if skin changed
|
||||
if (Options.getSkin() != null)
|
||||
|
@ -92,7 +87,7 @@ public class Splash extends BasicGameState {
|
|||
this.watchServiceChange = Options.isWatchServiceEnabled() && BeatmapWatchService.get() == null;
|
||||
|
||||
// load Utils class first (needed in other 'init' methods)
|
||||
Utils.init(container, game);
|
||||
Utils.init(displayContainer);
|
||||
|
||||
// fade in logo
|
||||
this.logoAlpha = new AnimatedValue(MIN_SPLASH_TIME, 0f, 1f, AnimationEquation.LINEAR);
|
||||
|
@ -100,16 +95,14 @@ public class Splash extends BasicGameState {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(GameContainer container, StateBasedGame game, Graphics g)
|
||||
throws SlickException {
|
||||
public void render(Graphics g) {
|
||||
g.setBackground(Color.black);
|
||||
GameImage.MENU_LOGO.getImage().drawCentered(container.getWidth() / 2, container.getHeight() / 2);
|
||||
GameImage.MENU_LOGO.getImage().drawCentered(displayContainer.width / 2, displayContainer.height / 2);
|
||||
UI.drawLoadingProgress(g);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(GameContainer container, StateBasedGame game, int delta)
|
||||
throws SlickException {
|
||||
public void update() {
|
||||
if (!init) {
|
||||
init = true;
|
||||
|
||||
|
@ -165,7 +158,7 @@ public class Splash extends BasicGameState {
|
|||
}
|
||||
|
||||
// fade in logo
|
||||
if (logoAlpha.update(delta))
|
||||
if (logoAlpha.update(displayContainer.delta))
|
||||
GameImage.MENU_LOGO.getImage().setAlpha(logoAlpha.getValue());
|
||||
|
||||
// change states when loading complete
|
||||
|
@ -176,30 +169,32 @@ public class Splash extends BasicGameState {
|
|||
if (Options.isThemeSongEnabled())
|
||||
MusicController.playThemeSong();
|
||||
else
|
||||
((SongMenu) game.getState(Opsu.STATE_SONGMENU)).setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
|
||||
//((SongMenu) game.getState(Opsu.STATE_SONGMENU)).setFocus(BeatmapSetList.get().getRandomNode(), -1, true, true);
|
||||
System.out.println(("todo"));
|
||||
// TODO
|
||||
}
|
||||
|
||||
// play the theme song
|
||||
else
|
||||
MusicController.playThemeSong();
|
||||
|
||||
game.enterState(Opsu.STATE_MAINMENU);
|
||||
//game.enterState(Opsu.STATE_MAINMENU);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getID() { return state; }
|
||||
|
||||
@Override
|
||||
public void keyPressed(int key, char c) {
|
||||
public boolean keyPressed(int key, char c) {
|
||||
if (key == Input.KEY_ESCAPE) {
|
||||
// close program
|
||||
if (++escapeCount >= 3)
|
||||
container.exit();
|
||||
if (++escapeCount >= 3) System.out.println("hi");
|
||||
//container.exit(); // TODO
|
||||
|
||||
// stop parsing beatmaps by sending interrupt to BeatmapParser
|
||||
else if (thread != null)
|
||||
thread.interrupt();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.lwjgl.LWJGLException;
|
|||
import org.newdawn.slick.*;
|
||||
import org.newdawn.slick.state.StateBasedGame;
|
||||
import yugecin.opsudance.Dancer;
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
|
||||
/**
|
||||
* Updates and draws the cursor.
|
||||
|
@ -68,9 +69,7 @@ public class Cursor {
|
|||
private boolean newStyle;
|
||||
|
||||
// game-related variables
|
||||
private static GameContainer container;
|
||||
private static StateBasedGame game;
|
||||
private static Input input;
|
||||
private static DisplayContainer displayContainer;
|
||||
|
||||
public static Color lastObjColor = Color.white;
|
||||
public static Color lastMirroredObjColor = Color.white;
|
||||
|
@ -82,13 +81,9 @@ public class Cursor {
|
|||
|
||||
/**
|
||||
* Initializes the class.
|
||||
* @param container the game container
|
||||
* @param game the game object
|
||||
*/
|
||||
public static void init(GameContainer container, StateBasedGame game) {
|
||||
Cursor.container = container;
|
||||
Cursor.game = game;
|
||||
Cursor.input = container.getInput();
|
||||
public static void init(DisplayContainer displayContainer) {
|
||||
Cursor.displayContainer = displayContainer;
|
||||
|
||||
// create empty cursor to simulate hiding the cursor
|
||||
try {
|
||||
|
@ -116,12 +111,14 @@ public class Cursor {
|
|||
* Draws the cursor.
|
||||
*/
|
||||
public void draw() {
|
||||
/*
|
||||
int state = game.getCurrentStateID();
|
||||
boolean mousePressed =
|
||||
(((state == Opsu.STATE_GAME || state == Opsu.STATE_GAMEPAUSEMENU) && Utils.isGameKeyPressed()) ||
|
||||
((input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON) || input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) &&
|
||||
!(state == Opsu.STATE_GAME && Options.isMouseDisabled())));
|
||||
draw(input.getMouseX(), input.getMouseY(), mousePressed);
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,7 +212,7 @@ public class Cursor {
|
|||
public void setCursorPosition(int mouseX, int mouseY) {
|
||||
// TODO: use an image buffer
|
||||
int removeCount = 0;
|
||||
float FPSmod = Math.max(container.getFPS(), 1) / 30f;
|
||||
float FPSmod = Math.max(1000 / displayContainer.renderDelta, 1) / 30f; // TODO
|
||||
if (newStyle) {
|
||||
// new style: add all points between cursor movements
|
||||
if ((lastPosition.x == 0 && lastPosition.y == 0) || !addCursorPoints(lastPosition.x, lastPosition.y, mouseX, mouseY)) {
|
||||
|
@ -349,11 +346,13 @@ public class Cursor {
|
|||
*/
|
||||
public void hide() {
|
||||
if (emptyCursor != null) {
|
||||
/*
|
||||
try {
|
||||
container.setMouseCursor(emptyCursor, 0, 0);
|
||||
} catch (SlickException e) {
|
||||
ErrorHandler.error("Failed to hide the cursor.", e, true);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -361,6 +360,6 @@ public class Cursor {
|
|||
* Unhides the cursor.
|
||||
*/
|
||||
public void show() {
|
||||
container.setDefaultMouseCursor();
|
||||
//container.setDefaultMouseCursor();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ import org.newdawn.slick.Graphics;
|
|||
import org.newdawn.slick.Image;
|
||||
import org.newdawn.slick.Input;
|
||||
import org.newdawn.slick.state.StateBasedGame;
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
|
||||
/**
|
||||
* Draws common UI components.
|
||||
|
@ -75,7 +76,7 @@ public class UI {
|
|||
private static AnimatedValue tooltipAlpha = new AnimatedValue(200, 0f, 1f, AnimationEquation.LINEAR);
|
||||
|
||||
// game-related variables
|
||||
private static GameContainer container;
|
||||
private static DisplayContainer displayContainer;
|
||||
private static Input input;
|
||||
|
||||
// This class should not be instantiated.
|
||||
|
@ -83,24 +84,21 @@ public class UI {
|
|||
|
||||
/**
|
||||
* Initializes UI data.
|
||||
* @param container the game container
|
||||
* @param game the game object
|
||||
*/
|
||||
public static void init(GameContainer container, StateBasedGame game) {
|
||||
UI.container = container;
|
||||
UI.input = container.getInput();
|
||||
public static void init(DisplayContainer displayContainer) {
|
||||
UI.displayContainer = displayContainer;
|
||||
|
||||
// initialize cursor
|
||||
Cursor.init(container, game);
|
||||
Cursor.init(displayContainer);
|
||||
cursor.hide();
|
||||
|
||||
// back button
|
||||
if (GameImage.MENU_BACK.getImages() != null) {
|
||||
Animation back = GameImage.MENU_BACK.getAnimation(120);
|
||||
backButton = new MenuButton(back, back.getWidth() / 2f, container.getHeight() - (back.getHeight() / 2f));
|
||||
backButton = new MenuButton(back, back.getWidth() / 2f, displayContainer.height - (back.getHeight() / 2f));
|
||||
} else {
|
||||
Image back = GameImage.MENU_BACK.getImage();
|
||||
backButton = new MenuButton(back, back.getWidth() / 2f, container.getHeight() - (back.getHeight() / 2f));
|
||||
backButton = new MenuButton(back, back.getWidth() / 2f, displayContainer.height - (back.getHeight() / 2f));
|
||||
}
|
||||
backButton.setHoverAnimationDuration(350);
|
||||
backButton.setHoverAnimationEquation(AnimationEquation.IN_OUT_BACK);
|
||||
|
@ -125,7 +123,6 @@ public class UI {
|
|||
public static void draw(Graphics g) {
|
||||
drawBarNotification(g);
|
||||
drawVolume(g);
|
||||
drawFPS();
|
||||
cursor.draw();
|
||||
drawTooltip(g);
|
||||
}
|
||||
|
@ -140,7 +137,6 @@ public class UI {
|
|||
public static void draw(Graphics g, int mouseX, int mouseY, boolean mousePressed) {
|
||||
drawBarNotification(g);
|
||||
drawVolume(g);
|
||||
drawFPS();
|
||||
cursor.draw(mouseX, mouseY, mousePressed);
|
||||
drawTooltip(g);
|
||||
}
|
||||
|
@ -189,27 +185,6 @@ public class UI {
|
|||
Fonts.MEDIUM.drawString(tabTextX, tabTextY, text, textColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the FPS at the bottom-right corner of the game container.
|
||||
* If the option is not activated, this will do nothing.
|
||||
*/
|
||||
public static void drawFPS() {
|
||||
if (!Options.isFPSCounterEnabled())
|
||||
return;
|
||||
|
||||
String fps = String.format("%dFPS", container.getFPS());
|
||||
Fonts.BOLD.drawString(
|
||||
container.getWidth() * 0.997f - Fonts.BOLD.getWidth(fps),
|
||||
container.getHeight() * 0.997f - Fonts.BOLD.getHeight(fps),
|
||||
Integer.toString(container.getFPS()), Color.white
|
||||
);
|
||||
Fonts.DEFAULT.drawString(
|
||||
container.getWidth() * 0.997f - Fonts.BOLD.getWidth("FPS"),
|
||||
container.getHeight() * 0.997f - Fonts.BOLD.getHeight("FPS"),
|
||||
"FPS", Color.white
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the volume bar on the middle right-hand side of the game container.
|
||||
* Only draws if the volume has recently been changed using with {@link #changeVolume(int)}.
|
||||
|
@ -219,7 +194,6 @@ public class UI {
|
|||
if (volumeDisplay == -1)
|
||||
return;
|
||||
|
||||
int width = container.getWidth(), height = container.getHeight();
|
||||
Image img = GameImage.VOLUME.getImage();
|
||||
|
||||
// move image in/out
|
||||
|
@ -230,13 +204,13 @@ public class UI {
|
|||
else if (ratio >= 0.9f)
|
||||
xOffset = img.getWidth() * (1 - ((1 - ratio) * 10f));
|
||||
|
||||
img.drawCentered(width - img.getWidth() / 2f + xOffset, height / 2f);
|
||||
img.drawCentered(displayContainer.width - img.getWidth() / 2f + xOffset, displayContainer.height / 2f);
|
||||
float barHeight = img.getHeight() * 0.9f;
|
||||
float volume = Options.getMasterVolume();
|
||||
g.setColor(Color.white);
|
||||
g.fillRoundRect(
|
||||
width - (img.getWidth() * 0.368f) + xOffset,
|
||||
(height / 2f) - (img.getHeight() * 0.47f) + (barHeight * (1 - volume)),
|
||||
displayContainer.width - (img.getWidth() * 0.368f) + xOffset,
|
||||
(displayContainer.height / 2f) - (img.getHeight() * 0.47f) + (barHeight * (1 - volume)),
|
||||
img.getWidth() * 0.15f, barHeight * volume, 3
|
||||
);
|
||||
}
|
||||
|
@ -260,7 +234,7 @@ public class UI {
|
|||
*/
|
||||
public static void changeVolume(int units) {
|
||||
final float UNIT_OFFSET = 0.05f;
|
||||
Options.setMasterVolume(container, Utils.clamp(Options.getMasterVolume() + (UNIT_OFFSET * units), 0f, 1f));
|
||||
Options.setMasterVolume(Utils.clamp(Options.getMasterVolume() + (UNIT_OFFSET * units), 0f, 1f));
|
||||
if (volumeDisplay == -1)
|
||||
volumeDisplay = 0;
|
||||
else if (volumeDisplay >= VOLUME_DISPLAY_TIME / 10)
|
||||
|
@ -294,8 +268,8 @@ public class UI {
|
|||
return;
|
||||
|
||||
// draw loading info
|
||||
float marginX = container.getWidth() * 0.02f, marginY = container.getHeight() * 0.02f;
|
||||
float lineY = container.getHeight() - marginY;
|
||||
float marginX = displayContainer.width * 0.02f, marginY = displayContainer.height * 0.02f;
|
||||
float lineY = displayContainer.height - marginY;
|
||||
int lineOffsetY = Fonts.MEDIUM.getLineHeight();
|
||||
if (Options.isLoadVerbose()) {
|
||||
// verbose: display percentages and file names
|
||||
|
@ -308,7 +282,7 @@ public class UI {
|
|||
Fonts.MEDIUM.drawString(marginX, lineY - (lineOffsetY * 2), text, Color.white);
|
||||
g.setColor(Color.white);
|
||||
g.fillRoundRect(marginX, lineY - (lineOffsetY / 2f),
|
||||
(container.getWidth() - (marginX * 2f)) * progress / 100f, lineOffsetY / 4f, 4
|
||||
(displayContainer.width - (marginX * 2f)) * progress / 100f, lineOffsetY / 4f, 4
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -332,7 +306,7 @@ public class UI {
|
|||
float unitBaseX, float unitBaseY, float unitWidth, float scrollAreaHeight,
|
||||
Color bgColor, Color scrollbarColor, boolean right
|
||||
) {
|
||||
float scrollbarWidth = container.getWidth() * 0.00347f;
|
||||
float scrollbarWidth = displayContainer.width * 0.00347f;
|
||||
float scrollbarHeight = scrollAreaHeight * lengthShown / totalLength;
|
||||
float offsetY = (scrollAreaHeight - scrollbarHeight) * (position / (totalLength - lengthShown));
|
||||
float scrollbarX = unitBaseX + unitWidth - ((right) ? scrollbarWidth : 0);
|
||||
|
@ -368,8 +342,7 @@ public class UI {
|
|||
if (tooltipAlpha.getTime() == 0 || tooltip == null)
|
||||
return;
|
||||
|
||||
int containerWidth = container.getWidth(), containerHeight = container.getHeight();
|
||||
int margin = containerWidth / 100, textMarginX = 2;
|
||||
int margin = displayContainer.width / 100, textMarginX = 2;
|
||||
int offset = GameImage.CURSOR_MIDDLE.getImage().getWidth() / 2;
|
||||
int lineHeight = Fonts.SMALL.getLineHeight();
|
||||
int textWidth = textMarginX * 2, textHeight = lineHeight;
|
||||
|
@ -388,12 +361,12 @@ public class UI {
|
|||
|
||||
// get drawing coordinates
|
||||
int x = input.getMouseX() + offset, y = input.getMouseY() + offset;
|
||||
if (x + textWidth > containerWidth - margin)
|
||||
x = containerWidth - margin - textWidth;
|
||||
if (x + textWidth > displayContainer.width - margin)
|
||||
x = displayContainer.width - margin - textWidth;
|
||||
else if (x < margin)
|
||||
x = margin;
|
||||
if (y + textHeight > containerHeight - margin)
|
||||
y = containerHeight - margin - textHeight;
|
||||
if (y + textHeight > displayContainer.height - margin)
|
||||
y = displayContainer.height - margin - textHeight;
|
||||
else if (y < margin)
|
||||
y = margin;
|
||||
|
||||
|
@ -467,13 +440,13 @@ public class UI {
|
|||
float alpha = 1f;
|
||||
if (barNotifTimer >= BAR_NOTIFICATION_TIME * 0.9f)
|
||||
alpha -= 1 - ((BAR_NOTIFICATION_TIME - barNotifTimer) / (BAR_NOTIFICATION_TIME * 0.1f));
|
||||
int midX = container.getWidth() / 2, midY = container.getHeight() / 2;
|
||||
int midX = displayContainer.width / 2, midY = displayContainer.height / 2;
|
||||
float barHeight = Fonts.LARGE.getLineHeight() * (1f + 0.6f * Math.min(barNotifTimer * 15f / BAR_NOTIFICATION_TIME, 1f));
|
||||
float oldAlphaB = Colors.BLACK_ALPHA.a, oldAlphaW = Colors.WHITE_ALPHA.a;
|
||||
Colors.BLACK_ALPHA.a *= alpha;
|
||||
Colors.WHITE_ALPHA.a = alpha;
|
||||
g.setColor(Colors.BLACK_ALPHA);
|
||||
g.fillRect(0, midY - barHeight / 2f, container.getWidth(), barHeight);
|
||||
g.fillRect(0, midY - barHeight / 2f, displayContainer.width, barHeight);
|
||||
Fonts.LARGE.drawString(
|
||||
midX - Fonts.LARGE.getWidth(barNotif) / 2f,
|
||||
midY - Fonts.LARGE.getLineHeight() / 2.2f,
|
||||
|
|
|
@ -22,6 +22,7 @@ import itdelatrisu.opsu.Utils;
|
|||
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;
|
||||
|
@ -61,7 +62,8 @@ public class OpsuDance {
|
|||
initUpdater(args);
|
||||
sout("database & updater initialized");
|
||||
|
||||
container.init(EmptyState.class);
|
||||
//container.init(EmptyState.class);
|
||||
container.init(Splash.class);
|
||||
} catch (Exception e) {
|
||||
errorAndExit("startup failure", e);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
package yugecin.opsudance.core;
|
||||
|
||||
import itdelatrisu.opsu.GameImage;
|
||||
import itdelatrisu.opsu.Options;
|
||||
import itdelatrisu.opsu.ui.Fonts;
|
||||
import org.lwjgl.LWJGLException;
|
||||
import org.lwjgl.Sys;
|
||||
|
@ -29,6 +30,7 @@ import org.newdawn.slick.Graphics;
|
|||
import org.newdawn.slick.Input;
|
||||
import org.newdawn.slick.KeyListener;
|
||||
import org.newdawn.slick.MouseListener;
|
||||
import org.newdawn.slick.openal.SoundStore;
|
||||
import org.newdawn.slick.opengl.InternalTextureLoader;
|
||||
import org.newdawn.slick.opengl.renderer.Renderer;
|
||||
import org.newdawn.slick.opengl.renderer.SGL;
|
||||
|
@ -70,7 +72,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
|||
|
||||
private OpsuState state;
|
||||
|
||||
private final DisplayMode nativeDisplayMode;
|
||||
public final DisplayMode nativeDisplayMode;
|
||||
|
||||
private Graphics graphics;
|
||||
private Input input;
|
||||
|
@ -204,7 +206,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
|||
Display.setDisplayMode(new DisplayMode(100, 100));
|
||||
Display.create();
|
||||
GLHelper.setIcons(new String[] { "icon16.png", "icon32.png" });
|
||||
setDisplayMode(800, 600, false);
|
||||
Options.setDisplayMode(this);
|
||||
sout("GL ready");
|
||||
glVersion = GL11.glGetString(GL11.GL_VERSION);
|
||||
glVendor = GL11.glGetString(GL11.GL_VENDOR);
|
||||
|
@ -257,6 +259,7 @@ public class DisplayContainer implements ErrorDumpable, KeyListener, MouseListen
|
|||
graphics.setAntiAlias(false);
|
||||
|
||||
input = new Input(height);
|
||||
input.enableKeyRepeat();
|
||||
input.addKeyListener(this);
|
||||
input.addMouseListener(this);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package yugecin.opsudance.core.inject;
|
||||
|
||||
import itdelatrisu.opsu.states.Splash;
|
||||
import yugecin.opsudance.PreStartupInitializer;
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
import yugecin.opsudance.core.events.EventBus;
|
||||
|
@ -50,6 +51,8 @@ public class OpsuDanceInjector extends Injector {
|
|||
|
||||
bind(EmptyRedState.class).asEagerSingleton();
|
||||
bind(EmptyState.class).asEagerSingleton();
|
||||
|
||||
bind(Splash.class).asEagerSingleton();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package yugecin.opsudance.core.state;
|
||||
|
||||
import org.newdawn.slick.Graphics;
|
||||
import yugecin.opsudance.core.DisplayContainer;
|
||||
import yugecin.opsudance.core.events.EventListener;
|
||||
import yugecin.opsudance.events.ResolutionChangedEvent;
|
||||
|
@ -41,6 +42,18 @@ public abstract class BaseOpsuState implements OpsuState, EventListener<Resoluti
|
|||
protected void revalidate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preRenderUpdate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Graphics g) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(ResolutionChangedEvent event) {
|
||||
if (isCurrentState) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user