Browse Source

Initial Commit, first release

seba 11 years ago
commit
1ea8b01057
23 changed files with 2558 additions and 0 deletions
  1. 3
    0
      .gitignore
  2. 328
    0
      Makefile
  3. 46
    0
      about.cpp
  4. 43
    0
      about.h
  5. 58
    0
      creategame.cpp
  6. 59
    0
      creategame.h
  7. 348
    0
      findserver.cpp
  8. 84
    0
      findserver.h
  9. 339
    0
      gpl-2.0.txt
  10. 39
    0
      main.cpp
  11. 87
    0
      newgame.cpp
  12. 60
    0
      newgame.h
  13. 45
    0
      playerwait.cpp
  14. 49
    0
      playerwait.h
  15. 108
    0
      renderarea.cpp
  16. 56
    0
      renderarea.h
  17. 84
    0
      selectmaster.cpp
  18. 61
    0
      selectmaster.h
  19. BIN
      trans/viergewinnt-qt_en.qm
  20. 341
    0
      trans/viergewinnt-qt_en.ts
  21. 33
    0
      viergewinnt-qt.pro
  22. 195
    0
      viergewinnt.cpp
  23. 92
    0
      viergewinnt.h

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
1
+*.o
2
+moc_*
3
+viergewinnt-qt

+ 328
- 0
Makefile View File

@@ -0,0 +1,328 @@
1
+#############################################################################
2
+# Makefile for building: viergewinnt-qt
3
+# Generated by qmake (2.01a) (Qt 4.4.3) on: Sa Nov 1 16:10:13 2008
4
+# Project:  viergewinnt-qt.pro
5
+# Template: app
6
+# Command: /usr/bin/qmake -unix -o Makefile viergewinnt-qt.pro
7
+#############################################################################
8
+
9
+####### Compiler, tools and options
10
+
11
+CC            = gcc
12
+CXX           = g++
13
+DEFINES       = -DQT_NO_DEBUG_OUTPUT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED
14
+CFLAGS        = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
15
+CXXFLAGS      = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
16
+INCPATH       = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtNetwork -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -I.
17
+LINK          = g++
18
+LFLAGS        = 
19
+LIBS          = $(SUBLIBS)  -L/usr/lib -lQtGui -lQtNetwork -lQtCore -lpthread
20
+AR            = ar cqs
21
+RANLIB        = 
22
+QMAKE         = /usr/bin/qmake
23
+TAR           = tar -cf
24
+COMPRESS      = gzip -9f
25
+COPY          = cp -f
26
+SED           = sed
27
+COPY_FILE     = $(COPY)
28
+COPY_DIR      = $(COPY) -r
29
+INSTALL_FILE  = install -m 644 -p
30
+INSTALL_DIR   = $(COPY_DIR)
31
+INSTALL_PROGRAM = install -m 755 -p
32
+DEL_FILE      = rm -f
33
+SYMLINK       = ln -sf
34
+DEL_DIR       = rmdir
35
+MOVE          = mv -f
36
+CHK_DIR_EXISTS= test -d
37
+MKDIR         = mkdir -p
38
+
39
+####### Output directory
40
+
41
+OBJECTS_DIR   = ./
42
+
43
+####### Files
44
+
45
+SOURCES       = about.cpp \
46
+		creategame.cpp \
47
+		findserver.cpp \
48
+		main.cpp \
49
+		newgame.cpp \
50
+		playerwait.cpp \
51
+		renderarea.cpp \
52
+		selectmaster.cpp \
53
+		viergewinnt.cpp moc_about.cpp \
54
+		moc_creategame.cpp \
55
+		moc_findserver.cpp \
56
+		moc_newgame.cpp \
57
+		moc_playerwait.cpp \
58
+		moc_renderarea.cpp \
59
+		moc_selectmaster.cpp \
60
+		moc_viergewinnt.cpp
61
+OBJECTS       = about.o \
62
+		creategame.o \
63
+		findserver.o \
64
+		main.o \
65
+		newgame.o \
66
+		playerwait.o \
67
+		renderarea.o \
68
+		selectmaster.o \
69
+		viergewinnt.o \
70
+		moc_about.o \
71
+		moc_creategame.o \
72
+		moc_findserver.o \
73
+		moc_newgame.o \
74
+		moc_playerwait.o \
75
+		moc_renderarea.o \
76
+		moc_selectmaster.o \
77
+		moc_viergewinnt.o
78
+DIST          = /usr/share/qt4/mkspecs/common/g++.conf \
79
+		/usr/share/qt4/mkspecs/common/unix.conf \
80
+		/usr/share/qt4/mkspecs/common/linux.conf \
81
+		/usr/share/qt4/mkspecs/qconfig.pri \
82
+		/usr/share/qt4/mkspecs/features/qt_functions.prf \
83
+		/usr/share/qt4/mkspecs/features/qt_config.prf \
84
+		/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
85
+		/usr/share/qt4/mkspecs/features/default_pre.prf \
86
+		/usr/share/qt4/mkspecs/features/release.prf \
87
+		/usr/share/qt4/mkspecs/features/default_post.prf \
88
+		/usr/share/qt4/mkspecs/features/warn_on.prf \
89
+		/usr/share/qt4/mkspecs/features/qt.prf \
90
+		/usr/share/qt4/mkspecs/features/unix/thread.prf \
91
+		/usr/share/qt4/mkspecs/features/moc.prf \
92
+		/usr/share/qt4/mkspecs/features/resources.prf \
93
+		/usr/share/qt4/mkspecs/features/uic.prf \
94
+		/usr/share/qt4/mkspecs/features/yacc.prf \
95
+		/usr/share/qt4/mkspecs/features/lex.prf \
96
+		viergewinnt-qt.pro
97
+QMAKE_TARGET  = viergewinnt-qt
98
+DESTDIR       = 
99
+TARGET        = viergewinnt-qt
100
+
101
+first: all
102
+####### Implicit rules
103
+
104
+.SUFFIXES: .o .c .cpp .cc .cxx .C
105
+
106
+.cpp.o:
107
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
108
+
109
+.cc.o:
110
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
111
+
112
+.cxx.o:
113
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
114
+
115
+.C.o:
116
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
117
+
118
+.c.o:
119
+	$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
120
+
121
+####### Build rules
122
+
123
+all: Makefile $(TARGET)
124
+
125
+$(TARGET):  $(OBJECTS)  
126
+	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
127
+
128
+Makefile: viergewinnt-qt.pro  /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \
129
+		/usr/share/qt4/mkspecs/common/unix.conf \
130
+		/usr/share/qt4/mkspecs/common/linux.conf \
131
+		/usr/share/qt4/mkspecs/qconfig.pri \
132
+		/usr/share/qt4/mkspecs/features/qt_functions.prf \
133
+		/usr/share/qt4/mkspecs/features/qt_config.prf \
134
+		/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
135
+		/usr/share/qt4/mkspecs/features/default_pre.prf \
136
+		/usr/share/qt4/mkspecs/features/release.prf \
137
+		/usr/share/qt4/mkspecs/features/default_post.prf \
138
+		/usr/share/qt4/mkspecs/features/warn_on.prf \
139
+		/usr/share/qt4/mkspecs/features/qt.prf \
140
+		/usr/share/qt4/mkspecs/features/unix/thread.prf \
141
+		/usr/share/qt4/mkspecs/features/moc.prf \
142
+		/usr/share/qt4/mkspecs/features/resources.prf \
143
+		/usr/share/qt4/mkspecs/features/uic.prf \
144
+		/usr/share/qt4/mkspecs/features/yacc.prf \
145
+		/usr/share/qt4/mkspecs/features/lex.prf \
146
+		/usr/lib/libQtGui.prl \
147
+		/usr/lib/libQtNetwork.prl \
148
+		/usr/lib/libQtCore.prl
149
+	$(QMAKE) -unix -o Makefile viergewinnt-qt.pro
150
+/usr/share/qt4/mkspecs/common/g++.conf:
151
+/usr/share/qt4/mkspecs/common/unix.conf:
152
+/usr/share/qt4/mkspecs/common/linux.conf:
153
+/usr/share/qt4/mkspecs/qconfig.pri:
154
+/usr/share/qt4/mkspecs/features/qt_functions.prf:
155
+/usr/share/qt4/mkspecs/features/qt_config.prf:
156
+/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
157
+/usr/share/qt4/mkspecs/features/default_pre.prf:
158
+/usr/share/qt4/mkspecs/features/release.prf:
159
+/usr/share/qt4/mkspecs/features/default_post.prf:
160
+/usr/share/qt4/mkspecs/features/warn_on.prf:
161
+/usr/share/qt4/mkspecs/features/qt.prf:
162
+/usr/share/qt4/mkspecs/features/unix/thread.prf:
163
+/usr/share/qt4/mkspecs/features/moc.prf:
164
+/usr/share/qt4/mkspecs/features/resources.prf:
165
+/usr/share/qt4/mkspecs/features/uic.prf:
166
+/usr/share/qt4/mkspecs/features/yacc.prf:
167
+/usr/share/qt4/mkspecs/features/lex.prf:
168
+/usr/lib/libQtGui.prl:
169
+/usr/lib/libQtNetwork.prl:
170
+/usr/lib/libQtCore.prl:
171
+qmake:  FORCE
172
+	@$(QMAKE) -unix -o Makefile viergewinnt-qt.pro
173
+
174
+dist: 
175
+	@$(CHK_DIR_EXISTS) .tmp/viergewinnt-qt1.0.0 || $(MKDIR) .tmp/viergewinnt-qt1.0.0 
176
+	$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/viergewinnt-qt1.0.0/ && $(COPY_FILE) --parents about.h creategame.h findserver.h newgame.h playerwait.h renderarea.h selectmaster.h viergewinnt.h .tmp/viergewinnt-qt1.0.0/ && $(COPY_FILE) --parents about.cpp creategame.cpp findserver.cpp main.cpp newgame.cpp playerwait.cpp renderarea.cpp selectmaster.cpp viergewinnt.cpp .tmp/viergewinnt-qt1.0.0/ && $(COPY_FILE) --parents viergewinnt-qt_en.ts .tmp/viergewinnt-qt1.0.0/ && (cd `dirname .tmp/viergewinnt-qt1.0.0` && $(TAR) viergewinnt-qt1.0.0.tar viergewinnt-qt1.0.0 && $(COMPRESS) viergewinnt-qt1.0.0.tar) && $(MOVE) `dirname .tmp/viergewinnt-qt1.0.0`/viergewinnt-qt1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/viergewinnt-qt1.0.0
177
+
178
+
179
+clean:compiler_clean 
180
+	-$(DEL_FILE) $(OBJECTS)
181
+	-$(DEL_FILE) *~ core *.core
182
+
183
+
184
+####### Sub-libraries
185
+
186
+distclean: clean
187
+	-$(DEL_FILE) $(TARGET) 
188
+	-$(DEL_FILE) Makefile
189
+
190
+
191
+mocclean: compiler_moc_header_clean compiler_moc_source_clean
192
+
193
+mocables: compiler_moc_header_make_all compiler_moc_source_make_all
194
+
195
+compiler_moc_header_make_all: moc_about.cpp moc_creategame.cpp moc_findserver.cpp moc_newgame.cpp moc_playerwait.cpp moc_renderarea.cpp moc_selectmaster.cpp moc_viergewinnt.cpp
196
+compiler_moc_header_clean:
197
+	-$(DEL_FILE) moc_about.cpp moc_creategame.cpp moc_findserver.cpp moc_newgame.cpp moc_playerwait.cpp moc_renderarea.cpp moc_selectmaster.cpp moc_viergewinnt.cpp
198
+moc_about.cpp: about.h
199
+	/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) about.h -o moc_about.cpp
200
+
201
+moc_creategame.cpp: creategame.h
202
+	/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) creategame.h -o moc_creategame.cpp
203
+
204
+moc_findserver.cpp: selectmaster.h \
205
+		creategame.h \
206
+		viergewinnt.h \
207
+		newgame.h \
208
+		playerwait.h \
209
+		about.h \
210
+		findserver.h
211
+	/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) findserver.h -o moc_findserver.cpp
212
+
213
+moc_newgame.cpp: newgame.h
214
+	/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) newgame.h -o moc_newgame.cpp
215
+
216
+moc_playerwait.cpp: playerwait.h
217
+	/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) playerwait.h -o moc_playerwait.cpp
218
+
219
+moc_renderarea.cpp: viergewinnt.h \
220
+		newgame.h \
221
+		playerwait.h \
222
+		renderarea.h
223
+	/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) renderarea.h -o moc_renderarea.cpp
224
+
225
+moc_selectmaster.cpp: selectmaster.h
226
+	/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) selectmaster.h -o moc_selectmaster.cpp
227
+
228
+moc_viergewinnt.cpp: newgame.h \
229
+		playerwait.h \
230
+		viergewinnt.h
231
+	/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) viergewinnt.h -o moc_viergewinnt.cpp
232
+
233
+compiler_rcc_make_all:
234
+compiler_rcc_clean:
235
+compiler_image_collection_make_all: qmake_image_collection.cpp
236
+compiler_image_collection_clean:
237
+	-$(DEL_FILE) qmake_image_collection.cpp
238
+compiler_moc_source_make_all:
239
+compiler_moc_source_clean:
240
+compiler_uic_make_all:
241
+compiler_uic_clean:
242
+compiler_yacc_decl_make_all:
243
+compiler_yacc_decl_clean:
244
+compiler_yacc_impl_make_all:
245
+compiler_yacc_impl_clean:
246
+compiler_lex_make_all:
247
+compiler_lex_clean:
248
+compiler_clean: compiler_moc_header_clean 
249
+
250
+####### Compile
251
+
252
+about.o: about.cpp about.h
253
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o about.o about.cpp
254
+
255
+creategame.o: creategame.cpp creategame.h
256
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o creategame.o creategame.cpp
257
+
258
+findserver.o: findserver.cpp findserver.h \
259
+		selectmaster.h \
260
+		creategame.h \
261
+		viergewinnt.h \
262
+		newgame.h \
263
+		playerwait.h \
264
+		about.h
265
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o findserver.o findserver.cpp
266
+
267
+main.o: main.cpp findserver.h \
268
+		selectmaster.h \
269
+		creategame.h \
270
+		viergewinnt.h \
271
+		newgame.h \
272
+		playerwait.h \
273
+		about.h
274
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
275
+
276
+newgame.o: newgame.cpp newgame.h
277
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o newgame.o newgame.cpp
278
+
279
+playerwait.o: playerwait.cpp playerwait.h
280
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o playerwait.o playerwait.cpp
281
+
282
+renderarea.o: renderarea.cpp renderarea.h \
283
+		viergewinnt.h \
284
+		newgame.h \
285
+		playerwait.h
286
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o renderarea.o renderarea.cpp
287
+
288
+selectmaster.o: selectmaster.cpp selectmaster.h
289
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o selectmaster.o selectmaster.cpp
290
+
291
+viergewinnt.o: viergewinnt.cpp viergewinnt.h \
292
+		newgame.h \
293
+		playerwait.h \
294
+		renderarea.h
295
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o viergewinnt.o viergewinnt.cpp
296
+
297
+moc_about.o: moc_about.cpp 
298
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_about.o moc_about.cpp
299
+
300
+moc_creategame.o: moc_creategame.cpp 
301
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_creategame.o moc_creategame.cpp
302
+
303
+moc_findserver.o: moc_findserver.cpp 
304
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_findserver.o moc_findserver.cpp
305
+
306
+moc_newgame.o: moc_newgame.cpp 
307
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_newgame.o moc_newgame.cpp
308
+
309
+moc_playerwait.o: moc_playerwait.cpp 
310
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_playerwait.o moc_playerwait.cpp
311
+
312
+moc_renderarea.o: moc_renderarea.cpp 
313
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_renderarea.o moc_renderarea.cpp
314
+
315
+moc_selectmaster.o: moc_selectmaster.cpp 
316
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_selectmaster.o moc_selectmaster.cpp
317
+
318
+moc_viergewinnt.o: moc_viergewinnt.cpp 
319
+	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_viergewinnt.o moc_viergewinnt.cpp
320
+
321
+####### Install
322
+
323
+install:   FORCE
324
+
325
+uninstall:   FORCE
326
+
327
+FORCE:
328
+

