basic implementation of sbv2
This commit is contained in:
@@ -28,6 +28,7 @@ import org.newdawn.slick.GameContainer;
|
||||
import org.newdawn.slick.Graphics;
|
||||
import org.newdawn.slick.Input;
|
||||
import yugecin.opsudance.ObjectColorOverrides;
|
||||
import yugecin.opsudance.sbv2.MoveStoryboard;
|
||||
import yugecin.opsudance.ui.OptionsOverlay.OptionTab;
|
||||
|
||||
import java.util.*;
|
||||
@@ -109,6 +110,7 @@ public class SBOverlay implements OptionsOverlay.Parent {
|
||||
private int index;
|
||||
|
||||
private final Game game;
|
||||
private final MoveStoryboard msb;
|
||||
private final OptionsOverlay overlay;
|
||||
|
||||
static {
|
||||
@@ -117,8 +119,9 @@ public class SBOverlay implements OptionsOverlay.Parent {
|
||||
}
|
||||
}
|
||||
|
||||
public SBOverlay(Game game, GameContainer container) {
|
||||
public SBOverlay(Game game, MoveStoryboard msb, GameContainer container) {
|
||||
this.game = game;
|
||||
this.msb = msb;
|
||||
initialOptions = new HashMap<>();
|
||||
overlay = new OptionsOverlay(this, options, 2, container);
|
||||
this.width = container.getWidth();
|
||||
@@ -131,6 +134,7 @@ public class SBOverlay implements OptionsOverlay.Parent {
|
||||
if (!Options.isEnableSB() || hide) {
|
||||
return;
|
||||
}
|
||||
msb.render(g);
|
||||
int lh = Fonts.SMALL.getLineHeight();
|
||||
Fonts.SMALL.drawString(10, height - 50 + lh, "save position: ctrl+s, load position: ctrl+l", Color.cyan);
|
||||
Fonts.SMALL.drawString(10, height - 50, "speed: C " + (speed / 10f) + " V", Color.cyan);
|
||||
@@ -163,6 +167,7 @@ public class SBOverlay implements OptionsOverlay.Parent {
|
||||
if (Options.isEnableSB() && menu) {
|
||||
overlay.update(delta, mouseX, mouseY);
|
||||
}
|
||||
msb.update(delta, mouseX, mouseY);
|
||||
}
|
||||
|
||||
public boolean keyPressed(int key, char c) {
|
||||
@@ -234,6 +239,7 @@ public class SBOverlay implements OptionsOverlay.Parent {
|
||||
public void setGameObjects(GameObject[] gameObjects) {
|
||||
if (this.gameObjects.length != gameObjects.length) {
|
||||
optionsMap = new HashMap[gameObjects.length];
|
||||
msb.setGameObjects(gameObjects);
|
||||
}
|
||||
if (optionsMap.length > 0) {
|
||||
// copy all current settings in first obj map
|
||||
@@ -246,6 +252,7 @@ public class SBOverlay implements OptionsOverlay.Parent {
|
||||
}
|
||||
|
||||
public boolean mousePressed(int button, int x, int y) {
|
||||
msb.mousePressed(x, y);
|
||||
if (!menu) {
|
||||
return false;
|
||||
}
|
||||
@@ -270,6 +277,7 @@ public class SBOverlay implements OptionsOverlay.Parent {
|
||||
if (index >= optionsMap.length) {
|
||||
return;
|
||||
}
|
||||
msb.setIndex(index);
|
||||
for (; this.index <= index; this.index++) {
|
||||
HashMap options = optionsMap[this.index];
|
||||
if (options == null) {
|
||||
@@ -289,6 +297,7 @@ public class SBOverlay implements OptionsOverlay.Parent {
|
||||
overlay.mouseReleased(button, x, y);
|
||||
return true;
|
||||
}
|
||||
msb.mouseReleased(x, y);
|
||||
if (x > 10 || index >= optionsMap.length || optionsMap[index] == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -348,6 +357,10 @@ public class SBOverlay implements OptionsOverlay.Parent {
|
||||
}
|
||||
}
|
||||
|
||||
public float[] getPoint(int trackPosition) {
|
||||
return msb.getPoint(trackPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeave() {
|
||||
menu = false;
|
||||
|
||||
72
src/yugecin/opsudance/ui/SimpleButton.java
Normal file
72
src/yugecin/opsudance/ui/SimpleButton.java
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* opsu!dance - fork of opsu! with cursordance auto
|
||||
* Copyright (C) 2016 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.ui;
|
||||
|
||||
|
||||
import org.newdawn.slick.Color;
|
||||
import org.newdawn.slick.Font;
|
||||
import org.newdawn.slick.Graphics;
|
||||
|
||||
import java.awt.Rectangle;
|
||||
|
||||
public class SimpleButton {
|
||||
|
||||
private final Color bg;
|
||||
private final Color fg;
|
||||
private final Color border;
|
||||
private final Color hoverBorder;
|
||||
private final Font font;
|
||||
private String text;
|
||||
private int textY;
|
||||
private Rectangle hitbox;
|
||||
private boolean isHovered;
|
||||
|
||||
public SimpleButton(int x, int y, int width, int height, Font font, String text, Color bg, Color fg, Color border, Color hoverBorder) {
|
||||
this.bg = bg;
|
||||
this.fg = fg;
|
||||
this.border = border;
|
||||
this.hoverBorder = hoverBorder;
|
||||
this.hitbox = new Rectangle(x, y, width, height);
|
||||
this.font = font;
|
||||
this.text = text;
|
||||
this.textY = y + (height - font.getLineHeight()) / 2;
|
||||
}
|
||||
|
||||
public void render(Graphics g) {
|
||||
g.setLineWidth(2f);
|
||||
g.setColor(bg);
|
||||
g.fillRect(hitbox.x, hitbox.y, hitbox.width, hitbox.height);
|
||||
g.setColor(fg);
|
||||
font.drawString(hitbox.x + 20, textY, text);
|
||||
if (isHovered) {
|
||||
g.setColor(hoverBorder);
|
||||
} else {
|
||||
g.setColor(border);
|
||||
}
|
||||
g.drawRect(hitbox.x, hitbox.y, hitbox.width, hitbox.height);
|
||||
}
|
||||
|
||||
public void update(int x, int y) {
|
||||
isHovered = hitbox.contains(x, y);
|
||||
}
|
||||
|
||||
public boolean isHovered() {
|
||||
return isHovered;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user