This commit is contained in:
Raybz@Raybz 2013-06-21 08:48:08 +02:00
commit 62122dcb7e
12 changed files with 137 additions and 29 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

View File

@ -35,15 +35,18 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
private static final String MAPPING_PLAYER_MOUSE_LEFT_CLICK = "PLAYER_Mouse_Left_Click"; private static final String MAPPING_PLAYER_MOUSE_LEFT_CLICK = "PLAYER_Mouse_Left_Click";
private static final float maxTimeToOverheat = 3f; private static final float maxTimeToOverheat = 3f;
private static final float maxCoolDown = 3f;
/**/ /**/
private InputManager inputManager; private InputManager inputManager;
private GameGUI gui; private GameGUI gui;
private float timeToOverheat = maxTimeToOverheat; private float timeToOverheat = maxTimeToOverheat;
private float coolDown = 0f;
private boolean isShooting = false; private boolean isShooting = false;
public PlayerShootControl(InputManager inputmanager, GameGUI gui) { public PlayerShootControl(InputManager inputmanager, GameGUI gui) {
this.inputManager = inputmanager; this.inputManager = inputmanager;
this.gui = gui; this.gui = gui;
gui.setMaxTimeToOverheat(maxTimeToOverheat);
initMappings(); initMappings();
} }
@ -51,10 +54,17 @@ public class PlayerShootControl extends BaseControl implements ActionListener {
protected void controlUpdate(float tpf) { protected void controlUpdate(float tpf) {
if (spatial.getUserData(UserDataKeys.RUNNING)) { if (spatial.getUserData(UserDataKeys.RUNNING)) {
if (isShooting) { if (isShooting) {
timeToOverheat -= tpf; if (coolDown <= 0f) {
if (timeToOverheat <= 0) { timeToOverheat -= tpf;
setShooting(false); gui.updateOverhead(timeToOverheat);
if (timeToOverheat <= 0) {
setShooting(false);
coolDown = maxCoolDown;
}
} else {
coolDown -= tpf;
} }
} }
} }
} }

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2013 Snowsun <http://wyrez.org> and contributors
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.wyrez.shootingstars.gui; package org.wyrez.shootingstars.gui;
import com.jme3.input.event.MouseButtonEvent; import com.jme3.input.event.MouseButtonEvent;
@ -24,9 +40,10 @@ public class FileMetaInfoGUI extends Panel implements Gui {
private FileMetaInfoListener listener; private FileMetaInfoListener listener;
private GameSettings settings; private GameSettings settings;
private String duration = "Test"; private String fileName = "";
private String title = "Test2"; private String duration = "";
private String artist = "Test3"; private String title = "";
private String artist = "";
public FileMetaInfoGUI(Screen screen, FileMetaInfoListener listener, GameSettings settings) { public FileMetaInfoGUI(Screen screen, FileMetaInfoListener listener, GameSettings settings) {
super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f));
@ -39,7 +56,7 @@ public class FileMetaInfoGUI extends Panel implements Gui {
private void create() { private void create() {
float startPointx = 256f; float startPointx = 256f;
float startPointy = 252f; float startPointy = 202f;
float marginLeft = 110f; float marginLeft = 110f;
float buttonWidth = 153.6f; float buttonWidth = 153.6f;
@ -52,33 +69,39 @@ public class FileMetaInfoGUI extends Panel implements Gui {
readMetaData(file); readMetaData(file);
Label lblArtistHead = new Label(screen, new Vector2f(startPointx, startPointy), new Vector2f(100f, 40f)); Label lblFileNameHead = new Label(screen, new Vector2f(startPointx, startPointy), new Vector2f(100f, 40f));
lblFileNameHead.setText("Track Name");
Label lblFileName = new Label(screen, new Vector2f(startPointx + marginLeft, startPointy), new Vector2f(400f, 40f));
lblFileName.setText(fileName);
Label lblArtistHead = new Label(screen, new Vector2f(startPointx, startPointy + 50f), new Vector2f(100f, 40f));
lblArtistHead.setText("Artist"); lblArtistHead.setText("Artist");
Label lblArtist = new Label(screen, new Vector2f(startPointx + marginLeft, startPointy), new Vector2f(400f, 40f)); Label lblArtist = new Label(screen, new Vector2f(startPointx + marginLeft, startPointy + 50f), new Vector2f(400f, 40f));
lblArtist.setText(artist); lblArtist.setText(artist);
Label lblTitelHead = new Label(screen, new Vector2f(startPointx, startPointy + 50f), new Vector2f(100f, 40f)); Label lblTitelHead = new Label(screen, new Vector2f(startPointx, startPointy + 100f), new Vector2f(100f, 40f));
lblTitelHead.setText("Titel"); lblTitelHead.setText("Titel");
Label lblTitel = new Label(screen, new Vector2f(startPointx + marginLeft, startPointy + 50f), new Vector2f(400f, 40f)); Label lblTitel = new Label(screen, new Vector2f(startPointx + marginLeft, startPointy + 100f), new Vector2f(400f, 40f));
lblTitel.setText(title); lblTitel.setText(title);
Label lblDurationHead = new Label(screen, new Vector2f(startPointx, startPointy + 100f), new Vector2f(100f, 40f)); Label lblDurationHead = new Label(screen, new Vector2f(startPointx, startPointy + 150f), new Vector2f(100f, 40f));
lblDurationHead.setText("Duration"); lblDurationHead.setText("Duration");
Label lblDuration = new Label(screen, new Vector2f(startPointx + marginLeft, startPointy + 100f), new Vector2f(400f, 40f)); Label lblDuration = new Label(screen, new Vector2f(startPointx + marginLeft, startPointy + 150f), new Vector2f(400f, 40f));
lblDuration.setText(duration); lblDuration.setText(duration);
Button btnStartLoading = new ButtonBase(screen, new Vector2f(startPointx + 500f, startPointy + 400f), new Vector2f(buttonWidth, 40)) { Button btnStartLoading = new ButtonBase(screen, new Vector2f(startPointx + 653f, startPointy + 438.8f), new Vector2f(buttonWidth, 40)) {
@Override @Override
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) { public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
listener.startLoading(); listener.startLoading();
} }
}; };
btnStartLoading.setText("Start Loading"); btnStartLoading.setText("Play");
Button btnCancel = new ButtonBase(screen, new Vector2f(startPointx + 750f, startPointy + 400f), new Vector2f(buttonWidth, 40)) { Button btnCancel = new ButtonBase(screen, new Vector2f(startPointx + 836f, startPointy + 438.8f), new Vector2f(buttonWidth, 40)) {
@Override @Override
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) { public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
listener.cancel(); listener.cancel();
@ -86,6 +109,8 @@ public class FileMetaInfoGUI extends Panel implements Gui {
}; };
btnCancel.setText("Cancel"); btnCancel.setText("Cancel");
this.addChild(lblFileNameHead);
this.addChild(lblFileName);
this.addChild(lblArtistHead); this.addChild(lblArtistHead);
this.addChild(lblArtist); this.addChild(lblArtist);
this.addChild(lblTitelHead); this.addChild(lblTitelHead);
@ -98,12 +123,13 @@ public class FileMetaInfoGUI extends Panel implements Gui {
private void readMetaData(File file) { private void readMetaData(File file) {
try { try {
fileName = file.getName();
AudioFile f = AudioFileIO.read(file); AudioFile f = AudioFileIO.read(file);
Tag tag = f.getTag(); Tag tag = f.getTag();
AudioHeader ah = f.getAudioHeader(); AudioHeader ah = f.getAudioHeader();
if (ah != null) { if (ah != null) {
duration = String.valueOf(ah.getTrackLength()); duration = String.valueOf(ah.getTrackLength()) + " s";
} }
if (tag != null) { if (tag != null) {

View File

@ -19,14 +19,20 @@ package org.wyrez.shootingstars.gui;
import com.jme3.asset.AssetManager; import com.jme3.asset.AssetManager;
import com.jme3.font.BitmapFont; import com.jme3.font.BitmapFont;
import com.jme3.input.event.MouseButtonEvent; import com.jme3.input.event.MouseButtonEvent;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector2f; import com.jme3.math.Vector2f;
import com.jme3.scene.Spatial; import com.jme3.scene.Spatial;
import com.jme3.ui.Picture; import com.jme3.ui.Picture;
import org.wyrez.shootingstars.gui.controls.ButtonBase; import org.wyrez.shootingstars.gui.controls.ButtonBase;
import org.wyrez.shootingstars.gui.controls.IndicatorBase;
import org.wyrez.shootingstars.gui.listener.GameListener; import org.wyrez.shootingstars.gui.listener.GameListener;
import tonegod.gui.controls.buttons.Button; import tonegod.gui.controls.buttons.Button;
import tonegod.gui.controls.extras.Indicator;
import tonegod.gui.controls.text.Label;
import tonegod.gui.controls.windows.Panel; import tonegod.gui.controls.windows.Panel;
import tonegod.gui.core.Screen; import tonegod.gui.core.Screen;
import tonegod.gui.effects.Effect;
/** /**
* *
@ -39,6 +45,7 @@ public class GameGUI extends Panel {
private Button btnResume; private Button btnResume;
private Button btnMenu; private Button btnMenu;
private Picture picCrosshair; private Picture picCrosshair;
private Indicator indOverheat;
private AssetManager assetManager; private AssetManager assetManager;
public GameGUI(Screen screen, GameListener listener, AssetManager assetManager) { public GameGUI(Screen screen, GameListener listener, AssetManager assetManager) {
@ -58,6 +65,9 @@ public class GameGUI extends Panel {
float startPointCrosshairx = 441f; float startPointCrosshairx = 441f;
float startPointCrosshairy = 560f; float startPointCrosshairy = 560f;
float startPointOverheatx = 505f;
float startPointOverheaty = 270f;
float startPointYMenu = 200f; float startPointYMenu = 200f;
btnStart = new ButtonBase(screen, new Vector2f(startPointx, startPointy), btnStart = new ButtonBase(screen, new Vector2f(startPointx, startPointy),
@ -94,22 +104,29 @@ public class GameGUI extends Panel {
picCrosshair.setWidth(400f); picCrosshair.setWidth(400f);
picCrosshair.setHeight(400f); picCrosshair.setHeight(400f);
picCrosshair.setImage(assetManager, "Textures/Crosshair.png", true); picCrosshair.setImage(assetManager, "Textures/Crosshair.png", true);
Panel plnCrosshair = new Panel(screen, new Vector2f(startPointCrosshairx, startPointCrosshairy), new Vector2f(0f, 0f)); Panel plnCrosshair = new Panel(screen, new Vector2f(startPointCrosshairx, startPointCrosshairy), new Vector2f(0f, 0f));
plnCrosshair.setIsVisible(false); plnCrosshair.setIsVisible(false);
plnCrosshair.setIgnoreMouse(true); plnCrosshair.setIgnoreMouse(true);
plnCrosshair.attachChild(picCrosshair); plnCrosshair.attachChild(picCrosshair);
indOverheat = new IndicatorBase(screen, new Vector2f(startPointOverheatx, startPointOverheaty),
new Vector2f(275f, 180f), Indicator.Orientation.VERTICAL);
indOverheat.setIndicatorColor(new ColorRGBA(0f, 0f, 1f, 0.5f));
indOverheat.setAlphaMap("Textures/Crosshair_AlphaMap.png");
indOverheat.setOverlayImage("Textures/Crosshair_OverlayImage.png");
//indOverheat.setBaseImage("Textures/Crosshair_Overheat_Fog.png");
this.addChild(btnStart); this.addChild(btnStart);
this.addChild(btnResume); this.addChild(btnResume);
this.addChild(btnMenu); this.addChild(btnMenu);
this.addChild(indOverheat);
this.addChild(plnCrosshair); this.addChild(plnCrosshair);
btnResume.hide(); btnResume.hide();
btnMenu.hide(); btnMenu.hide();
picCrosshair.setCullHint(CullHint.Always); picCrosshair.setCullHint(CullHint.Always);
indOverheat.hide();
} }
public void setStart() { public void setStart() {
@ -117,6 +134,7 @@ public class GameGUI extends Panel {
btnResume.hide(); btnResume.hide();
btnMenu.hide(); btnMenu.hide();
picCrosshair.setCullHint(CullHint.Inherit); picCrosshair.setCullHint(CullHint.Inherit);
indOverheat.show();
} }
public void setWait() { public void setWait() {
@ -124,6 +142,7 @@ public class GameGUI extends Panel {
btnResume.hide(); btnResume.hide();
btnMenu.hide(); btnMenu.hide();
picCrosshair.setCullHint(CullHint.Always); picCrosshair.setCullHint(CullHint.Always);
indOverheat.hide();
} }
public void showMenu() { public void showMenu() {
@ -131,6 +150,7 @@ public class GameGUI extends Panel {
btnResume.show(); btnResume.show();
btnMenu.show(); btnMenu.show();
picCrosshair.setCullHint(CullHint.Always); picCrosshair.setCullHint(CullHint.Always);
indOverheat.hide();
} }
public void resumeGame() { public void resumeGame() {
@ -138,6 +158,7 @@ public class GameGUI extends Panel {
btnResume.hide(); btnResume.hide();
btnMenu.hide(); btnMenu.hide();
picCrosshair.setCullHint(CullHint.Inherit); picCrosshair.setCullHint(CullHint.Inherit);
indOverheat.show();
} }
public void attach() { public void attach() {
@ -149,6 +170,10 @@ public class GameGUI extends Panel {
} }
public void updateOverhead(float percent) { public void updateOverhead(float percent) {
indOverheat.setCurrentValue(percent);
}
public void setMaxTimeToOverheat(float maxTimeToOverheat) {
indOverheat.setMaxValue(maxTimeToOverheat);
} }
} }

View File

@ -105,7 +105,7 @@ public class HighscoreGUI extends Panel implements Gui {
// marginScoreTop += 50f; // marginScoreTop += 50f;
// } // }
Button btnBack = new ButtonBase(screen, new Vector2f(startPointx + 1000f, startPointy + 610f), new Vector2f(153f, 40)) { Button btnBack = new ButtonBase(screen, new Vector2f(startPointx + 1060f, startPointy + 622.8f), new Vector2f(153f, 40)) {
@Override @Override
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) { public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
listener.back(); listener.back();

View File

@ -42,10 +42,10 @@ public class SelectTrackGUI extends Panel implements Gui{
} }
private void create() { private void create() {
float startPointx = 576f;//screen.getWidth() * 0.45f; float startPointx = 576f;
float startPointy = 324f;//screen.getHeight() * 0.45f; float startPointy = 260f;
float labelFontSize = 76f;//screen.getWidth() * 0.06f; float labelFontSize = 76f;
float buttonWidth = 153f;//screen.getWidth() * 0.12f; float buttonWidth = 153f;
float marginLabelOrLeft = 45f; float marginLabelOrLeft = 45f;
float marginLabelOrTop = 43f; float marginLabelOrTop = 43f;
float marginButtonYTDownloadTop = 129f; float marginButtonYTDownloadTop = 129f;
@ -70,9 +70,18 @@ public class SelectTrackGUI extends Panel implements Gui{
}; };
btnYTDownload.setText("YT Download"); btnYTDownload.setText("YT Download");
Button btnCancel = new ButtonBase(screen, new Vector2f(startPointx, startPointy + marginButtonYTDownloadTop + 114f), new Vector2f(buttonWidth, 40)) {
@Override
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
listener.cancel();
}
};
btnCancel.setText("Cancel");
this.addChild(btnSelectFile); this.addChild(btnSelectFile);
this.addChild(lblOr); this.addChild(lblOr);
this.addChild(btnYTDownload); this.addChild(btnYTDownload);
this.addChild(btnCancel);
} }
public void attach() { public void attach() {

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2013 Snowsun <http://wyrez.org> and contributors
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.wyrez.shootingstars.gui.listener; package org.wyrez.shootingstars.gui.listener;
/** /**

View File

@ -25,4 +25,6 @@ public interface SelectFileListener {
public void selectFile(); public void selectFile();
public void downloadYT(); public void downloadYT();
public void cancel();
} }

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2013 Snowsun <http://wyrez.org> and contributors
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.wyrez.shootingstars.states; package org.wyrez.shootingstars.states;
import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AbstractAppState;

View File

@ -65,4 +65,8 @@ public class SelectTrackState extends AbstractAppState implements SelectFileList
public void downloadYT() { public void downloadYT() {
stateManager.setState(State.YTDOWNLOAD); stateManager.setState(State.YTDOWNLOAD);
} }
public void cancel() {
stateManager.setState(State.MENU);
}
} }