+ 46
- 0
about.cpp View File

@@ -0,0 +1,46 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#include "about.h"
23
+
24
+AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent) {
25
+// 	setFixedSize(320, 200);
26
+	setWindowTitle(tr("Über"));
27
+	setModal(Qt::WindowModal);
28
+	
29
+	ok = new QPushButton(tr("Ok"));
30
+	connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
31
+	head = new QLabel(tr("Netzwerk-VierGewinnt Client\nProgrammiert von seba\nwww.seba-geek.de"));
32
+	head->setAlignment(Qt::AlignHCenter);
33
+	body = new QLabel(tr("Erstes QT-Programm!\nDies ist ein Client für das VierGewinnt-Modul vom \"Generic Network-Server\". Endlich eine Verbesserung zum SDL-Client..."));
34
+	body->setWordWrap(true);
35
+	 
36
+	layout = new QVBoxLayout;
37
+	
38
+	layout->addWidget(head);
39
+	layout->addSpacing(32);
40
+	layout->addWidget(body);
41
+	layout->addWidget(ok);
42
+	
43
+	layout->setAlignment(head, Qt::AlignHCenter);
44
+	
45
+	setLayout(layout);
46
+}

+ 43
- 0
about.h View File

@@ -0,0 +1,43 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#ifndef __ABOUT_H
23
+#define __ABOUT_H
24
+
25
+#include <QDialog>
26
+#include <QPushButton>
27
+#include <QVBoxLayout>
28
+#include <QLabel>
29
+
30
+class AboutDialog : public QDialog {
31
+	Q_OBJECT
32
+
33
+	public:
34
+		AboutDialog(QWidget *parent=0);
35
+	
36
+	private:
37
+		QPushButton *ok;
38
+		QLabel *head;
39
+		QLabel *body;
40
+		QVBoxLayout *layout;
41
+};
42
+
43
+#endif

+ 58
- 0
creategame.cpp View File

@@ -0,0 +1,58 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#include "creategame.h"
23
+
24
+CreateGameDialog::CreateGameDialog(QTcpSocket *_mysock, QWidget *parent) : QDialog(parent) {
25
+	mysock = _mysock;
26
+	setWindowTitle(tr("Neues Spiel"));
27
+	
28
+// 	stat = new QLabel("");
29
+	gname = new QLabel(tr("Spielname"));
30
+	editgname = new QLineEdit;
31
+	ok = new QPushButton(tr("Ok"));
32
+	connect(ok, SIGNAL(clicked()), this, SLOT(startListen()));
33
+	cancel = new QPushButton(tr("Abbrechen"));
34
+	connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
35
+	
36
+	layout = new QGridLayout;
37
+// 	layout->addWidget(stat, 0, 0, 1, 2);
38
+	layout->addWidget(gname, 1, 0);
39
+	layout->addWidget(editgname, 1, 1);
40
+	layout->addWidget(ok, 2, 0);
41
+	layout->addWidget(cancel, 2, 1);
42
+	
43
+	setLayout(layout);
44
+	setModal(Qt::WindowModal);
45
+}
46
+
47
+// void CreateGameDialog::reset() {
48
+// 	stat->setText("");
49
+// 	ok->show();
50
+// }
51
+
52
+void CreateGameDialog::startListen() {
53
+	QTextStream sockstream(mysock);
54
+	if(editgname->text()=="")
55
+		editgname->insert(tr("Unbenanntes Spiel"));
56
+	sockstream << "CREATE " << editgname->text() << "\n";
57
+	accept();
58
+}

+ 59
- 0
creategame.h View File

@@ -0,0 +1,59 @@
1
+#ifndef __CREATEGAME_H
2
+/* VierGewinnt - A simple 4-in-a-row network game
3
+ *
4
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
5
+ *      http://www.seba-geek.de
6
+ *
7
+ *  This file is part of VierGewinnt.
8
+ *
9
+ *  VierGewinnt is free software: you can redistribute it and/or modify
10
+ *  it under the terms of the GNU General Public License as published by
11
+ *  the Free Software Foundation, either version 2 of the License, or
12
+ *  (at your option) any later version.
13
+ *
14
+ *  VierGewinnt is distributed in the hope that it will be useful,
15
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ *  GNU General Public License for more details.
18
+ *
19
+ *  You should have received a copy of the GNU General Public License
20
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
21
+ */
22
+
23
+#define __CREATEGAME_H
24
+
25
+#include <QDialog>
26
+#include <QString>
27
+#include <QLabel>
28
+#include <QLineEdit>
29
+#include <QGridLayout>
30
+#include <QPushButton>
31
+#include <QMessageBox>
32
+#include <QTextStream>
33
+#include <QTcpSocket>
34
+#include <sstream>
35
+
36
+
37
+class CreateGameDialog : public QDialog {
38
+	Q_OBJECT
39
+	public:
40
+		CreateGameDialog(QTcpSocket *_mysock, QWidget *parent=0);
41
+		
42
+// 		void reset();
43
+		
44
+	private slots:
45
+		void startListen();
46
+		
47
+	private:
48
+		QTcpSocket *mysock;
49
+	
50
+		QGridLayout *layout;
51
+// 		QLabel *stat;
52
+		QLabel *gname;
53
+		QLineEdit *editgname;
54
+		QPushButton *ok;
55
+		QPushButton *cancel;
56
+	
57
+};
58
+
59
+#endif

+ 348
- 0
findserver.cpp View File

