author | koda |
Fri, 26 Oct 2012 14:19:43 +0100 | |
branch | 0.9.16 |
changeset 6007 | b3b9e995ae90 |
parent 5259 | 926958e3e87b |
child 5998 | e8f44e9433f0 |
permissions | -rw-r--r-- |
480 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
486 | 3 |
* Copyright (c) 2007 Igor Ulyanov <iulyanov@gmail.com> |
4976 | 4 |
* Copyright (c) 2007-2011 Andrey Korotaev <unC0Rr@gmail.com> |
480 | 5 |
* |
6 |
* This program is free software; you can redistribute it and/or modify |
|
7 |
* it under the terms of the GNU General Public License as published by |
|
8 |
* the Free Software Foundation; version 2 of the License |
|
9 |
* |
|
10 |
* This program 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 |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
18 |
*/ |
|
19 |
||
461 | 20 |
#ifndef _CHAT_WIDGET_INCLUDED |
21 |
#define _CHAT_WIDGET_INCLUDED |
|
22 |
||
23 |
#include <QWidget> |
|
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
1860
diff
changeset
|
24 |
#include <QListWidget> |
461 | 25 |
#include <QString> |
26 |
#include <QGridLayout> |
|
4899
8163c9aaad0c
automatically convert hedgewars.org urls to actual links (in order to make support in the lobby/rooms easier
sheepluva
parents:
4897
diff
changeset
|
27 |
#include <QRegExp> |
461 | 28 |
|
2775 | 29 |
#include "SDLs.h" |
30 |
||
4876 | 31 |
class ListWidgetNickItem; |
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
32 |
class QTextBrowser; |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
33 |
class QLineEdit; |
461 | 34 |
class QListWidget; |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
35 |
class QSettings; |
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
36 |
class SDLInteraction; |
461 | 37 |
|
4876 | 38 |
// this class is for custom nick sorting |
39 |
class ListWidgetNickItem : public QListWidgetItem |
|
40 |
{ |
|
41 |
public: |
|
4884 | 42 |
ListWidgetNickItem(const QString& nick, bool isFriend, bool isIgnored); |
4876 | 43 |
bool operator<(const QListWidgetItem & other) const; |
4884 | 44 |
void setFriend(bool isFriend); |
45 |
void setIgnored(bool isIgnored); |
|
46 |
bool isFriend(); |
|
47 |
bool ignored(); |
|
48 |
||
49 |
private: |
|
50 |
bool aFriend; |
|
51 |
bool isIgnored; |
|
4876 | 52 |
}; |
53 |
||
461 | 54 |
class HWChatWidget : public QWidget |
55 |
{ |
|
56 |
Q_OBJECT |
|
57 |
||
58 |
public: |
|
2845 | 59 |
HWChatWidget(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli, bool notify); |
60 |
void loadLists(const QString & nick); |
|
61 |
void saveLists(const QString & nick); |
|
62 |
void setShowReady(bool s); |
|
4892 | 63 |
void setShowFollow(bool enabled); |
4897
11598e7aa7e6
make names in chats clickable. still color adjustments needed; and testing
sheepluva
parents:
4892
diff
changeset
|
64 |
static const char* STYLE; |
4958
84afe376a3b3
Autokick ignored players from game room on join. Needs testing.
nemo
parents:
4899
diff
changeset
|
65 |
QStringList ignoreList, friendsList; |
2845 | 66 |
|
67 |
private: |
|
68 |
void loadList(QStringList & list, const QString & file); |
|
69 |
void saveList(QStringList & list, const QString & file); |
|
4884 | 70 |
void updateNickItem(QListWidgetItem *item); |
71 |
void updateNickItems(); |
|
4899
8163c9aaad0c
automatically convert hedgewars.org urls to actual links (in order to make support in the lobby/rooms easier
sheepluva
parents:
4897
diff
changeset
|
72 |
static const QRegExp URLREGEXP; |
461 | 73 |
|
74 |
public slots: |
|
1360 | 75 |
void onChatString(const QString& str); |
4897
11598e7aa7e6
make names in chats clickable. still color adjustments needed; and testing
sheepluva
parents:
4892
diff
changeset
|
76 |
void onChatString(const QString& nick, const QString& str); |
1587 | 77 |
void onServerMessage(const QString& str); |
2777 | 78 |
void nickAdded(const QString& nick, bool notifyNick); |
465 | 79 |
void nickRemoved(const QString& nick); |
80 |
void clear(); |
|
1405 | 81 |
void setReadyStatus(const QString & nick, bool isReady); |
1860 | 82 |
void adminAccess(bool); |
461 | 83 |
|
84 |
signals: |
|
85 |
void chatLine(const QString& str); |
|
1391 | 86 |
void kick(const QString & str); |
1860 | 87 |
void ban(const QString & str); |
1577 | 88 |
void info(const QString & str); |
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
1860
diff
changeset
|
89 |
void follow(const QString &); |
5259
926958e3e87b
display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents:
5094
diff
changeset
|
90 |
void nickCountUpdate(int cnt); |
461 | 91 |
|
92 |
private: |
|
93 |
QGridLayout mainLayout; |
|
1520
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
94 |
QTextBrowser* chatText; |
f72f538eba05
Refactor chat widget to use QTextBrower instead of QListWidget:
unc0rr
parents:
1405
diff
changeset
|
95 |
QStringList chatStrings; |
462 | 96 |
QListWidget* chatNicks; |
461 | 97 |
QLineEdit* chatEditLine; |
1860 | 98 |
QAction * acInfo; |
99 |
QAction * acKick; |
|
100 |
QAction * acBan; |
|
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
1860
diff
changeset
|
101 |
QAction * acFollow; |
2845 | 102 |
QAction * acIgnore; |
103 |
QAction * acFriend; |
|
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
104 |
QSettings * gameSettings; |
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2706
diff
changeset
|
105 |
SDLInteraction * sdli; |
2779
e1ae0019d43f
Suggestion from Tiy. Use a random hi. Could maybe be shorter sounds, using the 4 shortest voicepacks already
nemo
parents:
2777
diff
changeset
|
106 |
Mix_Chunk *sound[4]; |
2775 | 107 |
bool notify; |
2845 | 108 |
bool showReady; |
461 | 109 |
|
110 |
private slots: |
|
111 |
void returnPressed(); |
|
1860 | 112 |
void onBan(); |
1391 | 113 |
void onKick(); |
1577 | 114 |
void onInfo(); |
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
1860
diff
changeset
|
115 |
void onFollow(); |
2845 | 116 |
void onIgnore(); |
117 |
void onFriend(); |
|
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
1860
diff
changeset
|
118 |
void chatNickDoubleClicked(QListWidgetItem * item); |
2847 | 119 |
void chatNickSelected(int index); |
4897
11598e7aa7e6
make names in chats clickable. still color adjustments needed; and testing
sheepluva
parents:
4892
diff
changeset
|
120 |
void linkClicked(const QUrl & link); |
461 | 121 |
}; |
122 |
||
123 |
#endif // _CHAT_WIDGET_INCLUDED |