diff --git a/ShootingStars/assets/Textures/bg.png b/ShootingStars/assets/Textures/bg.png new file mode 100644 index 0000000..e89d9ab Binary files /dev/null and b/ShootingStars/assets/Textures/bg.png differ diff --git a/ShootingStars/src/org/wyrez/shootingstars/gui/BackgroundedGui.java b/ShootingStars/src/org/wyrez/shootingstars/gui/BackgroundedGui.java new file mode 100644 index 0000000..1293749 --- /dev/null +++ b/ShootingStars/src/org/wyrez/shootingstars/gui/BackgroundedGui.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2013 Darth Affe 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 . + */ +package org.wyrez.shootingstars.gui; + +import com.jme3.asset.AssetManager; +import com.jme3.math.Vector2f; +import com.jme3.ui.Picture; +import tonegod.gui.controls.windows.Panel; +import tonegod.gui.core.Screen; + +/** + * + * @author Darth Affe + */ +public abstract class BackgroundedGui extends Panel implements Gui { + + protected final AssetManager assetManager; + + public BackgroundedGui(Screen screen, Vector2f position, Vector2f dimension, AssetManager assetManager) { + super(screen, position, dimension); + this.assetManager = assetManager; + addBackground(); + } + + private void addBackground() { + Picture bgImage = new Picture("Background"); + bgImage.setWidth(screen.getWidth()); + bgImage.setHeight(screen.getHeight()); + bgImage.setImage(assetManager, "Textures/bg.png", false); + Panel bg = new Panel(screen, new Vector2f(0f, 0f)); + bg.centerToParent(); + bg.attachChild(bgImage); + + this.attachChild(bgImage); + } +} diff --git a/ShootingStars/src/org/wyrez/shootingstars/gui/FileMetaInfoGUI.java b/ShootingStars/src/org/wyrez/shootingstars/gui/FileMetaInfoGUI.java index 5d33526..f7af32f 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/gui/FileMetaInfoGUI.java +++ b/ShootingStars/src/org/wyrez/shootingstars/gui/FileMetaInfoGUI.java @@ -16,6 +16,7 @@ */ package org.wyrez.shootingstars.gui; +import com.jme3.asset.AssetManager; import com.jme3.input.event.MouseButtonEvent; import com.jme3.math.Vector2f; import java.io.File; @@ -25,14 +26,13 @@ import org.wyrez.shootingstars.gui.listener.FileMetaInfoListener; import org.wyrez.shootingstars.helper.ScreenHelper; import tonegod.gui.controls.buttons.Button; import tonegod.gui.controls.text.Label; -import tonegod.gui.controls.windows.Panel; import tonegod.gui.core.Screen; /** * * @author Snowsun */ -public class FileMetaInfoGUI extends Panel implements Gui { +public class FileMetaInfoGUI extends BackgroundedGui implements Gui { private FileMetaInfoListener listener; private GameSettings settings; @@ -42,8 +42,9 @@ public class FileMetaInfoGUI extends Panel implements Gui { private Label lblTitel; private Label lblDuration; - public FileMetaInfoGUI(Screen screen, FileMetaInfoListener listener, GameSettings settings, ScreenHelper screenHelper) { - super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); + public FileMetaInfoGUI(Screen screen, FileMetaInfoListener listener, + GameSettings settings, ScreenHelper screenHelper, AssetManager assetManager) { + super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f), assetManager); this.listener = listener; this.settings = settings; this.screenHelper = screenHelper; diff --git a/ShootingStars/src/org/wyrez/shootingstars/gui/HighscoreGUI.java b/ShootingStars/src/org/wyrez/shootingstars/gui/HighscoreGUI.java index 26f796d..7265fe4 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/gui/HighscoreGUI.java +++ b/ShootingStars/src/org/wyrez/shootingstars/gui/HighscoreGUI.java @@ -16,6 +16,7 @@ */ package org.wyrez.shootingstars.gui; +import com.jme3.asset.AssetManager; import com.jme3.input.event.MouseButtonEvent; import com.jme3.math.Vector2f; import java.text.DateFormat; @@ -35,7 +36,7 @@ import tonegod.gui.core.Screen; * * @author Snowsun */ -public class HighscoreGUI extends Panel implements Gui { +public class HighscoreGUI extends BackgroundedGui implements Gui { private HighscoreListener listener; private HighscoreManager highscoreManager; @@ -43,8 +44,9 @@ public class HighscoreGUI extends Panel implements Gui { private Panel plnScores; private TextField txtFilter; - public HighscoreGUI(Screen screen, HighscoreListener listener, HighscoreManager highscoreManager, ScreenHelper screenHelper) { - super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); + public HighscoreGUI(Screen screen, HighscoreListener listener, HighscoreManager highscoreManager, + ScreenHelper screenHelper, AssetManager assetManager) { + super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f), assetManager); this.listener = listener; this.highscoreManager = highscoreManager; this.screenHelper = screenHelper; diff --git a/ShootingStars/src/org/wyrez/shootingstars/gui/LoadingGui.java b/ShootingStars/src/org/wyrez/shootingstars/gui/LoadingGui.java index fb0649e..aec43fc 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/gui/LoadingGui.java +++ b/ShootingStars/src/org/wyrez/shootingstars/gui/LoadingGui.java @@ -16,6 +16,7 @@ */ package org.wyrez.shootingstars.gui; +import com.jme3.asset.AssetManager; import com.jme3.font.BitmapFont; import com.jme3.math.ColorRGBA; import com.jme3.math.Vector2f; @@ -24,21 +25,20 @@ import org.wyrez.shootingstars.helper.ScreenHelper; import org.wyrez.shootingstars.states.util.LoadingProgress; import tonegod.gui.controls.extras.Indicator; import tonegod.gui.controls.text.Label; -import tonegod.gui.controls.windows.Panel; import tonegod.gui.core.Screen; /** * * @author Darth Affe */ -public class LoadingGui extends Panel implements Gui{ +public class LoadingGui extends BackgroundedGui implements Gui{ private Label lblStatus; private Indicator indProgress; private ScreenHelper screenHelper; - public LoadingGui(Screen screen, ScreenHelper screenHelper) { - super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd + public LoadingGui(Screen screen, ScreenHelper screenHelper, AssetManager assetManager) { + super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f), assetManager); //create for full hd this.screenHelper = screenHelper; this.setIgnoreMouse(true); this.setIsVisible(false); diff --git a/ShootingStars/src/org/wyrez/shootingstars/gui/MenuGUI.java b/ShootingStars/src/org/wyrez/shootingstars/gui/MenuGUI.java index d30fa52..775e297 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/gui/MenuGUI.java +++ b/ShootingStars/src/org/wyrez/shootingstars/gui/MenuGUI.java @@ -16,6 +16,7 @@ */ package org.wyrez.shootingstars.gui; +import com.jme3.asset.AssetManager; import com.jme3.input.event.MouseButtonEvent; import com.jme3.math.Vector2f; import org.wyrez.shootingstars.gui.controls.ButtonBase; @@ -23,20 +24,19 @@ import org.wyrez.shootingstars.gui.listener.MenuListener; import org.wyrez.shootingstars.helper.ScreenHelper; import tonegod.gui.controls.buttons.Button; import tonegod.gui.controls.text.Label; -import tonegod.gui.controls.windows.Panel; import tonegod.gui.core.Screen; /** * * @author Darth Affe */ -public class MenuGUI extends Panel implements Gui { +public class MenuGUI extends BackgroundedGui implements Gui { private MenuListener listener; private ScreenHelper screenHelper; - public MenuGUI(Screen screen, MenuListener listener, ScreenHelper screenHelper) { - super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd + public MenuGUI(Screen screen, MenuListener listener, ScreenHelper screenHelper, AssetManager assetManager) { + super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f), assetManager); //create for full hd this.listener = listener; this.screenHelper = screenHelper; this.setIgnoreMouse(true); @@ -45,7 +45,6 @@ public class MenuGUI extends Panel implements Gui { } private void create() { - float startPointx = screenHelper.calcX(256f); float startPointy = screenHelper.calcY(252f); float labelFontSize = screenHelper.calcX(89f); diff --git a/ShootingStars/src/org/wyrez/shootingstars/gui/OptionsGUI.java b/ShootingStars/src/org/wyrez/shootingstars/gui/OptionsGUI.java index cea9104..7d701c3 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/gui/OptionsGUI.java +++ b/ShootingStars/src/org/wyrez/shootingstars/gui/OptionsGUI.java @@ -16,6 +16,7 @@ */ package org.wyrez.shootingstars.gui; +import com.jme3.asset.AssetManager; import com.jme3.input.event.MouseButtonEvent; import com.jme3.math.Vector2f; import org.wyrez.shootingstars.gui.controls.ButtonBase; @@ -29,14 +30,13 @@ import tonegod.gui.controls.lists.ComboBox; import tonegod.gui.controls.lists.Slider; import tonegod.gui.controls.text.Label; import tonegod.gui.controls.text.TextField; -import tonegod.gui.controls.windows.Panel; import tonegod.gui.core.Screen; /** * * @author Snowsun */ -public class OptionsGUI extends Panel implements Gui { +public class OptionsGUI extends BackgroundedGui implements Gui { private OptionsListener listener; private OptionSettings settings; @@ -56,8 +56,9 @@ public class OptionsGUI extends Panel implements Gui { private Slider sldMenuVolume; private Slider sldMusicVolume; - public OptionsGUI(Screen screen, OptionsListener listener, OptionSettings settings, ScreenHelper screenHelper) { - super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd + public OptionsGUI(Screen screen, OptionsListener listener, OptionSettings settings, + ScreenHelper screenHelper, AssetManager assetManager) { + super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f), assetManager); //create for full hd this.listener = listener; this.settings = settings; this.screenHelper = screenHelper; @@ -117,7 +118,7 @@ public class OptionsGUI extends Panel implements Gui { float startPointx = screenHelper.calcX(64f); float startPointy = screenHelper.calcY(36f); float marginLeftControls = screenHelper.calcX(115.8f); - + float startPointAudioVisualx = screenHelper.calcX(464f); float startPointAudioVisualy = screenHelper.calcY(36f); float marginLeftAudioVisualControl = screenHelper.calcX(190f); @@ -132,9 +133,9 @@ public class OptionsGUI extends Panel implements Gui { Label lblEnableAudioVisualization = new Label(screen, new Vector2f(startPointAudioVisualx, startPointAudioVisualy), new Vector2f(screenHelper.calcX(200f), screenHelper.calcY(40f))); lblEnableAudioVisualization.setText("Enable Audio Visualization"); lblEnableAudioVisualization.setFontSize(labelFontSize); - + chkEnableAudioVisualization = new CheckBox(screen, new Vector2f(startPointAudioVisualx + marginLeftAudioVisualControl, startPointAudioVisualy + screenHelper.calcY(12f)), new Vector2f(screenHelper.calcX(20f), screenHelper.calcX(20f))); - + this.addChild(lblPlayerName); this.addChild(txtPlayerName); this.addChild(lblEnableAudioVisualization); @@ -294,7 +295,7 @@ public class OptionsGUI extends Panel implements Gui { setComboBoxValue(cboFrequency, String.valueOf(settings.getFrequency())); chkFullscreen.setIsChecked(settings.isFullscreenEnabled()); chkVSync.setIsChecked(settings.isVSyncEnabled()); - chkShowWeapon.setIsChecked(settings.isShowWeaponEnabled()); + chkShowWeapon.setIsChecked(settings.isShowWeaponEnabled()); sldParticleDensity.setSelectedIndex(settings.getParticleDensity()); //Audio diff --git a/ShootingStars/src/org/wyrez/shootingstars/gui/SelectTrackGUI.java b/ShootingStars/src/org/wyrez/shootingstars/gui/SelectTrackGUI.java index 0e83341..1072139 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/gui/SelectTrackGUI.java +++ b/ShootingStars/src/org/wyrez/shootingstars/gui/SelectTrackGUI.java @@ -16,6 +16,7 @@ */ package org.wyrez.shootingstars.gui; +import com.jme3.asset.AssetManager; import com.jme3.input.event.MouseButtonEvent; import com.jme3.math.Vector2f; import org.wyrez.shootingstars.gui.controls.ButtonBase; @@ -23,20 +24,20 @@ import org.wyrez.shootingstars.gui.listener.SelectFileListener; import org.wyrez.shootingstars.helper.ScreenHelper; import tonegod.gui.controls.buttons.Button; import tonegod.gui.controls.text.Label; -import tonegod.gui.controls.windows.Panel; import tonegod.gui.core.Screen; /** * * @author Snowsun */ -public class SelectTrackGUI extends Panel implements Gui { +public class SelectTrackGUI extends BackgroundedGui implements Gui { private SelectFileListener listener; private ScreenHelper screenHelper; - public SelectTrackGUI(Screen screen, SelectFileListener listener, ScreenHelper screenHelper) { - super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd + public SelectTrackGUI(Screen screen, SelectFileListener listener, + ScreenHelper screenHelper, AssetManager assetManager) { + super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f), assetManager); //create for full hd this.listener = listener; this.screenHelper = screenHelper; this.setIgnoreMouse(true); diff --git a/ShootingStars/src/org/wyrez/shootingstars/gui/YTDownloadGUI.java b/ShootingStars/src/org/wyrez/shootingstars/gui/YTDownloadGUI.java index 9537af7..ec2c81c 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/gui/YTDownloadGUI.java +++ b/ShootingStars/src/org/wyrez/shootingstars/gui/YTDownloadGUI.java @@ -16,6 +16,7 @@ */ package org.wyrez.shootingstars.gui; +import com.jme3.asset.AssetManager; import com.jme3.input.event.MouseButtonEvent; import com.jme3.math.Vector2f; import org.wyrez.shootingstars.gui.controls.ButtonBase; @@ -24,20 +25,20 @@ import org.wyrez.shootingstars.helper.ScreenHelper; import tonegod.gui.controls.buttons.Button; import tonegod.gui.controls.text.Label; import tonegod.gui.controls.text.TextField; -import tonegod.gui.controls.windows.Panel; import tonegod.gui.core.Screen; /** * * @author Snowsun */ -public class YTDownloadGUI extends Panel implements Gui { +public class YTDownloadGUI extends BackgroundedGui implements Gui { private YTDownloadListener listener; private ScreenHelper screenHelper; - public YTDownloadGUI(Screen screen, YTDownloadListener listener, ScreenHelper screenHelper) { - super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd + public YTDownloadGUI(Screen screen, YTDownloadListener listener, + ScreenHelper screenHelper, AssetManager assetManager) { + super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f), assetManager); //create for full hd this.listener = listener; this.screenHelper = screenHelper; this.setIgnoreMouse(true); diff --git a/ShootingStars/src/org/wyrez/shootingstars/states/FileMetaInfoState.java b/ShootingStars/src/org/wyrez/shootingstars/states/FileMetaInfoState.java index dec2dcb..c66d4af 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/states/FileMetaInfoState.java +++ b/ShootingStars/src/org/wyrez/shootingstars/states/FileMetaInfoState.java @@ -18,6 +18,7 @@ package org.wyrez.shootingstars.states; import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AppStateManager; +import com.jme3.asset.AssetManager; import org.wyrez.shootingstars.game.GameSettings; import org.wyrez.shootingstars.gui.FileMetaInfoGUI; import org.wyrez.shootingstars.gui.Gui; @@ -33,12 +34,13 @@ public class FileMetaInfoState extends AbstractAppState implements FileMetaInfoL private StateManager stateManager; private Gui gui; - - public FileMetaInfoState(Screen screen, StateManager stateManager, GameSettings settings, ScreenHelper screenHelper) { + + public FileMetaInfoState(Screen screen, StateManager stateManager, + GameSettings settings, ScreenHelper screenHelper, AssetManager assetManager) { this.stateManager = stateManager; - this.gui = new FileMetaInfoGUI(screen, this, settings, screenHelper); + this.gui = new FileMetaInfoGUI(screen, this, settings, screenHelper, assetManager); } - + public void startLoading() { stateManager.setState(State.LOADING); } diff --git a/ShootingStars/src/org/wyrez/shootingstars/states/HighscoreState.java b/ShootingStars/src/org/wyrez/shootingstars/states/HighscoreState.java index b3d7fa2..6f4d5ab 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/states/HighscoreState.java +++ b/ShootingStars/src/org/wyrez/shootingstars/states/HighscoreState.java @@ -18,6 +18,7 @@ package org.wyrez.shootingstars.states; import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AppStateManager; +import com.jme3.asset.AssetManager; import org.wyrez.shootingstars.gui.Gui; import org.wyrez.shootingstars.gui.HighscoreGUI; import org.wyrez.shootingstars.gui.listener.HighscoreListener; @@ -37,9 +38,9 @@ public class HighscoreState extends AbstractAppState implements HighscoreListene private BackgroundMusic music; public HighscoreState(Screen screen, StateManager stateManager, HighscoreManager highscoreManager, - ScreenHelper screenHelper, BackgroundMusic music) { + ScreenHelper screenHelper, BackgroundMusic music, AssetManager assetManager) { this.stateManager = stateManager; - this.gui = new HighscoreGUI(screen, this, highscoreManager, screenHelper); + this.gui = new HighscoreGUI(screen, this, highscoreManager, screenHelper, assetManager); this.music = music; } diff --git a/ShootingStars/src/org/wyrez/shootingstars/states/LoadingState.java b/ShootingStars/src/org/wyrez/shootingstars/states/LoadingState.java index e5462e4..499d644 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/states/LoadingState.java +++ b/ShootingStars/src/org/wyrez/shootingstars/states/LoadingState.java @@ -18,6 +18,7 @@ package org.wyrez.shootingstars.states; import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AppStateManager; +import com.jme3.asset.AssetManager; import java.io.File; import org.wyrez.shootingstars.data.AudioDataManager; import org.wyrez.shootingstars.data.OggConverter; @@ -45,9 +46,9 @@ public class LoadingState extends AbstractAppState { public LoadingState(Screen screen, StateManager stateManager, AudioDataManager audioDataManager, GameSettings settings, - ScreenHelper screenHelper, BackgroundMusic music) { + ScreenHelper screenHelper, BackgroundMusic music, AssetManager assetManager) { this.stateManager = stateManager; - this.gui = new LoadingGui(screen,screenHelper); + this.gui = new LoadingGui(screen, screenHelper, assetManager); this.audioDataManager = audioDataManager; this.settings = settings; this.music = music; diff --git a/ShootingStars/src/org/wyrez/shootingstars/states/MenuState.java b/ShootingStars/src/org/wyrez/shootingstars/states/MenuState.java index 762895a..bc6e4d8 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/states/MenuState.java +++ b/ShootingStars/src/org/wyrez/shootingstars/states/MenuState.java @@ -18,6 +18,7 @@ package org.wyrez.shootingstars.states; import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AppStateManager; +import com.jme3.asset.AssetManager; import org.wyrez.shootingstars.ShootingStars; import org.wyrez.shootingstars.gui.Gui; import org.wyrez.shootingstars.gui.MenuGUI; @@ -38,9 +39,9 @@ public class MenuState extends AbstractAppState implements MenuListener { private BackgroundMusic music; public MenuState(Screen screen, StateManager stateManager, ShootingStars shootingStars, - ScreenHelper screenHelper, BackgroundMusic music) { + ScreenHelper screenHelper, BackgroundMusic music, AssetManager assetManager) { this.stateManager = stateManager; - this.gui = new MenuGUI(screen, this, screenHelper); + this.gui = new MenuGUI(screen, this, screenHelper, assetManager); this.shootingStars = shootingStars; this.music = music; } diff --git a/ShootingStars/src/org/wyrez/shootingstars/states/OptionsState.java b/ShootingStars/src/org/wyrez/shootingstars/states/OptionsState.java index c45b9ec..30efe8f 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/states/OptionsState.java +++ b/ShootingStars/src/org/wyrez/shootingstars/states/OptionsState.java @@ -18,6 +18,7 @@ package org.wyrez.shootingstars.states; import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AppStateManager; +import com.jme3.asset.AssetManager; import org.wyrez.shootingstars.gui.OptionsGUI; import org.wyrez.shootingstars.gui.listener.OptionsListener; import org.wyrez.shootingstars.helper.ScreenHelper; @@ -35,17 +36,17 @@ public class OptionsState extends AbstractAppState implements OptionsListener { private OptionsGUI gui; private OptionSettings settings; private BackgroundMusic music; - + public OptionsState(Screen screen, StateManager stateManager, OptionSettings settings, - ScreenHelper screenHelper, BackgroundMusic music) { + ScreenHelper screenHelper, BackgroundMusic music, AssetManager assetManager) { this.stateManager = stateManager; this.settings = settings; - this.gui = new OptionsGUI(screen, this,settings, screenHelper); + this.gui = new OptionsGUI(screen, this, settings, screenHelper, assetManager); this.music = music; } @Override - public void stateAttached(AppStateManager stateManager) { + public void stateAttached(AppStateManager stateManager) { gui.attach(); } @@ -53,7 +54,7 @@ public class OptionsState extends AbstractAppState implements OptionsListener { public void stateDetached(AppStateManager stateManager) { gui.detach(); } - + public void save() { stateManager.setState(State.MENU); music.update(); @@ -62,5 +63,4 @@ public class OptionsState extends AbstractAppState implements OptionsListener { public void cancel() { stateManager.setState(State.MENU); } - } diff --git a/ShootingStars/src/org/wyrez/shootingstars/states/SelectTrackState.java b/ShootingStars/src/org/wyrez/shootingstars/states/SelectTrackState.java index 58444a3..a85b271 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/states/SelectTrackState.java +++ b/ShootingStars/src/org/wyrez/shootingstars/states/SelectTrackState.java @@ -18,6 +18,7 @@ package org.wyrez.shootingstars.states; import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AppStateManager; +import com.jme3.asset.AssetManager; import com.sun.jna.Memory; import java.io.File; import javax.swing.JFileChooser; @@ -38,7 +39,7 @@ import uk.co.caprica.vlcj.player.direct.RenderCallback; * @author Snowsun */ public class SelectTrackState extends AbstractAppState implements SelectFileListener { - + private static final int SLEEP = 1000; /**/ private ShootingStars shootingStars; @@ -49,29 +50,30 @@ public class SelectTrackState extends AbstractAppState implements SelectFileList //HACK filechooser is not visible in fullscreen private int selectState = -1; private boolean wasFullscreen; - + public SelectTrackState(Screen screen, StateManager stateManager, GameSettings settings, ScreenHelper screenHelper, - OptionSettings optionSettings, ShootingStars shootingStars) { + OptionSettings optionSettings, ShootingStars shootingStars, + AssetManager assetManager) { this.shootingStars = shootingStars; this.optionSettings = optionSettings; this.stateManager = stateManager; this.settings = settings; - this.gui = new SelectTrackGUI(screen, this, screenHelper); + this.gui = new SelectTrackGUI(screen, this, screenHelper, assetManager); } - + @Override public void stateAttached(AppStateManager stateManager) { gui.attach(); selectState = -1; } - + @Override public void stateDetached(AppStateManager stateManager) { gui.detach(); selectState = -1; } - + @Override public void update(float tpf) { //TODO this is a hell of a workaround... @@ -87,7 +89,7 @@ public class SelectTrackState extends AbstractAppState implements SelectFileList case 1: JFileChooser jFileChooser = new JFileChooser(); int returnVal = jFileChooser.showOpenDialog(null); - + settings.setAudioFile(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = jFileChooser.getSelectedFile(); @@ -115,12 +117,12 @@ public class SelectTrackState extends AbstractAppState implements SelectFileList break; } } - + public void selectFile() { wasFullscreen = optionSettings.isFullscreenEnabled(); selectState = 0; } - + private void readMetadata(String file) { MediaPlayerFactory mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--quiet"); DirectMediaPlayer mediaPlayer = mediaPlayerFactory.newDirectMediaPlayer(1, 1, new RenderCallback() { @@ -138,16 +140,16 @@ public class SelectTrackState extends AbstractAppState implements SelectFileList settings.setTrackTitle(mediaPlayer.getMediaMeta().getTitle()); settings.setTrackArtist(mediaPlayer.getMediaMeta().getArtist()); settings.setTrackLength(Math.round((float) mediaPlayer.getLength() / 1000f)); - + mediaPlayer.stop(); mediaPlayer.release(); mediaPlayerFactory.release(); } - + public void downloadYT() { stateManager.setState(State.YTDOWNLOAD); } - + public void cancel() { stateManager.setState(State.MENU); } diff --git a/ShootingStars/src/org/wyrez/shootingstars/states/YTDownloadState.java b/ShootingStars/src/org/wyrez/shootingstars/states/YTDownloadState.java index faee704..3f318a7 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/states/YTDownloadState.java +++ b/ShootingStars/src/org/wyrez/shootingstars/states/YTDownloadState.java @@ -18,6 +18,7 @@ package org.wyrez.shootingstars.states; import com.jme3.app.state.AbstractAppState; import com.jme3.app.state.AppStateManager; +import com.jme3.asset.AssetManager; import com.sun.jna.Memory; import java.io.File; import java.util.regex.Matcher; @@ -53,10 +54,11 @@ public class YTDownloadState extends AbstractAppState implements YTDownloadListe private YTDownloader downloader; public YTDownloadState(Screen screen, StateManager stateManager, - GameSettings settings, YTDownloader downloader, ScreenHelper screenHelper) { + GameSettings settings, YTDownloader downloader, ScreenHelper screenHelper, + AssetManager assetManager) { this.stateManager = stateManager; this.settings = settings; - this.gui = new YTDownloadGUI(screen, this, screenHelper); + this.gui = new YTDownloadGUI(screen, this, screenHelper, assetManager); this.downloader = downloader; }