@@ -0,0 +1,348 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#include "findserver.h"
23
+
24
+#include <QtNetwork>
25
+#include <QDataStream>
26
+#include <QtDebug>
27
+
28
+FindServerWidget::FindServerWidget(QWidget *parent) : QWidget(parent) {
29
+	setFixedSize(640, 480);
30
+	setWindowTitle(tr("Sebas Netzwerk-VierGewinnt Client")+" - "+tr("Serverliste"));
31
+	masterserver = "1.proj.seba-geek.de"; // srv1.proj.seba-geek.de
32
+	masterport = 31415;
33
+	
34
+	// net stuff
35
+	mysock = new QTcpSocket;
36
+	connect(mysock, SIGNAL(connected()), this, SLOT(procNet()));
37
+	connect(mysock, SIGNAL(readyRead()), this, SLOT(procNet()));
38
+	connect(mysock, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(procNetError(QAbstractSocket::SocketError)));
39
+	connect(mysock, SIGNAL(disconnected()), this, SLOT(procNetDisconnect()));
40
+	
41
+	// dialoge
42
+	masterdialog = new SelectMasterDialog(this);
43
+	cgamedialog = new CreateGameDialog(mysock); /* , this */
44
+	vwinwid = new VierGewinntWidget(mysock, this);
45
+	about = new AboutDialog(this);
46
+
47
+	// networkbrowser
48
+	nettable = new QTreeWidget;
49
+	nettable->setColumnCount(5);
50
+// 	nettable->setMaximumWidth(400);
51
+	QStringList header;
52
+	header << tr("Id") << tr("Spielname") << tr("Spieler") << tr("Spielfeld") << tr("Gewinnt") << "";
53
+	nettable->setHeaderLabels(header);
54
+// 	nettable->resizeColumnToContents(0);
55
+// 	nettable->resizeColumnToContents(1);
56
+// 	nettable->resizeColumnToContents(2);
57
+	
58
+	// buttonreihe
59
+	buttonrow = new QHBoxLayout;
60
+	refresh = new QPushButton(tr("Erneuern"));
61
+	connect(refresh, SIGNAL(clicked()), this, SLOT(refreshServerList()));
62
+	create = new QPushButton(tr("Erstellen"));
63
+	connect(create, SIGNAL(clicked()), this, SLOT(createGame()));
64
+	join = new QPushButton(tr("Beitreten"));
65
+	connect(join, SIGNAL(clicked()), this, SLOT(joinGame()));
66
+	othermaster = new QPushButton(tr("Anderer Masterserver"));
67
+	connect(othermaster, SIGNAL(clicked()), this, SLOT(changeMaster()));
68
+	butabout = new QPushButton(tr("Über"));
69
+	connect(butabout, SIGNAL(clicked()), about, SLOT(exec()));
70
+	
71
+	
72
+	
73
+	buttonrow->addWidget(refresh);
74
+	buttonrow->addWidget(create);
75
+	buttonrow->addWidget(join);
76
+	buttonrow->addStretch();
77
+	buttonrow->addWidget(othermaster);
78
+	buttonrow->addWidget(butabout);
79
+
80
+	
81
+	// network drunter
82
+	status = new QTextEdit;
83
+	status->setReadOnly(true);
84
+	status->setMaximumHeight(80);
85
+	addLog(tr("Drücke Erneuern um eine Serverliste zu erhalten"));
86
+	
87
+	// layout stuff
88
+	layout = new QVBoxLayout;
89
+	
90
+	layout->addWidget(nettable);
91
+	layout->addLayout(buttonrow);
92
+	layout->addWidget(status);
93
+	
94
+	setLayout(layout);
95
+	
96
+	loginstate = 0;
97
+	refreshonconnect = false;
98
+	ingame = false;
99
+}
100
+
101
+void FindServerWidget::refreshServerList() {
102
+	if(mysock->state()==QTcpSocket::UnconnectedState) {
103
+		refreshonconnect = true;
104
+		startConnect();
105
+	} else {
106
+		QTextStream sockstream(mysock);
107
+		addLog(tr("Fordere Liste an..."));
108
+		nettable->clear();
109
+		sockstream << "LIST\n";
110
+	}
111
+}
112
+
113
+void FindServerWidget::changeMaster() {
114
+// 	this->hide();
115
+	masterdialog->setData(masterserver, masterport);
116
+	masterdialog->show();
117
+	if(masterdialog->exec()== QDialog::Accepted) {
118
+		masterserver = masterdialog->getMasterServer();
119
+		masterport = masterdialog->getMasterPort();
120
+		mysock->close();
121
+		startConnect();
122
+	}
123
+}
124
+
125
+void FindServerWidget::createGame() {
126
+	if(mysock->state()==QTcpSocket::UnconnectedState)
127
+		startConnect();
128
+// 	this->setDisabled(true);
129
+// 	this->hide();
130
+// 	cgamedialog->reset();
131
+	cgamedialog->show();
132
+	if(cgamedialog->exec()== QDialog::Accepted) {
133
+		addLog(tr("Spiel erstellt"));
134
+		vwinwid->init(7, 6);		
135
+		qDebug() << "i am still here!";
136
+	} else {
137
+// 		this->setDisabled(false);
138
+// 		mysock->close();
139
+	}
140
+// 	this->show();
141
+}
142
+
143
+void FindServerWidget::joinGame() {
144
+	QTreeWidgetItem *myitem = nettable->currentItem();
145
+	if(myitem==0) {
146
+		QMessageBox msgbox(this);
147
+		msgbox.setText(tr("Es wurde kein Spiel zum beitreten ausgewählt"));
148
+		msgbox.exec();
149
+		return;
150
+	}
151
+	
152
+	if(mysock->state()==QTcpSocket::UnconnectedState)
153
+		startConnect();
154
+	
155
+	// initing the field (here we have the data)
156
+	vwinwid->init(7, 6); // to be changed when custom fields are allowed
157
+	
158
+	// get id
159
+	int gameid = myitem->text(0).toInt();
160
+	addLog(tr("Trete Spiel bei.."));
161
+	QTextStream mytext(mysock);
162
+	mytext << "JOIN " << gameid << "\n";
163
+}
164
+
165
+void FindServerWidget::procNet() {
166
+	QTextStream sockstream(mysock);
167
+	QString tmpbuf;
168
+	switch(loginstate) {
169
+		case 0:{
170
+			sockstream << "VERSION viergewinnt-qt\n";
171
+			loginstate++;
172
+		}break;
173
+		case 1:
174
+			tmpbuf = mysock->readLine();
175
+			if(tmpbuf.contains("ACK VERSION")) {
176
+				addLog(tr("Version akzeptiert"));
177
+				sockstream << "SELECT VierGewinnt\n";
178
+				loginstate++;
179
+			} else {
180
+				addLog(tr("Version nicht akzeptiert, kein GNS-Server!"));
181
+				mysock->close();
182
+			}
183
+		break;
184
+		case 2:
185
+			tmpbuf = mysock->readLine();
186
+			if(tmpbuf.contains("ACK SELECT")) {
187
+				loginstate++;
188
+				addLog(tr("Modul ausgewählt"));
189
+				if(refreshonconnect) {
190
+					refreshServerList();
191
+					
192
+					refreshonconnect = false;
193
+				}
194
+			} else {
195
+				addLog(tr("VierGewinnt-Modul nicht gefunden!"));
196
+				mysock->close();
197
+			}
198
+		break;
199
+		default:
200
+			// list, join or error
201
+// 			tmpbuf = mysock->readLine();
202
+// 			addLog("Got INput: "+sockstream.readLine());
203
+			
204
+			do {
205
+				
206
+				QTextStream sockstream2(mysock->readLine());
207
+				sockstream2 >> tmpbuf;
208
+				
209
+				if(tmpbuf=="ERROR") {
210
+					sockstream2 >> tmpbuf;
211
+					int myerrno = tmpbuf.toInt();
212
+					if(myerrno==121) {
213
+						addLog(tr("Keine Spiele offen :("));
214
+					} else if(myerrno==125) {
215
+						addLog(tr("Konnte nicht beitreten: Spiel voll"));
216
+					} else if(myerrno==124) {
217
+						addLog(tr("Spiel konnte nicht gefunden werden"));
218
+					} else if(tmpbuf=="Not") {
219
+						sockstream2 >> tmpbuf;
220
+						if(tmpbuf=="your") {
221
+							vwinwid->ackAdd(false);
222
+						}
223
+					} else if(tmpbuf=="Row") {
224
+						vwinwid->ackAdd(false);
225
+					} else {
226
+						qDebug() << "Unbekannter Fehler: " << tmpbuf;
227
+// 						addLog(tr("Unbekannter error: ")+tmpbuf);
228
+					}
229
+				} else if(tmpbuf=="GAME") {
230
+					QStringList qstrlst;
231
+					QString tmpbuf2;
232
+					sockstream2 >> tmpbuf;	// id
233
+					qstrlst << tmpbuf;
234
+					sockstream2 >> tmpbuf2;	// player in
235
+					sockstream2 >> tmpbuf;	// player max
236
+					tmpbuf2 += "/";
237
+					tmpbuf2 += tmpbuf;
238
+					sockstream2 >> tmpbuf;	// game's name
239
+					qstrlst << tmpbuf;
240
+					qstrlst << tmpbuf2;
241
+					sockstream2 >> tmpbuf2;	// x
242
+					sockstream2 >> tmpbuf;	// y
243
+					tmpbuf2 += "x";
244
+					tmpbuf2 += tmpbuf;
245
+					qstrlst << tmpbuf2;
246
+					sockstream2 >> tmpbuf;	// for the win
247
+					qstrlst << tmpbuf;
248
+					nettable->addTopLevelItem(new QTreeWidgetItem(qstrlst));
249
+				} else if(tmpbuf=="ACK") {
250
+					sockstream2 >> tmpbuf;
251
+					if(tmpbuf=="CREATE") {
252
+						addLog("Spiel erstellt, warte auf Mitspieler");
253
+						vwinwid->clientExited();
254
+						this->hide();
255
+						vwinwid->show();
256
+					} else if(tmpbuf=="JOIN") {
257
+						// set data to mainwindow
258
+						goToGameWindow();
259
+					} else if(tmpbuf=="ADD") {
260
+						vwinwid->ackAdd(true);
261
+					}
262
+				} else if(tmpbuf=="INFO") {
263
+					sockstream2 >> tmpbuf;
264
+					if(tmpbuf=="START") {
265
+						vwinwid->startGame();
266
+						qDebug() << "Game Started!";
267
+					} else if(tmpbuf=="TURN") {
268
+						sockstream2 >> tmpbuf;
269
+						vwinwid->setTurn(tmpbuf.toInt()==1);
270
+					} else if(tmpbuf=="ADD") {
271
+						sockstream2 >> tmpbuf;
272
+						vwinwid->add(tmpbuf.toInt(), VierGewinntWidget::o);
273
+					} else if(tmpbuf=="GAME") {
274
+						sockstream2 >> tmpbuf;
275
+						if(tmpbuf=="STOP") {
276
+							vwinwid->clientExited();
277
+						}
278
+					} else if(tmpbuf=="STATUS") {
279
+						sockstream2 >> tmpbuf;
280
+						vwinwid->newGame(tmpbuf=="WON");
281
+						// REQ NEW GAME Message ignored, handled here
282
+					} else if(tmpbuf=="CLIENT") {
283
+						sockstream2 >> tmpbuf;
284
+						if(tmpbuf=="NEW") {
285
+							vwinwid->ackNewGame();
286
+						}
287
+					} else if(tmpbuf=="NEW") {
288
+						sockstream2 >> tmpbuf;
289
+						if(tmpbuf=="GAME") {
290
+							vwinwid->startGame();
291
+						}
292
+					} else if(tmpbuf=="SCORE") {
293
+						QString tmpbuf2;
294
+						sockstream2 >> tmpbuf;
295
+						sockstream2 >> tmpbuf2;
296
+						vwinwid->setScore(tmpbuf.toInt(), tmpbuf2.toInt());
297
+					}
298
+				} else {
299
+					qDebug() << "Unhandled TMPBUF: " << tmpbuf;
300
+				}
301
+			} while(!sockstream.atEnd());
302
+		break;
303
+	}
304
+}
305
+
306
+void FindServerWidget::procNetError(QAbstractSocket::SocketError e) {
307
+	switch(e) {
308
+		case QAbstractSocket::HostNotFoundError:
309
+			addLog(tr("Fehler: Der Master-Server Hostname konnte nicht aufgelöst werden!"));
310
+		break;
311
+		case QAbstractSocket::ConnectionRefusedError:
312
+			addLog(tr("Fehler: Verbindungsversuch zum Master-Server ist fehlgeschlagen!"));
313
+		break;
314
+		case QAbstractSocket::RemoteHostClosedError:
315
+			procNetDisconnect();
316
+		break;
317
+		default:
318
+			addLog(tr("Netzwerkfehler: '%1'").arg(mysock->errorString()));
319
+		break;
320
+	}
321
+	qDebug() << "Networ error: " << mysock->errorString();
322
+}
323
+
324
+void FindServerWidget::procNetDisconnect() {
325
+	vwinwid->hide();
326
+	this->show();
327
+	nettable->clear();
328
+	addLog(tr("Die Verbindung zum Masterserver wurde getrennt."));
329
+}
330
+
331
+void FindServerWidget::addLog(QString str) {
332
+	status->append(str);
333
+	qDebug() << "Log: " << str;
334
+}
335
+
336
+void FindServerWidget::startConnect() {
337
+	loginstate = 0;
338
+	ingame = false;
339
+	addLog((tr("Versuche Verbindung zu ")+masterserver+" ..."));
340
+	mysock->connectToHost(masterserver, masterport);
341
+}
342
+
343
+void FindServerWidget::goToGameWindow() {
344
+	qDebug() << "SHOW togamewindow";
345
+	this->hide();
346
+	vwinwid->startGame();
347
+	vwinwid->show();
348
+}

