• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdegames
 

libtdegames

  • libtdegames
  • kgame
  • dialogs
kgamedialogconfig.cpp
1/*
2 This file is part of the TDE games library
3 Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)
4 Copyright (C) 2001 Martin Heni (martin@heni-online.de)
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#include "kgamedialogconfig.h"
22
23#include "kgame.h"
24#include "kplayer.h"
25#include "kgamechat.h"
26#include "kgameconnectdialog.h"
27
28#include <tdelocale.h>
29#include <knuminput.h>
30#include <kdialog.h>
31#include <tdelistbox.h>
32#include <tdemessagebox.h>
33
34#include <tqlayout.h>
35#include <tqhgroupbox.h>
36#include <tqlabel.h>
37#include <tqpushbutton.h>
38#include <tqlineedit.h>
39#include <tqvbox.h>
40#include <tqptrdict.h>
41
42#include "kgamedialogconfig.moc"
43
44class KGameDialogConfigPrivate
45{
46public:
47 KGameDialogConfigPrivate()
48 {
49 mOwner = 0;
50 mGame = 0;
51
52 mAdmin = false;
53 }
54
55 bool mAdmin;
56 KGame* mGame;
57 KPlayer* mOwner;
58};
59
60KGameDialogConfig::KGameDialogConfig(TQWidget* parent) : TQWidget(parent)
61{
62 d = new KGameDialogConfigPrivate;
63}
64
65KGameDialogConfig::~KGameDialogConfig()
66{
67 kdDebug(11001) << k_funcinfo << endl;
68 delete d;
69}
70
71void KGameDialogConfig::setKGame(KGame* g)
72{
73 d->mGame = g;
74}
75
76void KGameDialogConfig::setOwner(KPlayer* p)
77{
78 d->mOwner = p;
79}
80
81void KGameDialogConfig::setAdmin(bool a)
82{
83 d->mAdmin = a;
84}
85
86KGame* KGameDialogConfig::game() const
87{ return d->mGame; }
88bool KGameDialogConfig::admin() const
89{ return d->mAdmin; }
90KPlayer* KGameDialogConfig::owner() const
91{ return d->mOwner; }
92
94class KGameDialogNetworkConfigPrivate
95{
96public:
97 KGameDialogNetworkConfigPrivate()
98 {
99 mInitConnection = 0;
100 mNetworkLabel = 0;
101 mDisconnectButton = 0;
102 mConnect = 0;
103 mDefaultServer=true;
104
105 }
106
107 // TQPushButton* mInitConnection;
108 TQHGroupBox* mInitConnection;
109 TQLabel* mNetworkLabel;
110 TQPushButton *mDisconnectButton;
111
112 bool mDefaultServer;
113 TQString mDefaultHost;
114 unsigned short int mDefaultPort;
115 KGameConnectWidget *mConnect;
116};
117
118
119KGameDialogNetworkConfig::KGameDialogNetworkConfig(TQWidget* parent)
120 : KGameDialogConfig(parent)
121{
122// kdDebug(11001) << k_funcinfo << ": this=" << this << endl;
123 d = new KGameDialogNetworkConfigPrivate();
124
125 TQVBoxLayout* topLayout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint(), "toplayout");
126
127 TQHBoxLayout *hb = new TQHBoxLayout(topLayout, KDialog::spacingHint());
128
129 d->mNetworkLabel = new TQLabel(this);
130 hb->addWidget(d->mNetworkLabel);
131
132 d->mDisconnectButton=new TQPushButton(i18n("Disconnect"),this);
133 connect(d->mDisconnectButton, TQ_SIGNAL(clicked()), this, TQ_SLOT(slotExitConnection()));
134 hb->addWidget(d->mDisconnectButton);
135
136 d->mInitConnection = new TQHGroupBox(i18n("Network Configuration"), this);
137 topLayout->addWidget(d->mInitConnection);
138
139 d->mConnect = new KGameConnectWidget(d->mInitConnection);
140 connect(d->mConnect, TQ_SIGNAL(signalNetworkSetup()), this, TQ_SLOT(slotInitConnection()));
141 connect(d->mConnect, TQ_SIGNAL(signalServerTypeChanged(int)),
142 this, TQ_SIGNAL(signalServerTypeChanged(int)));
143
144 // Needs to be AFTER the creation of the dialogs
145 setConnected(false);
146 setDefaultNetworkInfo("localhost", 7654,true);
147}
148
149KGameDialogNetworkConfig::~KGameDialogNetworkConfig()
150{
151 kdDebug(11001) << k_funcinfo << endl;
152 delete d;
153}
154
155void KGameDialogNetworkConfig::slotExitConnection()
156{
157 kdDebug(11001) << k_funcinfo << " !!!!!!!!!!!!!!!!!!!!!!!" << endl;
158 if (game()) game()->disconnect();
159 setConnected(false,false);
160}
161
162void KGameDialogNetworkConfig::slotInitConnection()
163{
164 kdDebug(11001) << k_funcinfo << endl;
165 bool connected = false;
166 bool master = true;
167 unsigned short int port = d->mConnect->port();
168 TQString host = d->mConnect->host();
169
170 if (host.isNull()) {
171 master = true;
172 if (game()) {
173 game()->setDiscoveryInfo(d->mConnect->type(),d->mConnect->gameName());
174 connected = game()->offerConnections(port);
175 }
176 } else {
177 master = false;
178 if (game()) {
179 connected = game()->connectToServer(host, port);
180 }
181 // We need to learn about failed connections
182 if (game()) {
183 connect(game(), TQ_SIGNAL(signalConnectionBroken()),
184 this, TQ_SLOT(slotConnectionBroken()));
185 }
186 }
187 setConnected(connected, master);
188}
189
190void KGameDialogNetworkConfig::slotConnectionBroken()
191{
192 kdDebug(11001) << k_funcinfo << endl;
193 setConnected(false,false);
194 KMessageBox::error(this, i18n("Cannot connect to the network"));
195}
196
197void KGameDialogNetworkConfig::setConnected(bool connected, bool master)
198{
199 if (!connected) {
200 d->mNetworkLabel->setText(i18n("Network status: No Network"));
201 d->mInitConnection->setEnabled(true);
202 d->mDisconnectButton->setEnabled(false);
203 return;
204 }
205 if (master) {
206 d->mNetworkLabel->setText(i18n("Network status: You are MASTER"));
207 } else {
208 d->mNetworkLabel->setText(i18n("Network status: You are connected"));
209 }
210 d->mInitConnection->setEnabled(false);
211 d->mDisconnectButton->setEnabled(true);
212}
213
214void KGameDialogNetworkConfig::submitToKGame(KGame* , KPlayer* )
215{
216}
217
218void KGameDialogNetworkConfig::setKGame(KGame* g)
219{
220 KGameDialogConfig::setKGame(g);
221 if (!game()) {
222 setConnected(false);
223 return;
224 }
225 setConnected(game()->isNetwork(), game()->isMaster());
226}
227
228void KGameDialogNetworkConfig::setDefaultNetworkInfo(const TQString& host, unsigned short int port,bool server)
229{
230 d->mDefaultPort = port;
231 d->mDefaultHost = host;
232 d->mDefaultServer = server;
233
234 d->mConnect->setHost(host);
235 d->mConnect->setPort(port);
236 if (server) {
237 d->mConnect->setDefault(0);
238 } else {
239 d->mConnect->setDefault(1);
240 }
241}
242
243void KGameDialogNetworkConfig::setDiscoveryInfo(const TQString& type, const TQString& name)
244{
245 d->mConnect->setType(type);
246 d->mConnect->setName(name);
247}
248
250class KGameDialogGeneralConfigPrivate
251{
252public:
253 KGameDialogGeneralConfigPrivate()
254 {
255 mTopLayout = 0;
256 mName = 0;
257 }
258
259 TQLineEdit* mName;
260
261 TQVBoxLayout* mTopLayout;
262};
263
264KGameDialogGeneralConfig::KGameDialogGeneralConfig(TQWidget* parent, bool initializeGUI)
265 : KGameDialogConfig(parent)
266{
267// kdDebug(11001) << k_funcinfo << ": this=" << this << endl;
268 d = new KGameDialogGeneralConfigPrivate;
269
270 if (initializeGUI) {
271 d->mTopLayout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
272 d->mTopLayout->setAutoAdd(true);
273
274 TQWidget* nameWidget = new TQWidget(this);
275 TQHBoxLayout* l = new TQHBoxLayout(nameWidget);
276 TQLabel* nameLabel = new TQLabel(i18n("Your name:"), nameWidget);
277 l->addWidget(nameLabel);
278 d->mName = new TQLineEdit(nameWidget);
279 l->addWidget(d->mName);
280 }
281}
282
283KGameDialogGeneralConfig::~KGameDialogGeneralConfig()
284{
285 kdDebug(11001) << k_funcinfo << endl;
286 delete d;
287}
288
289void KGameDialogGeneralConfig::setPlayerName(const TQString& name)
290{
291 if (d->mName) {
292 d->mName->setText(name);
293 }
294}
295
296TQString KGameDialogGeneralConfig::playerName() const
297{
298 return d->mName ? d->mName->text() : TQString();
299}
300
301void KGameDialogGeneralConfig::setOwner(KPlayer* p)
302{
303 if (owner()) {
304 owner()->disconnect(this);
305 }
306 KGameDialogConfig::setOwner(p);
307 if (!owner()) {
308 // can this config be used at all?
309 // maybe call hide()
310 return;
311 }
312 connect(owner(), TQ_SIGNAL(signalPropertyChanged(KGamePropertyBase*, KPlayer*)),
313 this, TQ_SLOT(slotPropertyChanged(KGamePropertyBase*, KPlayer*)));
314 setPlayerName(p->name());
315 //TODO: connect signalPropertyChanged and check for playername changes!
316}
317
318void KGameDialogGeneralConfig::setKGame(KGame* g)
319{
320 KGameDialogConfig::setKGame(g);
321 if (!g) {
322 // TODO
323 // can this config be used at all?
324 // maybe call hide()
325 return;
326 }
327}
328
329void KGameDialogGeneralConfig::setAdmin(bool admin)
330{
331 KGameDialogConfig::setAdmin(admin);
332// enable/disable widgets
333
334}
335
336void KGameDialogGeneralConfig::submitToKGame(KGame* g, KPlayer* p)
337{
338//FIXME
339 if (p) {
340 p->setName(playerName());
341 }
342 if (g) {
343 }
344}
345
346void KGameDialogGeneralConfig::slotPropertyChanged(KGamePropertyBase* prop, KPlayer* p)
347{
348 if (!prop || !p || p != owner()) {
349 return;
350 }
351 switch (prop->id()) {
352 case KGamePropertyBase::IdName:
353 setPlayerName(p->name());
354 break;
355 default:
356 break;
357 }
358}
359
360class KGameDialogMsgServerConfigPrivate
361{
362public:
363 KGameDialogMsgServerConfigPrivate()
364 {
365 senderLayout = 0;
366 localLayout = 0;
367
368 changeMaxClients = 0;
369 changeAdmin= 0;
370 removeClient= 0;
371 noAdmin = 0;
372
373 noMaster = 0;
374 }
375
376 TQVBoxLayout* senderLayout;
377 TQHBoxLayout* localLayout;
378
379 TQPushButton* changeMaxClients;
380 TQPushButton* changeAdmin;
381 TQPushButton* removeClient;
382 TQLabel* noAdmin;
383
384 TQLabel* noMaster;
385};
386
387
388// TODO: change ADMIN ID, remove CLIENTS, change MAXCLIENTS
389// we do everything here with TQPushButtons as we want to wait a moment before
390// continuing - the message must be sent over network first
391KGameDialogMsgServerConfig::KGameDialogMsgServerConfig(TQWidget* parent)
392 : KGameDialogConfig(parent)
393{
394 d = new KGameDialogMsgServerConfigPrivate;
395
396 TQVBoxLayout* topLayout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
397 d->senderLayout = new TQVBoxLayout(topLayout);
398 d->localLayout = new TQHBoxLayout(topLayout);
399}
400
401KGameDialogMsgServerConfig::~KGameDialogMsgServerConfig()
402{
403 kdDebug(11001) << k_funcinfo << endl;
404 delete d;
405}
406
407void KGameDialogMsgServerConfig::setKGame(KGame* g)
408{
409 KGameDialogConfig::setKGame(g);
410 //TODO display the ID of the admin if we aren't
411 // connect(g, TQ_SIGNAL(signalAdminChanged(int)), this, TQ_SLOT(slotChangeIsAdmin(int)));//TODO
412 if (!game()) {
413 // we cannot do anything without a KGame object!
414 setAdmin(false);
415 return;
416 }
417 setAdmin(game()->isAdmin());
418 setHasMsgServer(game()->messageServer());
419}
420
421
422void KGameDialogMsgServerConfig::slotChangeMaxClients()
423{
424 if (!game()) {
425 kdError(11001) << k_funcinfo << ": no valid game object available!" << endl;
426 return;
427 }
428 if (!game()->isAdmin()) {
429 kdError(11001) << k_funcinfo << ": only ADMIN is allowed to call this!" << endl;
430 return;
431 }
432 int max;
433// edit->setText(TQString::number()); // current max clients! //TODO
434
435 TQDialog* dialog = new TQDialog();
436 dialog->setCaption(i18n("Maximal Number of Clients"));
437 TQHBoxLayout* l = new TQHBoxLayout(dialog, KDialog::marginHint(), KDialog::spacingHint());
438 l->setAutoAdd(true);
439
440 (void) new TQLabel(i18n("Maximal number of clients (-1 = infinite):"), dialog);
441 TQLineEdit* edit = new TQLineEdit(dialog);//TODO: use KIntNumInput
442// edit->setText(TQString::number(max)); // current max clients! //TODO
443 if (dialog->exec() == TQDialog::Accepted) {
444 bool ok;
445 max = edit->text().toInt(&ok);
446 if (ok) {
447 game()->setMaxClients(max);
448 }
449 }
450
451}
452
453void KGameDialogMsgServerConfig::slotRemoveClient()
454{
455}
456
457void KGameDialogMsgServerConfig::slotChangeAdmin()
458{
459 if (!game()) {
460 kdError(11001) << k_funcinfo << ": no valid game object available!" << endl;
461 return;
462 }
463 if (!admin()) {
464 kdError(11001) << k_funcinfo << ": only ADMIN is allowed to call this!" << endl;
465 return;
466 }
467 //TODO
468 TQ_UINT32 newAdmin = 0;
469// newAdmin = ;
470 game()->electAdmin(newAdmin);
471}
472
473void KGameDialogMsgServerConfig::removeClient(TQ_UINT32 /*id*/)
474{
475//TODO
476}
477
478void KGameDialogMsgServerConfig::setAdmin(bool a)
479{
480 if (admin() == a) {
481 // no need to do anything
482 return;
483 }
484 KGameDialogConfig::setAdmin(a);
485 if (admin()) {
486 if (d->noAdmin) {
487 delete d->noAdmin;
488 d->noAdmin = 0;
489 }
490 d->changeMaxClients = new TQPushButton(i18n("Change Maximal Number of Clients"), this);
491 connect(d->changeMaxClients, TQ_SIGNAL(pressed()), this, TQ_SLOT(slotChangeMaxClients()));
492 d->changeAdmin = new TQPushButton(i18n("Change Admin"), this);
493 connect(d->changeAdmin, TQ_SIGNAL(pressed()), this, TQ_SLOT(slotChangeAdmin()));
494 d->removeClient = new TQPushButton(i18n("Remove Client with All Players"), this);
495 connect(d->removeClient, TQ_SIGNAL(pressed()), this, TQ_SLOT(slotRemoveClient()));
496 d->senderLayout->addWidget(d->changeMaxClients);
497 d->senderLayout->addWidget(d->changeAdmin);
498 d->senderLayout->addWidget(d->removeClient);
499 } else {
500 if (d->changeMaxClients) {
501 delete d->changeMaxClients;
502 d->changeMaxClients = 0;
503 }
504 if (d->changeAdmin) {
505 delete d->changeAdmin;
506 d->changeAdmin = 0;
507 }
508 if (d->removeClient) {
509 delete d->removeClient;
510 d->removeClient = 0;
511 }
512 d->noAdmin = new TQLabel(i18n("Only the admin can configure the message server!"), this);
513 d->senderLayout->addWidget(d->noAdmin);
514 }
515}
516
517
518void KGameDialogMsgServerConfig::setHasMsgServer(bool has)
519{
520 if (!has) {
521 // delete all inputs
522 if (!d->noMaster) {
523 d->noMaster = new TQLabel(i18n("You don't own the message server"), this);
524 d->localLayout->addWidget(d->noMaster);
525 }
526 return;
527 }
528 if (d->noMaster) {
529 delete d->noMaster;
530 d->noMaster = 0;
531 }
532 //TODO
533 // list all connections, data (max clients) and so on
534 // cannot be done above (together with TQPushButtons) as it is possible that
535 // this client is ADMIN but not MASTER (i.e. doesn't own the messageserver)
536}
537
538
539class KGameDialogChatConfigPrivate
540{
541public:
542 KGameDialogChatConfigPrivate()
543 {
544 mChat = 0;
545 }
546
547 KGameChat* mChat;
548};
549
550KGameDialogChatConfig::KGameDialogChatConfig(int chatMsgId, TQWidget* parent)
551 : KGameDialogConfig(parent)
552{
553 d = new KGameDialogChatConfigPrivate;
554 TQVBoxLayout* topLayout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
555 topLayout->setAutoAdd(true);
556 TQHGroupBox* b = new TQHGroupBox(i18n("Chat"), this);
557 d->mChat = new KGameChat(0, chatMsgId, b);
558}
559
560KGameDialogChatConfig::~KGameDialogChatConfig()
561{
562 kdDebug(11001) << k_funcinfo << endl;
563 delete d;
564}
565
566void KGameDialogChatConfig::setKGame(KGame* g)
567{
568 KGameDialogConfig::setKGame(g);
569 d->mChat->setKGame(game());
570 if (!game()) {
571 hide();
572 } else {
573 show();
574 }
575}
576
577void KGameDialogChatConfig::setOwner(KPlayer* p)
578{
579 KGameDialogConfig::setOwner(p);
580 if (!owner()) {
581 hide();
582 return;
583 }
584 d->mChat->setFromPlayer(owner());
585 show();
586}
587
588
589
590class KGameDialogConnectionConfigPrivate
591{
592public:
593 KGameDialogConnectionConfigPrivate()
594 {
595 mPlayerBox = 0;
596 }
597
598 TQPtrDict<KPlayer> mItem2Player;
599 TDEListBox* mPlayerBox;
600};
601
602KGameDialogConnectionConfig::KGameDialogConnectionConfig(TQWidget* parent)
603 : KGameDialogConfig(parent)
604{
605 //TODO: prevent player to ban himself
606 d = new KGameDialogConnectionConfigPrivate;
607 TQVBoxLayout* topLayout = new TQVBoxLayout(this, KDialog::marginHint(), KDialog::spacingHint());
608 topLayout->setAutoAdd(true);
609 TQHGroupBox* b = new TQHGroupBox(i18n("Connected Players"), this);
610 d->mPlayerBox = new TDEListBox(b);
611 setMinimumHeight(100);
612}
613
614KGameDialogConnectionConfig::~KGameDialogConnectionConfig()
615{
616 kdDebug(11001) << k_funcinfo << endl;
617 // d->mIem2Player.clear();
618 delete d;
619}
620
621void KGameDialogConnectionConfig::setKGame(KGame* g)
622{
623 if (game()) {
624 disconnect(game(), 0, this, 0);
625 }
626 KGameDialogConfig::setKGame(g);
627 slotClearPlayers();
628 if (game()) {
629// react to changes in KGame::playerList()
630 connect(game(), TQ_SIGNAL(signalPlayerJoinedGame(KPlayer*)),
631 this, TQ_SLOT(slotPlayerJoinedGame(KPlayer*)));
632 connect(game(), TQ_SIGNAL(signalPlayerLeftGame(KPlayer*)),
633 this, TQ_SLOT(slotPlayerLeftGame(KPlayer*)));
634
635 KGame::KGamePlayerList l = *game()->playerList();
636 for (KPlayer* p = l.first(); p; p = l.next()) {
637 slotPlayerJoinedGame(p);
638 }
639 }
640}
641
642void KGameDialogConnectionConfig::setOwner(KPlayer* p)
643{
644 KGameDialogConfig::setOwner(p);
645}
646
647void KGameDialogConnectionConfig::setAdmin(bool a)
648{
649 if (!game()) {// not possible... in theory
650 return;
651 }
652 if (admin()) {
653 disconnect(game(), TQ_SIGNAL(executed(TQListBoxItem*)), this, 0);
654 }
655 KGameDialogConfig::setAdmin(a);
656 if (admin()) {
657 connect(d->mPlayerBox, TQ_SIGNAL(executed(TQListBoxItem*)), this,
658 TQ_SLOT(slotKickPlayerOut(TQListBoxItem*)));
659 }
660}
661
662TQListBoxItem* KGameDialogConnectionConfig::item(KPlayer* p) const
663{
664 TQPtrDictIterator<KPlayer> it(d->mItem2Player);
665 while (it.current()) {
666 if (it.current() == p) {
667 return (TQListBoxItem*)it.currentKey();
668 }
669 ++it;
670 }
671 return 0;
672}
673
674void KGameDialogConnectionConfig::slotClearPlayers()
675{
676 TQPtrDictIterator<KPlayer> it(d->mItem2Player);
677 while (it.current()) {
678 slotPlayerLeftGame(it.current());
679 ++it;
680 }
681
682 if (d->mItem2Player.count() > 0) {
683 kdWarning(11001) << k_funcinfo << ": itemList wasn't cleared properly" << endl;
684 d->mItem2Player.clear();
685 }
686 if (d->mPlayerBox->count() > 0) {
687 kdWarning(11001) << k_funcinfo << ": listBox wasn't cleared properly" << endl;
688 d->mPlayerBox->clear();
689 }
690
691}
692
693void KGameDialogConnectionConfig::slotPlayerJoinedGame(KPlayer* p)
694{
695 if (!p) {
696 kdError(11001) << k_funcinfo << ": Cannot add NULL player" << endl;
697 }
698 if (d->mItem2Player[p]) {
699 kdError(11001) << k_funcinfo << ": attempt to double add player" << endl;
700 return;
701 }
702 kdDebug(11001) << k_funcinfo << ": add player " << p->id() << endl;
703 TQListBoxText* t = new TQListBoxText(p->name());
704 d->mItem2Player.insert(t, p);
705 d->mPlayerBox->insertItem(t);
706
707 connect(p, TQ_SIGNAL(signalPropertyChanged(KGamePropertyBase*, KPlayer*)),
708 this, TQ_SLOT(slotPropertyChanged(KGamePropertyBase*, KPlayer*)));
709
710}
711
712void KGameDialogConnectionConfig::slotPlayerLeftGame(KPlayer* p)
713{
714 // disconnect first
715 this->disconnect(p);
716 if (!item(p)) {
717 kdError(11001) << k_funcinfo << ": cannot find " << p->id()
718 << " in list" << endl;
719 return;
720 }
721 d->mPlayerBox->removeItem(d->mPlayerBox->index(item(p)));
722
723}
724
725void KGameDialogConnectionConfig::slotKickPlayerOut(TQListBoxItem* item)
726{
727 kdDebug(11001) << "kick player out" << endl;
728 KPlayer* p = d->mItem2Player[item];
729 if (!p) {
730 kdError(11001) << "invalid item selected - no player found" << endl;
731 return;
732 }
733 if (!game()) {
734 kdWarning(11001) << "no game set" << endl;
735 return;
736 }
737 if (!admin()) {
738 kdDebug(11001) << "Only the ADMIN can kick players" << endl;
739 return;
740 }
741 if (p == owner()) { // you wanna ban the ADMIN ??
742 kdDebug(11001) << "you cannot kick the ADMIN" << endl;
743 return;
744 }
745
746 if (KMessageBox::questionYesNo(this, i18n("Do you want to ban player \"%1\" from the game?").arg(
747 p->name()), TQString(), i18n("Ban Player"), i18n("Do Not Ban")) == KMessageBox::Yes) {
748 kdDebug(11001) << "will remove player " << p << endl;
749 game()->removePlayer(p);
750// d->mPlayerBox->removeItem(d->mPlayerBox->index(item)); // should be done by signalPlayerLeftGame
751 } else {
752 kdDebug(11001) << "will NOT remove player " << p << endl;
753 }
754}
755
756void KGameDialogConnectionConfig::slotPropertyChanged(KGamePropertyBase* prop, KPlayer* player)
757{
758 if(prop->id() == KGamePropertyBase::IdName) {
759 TQListBoxText* old = 0;
760 TQPtrDictIterator<KPlayer> it(d->mItem2Player);
761 while (it.current() && !old) {
762 if (it.current() == player) {
763 old = (TQListBoxText*)it.currentKey();
764 }
765 ++it;
766 }
767 TQListBoxText* t = new TQListBoxText(player->name());
768 d->mPlayerBox->changeItem(t, d->mPlayerBox->index(old));
769 d->mItem2Player.remove(old);
770 d->mItem2Player.insert(t, player);
771 }
772}
773
KGameChat
A Chat widget for KGame-based games.
Definition: kgamechat.h:44
KGameDialogChatConfig::setKGame
virtual void setKGame(KGame *g)
The KGame object of the dialog has been changed.
Definition: kgamedialogconfig.cpp:566
KGameDialogChatConfig::setOwner
virtual void setOwner(KPlayer *p)
The owner player of the dialog has been changed.
Definition: kgamedialogconfig.cpp:577
KGameDialogConfig
Base class for configuration widgets.
Definition: kgamedialogconfig.h:52
KGameDialogConfig::setAdmin
virtual void setAdmin(bool admin)
The admin status has been changed.
Definition: kgamedialogconfig.cpp:81
KGameDialogConfig::setOwner
virtual void setOwner(KPlayer *p)
The owner player of the dialog has been changed.
Definition: kgamedialogconfig.cpp:76
KGameDialogConfig::setKGame
virtual void setKGame(KGame *g)
The KGame object of the dialog has been changed.
Definition: kgamedialogconfig.cpp:71
KGameDialogConfig::owner
KPlayer * owner() const
A pointer to the KPlayer object that has been set by setOwner.
Definition: kgamedialogconfig.cpp:90
KGameDialogConfig::admin
bool admin() const
Definition: kgamedialogconfig.cpp:88
KGameDialogConfig::game
KGame * game() const
A pointer to the KGame object that has been set by setKGame.
Definition: kgamedialogconfig.cpp:86
KGamePropertyBase
Base class of KGameProperty.
Definition: kgameproperty.h:43
KGamePropertyBase::id
int id() const
Definition: kgameproperty.h:238
KGame
The main KDE game object.
Definition: kgame.h:63
KPlayer
Base class for a game player.
Definition: kplayer.h:70
KPlayer::name
virtual const TQString & name() const
Definition: kplayer.cpp:192
KPlayer::id
TQ_UINT32 id() const
Returns the id of the player.
Definition: kplayer.cpp:195
KPlayer::setName
void setName(const TQString &name)
Sets the name of the player.
Definition: kplayer.cpp:189

libtdegames

Skip menu "libtdegames"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdegames

Skip menu "libtdegames"
  • libtdegames
Generated for libtdegames by doxygen 1.9.4
This website is maintained by Timothy Pearson.