Refactor GUI
This commit is contained in:
parent
646a7dae58
commit
74ea671412
Binary file not shown.
@ -20,7 +20,6 @@ import com.jme3.font.BitmapFont;
|
|||||||
import com.jme3.input.event.MouseButtonEvent;
|
import com.jme3.input.event.MouseButtonEvent;
|
||||||
import com.jme3.math.Vector2f;
|
import com.jme3.math.Vector2f;
|
||||||
import org.wyrez.shootingstars.gui.controls.ButtonBase;
|
import org.wyrez.shootingstars.gui.controls.ButtonBase;
|
||||||
import org.wyrez.shootingstars.gui.controls.PanelBase;
|
|
||||||
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.windows.Panel;
|
import tonegod.gui.controls.windows.Panel;
|
||||||
@ -33,7 +32,7 @@ import tonegod.gui.core.Screen;
|
|||||||
public class GameGUI extends Panel {
|
public class GameGUI extends Panel {
|
||||||
|
|
||||||
private GameListener listener;
|
private GameListener listener;
|
||||||
private Panel pnlStart;
|
private Button btnStart;
|
||||||
|
|
||||||
public GameGUI(Screen screen, GameListener listener) {
|
public GameGUI(Screen screen, GameListener listener) {
|
||||||
super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd
|
super(screen, new Vector2f(0f, 0f), new Vector2f(1280f, 720f)); //create for full hd
|
||||||
@ -41,34 +40,32 @@ public class GameGUI extends Panel {
|
|||||||
this.setIgnoreMouse(true);
|
this.setIgnoreMouse(true);
|
||||||
this.setIsVisible(false);
|
this.setIsVisible(false);
|
||||||
create();
|
create();
|
||||||
this.resize(screen.getWidth(), screen.getHeight(), Borders.SE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void create() {
|
private void create() {
|
||||||
pnlStart = new PanelBase(screen, new Vector2f(15, 15), new Vector2f(800, 500));
|
|
||||||
pnlStart.setIgnoreMouse(true);
|
|
||||||
|
|
||||||
Button btnStart = new ButtonBase(screen, new Vector2f(360f, 360f),
|
float startPointx = screen.getWidth() * 0.42f;
|
||||||
|
float startPointy = screen.getHeight() * 0.80f;
|
||||||
|
|
||||||
|
btnStart = new ButtonBase(screen, new Vector2f(startPointx, startPointy),
|
||||||
new Vector2f(200f, 30f)) {
|
new Vector2f(200f, 30f)) {
|
||||||
@Override
|
@Override
|
||||||
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||||
listener.start();
|
listener.start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
btnStart.setText("Start Game");
|
btnStart.setText("Launch");
|
||||||
btnStart.setTextAlign(BitmapFont.Align.Center);
|
btnStart.setTextAlign(BitmapFont.Align.Center);
|
||||||
|
|
||||||
pnlStart.addChild(btnStart);
|
this.addChild(btnStart);
|
||||||
|
|
||||||
this.addChild(pnlStart);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStart() {
|
public void setStart() {
|
||||||
pnlStart.hide();
|
btnStart.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWait() {
|
public void setWait() {
|
||||||
pnlStart.show();
|
btnStart.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attach() {
|
public void attach() {
|
||||||
|
|||||||
@ -20,7 +20,6 @@ import com.jme3.font.BitmapFont;
|
|||||||
import com.jme3.math.ColorRGBA;
|
import com.jme3.math.ColorRGBA;
|
||||||
import com.jme3.math.Vector2f;
|
import com.jme3.math.Vector2f;
|
||||||
import org.wyrez.shootingstars.gui.controls.IndicatorBase;
|
import org.wyrez.shootingstars.gui.controls.IndicatorBase;
|
||||||
import org.wyrez.shootingstars.gui.controls.PanelBase;
|
|
||||||
import org.wyrez.shootingstars.states.util.LoadingProgress;
|
import org.wyrez.shootingstars.states.util.LoadingProgress;
|
||||||
import tonegod.gui.controls.extras.Indicator;
|
import tonegod.gui.controls.extras.Indicator;
|
||||||
import tonegod.gui.controls.text.Label;
|
import tonegod.gui.controls.text.Label;
|
||||||
@ -41,26 +40,24 @@ public class LoadingGui extends Panel {
|
|||||||
this.setIgnoreMouse(true);
|
this.setIgnoreMouse(true);
|
||||||
this.setIsVisible(false);
|
this.setIsVisible(false);
|
||||||
create();
|
create();
|
||||||
this.resize(screen.getWidth(), screen.getHeight(), Borders.SE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void create() {
|
private void create() {
|
||||||
Panel panel = new PanelBase(screen, new Vector2f(15, 15), new Vector2f(800, 500));
|
|
||||||
panel.setIgnoreMouse(true);
|
float startPointx = screen.getWidth() * 0.42f;
|
||||||
|
float startPointy = screen.getHeight() * 0.80f;
|
||||||
|
|
||||||
indProgress = new IndicatorBase(screen, new Vector2f(360f, 360f),
|
indProgress = new IndicatorBase(screen, new Vector2f(startPointx, startPointy),
|
||||||
new Vector2f(200f, 30f), Indicator.Orientation.HORIZONTAL);
|
new Vector2f(200f, 30f), Indicator.Orientation.HORIZONTAL);
|
||||||
indProgress.setDisplayValues();
|
indProgress.setDisplayValues();
|
||||||
indProgress.setMaxValue(LoadingProgress.getProgressCount());
|
indProgress.setMaxValue(LoadingProgress.getProgressCount());
|
||||||
indProgress.setIndicatorColor(ColorRGBA.Black);
|
indProgress.setIndicatorColor(ColorRGBA.Black);
|
||||||
|
|
||||||
lblStatus = new Label(screen, new Vector2f(360f, 400f), new Vector2f(200f, 30f));
|
lblStatus = new Label(screen, new Vector2f(startPointx, startPointy + (screen.getHeight() * 0.05f)), new Vector2f(200f, 30f));
|
||||||
lblStatus.setTextAlign(BitmapFont.Align.Center);
|
lblStatus.setTextAlign(BitmapFont.Align.Center);
|
||||||
|
|
||||||
panel.addChild(indProgress);
|
this.addChild(indProgress);
|
||||||
panel.addChild(lblStatus);
|
this.addChild(lblStatus);
|
||||||
|
|
||||||
this.addChild(panel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attach() {
|
public void attach() {
|
||||||
|
|||||||
@ -19,9 +19,9 @@ package org.wyrez.shootingstars.gui;
|
|||||||
import com.jme3.input.event.MouseButtonEvent;
|
import com.jme3.input.event.MouseButtonEvent;
|
||||||
import com.jme3.math.Vector2f;
|
import com.jme3.math.Vector2f;
|
||||||
import org.wyrez.shootingstars.gui.controls.ButtonBase;
|
import org.wyrez.shootingstars.gui.controls.ButtonBase;
|
||||||
import org.wyrez.shootingstars.gui.controls.PanelBase;
|
|
||||||
import org.wyrez.shootingstars.gui.listener.MenuListener;
|
import org.wyrez.shootingstars.gui.listener.MenuListener;
|
||||||
import tonegod.gui.controls.buttons.Button;
|
import tonegod.gui.controls.buttons.Button;
|
||||||
|
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;
|
||||||
|
|
||||||
@ -39,33 +39,43 @@ public class MenuGUI extends Panel implements Gui {
|
|||||||
this.setIgnoreMouse(true);
|
this.setIgnoreMouse(true);
|
||||||
this.setIsVisible(false);
|
this.setIsVisible(false);
|
||||||
create();
|
create();
|
||||||
this.resize(screen.getWidth(), screen.getHeight(), Borders.SE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void create() {
|
private void create() {
|
||||||
Panel panel = new PanelBase(screen, new Vector2f(15, 15), new Vector2f(800, 500));
|
|
||||||
panel.setIgnoreMouse(true);
|
float startPointx = screen.getWidth() * 0.2f;
|
||||||
|
float startPointy = screen.getHeight() * 0.35f;
|
||||||
|
float labelFontSize = screen.getWidth() * 0.07f;
|
||||||
|
float buttonLabelDistancex = screen.getWidth() * 0.5f;
|
||||||
|
|
||||||
|
Label lblWyrez = new Label(screen, new Vector2f(startPointx, startPointy), new Vector2f(300, 40));
|
||||||
|
lblWyrez.setFontSize(labelFontSize);
|
||||||
|
lblWyrez.setText("Wyrez");
|
||||||
|
|
||||||
|
Label lblShootingStars = new Label(screen, new Vector2f(startPointx, startPointy + (screen.getHeight() * 0.1f)), new Vector2f(500, 40));
|
||||||
|
lblShootingStars.setFontSize(labelFontSize);
|
||||||
|
lblShootingStars.setText("Shooting Stars");
|
||||||
|
|
||||||
Button btnExit = new ButtonBase(screen, new Vector2f(600, 400), new Vector2f(120, 40)) {
|
Button btnStart = new ButtonBase(screen, new Vector2f(startPointx + buttonLabelDistancex, startPointy + (screen.getHeight() * 0.03f)), new Vector2f(160, 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
|
@Override
|
||||||
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||||
listener.startGame();
|
listener.startGame();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
btnStart.setText("Start");
|
btnStart.setText("Start Game");
|
||||||
|
|
||||||
|
Button btnExit = new ButtonBase(screen, new Vector2f(startPointx + buttonLabelDistancex, startPointy + (screen.getHeight() * 0.125f)), new Vector2f(160, 40)) {
|
||||||
|
@Override
|
||||||
|
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean toggled) {
|
||||||
|
listener.exitGame();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
btnExit.setText("Exit Game");
|
||||||
|
|
||||||
panel.addChild(btnStart);
|
this.addChild(btnStart);
|
||||||
panel.addChild(btnExit);
|
this.addChild(btnExit);
|
||||||
|
this.addChild(lblWyrez);
|
||||||
this.addChild(panel);
|
this.addChild(lblShootingStars);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attach() {
|
public void attach() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user