+ 84
- 0
findserver.h View File

@@ -0,0 +1,84 @@
1
+#ifndef __FINDSERVER_H
2
+#define __FINDSERVER_H
3
+
4
+#include <QApplication>
5
+#include <QStringList>
6
+#include <QTreeWidget>
7
+#include <QTextEdit>
8
+/* VierGewinnt - A simple 4-in-a-row network game
9
+ *
10
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
11
+ *      http://www.seba-geek.de
12
+ *
13
+ *  This file is part of VierGewinnt.
14
+ *
15
+ *  VierGewinnt is free software: you can redistribute it and/or modify
16
+ *  it under the terms of the GNU General Public License as published by
17
+ *  the Free Software Foundation, either version 2 of the License, or
18
+ *  (at your option) any later version.
19
+ *
20
+ *  VierGewinnt is distributed in the hope that it will be useful,
21
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
+ *  GNU General Public License for more details.
24
+ *
25
+ *  You should have received a copy of the GNU General Public License
26
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
27
+ */
28
+
29
+#include <QLayout>
30
+#include <QPushButton>
31
+#include <QWidget>
32
+#include <QTcpSocket>
33
+
34
+#include "selectmaster.h"
35
+#include "creategame.h"
36
+#include "viergewinnt.h"
37
+#include "about.h"
38
+
39
+class FindServerWidget : public QWidget {
40
+	Q_OBJECT
41
+
42
+	public:
43
+		FindServerWidget(QWidget *parent=0);
44
+	
45
+	private slots:
46
+		void refreshServerList();
47
+		void changeMaster();
48
+		void createGame();
49
+		void joinGame();
50
+		void procNet();
51
+		void procNetError(QAbstractSocket::SocketError e);
52
+		void procNetDisconnect();
53
+		
54
+	private:
55
+		// main stuff
56
+		void addLog(QString str);
57
+		void startConnect();
58
+		void goToGameWindow();
59
+		
60
+		// gns stuff
61
+		QTcpSocket *mysock;
62
+		QString masterserver;
63
+		int masterport;
64
+		bool ingame;
65
+		bool refreshonconnect;
66
+		int loginstate;
67
+		CreateGameDialog *cgamedialog;
68
+	
69
+		// gui stuff
70
+		QTreeWidget *nettable;
71
+		QHBoxLayout *buttonrow;
72
+		QPushButton *refresh;
73
+		QPushButton *create;
74
+		QPushButton *join;
75
+		QPushButton *othermaster;
76
+		QPushButton *butabout;
77
+		QTextEdit *status;
78
+		SelectMasterDialog *masterdialog;
79
+		QVBoxLayout *layout;
80
+		VierGewinntWidget *vwinwid;
81
+		AboutDialog *about;
82
+};
83
+
84
+#endif

+ 339
- 0
gpl-2.0.txt View File

@@ -0,0 +1,339 @@
1
+		    GNU GENERAL PUBLIC LICENSE
2
+		       Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+			    Preamble
10
+
11
+  The licenses for most software are designed to take away your
12
+freedom to share and change it.  By contrast, the GNU General Public
13
+License is intended to guarantee your freedom to share and change free
14
+software--to make sure the software is free for all its users.  This
15
+General Public License applies to most of the Free Software
16
+Foundation's software and to any other program whose authors commit to
17
+using it.  (Some other Free Software Foundation software is covered by
18
+the GNU Lesser General Public License instead.)  You can apply it to
19
+your programs, too.
20
+
21
+  When we speak of free software, we are referring to freedom, not
22
+price.  Our General Public Licenses are designed to make sure that you
23
+have the freedom to distribute copies of free software (and charge for
24
+this service if you wish), that you receive source code or can get it
25
+if you want it, that you can change the software or use pieces of it
26
+in new free programs; and that you know you can do these things.
27
+
28
+  To protect your rights, we need to make restrictions that forbid
29
+anyone to deny you these rights or to ask you to surrender the rights.
30
+These restrictions translate to certain responsibilities for you if you
31
+distribute copies of the software, or if you modify it.
32
+
33
+  For example, if you distribute copies of such a program, whether
34
+gratis or for a fee, you must give the recipients all the rights that
35
+you have.  You must make sure that they, too, receive or can get the
36
+source code.  And you must show them these terms so they know their
37
+rights.
38
+
39
+  We protect your rights with two steps: (1) copyright the software, and
40
+(2) offer you this license which gives you legal permission to copy,
41
+distribute and/or modify the software.
42
+
43
+  Also, for each author's protection and ours, we want to make certain
44
+that everyone understands that there is no warranty for this free
45
+software.  If the software is modified by someone else and passed on, we
46
+want its recipients to know that what they have is not the original, so
47
+that any problems introduced by others will not reflect on the original
48
+authors' reputations.
49
+
50
+  Finally, any free program is threatened constantly by software
51
+patents.  We wish to avoid the danger that redistributors of a free
52
+program will individually obtain patent licenses, in effect making the
53
+program proprietary.  To prevent this, we have made it clear that any
54
+patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+  The precise terms and conditions for copying, distribution and
57
+modification follow.
58
+
59
+		    GNU GENERAL PUBLIC LICENSE
60
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+  0. This License applies to any program or other work which contains
63
+a notice placed by the copyright holder saying it may be distributed
64
+under the terms of this General Public License.  The "Program", below,
65
+refers to any such program or work, and a "work based on the Program"
66
+means either the Program or any derivative work under copyright law:
67
+that is to say, a work containing the Program or a portion of it,
68
+either verbatim or with modifications and/or translated into another
69
+language.  (Hereinafter, translation is included without limitation in
70
+the term "modification".)  Each licensee is addressed as "you".
71
+
72
+Activities other than copying, distribution and modification are not
73
+covered by this License; they are outside its scope.  The act of
74
+running the Program is not restricted, and the output from the Program
75
+is covered only if its contents constitute a work based on the
76
+Program (independent of having been made by running the Program).
77
+Whether that is true depends on what the Program does.
78
+
79
+  1. You may copy and distribute verbatim copies of the Program's
80
+source code as you receive it, in any medium, provided that you
81
+conspicuously and appropriately publish on each copy an appropriate
82
+copyright notice and disclaimer of warranty; keep intact all the
83
+notices that refer to this License and to the absence of any warranty;
84
+and give any other recipients of the Program a copy of this License
85
+along with the Program.
86
+
87
+You may charge a fee for the physical act of transferring a copy, and
88
+you may at your option offer warranty protection in exchange for a fee.
89
+
90
+  2. You may modify your copy or copies of the Program or any portion
91
+of it, thus forming a work based on the Program, and copy and
92
+distribute such modifications or work under the terms of Section 1
93
+above, provided that you also meet all of these conditions:
94
+
95
+    a) You must cause the modified files to carry prominent notices
96
+    stating that you changed the files and the date of any change.
97
+
98
+    b) You must cause any work that you distribute or publish, that in
99
+    whole or in part contains or is derived from the Program or any
100
+    part thereof, to be licensed as a whole at no charge to all third
101
+    parties under the terms of this License.
102
+
103
+    c) If the modified program normally reads commands interactively
104
+    when run, you must cause it, when started running for such
105
+    interactive use in the most ordinary way, to print or display an
106
+    announcement including an appropriate copyright notice and a
107
+    notice that there is no warranty (or else, saying that you provide
108
+    a warranty) and that users may redistribute the program under
109
+    these conditions, and telling the user how to view a copy of this
110
+    License.  (Exception: if the Program itself is interactive but
111
+    does not normally print such an announcement, your work based on
112
+    the Program is not required to print an announcement.)
113
+
114
+These requirements apply to the modified work as a whole.  If
115
+identifiable sections of that work are not derived from the Program,
116
+and can be reasonably considered independent and separate works in
117
+themselves, then this License, and its terms, do not apply to those
118
+sections when you distribute them as separate works.  But when you
119
+distribute the same sections as part of a whole which is a work based
120
+on the Program, the distribution of the whole must be on the terms of
121
+this License, whose permissions for other licensees extend to the
122
+entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+Thus, it is not the intent of this section to claim rights or contest
125
+your rights to work written entirely by you; rather, the intent is to
126
+exercise the right to control the distribution of derivative or
127
+collective works based on the Program.
128
+
129
+In addition, mere aggregation of another work not based on the Program
130
+with the Program (or with a work based on the Program) on a volume of
131
+a storage or distribution medium does not bring the other work under
132
+the scope of this License.
133
+
134
+  3. You may copy and distribute the Program (or a work based on it,
135
+under Section 2) in object code or executable form under the terms of
136
+Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+    a) Accompany it with the complete corresponding machine-readable
139
+    source code, which must be distributed under the terms of Sections
140
+    1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+    b) Accompany it with a written offer, valid for at least three
143
+    years, to give any third party, for a charge no more than your
144
+    cost of physically performing source distribution, a complete
145
+    machine-readable copy of the corresponding source code, to be
146
+    distributed under the terms of Sections 1 and 2 above on a medium
147
+    customarily used for software interchange; or,
148
+
149
+    c) Accompany it with the information you received as to the offer
150
+    to distribute corresponding source code.  (This alternative is
151
+    allowed only for noncommercial distribution and only if you
152
+    received the program in object code or executable form with such
153
+    an offer, in accord with Subsection b above.)
154
+
155
+The source code for a work means the preferred form of the work for
156
+making modifications to it.  For an executable work, complete source
157
+code means all the source code for all modules it contains, plus any
158
+associated interface definition files, plus the scripts used to
159
+control compilation and installation of the executable.  However, as a
160
+special exception, the source code distributed need not include
161
+anything that is normally distributed (in either source or binary
162
+form) with the major components (compiler, kernel, and so on) of the
163
+operating system on which the executable runs, unless that component
164
+itself accompanies the executable.
165
+
166
+If distribution of executable or object code is made by offering
167
+access to copy from a designated place, then offering equivalent
168
+access to copy the source code from the same place counts as
169
+distribution of the source code, even though third parties are not
170
+compelled to copy the source along with the object code.
171
+
172
+  4. You may not copy, modify, sublicense, or distribute the Program
173
+except as expressly provided under this License.  Any attempt
174
+otherwise to copy, modify, sublicense or distribute the Program is
175
+void, and will automatically terminate your rights under this License.
176
+However, parties who have received copies, or rights, from you under
177
+this License will not have their licenses terminated so long as such
178
+parties remain in full compliance.
179
+
180
+  5. You are not required to accept this License, since you have not
181
+signed it.  However, nothing else grants you permission to modify or
182
+distribute the Program or its derivative works.  These actions are
183
+prohibited by law if you do not accept this License.  Therefore, by
184
+modifying or distributing the Program (or any work based on the
185
+Program), you indicate your acceptance of this License to do so, and
186
+all its terms and conditions for copying, distributing or modifying
187
+the Program or works based on it.
188
+
189
+  6. Each time you redistribute the Program (or any work based on the
190
+Program), the recipient automatically receives a license from the
191
+original licensor to copy, distribute or modify the Program subject to
192
+these terms and conditions.  You may not impose any further
193
+restrictions on the recipients' exercise of the rights granted herein.
194
+You are not responsible for enforcing compliance by third parties to
195
+this License.
196
+
197
+  7. If, as a consequence of a court judgment or allegation of patent
198
+infringement or for any other reason (not limited to patent issues),
199
+conditions are imposed on you (whether by court order, agreement or
200
+otherwise) that contradict the conditions of this License, they do not
201
+excuse you from the conditions of this License.  If you cannot
202
+distribute so as to satisfy simultaneously your obligations under this
203
+License and any other pertinent obligations, then as a consequence you
204
+may not distribute the Program at all.  For example, if a patent
205
+license would not permit royalty-free redistribution of the Program by
206
+all those who receive copies directly or indirectly through you, then
207
+the only way you could satisfy both it and this License would be to
208
+refrain entirely from distribution of the Program.
209
+
210
+If any portion of this section is held invalid or unenforceable under
211
+any particular circumstance, the balance of the section is intended to
212
+apply and the section as a whole is intended to apply in other
213
+circumstances.
214
+
215
+It is not the purpose of this section to induce you to infringe any
216
+patents or other property right claims or to contest validity of any
217
+such claims; this section has the sole purpose of protecting the
218
+integrity of the free software distribution system, which is
219
+implemented by public license practices.  Many people have made
220
+generous contributions to the wide range of software distributed
221
+through that system in reliance on consistent application of that
222
+system; it is up to the author/donor to decide if he or she is willing
223
+to distribute software through any other system and a licensee cannot
224
+impose that choice.
225
+
226
+This section is intended to make thoroughly clear what is believed to
227
+be a consequence of the rest of this License.
228
+
229
+  8. If the distribution and/or use of the Program is restricted in
230
+certain countries either by patents or by copyrighted interfaces, the
231
+original copyright holder who places the Program under this License
232
+may add an explicit geographical distribution limitation excluding
233
+those countries, so that distribution is permitted only in or among
234
+countries not thus excluded.  In such case, this License incorporates
235
+the limitation as if written in the body of this License.
236
+
237
+  9. The Free Software Foundation may publish revised and/or new versions
238
+of the General Public License from time to time.  Such new versions will
239
+be similar in spirit to the present version, but may differ in detail to
240
+address new problems or concerns.
241
+
242
+Each version is given a distinguishing version number.  If the Program
243
+specifies a version number of this License which applies to it and "any
244
+later version", you have the option of following the terms and conditions
245
+either of that version or of any later version published by the Free
246
+Software Foundation.  If the Program does not specify a version number of
247
+this License, you may choose any version ever published by the Free Software
248
+Foundation.
249
+
250
+  10. If you wish to incorporate parts of the Program into other free
251
+programs whose distribution conditions are different, write to the author
252
+to ask for permission.  For software which is copyrighted by the Free
253
+Software Foundation, write to the Free Software Foundation; we sometimes
254
+make exceptions for this.  Our decision will be guided by the two goals
255
+of preserving the free status of all derivatives of our free software and
256
+of promoting the sharing and reuse of software generally.
257
+
258
+			    NO WARRANTY
259
+
260
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
262
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
266
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
267
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+REPAIR OR CORRECTION.
269
+
270
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+POSSIBILITY OF SUCH DAMAGES.
279
+
280
+		     END OF TERMS AND CONDITIONS
281
+
282
+	    How to Apply These Terms to Your New Programs
283
+
284
+  If you develop a new program, and you want it to be of the greatest
285
+possible use to the public, the best way to achieve this is to make it
286
+free software which everyone can redistribute and change under these terms.
287
+
288
+  To do so, attach the following notices to the program.  It is safest
289
+to attach them to the start of each source file to most effectively
290
+convey the exclusion of warranty; and each file should have at least
291
+the "copyright" line and a pointer to where the full notice is found.
292
+
293
+    <one line to give the program's name and a brief idea of what it does.>
294
+    Copyright (C) <year>  <name of author>
295
+
296
+    This program is free software; you can redistribute it and/or modify
297
+    it under the terms of the GNU General Public License as published by
298
+    the Free Software Foundation; either version 2 of the License, or
299
+    (at your option) any later version.
300
+
301
+    This program is distributed in the hope that it will be useful,
302
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
304
+    GNU General Public License for more details.
305
+
306
+    You should have received a copy of the GNU General Public License along
307
+    with this program; if not, write to the Free Software Foundation, Inc.,
308
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+Also add information on how to contact you by electronic and paper mail.
311
+
312
+If the program is interactive, make it output a short notice like this
313
+when it starts in an interactive mode:
314
+
315
+    Gnomovision version 69, Copyright (C) year name of author
316
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+    This is free software, and you are welcome to redistribute it
318
+    under certain conditions; type `show c' for details.
319
+
320
+The hypothetical commands `show w' and `show c' should show the appropriate
321
+parts of the General Public License.  Of course, the commands you use may
322
+be called something other than `show w' and `show c'; they could even be
323
+mouse-clicks or menu items--whatever suits your program.
324
+
325
+You should also get your employer (if you work as a programmer) or your
326
+school, if any, to sign a "copyright disclaimer" for the program, if
327
+necessary.  Here is a sample; alter the names:
328
+
329
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+  <signature of Ty Coon>, 1 April 1989
333
+  Ty Coon, President of Vice
334
+
335
+This General Public License does not permit incorporating your program into
336
+proprietary programs.  If your program is a subroutine library, you may
337
+consider it more useful to permit linking proprietary applications with the
338
+library.  If this is what you want to do, use the GNU Lesser General
339
+Public License instead of this License.

+ 39
- 0
main.cpp View File

@@ -0,0 +1,39 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#include <QApplication>
23
+#include <QTranslator>
24
+#include <QLocale>
25
+#include "findserver.h"
26
+
27
+int main(int argc, char **argv) {
28
+	QApplication app(argc, argv);
29
+	
30
+	QLocale locale;
31
+	QTranslator translator;
32
+	translator.load(QString("trans/viergewinnt-qt_") + locale.name());
33
+	app.installTranslator(&translator);
34
+	
35
+	FindServerWidget fswid;
36
+	fswid.show();
37
+	
38
+	return app.exec();
39
+}

+ 87
- 0
newgame.cpp View File

@@ -0,0 +1,87 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#include "newgame.h"
23
+
24
+
25
+NewGameDialog::NewGameDialog(QTcpSocket *sock, QWidget *parent) : QDialog(parent) {
26
+	mysock = sock;
27
+	gameend = new QLabel("");
28
+	newgame = new QLabel(tr("Ein neues Spiel?"));
29
+	netplayer = new QLabel("");
30
+	ok = new QPushButton(tr("Ok"));
31
+	connect(ok, SIGNAL(clicked()), this, SLOT(localAck()));
32
+	cancel = new QPushButton(tr("Abbrechen"));
33
+	connect(cancel, SIGNAL(clicked()), this, SLOT(closeGame()));
34
+	connect(this, SIGNAL(rejected()), this, SLOT(closeGame()));
35
+	setWindowTitle(tr("Neues Spiel?"));
36
+	reset(true);
37
+	
38
+	buttonrow = new QHBoxLayout;
39
+	buttonrow->addStretch();
40
+	buttonrow->addWidget(ok);
41
+	buttonrow->addStretch();
42
+	buttonrow->addWidget(cancel);
43
+	buttonrow->addStretch();
44
+
45
+	
46
+	layout = new QVBoxLayout;
47
+	
48
+	layout->addWidget(gameend);
49
+	layout->addSpacing(32);
50
+	layout->addWidget(newgame);
51
+	layout->addWidget(netplayer);
52
+	layout->addLayout(buttonrow);
53
+	
54
+	//center
55
+	layout->setAlignment(gameend, Qt::AlignHCenter);
56
+	layout->setAlignment(newgame, Qt::AlignHCenter);
57
+	layout->setAlignment(netplayer, Qt::AlignHCenter);
58
+	
59
+	setLayout(layout);
60
+	
61
+	setModal(Qt::WindowModal);
62
+}
63
+
64
+void NewGameDialog::reset(bool won) {
65
+	netplayer->setText(tr("Dein Mispieler hat bisher noch nicht zugestimmt."));
66
+	ok->setDisabled(false);
67
+	if(won) {
68
+		gameend->setText(tr("Whee, du hast gewonnen! :)"));
69
+	} else {
70
+		gameend->setText(tr("Du hast verloren -.-"));
71
+	}
72
+}
73
+
74
+void NewGameDialog::netPlayerAck() {
75
+	netplayer->setText(tr("Dein Mispieler hat zugestimmt."));
76
+}
77
+
78
+void NewGameDialog::localAck() {
79
+	ok->setDisabled(true);
80
+	QTextStream sockstream(mysock);
81
+	sockstream << "ACK NEW GAME\n";
82
+}
83
+
84
+void NewGameDialog::closeGame() {
85
+	mysock->close();
86
+	done(1);
87
+}

+ 60
- 0
newgame.h View File

@@ -0,0 +1,60 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#ifndef __NEWGAME_H
23
+#define __NEWGAME_H
24
+
25
+#include <QDialog>
26
+#include <QLabel>
27
+#include <QPushButton>
28
+#include <QVBoxLayout>
29
+#include <QHBoxLayout>
30
+#include <QTcpSocket>
31
+#include <QTextStream>
32
+
33
+
34
+class NewGameDialog : public QDialog {
35
+	Q_OBJECT
36
+	
37
+	public:
38
+		NewGameDialog(QTcpSocket *sock, QWidget *parent=0);
39
+		
40
+		void reset(bool won);
41
+		void netPlayerAck();
42
+	
43
+	private slots:
44
+		void localAck();
45
+		void closeGame();
46
+		
47
+	private:
48
+		QVBoxLayout *layout;
49
+		QHBoxLayout *buttonrow;
50
+		QLabel *gameend;
51
+		QLabel *newgame;
52
+		QLabel *netplayer;
53
+		QPushButton *ok;
54
+		QPushButton *cancel;
55
+		QTcpSocket *mysock;
56
+		
57
+		bool myack, youack;
58
+};
59
+
60
+#endif

+ 45
- 0
playerwait.cpp View File

@@ -0,0 +1,45 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#include "playerwait.h"
23
+
24
+PlayerWaitDialog::PlayerWaitDialog(QTcpSocket *sock, QWidget *parent) : QDialog(parent) {
25
+	mysock = sock;
26
+	cancel = new QPushButton(tr("Abbrechen"));
27
+	connect(cancel, SIGNAL(clicked()), this, SLOT(closeGame()));
28
+	connect(this, SIGNAL(rejected()), this, SLOT(closeGame()));
29
+	waiting = new QLabel(tr("Warte auf anderen Spieler..."));
30
+	setWindowTitle(tr("Auf Spieler warten"));
31
+	
32
+	layout = new QVBoxLayout;
33
+	layout->addWidget(waiting);
34
+	layout->addStretch();
35
+	layout->addWidget(cancel);
36
+	
37
+	setLayout(layout);
38
+	
39
+	setModal(Qt::WindowModal);
40
+}
41
+
42
+void PlayerWaitDialog::closeGame() {
43
+	mysock->close();
44
+	done(1);
45
+}

