annotate kopieckreta/src/KopiecKreta.java @ 24:c7e131ce2f14

makefile rm
author Przemyslaw <prymula76@outlook.com>
date Mon, 01 Apr 2024 07:16:40 +0200
parents 489244127359
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
prymula <prymula76@outlook.com>
parents:
diff changeset
1
prymula <prymula76@outlook.com>
parents:
diff changeset
2 /*
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
3 Kopiec Kreta - gra w odgadywanie slow
0
prymula <prymula76@outlook.com>
parents:
diff changeset
4 ver. 0.4.0-beta
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
5 autor: Przemyslaw R. Pietraszczyk
0
prymula <prymula76@outlook.com>
parents:
diff changeset
6 data: 2020-09-30
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
7 licencja: GPL v3
0
prymula <prymula76@outlook.com>
parents:
diff changeset
8
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
9 slownik pochodzi z: sjp.pl
0
prymula <prymula76@outlook.com>
parents:
diff changeset
10
prymula <prymula76@outlook.com>
parents:
diff changeset
11 */
prymula <prymula76@outlook.com>
parents:
diff changeset
12
prymula <prymula76@outlook.com>
parents:
diff changeset
13 package src;
prymula <prymula76@outlook.com>
parents:
diff changeset
14
prymula <prymula76@outlook.com>
parents:
diff changeset
15 import java.awt.*; // Toolkit
prymula <prymula76@outlook.com>
parents:
diff changeset
16 import javax.swing.JFrame;
prymula <prymula76@outlook.com>
parents:
diff changeset
17 import javax.swing.JLabel;
prymula <prymula76@outlook.com>
parents:
diff changeset
18 import javax.swing.JPanel;
prymula <prymula76@outlook.com>
parents:
diff changeset
19 import javax.swing.JButton;
prymula <prymula76@outlook.com>
parents:
diff changeset
20 //import javax.swing.JComponent;
prymula <prymula76@outlook.com>
parents:
diff changeset
21 import javax.swing.JMenuBar;
prymula <prymula76@outlook.com>
parents:
diff changeset
22 import javax.swing.JMenu;
prymula <prymula76@outlook.com>
parents:
diff changeset
23 import javax.swing.JMenuItem;
prymula <prymula76@outlook.com>
parents:
diff changeset
24 import javax.swing.JOptionPane;
prymula <prymula76@outlook.com>
parents:
diff changeset
25 import javax.swing.Box;
prymula <prymula76@outlook.com>
parents:
diff changeset
26 import javax.swing.JTextArea;
prymula <prymula76@outlook.com>
parents:
diff changeset
27 import javax.swing.JDialog;
prymula <prymula76@outlook.com>
parents:
diff changeset
28 import javax.swing.JTextField;
prymula <prymula76@outlook.com>
parents:
diff changeset
29 import javax.swing.JCheckBox;
prymula <prymula76@outlook.com>
parents:
diff changeset
30 import javax.swing.BorderFactory;
prymula <prymula76@outlook.com>
parents:
diff changeset
31 import javax.swing.WindowConstants;
prymula <prymula76@outlook.com>
parents:
diff changeset
32 import java.awt.event.*;
prymula <prymula76@outlook.com>
parents:
diff changeset
33 import java.awt.event.ActionListener;
prymula <prymula76@outlook.com>
parents:
diff changeset
34 //import java.awt.event.KeyListener;
prymula <prymula76@outlook.com>
parents:
diff changeset
35 import java.awt.event.ActionEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
36 import java.awt.event.WindowEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
37 import java.awt.event.WindowAdapter;
prymula <prymula76@outlook.com>
parents:
diff changeset
38 import java.awt.event.ComponentAdapter;
prymula <prymula76@outlook.com>
parents:
diff changeset
39 import java.awt.event.ComponentEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
40 import java.awt.event.ItemEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
41 //import java.awt.event.KeyEvent;
prymula <prymula76@outlook.com>
parents:
diff changeset
42 import java.util.*; //Timer
prymula <prymula76@outlook.com>
parents:
diff changeset
43 //import java.awt.Robot;
prymula <prymula76@outlook.com>
parents:
diff changeset
44 import java.awt.Toolkit;
prymula <prymula76@outlook.com>
parents:
diff changeset
45
prymula <prymula76@outlook.com>
parents:
diff changeset
46 import java.beans.*; //property change stuff
prymula <prymula76@outlook.com>
parents:
diff changeset
47 import java.io.BufferedReader;
prymula <prymula76@outlook.com>
parents:
diff changeset
48 import java.io.InputStream;
prymula <prymula76@outlook.com>
parents:
diff changeset
49 import java.io.OutputStream;
prymula <prymula76@outlook.com>
parents:
diff changeset
50 import java.io.InputStreamReader;
prymula <prymula76@outlook.com>
parents:
diff changeset
51 import java.io.IOException;
prymula <prymula76@outlook.com>
parents:
diff changeset
52
prymula <prymula76@outlook.com>
parents:
diff changeset
53 public class KopiecKreta extends JTextArea implements ActionListener {
prymula <prymula76@outlook.com>
parents:
diff changeset
54
prymula <prymula76@outlook.com>
parents:
diff changeset
55 static JMenuBar menuBar;
prymula <prymula76@outlook.com>
parents:
diff changeset
56 static JMenu menu, info, menu2;
prymula <prymula76@outlook.com>
parents:
diff changeset
57 static JMenuItem menuItem, menuExit, menuInfo, menuPref;
prymula <prymula76@outlook.com>
parents:
diff changeset
58 static JFrame frame;
prymula <prymula76@outlook.com>
parents:
diff changeset
59 static boolean go=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
60 static Timer timer = new Timer();
prymula <prymula76@outlook.com>
parents:
diff changeset
61 static String content;
prymula <prymula76@outlook.com>
parents:
diff changeset
62 final static int NRINGS=11;
prymula <prymula76@outlook.com>
parents:
diff changeset
63 final static int NCHAR=23; //32;
prymula <prymula76@outlook.com>
parents:
diff changeset
64 static MyResource res = new MyResource();
prymula <prymula76@outlook.com>
parents:
diff changeset
65 static wavResource wav;
prymula <prymula76@outlook.com>
parents:
diff changeset
66 static Ring []truering = new Ring[NRINGS];
prymula <prymula76@outlook.com>
parents:
diff changeset
67 static Ring []falsering = new Ring[NRINGS];
prymula <prymula76@outlook.com>
parents:
diff changeset
68 static String [] mound = new String[20]; // tekst do wyswietlenia przez paint
prymula <prymula76@outlook.com>
parents:
diff changeset
69 static JTextArea textArea;
prymula <prymula76@outlook.com>
parents:
diff changeset
70 static JPanel startScreen;
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
71 static int activeRing; // indeks ringu na ktorym jest prowadzona aktualnie gra
0
prymula <prymula76@outlook.com>
parents:
diff changeset
72 static KopiecKreta kk;
prymula <prymula76@outlook.com>
parents:
diff changeset
73 static Actions actions;
prymula <prymula76@outlook.com>
parents:
diff changeset
74 final static String CONSTCH="1234";
prymula <prymula76@outlook.com>
parents:
diff changeset
75 final static Character[] charsInStock= {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'w', 'y', 'z'};
prymula <prymula76@outlook.com>
parents:
diff changeset
76 static ArrayList<String> cheatSheet;
prymula <prymula76@outlook.com>
parents:
diff changeset
77 static int pointsForTheRing;
prymula <prymula76@outlook.com>
parents:
diff changeset
78 static int pointsFOrTheMund;
prymula <prymula76@outlook.com>
parents:
diff changeset
79 static int totalScore, level;
prymula <prymula76@outlook.com>
parents:
diff changeset
80 static boolean cheatActivate=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
81 static SoundDialog sounddialog;
prymula <prymula76@outlook.com>
parents:
diff changeset
82 //static ResetDialog resetdialog;
prymula <prymula76@outlook.com>
parents:
diff changeset
83 //static GetNameDialog getNameDialog;
prymula <prymula76@outlook.com>
parents:
diff changeset
84 //Boolean runSoundDialog=Boolean.valueOf(false);
prymula <prymula76@outlook.com>
parents:
diff changeset
85 static ConfigFile configfile;
prymula <prymula76@outlook.com>
parents:
diff changeset
86 //static char pressKey=' ';
prymula <prymula76@outlook.com>
parents:
diff changeset
87
prymula <prymula76@outlook.com>
parents:
diff changeset
88 public KopiecKreta() {
prymula <prymula76@outlook.com>
parents:
diff changeset
89 //GridBagLayout gridbag = (GridBagLayout)getLayout();
prymula <prymula76@outlook.com>
parents:
diff changeset
90 //GridBagConstraints c = new GridBagConstraints();
prymula <prymula76@outlook.com>
parents:
diff changeset
91
prymula <prymula76@outlook.com>
parents:
diff changeset
92 menuBar = new JMenuBar();
prymula <prymula76@outlook.com>
parents:
diff changeset
93 menu = new JMenu("Plik");
prymula <prymula76@outlook.com>
parents:
diff changeset
94 menuBar.add(menu);
prymula <prymula76@outlook.com>
parents:
diff changeset
95 menu2 = new JMenu("Opcje");
prymula <prymula76@outlook.com>
parents:
diff changeset
96 menuBar.add(menu2);
prymula <prymula76@outlook.com>
parents:
diff changeset
97 // przenosi INFO na prawa strone
prymula <prymula76@outlook.com>
parents:
diff changeset
98 menuBar.add(Box.createHorizontalGlue());
prymula <prymula76@outlook.com>
parents:
diff changeset
99 info = new JMenu("Info");
prymula <prymula76@outlook.com>
parents:
diff changeset
100 // kierunek wyswietlania menu
prymula <prymula76@outlook.com>
parents:
diff changeset
101 info.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
prymula <prymula76@outlook.com>
parents:
diff changeset
102 menuBar.add(info);
prymula <prymula76@outlook.com>
parents:
diff changeset
103 menuItem = new JMenuItem("Nowa Gra", null);
prymula <prymula76@outlook.com>
parents:
diff changeset
104 menuItem.setActionCommand("MenuItem1");
prymula <prymula76@outlook.com>
parents:
diff changeset
105 menuItem.addActionListener(this);
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
106 menuItem.setToolTipText("Rozpoczyna nowa gre.");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
107 menu.add(menuItem);
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
108 //menuItem = new JMenuItem("Sala slawy", null);
0
prymula <prymula76@outlook.com>
parents:
diff changeset
109 //menuItem.setActionCommand("MenuItem11");
prymula <prymula76@outlook.com>
parents:
diff changeset
110 //menuItem.addActionListener(this);
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
111 //menuItem.setToolTipText("Wyswietla najlepsze wyniki");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
112 //menu.add(menuItem);
prymula <prymula76@outlook.com>
parents:
diff changeset
113 menu.addSeparator();
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
114 menuExit = new JMenuItem("Zakoncz", null);
0
prymula <prymula76@outlook.com>
parents:
diff changeset
115 menuExit.setActionCommand("MenuItem2");
prymula <prymula76@outlook.com>
parents:
diff changeset
116 menuExit.addActionListener(this);
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
117 menuExit.setToolTipText("Wyjscie z programu");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
118 menu.add(menuExit);
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
119 menuPref = new JMenuItem("Preferencje dzwieku",null);
0
prymula <prymula76@outlook.com>
parents:
diff changeset
120 menuPref.setActionCommand("MenuItem4");
prymula <prymula76@outlook.com>
parents:
diff changeset
121 menuPref.addActionListener(this);
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
122 menuPref.setToolTipText("Preferencje dotyczace dzwieku");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
123 menu2.add(menuPref);
prymula <prymula76@outlook.com>
parents:
diff changeset
124 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
125 menuPref = new JMenuItem("Resetowanie",null);
prymula <prymula76@outlook.com>
parents:
diff changeset
126 menuPref.setActionCommand("MenuItem5");
prymula <prymula76@outlook.com>
parents:
diff changeset
127 menuPref.addActionListener(this);
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
128 menuPref.setToolTipText("Resetowanie najlepszych wynikow");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
129 menu2.add(menuPref);
prymula <prymula76@outlook.com>
parents:
diff changeset
130 */
prymula <prymula76@outlook.com>
parents:
diff changeset
131 menuInfo = new JMenuItem("Pomoc", null);
prymula <prymula76@outlook.com>
parents:
diff changeset
132 menuInfo.setActionCommand("MenuItem33");
prymula <prymula76@outlook.com>
parents:
diff changeset
133 menuInfo.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
134 menuInfo.setToolTipText("Samouczek");
prymula <prymula76@outlook.com>
parents:
diff changeset
135 info.add(menuInfo);
prymula <prymula76@outlook.com>
parents:
diff changeset
136 menuInfo = new JMenuItem("O Programie", null);
prymula <prymula76@outlook.com>
parents:
diff changeset
137 menuInfo.setActionCommand("MenuItem3");
prymula <prymula76@outlook.com>
parents:
diff changeset
138 menuInfo.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
139 menuInfo.setToolTipText("Informacje o programie");
prymula <prymula76@outlook.com>
parents:
diff changeset
140 info.add(menuInfo);
prymula <prymula76@outlook.com>
parents:
diff changeset
141
prymula <prymula76@outlook.com>
parents:
diff changeset
142 //addKeyListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
143 //actions = new Actions();
prymula <prymula76@outlook.com>
parents:
diff changeset
144 //addKeyListener(actions);
prymula <prymula76@outlook.com>
parents:
diff changeset
145 //setFocusable(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
146
prymula <prymula76@outlook.com>
parents:
diff changeset
147
prymula <prymula76@outlook.com>
parents:
diff changeset
148 }
prymula <prymula76@outlook.com>
parents:
diff changeset
149
prymula <prymula76@outlook.com>
parents:
diff changeset
150
prymula <prymula76@outlook.com>
parents:
diff changeset
151 public void actionPerformed(final ActionEvent e) {
prymula <prymula76@outlook.com>
parents:
diff changeset
152
prymula <prymula76@outlook.com>
parents:
diff changeset
153 // Nowa gra
prymula <prymula76@outlook.com>
parents:
diff changeset
154 if(e.getActionCommand().equals("MenuItem1")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
155 //getNameDialog.initUI(configfile, frame, getNameDialog.runGetNameDialog);
prymula <prymula76@outlook.com>
parents:
diff changeset
156 //getNameDialog.runGetNameDialog=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
157 //if (getNameDialog.go){
prymula <prymula76@outlook.com>
parents:
diff changeset
158
prymula <prymula76@outlook.com>
parents:
diff changeset
159 activeRing=10;
prymula <prymula76@outlook.com>
parents:
diff changeset
160 totalScore=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
161 pointsForTheRing=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
162 pointsFOrTheMund=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
163 level=1;
prymula <prymula76@outlook.com>
parents:
diff changeset
164 //frame.remove(startScreen);
prymula <prymula76@outlook.com>
parents:
diff changeset
165 //frame.add(textArea);
prymula <prymula76@outlook.com>
parents:
diff changeset
166 startScreen.setVisible(false);
prymula <prymula76@outlook.com>
parents:
diff changeset
167 textArea.setVisible(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
168 create_secret_mound();
prymula <prymula76@outlook.com>
parents:
diff changeset
169 create_real_mound(); // generuje prawdziwy kopiec
prymula <prymula76@outlook.com>
parents:
diff changeset
170 cheatSheet = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
171 setCharCheatSheet ();
prymula <prymula76@outlook.com>
parents:
diff changeset
172 go=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
173 setDisplayMound();
prymula <prymula76@outlook.com>
parents:
diff changeset
174 // }
prymula <prymula76@outlook.com>
parents:
diff changeset
175 }
prymula <prymula76@outlook.com>
parents:
diff changeset
176 // Zakonczenie
prymula <prymula76@outlook.com>
parents:
diff changeset
177 else if(e.getActionCommand().equals("MenuItem2")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
178 System.exit(0);
prymula <prymula76@outlook.com>
parents:
diff changeset
179 }
prymula <prymula76@outlook.com>
parents:
diff changeset
180 // O Programie
prymula <prymula76@outlook.com>
parents:
diff changeset
181 else if(e.getActionCommand().equals("MenuItem3")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
182 String s1=" Port mojej gry pierwotnie napisanej dla Androida 2.3\n\n",
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
183 s2=" Program napisany na podstawie fragmentow kodow,\n",
0
prymula <prymula76@outlook.com>
parents:
diff changeset
184 s3=" wyszukanych w wyszukiwarce Google,\n",
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
185 s4=" plus wlasna inwencja\n\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
186 s5=" Autor zarzeka sie ze nigdy nie posiadal, ani nie posiada\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
187 s6=" zadnej ksiazki na temat Javy.\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
188 s7="Oraz nie przeczytal ani jednej ksiazki na temat tego jezyka!\n\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
189 s8=" Przemyslaw R. Pietraszczyk - jesien 2020\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
190 s9=" Licencja: GPL v3\n\n",
0
prymula <prymula76@outlook.com>
parents:
diff changeset
191 s10=" Stworzono w oparciu o OpenJDK 11 oraz ANT\n\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
192 s11=" o/s: "+configfile.osName+" ver. "+configfile.osVersion+"\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
193 s12=" java ver: "+configfile.jvmVersion;
prymula <prymula76@outlook.com>
parents:
diff changeset
194
prymula <prymula76@outlook.com>
parents:
diff changeset
195 JOptionPane.showMessageDialog(frame,
prymula <prymula76@outlook.com>
parents:
diff changeset
196 s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12,
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
197 "Kopiec Kreta 0.230924-0",
0
prymula <prymula76@outlook.com>
parents:
diff changeset
198 JOptionPane.PLAIN_MESSAGE);
prymula <prymula76@outlook.com>
parents:
diff changeset
199
prymula <prymula76@outlook.com>
parents:
diff changeset
200 }
prymula <prymula76@outlook.com>
parents:
diff changeset
201 else if(e.getActionCommand().equals("MenuItem33")) {
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
202 String s1="Celem gry jest odgadniecie wszyskich zakrytych pol.\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
203 s2="Rozgrywke rozpoczyna sie od dolnego pierscienia.\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
204 s3="Po odgadnieciu wszyskich liter w danym pierscieniu,\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
205 s4="rozgrywka przenosi sie na kolejny, wyzszy ring.\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
206 s5="Po odgadnieciu wszystkich liter, gracz pytany jest\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
207 s6="o chec gry na opcjonalnym nastepnym poziomie.\n\n",
0
prymula <prymula76@outlook.com>
parents:
diff changeset
208 s7="UWAGA ! Caps Lock - bez znaczenia !\n",
prymula <prymula76@outlook.com>
parents:
diff changeset
209 s8="\n";
prymula <prymula76@outlook.com>
parents:
diff changeset
210 JOptionPane.showMessageDialog(frame,
prymula <prymula76@outlook.com>
parents:
diff changeset
211 s1+s2+s3+s4+s5+s6+s7+s8,
prymula <prymula76@outlook.com>
parents:
diff changeset
212 "Pomoc",
prymula <prymula76@outlook.com>
parents:
diff changeset
213 JOptionPane.PLAIN_MESSAGE);
prymula <prymula76@outlook.com>
parents:
diff changeset
214 }
prymula <prymula76@outlook.com>
parents:
diff changeset
215 else if(e.getActionCommand().equals("MenuItem4")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
216 sounddialog.initUI(configfile, frame, sounddialog.runSoundDialog);
prymula <prymula76@outlook.com>
parents:
diff changeset
217 sounddialog.runSoundDialog=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
218 }
prymula <prymula76@outlook.com>
parents:
diff changeset
219 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
220 else if(e.getActionCommand().equals("MenuItem5")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
221 resetdialog.initUI(configfile);
prymula <prymula76@outlook.com>
parents:
diff changeset
222 }
prymula <prymula76@outlook.com>
parents:
diff changeset
223 */
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
224 // sala slawy
0
prymula <prymula76@outlook.com>
parents:
diff changeset
225 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
226 else if(e.getActionCommand().equals("MenuItem11")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
227
prymula <prymula76@outlook.com>
parents:
diff changeset
228 }
prymula <prymula76@outlook.com>
parents:
diff changeset
229 */
prymula <prymula76@outlook.com>
parents:
diff changeset
230 //System.out.println("ACTION PERFORMED " + e);
prymula <prymula76@outlook.com>
parents:
diff changeset
231 }
prymula <prymula76@outlook.com>
parents:
diff changeset
232
prymula <prymula76@outlook.com>
parents:
diff changeset
233 private static void createAndShowGUI() {
prymula <prymula76@outlook.com>
parents:
diff changeset
234
prymula <prymula76@outlook.com>
parents:
diff changeset
235 frame=new JFrame("Kopiec Kreta");
prymula <prymula76@outlook.com>
parents:
diff changeset
236 //Robot robot;
prymula <prymula76@outlook.com>
parents:
diff changeset
237 // menuBar z konstruktora
prymula <prymula76@outlook.com>
parents:
diff changeset
238 final int frameWidth = 250;
prymula <prymula76@outlook.com>
parents:
diff changeset
239 final int frameHeight = 460;
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
240 final int GNOMEPANEL=80; // nieco nizej niz panel
0
prymula <prymula76@outlook.com>
parents:
diff changeset
241 final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
prymula <prymula76@outlook.com>
parents:
diff changeset
242 //frame.setBounds((int) screenSize.getWidth() - frameWidth,
prymula <prymula76@outlook.com>
parents:
diff changeset
243 // (int) screenSize.getHeight() - frameHeight, frameWidth, frameHeight);
prymula <prymula76@outlook.com>
parents:
diff changeset
244 frame.setBounds((int) screenSize.getWidth() - frameWidth,
prymula <prymula76@outlook.com>
parents:
diff changeset
245 GNOMEPANEL, frameWidth, frameHeight);
prymula <prymula76@outlook.com>
parents:
diff changeset
246 frame.setResizable(false);
prymula <prymula76@outlook.com>
parents:
diff changeset
247 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
prymula <prymula76@outlook.com>
parents:
diff changeset
248 sounddialog = new SoundDialog();
prymula <prymula76@outlook.com>
parents:
diff changeset
249 //resetdialog = new ResetDialog();
prymula <prymula76@outlook.com>
parents:
diff changeset
250 //getNameDialog = new GetNameDialog();
prymula <prymula76@outlook.com>
parents:
diff changeset
251 textArea = new KopiecKreta();
prymula <prymula76@outlook.com>
parents:
diff changeset
252 startScreen = new StartScreen();
prymula <prymula76@outlook.com>
parents:
diff changeset
253 //textArea.setFont(new Font("Serif", Font.ITALIC, 18));
prymula <prymula76@outlook.com>
parents:
diff changeset
254 textArea.setFont(new Font("Serif", Font.BOLD, 18));
prymula <prymula76@outlook.com>
parents:
diff changeset
255 textArea.setLineWrap(true); //nowe
prymula <prymula76@outlook.com>
parents:
diff changeset
256 textArea.setWrapStyleWord(true); // nowe
prymula <prymula76@outlook.com>
parents:
diff changeset
257 textArea.setEditable(false);
prymula <prymula76@outlook.com>
parents:
diff changeset
258 textArea.setBounds(5,5,240,430);
prymula <prymula76@outlook.com>
parents:
diff changeset
259 frame.add(textArea);
prymula <prymula76@outlook.com>
parents:
diff changeset
260 textArea.setVisible(false);
prymula <prymula76@outlook.com>
parents:
diff changeset
261 frame.add(menuBar);
prymula <prymula76@outlook.com>
parents:
diff changeset
262 frame.add(startScreen);
prymula <prymula76@outlook.com>
parents:
diff changeset
263 startScreen.setFont(new Font("Serif", Font.BOLD, 18));
prymula <prymula76@outlook.com>
parents:
diff changeset
264 startScreen.setBounds(5,5,240,430);
prymula <prymula76@outlook.com>
parents:
diff changeset
265
prymula <prymula76@outlook.com>
parents:
diff changeset
266 frame.setJMenuBar(menuBar);
prymula <prymula76@outlook.com>
parents:
diff changeset
267 frame.setLayout(null);
prymula <prymula76@outlook.com>
parents:
diff changeset
268 frame.setSize(250,500); // 400 x 400
prymula <prymula76@outlook.com>
parents:
diff changeset
269 frame.setVisible(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
270 actions = new Actions();
prymula <prymula76@outlook.com>
parents:
diff changeset
271 frame.addKeyListener(actions);
prymula <prymula76@outlook.com>
parents:
diff changeset
272 frame.setFocusable(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
273 textArea.setForeground(Color.BLACK);
prymula <prymula76@outlook.com>
parents:
diff changeset
274 textArea.setBackground(Color.GREEN);
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
275 // zapobiega utracie KeyEvent po wyjsciu z SoundDialog i ResetDialog
0
prymula <prymula76@outlook.com>
parents:
diff changeset
276 frame.addFocusListener(new FocusListener(){
prymula <prymula76@outlook.com>
parents:
diff changeset
277 public void focusGained(FocusEvent e){
prymula <prymula76@outlook.com>
parents:
diff changeset
278 //System.out.println("Focus GAINED:"+e);
prymula <prymula76@outlook.com>
parents:
diff changeset
279 }
prymula <prymula76@outlook.com>
parents:
diff changeset
280 public void focusLost(FocusEvent e){
prymula <prymula76@outlook.com>
parents:
diff changeset
281 //System.out.println("Focus LOST:"+e);
prymula <prymula76@outlook.com>
parents:
diff changeset
282
prymula <prymula76@outlook.com>
parents:
diff changeset
283 // FIX FOR GNOME/XWIN FOCUS BUG
prymula <prymula76@outlook.com>
parents:
diff changeset
284 e.getComponent().requestFocus();
prymula <prymula76@outlook.com>
parents:
diff changeset
285 }
prymula <prymula76@outlook.com>
parents:
diff changeset
286 });
prymula <prymula76@outlook.com>
parents:
diff changeset
287 try {
prymula <prymula76@outlook.com>
parents:
diff changeset
288 configfile = new ConfigFile();
prymula <prymula76@outlook.com>
parents:
diff changeset
289 }catch (IOException e){}
prymula <prymula76@outlook.com>
parents:
diff changeset
290 configfile.load();
prymula <prymula76@outlook.com>
parents:
diff changeset
291
prymula <prymula76@outlook.com>
parents:
diff changeset
292 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
293 try {
prymula <prymula76@outlook.com>
parents:
diff changeset
294 // obiekt robot posiada metode do pobierania koloru pixela
prymula <prymula76@outlook.com>
parents:
diff changeset
295 robot = new Robot();
prymula <prymula76@outlook.com>
parents:
diff changeset
296 robot.mouseMove(screenSize.width-100, 200);
prymula <prymula76@outlook.com>
parents:
diff changeset
297 robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
prymula <prymula76@outlook.com>
parents:
diff changeset
298 robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
prymula <prymula76@outlook.com>
parents:
diff changeset
299 }catch (AWTException e) {}
prymula <prymula76@outlook.com>
parents:
diff changeset
300 frame.setAlwaysOnTop(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
301 */
prymula <prymula76@outlook.com>
parents:
diff changeset
302
prymula <prymula76@outlook.com>
parents:
diff changeset
303 timer.schedule(new KeyTicks(), 0, 1000); // lepiej 1000
prymula <prymula76@outlook.com>
parents:
diff changeset
304
prymula <prymula76@outlook.com>
parents:
diff changeset
305 }
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
306 // dodaje punkty za pierscien i kazuje pozostale litery sciagi
0
prymula <prymula76@outlook.com>
parents:
diff changeset
307 static public void addScores(){
prymula <prymula76@outlook.com>
parents:
diff changeset
308 int n;
prymula <prymula76@outlook.com>
parents:
diff changeset
309 pointsForTheRing=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
310 if (!cheatActivate){
prymula <prymula76@outlook.com>
parents:
diff changeset
311 for (int i=0;i< cheatSheet.size();i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
312 pointsForTheRing++;
prymula <prymula76@outlook.com>
parents:
diff changeset
313 }
prymula <prymula76@outlook.com>
parents:
diff changeset
314 pointsFOrTheMund+=pointsForTheRing;
prymula <prymula76@outlook.com>
parents:
diff changeset
315 }
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
316 //System.out.println("Naliczylem "+pointsForTheRing+" punktow za ring");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
317 }
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
318 // zapelnia tablice ze znakami do podpowiedzi
0
prymula <prymula76@outlook.com>
parents:
diff changeset
319 static private void setCharCheatSheet (){
prymula <prymula76@outlook.com>
parents:
diff changeset
320
prymula <prymula76@outlook.com>
parents:
diff changeset
321 for (int i=0; i<NCHAR; i++){
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
322 // przepisujemy kolejno znaki do listy stringow
0
prymula <prymula76@outlook.com>
parents:
diff changeset
323 char c= Character.toUpperCase(charsInStock[i]);
prymula <prymula76@outlook.com>
parents:
diff changeset
324 cheatSheet.add(String.valueOf(c));
prymula <prymula76@outlook.com>
parents:
diff changeset
325 }
prymula <prymula76@outlook.com>
parents:
diff changeset
326 }
prymula <prymula76@outlook.com>
parents:
diff changeset
327 static private void refreshCheatSheet(int n){
prymula <prymula76@outlook.com>
parents:
diff changeset
328 String t="";
prymula <prymula76@outlook.com>
parents:
diff changeset
329 cheatSheet.remove(n);
prymula <prymula76@outlook.com>
parents:
diff changeset
330 for (int i=0;i< cheatSheet.size();i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
331 t+=cheatSheet.get(i);
prymula <prymula76@outlook.com>
parents:
diff changeset
332 }
prymula <prymula76@outlook.com>
parents:
diff changeset
333 }
prymula <prymula76@outlook.com>
parents:
diff changeset
334 // szuka znaku w tablicy z podpowiedzia
prymula <prymula76@outlook.com>
parents:
diff changeset
335 static private int searchCharChaetSheet(char c){
prymula <prymula76@outlook.com>
parents:
diff changeset
336 String s="";
prymula <prymula76@outlook.com>
parents:
diff changeset
337 String sc="";
prymula <prymula76@outlook.com>
parents:
diff changeset
338 //String test="";
prymula <prymula76@outlook.com>
parents:
diff changeset
339 for (int i=0;i< cheatSheet.size();i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
340 s=cheatSheet.get(i);
prymula <prymula76@outlook.com>
parents:
diff changeset
341 sc = String.valueOf(c);
prymula <prymula76@outlook.com>
parents:
diff changeset
342 // test+=sc;
prymula <prymula76@outlook.com>
parents:
diff changeset
343 if (s.equals(sc)) {
prymula <prymula76@outlook.com>
parents:
diff changeset
344 return i;
prymula <prymula76@outlook.com>
parents:
diff changeset
345 }
prymula <prymula76@outlook.com>
parents:
diff changeset
346 }
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
347 //System.out.println("Nie odnalazlem znaku:"+sc);
0
prymula <prymula76@outlook.com>
parents:
diff changeset
348 return -1;
prymula <prymula76@outlook.com>
parents:
diff changeset
349 }
prymula <prymula76@outlook.com>
parents:
diff changeset
350 static private void create_real_mound(){
prymula <prymula76@outlook.com>
parents:
diff changeset
351
prymula <prymula76@outlook.com>
parents:
diff changeset
352 int n_char=3;
prymula <prymula76@outlook.com>
parents:
diff changeset
353 String r="";
prymula <prymula76@outlook.com>
parents:
diff changeset
354
prymula <prymula76@outlook.com>
parents:
diff changeset
355 for (int i=0; i<NRINGS; i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
356 truering[i] = new Ring(res.getDirectory(n_char));
prymula <prymula76@outlook.com>
parents:
diff changeset
357 n_char++;
prymula <prymula76@outlook.com>
parents:
diff changeset
358 for (int j=0;j<truering[i].getLength();j++){
prymula <prymula76@outlook.com>
parents:
diff changeset
359 String _r=Character.toString(truering[i].getChar(j));
prymula <prymula76@outlook.com>
parents:
diff changeset
360
prymula <prymula76@outlook.com>
parents:
diff changeset
361 r+=_r;
prymula <prymula76@outlook.com>
parents:
diff changeset
362 }
prymula <prymula76@outlook.com>
parents:
diff changeset
363 r+="\n";
prymula <prymula76@outlook.com>
parents:
diff changeset
364 }
prymula <prymula76@outlook.com>
parents:
diff changeset
365
prymula <prymula76@outlook.com>
parents:
diff changeset
366 System.out.println(r);
prymula <prymula76@outlook.com>
parents:
diff changeset
367
prymula <prymula76@outlook.com>
parents:
diff changeset
368 }
prymula <prymula76@outlook.com>
parents:
diff changeset
369 public static void create_secret_mound(){
prymula <prymula76@outlook.com>
parents:
diff changeset
370 // kodujemy od 3 liter
prymula <prymula76@outlook.com>
parents:
diff changeset
371 String s="???";
prymula <prymula76@outlook.com>
parents:
diff changeset
372
prymula <prymula76@outlook.com>
parents:
diff changeset
373 for (int i=0; i<NRINGS; i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
374 falsering[i] = new Ring(s);
prymula <prymula76@outlook.com>
parents:
diff changeset
375 s+="?";
prymula <prymula76@outlook.com>
parents:
diff changeset
376 }
prymula <prymula76@outlook.com>
parents:
diff changeset
377 }
prymula <prymula76@outlook.com>
parents:
diff changeset
378
prymula <prymula76@outlook.com>
parents:
diff changeset
379 public static void main(final String[] args) {
prymula <prymula76@outlook.com>
parents:
diff changeset
380
prymula <prymula76@outlook.com>
parents:
diff changeset
381 try {
prymula <prymula76@outlook.com>
parents:
diff changeset
382 res.read();
prymula <prymula76@outlook.com>
parents:
diff changeset
383 //wav = new wavResource();
prymula <prymula76@outlook.com>
parents:
diff changeset
384 //wav.loadWav();
prymula <prymula76@outlook.com>
parents:
diff changeset
385 //wav.initWav();
prymula <prymula76@outlook.com>
parents:
diff changeset
386 }catch (Exception e) {
prymula <prymula76@outlook.com>
parents:
diff changeset
387 e.printStackTrace();
prymula <prymula76@outlook.com>
parents:
diff changeset
388 }
prymula <prymula76@outlook.com>
parents:
diff changeset
389 javax.swing.SwingUtilities.invokeLater(new RunnableImplementation());
prymula <prymula76@outlook.com>
parents:
diff changeset
390 }
prymula <prymula76@outlook.com>
parents:
diff changeset
391
prymula <prymula76@outlook.com>
parents:
diff changeset
392 static private void setDisplayMound(){
prymula <prymula76@outlook.com>
parents:
diff changeset
393 String sr = new String();
prymula <prymula76@outlook.com>
parents:
diff changeset
394 String r="";
prymula <prymula76@outlook.com>
parents:
diff changeset
395 textArea.setText(null);
prymula <prymula76@outlook.com>
parents:
diff changeset
396 sr+="\n";
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
397 // i=1 poniewaz pomijamy 3 literowy ring
0
prymula <prymula76@outlook.com>
parents:
diff changeset
398 for (int i=1;i<NRINGS;i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
399
prymula <prymula76@outlook.com>
parents:
diff changeset
400 //String r="";
prymula <prymula76@outlook.com>
parents:
diff changeset
401 for (int j=0;j<truering[i].getLength();j++){
prymula <prymula76@outlook.com>
parents:
diff changeset
402
prymula <prymula76@outlook.com>
parents:
diff changeset
403 String _r=Character.toString(truering[i].getChar(j));
prymula <prymula76@outlook.com>
parents:
diff changeset
404 r+=_r;
prymula <prymula76@outlook.com>
parents:
diff changeset
405 }
prymula <prymula76@outlook.com>
parents:
diff changeset
406 //System.out.println(r);
prymula <prymula76@outlook.com>
parents:
diff changeset
407 r="";
prymula <prymula76@outlook.com>
parents:
diff changeset
408 sr+=" ";
prymula <prymula76@outlook.com>
parents:
diff changeset
409 if (i==activeRing){
prymula <prymula76@outlook.com>
parents:
diff changeset
410 sr+=">";
prymula <prymula76@outlook.com>
parents:
diff changeset
411 }
prymula <prymula76@outlook.com>
parents:
diff changeset
412 else sr+=" ";
prymula <prymula76@outlook.com>
parents:
diff changeset
413 for (int j=0;j<falsering[i].getLength();j++){
prymula <prymula76@outlook.com>
parents:
diff changeset
414 String _s=Character.toString(falsering[i].getChar(j));
prymula <prymula76@outlook.com>
parents:
diff changeset
415 sr +=_s;
prymula <prymula76@outlook.com>
parents:
diff changeset
416 }
prymula <prymula76@outlook.com>
parents:
diff changeset
417 if (i==activeRing){
prymula <prymula76@outlook.com>
parents:
diff changeset
418 sr+="<";
prymula <prymula76@outlook.com>
parents:
diff changeset
419 }
prymula <prymula76@outlook.com>
parents:
diff changeset
420 mound[i]=sr;
prymula <prymula76@outlook.com>
parents:
diff changeset
421 //System.out.println("mound["+i+"] "+mound[i]);
prymula <prymula76@outlook.com>
parents:
diff changeset
422
prymula <prymula76@outlook.com>
parents:
diff changeset
423 textArea.append(mound[i]+"\n");
prymula <prymula76@outlook.com>
parents:
diff changeset
424 sr="";
prymula <prymula76@outlook.com>
parents:
diff changeset
425 }
prymula <prymula76@outlook.com>
parents:
diff changeset
426 textArea.append("\n\n");
prymula <prymula76@outlook.com>
parents:
diff changeset
427 for (int i=0; i<cheatSheet.size();i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
428 textArea.append(cheatSheet.get(i));
prymula <prymula76@outlook.com>
parents:
diff changeset
429 textArea.append(" ");
prymula <prymula76@outlook.com>
parents:
diff changeset
430 }
prymula <prymula76@outlook.com>
parents:
diff changeset
431
prymula <prymula76@outlook.com>
parents:
diff changeset
432 }
prymula <prymula76@outlook.com>
parents:
diff changeset
433
prymula <prymula76@outlook.com>
parents:
diff changeset
434
prymula <prymula76@outlook.com>
parents:
diff changeset
435 private static final class RunnableImplementation implements Runnable {
prymula <prymula76@outlook.com>
parents:
diff changeset
436 public void run(){
prymula <prymula76@outlook.com>
parents:
diff changeset
437 wav = new wavResource();
prymula <prymula76@outlook.com>
parents:
diff changeset
438 createAndShowGUI();
prymula <prymula76@outlook.com>
parents:
diff changeset
439 }
prymula <prymula76@outlook.com>
parents:
diff changeset
440 }
prymula <prymula76@outlook.com>
parents:
diff changeset
441 public static void unhideWords(){
prymula <prymula76@outlook.com>
parents:
diff changeset
442 for (int j=0;j<truering[activeRing].getLength();j++){
prymula <prymula76@outlook.com>
parents:
diff changeset
443 falsering[activeRing].setChar(truering[activeRing].getChar(j),j);
prymula <prymula76@outlook.com>
parents:
diff changeset
444 }
prymula <prymula76@outlook.com>
parents:
diff changeset
445 }
prymula <prymula76@outlook.com>
parents:
diff changeset
446
prymula <prymula76@outlook.com>
parents:
diff changeset
447 static class KeyTicks extends TimerTask {
prymula <prymula76@outlook.com>
parents:
diff changeset
448 int cw=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
449 static char pressKey='Q';
prymula <prymula76@outlook.com>
parents:
diff changeset
450 static char lastKey='Q';
prymula <prymula76@outlook.com>
parents:
diff changeset
451 static boolean firstRun=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
452 int n=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
453 /* FIXME - miga gdy odnaleziono litere ?
prymula <prymula76@outlook.com>
parents:
diff changeset
454 */
prymula <prymula76@outlook.com>
parents:
diff changeset
455 public void run() {
prymula <prymula76@outlook.com>
parents:
diff changeset
456 ArrayList<Integer> indexExist = new ArrayList<Integer>();
prymula <prymula76@outlook.com>
parents:
diff changeset
457 int returnIndex;
prymula <prymula76@outlook.com>
parents:
diff changeset
458
prymula <prymula76@outlook.com>
parents:
diff changeset
459
prymula <prymula76@outlook.com>
parents:
diff changeset
460 pressKey=actions.getKey();
prymula <prymula76@outlook.com>
parents:
diff changeset
461
prymula <prymula76@outlook.com>
parents:
diff changeset
462 if (go) {
prymula <prymula76@outlook.com>
parents:
diff changeset
463 wav.stop();
prymula <prymula76@outlook.com>
parents:
diff changeset
464 indexExist=checkInstance(pressKey);
prymula <prymula76@outlook.com>
parents:
diff changeset
465 for (int exist: indexExist){
prymula <prymula76@outlook.com>
parents:
diff changeset
466 falsering[activeRing].setChar(pressKey,exist);
prymula <prymula76@outlook.com>
parents:
diff changeset
467 wav.PlayFlag=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
468 if (lastKey != pressKey) {
prymula <prymula76@outlook.com>
parents:
diff changeset
469 if (sounddialog.soundAccept()){
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
470 //System.out.println("Dzwiek akceptuje");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
471 wav.play("/smooth-ok.wav");
prymula <prymula76@outlook.com>
parents:
diff changeset
472 }
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
473 else System.out.println("Dzwiek NIE akceptuje");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
474 }
prymula <prymula76@outlook.com>
parents:
diff changeset
475 }
prymula <prymula76@outlook.com>
parents:
diff changeset
476 if (lastKey != pressKey && indexExist.isEmpty() && !firstRun) {
prymula <prymula76@outlook.com>
parents:
diff changeset
477 //if (lastKey != pressKey && indexExist.isEmpty()) {
prymula <prymula76@outlook.com>
parents:
diff changeset
478
prymula <prymula76@outlook.com>
parents:
diff changeset
479 wav.PlayFlag=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
480 if (sounddialog.soundAccept()){
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
481 //System.out.println("Dzwiek akceptuje");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
482 wav.play("/bass-bad.wav");
prymula <prymula76@outlook.com>
parents:
diff changeset
483 }
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
484 else System.out.println("Dzwiek NIE akceptuje");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
485 }
prymula <prymula76@outlook.com>
parents:
diff changeset
486 lastKey=pressKey;
prymula <prymula76@outlook.com>
parents:
diff changeset
487
prymula <prymula76@outlook.com>
parents:
diff changeset
488 returnIndex = searchCharChaetSheet(pressKey);
prymula <prymula76@outlook.com>
parents:
diff changeset
489 if (returnIndex != -1){
prymula <prymula76@outlook.com>
parents:
diff changeset
490 refreshCheatSheet(returnIndex);
prymula <prymula76@outlook.com>
parents:
diff changeset
491 }
prymula <prymula76@outlook.com>
parents:
diff changeset
492 setDisplayMound();
prymula <prymula76@outlook.com>
parents:
diff changeset
493 pressKey=' ';
prymula <prymula76@outlook.com>
parents:
diff changeset
494 indexExist.clear();
prymula <prymula76@outlook.com>
parents:
diff changeset
495
prymula <prymula76@outlook.com>
parents:
diff changeset
496 if (actions.getCheat().equals(CONSTCH)){
prymula <prymula76@outlook.com>
parents:
diff changeset
497 //pointsForTheRing=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
498 actions.resetCheat();
prymula <prymula76@outlook.com>
parents:
diff changeset
499 cheatActivate=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
500 unhideWords();
prymula <prymula76@outlook.com>
parents:
diff changeset
501 }
prymula <prymula76@outlook.com>
parents:
diff changeset
502 if (checkFullRing()) {
prymula <prymula76@outlook.com>
parents:
diff changeset
503 totalScore+=pointsForTheRing;
prymula <prymula76@outlook.com>
parents:
diff changeset
504 setCharCheatSheet ();
prymula <prymula76@outlook.com>
parents:
diff changeset
505 setDisplayMound();
prymula <prymula76@outlook.com>
parents:
diff changeset
506
prymula <prymula76@outlook.com>
parents:
diff changeset
507 }
prymula <prymula76@outlook.com>
parents:
diff changeset
508
prymula <prymula76@outlook.com>
parents:
diff changeset
509 firstRun=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
510 }
prymula <prymula76@outlook.com>
parents:
diff changeset
511 }
prymula <prymula76@outlook.com>
parents:
diff changeset
512 static private boolean checkFullRing() {
prymula <prymula76@outlook.com>
parents:
diff changeset
513 if (truering[activeRing].getString().equals(falsering[activeRing].getString())){
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
514 //System.out.println("Czy zaliczony pierscien ? activeRing:"+activeRing);
0
prymula <prymula76@outlook.com>
parents:
diff changeset
515 if (activeRing >1){
prymula <prymula76@outlook.com>
parents:
diff changeset
516 addScores();
prymula <prymula76@outlook.com>
parents:
diff changeset
517 cheatActivate=false;
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
518 // nowa sciaga
0
prymula <prymula76@outlook.com>
parents:
diff changeset
519 cheatSheet = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
520 activeRing--;
prymula <prymula76@outlook.com>
parents:
diff changeset
521 return true;
prymula <prymula76@outlook.com>
parents:
diff changeset
522 }
prymula <prymula76@outlook.com>
parents:
diff changeset
523 else {
prymula <prymula76@outlook.com>
parents:
diff changeset
524 go=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
525
prymula <prymula76@outlook.com>
parents:
diff changeset
526 setDisplayMound();
prymula <prymula76@outlook.com>
parents:
diff changeset
527 if(activeRing==1){
prymula <prymula76@outlook.com>
parents:
diff changeset
528
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
529 String s1="Ukonczyles poziom "+level+" !\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
530 s2="Na tym poziomie uzyskales "+pointsFOrTheMund+" punktow.\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
531 s3="Poki co ugrales "+totalScore+" punktow !\n\n",
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
532 s4="Kontynujesz gre ?";
0
prymula <prymula76@outlook.com>
parents:
diff changeset
533
prymula <prymula76@outlook.com>
parents:
diff changeset
534 // moze boolean ?
prymula <prymula76@outlook.com>
parents:
diff changeset
535 int dialogButton = JOptionPane.YES_NO_OPTION;
prymula <prymula76@outlook.com>
parents:
diff changeset
536 int answer = JOptionPane.showConfirmDialog (frame, s1+s2+s3+s4,"Komunikat", dialogButton);
prymula <prymula76@outlook.com>
parents:
diff changeset
537
prymula <prymula76@outlook.com>
parents:
diff changeset
538 if(answer == JOptionPane.YES_OPTION) {
prymula <prymula76@outlook.com>
parents:
diff changeset
539 activeRing=10;
prymula <prymula76@outlook.com>
parents:
diff changeset
540 go=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
541 level++;
prymula <prymula76@outlook.com>
parents:
diff changeset
542 create_secret_mound();
prymula <prymula76@outlook.com>
parents:
diff changeset
543 create_real_mound(); // generuje prawdziwy kopiec
prymula <prymula76@outlook.com>
parents:
diff changeset
544 setDisplayMound();
prymula <prymula76@outlook.com>
parents:
diff changeset
545 pointsFOrTheMund=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
546 }
prymula <prymula76@outlook.com>
parents:
diff changeset
547 if(answer == JOptionPane.NO_OPTION) {
prymula <prymula76@outlook.com>
parents:
diff changeset
548 System.exit(0);
prymula <prymula76@outlook.com>
parents:
diff changeset
549
prymula <prymula76@outlook.com>
parents:
diff changeset
550 }
prymula <prymula76@outlook.com>
parents:
diff changeset
551 }
prymula <prymula76@outlook.com>
parents:
diff changeset
552 }
prymula <prymula76@outlook.com>
parents:
diff changeset
553 }
prymula <prymula76@outlook.com>
parents:
diff changeset
554 return false;
prymula <prymula76@outlook.com>
parents:
diff changeset
555 }
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
556 // sprawdza czy rzadana litera znajduje sie w pierscieniu
0
prymula <prymula76@outlook.com>
parents:
diff changeset
557 static private ArrayList<Integer> checkInstance(char key){
prymula <prymula76@outlook.com>
parents:
diff changeset
558 ArrayList<Integer> indexExist = new ArrayList<Integer>();
prymula <prymula76@outlook.com>
parents:
diff changeset
559
prymula <prymula76@outlook.com>
parents:
diff changeset
560 for (int i=0; i<truering[activeRing].getLength();i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
561 if (truering[activeRing].getChar(i) == key) {
prymula <prymula76@outlook.com>
parents:
diff changeset
562 indexExist.add(i);
prymula <prymula76@outlook.com>
parents:
diff changeset
563 }
prymula <prymula76@outlook.com>
parents:
diff changeset
564 }
prymula <prymula76@outlook.com>
parents:
diff changeset
565 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
566 if (indexExist.size()!=0) {
prymula <prymula76@outlook.com>
parents:
diff changeset
567 changeView=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
568 }
prymula <prymula76@outlook.com>
parents:
diff changeset
569 */
prymula <prymula76@outlook.com>
parents:
diff changeset
570 return indexExist;
prymula <prymula76@outlook.com>
parents:
diff changeset
571 }
prymula <prymula76@outlook.com>
parents:
diff changeset
572 }
prymula <prymula76@outlook.com>
parents:
diff changeset
573 static class Ring {
prymula <prymula76@outlook.com>
parents:
diff changeset
574 char c[];
prymula <prymula76@outlook.com>
parents:
diff changeset
575 int l=0; // dlugosc
prymula <prymula76@outlook.com>
parents:
diff changeset
576 public Ring(String s){
prymula <prymula76@outlook.com>
parents:
diff changeset
577 //System.out.println("Z Ring constructor: "+s+" dlugosc: "+s.length());
prymula <prymula76@outlook.com>
parents:
diff changeset
578 c = new char[s.length()+2];
prymula <prymula76@outlook.com>
parents:
diff changeset
579 c =s.toCharArray();
prymula <prymula76@outlook.com>
parents:
diff changeset
580 l=s.length();
prymula <prymula76@outlook.com>
parents:
diff changeset
581 }
prymula <prymula76@outlook.com>
parents:
diff changeset
582 public char getChar(int poz){
prymula <prymula76@outlook.com>
parents:
diff changeset
583 return (char) c[poz];
prymula <prymula76@outlook.com>
parents:
diff changeset
584 }
prymula <prymula76@outlook.com>
parents:
diff changeset
585 public void setChar(char _c,int p){
prymula <prymula76@outlook.com>
parents:
diff changeset
586 c[p]=_c;
prymula <prymula76@outlook.com>
parents:
diff changeset
587 }
prymula <prymula76@outlook.com>
parents:
diff changeset
588 public int getLength(){
prymula <prymula76@outlook.com>
parents:
diff changeset
589 return l;
prymula <prymula76@outlook.com>
parents:
diff changeset
590 }
prymula <prymula76@outlook.com>
parents:
diff changeset
591 public String getString(){
prymula <prymula76@outlook.com>
parents:
diff changeset
592 String sr = new String();
prymula <prymula76@outlook.com>
parents:
diff changeset
593 for (int j=0;j<l;j++){
prymula <prymula76@outlook.com>
parents:
diff changeset
594 String _s=Character.toString(c[j]);
prymula <prymula76@outlook.com>
parents:
diff changeset
595 sr +=_s;
prymula <prymula76@outlook.com>
parents:
diff changeset
596 }
prymula <prymula76@outlook.com>
parents:
diff changeset
597 return sr;
prymula <prymula76@outlook.com>
parents:
diff changeset
598 }
prymula <prymula76@outlook.com>
parents:
diff changeset
599 }
prymula <prymula76@outlook.com>
parents:
diff changeset
600 }
prymula <prymula76@outlook.com>
parents:
diff changeset
601 class SoundDialog implements ItemListener, ActionListener{
prymula <prymula76@outlook.com>
parents:
diff changeset
602 JCheckBox chkBox1;
prymula <prymula76@outlook.com>
parents:
diff changeset
603 JFrame frame;
prymula <prymula76@outlook.com>
parents:
diff changeset
604 boolean sound = true;
prymula <prymula76@outlook.com>
parents:
diff changeset
605 ConfigFile config;
prymula <prymula76@outlook.com>
parents:
diff changeset
606 public Boolean runSoundDialog=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
607
prymula <prymula76@outlook.com>
parents:
diff changeset
608 protected void initUI(ConfigFile cf, JFrame f, Boolean run) {
prymula <prymula76@outlook.com>
parents:
diff changeset
609 if (!run) {
prymula <prymula76@outlook.com>
parents:
diff changeset
610 frame = new JFrame("Zapytanko");
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
611 frame.getContentPane().setSize(new Dimension(300,200)); // nie dziala
0
prymula <prymula76@outlook.com>
parents:
diff changeset
612 frame.getContentPane().setLayout(new GridBagLayout());
prymula <prymula76@outlook.com>
parents:
diff changeset
613 frame.setAlwaysOnTop(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
614 GridBagConstraints c = new GridBagConstraints();
prymula <prymula76@outlook.com>
parents:
diff changeset
615 // nadpisanie metody zamykania okna
prymula <prymula76@outlook.com>
parents:
diff changeset
616 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
prymula <prymula76@outlook.com>
parents:
diff changeset
617 frame.addWindowListener(new WindowAdapter() {
prymula <prymula76@outlook.com>
parents:
diff changeset
618 public void windowClosing(WindowEvent ev) {
prymula <prymula76@outlook.com>
parents:
diff changeset
619 runSoundDialog=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
620 frame.dispose();
prymula <prymula76@outlook.com>
parents:
diff changeset
621 }
prymula <prymula76@outlook.com>
parents:
diff changeset
622 // zapobiega minimalizacji okna dialogowego
prymula <prymula76@outlook.com>
parents:
diff changeset
623 public void windowIconified(WindowEvent we) {
prymula <prymula76@outlook.com>
parents:
diff changeset
624 frame.setState(JFrame.NORMAL);
prymula <prymula76@outlook.com>
parents:
diff changeset
625 //JOptionPane.showMessageDialog(frame, "Cant Minimize");
prymula <prymula76@outlook.com>
parents:
diff changeset
626 }
prymula <prymula76@outlook.com>
parents:
diff changeset
627 });
prymula <prymula76@outlook.com>
parents:
diff changeset
628 JLabel label = new JLabel(" ");
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
629 JButton button = new JButton("Zatwierdz");
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
630 chkBox1= new JCheckBox("Odtwarzaj dzwiek");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
631 config=cf;
prymula <prymula76@outlook.com>
parents:
diff changeset
632 sound = cf.load();
prymula <prymula76@outlook.com>
parents:
diff changeset
633 System.out.println("Dzwiek: "+sound);
prymula <prymula76@outlook.com>
parents:
diff changeset
634 chkBox1.setSelected(sound);
prymula <prymula76@outlook.com>
parents:
diff changeset
635 c.fill = GridBagConstraints.HORIZONTAL;
prymula <prymula76@outlook.com>
parents:
diff changeset
636 c.ipady = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
637 c.weighty = 1.0;
prymula <prymula76@outlook.com>
parents:
diff changeset
638 c.gridwidth = 3;
prymula <prymula76@outlook.com>
parents:
diff changeset
639 c.gridx = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
640 c.gridy = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
641 frame.getContentPane().add(chkBox1,c);
prymula <prymula76@outlook.com>
parents:
diff changeset
642
prymula <prymula76@outlook.com>
parents:
diff changeset
643 c.fill = GridBagConstraints.HORIZONTAL;
prymula <prymula76@outlook.com>
parents:
diff changeset
644 c.ipady = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
645 c.weighty = 1.0;
prymula <prymula76@outlook.com>
parents:
diff changeset
646 c.gridwidth = 3;
prymula <prymula76@outlook.com>
parents:
diff changeset
647 c.gridx = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
648 c.gridy = 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
649 frame.getContentPane().add(label,c);
prymula <prymula76@outlook.com>
parents:
diff changeset
650
prymula <prymula76@outlook.com>
parents:
diff changeset
651 c.fill = GridBagConstraints.HORIZONTAL;
prymula <prymula76@outlook.com>
parents:
diff changeset
652 c.ipady = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
653 c.weighty = 1.0;
prymula <prymula76@outlook.com>
parents:
diff changeset
654 c.anchor = GridBagConstraints.PAGE_END; //bottom of space
prymula <prymula76@outlook.com>
parents:
diff changeset
655 c.gridwidth = 3;
prymula <prymula76@outlook.com>
parents:
diff changeset
656 c.gridx = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
657 c.gridy = 2;
prymula <prymula76@outlook.com>
parents:
diff changeset
658 frame.getContentPane().add(button,c);
prymula <prymula76@outlook.com>
parents:
diff changeset
659
prymula <prymula76@outlook.com>
parents:
diff changeset
660 chkBox1.addItemListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
661 button.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
662 if (cf.osName.equals("Linux")) frame.setUndecorated(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
663 chkBox1.setBorder(BorderFactory.createMatteBorder(20, 20, 20, 20, Color.RED)); // w tym wypadku kolor nie ma znaczenia
prymula <prymula76@outlook.com>
parents:
diff changeset
664 frame.getRootPane().setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.RED));
prymula <prymula76@outlook.com>
parents:
diff changeset
665 frame.pack();
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
666 // pojawi sie nad oknem rodzica
0
prymula <prymula76@outlook.com>
parents:
diff changeset
667 frame.setLocationRelativeTo(f);
prymula <prymula76@outlook.com>
parents:
diff changeset
668 frame.setResizable(false);
prymula <prymula76@outlook.com>
parents:
diff changeset
669 frame.setVisible(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
670 }
prymula <prymula76@outlook.com>
parents:
diff changeset
671 }
prymula <prymula76@outlook.com>
parents:
diff changeset
672 public void itemStateChanged(ItemEvent e) {
prymula <prymula76@outlook.com>
parents:
diff changeset
673
prymula <prymula76@outlook.com>
parents:
diff changeset
674 Object source = e.getItemSelectable();
prymula <prymula76@outlook.com>
parents:
diff changeset
675
prymula <prymula76@outlook.com>
parents:
diff changeset
676 if (source == chkBox1) {
prymula <prymula76@outlook.com>
parents:
diff changeset
677 //System.out.println("Zaznaczono dzwiek");
prymula <prymula76@outlook.com>
parents:
diff changeset
678 sound = true;
prymula <prymula76@outlook.com>
parents:
diff changeset
679 }
prymula <prymula76@outlook.com>
parents:
diff changeset
680 if (e.getStateChange() == ItemEvent.DESELECTED) {
prymula <prymula76@outlook.com>
parents:
diff changeset
681 //System.out.println("Odznaczono dzwiek");
prymula <prymula76@outlook.com>
parents:
diff changeset
682 sound = false;
prymula <prymula76@outlook.com>
parents:
diff changeset
683
prymula <prymula76@outlook.com>
parents:
diff changeset
684 }
prymula <prymula76@outlook.com>
parents:
diff changeset
685
prymula <prymula76@outlook.com>
parents:
diff changeset
686 }
prymula <prymula76@outlook.com>
parents:
diff changeset
687 public void actionPerformed(ActionEvent e) {
prymula <prymula76@outlook.com>
parents:
diff changeset
688 frame.setVisible(false);
prymula <prymula76@outlook.com>
parents:
diff changeset
689 config.save(sound);
prymula <prymula76@outlook.com>
parents:
diff changeset
690 runSoundDialog=false;
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
691 //System.out.println("Zapisuje dzwiek: "+sound);
0
prymula <prymula76@outlook.com>
parents:
diff changeset
692
prymula <prymula76@outlook.com>
parents:
diff changeset
693 }
prymula <prymula76@outlook.com>
parents:
diff changeset
694 public boolean soundAccept(){
prymula <prymula76@outlook.com>
parents:
diff changeset
695 return sound;
prymula <prymula76@outlook.com>
parents:
diff changeset
696 }
prymula <prymula76@outlook.com>
parents:
diff changeset
697 }
prymula <prymula76@outlook.com>
parents:
diff changeset
698 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
699 class ResetDialog implements ItemListener, ActionListener{
prymula <prymula76@outlook.com>
parents:
diff changeset
700 JCheckBox chkBox1;
prymula <prymula76@outlook.com>
parents:
diff changeset
701 JFrame frame;
prymula <prymula76@outlook.com>
parents:
diff changeset
702 boolean reset = false;
prymula <prymula76@outlook.com>
parents:
diff changeset
703 protected void initUI(ConfigFile cf) {
prymula <prymula76@outlook.com>
parents:
diff changeset
704
prymula <prymula76@outlook.com>
parents:
diff changeset
705 frame = new JFrame("Zapytanko");
prymula <prymula76@outlook.com>
parents:
diff changeset
706
prymula <prymula76@outlook.com>
parents:
diff changeset
707 JPanel mainPanel;
prymula <prymula76@outlook.com>
parents:
diff changeset
708 JButton button;
prymula <prymula76@outlook.com>
parents:
diff changeset
709 frame.getContentPane().setLayout(new GridBagLayout());
prymula <prymula76@outlook.com>
parents:
diff changeset
710 GridBagConstraints c = new GridBagConstraints();
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
711 button = new JButton("Zatwierdz");
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
712 //chkBox1= new JCheckBox("Odtwarzaj dzwiek");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
713 chkBox1= new JCheckBox("Zresetuj najlepsze wyniki");
prymula <prymula76@outlook.com>
parents:
diff changeset
714
prymula <prymula76@outlook.com>
parents:
diff changeset
715 chkBox1.setSelected(reset);
prymula <prymula76@outlook.com>
parents:
diff changeset
716 c.fill = GridBagConstraints.HORIZONTAL;
prymula <prymula76@outlook.com>
parents:
diff changeset
717 c.ipady = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
718 c.weighty = 1.0;
prymula <prymula76@outlook.com>
parents:
diff changeset
719 //c.anchor = GridBagConstraints.PAGE_END; //bottom of space
prymula <prymula76@outlook.com>
parents:
diff changeset
720 c.gridwidth = 3;
prymula <prymula76@outlook.com>
parents:
diff changeset
721 c.gridx = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
722 c.gridy = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
723 frame.getContentPane().add(chkBox1,c);
prymula <prymula76@outlook.com>
parents:
diff changeset
724
prymula <prymula76@outlook.com>
parents:
diff changeset
725
prymula <prymula76@outlook.com>
parents:
diff changeset
726
prymula <prymula76@outlook.com>
parents:
diff changeset
727 c.fill = GridBagConstraints.HORIZONTAL;
prymula <prymula76@outlook.com>
parents:
diff changeset
728 c.ipady = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
729 c.weighty = 1.0;
prymula <prymula76@outlook.com>
parents:
diff changeset
730 c.anchor = GridBagConstraints.PAGE_END; //bottom of space
prymula <prymula76@outlook.com>
parents:
diff changeset
731 c.gridwidth = 3;
prymula <prymula76@outlook.com>
parents:
diff changeset
732 c.gridx = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
733 c.gridy = 2;
prymula <prymula76@outlook.com>
parents:
diff changeset
734 frame.getContentPane().add(button,c);
prymula <prymula76@outlook.com>
parents:
diff changeset
735
prymula <prymula76@outlook.com>
parents:
diff changeset
736
prymula <prymula76@outlook.com>
parents:
diff changeset
737
prymula <prymula76@outlook.com>
parents:
diff changeset
738 chkBox1.addItemListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
739 button.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
740 frame.pack();
prymula <prymula76@outlook.com>
parents:
diff changeset
741 frame.setLocationRelativeTo(null);
prymula <prymula76@outlook.com>
parents:
diff changeset
742 frame.setResizable(false);
prymula <prymula76@outlook.com>
parents:
diff changeset
743 frame.setVisible(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
744 }
prymula <prymula76@outlook.com>
parents:
diff changeset
745 public void itemStateChanged(ItemEvent e) {
prymula <prymula76@outlook.com>
parents:
diff changeset
746 //t index = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
747 //ar c = '-';
prymula <prymula76@outlook.com>
parents:
diff changeset
748 Object source = e.getItemSelectable();
prymula <prymula76@outlook.com>
parents:
diff changeset
749
prymula <prymula76@outlook.com>
parents:
diff changeset
750 if (source == chkBox1) {
prymula <prymula76@outlook.com>
parents:
diff changeset
751 //dex = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
752 System.out.println("Zaznaczono dzwiek");
prymula <prymula76@outlook.com>
parents:
diff changeset
753 reset = true;
prymula <prymula76@outlook.com>
parents:
diff changeset
754 }
prymula <prymula76@outlook.com>
parents:
diff changeset
755 if (e.getStateChange() == ItemEvent.DESELECTED) {
prymula <prymula76@outlook.com>
parents:
diff changeset
756 System.out.println("Odznaczono dzwiek");
prymula <prymula76@outlook.com>
parents:
diff changeset
757 reset = false;
prymula <prymula76@outlook.com>
parents:
diff changeset
758
prymula <prymula76@outlook.com>
parents:
diff changeset
759 }
prymula <prymula76@outlook.com>
parents:
diff changeset
760
prymula <prymula76@outlook.com>
parents:
diff changeset
761 }
prymula <prymula76@outlook.com>
parents:
diff changeset
762 public void actionPerformed(ActionEvent e) {
prymula <prymula76@outlook.com>
parents:
diff changeset
763 frame.setVisible(false);
prymula <prymula76@outlook.com>
parents:
diff changeset
764 System.out.println("jestem action");
prymula <prymula76@outlook.com>
parents:
diff changeset
765 }
prymula <prymula76@outlook.com>
parents:
diff changeset
766 public boolean resetAccept(){
prymula <prymula76@outlook.com>
parents:
diff changeset
767 return reset;
prymula <prymula76@outlook.com>
parents:
diff changeset
768 }
prymula <prymula76@outlook.com>
parents:
diff changeset
769 }
prymula <prymula76@outlook.com>
parents:
diff changeset
770 */
prymula <prymula76@outlook.com>
parents:
diff changeset
771 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
772 class GetNameDialog implements ActionListener, KeyListener {
prymula <prymula76@outlook.com>
parents:
diff changeset
773 JTextField text;
prymula <prymula76@outlook.com>
parents:
diff changeset
774 JFrame frame;
prymula <prymula76@outlook.com>
parents:
diff changeset
775 public String namePlayer="";
prymula <prymula76@outlook.com>
parents:
diff changeset
776 public boolean go;
prymula <prymula76@outlook.com>
parents:
diff changeset
777 ConfigFile config;
prymula <prymula76@outlook.com>
parents:
diff changeset
778 public Boolean runGetNameDialog=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
779
prymula <prymula76@outlook.com>
parents:
diff changeset
780 protected void initUI(ConfigFile cf, JFrame f, Boolean run) {
prymula <prymula76@outlook.com>
parents:
diff changeset
781 if (!run) {
prymula <prymula76@outlook.com>
parents:
diff changeset
782 frame = new JFrame("Zapytanko");
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
783 frame.getContentPane().setSize(new Dimension(300,200)); // nie dziala
0
prymula <prymula76@outlook.com>
parents:
diff changeset
784 frame.getContentPane().setLayout(new GridBagLayout());
prymula <prymula76@outlook.com>
parents:
diff changeset
785 frame.setAlwaysOnTop(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
786 GridBagConstraints c = new GridBagConstraints();
prymula <prymula76@outlook.com>
parents:
diff changeset
787 // nadpisanie metody zamykania okna
prymula <prymula76@outlook.com>
parents:
diff changeset
788 frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
prymula <prymula76@outlook.com>
parents:
diff changeset
789 frame.addWindowListener(new WindowAdapter() {
prymula <prymula76@outlook.com>
parents:
diff changeset
790 public void windowClosing(WindowEvent ev) {
prymula <prymula76@outlook.com>
parents:
diff changeset
791 runGetNameDialog=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
792 frame.dispose();
prymula <prymula76@outlook.com>
parents:
diff changeset
793 }
prymula <prymula76@outlook.com>
parents:
diff changeset
794 });
prymula <prymula76@outlook.com>
parents:
diff changeset
795 JLabel label1 = new JLabel(" ");
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
796 JLabel label2 = new JLabel("Najperw sie przedstaw:");
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
797 JButton button = new JButton("Zatwierdz");
0
prymula <prymula76@outlook.com>
parents:
diff changeset
798 button.setActionCommand("Button");
prymula <prymula76@outlook.com>
parents:
diff changeset
799
prymula <prymula76@outlook.com>
parents:
diff changeset
800 text = new JTextField();
prymula <prymula76@outlook.com>
parents:
diff changeset
801 //text.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
802 //text.setActionCommand("Text");
prymula <prymula76@outlook.com>
parents:
diff changeset
803
prymula <prymula76@outlook.com>
parents:
diff changeset
804 text.addKeyListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
805 text.setFocusable(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
806 text.requestFocus();
prymula <prymula76@outlook.com>
parents:
diff changeset
807
prymula <prymula76@outlook.com>
parents:
diff changeset
808 c.fill = GridBagConstraints.HORIZONTAL;
prymula <prymula76@outlook.com>
parents:
diff changeset
809 c.ipady = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
810 c.weighty = 1.0;
prymula <prymula76@outlook.com>
parents:
diff changeset
811 c.gridwidth = 3;
prymula <prymula76@outlook.com>
parents:
diff changeset
812 c.gridx = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
813 c.gridy = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
814 frame.getContentPane().add(label2,c);
prymula <prymula76@outlook.com>
parents:
diff changeset
815
prymula <prymula76@outlook.com>
parents:
diff changeset
816 c.fill = GridBagConstraints.HORIZONTAL;
prymula <prymula76@outlook.com>
parents:
diff changeset
817 c.ipady = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
818 c.weighty = 1.0;
prymula <prymula76@outlook.com>
parents:
diff changeset
819 c.gridwidth = 3;
prymula <prymula76@outlook.com>
parents:
diff changeset
820 c.gridx = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
821 c.gridy = 1;
prymula <prymula76@outlook.com>
parents:
diff changeset
822 frame.getContentPane().add(text,c);
prymula <prymula76@outlook.com>
parents:
diff changeset
823
prymula <prymula76@outlook.com>
parents:
diff changeset
824 c.fill = GridBagConstraints.HORIZONTAL;
prymula <prymula76@outlook.com>
parents:
diff changeset
825 c.ipady = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
826 c.weighty = 1.0;
prymula <prymula76@outlook.com>
parents:
diff changeset
827 c.gridwidth = 3;
prymula <prymula76@outlook.com>
parents:
diff changeset
828 c.gridx = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
829 c.gridy = 2;
prymula <prymula76@outlook.com>
parents:
diff changeset
830 frame.getContentPane().add(label1,c);
prymula <prymula76@outlook.com>
parents:
diff changeset
831
prymula <prymula76@outlook.com>
parents:
diff changeset
832 c.fill = GridBagConstraints.HORIZONTAL;
prymula <prymula76@outlook.com>
parents:
diff changeset
833 c.ipady = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
834 c.weighty = 1.0;
prymula <prymula76@outlook.com>
parents:
diff changeset
835 c.anchor = GridBagConstraints.PAGE_END; //bottom of space
prymula <prymula76@outlook.com>
parents:
diff changeset
836 c.gridwidth = 3;
prymula <prymula76@outlook.com>
parents:
diff changeset
837 c.gridx = 0;
prymula <prymula76@outlook.com>
parents:
diff changeset
838 c.gridy = 3;
prymula <prymula76@outlook.com>
parents:
diff changeset
839 frame.getContentPane().add(button,c);
prymula <prymula76@outlook.com>
parents:
diff changeset
840 text.setEditable(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
841 if (namePlayer.length()!=0){
prymula <prymula76@outlook.com>
parents:
diff changeset
842 text.setText(namePlayer);
prymula <prymula76@outlook.com>
parents:
diff changeset
843 text.selectAll();
prymula <prymula76@outlook.com>
parents:
diff changeset
844 }
prymula <prymula76@outlook.com>
parents:
diff changeset
845 button.addActionListener(this);
prymula <prymula76@outlook.com>
parents:
diff changeset
846 if (cf.osName.equals("Linux")) frame.setUndecorated(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
847 frame.getRootPane().setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, Color.RED));
prymula <prymula76@outlook.com>
parents:
diff changeset
848 frame.pack();
prymula <prymula76@outlook.com>
parents:
diff changeset
849 frame.setLocationRelativeTo(f);
prymula <prymula76@outlook.com>
parents:
diff changeset
850 frame.setResizable(false);
prymula <prymula76@outlook.com>
parents:
diff changeset
851 frame.setVisible(true);
prymula <prymula76@outlook.com>
parents:
diff changeset
852 }
prymula <prymula76@outlook.com>
parents:
diff changeset
853 }
prymula <prymula76@outlook.com>
parents:
diff changeset
854
prymula <prymula76@outlook.com>
parents:
diff changeset
855 public void actionPerformed(ActionEvent e) {
prymula <prymula76@outlook.com>
parents:
diff changeset
856 if(e.getActionCommand().equals("Button")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
857
prymula <prymula76@outlook.com>
parents:
diff changeset
858 frame.setVisible(false);
prymula <prymula76@outlook.com>
parents:
diff changeset
859 namePlayer=text.getText();
prymula <prymula76@outlook.com>
parents:
diff changeset
860 runGetNameDialog=false;
prymula <prymula76@outlook.com>
parents:
diff changeset
861 if (namePlayer.length()!=0){
prymula <prymula76@outlook.com>
parents:
diff changeset
862 go=true;
prymula <prymula76@outlook.com>
parents:
diff changeset
863 }
prymula <prymula76@outlook.com>
parents:
diff changeset
864 }
prymula <prymula76@outlook.com>
parents:
diff changeset
865 else if(e.getActionCommand().equals("Text")) {
prymula <prymula76@outlook.com>
parents:
diff changeset
866
prymula <prymula76@outlook.com>
parents:
diff changeset
867 String t= text.getText();
prymula <prymula76@outlook.com>
parents:
diff changeset
868 text.setText(t);
prymula <prymula76@outlook.com>
parents:
diff changeset
869 text.selectAll();
prymula <prymula76@outlook.com>
parents:
diff changeset
870
prymula <prymula76@outlook.com>
parents:
diff changeset
871 }
prymula <prymula76@outlook.com>
parents:
diff changeset
872 }
prymula <prymula76@outlook.com>
parents:
diff changeset
873
prymula <prymula76@outlook.com>
parents:
diff changeset
874 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
875 public void keyTyped(KeyEvent e) {
prymula <prymula76@outlook.com>
parents:
diff changeset
876 }
prymula <prymula76@outlook.com>
parents:
diff changeset
877
prymula <prymula76@outlook.com>
parents:
diff changeset
878 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
879 public void keyReleased(KeyEvent event) {
prymula <prymula76@outlook.com>
parents:
diff changeset
880 }
prymula <prymula76@outlook.com>
parents:
diff changeset
881
prymula <prymula76@outlook.com>
parents:
diff changeset
882 @Override
prymula <prymula76@outlook.com>
parents:
diff changeset
883 public void keyPressed(KeyEvent event) {
prymula <prymula76@outlook.com>
parents:
diff changeset
884 if (event.getExtendedKeyCode() == KeyEvent.getExtendedKeyCodeForChar('a')) {
prymula <prymula76@outlook.com>
parents:
diff changeset
885 System.out.println("OK");
prymula <prymula76@outlook.com>
parents:
diff changeset
886 }
prymula <prymula76@outlook.com>
parents:
diff changeset
887 System.out.println("GETNAME");
prymula <prymula76@outlook.com>
parents:
diff changeset
888 String t= text.getText();
prymula <prymula76@outlook.com>
parents:
diff changeset
889 text.setText(t);
prymula <prymula76@outlook.com>
parents:
diff changeset
890 text.selectAll();
prymula <prymula76@outlook.com>
parents:
diff changeset
891 }
prymula <prymula76@outlook.com>
parents:
diff changeset
892 }
prymula <prymula76@outlook.com>
parents:
diff changeset
893
prymula <prymula76@outlook.com>
parents:
diff changeset
894 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
895 private void readConfig() {
prymula <prymula76@outlook.com>
parents:
diff changeset
896
prymula <prymula76@outlook.com>
parents:
diff changeset
897
prymula <prymula76@outlook.com>
parents:
diff changeset
898 try {
prymula <prymula76@outlook.com>
parents:
diff changeset
899 InputStream is = this.getClass().getResourceAsStream("/config");
prymula <prymula76@outlook.com>
parents:
diff changeset
900 BufferedReader br=new BufferedReader(new InputStreamReader(is, "utf-8"));
prymula <prymula76@outlook.com>
parents:
diff changeset
901
prymula <prymula76@outlook.com>
parents:
diff changeset
902 lineConfig = br.readLine();
prymula <prymula76@outlook.com>
parents:
diff changeset
903 } catch (Exception e){
prymula <prymula76@outlook.com>
parents:
diff changeset
904 e.printStackTrace();
prymula <prymula76@outlook.com>
parents:
diff changeset
905 }
prymula <prymula76@outlook.com>
parents:
diff changeset
906 }
prymula <prymula76@outlook.com>
parents:
diff changeset
907 */
prymula <prymula76@outlook.com>
parents:
diff changeset
908 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
909 private void writeConfig() {
prymula <prymula76@outlook.com>
parents:
diff changeset
910
prymula <prymula76@outlook.com>
parents:
diff changeset
911
prymula <prymula76@outlook.com>
parents:
diff changeset
912 try {
prymula <prymula76@outlook.com>
parents:
diff changeset
913 OutputStream is = this.getClass().getResourceAsStream("/config");
prymula <prymula76@outlook.com>
parents:
diff changeset
914 BufferedReader br=new BufferedReader(new InputStreamReader(is, "utf-8"));
prymula <prymula76@outlook.com>
parents:
diff changeset
915
prymula <prymula76@outlook.com>
parents:
diff changeset
916 lineConfig = br.readLine();
prymula <prymula76@outlook.com>
parents:
diff changeset
917 } catch (Exception e){
prymula <prymula76@outlook.com>
parents:
diff changeset
918 e.printStackTrace();
prymula <prymula76@outlook.com>
parents:
diff changeset
919 }
prymula <prymula76@outlook.com>
parents:
diff changeset
920 }
prymula <prymula76@outlook.com>
parents:
diff changeset
921 */
23
489244127359 kopieckreta-0.240903-0
Przemyslaw <prymula76@outlook.com>
parents: 0
diff changeset
922 //}