added basic gui and loading screen
This commit is contained in:
parent
33c425c368
commit
5eb2fcc290
@ -1,3 +1,7 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.processors.list=
|
||||
annotation.processing.run.all.processors=true
|
||||
application.title=MyGame
|
||||
application.vendor=MyCompany
|
||||
assets.jar.name=assets.jar
|
||||
@ -28,13 +32,18 @@ dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
includes=**
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=false
|
||||
jar.index=${jnlp.enabled}
|
||||
javac.classpath=\
|
||||
${libs.jme3.classpath}:\
|
||||
${libs.jme3-libraries.classpath}
|
||||
${libs.tonegodGUI.classpath}:\
|
||||
${libs.jme3-libraries-lwjgl-minimum.classpath}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.test.classpath=\
|
||||
@ -55,11 +64,16 @@ jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
|
||||
jnlp.codebase.type=local
|
||||
jnlp.descriptor=application
|
||||
jnlp.enabled=false
|
||||
jnlp.mixed.code=default
|
||||
jnlp.offline-allowed=false
|
||||
jnlp.signed=false
|
||||
jnlp.signing=
|
||||
jnlp.signing.alias=
|
||||
jnlp.signing.keystore=
|
||||
main.class=org.wyrez.shootingstars.ShootingStars
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
manifest.file=MANIFEST.MF
|
||||
mkdist.disabled=false
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.wyrez.shootingstars;
|
||||
|
||||
import com.jme3.app.Application;
|
||||
import com.jme3.app.DebugKeysAppState;
|
||||
import com.jme3.app.SimpleApplication;
|
||||
import com.jme3.app.StatsAppState;
|
||||
@ -25,6 +26,7 @@ import com.jme3.scene.Node;
|
||||
import org.wyrez.persij.PersiJContainer;
|
||||
import org.wyrez.shootingstars.states.State;
|
||||
import org.wyrez.shootingstars.states.StateManager;
|
||||
import tonegod.gui.core.Screen;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -34,6 +36,7 @@ public class ShootingStars extends SimpleApplication {
|
||||
|
||||
private PersiJContainer container;
|
||||
private StateManager sManager;
|
||||
private Screen screen;
|
||||
|
||||
public ShootingStars() {
|
||||
super(new StatsAppState(), new DebugKeysAppState());
|
||||
@ -42,6 +45,7 @@ public class ShootingStars extends SimpleApplication {
|
||||
@Override
|
||||
public void simpleInitApp() {
|
||||
registerTypes();
|
||||
initGUI();
|
||||
|
||||
sManager = container.resolve(StateManager.class);
|
||||
sManager.setState(State.START);
|
||||
@ -51,16 +55,19 @@ public class ShootingStars extends SimpleApplication {
|
||||
public void simpleUpdate(float tpf) {
|
||||
}
|
||||
|
||||
public StateManager getSManager() {
|
||||
return sManager;
|
||||
private void initGUI() {
|
||||
guiNode.addControl(container.resolve(Screen.class));
|
||||
}
|
||||
|
||||
private void registerTypes() {
|
||||
container = new PersiJContainer();
|
||||
container.registerSingleton(ShootingStars.class, this);
|
||||
container.registerSingleton(Application.class, this);
|
||||
container.registerSingleton(Node.class, rootNode);
|
||||
container.registerSingleton(Camera.class, cam);
|
||||
container.registerSingleton(AppStateManager.class, stateManager);
|
||||
container.registerType(StateManager.class, true);
|
||||
container.registerType(Screen.class, true);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <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;
|
||||
|
||||
import com.jme3.input.event.MouseButtonEvent;
|
||||
import com.jme3.input.event.MouseMotionEvent;
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.math.Vector4f;
|
||||
import tonegod.gui.controls.buttons.Button;
|
||||
import tonegod.gui.core.Screen;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class ButtonBase extends Button {
|
||||
|
||||
public ButtonBase(Screen screen, Vector2f position) {
|
||||
super(screen, position);
|
||||
}
|
||||
|
||||
public ButtonBase(Screen screen, Vector2f position, Vector2f dimensions) {
|
||||
super(screen, position, dimensions);
|
||||
}
|
||||
|
||||
public ButtonBase(Screen screen, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
|
||||
super(screen, position, dimensions, resizeBorders, defaultImg);
|
||||
}
|
||||
|
||||
public ButtonBase(Screen screen, String UID, Vector2f position) {
|
||||
super(screen, UID, position);
|
||||
}
|
||||
|
||||
public ButtonBase(Screen screen, String UID, Vector2f position, Vector2f dimensions) {
|
||||
super(screen, UID, position, dimensions);
|
||||
}
|
||||
|
||||
public ButtonBase(Screen screen, String UID, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
|
||||
super(screen, UID, position, dimensions, resizeBorders, defaultImg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonMouseLeftDown(MouseButtonEvent evt, boolean toggled) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonMouseRightDown(MouseButtonEvent evt, boolean toggled) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonMouseRightUp(MouseButtonEvent evt, boolean toggled) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonFocus(MouseMotionEvent evt) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onButtonLostFocus(MouseMotionEvent evt) {
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <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;
|
||||
|
||||
import com.jme3.math.Vector2f;
|
||||
import com.jme3.math.Vector4f;
|
||||
import tonegod.gui.controls.extras.Indicator;
|
||||
import tonegod.gui.core.Screen;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class IndicatorBase extends Indicator {
|
||||
|
||||
public IndicatorBase(Screen screen, Vector2f position, Orientation orientation) {
|
||||
super(screen, position, orientation);
|
||||
}
|
||||
|
||||
public IndicatorBase(Screen screen, Vector2f position, Vector2f dimensions, Orientation orientation) {
|
||||
super(screen, position, dimensions, orientation);
|
||||
}
|
||||
|
||||
public IndicatorBase(Screen screen, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg, Orientation orientation) {
|
||||
super(screen, position, dimensions, resizeBorders, defaultImg, orientation);
|
||||
}
|
||||
|
||||
public IndicatorBase(Screen screen, String UID, Vector2f position, Orientation orientation) {
|
||||
super(screen, UID, position, orientation);
|
||||
}
|
||||
|
||||
public IndicatorBase(Screen screen, String UID, Vector2f position, Vector2f dimensions, Orientation orientation) {
|
||||
super(screen, UID, position, dimensions, orientation);
|
||||
}
|
||||
|
||||
public IndicatorBase(Screen screen, String UID, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg, Orientation orientation) {
|
||||
super(screen, UID, position, dimensions, resizeBorders, defaultImg, orientation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChange(float arg0, float arg1) {
|
||||
}
|
||||
}
|
||||
@ -17,11 +17,147 @@
|
||||
package org.wyrez.shootingstars.states;
|
||||
|
||||
import com.jme3.app.state.AbstractAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import com.jme3.font.BitmapFont;
|
||||
import com.jme3.input.event.MouseButtonEvent;
|
||||
import com.jme3.math.ColorRGBA;
|
||||
import com.jme3.math.Vector2f;
|
||||
import org.wyrez.shootingstars.gui.ButtonBase;
|
||||
import org.wyrez.shootingstars.gui.IndicatorBase;
|
||||
import org.wyrez.shootingstars.states.util.LoadingProgress;
|
||||
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.core.Screen;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public class LoadingState extends AbstractAppState{
|
||||
public class LoadingState extends AbstractAppState {
|
||||
|
||||
private StateManager stateManager;
|
||||
private Screen screen;
|
||||
private Panel loadingPanel;
|
||||
private Label lblStatus;
|
||||
private Indicator indProgress;
|
||||
private Button btnStart;
|
||||
private LoadingProgress currentProgress;
|
||||
|
||||
public LoadingState(Screen screen, StateManager stateManager) {
|
||||
this.screen = screen;
|
||||
this.stateManager = stateManager;
|
||||
createGUI();
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
loadingPanel = new Panel(screen, new Vector2f(15, 15), new Vector2f(800, 500));
|
||||
loadingPanel.setIgnoreMouse(true);
|
||||
|
||||
indProgress = new IndicatorBase(screen, new Vector2f(360f, 360f),
|
||||
new Vector2f(200f, 30f), Indicator.Orientation.HORIZONTAL);
|
||||
indProgress.setDisplayValues();
|
||||
indProgress.setMaxValue(LoadingProgress.getProgressCount());
|
||||
indProgress.setIndicatorColor(ColorRGBA.Black);
|
||||
|
||||
lblStatus = new Label(screen, new Vector2f(360f, 400f), new Vector2f(200f, 30f));
|
||||
lblStatus.setTextAlign(BitmapFont.Align.Center);
|
||||
|
||||
btnStart = new ButtonBase(screen, new Vector2f(360f, 360f),
|
||||
new Vector2f(200f, 30f)) {
|
||||
@Override
|
||||
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||
startGame();
|
||||
}
|
||||
};
|
||||
btnStart.setText("Start Game");
|
||||
btnStart.setTextAlign(BitmapFont.Align.Center);
|
||||
|
||||
loadingPanel.addChild(indProgress);
|
||||
loadingPanel.addChild(lblStatus);
|
||||
loadingPanel.addChild(btnStart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateAttached(AppStateManager stateManager) {
|
||||
currentProgress = LoadingProgress.START;
|
||||
screen.addElement(loadingPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateDetached(AppStateManager stateManager) {
|
||||
screen.removeElement(loadingPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
switch (currentProgress) {
|
||||
case START:
|
||||
setLoadingStart();
|
||||
currentProgress = LoadingProgress.ANALYSE_LOW_BAND;
|
||||
break;
|
||||
case ANALYSE_LOW_BAND:
|
||||
analyseLowBand();
|
||||
currentProgress = LoadingProgress.ANALYSE_HIGH_BAND;
|
||||
break;
|
||||
case ANALYSE_HIGH_BAND:
|
||||
analyseHighBand();
|
||||
currentProgress = LoadingProgress.GENERATING_SCENE;
|
||||
break;
|
||||
case GENERATING_SCENE:
|
||||
generateScene();
|
||||
currentProgress = LoadingProgress.DONE;
|
||||
break;
|
||||
case DONE:
|
||||
setLoadingDone();
|
||||
break;
|
||||
}
|
||||
updateProgress(currentProgress);
|
||||
}
|
||||
|
||||
private void analyseLowBand() {
|
||||
//TODO fill
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
private void analyseHighBand() {
|
||||
//TODO fill
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
private void generateScene() {
|
||||
//TODO fill
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
private void setLoadingStart() {
|
||||
btnStart.hide();
|
||||
indProgress.show();
|
||||
lblStatus.show();
|
||||
}
|
||||
|
||||
private void setLoadingDone() {
|
||||
btnStart.show();
|
||||
indProgress.hide();
|
||||
lblStatus.hide();
|
||||
}
|
||||
|
||||
private void startGame() {
|
||||
stateManager.setState(State.GAME);
|
||||
}
|
||||
|
||||
private void updateProgress(LoadingProgress progress) {
|
||||
lblStatus.setText(progress.getText());
|
||||
indProgress.setCurrentValue(progress.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,12 @@ package org.wyrez.shootingstars.states;
|
||||
|
||||
import com.jme3.app.state.AbstractAppState;
|
||||
import com.jme3.app.state.AppStateManager;
|
||||
import com.jme3.input.event.MouseButtonEvent;
|
||||
import com.jme3.math.Vector2f;
|
||||
import org.wyrez.shootingstars.gui.ButtonBase;
|
||||
import tonegod.gui.controls.buttons.Button;
|
||||
import tonegod.gui.controls.windows.Panel;
|
||||
import tonegod.gui.core.Screen;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -25,15 +31,56 @@ import com.jme3.app.state.AppStateManager;
|
||||
*/
|
||||
public class MenuState extends AbstractAppState {
|
||||
|
||||
public MenuState() {
|
||||
private StateManager stateManager;
|
||||
private Screen screen;
|
||||
private Panel menuPanel;
|
||||
|
||||
public MenuState(Screen screen, StateManager stateManager) {
|
||||
this.screen = screen;
|
||||
this.stateManager = stateManager;
|
||||
createGUI();
|
||||
}
|
||||
|
||||
private void createGUI() {
|
||||
menuPanel = new Panel(screen, new Vector2f(15, 15), new Vector2f(800, 500));
|
||||
menuPanel.setIgnoreMouse(true);
|
||||
|
||||
Button btnExit = new ButtonBase(screen, new Vector2f(600, 400), new Vector2f(120, 40)) {
|
||||
@Override
|
||||
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||
exitGame();
|
||||
}
|
||||
};
|
||||
btnExit.setText("Exit");
|
||||
|
||||
Button btnStart = new ButtonBase(screen, new Vector2f(600, 300), new Vector2f(120, 40)) {
|
||||
@Override
|
||||
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||
startGame();
|
||||
}
|
||||
};
|
||||
btnStart.setText("Start");
|
||||
|
||||
menuPanel.addChild(btnStart);
|
||||
menuPanel.addChild(btnExit);
|
||||
}
|
||||
|
||||
private void startGame() {
|
||||
stateManager.setState(State.LOADING);
|
||||
}
|
||||
|
||||
private void exitGame() {
|
||||
//TODO ss.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateAttached(AppStateManager stateManager) {
|
||||
screen.addElement(menuPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stateDetached(AppStateManager stateManager) {
|
||||
screen.removeElement(menuPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -41,5 +41,11 @@ public class StartState extends AbstractAppState {
|
||||
|
||||
@Override
|
||||
public void update(float tpf) {
|
||||
//TODO load everything
|
||||
//init states
|
||||
stateManager.getState(State.MENU);
|
||||
stateManager.getState(State.LOADING);
|
||||
|
||||
stateManager.setState(State.MENU);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Darth Affe <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.util;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Darth Affe
|
||||
*/
|
||||
public enum LoadingProgress {
|
||||
|
||||
START("Loading...", 0), ANALYSE_LOW_BAND("Analyse Low-Band...", 0),
|
||||
ANALYSE_HIGH_BAND("Analyse High-Band...", 1), GENERATING_SCENE("Generating Scene...", 2),
|
||||
DONE("Done!", 3);
|
||||
private String text;
|
||||
private float value;
|
||||
|
||||
private LoadingProgress(String text, int value) {
|
||||
this.text = text;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public float getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public static int getProgressCount() {
|
||||
return LoadingProgress.values().length - 2;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user