+ 49
- 0
playerwait.h View File

@@ -0,0 +1,49 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#ifndef __PLAYERWAIT_H
23
+#define __PLAYERWAIT_H
24
+
25
+#include <QDialog>
26
+#include <QLabel>
27
+#include <QPushButton>
28
+#include <QTcpSocket>
29
+#include <QVBoxLayout>
30
+
31
+class PlayerWaitDialog : public QDialog {
32
+	Q_OBJECT
33
+
34
+	public:
35
+		PlayerWaitDialog(QTcpSocket *sock, QWidget *parent=0);
36
+	
37
+	private slots:
38
+		void closeGame();
39
+	
40
+	private:
41
+		QVBoxLayout *layout;
42
+		QTcpSocket *mysock;
43
+		QPushButton *cancel;
44
+		QLabel *waiting;
45
+	
46
+};
47
+
48
+
49
+#endif

+ 108
- 0
renderarea.cpp View File

@@ -0,0 +1,108 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#include "renderarea.h"
23
+
24
+#include <QPainter>
25
+
26
+RenderArea::RenderArea(QWidget *parent) : QWidget(parent) {
27
+	QSizePolicy tmppol;
28
+	tmppol.setHorizontalPolicy(QSizePolicy::Maximum);
29
+	tmppol.setVerticalPolicy(QSizePolicy::Maximum);
30
+	setSizePolicy(tmppol);
31
+
32
+// 	this->antialiased = true;
33
+
34
+	// pens
35
+	xpen.setColor(Qt::green);
36
+	xpen.setWidth(10);
37
+	xpen.setJoinStyle(Qt::RoundJoin);
38
+	xpen.setCapStyle(Qt::RoundCap);
39
+
40
+	ypen.setColor(Qt::red);
41
+	ypen.setWidth(10);
42
+	
43
+	mfact = 0.75;
44
+	feld = 0; // just to clarify, also set in next statement
45
+	setFeldInfo(7, 6, 0);
46
+}
47
+
48
+void RenderArea::setFeldInfo(int _x, int _y, VierGewinntWidget::Stein **_feld) {
49
+	fx = _x;
50
+	fy = _y;
51
+	feld = _feld;
52
+}
53
+
54
+QSize RenderArea::minimumSizeHint() const {
55
+	return QSize(320, 240);
56
+}
57
+
58
+QSize RenderArea::sizeHint() const {
59
+	return QSize(640, 480);
60
+}
61
+
62
+void RenderArea::paintEvent(QPaintEvent * /*event*/) {
63
+	QPainter painter(this);
64
+	painter.setRenderHint(QPainter::Antialiasing, true);
65
+	// Start with grid
66
+	int fsize = std::min(width()/fx, height()/fy);
67
+// 	painter.drawLine(0, 0, width(), height());
68
+	painter.translate((width()-fsize*fx)/2, (height()-fsize*fy)/2);
69
+	for(int i=0; i<=fx; i++)
70
+		painter.drawLine(i*fsize, 0, i*fsize, fsize*fy);
71
+	for(int i=0; i<=fy; i++)
72
+		painter.drawLine(0, i*fsize, fsize*fx, i*fsize);
73
+		
74
+	
75
+	if(feld==0)
76
+		return;
77
+		
78
+	// paint x and o
79
+	for(int i=0; i<fx; i++) {
80
+		for(int j=0; j<fy; j++) {
81
+			if(feld[i][j]!=VierGewinntWidget::n) {
82
+				painter.save();
83
+				painter.translate(i*fsize+fsize/2, j*fsize+fsize/2);
84
+				if(feld[i][j]==VierGewinntWidget::x) {
85
+					painter.setPen(xpen);
86
+					painter.drawLine(-fsize/2*mfact, -fsize/2*mfact, fsize/2*mfact, fsize/2*mfact);
87
+					painter.drawLine(-fsize/2*mfact,  fsize/2*mfact, fsize/2*mfact,-fsize/2*mfact);
88
+				} else {
89
+					painter.setPen(ypen);
90
+					painter.drawEllipse(-fsize/2*mfact, -fsize/2*mfact, fsize*mfact, fsize*mfact);
91
+				}
92
+				painter.restore();
93
+			}
94
+		}
95
+	}
96
+}
97
+
98
+void RenderArea::mouseReleaseEvent(QMouseEvent *event) {
99
+	if(event->button()!=Qt::LeftButton)
100
+		return;
101
+
102
+	int fsize = std::min(width()/fx, height()/fy);
103
+	int myrow = (event->x()-((width()-fsize*fx)/2))/fsize;
104
+	if(myrow<0||myrow>=fx||event->x()-((width()-fsize*fx)/2)<0)
105
+		return;
106
+	
107
+	addStein(myrow);
108
+}

+ 56
- 0
renderarea.h View File

@@ -0,0 +1,56 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#ifndef __RENDERAREA_H
23
+#define __RENDERAREA_H
24
+
25
+#include <QWidget>
26
+#include <QPen>
27
+#include <QMouseEvent>
28
+#include "viergewinnt.h"
29
+
30
+class RenderArea : public QWidget {
31
+	Q_OBJECT
32
+
33
+	public:
34
+		RenderArea(QWidget *parent=0);
35
+		
36
+		void setFeldInfo(int _x, int _y, VierGewinntWidget::Stein **_feld);
37
+		QSize minimumSizeHint() const;
38
+		QSize sizeHint() const;
39
+	
40
+	signals:
41
+		void addStein(int row);
42
+	
43
+	protected:
44
+		void paintEvent(QPaintEvent *event);
45
+		void mouseReleaseEvent(QMouseEvent *event);
46
+		
47
+	private:
48
+		int fx;
49
+		int fy;
50
+		float mfact;
51
+		VierGewinntWidget::Stein **feld;
52
+		QPen xpen;
53
+		QPen ypen;
54
+};
55
+
56
+#endif

+ 84
- 0
selectmaster.cpp View File

@@ -0,0 +1,84 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#include "selectmaster.h"
23
+
24
+SelectMasterDialog::SelectMasterDialog(QWidget *parent) : QDialog(parent) {
25
+	labelhead = new QLabel(tr("Bitte gib einen anderen Masterserver an"));
26
+	labelmasteraddr = new QLabel(tr("Master-Server:"));
27
+	labelmasterport = new QLabel(tr("Master-Port:"));
28
+	editmasteraddr = new QLineEdit;
29
+	editmasterport = new QLineEdit;
30
+	okcancel = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
31
+	
32
+	connect(okcancel, SIGNAL(accepted()), this, SLOT(checkAndAccept()));
33
+	connect(okcancel, SIGNAL(rejected()), this, SLOT(reject()));
34
+	
35
+	layout = new QGridLayout;
36
+	layout->addWidget(labelhead, 0, 0, 1, 2);
37
+	layout->addWidget(labelmasteraddr, 1, 0);
38
+	layout->addWidget(editmasteraddr, 1, 1);
39
+	layout->addWidget(labelmasterport, 2, 0);
40
+	layout->addWidget(editmasterport, 2, 1);
41
+	layout->addWidget(okcancel, 3, 0, 1, 2);
42
+
43
+	setLayout(layout);
44
+	setWindowTitle(tr("Master-Server ändern"));
45
+	setModal(Qt::WindowModal);
46
+	
47
+}
48
+
49
+void SelectMasterDialog::checkAndAccept() {
50
+	if(editmasteraddr->text()=="") {
51
+		QMessageBox msgbox(this);
52
+		msgbox.setText(tr("Der Master-Server ist ungültig"));
53
+		msgbox.exec();
54
+		return;
55
+	}
56
+	
57
+	int tmpport = editmasterport->text().toInt();
58
+	if(tmpport<1||tmpport>65535) {
59
+		QMessageBox msgbox(this);
60
+		msgbox.setText(tr("Der Master-Port ist ungültig"));
61
+		msgbox.exec();
62
+		return;
63
+	}
64
+	masterserver = editmasteraddr->text();
65
+	masterport = tmpport;
66
+	accept();
67
+}
68
+
69
+void SelectMasterDialog::setData(QString srv, int port) {
70
+	masterserver = srv;
71
+	masterport = port;
72
+	editmasteraddr->setText(masterserver);
73
+	std::stringstream str;
74
+	str << masterport;
75
+	editmasterport->setText(QString(str.str().c_str()));
76
+}
77
+
78
+QString SelectMasterDialog::getMasterServer() {
79
+	return masterserver;
80
+}
81
+
82
+int SelectMasterDialog::getMasterPort() {
83
+	return masterport;
84
+}

+ 61
- 0
selectmaster.h View File

@@ -0,0 +1,61 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#ifndef __SELECTMASTER_H
23
+#define __SELECTMASTER_H
24
+
25
+#include <QDialog>
26
+#include <QString>
27
+#include <QLabel>
28
+#include <QLineEdit>
29
+#include <QGridLayout>
30
+#include <QDialogButtonBox>
31
+#include <QMessageBox>
32
+#include <sstream>
33
+
34
+class SelectMasterDialog : public QDialog {
35
+	Q_OBJECT
36
+	
37
+	public:
38
+		SelectMasterDialog(QWidget *parent=0);
39
+		void setData(QString srv, int port);
40
+		
41
+		QString getMasterServer();
42
+		int getMasterPort();
43
+	
44
+	private slots:
45
+		void checkAndAccept();
46
+	
47
+	private:
48
+		QString masterserver;
49
+		int masterport;
50
+	
51
+		// Guistuff
52
+		QDialogButtonBox *okcancel;
53
+		QLineEdit *editmasteraddr;
54
+		QLineEdit *editmasterport;
55
+		QLabel *labelmasteraddr;
56
+		QLabel *labelmasterport;
57
+		QLabel *labelhead;
58
+		QGridLayout *layout;
59
+};
60
+
61
+#endif

BIN
trans/viergewinnt-qt_en.qm View File


+ 341
- 0
trans/viergewinnt-qt_en.ts View File

