refactored gui
This commit is contained in:
parent
6e786112de
commit
665e11b6c2
56
ShootingStars/src/org/wyrez/shootingstars/gui/GameGUI.java
Normal file
56
ShootingStars/src/org/wyrez/shootingstars/gui/GameGUI.java
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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 org.wyrez.shootingstars.gui.controls.PanelBase;
|
||||||
|
import org.wyrez.shootingstars.gui.listener.GameListener;
|
||||||
|
import tonegod.gui.controls.windows.Panel;
|
||||||
|
import tonegod.gui.core.Screen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Darth Affe
|
||||||
|
*/
|
||||||
|
public class GameGUI extends Panel {
|
||||||
|
|
||||||
|
private GameListener listener;
|
||||||
|
|
||||||
|
public GameGUI(Screen screen, GameListener listener) {
|
||||||
|
super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd
|
||||||
|
this.listener = listener;
|
||||||
|
this.setIgnoreMouse(true);
|
||||||
|
this.setIsVisible(false);
|
||||||
|
create();
|
||||||
|
this.resize(screen.getWidth(), screen.getHeight(), Borders.SE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create() {
|
||||||
|
//Panel panel = new PanelBase(screen, new Vector2f(15, 15), new Vector2f(800, 500));
|
||||||
|
//panel.setIgnoreMouse(true);
|
||||||
|
|
||||||
|
//this.addChild(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void attach() {
|
||||||
|
screen.addElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void detach() {
|
||||||
|
screen.removeElement(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
ShootingStars/src/org/wyrez/shootingstars/gui/Gui.java
Normal file
28
ShootingStars/src/org/wyrez/shootingstars/gui/Gui.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Darth Affe
|
||||||
|
*/
|
||||||
|
public interface Gui {
|
||||||
|
|
||||||
|
public void attach();
|
||||||
|
|
||||||
|
public void detach();
|
||||||
|
}
|
||||||
108
ShootingStars/src/org/wyrez/shootingstars/gui/LoadingGui.java
Normal file
108
ShootingStars/src/org/wyrez/shootingstars/gui/LoadingGui.java
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
/*
|
||||||
|
* 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.font.BitmapFont;
|
||||||
|
import com.jme3.input.event.MouseButtonEvent;
|
||||||
|
import com.jme3.math.ColorRGBA;
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import org.wyrez.shootingstars.gui.controls.ButtonBase;
|
||||||
|
import org.wyrez.shootingstars.gui.controls.IndicatorBase;
|
||||||
|
import org.wyrez.shootingstars.gui.controls.PanelBase;
|
||||||
|
import org.wyrez.shootingstars.gui.listener.LoadingListener;
|
||||||
|
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 LoadingGui extends Panel {
|
||||||
|
|
||||||
|
private LoadingListener listener;
|
||||||
|
private Label lblStatus;
|
||||||
|
private Indicator indProgress;
|
||||||
|
private Button btnStart;
|
||||||
|
|
||||||
|
public LoadingGui(Screen screen, LoadingListener listener) {
|
||||||
|
super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd
|
||||||
|
this.listener = listener;
|
||||||
|
this.setIgnoreMouse(true);
|
||||||
|
this.setIsVisible(false);
|
||||||
|
create();
|
||||||
|
this.resize(screen.getWidth(), screen.getHeight(), Borders.SE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create() {
|
||||||
|
Panel panel = new PanelBase(screen, new Vector2f(15, 15), new Vector2f(800, 500));
|
||||||
|
panel.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) {
|
||||||
|
listener.startGame();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
btnStart.setText("Start Game");
|
||||||
|
btnStart.setTextAlign(BitmapFont.Align.Center);
|
||||||
|
|
||||||
|
panel.addChild(indProgress);
|
||||||
|
panel.addChild(lblStatus);
|
||||||
|
panel.addChild(btnStart);
|
||||||
|
|
||||||
|
this.addChild(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void attach() {
|
||||||
|
screen.addElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void detach() {
|
||||||
|
screen.removeElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateProgress(LoadingProgress progress) {
|
||||||
|
lblStatus.setText(progress.getText());
|
||||||
|
indProgress.setCurrentValue(progress.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoadingStart() {
|
||||||
|
btnStart.hide();
|
||||||
|
indProgress.show();
|
||||||
|
lblStatus.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLoadingDone() {
|
||||||
|
btnStart.show();
|
||||||
|
indProgress.hide();
|
||||||
|
lblStatus.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
78
ShootingStars/src/org/wyrez/shootingstars/gui/MenuGUI.java
Normal file
78
ShootingStars/src/org/wyrez/shootingstars/gui/MenuGUI.java
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* 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.math.Vector2f;
|
||||||
|
import org.wyrez.shootingstars.gui.controls.ButtonBase;
|
||||||
|
import org.wyrez.shootingstars.gui.controls.PanelBase;
|
||||||
|
import org.wyrez.shootingstars.gui.listener.MenuListener;
|
||||||
|
import tonegod.gui.controls.buttons.Button;
|
||||||
|
import tonegod.gui.controls.windows.Panel;
|
||||||
|
import tonegod.gui.core.Screen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Darth Affe
|
||||||
|
*/
|
||||||
|
public class MenuGUI extends Panel implements Gui {
|
||||||
|
|
||||||
|
private MenuListener listener;
|
||||||
|
|
||||||
|
public MenuGUI(Screen screen, MenuListener listener) {
|
||||||
|
super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd
|
||||||
|
this.listener = listener;
|
||||||
|
this.setIgnoreMouse(true);
|
||||||
|
this.setIsVisible(false);
|
||||||
|
create();
|
||||||
|
this.resize(screen.getWidth(), screen.getHeight(), Borders.SE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void create() {
|
||||||
|
Panel panel = new PanelBase(screen, new Vector2f(15, 15), new Vector2f(800, 500));
|
||||||
|
panel.setIgnoreMouse(true);
|
||||||
|
|
||||||
|
Button btnExit = new ButtonBase(screen, new Vector2f(600, 400), new Vector2f(120, 40)) {
|
||||||
|
@Override
|
||||||
|
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||||
|
listener.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) {
|
||||||
|
listener.startGame();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
btnStart.setText("Start");
|
||||||
|
|
||||||
|
panel.addChild(btnStart);
|
||||||
|
panel.addChild(btnExit);
|
||||||
|
|
||||||
|
this.addChild(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void attach() {
|
||||||
|
screen.addElement(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void detach() {
|
||||||
|
screen.removeElement(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,66 +14,54 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.wyrez.shootingstars.gui;
|
package org.wyrez.shootingstars.gui.controls;
|
||||||
|
|
||||||
import com.jme3.input.event.MouseButtonEvent;
|
import com.jme3.input.event.MouseButtonEvent;
|
||||||
import com.jme3.input.event.MouseMotionEvent;
|
import com.jme3.input.event.MouseMotionEvent;
|
||||||
import com.jme3.math.Vector2f;
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.math.Vector4f;
|
import com.jme3.math.Vector4f;
|
||||||
import tonegod.gui.controls.buttons.Button;
|
import tonegod.gui.controls.buttons.Button;
|
||||||
|
import tonegod.gui.controls.buttons.ButtonAdapter;
|
||||||
import tonegod.gui.core.Screen;
|
import tonegod.gui.core.Screen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darth Affe
|
* @author Darth Affe
|
||||||
*/
|
*/
|
||||||
public class ButtonBase extends Button {
|
public class ButtonBase extends ButtonAdapter {
|
||||||
|
|
||||||
public ButtonBase(Screen screen, Vector2f position) {
|
public ButtonBase(Screen screen, Vector2f position) {
|
||||||
super(screen, position);
|
super(screen, position);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ButtonBase(Screen screen, Vector2f position, Vector2f dimensions) {
|
public ButtonBase(Screen screen, Vector2f position, Vector2f dimensions) {
|
||||||
super(screen, position, dimensions);
|
super(screen, position, dimensions);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ButtonBase(Screen screen, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
|
public ButtonBase(Screen screen, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
|
||||||
super(screen, position, dimensions, resizeBorders, defaultImg);
|
super(screen, position, dimensions, resizeBorders, defaultImg);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ButtonBase(Screen screen, String UID, Vector2f position) {
|
public ButtonBase(Screen screen, String UID, Vector2f position) {
|
||||||
super(screen, UID, position);
|
super(screen, UID, position);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ButtonBase(Screen screen, String UID, Vector2f position, Vector2f dimensions) {
|
public ButtonBase(Screen screen, String UID, Vector2f position, Vector2f dimensions) {
|
||||||
super(screen, UID, position, dimensions);
|
super(screen, UID, position, dimensions);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ButtonBase(Screen screen, String UID, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
|
public ButtonBase(Screen screen, String UID, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
|
||||||
super(screen, UID, position, dimensions, resizeBorders, defaultImg);
|
super(screen, UID, position, dimensions, resizeBorders, defaultImg);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void init() {
|
||||||
public void onButtonMouseLeftDown(MouseButtonEvent evt, boolean toggled) {
|
// this.setScaleNS(true);
|
||||||
}
|
//this.setScaleEW(true);
|
||||||
|
|
||||||
@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) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14,7 +14,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.wyrez.shootingstars.gui;
|
package org.wyrez.shootingstars.gui.controls;
|
||||||
|
|
||||||
import com.jme3.math.Vector2f;
|
import com.jme3.math.Vector2f;
|
||||||
import com.jme3.math.Vector4f;
|
import com.jme3.math.Vector4f;
|
||||||
@ -29,26 +29,39 @@ public class IndicatorBase extends Indicator {
|
|||||||
|
|
||||||
public IndicatorBase(Screen screen, Vector2f position, Orientation orientation) {
|
public IndicatorBase(Screen screen, Vector2f position, Orientation orientation) {
|
||||||
super(screen, position, orientation);
|
super(screen, position, orientation);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndicatorBase(Screen screen, Vector2f position, Vector2f dimensions, Orientation orientation) {
|
public IndicatorBase(Screen screen, Vector2f position, Vector2f dimensions, Orientation orientation) {
|
||||||
super(screen, position, dimensions, orientation);
|
super(screen, position, dimensions, orientation);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndicatorBase(Screen screen, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg, Orientation orientation) {
|
public IndicatorBase(Screen screen, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg, Orientation orientation) {
|
||||||
super(screen, position, dimensions, resizeBorders, defaultImg, orientation);
|
super(screen, position, dimensions, resizeBorders, defaultImg, orientation);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndicatorBase(Screen screen, String UID, Vector2f position, Orientation orientation) {
|
public IndicatorBase(Screen screen, String UID, Vector2f position, Orientation orientation) {
|
||||||
super(screen, UID, position, orientation);
|
super(screen, UID, position, orientation);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndicatorBase(Screen screen, String UID, Vector2f position, Vector2f dimensions, Orientation orientation) {
|
public IndicatorBase(Screen screen, String UID, Vector2f position, Vector2f dimensions, Orientation orientation) {
|
||||||
super(screen, UID, position, dimensions, orientation);
|
super(screen, UID, position, dimensions, orientation);
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndicatorBase(Screen screen, String UID, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg, Orientation 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);
|
super(screen, UID, position, dimensions, resizeBorders, defaultImg, orientation);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
this.setScaleNS(true);
|
||||||
|
this.setScaleEW(true);
|
||||||
|
this.setDockE(true);
|
||||||
|
this.setDockS(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* 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.controls;
|
||||||
|
|
||||||
|
import com.jme3.math.Vector2f;
|
||||||
|
import com.jme3.math.Vector4f;
|
||||||
|
import tonegod.gui.controls.windows.Panel;
|
||||||
|
import tonegod.gui.core.Screen;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Darth Affe
|
||||||
|
*/
|
||||||
|
public class PanelBase extends Panel {
|
||||||
|
|
||||||
|
public PanelBase(Screen screen, Vector2f position) {
|
||||||
|
super(screen, position);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PanelBase(Screen screen, Vector2f position, Vector2f dimensions) {
|
||||||
|
super(screen, position, dimensions);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PanelBase(Screen screen, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
|
||||||
|
super(screen, position, dimensions, resizeBorders, defaultImg);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PanelBase(Screen screen, String UID, Vector2f position) {
|
||||||
|
super(screen, UID, position);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PanelBase(Screen screen, String UID, Vector2f position, Vector2f dimensions) {
|
||||||
|
super(screen, UID, position, dimensions);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PanelBase(Screen screen, String UID, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
|
||||||
|
super(screen, UID, position, dimensions, resizeBorders, defaultImg);
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
this.setScaleEW(true);
|
||||||
|
this.setScaleNS(true);
|
||||||
|
this.setDockE(true);
|
||||||
|
this.setDockS(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* 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.listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Darth Affe
|
||||||
|
*/
|
||||||
|
public interface GameListener {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* 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.listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Darth Affe
|
||||||
|
*/
|
||||||
|
public interface LoadingListener {
|
||||||
|
|
||||||
|
public void startGame();
|
||||||
|
}
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
* 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.listener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Darth Affe
|
||||||
|
*/
|
||||||
|
public interface MenuListener {
|
||||||
|
|
||||||
|
public void exitGame();
|
||||||
|
|
||||||
|
public void startGame();
|
||||||
|
}
|
||||||
@ -17,10 +17,39 @@
|
|||||||
package org.wyrez.shootingstars.states;
|
package org.wyrez.shootingstars.states;
|
||||||
|
|
||||||
import com.jme3.app.state.AbstractAppState;
|
import com.jme3.app.state.AbstractAppState;
|
||||||
|
import com.jme3.app.state.AppStateManager;
|
||||||
|
import com.jme3.scene.Node;
|
||||||
|
import org.wyrez.shootingstars.gui.GameGUI;
|
||||||
|
import org.wyrez.shootingstars.gui.listener.GameListener;
|
||||||
|
import tonegod.gui.core.Screen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darth Affe
|
* @author Darth Affe
|
||||||
*/
|
*/
|
||||||
public class GameState extends AbstractAppState {
|
public class GameState extends AbstractAppState implements GameListener {
|
||||||
|
|
||||||
|
private StateManager stateManager;
|
||||||
|
private Node rootNode;
|
||||||
|
private GameGUI gui;
|
||||||
|
|
||||||
|
public GameState(Node rootNode, Screen screen, StateManager stateManager) {
|
||||||
|
this.rootNode = rootNode;
|
||||||
|
this.gui = new GameGUI(screen, this);
|
||||||
|
this.stateManager = stateManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stateAttached(AppStateManager stateManager) {
|
||||||
|
gui.attach();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stateDetached(AppStateManager stateManager) {
|
||||||
|
gui.detach();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(float tpf) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,83 +18,42 @@ package org.wyrez.shootingstars.states;
|
|||||||
|
|
||||||
import com.jme3.app.state.AbstractAppState;
|
import com.jme3.app.state.AbstractAppState;
|
||||||
import com.jme3.app.state.AppStateManager;
|
import com.jme3.app.state.AppStateManager;
|
||||||
import com.jme3.font.BitmapFont;
|
import org.wyrez.shootingstars.gui.LoadingGui;
|
||||||
import com.jme3.input.event.MouseButtonEvent;
|
import org.wyrez.shootingstars.gui.listener.LoadingListener;
|
||||||
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 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;
|
import tonegod.gui.core.Screen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darth Affe
|
* @author Darth Affe
|
||||||
*/
|
*/
|
||||||
public class LoadingState extends AbstractAppState {
|
public class LoadingState extends AbstractAppState implements LoadingListener {
|
||||||
|
|
||||||
private StateManager stateManager;
|
private StateManager stateManager;
|
||||||
private Screen screen;
|
private LoadingGui gui;
|
||||||
private Panel loadingPanel;
|
|
||||||
private Label lblStatus;
|
|
||||||
private Indicator indProgress;
|
|
||||||
private Button btnStart;
|
|
||||||
private LoadingProgress currentProgress;
|
private LoadingProgress currentProgress;
|
||||||
|
|
||||||
public LoadingState(Screen screen, StateManager stateManager) {
|
public LoadingState(Screen screen, StateManager stateManager) {
|
||||||
this.screen = screen;
|
|
||||||
this.stateManager = stateManager;
|
this.stateManager = stateManager;
|
||||||
createGUI();
|
this.gui = new LoadingGui(screen, this);
|
||||||
}
|
|
||||||
|
|
||||||
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
|
@Override
|
||||||
public void stateAttached(AppStateManager stateManager) {
|
public void stateAttached(AppStateManager stateManager) {
|
||||||
currentProgress = LoadingProgress.START;
|
currentProgress = LoadingProgress.START;
|
||||||
screen.addElement(loadingPanel);
|
gui.attach();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateDetached(AppStateManager stateManager) {
|
public void stateDetached(AppStateManager stateManager) {
|
||||||
screen.removeElement(loadingPanel);
|
gui.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(float tpf) {
|
public void update(float tpf) {
|
||||||
switch (currentProgress) {
|
switch (currentProgress) {
|
||||||
case START:
|
case START:
|
||||||
setLoadingStart();
|
gui.setLoadingStart();
|
||||||
currentProgress = LoadingProgress.ANALYSE_LOW_BAND;
|
currentProgress = LoadingProgress.ANALYSE_LOW_BAND;
|
||||||
break;
|
break;
|
||||||
case ANALYSE_LOW_BAND:
|
case ANALYSE_LOW_BAND:
|
||||||
@ -110,10 +69,10 @@ public class LoadingState extends AbstractAppState {
|
|||||||
currentProgress = LoadingProgress.DONE;
|
currentProgress = LoadingProgress.DONE;
|
||||||
break;
|
break;
|
||||||
case DONE:
|
case DONE:
|
||||||
setLoadingDone();
|
gui.setLoadingDone();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
updateProgress(currentProgress);
|
gui.updateProgress(currentProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void analyseLowBand() {
|
private void analyseLowBand() {
|
||||||
@ -140,24 +99,7 @@ public class LoadingState extends AbstractAppState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLoadingStart() {
|
public void startGame() {
|
||||||
btnStart.hide();
|
|
||||||
indProgress.show();
|
|
||||||
lblStatus.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setLoadingDone() {
|
|
||||||
btnStart.show();
|
|
||||||
indProgress.hide();
|
|
||||||
lblStatus.hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startGame() {
|
|
||||||
stateManager.setState(State.GAME);
|
stateManager.setState(State.GAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProgress(LoadingProgress progress) {
|
|
||||||
lblStatus.setText(progress.getText());
|
|
||||||
indProgress.setCurrentValue(progress.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,69 +18,41 @@ package org.wyrez.shootingstars.states;
|
|||||||
|
|
||||||
import com.jme3.app.state.AbstractAppState;
|
import com.jme3.app.state.AbstractAppState;
|
||||||
import com.jme3.app.state.AppStateManager;
|
import com.jme3.app.state.AppStateManager;
|
||||||
import com.jme3.input.event.MouseButtonEvent;
|
import org.wyrez.shootingstars.gui.Gui;
|
||||||
import com.jme3.math.Vector2f;
|
import org.wyrez.shootingstars.gui.MenuGUI;
|
||||||
import org.wyrez.shootingstars.gui.ButtonBase;
|
import org.wyrez.shootingstars.gui.listener.MenuListener;
|
||||||
import tonegod.gui.controls.buttons.Button;
|
|
||||||
import tonegod.gui.controls.windows.Panel;
|
|
||||||
import tonegod.gui.core.Screen;
|
import tonegod.gui.core.Screen;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Darth Affe
|
* @author Darth Affe
|
||||||
*/
|
*/
|
||||||
public class MenuState extends AbstractAppState {
|
public class MenuState extends AbstractAppState implements MenuListener {
|
||||||
|
|
||||||
private StateManager stateManager;
|
private StateManager stateManager;
|
||||||
private Screen screen;
|
private Gui gui;
|
||||||
private Panel menuPanel;
|
|
||||||
|
|
||||||
public MenuState(Screen screen, StateManager stateManager) {
|
public MenuState(Screen screen, StateManager stateManager) {
|
||||||
this.screen = screen;
|
|
||||||
this.stateManager = stateManager;
|
this.stateManager = stateManager;
|
||||||
createGUI();
|
this.gui = new MenuGUI(screen, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGUI() {
|
public void startGame() {
|
||||||
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);
|
stateManager.setState(State.LOADING);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exitGame() {
|
public void exitGame() {
|
||||||
//TODO ss.stop();
|
//TODO ss.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateAttached(AppStateManager stateManager) {
|
public void stateAttached(AppStateManager stateManager) {
|
||||||
screen.addElement(menuPanel);
|
gui.attach();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stateDetached(AppStateManager stateManager) {
|
public void stateDetached(AppStateManager stateManager) {
|
||||||
screen.removeElement(menuPanel);
|
gui.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user