Feature/menu
# Conflicts: # model/gameState/MenuState.java # model/objects/MenuButton.java
This commit is contained in:
@@ -48,6 +48,16 @@ public class MenuState extends GameState {
|
||||
BufferedImage aanwijzers = Images.getImage(ImageType.aanwijzers);
|
||||
int index = 0;
|
||||
|
||||
|
||||
|
||||
int kleurButton1 = 0;
|
||||
int kleurButton2 = 1;
|
||||
int kleurButton3 = 2;
|
||||
int kleurButton4 = 3;
|
||||
int kleurButton5 = 4;
|
||||
|
||||
|
||||
|
||||
public MenuState(GameStateManager gsm, SongHandler sh) {
|
||||
super(gsm, sh);
|
||||
buttons = new ArrayList<MenuButton>();
|
||||
@@ -94,15 +104,14 @@ public class MenuState extends GameState {
|
||||
}else{
|
||||
previousScreen();
|
||||
}
|
||||
for(MenuButton b:buttons){
|
||||
b.update();
|
||||
}
|
||||
if(selected != oldselected){
|
||||
for(int i = 0; i < buttons.size(); i++){
|
||||
buttons.get(i).setSong(selectedToSong(selected+(i-2)));
|
||||
|
||||
}
|
||||
oldselected = selected;
|
||||
|
||||
|
||||
buttons2.clear();
|
||||
int instanceNr = 0;
|
||||
for(int i = sh.getCurrentSong().getSongs().size(); i>0; i--){
|
||||
@@ -114,10 +123,24 @@ public class MenuState extends GameState {
|
||||
}
|
||||
}
|
||||
index++;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Graphics2D g2) {
|
||||
|
||||
buttons.clear();
|
||||
buttons.add(new MenuButton(400,250,GameModel.colors[kleurButton1],selectedToSong(selected-2)));
|
||||
buttons.add(new MenuButton(400,390,GameModel.colors[kleurButton2],selectedToSong(selected-1)));
|
||||
buttons.add(new MenuButton(400,530,GameModel.colors[kleurButton3],selectedToSong(selected)));
|
||||
buttons.add(new MenuButton(400,670,GameModel.colors[kleurButton4],selectedToSong(selected+1)));
|
||||
buttons.add(new MenuButton(400,810,GameModel.colors[kleurButton5],selectedToSong(selected+2)));
|
||||
buttons.get(2).setSelected(true);
|
||||
|
||||
|
||||
g2.setColor(Color.BLACK);
|
||||
Font textFont2 = new Font("OCR A Extended", Font.BOLD, 50);
|
||||
g2.setFont(textFont2);
|
||||
if(!subscreen) {
|
||||
g2.drawImage(mainScreenBackground, 0, 0, 1280,1024,null);
|
||||
for(MenuButton b:buttons){
|
||||
@@ -184,14 +207,61 @@ public class MenuState extends GameState {
|
||||
if(difSelect > buttons2.size()-1){
|
||||
difSelect = 0;
|
||||
}
|
||||
|
||||
// System.out.println(difSelect);
|
||||
}
|
||||
sh.set(sh.getCurrentSong().getSongs().get(difSelect));
|
||||
generateSubScreenForeground();
|
||||
}else{ //Screen for selecting song
|
||||
if(e.getJoystick().getPos() == Joystick.Position.DOWN){
|
||||
selected++;
|
||||
|
||||
kleurButton1++;
|
||||
kleurButton1 %= 6;
|
||||
|
||||
kleurButton2++;
|
||||
kleurButton2 %= 6;
|
||||
|
||||
kleurButton3++;
|
||||
kleurButton3 %= 6;
|
||||
|
||||
kleurButton4++;
|
||||
kleurButton4 %= 6;
|
||||
|
||||
kleurButton5++;
|
||||
kleurButton5 %= 6;
|
||||
|
||||
|
||||
|
||||
}else if(e.getJoystick().getPos() == Joystick.Position.UP){
|
||||
selected--;
|
||||
kleurButton1--;
|
||||
if(kleurButton1 < 0){
|
||||
kleurButton1 = 5;
|
||||
}
|
||||
|
||||
kleurButton2--;
|
||||
if(kleurButton2 < 0){
|
||||
kleurButton2 = 5;
|
||||
}
|
||||
|
||||
kleurButton3--;
|
||||
if(kleurButton3 < 0){
|
||||
kleurButton3 = 5;
|
||||
}
|
||||
|
||||
kleurButton4--;
|
||||
if(kleurButton4 < 0){
|
||||
kleurButton4 = 5;
|
||||
}
|
||||
|
||||
kleurButton5--;
|
||||
if(kleurButton5 < 0){
|
||||
kleurButton5 = 5;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
sh.set(songs.indexOf(selectedToSong(selected)));
|
||||
sh.play();
|
||||
|
||||
@@ -15,6 +15,8 @@ import java.awt.Transparency;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.image.VolatileImage;
|
||||
import java.awt.geom.GeneralPath;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import audio.Song;
|
||||
|
||||
@@ -26,10 +28,14 @@ public class MenuButton {
|
||||
|
||||
private boolean selected;
|
||||
private VolatileImage background;
|
||||
|
||||
|
||||
private ArrayList<Color> colors;
|
||||
private int x, y;
|
||||
private boolean selected;
|
||||
private Song song;
|
||||
Color color;
|
||||
|
||||
public MenuButton(int x, int y, double scale, int rounding, Color c0, Song song){
|
||||
public MenuButton(int x, int y, Color color, Song song){
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.scalefactor = scale;
|
||||
@@ -75,12 +81,46 @@ public class MenuButton {
|
||||
g2d.fill(arrayToGeneralpath(new int[][]{{118, 88}, {114, 48},{78, 25+rounding}, {82, 73+rounding}}));
|
||||
g2d.setColor(buttoncolor);
|
||||
g2d.fill(arrayToGeneralpath(new int[][]{{78, 25+rounding}, {82, 73+rounding},{15, 88+(int)(rounding*0.5)}, {10, 43+(int)(rounding*0.5)}}));
|
||||
this.color = color;
|
||||
setSong(song);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void draw(Graphics2D g2d){
|
||||
|
||||
|
||||
if(selected){
|
||||
g2d.setStroke(new BasicStroke(4));
|
||||
g2d.setColor(color);
|
||||
GeneralPath path = new GeneralPath();
|
||||
path.moveTo(320, 540);
|
||||
path.lineTo(320, 590);
|
||||
path.lineTo(385, 565);
|
||||
|
||||
path.closePath();
|
||||
g2d.fill(path);
|
||||
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.draw(border);
|
||||
g2d.draw(path);
|
||||
|
||||
g2d.setColor(color.darker().darker().darker().darker());
|
||||
g2d.fillRect(x-10, y-10,900,90);
|
||||
}
|
||||
g2d.setColor(color.darker().darker());
|
||||
g2d.fillRect(x-5, y-5,890,80);
|
||||
g2d.setColor(color);
|
||||
g2d.fillRect(x,y,880,70);
|
||||
>>>>>>> 7dd4066a8ab297001a5e0e35d877aff3f29525ac
|
||||
|
||||
if(selected){
|
||||
g2d.setColor(Color.BLACK);
|
||||
g2d.drawRect(x-10, y-10, 900, 90);
|
||||
g2d.drawRect(x-5, y-5, 890, 80);
|
||||
g2d.drawRect(x, y, 880, 70);
|
||||
|
||||
}
|
||||
|
||||
g2d.setPaint(gradient);
|
||||
g2d.fill(line);
|
||||
|
||||
@@ -110,6 +150,14 @@ public class MenuButton {
|
||||
|
||||
public void update(){
|
||||
}
|
||||
|
||||
//draw text
|
||||
g2d.setColor(Color.BLACK);
|
||||
Font textFont = new Font("OCR A Extended", Font.BOLD,60);
|
||||
g2d.setFont(textFont);
|
||||
g2d.drawString(song.getTitle(), x+50, y+57);
|
||||
}
|
||||
|
||||
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
|
||||
Reference in New Issue
Block a user