Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
29b83c37
Commit
29b83c37
authored
Jul 06, 2015
by
Zach
Browse files
Merge pull request #1215 from ZeldaZach/fix_1208
Mod Global Messaging
parents
4cf92de4
ae4436ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/chatview.cpp
View file @
29b83c37
...
...
@@ -171,7 +171,7 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
{
// search for the first [ or @
bracketFirstIndex
=
message
.
indexOf
(
'['
);
mentionFirstIndex
=
mentionEnabled
?
message
.
indexOf
(
'@'
)
:
-
1
;
mentionFirstIndex
=
message
.
indexOf
(
'@'
);
urlFirstIndex
=
message
.
indexOf
(
urlStarter
);
bool
startsWithBracket
=
(
bracketFirstIndex
!=
-
1
);
...
...
@@ -298,20 +298,19 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
}
else
if
(
index
==
mentionFirstIndex
)
{
if
(
tabSupervisor
->
getIsLocalGame
())
int
firstSpace
=
message
.
indexOf
(
" "
);
QString
fullMentionUpToSpaceOrEnd
=
(
firstSpace
==
-
1
)
?
message
.
mid
(
1
)
:
message
.
mid
(
1
,
firstSpace
-
1
);
QString
mentionIntact
=
fullMentionUpToSpaceOrEnd
;
if
((
!
mentionEnabled
&&
!
isModeratorSendingGlobal
(
userLevel
,
fullMentionUpToSpaceOrEnd
))
||
tabSupervisor
->
getIsLocalGame
())
{
cursor
.
insertText
(
"@"
);
message
=
message
.
mid
(
1
);
}
else
{
QMap
<
QString
,
UserListTWI
*>
userList
=
tabSupervisor
->
getUserListsTab
()
->
getAllUsersList
()
->
getUsers
();
int
firstSpace
=
message
.
indexOf
(
" "
);
QString
fullMentionUpToSpaceOrEnd
=
(
firstSpace
==
-
1
)
?
message
.
mid
(
1
)
:
message
.
mid
(
1
,
firstSpace
-
1
);
QString
mentionIntact
=
fullMentionUpToSpaceOrEnd
;
do
{
if
(
isFullMentionAValidUser
(
userList
,
fullMentionUpToSpaceOrEnd
))
// Is there a user online named this?
...
...
@@ -343,6 +342,23 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
cursor
.
setCharFormat
(
defaultFormat
);
break
;
}
else
if
(
isModeratorSendingGlobal
(
userLevel
,
fullMentionUpToSpaceOrEnd
))
{
// Moderator Sending Global Message
mentionFormat
.
setBackground
(
QBrush
(
getCustomMentionColor
()));
mentionFormat
.
setForeground
(
settingsCache
->
getChatMentionForeground
()
?
QBrush
(
Qt
::
white
)
:
QBrush
(
Qt
::
black
));
cursor
.
insertText
(
"@"
+
fullMentionUpToSpaceOrEnd
,
mentionFormat
);
message
=
message
.
mid
(
fullMentionUpToSpaceOrEnd
.
size
()
+
1
);
QApplication
::
alert
(
this
);
if
(
settingsCache
->
getShowMentionPopup
()
&&
shouldShowSystemPopup
())
{
QString
ref
=
sender
.
left
(
sender
.
length
()
-
2
);
showSystemPopup
(
ref
);
}
cursor
.
setCharFormat
(
defaultFormat
);
break
;
}
else
if
(
fullMentionUpToSpaceOrEnd
.
right
(
1
).
indexOf
(
notALetterOrNumber
)
==
-
1
||
fullMentionUpToSpaceOrEnd
.
size
()
<
2
)
{
cursor
.
insertText
(
"@"
+
mentionIntact
,
defaultFormat
);
...
...
@@ -368,6 +384,19 @@ void ChatView::appendMessage(QString message, QString sender, UserLevelFlags use
verticalScrollBar
()
->
setValue
(
verticalScrollBar
()
->
maximum
());
}
bool
ChatView
::
isModeratorSendingGlobal
(
QFlags
<
ServerInfo_User
::
UserLevelFlag
>
userLevelFlag
,
QString
message
)
{
int
userLevel
=
QString
::
number
(
userLevelFlag
).
toInt
();
QStringList
getAttentionList
;
getAttentionList
<<
"/all"
;
// Send a message to all users
if
(
getAttentionList
.
contains
(
message
)
&&
(
userLevel
&
ServerInfo_User
::
IsModerator
||
userLevel
&
ServerInfo_User
::
IsAdmin
))
return
true
;
return
false
;
}
void
ChatView
::
actMessageClicked
()
{
emit
messageClickedSignal
();
}
...
...
cockatrice/src/chatview.h
View file @
29b83c37
...
...
@@ -43,6 +43,7 @@ private:
QColor
getCustomMentionColor
();
bool
shouldShowSystemPopup
();
void
showSystemPopup
(
QString
&
sender
);
bool
isModeratorSendingGlobal
(
QFlags
<
ServerInfo_User
::
UserLevelFlag
>
userLevelFlag
,
QString
message
);
private
slots
:
void
openLink
(
const
QUrl
&
link
);
void
actMessageClicked
();
...
...
common/pb/serverinfo_user.proto
View file @
29b83c37
message
ServerInfo_User
{
enum
UserLevelFlag
{
IsNothing
=
0
;
IsUser
=
1
;
IsRegistered
=
2
;
IsModerator
=
4
;
IsAdmin
=
8
;
};
enum
Gender
{
GenderUnknown
=
-
1
;
Male
=
0
;
Female
=
1
;
};
optional
string
name
=
1
;
optional
uint32
user_level
=
2
;
optional
string
address
=
3
;
optional
string
real_name
=
4
;
optional
Gender
gender
=
5
[
default
=
GenderUnknown
];
optional
string
country
=
6
;
optional
bytes
avatar_bmp
=
7
;
optional
sint32
id
=
8
[
default
=
-
1
];
optional
sint32
server_id
=
9
[
default
=
-
1
];
optional
uint64
session_id
=
10
;
enum
UserLevelFlag
{
IsNothing
=
0
;
IsUser
=
1
;
IsRegistered
=
2
;
IsModerator
=
4
;
IsAdmin
=
8
;
};
enum
Gender
{
GenderUnknown
=
-
1
;
Male
=
0
;
Female
=
1
;
};
optional
string
name
=
1
;
optional
uint32
user_level
=
2
;
optional
string
address
=
3
;
optional
string
real_name
=
4
;
optional
Gender
gender
=
5
[
default
=
GenderUnknown
];
optional
string
country
=
6
;
optional
bytes
avatar_bmp
=
7
;
optional
sint32
id
=
8
[
default
=
-
1
];
optional
sint32
server_id
=
9
[
default
=
-
1
];
optional
uint64
session_id
=
10
;
optional
uint64
accountage_secs
=
11
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment