Added Highscore page, Menu and Registration
This commit is contained in:
parent
148ff8bcb6
commit
b5b62e2b07
47 changed files with 763 additions and 159 deletions
|
|
@ -15,7 +15,7 @@ public class Palette {
|
|||
public static Color registerLblBtn_color = new Color(95,0,0);
|
||||
public static Color registerLblBtn_onmouseover_color = new Color(95,0,0, 127);
|
||||
public static Color registerLblBtn_onmouseclick_color = new Color(53,66,32);
|
||||
|
||||
public static Color scrollPanel_backgroundColor = new Color(220,229,207);
|
||||
|
||||
public static Font button_font = new Font("DK Trained Monkey", Font.BOLD, 30);
|
||||
|
||||
|
|
|
|||
80
Client/src/com/texttwist/client/pages/Highscores.java
Normal file
80
Client/src/com/texttwist/client/pages/Highscores.java
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
package com.texttwist.client.pages;
|
||||
|
||||
import com.texttwist.client.constants.Palette;
|
||||
import com.texttwist.client.ui.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Created by loke on 14/06/2017.
|
||||
*/
|
||||
public class Highscores extends Page{
|
||||
|
||||
public TTContainer highscoreContainer;
|
||||
Highscores(JFrame window) throws IOException {
|
||||
super(window);
|
||||
createUIComponents();
|
||||
window.setVisible(true);
|
||||
}
|
||||
|
||||
private DefaultListModel fetchHighscores(){
|
||||
DefaultListModel<String> highscoreList = new DefaultListModel<String>();
|
||||
highscoreList.addElement("USA");
|
||||
highscoreList.addElement("India");
|
||||
highscoreList.addElement("Vietnam");
|
||||
highscoreList.addElement("Canada");
|
||||
highscoreList.addElement("Denmark");
|
||||
highscoreList.addElement("France");
|
||||
|
||||
highscoreList.addElement("France");
|
||||
highscoreList.addElement("Great Britain");
|
||||
highscoreList.addElement("Japan");
|
||||
|
||||
highscoreList.addElement("France");
|
||||
highscoreList.addElement("Great Britain");
|
||||
highscoreList.addElement("Japan");
|
||||
|
||||
highscoreList.addElement("France");
|
||||
highscoreList.addElement("Great Britain");
|
||||
highscoreList.addElement("Japan");
|
||||
highscoreList.addElement("Great Britain");
|
||||
highscoreList.addElement("Japan");
|
||||
return highscoreList;
|
||||
}
|
||||
@Override
|
||||
public void createUIComponents() throws IOException {
|
||||
addLogo(root);
|
||||
highscoreContainer = new TTContainer(
|
||||
null,
|
||||
new Dimension(1150,220),
|
||||
Palette.root_backgroundColor,
|
||||
-1,
|
||||
root);
|
||||
|
||||
TTLabel title = new TTLabel(
|
||||
new Point(200,0),
|
||||
new Dimension(350,50),
|
||||
"Highscores",
|
||||
new Font(Palette.inputBox_font.getFontName(), Font.ITALIC, 38),
|
||||
null,
|
||||
highscoreContainer);
|
||||
|
||||
TTScrollList highscoreList = new TTScrollList(
|
||||
new Point(0, 60),
|
||||
new Dimension(575, 142),
|
||||
fetchHighscores(),
|
||||
highscoreContainer);
|
||||
addBack(root,
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
return new Menu(Page.window);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,6 @@ public class Home extends Page {
|
|||
@Override
|
||||
public void createUIComponents(){
|
||||
addLogo(root);
|
||||
|
||||
loginDataContainer = new TTContainer(
|
||||
null,
|
||||
new Dimension(1150,250),
|
||||
|
|
@ -33,15 +32,25 @@ public class Home extends Page {
|
|||
new Dimension(210,50),
|
||||
"Username",
|
||||
loginDataContainer);
|
||||
|
||||
TTPasswordField passwordField = new TTPasswordField(
|
||||
new Point(290,60),
|
||||
new Dimension(210,50),
|
||||
loginDataContainer);
|
||||
|
||||
TTButton loginBtn = new TTButton(
|
||||
new Point(70,120),
|
||||
new Dimension(430,50),
|
||||
"Go!",
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
//TODO CHIAMA API PER LOGIN E SE TUTTO OKEY MANDA A PAGINA DEL MENU
|
||||
return new Menu(Page.window);
|
||||
}
|
||||
},
|
||||
loginDataContainer);
|
||||
|
||||
TTLabel registerText = new TTLabel(
|
||||
new Point(70,200),
|
||||
new Dimension(350,50),
|
||||
|
|
@ -49,18 +58,20 @@ public class Home extends Page {
|
|||
new Font(Palette.inputBox_font.getFontName(), Font.ITALIC, 24),
|
||||
null,
|
||||
loginDataContainer);
|
||||
|
||||
TTLabelBtn registerField = new TTLabelBtn(
|
||||
new Point(360, 200),
|
||||
new Dimension(210, 50),
|
||||
"Register!",
|
||||
new Font(Palette.inputBox_font.getFontName(), Font.BOLD, 34),
|
||||
null,
|
||||
new Callable<Page>() {
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Page call() throws Exception {
|
||||
public Object call() throws Exception {
|
||||
return new Register(Page.window);
|
||||
}
|
||||
},
|
||||
loginDataContainer);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
Client/src/com/texttwist/client/pages/MatchRequests.java
Normal file
12
Client/src/com/texttwist/client/pages/MatchRequests.java
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package com.texttwist.client.pages;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Created by loke on 14/06/2017.
|
||||
*/
|
||||
public class MatchRequests extends Page{
|
||||
public MatchRequests(JFrame window){
|
||||
super(window);
|
||||
}
|
||||
}
|
||||
12
Client/src/com/texttwist/client/pages/MatchSetup.java
Normal file
12
Client/src/com/texttwist/client/pages/MatchSetup.java
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package com.texttwist.client.pages;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Created by loke on 14/06/2017.
|
||||
*/
|
||||
public class MatchSetup extends Page {
|
||||
public MatchSetup(JFrame window){
|
||||
super(window);
|
||||
}
|
||||
}
|
||||
96
Client/src/com/texttwist/client/pages/Menu.java
Normal file
96
Client/src/com/texttwist/client/pages/Menu.java
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
package com.texttwist.client.pages;
|
||||
import com.texttwist.client.constants.Palette;
|
||||
import com.texttwist.client.ui.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Created by loke on 14/06/2017.
|
||||
*/
|
||||
public class Menu extends Page{
|
||||
|
||||
private TTContainer menuBar;
|
||||
|
||||
public Menu(JFrame window) throws IOException {
|
||||
super(window);
|
||||
createUIComponents();
|
||||
window.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createUIComponents() throws IOException {
|
||||
addLogo(root);
|
||||
menuBar = new TTContainer(
|
||||
null,
|
||||
new Dimension(1150,220),
|
||||
Palette.root_backgroundColor,
|
||||
-1,
|
||||
root);
|
||||
TTButton newMatch = new TTButton(
|
||||
new Point(25,30),
|
||||
new Dimension(250,75),
|
||||
"New Match!",
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
|
||||
//TODO CHIAMA API PER REGISTRAZIONE E SE TUTTO OKEY MANDA A PAGINA LOGIN
|
||||
return new MatchSetup(window);
|
||||
}
|
||||
},
|
||||
menuBar);
|
||||
TTButton matchRequests = new TTButton(
|
||||
new Point(290,30),
|
||||
new Dimension(250,75),
|
||||
"In pending",
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
//TODO CHIAMA API PER REGISTRAZIONE E SE TUTTO OKEY MANDA A PAGINA LOGIN
|
||||
return new MatchRequests(window);
|
||||
}
|
||||
},
|
||||
menuBar);
|
||||
TTCircleCounter circleCounter = new TTCircleCounter(
|
||||
new Point(290,30),
|
||||
new Dimension(25,25),
|
||||
menuBar.getGraphics(),
|
||||
menuBar);
|
||||
|
||||
TTButton highscores = new TTButton(
|
||||
new Point(25, 115),
|
||||
new Dimension(250, 75),
|
||||
"Highscores",
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
return new Highscores(Page.window);
|
||||
}
|
||||
},
|
||||
menuBar);
|
||||
|
||||
TTButton logout = new TTButton(
|
||||
new Point(290, 115),
|
||||
new Dimension(250, 75),
|
||||
"Logout",
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
return new Home(Page.window);
|
||||
}
|
||||
},
|
||||
menuBar);
|
||||
addBack(root,
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
return new Home(Page.window);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -3,11 +3,14 @@ package com.texttwist.client.pages;
|
|||
import com.texttwist.client.constants.Palette;
|
||||
import com.texttwist.client.ui.TTContainer;
|
||||
import com.texttwist.client.ui.TTImage;
|
||||
import com.texttwist.client.ui.TTImageBtn;
|
||||
import com.texttwist.client.ui.TTLabel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Created by loke on 13/06/2017.
|
||||
|
|
@ -31,10 +34,9 @@ public class Page {
|
|||
BoxLayout.Y_AXIS,
|
||||
null);
|
||||
window.add(root);
|
||||
|
||||
}
|
||||
|
||||
public void createUIComponents(){}
|
||||
public void createUIComponents() throws IOException {}
|
||||
|
||||
public void addLogo(TTContainer parent) {
|
||||
TTContainer container = new TTContainer(
|
||||
|
|
@ -54,4 +56,25 @@ public class Page {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void addBack(TTContainer parent, Callable<Object> clickHandler) {
|
||||
try {
|
||||
TTImageBtn back = new TTImageBtn(
|
||||
new Point(0, 800),
|
||||
new Dimension(0, 0),
|
||||
new ImageIcon(new File("./Client/resources/images/back.png").getCanonicalPath()),
|
||||
clickHandler,
|
||||
parent);
|
||||
TTLabel registerText = new TTLabel(
|
||||
new Point(55,775),
|
||||
new Dimension(350,0),
|
||||
"Back",
|
||||
new Font(Palette.inputBox_font.getFontName(), Font.ITALIC, 24),
|
||||
null,
|
||||
parent);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
package com.texttwist.client.pages;
|
||||
|
||||
import com.texttwist.client.constants.Palette;
|
||||
import com.texttwist.client.ui.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Created by loke on 13/06/2017.
|
||||
*/
|
||||
public class Register extends Page {
|
||||
|
||||
private TTContainer registerDataContainer;
|
||||
public Register(JFrame window) {
|
||||
super(window);
|
||||
createUIComponents();
|
||||
|
|
@ -16,6 +22,48 @@ public class Register extends Page {
|
|||
@Override
|
||||
public void createUIComponents() {
|
||||
addLogo(root);
|
||||
registerDataContainer = new TTContainer(
|
||||
null,
|
||||
new Dimension(1150,220),
|
||||
Palette.root_backgroundColor,
|
||||
-1,
|
||||
root);
|
||||
TTLabel registerText = new TTLabel(
|
||||
new Point(70,35),
|
||||
new Dimension(400,40),
|
||||
"<html><h2>Insert your datas and press Register!</h2></html>",
|
||||
new Font(Palette.inputBox_font.getFontName(), Font.ITALIC, 12),
|
||||
null,
|
||||
registerDataContainer);
|
||||
TTInputField usernameField = new TTInputField(
|
||||
new Point(70,90),
|
||||
new Dimension(210,50),
|
||||
"Username",
|
||||
registerDataContainer);
|
||||
TTPasswordField passwordField = new TTPasswordField(
|
||||
new Point(290,90),
|
||||
new Dimension(210,50),
|
||||
registerDataContainer);
|
||||
TTButton register = new TTButton(
|
||||
new Point(70,150),
|
||||
new Dimension(430,50),
|
||||
"Register!",
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
|
||||
//TODO CHIAMA API PER REGISTRAZIONE E SE TUTTO OKEY MANDA A PAGINA LOGIN
|
||||
return new Home(window);
|
||||
}
|
||||
},
|
||||
registerDataContainer);
|
||||
addBack(root,
|
||||
new Callable<Object>() {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
return new Home(Page.window);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,20 @@
|
|||
package com.texttwist.client.ui;
|
||||
|
||||
import com.texttwist.client.constants.Palette;
|
||||
import com.texttwist.client.pages.Page;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Created by loke on 13/06/2017.
|
||||
*/
|
||||
public class TTButton extends JButton{
|
||||
|
||||
public TTButton(Point position, Dimension dimension, String caption, JPanel parent) {
|
||||
public TTButton(Point position, Dimension dimension, String caption, Callable<Object> clickHandler, JPanel parent) {
|
||||
super();
|
||||
|
||||
setBackground(Palette.button_backgroundColor);
|
||||
|
|
@ -22,7 +24,25 @@ public class TTButton extends JButton{
|
|||
setPreferredSize(dimension);
|
||||
setText(caption);
|
||||
|
||||
parent.add(this);
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
super.mouseClicked(e);
|
||||
setForeground(Palette.registerLblBtn_onmouseclick_color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
super.mouseClicked(e);
|
||||
setForeground(Palette.registerLblBtn_color);
|
||||
try {
|
||||
clickHandler.call();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
parent.add(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
35
Client/src/com/texttwist/client/ui/TTCircleCounter.java
Normal file
35
Client/src/com/texttwist/client/ui/TTCircleCounter.java
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package com.texttwist.client.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by loke on 14/06/2017.
|
||||
*/
|
||||
public class TTCircleCounter extends JComponent{
|
||||
|
||||
private Point position;
|
||||
private Dimension dimension;
|
||||
|
||||
public TTCircleCounter(Point position, Dimension dimension, Graphics g, TTContainer parent){
|
||||
this.position=position;
|
||||
this.dimension=dimension;
|
||||
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
Ellipse2D.Double circle = new Ellipse2D.Double(position.x, position.y, dimension.width, dimension.height);
|
||||
g2d.fill(circle);
|
||||
g2d.setColor(Color.RED);
|
||||
|
||||
parent.add(this);
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
Ellipse2D.Double circle = new Ellipse2D.Double(position.x, position.y, dimension.width, dimension.height);
|
||||
g2d.setColor(Color.RED);
|
||||
g2d.fill(circle);
|
||||
}
|
||||
}
|
||||
|
|
@ -14,11 +14,8 @@ import java.io.IOException;
|
|||
*/
|
||||
public class TTImage extends JLabel{
|
||||
|
||||
public TTImage(Point position, Dimension dimension, ImageIcon image , JPanel parent) throws IOException {
|
||||
public TTImage(Point position, Dimension dimension, ImageIcon image, JPanel parent) throws IOException {
|
||||
super();
|
||||
|
||||
//setBackground(Palette.inputBox_backgroundColor);
|
||||
//setFont(Palette.inputBox_font);
|
||||
setBounds(position.x,position.y,dimension.width, dimension.height);
|
||||
setPreferredSize(dimension);
|
||||
setIcon(image);
|
||||
|
|
|
|||
32
Client/src/com/texttwist/client/ui/TTImageBtn.java
Normal file
32
Client/src/com/texttwist/client/ui/TTImageBtn.java
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package com.texttwist.client.ui;
|
||||
|
||||
import com.texttwist.client.constants.Palette;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* Created by loke on 14/06/2017.
|
||||
*/
|
||||
public class TTImageBtn extends TTImage {
|
||||
public TTImageBtn(Point position, Dimension dimension, ImageIcon image, Callable<Object> clickHandler, JPanel parent) throws IOException {
|
||||
super(position,dimension,image,parent);
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
super.mouseClicked(e);
|
||||
setForeground(Palette.registerLblBtn_color);
|
||||
try {
|
||||
clickHandler.call();
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ import java.util.concurrent.Callable;
|
|||
*/
|
||||
public class TTLabelBtn extends TTLabel{
|
||||
|
||||
public TTLabelBtn(Point position, Dimension dimension, String caption, Font font, Color fontColor, Callable<Page> clickHandler, JPanel parent) {
|
||||
public TTLabelBtn(Point position, Dimension dimension, String caption, Font font, Color fontColor, Callable<Object> clickHandler, JPanel parent) {
|
||||
super(position, dimension, caption, font, fontColor, parent);
|
||||
|
||||
setForeground(Palette.registerLblBtn_color);
|
||||
|
|
|
|||
31
Client/src/com/texttwist/client/ui/TTScrollList.java
Normal file
31
Client/src/com/texttwist/client/ui/TTScrollList.java
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package com.texttwist.client.ui;
|
||||
|
||||
import com.texttwist.client.constants.Palette;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Created by loke on 14/06/2017.
|
||||
*/
|
||||
public class TTScrollList extends JList {
|
||||
|
||||
public TTScrollList(Point position, Dimension dimension, ListModel listModel, JPanel parent){
|
||||
super(listModel);
|
||||
setBackground(Palette.scrollPanel_backgroundColor);
|
||||
setFont(Palette.inputBox_font);
|
||||
setBounds(position.x, position.y, dimension.width, dimension.height);
|
||||
// setPreferredSize(dimension);
|
||||
setForeground(Palette.fontColor);
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane();
|
||||
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
||||
scrollPane.setBounds(position.x, position.y, dimension.width, dimension.height);
|
||||
// scrollPane.setMinimumSize(dimension);
|
||||
scrollPane.setBackground(Palette.scrollPanel_backgroundColor);
|
||||
scrollPane.setViewportView(this);
|
||||
|
||||
parent.add(scrollPane);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue