Merge pull request #218 from Salanto/area_message

Add Area Messages
This commit is contained in:
Salanto 2021-12-17 21:24:40 +01:00 committed by GitHub
commit 57dc4ee9ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 153 additions and 3 deletions

View File

@ -633,5 +633,20 @@
"name":"clearcm",
"usage":"/clearcm",
"text":"Removes all CMs from the current area. This command takes no arguments."
},
{
"name":"togglemessage",
"usage":"/togglemessage",
"text":"Toggles wether the client shows the area message when joining the current area."
},
{
"name":"clearmessage",
"usage":"/clearmessage",
"text":"Clears the areas message and disables automatic sending."
},
{
"name":"areamessage",
"usage":"/areamessage",
"text":"Returns the area message in OOC. If text is entered it updates the current area message."
}
]

View File

@ -984,6 +984,33 @@ class AOClient : public QObject {
*/
void cmdIgnoreBgList(int argc, QStringList argv);
/**
* @brief Returns the area message in OOC. Double to set the current area message.
*
* @details See short description.
*
* @iscommand
*/
void cmdAreaMessage(int argc, QStringList argv);
/**
* @brief Clears the areas message and disables automatic sending.
*
* @details No arguments.
*
* @iscommand
*/
void cmdClearAreaMessage(int argc, QStringList argv);
/**
* @brief Toggles wether the client shows the area message when joining the current area.
*
* @details No arguments.
*
* @iscommand
*/
void cmdToggleAreaMessageOnJoin(int argc, QStringList argv);
///@}
/**
@ -2155,7 +2182,10 @@ class AOClient : public QObject {
{"noticeg", {ACLFlags.value("SEND_NOTICE"), 1, &AOClient::cmdNoticeGlobal}},
{"togglejukebox", {ACLFlags.value("None"), 0, &AOClient::cmdToggleJukebox}},
{"help", {ACLFlags.value("NONE"), 1, &AOClient::cmdHelp}},
{"clearcm", {ACLFlags.value("KICK"), 0, &AOClient::cmdClearCM}}
{"clearcm", {ACLFlags.value("KICK"), 0, &AOClient::cmdClearCM}},
{"togglemessage", {ACLFlags.value("CM"), 0, &AOClient::cmdToggleAreaMessageOnJoin}},
{"clearmessage", {ACLFlags.value("CM"), 0, &AOClient::cmdClearAreaMessage}},
{"areamessage", {ACLFlags.value("CM"), 0, &AOClient::cmdAreaMessage}}
};
/**

View File

@ -541,6 +541,29 @@ class AreaData : public QObject {
*/
void changeDoc(const QString& f_newDoc_r);
/**
* @brief Returns the message of the area.
*
* @return See short description.
*
* @see #m_area_message
*/
QString areaMessage() const;
/**
* @brief Returns if the area's message should be sent when a user joins the area.
*
* @return See short description.
*/
bool sendAreaMessageOnJoin() const;
/**
* @brief Changes the area message in the area.
*
* @param f_newMessage_r The new message.
*/
void changeAreaMessage(const QString& f_newMessage_r);
/**
* @brief Returns the value of the Confidence bar for the defence's side.
*
@ -806,6 +829,11 @@ class AreaData : public QObject {
*/
void toggleIgnoreBgList();
/**
* @brief Toggles whether the area message is sent upon joining the area.
*/
void toggleAreaMessageJoin();
/**
* @brief Toggles wether the jukebox is enabled or not.
*/
@ -816,7 +844,7 @@ class AreaData : public QObject {
*/
QString addJukeboxSong(QString f_song);
public slots:
public slots:
/**
* @brief Plays a random song from the jukebox. Plays the same if only one is left.
@ -932,6 +960,14 @@ private:
*/
QString m_document;
/**
* @brief The message of the area.
*
* @details The area message has multiple purposes. It can be used to provide general information for
* RP or guidance for players joining the area. Unlike document it can be sent on area join. Like a MOTD, but for the area.
*/
QString m_area_message;
/**
* @brief The Confidence Gauge's value for the Defence side.
*
@ -1019,6 +1055,11 @@ private:
*/
bool m_ignoreBgList;
/**
* @brief Whether or not the area message is sent upon area join.
*/
bool m_send_area_message;
// Jukebox specific members
/**
* @brief Stores the songs added to the jukebox to be played.

View File

@ -150,6 +150,9 @@ void AOClient::changeArea(int new_area)
}
}
sendServerMessage("You moved to area " + server->m_area_names[m_current_area]);
if (server->m_areas[m_current_area]->sendAreaMessageOnJoin())
sendServerMessage(server->m_areas[m_current_area]->areaMessage());
if (server->m_areas[m_current_area]->lockStatus() == AreaData::LockStatus::SPECTATABLE)
sendServerMessage("Area " + server->m_area_names[m_current_area] + " is spectate-only; to chat IC you will need to be invited by the CM.");
}

View File

@ -26,11 +26,13 @@ AreaData::AreaData(QString p_name, int p_index) :
m_status(IDLE),
m_locked(FREE),
m_document("No document."),
m_area_message("No area message set."),
m_defHP(10),
m_proHP(10),
m_statement(0),
m_judgelog(),
m_lastICMessage()
m_lastICMessage(),
m_send_area_message(false)
{
QStringList name_split = p_name.split(":");
name_split.removeFirst();
@ -479,6 +481,24 @@ void AreaData::changeDoc(const QString &f_newDoc_r)
m_document = f_newDoc_r;
}
QString AreaData::areaMessage() const
{
return m_area_message;
}
bool AreaData::sendAreaMessageOnJoin() const
{
return m_send_area_message;
}
void AreaData::changeAreaMessage(const QString& f_newMessage_r)
{
if(f_newMessage_r.isEmpty())
m_area_message = "No area message set.";
else
m_area_message = f_newMessage_r;
}
bool AreaData::bgLocked() const
{
return m_bgLocked;
@ -524,6 +544,11 @@ void AreaData::toggleIgnoreBgList()
m_ignoreBgList = !m_ignoreBgList;
}
void AreaData::toggleAreaMessageJoin()
{
m_send_area_message = !m_send_area_message;
}
void AreaData::toggleJukebox()
{
m_jukebox = !m_jukebox;

View File

@ -372,3 +372,39 @@ void AOClient::cmdIgnoreBgList(int argc, QStringList argv)
QString l_state = l_area->ignoreBgList() ? "ignored." : "enforced.";
sendServerMessage("BG list in this area is now " + l_state);
}
void AOClient::cmdAreaMessage(int argc, QStringList argv)
{
AreaData* l_area = server->m_areas[m_current_area];
if (argc == 0) {
sendServerMessage(l_area->areaMessage());
return;
}
if (argc >= 1) {
l_area->changeAreaMessage(argv.join(" "));
sendServerMessage("Updated this area's message.");
}
}
void AOClient::cmdToggleAreaMessageOnJoin(int argc, QStringList argv)
{
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData* l_area = server->m_areas[m_current_area];
l_area->toggleAreaMessageJoin();
QString l_state = l_area->sendAreaMessageOnJoin() ? "enabled." : "disabled.";
sendServerMessage("Sending message on area join is now " +l_state);
}
void AOClient::cmdClearAreaMessage(int argc, QStringList argv)
{
Q_UNUSED(argc);
Q_UNUSED(argv);
AreaData* l_area = server->m_areas[m_current_area];
l_area->changeAreaMessage(QString{});
if (l_area->sendAreaMessageOnJoin()) //Turn off the automatic sending.
cmdToggleAreaMessageOnJoin(0,QStringList{}); //Dummy values.
}