@@ -0,0 +1,341 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<!DOCTYPE TS><TS version="1.1" language="en">
3
+<defaultcodec>ISO-8859-15</defaultcodec>
4
+<context>
5
+    <name>AboutDialog</name>
6
+    <message>
7
+        <location filename="about.cpp" line="26"/>
8
+        <source>&#xdc;ber</source>
9
+        <translation>About</translation>
10
+    </message>
11
+    <message>
12
+        <location filename="about.cpp" line="29"/>
13
+        <source>Ok</source>
14
+        <translation>Ok</translation>
15
+    </message>
16
+    <message>
17
+        <location filename="about.cpp" line="31"/>
18
+        <source>Netzwerk-VierGewinnt Client
19
+Programmiert von seba
20
+www.seba-geek.de</source>
21
+        <translation>Network-VierGewinnt Client
22
+Programmed by seba
23
+www.seba-geek.de</translation>
24
+    </message>
25
+    <message>
26
+        <location filename="about.cpp" line="33"/>
27
+        <source>Erstes QT-Programm!
28
+Dies ist ein Client f&#xfc;r das VierGewinnt-Modul vom &quot;Generic Network-Server&quot;. Endlich eine Verbesserung zum SDL-Client...</source>
29
+        <translation>First QT-Programm!
30
+This is a client for the VierGewinnt-Module from the &quot;Generic Network-Server&quot;. At last an improvement to the SDL-Client...</translation>
31
+    </message>
32
+</context>
33
+<context>
34
+    <name>CreateGameDialog</name>
35
+    <message>
36
+        <location filename="creategame.cpp" line="26"/>
37
+        <source>Neues Spiel</source>
38
+        <translation>New Game</translation>
39
+    </message>
40
+    <message>
41
+        <location filename="creategame.cpp" line="29"/>
42
+        <source>Spielname</source>
43
+        <translation>Gamename</translation>
44
+    </message>
45
+    <message>
46
+        <location filename="creategame.cpp" line="31"/>
47
+        <source>Ok</source>
48
+        <translation>Ok</translation>
49
+    </message>
50
+    <message>
51
+        <location filename="creategame.cpp" line="33"/>
52
+        <source>Abbrechen</source>
53
+        <translation>Cancel</translation>
54
+    </message>
55
+    <message>
56
+        <location filename="creategame.cpp" line="55"/>
57
+        <source>Unbenanntes Spiel</source>
58
+        <translation>Unknown Game</translation>
59
+    </message>
60
+</context>
61
+<context>
62
+    <name>FindServerWidget</name>
63
+    <message>
64
+        <location filename="findserver.cpp" line="30"/>
65
+        <source>Sebas Netzwerk-VierGewinnt Client</source>
66
+        <translation>Sebas Network-VierGewinnt Client</translation>
67
+    </message>
68
+    <message>
69
+        <location filename="findserver.cpp" line="30"/>
70
+        <source>Serverliste</source>
71
+        <translation>Serverlist</translation>
72
+    </message>
73
+    <message>
74
+        <location filename="findserver.cpp" line="52"/>
75
+        <source>Id</source>
76
+        <translation>Id</translation>
77
+    </message>
78
+    <message>
79
+        <location filename="findserver.cpp" line="52"/>
80
+        <source>Spielname</source>
81
+        <translation>Gamename</translation>
82
+    </message>
83
+    <message>
84
+        <location filename="findserver.cpp" line="52"/>
85
+        <source>Spieler</source>
86
+        <translation>Players</translation>
87
+    </message>
88
+    <message>
89
+        <location filename="findserver.cpp" line="52"/>
90
+        <source>Spielfeld</source>
91
+        <translation>Field</translation>
92
+    </message>
93
+    <message>
94
+        <location filename="findserver.cpp" line="52"/>
95
+        <source>Gewinnt</source>
96
+        <translation>Wins</translation>
97
+    </message>
98
+    <message>
99
+        <location filename="findserver.cpp" line="60"/>
100
+        <source>Erneuern</source>
101
+        <translation>Refresh</translation>
102
+    </message>
103
+    <message>
104
+        <location filename="findserver.cpp" line="62"/>
105
+        <source>Erstellen</source>
106
+        <translation>Create</translation>
107
+    </message>
108
+    <message>
109
+        <location filename="findserver.cpp" line="64"/>
110
+        <source>Beitreten</source>
111
+        <translation>Join</translation>
112
+    </message>
113
+    <message>
114
+        <location filename="findserver.cpp" line="66"/>
115
+        <source>Anderer Masterserver</source>
116
+        <translation>Change masterserver</translation>
117
+    </message>
118
+    <message>
119
+        <location filename="findserver.cpp" line="68"/>
120
+        <source>&#xdc;ber</source>
121
+        <translation>About</translation>
122
+    </message>
123
+    <message>
124
+        <location filename="findserver.cpp" line="85"/>
125
+        <source>Dr&#xfc;cke Erneuern um eine Serverliste zu erhalten</source>
126
+        <translation>Press Refresh to get the serverlist</translation>
127
+    </message>
128
+    <message>
129
+        <location filename="findserver.cpp" line="107"/>
130
+        <source>Fordere Liste an...</source>
131
+        <translation>Requesting list...</translation>
132
+    </message>
133
+    <message>
134
+        <location filename="findserver.cpp" line="133"/>
135
+        <source>Spiel erstellt</source>
136
+        <translation>Game created</translation>
137
+    </message>
138
+    <message>
139
+        <location filename="findserver.cpp" line="147"/>
140
+        <source>Es wurde kein Spiel zum beitreten ausgew&#xe4;hlt</source>
141
+        <translation>No Game was selected</translation>
142
+    </message>
143
+    <message>
144
+        <location filename="findserver.cpp" line="160"/>
145
+        <source>Trete Spiel bei..</source>
146
+        <translation>Joining game..</translation>
147
+    </message>
148
+    <message>
149
+        <location filename="findserver.cpp" line="176"/>
150
+        <source>Version akzeptiert</source>
151
+        <translation>Version accepted</translation>
152
+    </message>
153
+    <message>
154
+        <location filename="findserver.cpp" line="180"/>
155
+        <source>Version nicht akzeptiert, kein GNS-Server!</source>
156
+        <translation>Version rejected, not a GNS-Server!</translation>
157
+    </message>
158
+    <message>
159
+        <location filename="findserver.cpp" line="188"/>
160
+        <source>Modul ausgew&#xe4;hlt</source>
161
+        <translation>Module selected</translation>
162
+    </message>
163
+    <message>
164
+        <location filename="findserver.cpp" line="195"/>
165
+        <source>VierGewinnt-Modul nicht gefunden!</source>
166
+        <translation>VierGewinnt-Module not found!</translation>
167
+    </message>
168
+    <message>
169
+        <location filename="findserver.cpp" line="213"/>
170
+        <source>Keine Spiele offen :(</source>
171
+        <translation>No games open :(</translation>
172
+    </message>
173
+    <message>
174
+        <location filename="findserver.cpp" line="215"/>
175
+        <source>Konnte nicht beitreten: Spiel voll</source>
176
+        <translation>Could not join: Game full</translation>
177
+    </message>
178
+    <message>
179
+        <location filename="findserver.cpp" line="217"/>
180
+        <source>Spiel konnte nicht gefunden werden</source>
181
+        <translation>Could not find game</translation>
182
+    </message>
183
+    <message>
184
+        <location filename="findserver.cpp" line="309"/>
185
+        <source>Fehler: Der Master-Server Hostname konnte nicht aufgel&#xf6;st werden!</source>
186
+        <translation>Error: The masterserver hostname could not be resolved!</translation>
187
+    </message>
188
+    <message>
189
+        <location filename="findserver.cpp" line="312"/>
190
+        <source>Fehler: Verbindungsversuch zum Master-Server ist fehlgeschlagen!</source>
191
+        <translation>Error: Could not connect to masterserver!</translation>
192
+    </message>
193
+    <message>
194
+        <location filename="findserver.cpp" line="318"/>
195
+        <source>Netzwerkfehler: &apos;%1&apos;</source>
196
+        <translation>Networkerror: &apos;%1&apos;</translation>
197
+    </message>
198
+    <message>
199
+        <location filename="findserver.cpp" line="328"/>
200
+        <source>Die Verbindung zum Masterserver wurde getrennt.</source>
201
+        <translation>Disconnected from masterserver.</translation>
202
+    </message>
203
+    <message>
204
+        <location filename="findserver.cpp" line="339"/>
205
+        <source>Versuche Verbindung zu </source>
206
+        <translation>Trying to connect to </translation>
207
+    </message>
208
+</context>
209
+<context>
210
+    <name>NewGameDialog</name>
211
+    <message>
212
+        <location filename="newgame.cpp" line="28"/>
213
+        <source>Ein neues Spiel?</source>
214
+        <translation>A new game?</translation>
215
+    </message>
216
+    <message>
217
+        <location filename="newgame.cpp" line="30"/>
218
+        <source>Ok</source>
219
+        <translation>Ok</translation>
220
+    </message>
221
+    <message>
222
+        <location filename="newgame.cpp" line="32"/>
223
+        <source>Abbrechen</source>
224
+        <translation>Cancel</translation>
225
+    </message>
226
+    <message>
227
+        <location filename="newgame.cpp" line="35"/>
228
+        <source>Neues Spiel?</source>
229
+        <translation>New game?</translation>
230
+    </message>
231
+    <message>
232
+        <location filename="newgame.cpp" line="65"/>
233
+        <source>Dein Mispieler hat bisher noch nicht zugestimmt.</source>
234
+        <translation>Your opponent did not agree to a new game right now.</translation>
235
+    </message>
236
+    <message>
237
+        <location filename="newgame.cpp" line="68"/>
238
+        <source>Whee, du hast gewonnen! :)</source>
239
+        <translation>Whee, you won! :)</translation>
240
+    </message>
241
+    <message>
242
+        <location filename="newgame.cpp" line="70"/>
243
+        <source>Du hast verloren -.-</source>
244
+        <translation>You have lost -.-</translation>
245
+    </message>
246
+    <message>
247
+        <location filename="newgame.cpp" line="75"/>
248
+        <source>Dein Mispieler hat zugestimmt.</source>
249
+        <translation>Your opponent agreed.</translation>
250
+    </message>
251
+</context>
252
+<context>
253
+    <name>PlayerWaitDialog</name>
254
+    <message>
255
+        <location filename="playerwait.cpp" line="26"/>
256
+        <source>Abbrechen</source>
257
+        <translation>Cancel</translation>
258
+    </message>
259
+    <message>
260
+        <location filename="playerwait.cpp" line="29"/>
261
+        <source>Warte auf anderen Spieler...</source>
262
+        <translation>Waiting for other player...</translation>
263
+    </message>
264
+    <message>
265
+        <location filename="playerwait.cpp" line="30"/>
266
+        <source>Auf Spieler warten</source>
267
+        <translation>Waiting for other player</translation>
268
+    </message>
269
+</context>
270
+<context>
271
+    <name>SelectMasterDialog</name>
272
+    <message>
273
+        <location filename="selectmaster.cpp" line="25"/>
274
+        <source>Bitte gib einen anderen Masterserver an</source>
275
+        <translation>Please enter another masterserver</translation>
276
+    </message>
277
+    <message>
278
+        <location filename="selectmaster.cpp" line="26"/>
279
+        <source>Master-Server:</source>
280
+        <translation>Masterserver:</translation>
281
+    </message>
282
+    <message>
283
+        <location filename="selectmaster.cpp" line="27"/>
284
+        <source>Master-Port:</source>
285
+        <translation>Masterport:</translation>
286
+    </message>
287
+    <message>
288
+        <location filename="selectmaster.cpp" line="44"/>
289
+        <source>Master-Server &#xe4;ndern</source>
290
+        <translation>Change masterserver</translation>
291
+    </message>
292
+    <message>
293
+        <location filename="selectmaster.cpp" line="52"/>
294
+        <source>Der Master-Server ist ung&#xfc;ltig</source>
295
+        <translation>The masterserver is invalid</translation>
296
+    </message>
297
+    <message>
298
+        <location filename="selectmaster.cpp" line="60"/>
299
+        <source>Der Master-Port ist ung&#xfc;ltig</source>
300
+        <translation>The masterport is invalid</translation>
301
+    </message>
302
+</context>
303
+<context>
304
+    <name>VierGewinntWidget</name>
305
+    <message>
306
+        <location filename="viergewinnt.cpp" line="29"/>
307
+        <source>Sebas Netzwerk-VierGewinnt Client</source>
308
+        <translation>Sebas Network-VierGewinnt Client</translation>
309
+    </message>
310
+    <message>
311
+        <location filename="viergewinnt.cpp" line="29"/>
312
+        <source>Spielfenster</source>
313
+        <translation>Gamewindow</translation>
314
+    </message>
315
+    <message>
316
+        <location filename="viergewinnt.cpp" line="36"/>
317
+        <source>Spiel ist gestartet</source>
318
+        <translation>The game has been started</translation>
319
+    </message>
320
+    <message>
321
+        <location filename="viergewinnt.cpp" line="41"/>
322
+        <source>zu</source>
323
+        <translation>to</translation>
324
+    </message>
325
+    <message>
326
+        <location filename="viergewinnt.cpp" line="43"/>
327
+        <source>Spiel Beenden</source>
328
+        <translation>Quit game</translation>
329
+    </message>
330
+    <message>
331
+        <location filename="viergewinnt.cpp" line="133"/>
332
+        <source>Du bist am Zug</source>
333
+        <translation>It&apos;s your move</translation>
334
+    </message>
335
+    <message>
336
+        <location filename="viergewinnt.cpp" line="135"/>
337
+        <source>Dein Mitspieler ist am Zug</source>
338
+        <translation>It&apos;s your opponents move</translation>
339
+    </message>
340
+</context>
341
+</TS>

