-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenuPrincipal.java
More file actions
165 lines (143 loc) · 8.06 KB
/
Copy pathMenuPrincipal.java
File metadata and controls
165 lines (143 loc) · 8.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
package sequence;
import java.io.IOException;
import java.util.ArrayList;
import javax.swing.JOptionPane;
public class MenuPrincipal extends javax.swing.JFrame {
AdminUsuarios useradmin = new AdminUsuarios();
ConfiguracionPartida config = new ConfiguracionPartida();
public MenuPrincipal() throws IOException {
initComponents();
setLocationRelativeTo(null);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
ConfiguracionBtn = new javax.swing.JButton();
Desconectarse = new javax.swing.JButton();
Titulo = new javax.swing.JLabel();
NuevaPartidaBtn = new javax.swing.JButton();
ReportesBtn = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
setResizable(false);
getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
ConfiguracionBtn.setFont(new java.awt.Font("Arial", 0, 36)); // NOI18N
ConfiguracionBtn.setText("Configuración");
ConfiguracionBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ConfiguracionBtnActionPerformed(evt);
}
});
jPanel1.add(ConfiguracionBtn, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 280, -1, -1));
Desconectarse.setFont(new java.awt.Font("Arial", 0, 36)); // NOI18N
Desconectarse.setText("Desconectarse");
Desconectarse.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
DesconectarseActionPerformed(evt);
}
});
jPanel1.add(Desconectarse, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 520, -1, -1));
Titulo.setFont(new java.awt.Font("Arial", 0, 48)); // NOI18N
Titulo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
Titulo.setText("Sequence");
jPanel1.add(Titulo, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 40, -1, -1));
NuevaPartidaBtn.setFont(new java.awt.Font("Arial", 0, 36)); // NOI18N
NuevaPartidaBtn.setText("Iniciar Nueva Partida");
NuevaPartidaBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
NuevaPartidaBtnActionPerformed(evt);
}
});
jPanel1.add(NuevaPartidaBtn, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 170, -1, -1));
ReportesBtn.setFont(new java.awt.Font("Arial", 0, 36)); // NOI18N
ReportesBtn.setText("Reportes");
ReportesBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ReportesBtnActionPerformed(evt);
}
});
jPanel1.add(ReportesBtn, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 400, -1, -1));
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/IMAGENES/fondo.png"))); // NOI18N
jPanel1.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 970, 630));
getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, 632));
pack();
}// </editor-fold>//GEN-END:initComponents
private void DesconectarseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DesconectarseActionPerformed
AdminPantallas.AbrirMenuInicio();
this.dispose();
}//GEN-LAST:event_DesconectarseActionPerformed
private void ConfiguracionBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConfiguracionBtnActionPerformed
AdminPantallas.AbrirConfiguracion();
this.dispose();
}//GEN-LAST:event_ConfiguracionBtnActionPerformed
private void NuevaPartidaBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NuevaPartidaBtnActionPerformed
try{
if(useradmin.getTodosUsuarios().size()>=ConfiguracionPartida.getCantjugadores()){
if(ConfiguracionPartida.getCantjugadores()<4){
ArrayList<String> equipo2 = new ArrayList();
ArrayList<String> equipo3 = new ArrayList();
for(int i=0; i<ConfiguracionPartida.getCantjugadores()-1;i++){
String player = JOptionPane.showInputDialog(null, "Ingrese el nombre de usuario de su contrincante", "Contrincante", JOptionPane.INFORMATION_MESSAGE);
if(player!=null){
if(!player.equals("")){
try{
if(useradmin.BuscarUser(player)!=-1 && !player.equals(useradmin.getUserlog())){
if(ConfiguracionPartida.getCantjugadores()==2 || (ConfiguracionPartida.getCantjugadores()==3 && equipo2.isEmpty()))
equipo2.add(player);
else
equipo3.add(player);
} else{
JOptionPane.showMessageDialog(null, "Por favor ingrese un usuario valido", "Error", JOptionPane.ERROR_MESSAGE);
equipo2.clear();
break;
}
}catch(IOException e){
JOptionPane.showMessageDialog(null, "Parece que algo salió mal", "Error", JOptionPane.ERROR_MESSAGE);
}
} else{
JOptionPane.showMessageDialog(null, "Por favor ingrese un usuario valido", "Error", JOptionPane.ERROR_MESSAGE);
equipo2.clear();
}
}
}
if((ConfiguracionPartida.getCantjugadores()==2 && !equipo2.isEmpty()) || (ConfiguracionPartida.getCantjugadores()==3 && !equipo2.isEmpty() && !equipo3.isEmpty())){
if((ConfiguracionPartida.getCantjugadores()==2) || (ConfiguracionPartida.getCantjugadores()==3 && (!equipo2.get(0).equals(equipo3.get(0))))){
ConfiguracionPartida.setEquipo2(equipo2);
ConfiguracionPartida.setEquipo3(equipo3);
ArrayList<String> equipo1 = new ArrayList();
equipo1.add(useradmin.getUserlog());
ConfiguracionPartida.setEquipo1(equipo1);
config.setColoresEquipos(equipo1, equipo2, equipo3);
AdminPantallas.AbrirSequence();
this.dispose();
} else{
JOptionPane.showMessageDialog(null, "Verifique que los usuarios no se repitan", "Error", JOptionPane.ERROR_MESSAGE);
}
}
} else{
AdminPantallas.AbrirMenuEquipos();
this.dispose();
}
}else{
JOptionPane.showMessageDialog(null, "No existen suficientes usuarios para jugar", "Error", JOptionPane.ERROR_MESSAGE);
}
}catch(IOException e){
JOptionPane.showMessageDialog(null, "Parece que algo salió mal", "Error", JOptionPane.ERROR_MESSAGE);
}
}//GEN-LAST:event_NuevaPartidaBtnActionPerformed
private void ReportesBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReportesBtnActionPerformed
AdminPantallas.AbrirReportes();
this.dispose();
}//GEN-LAST:event_ReportesBtnActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton ConfiguracionBtn;
private javax.swing.JButton Desconectarse;
private javax.swing.JButton NuevaPartidaBtn;
private javax.swing.JButton ReportesBtn;
private javax.swing.JLabel Titulo;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
// End of variables declaration//GEN-END:variables
}