+ 33
- 0
viergewinnt-qt.pro View File

@@ -0,0 +1,33 @@
1
+######################################################################
2
+# Automatically generated by qmake (2.01a) Sa Nov 1 01:59:30 2008
3
+######################################################################
4
+
5
+TEMPLATE = app
6
+TARGET = 
7
+DEPENDPATH += .
8
+INCLUDEPATH += .
9
+DEFINES += QT_NO_DEBUG_OUTPUT
10
+QT += network
11
+CONFIG += qt warn_on release
12
+
13
+# Input
14
+TRANSLATIONS = viergewinnt-qt_en.ts
15
+CODECFORTR      = ISO-8859-15
16
+
17
+HEADERS += about.h \
18
+           creategame.h \
19
+           findserver.h \
20
+           newgame.h \
21
+           playerwait.h \
22
+           renderarea.h \
23
+           selectmaster.h \
24
+           viergewinnt.h
25
+SOURCES += about.cpp \
26
+           creategame.cpp \
27
+           findserver.cpp \
28
+           main.cpp \
29
+           newgame.cpp \
30
+           playerwait.cpp \
31
+           renderarea.cpp \
32
+           selectmaster.cpp \
33
+           viergewinnt.cpp

+ 195
- 0
viergewinnt.cpp View File

@@ -0,0 +1,195 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#include "viergewinnt.h"
23
+#include "renderarea.h"
24
+
25
+VierGewinntWidget::VierGewinntWidget(QTcpSocket *tcpsock, QWidget *parent) : QDialog(parent) {
26
+	setFixedSize(640, 480);
27
+	setWindowTitle(tr("Sebas Netzwerk-VierGewinnt Client")+" - "+tr("Spielfenster"));
28
+	feld = 0;
29
+	mysock = tcpsock;
30
+	fx = 7;
31
+	fy = 6;
32
+	
33
+	// Arrange QT Stuff
34
+	status = new QLabel(tr("Spiel ist gestartet"));
35
+	rarea = new RenderArea;
36
+	connect(rarea, SIGNAL(addStein(int)), this, SLOT(netAdd(int)));
37
+	
38
+	myscore = new QLCDNumber(2);
39
+	vs = new QLabel(tr("zu"));
40
+	youscore = new QLCDNumber(2);
41
+	exit = new QPushButton(tr("Spiel Beenden"));
42
+	connect(exit, SIGNAL(clicked()), this, SLOT(closeGame()));
43
+	
44
+	// layout
45
+	upperrow = new QHBoxLayout;
46
+	upperrow->addStretch();
47
+	upperrow->addWidget(status);
48
+	upperrow->addStretch();
49
+	
50
+	underrow = new QHBoxLayout;
51
+	underrow->addStretch();
52
+	underrow->addWidget(myscore);
53
+	underrow->addWidget(vs);
54
+	underrow->addWidget(youscore);
55
+	underrow->addStretch();
56
+	underrow->addWidget(exit);
57
+	
58
+	layout = new QVBoxLayout;
59
+	layout->addLayout(upperrow);
60
+	layout->addWidget(rarea);
61
+	layout->addLayout(underrow);
62
+	setLayout(layout);
63
+	
64
+	waitforplayer = new PlayerWaitDialog(mysock, this);
65
+	newgame = new NewGameDialog(mysock, this);
66
+}
67
+
68
+void VierGewinntWidget::init(int _x, int _y) {
69
+	qDebug() << "game init(" << _x << ", " << _y << ")\n";
70
+	dealloc();
71
+	
72
+	// reset all possible dialogues
73
+// 	setDisabled(false);
74
+	newgame->hide();
75
+	waitforplayer->hide();
76
+	
77
+	fx = _x;
78
+	fy = _y;
79
+	feld = new Stein*[fx];
80
+	for(int i=0; i<fx; i++)
81
+		feld[i] = new Stein[fy];
82
+	setScore(0, 0);
83
+	cleanFeld();
84
+	rarea->setFeldInfo(fx, fy, feld);
85
+}
86
+
87
+void VierGewinntWidget::startGame() {
88
+// 	this->setDisabled(false);
89
+	// clear all dialogues here
90
+	qDebug() << "Starting Game";
91
+	newgame->hide();
92
+	waitforplayer->hide();
93
+	
94
+	cleanFeld();
95
+	QTextStream sockstream(mysock);
96
+	sockstream << "TURN\n";
97
+	sockstream << "SHOWSCORE\n";
98
+}
99
+
100
+void VierGewinntWidget::add(int row, Stein st) {
101
+	for(int i=fy-1; i>=0; i--) {
102
+		qDebug() << "doing " << i << " for row " << row << ", adding " << st;
103
+		if(feld[row][i]==n) {
104
+			feld[row][i] = st;
105
+			rarea->update();
106
+			setTurn(!myturn);
107
+			return;
108
+		}
109
+	}
110
+	
111
+}
112
+
113
+void VierGewinntWidget::cleanFeld() {
114
+	qDebug() << "Cleaning Feld";
115
+	if(feld==0)
116
+		return;
117
+	for(int i=0; i<fx; i++) {
118
+		for(int j=0; j<fy; j++) {
119
+			feld[i][j] = n;
120
+		}
121
+	}
122
+	rarea->update();
123
+	
124
+	while(!pendingadd.empty())
125
+		pendingadd.pop();
126
+}
127
+
128
+void VierGewinntWidget::setTurn(bool _myturn) {
129
+	myturn = _myturn;
130
+	if(myturn) {
131
+		status->setText(tr("Du bist am Zug"));
132
+	} else {
133
+		status->setText(tr("Dein Mitspieler ist am Zug"));
134
+	}
135
+}
136
+
137
+void VierGewinntWidget::clientExited() {
138
+	// pending dialog mit cancel
139
+	qDebug() << "Wait for player...";
140
+	newgame->hide();
141
+	waitforplayer->show();
142
+}
143
+
144
+void VierGewinntWidget::ackAdd(bool valid) {
145
+	if(valid)
146
+		add(pendingadd.front(), x);
147
+	pendingadd.pop();
148
+}
149
+
150
+void VierGewinntWidget::ackNewGame() {
151
+	newgame->netPlayerAck();
152
+}
153
+
154
+void VierGewinntWidget::newGame(bool won) {
155
+	if(won) {
156
+		setScore(myscore->intValue()+1, youscore->intValue());
157
+	} else {
158
+		setScore(myscore->intValue(), youscore->intValue()+1);
159
+	}
160
+// 	this->setDisabled(true);
161
+	newgame->reset(won);
162
+	newgame->show();
163
+	
164
+	// exec, abhfangen
165
+}
166
+
167
+void VierGewinntWidget::closeGame() {
168
+	mysock->close();
169
+}
170
+
171
+void VierGewinntWidget::netAdd(int row) {
172
+// 	if(!myturn)
173
+// 		return;
174
+	pendingadd.push(row);
175
+	QTextStream sockstream(mysock);
176
+	sockstream << "ADD " << row << "\n";
177
+}
178
+
179
+void VierGewinntWidget::setScore(int a, int b) {
180
+	myscore->display(a);
181
+	youscore->display(b);
182
+}
183
+
184
+void VierGewinntWidget::dealloc() {
185
+	if(feld==0)
186
+		return;
187
+	for(int i=0; i<x; i++)
188
+		delete[](feld[i]);
189
+	delete[](feld);
190
+	feld = 0;
191
+}
192
+
193
+VierGewinntWidget::~VierGewinntWidget() {
194
+	dealloc();
195
+}

+ 92
- 0
viergewinnt.h View File

@@ -0,0 +1,92 @@
1
+/* VierGewinnt - A simple 4-in-a-row network game
2
+ *
3
+ *      Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
4
+ *      http://www.seba-geek.de
5
+ *
6
+ *  This file is part of VierGewinnt.
7
+ *
8
+ *  VierGewinnt is free software: you can redistribute it and/or modify
9
+ *  it under the terms of the GNU General Public License as published by
10
+ *  the Free Software Foundation, either version 2 of the License, or
11
+ *  (at your option) any later version.
12
+ *
13
+ *  VierGewinnt is distributed in the hope that it will be useful,
14
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
+ *  GNU General Public License for more details.
17
+ *
18
+ *  You should have received a copy of the GNU General Public License
19
+ *  along with VierGewinnt.  If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+
22
+#ifndef __VIERGEWINNT_H
23
+#define __VIERGEWINNT_H
24
+
25
+#include <QDialog>
26
+#include <QWidget>
27
+#include <QTcpSocket>
28
+#include <QPushButton>
29
+#include <QLCDNumber>
30
+#include <QVBoxLayout>
31
+#include <QHBoxLayout>
32
+#include <QMessageBox>
33
+#include <QLabel>
34
+#include <QDebug>
35
+#include <queue>
36
+
37
+#include "newgame.h"
38
+#include "playerwait.h"
39
+
40
+class RenderArea;
41
+
42
+class VierGewinntWidget : public QDialog {
43
+	Q_OBJECT
44
+
45
+	public:
46
+		VierGewinntWidget(QTcpSocket *tcpsock, QWidget *parent);
47
+		~VierGewinntWidget();
48
+		
49
+		enum Stein {n=0, x, o};
50
+		
51
+		void init(int _x, int _y);
52
+		void startGame();
53
+		void add(int row, Stein st);
54
+		void cleanFeld();
55
+		void setScore(int a, int b);
56
+		
57
+		// called by networkstuff
58
+		void setTurn(bool _myturn);
59
+		void clientExited();
60
+		void ackAdd(bool valid);
61
+		void ackNewGame();
62
+		void newGame(bool won);
63
+		
64
+	private slots:
65
+		void closeGame();
66
+		void netAdd(int row);
67
+		
68
+	private:
69
+		void dealloc();
70
+	
71
+		int fx, fy;
72
+		Stein **feld;
73
+		QTcpSocket *mysock;
74
+		bool myturn;
75
+		std::queue<int> pendingadd;
76
+		
77
+		// guistuff
78
+		QVBoxLayout *layout;
79
+		QHBoxLayout *upperrow;
80
+		QHBoxLayout *underrow;
81
+		PlayerWaitDialog *waitforplayer;
82
+		NewGameDialog *newgame;
83
+		
84
+		QLabel *status;
85
+		RenderArea *rarea;
86
+		QLCDNumber *myscore;
87
+		QLabel *vs;
88
+		QLCDNumber *youscore;
89
+		QPushButton *exit;
90
+};
91
+
92
+#endif

Loading…
Cancel
Save