Commit 4125d690 authored by marco's avatar marco
Browse files

Fix merge & relative path for portable build

parents be7efa98 74533859
...@@ -7,6 +7,7 @@ RUN apt-get update && apt-get install -y\ ...@@ -7,6 +7,7 @@ RUN apt-get update && apt-get install -y\
cmake\ cmake\
git\ git\
libprotobuf-dev\ libprotobuf-dev\
libqt5sql5-mysql\
libqt5svg5-dev\ libqt5svg5-dev\
libqt5webkit5-dev\ libqt5webkit5-dev\
libsqlite3-dev\ libsqlite3-dev\
...@@ -37,4 +38,4 @@ WORKDIR /home/servatrice ...@@ -37,4 +38,4 @@ WORKDIR /home/servatrice
EXPOSE 4747 EXPOSE 4747
CMD servatrice ENTRYPOINT [ "servatrice" ]
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "pb/event_server_shutdown.pb.h" #include "pb/event_server_shutdown.pb.h"
#include "pb/event_connection_closed.pb.h" #include "pb/event_connection_closed.pb.h"
#include "pb/event_user_message.pb.h" #include "pb/event_user_message.pb.h"
#include "pb/event_notify_user.pb.h"
#include "pb/event_list_rooms.pb.h" #include "pb/event_list_rooms.pb.h"
#include "pb/event_add_to_list.pb.h" #include "pb/event_add_to_list.pb.h"
#include "pb/event_remove_from_list.pb.h" #include "pb/event_remove_from_list.pb.h"
...@@ -40,6 +41,7 @@ AbstractClient::AbstractClient(QObject *parent) ...@@ -40,6 +41,7 @@ AbstractClient::AbstractClient(QObject *parent)
qRegisterMetaType<Event_ListRooms>("Event_ListRooms"); qRegisterMetaType<Event_ListRooms>("Event_ListRooms");
qRegisterMetaType<Event_GameJoined>("Event_GameJoined"); qRegisterMetaType<Event_GameJoined>("Event_GameJoined");
qRegisterMetaType<Event_UserMessage>("Event_UserMessage"); qRegisterMetaType<Event_UserMessage>("Event_UserMessage");
qRegisterMetaType<Event_NotifyUser>("Event_NotifyUser");
qRegisterMetaType<ServerInfo_User>("ServerInfo_User"); qRegisterMetaType<ServerInfo_User>("ServerInfo_User");
qRegisterMetaType<QList<ServerInfo_User> >("QList<ServerInfo_User>"); qRegisterMetaType<QList<ServerInfo_User> >("QList<ServerInfo_User>");
qRegisterMetaType<Event_ReplayAdded>("Event_ReplayAdded"); qRegisterMetaType<Event_ReplayAdded>("Event_ReplayAdded");
...@@ -75,6 +77,7 @@ void AbstractClient::processProtocolItem(const ServerMessage &item) ...@@ -75,6 +77,7 @@ void AbstractClient::processProtocolItem(const ServerMessage &item)
case SessionEvent::SERVER_SHUTDOWN: emit serverShutdownEventReceived(event.GetExtension(Event_ServerShutdown::ext)); break; case SessionEvent::SERVER_SHUTDOWN: emit serverShutdownEventReceived(event.GetExtension(Event_ServerShutdown::ext)); break;
case SessionEvent::CONNECTION_CLOSED: emit connectionClosedEventReceived(event.GetExtension(Event_ConnectionClosed::ext)); break; case SessionEvent::CONNECTION_CLOSED: emit connectionClosedEventReceived(event.GetExtension(Event_ConnectionClosed::ext)); break;
case SessionEvent::USER_MESSAGE: emit userMessageEventReceived(event.GetExtension(Event_UserMessage::ext)); break; case SessionEvent::USER_MESSAGE: emit userMessageEventReceived(event.GetExtension(Event_UserMessage::ext)); break;
case SessionEvent::NOTIFY_USER: emit notifyUserEventReceived(event.GetExtension(Event_NotifyUser::ext)); break;
case SessionEvent::LIST_ROOMS: emit listRoomsEventReceived(event.GetExtension(Event_ListRooms::ext)); break; case SessionEvent::LIST_ROOMS: emit listRoomsEventReceived(event.GetExtension(Event_ListRooms::ext)); break;
case SessionEvent::ADD_TO_LIST: emit addToListEventReceived(event.GetExtension(Event_AddToList::ext)); break; case SessionEvent::ADD_TO_LIST: emit addToListEventReceived(event.GetExtension(Event_AddToList::ext)); break;
case SessionEvent::REMOVE_FROM_LIST: emit removeFromListEventReceived(event.GetExtension(Event_RemoveFromList::ext)); break; case SessionEvent::REMOVE_FROM_LIST: emit removeFromListEventReceived(event.GetExtension(Event_RemoveFromList::ext)); break;
......
...@@ -21,6 +21,7 @@ class Event_ServerMessage; ...@@ -21,6 +21,7 @@ class Event_ServerMessage;
class Event_ListRooms; class Event_ListRooms;
class Event_GameJoined; class Event_GameJoined;
class Event_UserMessage; class Event_UserMessage;
class Event_NotifyUser;
class Event_ConnectionClosed; class Event_ConnectionClosed;
class Event_ServerShutdown; class Event_ServerShutdown;
class Event_ReplayAdded; class Event_ReplayAdded;
...@@ -56,6 +57,7 @@ signals: ...@@ -56,6 +57,7 @@ signals:
void listRoomsEventReceived(const Event_ListRooms &event); void listRoomsEventReceived(const Event_ListRooms &event);
void gameJoinedEventReceived(const Event_GameJoined &event); void gameJoinedEventReceived(const Event_GameJoined &event);
void userMessageEventReceived(const Event_UserMessage &event); void userMessageEventReceived(const Event_UserMessage &event);
void notifyUserEventReceived(const Event_NotifyUser &event);
void userInfoChanged(const ServerInfo_User &userInfo); void userInfoChanged(const ServerInfo_User &userInfo);
void buddyListReceived(const QList<ServerInfo_User> &buddyList); void buddyListReceived(const QList<ServerInfo_User> &buddyList);
void ignoreListReceived(const QList<ServerInfo_User> &ignoreList); void ignoreListReceived(const QList<ServerInfo_User> &ignoreList);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
void DlgCreateGame::sharedCtor() void DlgCreateGame::sharedCtor()
{ {
rememberGameSettings = new QCheckBox(tr("Re&member settings"));
descriptionLabel = new QLabel(tr("&Description:")); descriptionLabel = new QLabel(tr("&Description:"));
descriptionEdit = new QLineEdit; descriptionEdit = new QLineEdit;
descriptionLabel->setBuddy(descriptionEdit); descriptionLabel->setBuddy(descriptionEdit);
...@@ -38,6 +39,7 @@ void DlgCreateGame::sharedCtor() ...@@ -38,6 +39,7 @@ void DlgCreateGame::sharedCtor()
generalGrid->addWidget(descriptionEdit, 0, 1); generalGrid->addWidget(descriptionEdit, 0, 1);
generalGrid->addWidget(maxPlayersLabel, 1, 0); generalGrid->addWidget(maxPlayersLabel, 1, 0);
generalGrid->addWidget(maxPlayersEdit, 1, 1); generalGrid->addWidget(maxPlayersEdit, 1, 1);
generalGrid->addWidget(rememberGameSettings, 2, 0);
QVBoxLayout *gameTypeLayout = new QVBoxLayout; QVBoxLayout *gameTypeLayout = new QVBoxLayout;
QMapIterator<int, QString> gameTypeIterator(gameTypes); QMapIterator<int, QString> gameTypeIterator(gameTypes);
...@@ -111,15 +113,26 @@ DlgCreateGame::DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameType ...@@ -111,15 +113,26 @@ DlgCreateGame::DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameType
{ {
sharedCtor(); sharedCtor();
rememberGameSettings->setChecked(settingsCache->getRememberGameSettings());
descriptionEdit->setText(settingsCache->getGameDescription()); descriptionEdit->setText(settingsCache->getGameDescription());
maxPlayersEdit->setValue(settingsCache->getMaxPlayers()); maxPlayersEdit->setValue(settingsCache->getMaxPlayers());
onlyBuddiesCheckBox->setChecked(settingsCache->getOnlyBuddies()); onlyBuddiesCheckBox->setChecked(settingsCache->getOnlyBuddies());
if (room && room->getUserInfo()->user_level() & ServerInfo_User::IsRegistered)
{
onlyRegisteredCheckBox->setChecked(settingsCache->getOnlyRegistered()); onlyRegisteredCheckBox->setChecked(settingsCache->getOnlyRegistered());
} else {
onlyBuddiesCheckBox->setEnabled(false);
onlyRegisteredCheckBox->setEnabled(false);
}
spectatorsAllowedCheckBox->setChecked(settingsCache->getSpectatorsAllowed()); spectatorsAllowedCheckBox->setChecked(settingsCache->getSpectatorsAllowed());
spectatorsNeedPasswordCheckBox->setChecked(settingsCache->getSpectatorsNeedPassword()); spectatorsNeedPasswordCheckBox->setChecked(settingsCache->getSpectatorsNeedPassword());
spectatorsCanTalkCheckBox->setChecked(settingsCache->getSpectatorsCanTalk()); spectatorsCanTalkCheckBox->setChecked(settingsCache->getSpectatorsCanTalk());
spectatorsSeeEverythingCheckBox->setChecked(settingsCache->getSpectatorsCanSeeEverything()); spectatorsSeeEverythingCheckBox->setChecked(settingsCache->getSpectatorsCanSeeEverything());
if (!rememberGameSettings->isChecked()){
actReset();
}
clearButton = new QPushButton(tr("&Clear")); clearButton = new QPushButton(tr("&Clear"));
buttonBox->addButton(QDialogButtonBox::Cancel); buttonBox->addButton(QDialogButtonBox::Cancel);
buttonBox->addButton(clearButton, QDialogButtonBox::ActionRole); buttonBox->addButton(clearButton, QDialogButtonBox::ActionRole);
...@@ -134,6 +147,7 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS ...@@ -134,6 +147,7 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
{ {
sharedCtor(); sharedCtor();
rememberGameSettings->setEnabled(false);
descriptionEdit->setEnabled(false); descriptionEdit->setEnabled(false);
maxPlayersEdit->setEnabled(false); maxPlayersEdit->setEnabled(false);
passwordEdit->setEnabled(false); passwordEdit->setEnabled(false);
...@@ -197,15 +211,6 @@ descriptionEdit->setFocus(); ...@@ -197,15 +211,6 @@ descriptionEdit->setFocus();
void DlgCreateGame::actOK() void DlgCreateGame::actOK()
{ {
settingsCache->setGameDescription(descriptionEdit->text());
settingsCache->setMaxPlayers(maxPlayersEdit->value());
settingsCache->setOnlyBuddies(onlyBuddiesCheckBox->isChecked());
settingsCache->setOnlyRegistered(onlyRegisteredCheckBox->isChecked());
settingsCache->setSpectatorsAllowed(spectatorsAllowedCheckBox->isChecked());
settingsCache->setSpectatorsNeedPassword(spectatorsNeedPasswordCheckBox->isChecked());
settingsCache->setSpectatorsCanTalk(spectatorsCanTalkCheckBox->isChecked());
settingsCache->setSpectatorsCanSeeEverything(spectatorsSeeEverythingCheckBox->isChecked());
Command_CreateGame cmd; Command_CreateGame cmd;
cmd.set_description(descriptionEdit->text().simplified().toStdString()); cmd.set_description(descriptionEdit->text().simplified().toStdString());
cmd.set_password(passwordEdit->text().toStdString()); cmd.set_password(passwordEdit->text().toStdString());
...@@ -227,7 +232,18 @@ void DlgCreateGame::actOK() ...@@ -227,7 +232,18 @@ void DlgCreateGame::actOK()
} }
} }
settingsCache->setRememberGameSettings(rememberGameSettings->isChecked());
if (rememberGameSettings->isChecked()){
settingsCache->setGameDescription(descriptionEdit->text());
settingsCache->setMaxPlayers(maxPlayersEdit->value());
settingsCache->setOnlyBuddies(onlyBuddiesCheckBox->isChecked());
settingsCache->setOnlyRegistered(onlyRegisteredCheckBox->isChecked());
settingsCache->setSpectatorsAllowed(spectatorsAllowedCheckBox->isChecked());
settingsCache->setSpectatorsNeedPassword(spectatorsNeedPasswordCheckBox->isChecked());
settingsCache->setSpectatorsCanTalk(spectatorsCanTalkCheckBox->isChecked());
settingsCache->setSpectatorsCanSeeEverything(spectatorsSeeEverythingCheckBox->isChecked());
settingsCache->setGameTypes(gameTypes); settingsCache->setGameTypes(gameTypes);
}
PendingCommand *pend = room->prepareRoomCommand(cmd); PendingCommand *pend = room->prepareRoomCommand(cmd);
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(checkResponse(Response))); connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(checkResponse(Response)));
room->sendRoomCommand(pend); room->sendRoomCommand(pend);
......
...@@ -39,6 +39,7 @@ private: ...@@ -39,6 +39,7 @@ private:
QCheckBox *spectatorsAllowedCheckBox, *spectatorsNeedPasswordCheckBox, *spectatorsCanTalkCheckBox, *spectatorsSeeEverythingCheckBox; QCheckBox *spectatorsAllowedCheckBox, *spectatorsNeedPasswordCheckBox, *spectatorsCanTalkCheckBox, *spectatorsSeeEverythingCheckBox;
QDialogButtonBox *buttonBox; QDialogButtonBox *buttonBox;
QPushButton *clearButton; QPushButton *clearButton;
QCheckBox *rememberGameSettings;
void sharedCtor(); void sharedCtor();
}; };
......
...@@ -34,7 +34,7 @@ DlgEditUser::DlgEditUser(QWidget *parent, QString email, int gender, QString cou ...@@ -34,7 +34,7 @@ DlgEditUser::DlgEditUser(QWidget *parent, QString email, int gender, QString cou
foreach(QString c, countries) foreach(QString c, countries)
{ {
countryEdit->addItem(QPixmap(":/resources/countries/" + c + ".svg"), c); countryEdit->addItem(QPixmap(":/resources/countries/" + c + ".svg"), c);
if(c == country) if (c == country)
countryEdit->setCurrentIndex(i); countryEdit->setCurrentIndex(i);
++i; ++i;
......
...@@ -58,9 +58,7 @@ DlgRegister::DlgRegister(QWidget *parent) ...@@ -58,9 +58,7 @@ DlgRegister::DlgRegister(QWidget *parent)
countryEdit->setCurrentIndex(0); countryEdit->setCurrentIndex(0);
QStringList countries = settingsCache->getCountries(); QStringList countries = settingsCache->getCountries();
foreach(QString c, countries) foreach(QString c, countries)
{
countryEdit->addItem(QPixmap(":/resources/countries/" + c + ".svg"), c); countryEdit->addItem(QPixmap(":/resources/countries/" + c + ".svg"), c);
}
realnameLabel = new QLabel(tr("Real name:")); realnameLabel = new QLabel(tr("Real name:"));
realnameEdit = new QLineEdit(); realnameEdit = new QLineEdit();
......
...@@ -19,7 +19,7 @@ public: ...@@ -19,7 +19,7 @@ public:
QString getPassword() const { return passwordEdit->text(); } QString getPassword() const { return passwordEdit->text(); }
QString getEmail() const { return emailEdit->text(); } QString getEmail() const { return emailEdit->text(); }
int getGender() const { return genderEdit->currentIndex() - 1; } int getGender() const { return genderEdit->currentIndex() - 1; }
QString getCountry() const { return genderEdit->currentIndex() == 0 ? "" : countryEdit->currentText(); } QString getCountry() const { return countryEdit->currentIndex() == 0 ? "" : countryEdit->currentText(); }
QString getRealName() const { return realnameEdit->text(); } QString getRealName() const { return realnameEdit->text(); }
private slots: private slots:
void actOk(); void actOk();
......
...@@ -119,7 +119,7 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr ...@@ -119,7 +119,7 @@ QPixmap CountryPixmapGenerator::generatePixmap(int height, const QString &countr
if (pmCache.contains(key)) if (pmCache.contains(key))
return pmCache.value(key); return pmCache.value(key);
QSvgRenderer svg(QString(":/resources/countries/" + countryCode + ".svg")); QSvgRenderer svg(QString(":/resources/countries/" + countryCode.toLower() + ".svg"));
int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height()); int width = (int) round(height * (double) svg.defaultSize().width() / (double) svg.defaultSize().height());
QPixmap pixmap(width, height); QPixmap pixmap(width, height);
pixmap.fill(Qt::transparent); pixmap.fill(Qt::transparent);
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "pb/event_server_identification.pb.h" #include "pb/event_server_identification.pb.h"
#include "settingscache.h" #include "settingscache.h"
#include "main.h" #include "main.h"
#include "version_string.h"
static const unsigned int protocolVersion = 14; static const unsigned int protocolVersion = 14;
...@@ -112,6 +113,7 @@ void RemoteClient::doLogin() ...@@ -112,6 +113,7 @@ void RemoteClient::doLogin()
cmdLogin.set_user_name(userName.toStdString()); cmdLogin.set_user_name(userName.toStdString());
cmdLogin.set_password(password.toStdString()); cmdLogin.set_password(password.toStdString());
cmdLogin.set_clientid(settingsCache->getClientID().toStdString()); cmdLogin.set_clientid(settingsCache->getClientID().toStdString());
cmdLogin.set_clientver(VERSION_STRING);
PendingCommand *pend = prepareSessionCommand(cmdLogin); PendingCommand *pend = prepareSessionCommand(cmdLogin);
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(loginResponse(Response))); connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(loginResponse(Response)));
sendCommand(pend); sendCommand(pend);
......
...@@ -220,6 +220,7 @@ SettingsCache::SettingsCache() ...@@ -220,6 +220,7 @@ SettingsCache::SettingsCache()
spectatorsNeedPassword = settings->value("game/spectatorsneedpassword", false).toBool(); spectatorsNeedPassword = settings->value("game/spectatorsneedpassword", false).toBool();
spectatorsCanTalk = settings->value("game/spectatorscantalk", false).toBool(); spectatorsCanTalk = settings->value("game/spectatorscantalk", false).toBool();
spectatorsCanSeeEverything = settings->value("game/spectatorscanseeeverything", false).toBool(); spectatorsCanSeeEverything = settings->value("game/spectatorscanseeeverything", false).toBool();
rememberGameSettings = settings->value("game/remembergamesettings", true).toBool();
clientID = settings->value("personal/clientid", "notset").toString(); clientID = settings->value("personal/clientid", "notset").toString();
} }
...@@ -646,3 +647,9 @@ void SettingsCache::setSpectatorsCanSeeEverything(const bool _spectatorsCanSeeEv ...@@ -646,3 +647,9 @@ void SettingsCache::setSpectatorsCanSeeEverything(const bool _spectatorsCanSeeEv
spectatorsCanSeeEverything = _spectatorsCanSeeEverything; spectatorsCanSeeEverything = _spectatorsCanSeeEverything;
settings->setValue("game/spectatorscanseeeverything", spectatorsCanSeeEverything); settings->setValue("game/spectatorscanseeeverything", spectatorsCanSeeEverything);
} }
void SettingsCache::setRememberGameSettings(const bool _rememberGameSettings)
{
rememberGameSettings = _rememberGameSettings;
settings->setValue("game/remembergamesettings", rememberGameSettings);
}
\ No newline at end of file
...@@ -115,6 +115,8 @@ private: ...@@ -115,6 +115,8 @@ private:
bool spectatorsCanSeeEverything; bool spectatorsCanSeeEverything;
int keepalive; int keepalive;
void translateLegacySettings(); void translateLegacySettings();
bool rememberGameSettings;
public: public:
SettingsCache(); SettingsCache();
QString getSettingsPath(); QString getSettingsPath();
...@@ -187,6 +189,7 @@ public: ...@@ -187,6 +189,7 @@ public:
bool getSpectatorsNeedPassword() const { return spectatorsNeedPassword; } bool getSpectatorsNeedPassword() const { return spectatorsNeedPassword; }
bool getSpectatorsCanTalk() const { return spectatorsCanTalk; } bool getSpectatorsCanTalk() const { return spectatorsCanTalk; }
bool getSpectatorsCanSeeEverything() const { return spectatorsCanSeeEverything; } bool getSpectatorsCanSeeEverything() const { return spectatorsCanSeeEverything; }
bool getRememberGameSettings() const { return rememberGameSettings; }
int getKeepAlive() const { return keepalive; } int getKeepAlive() const { return keepalive; }
void setClientID(QString clientID); void setClientID(QString clientID);
QString getClientID() { return clientID; } QString getClientID() { return clientID; }
...@@ -260,6 +263,7 @@ public slots: ...@@ -260,6 +263,7 @@ public slots:
void setSpectatorsNeedPassword(const bool _spectatorsNeedPassword); void setSpectatorsNeedPassword(const bool _spectatorsNeedPassword);
void setSpectatorsCanTalk(const bool _spectatorsCanTalk); void setSpectatorsCanTalk(const bool _spectatorsCanTalk);
void setSpectatorsCanSeeEverything(const bool _spectatorsCanSeeEverything); void setSpectatorsCanSeeEverything(const bool _spectatorsCanSeeEverything);
void setRememberGameSettings(const bool _rememberGameSettings);
}; };
extern SettingsCache *settingsCache; extern SettingsCache *settingsCache;
......
#include <QDebug>
#include <QPainter>
#include <QMessageBox>
#include <QApplication> #include <QApplication>
#include "tab_supervisor.h" #include "tab_supervisor.h"
#include "abstractclient.h" #include "abstractclient.h"
...@@ -13,14 +16,12 @@ ...@@ -13,14 +16,12 @@
#include "pixmapgenerator.h" #include "pixmapgenerator.h"
#include "userlist.h" #include "userlist.h"
#include "settingscache.h" #include "settingscache.h"
#include <QDebug>
#include <QPainter>
#include <QMessageBox>
#include "pb/room_commands.pb.h" #include "pb/room_commands.pb.h"
#include "pb/room_event.pb.h" #include "pb/room_event.pb.h"
#include "pb/game_event_container.pb.h" #include "pb/game_event_container.pb.h"
#include "pb/event_user_message.pb.h" #include "pb/event_user_message.pb.h"
#include "pb/event_notify_user.pb.h"
#include "pb/event_game_joined.pb.h" #include "pb/event_game_joined.pb.h"
#include "pb/serverinfo_user.pb.h" #include "pb/serverinfo_user.pb.h"
#include "pb/serverinfo_room.pb.h" #include "pb/serverinfo_room.pb.h"
...@@ -90,6 +91,7 @@ TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent) ...@@ -90,6 +91,7 @@ TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent)
connect(client, SIGNAL(gameJoinedEventReceived(const Event_GameJoined &)), this, SLOT(gameJoined(const Event_GameJoined &))); connect(client, SIGNAL(gameJoinedEventReceived(const Event_GameJoined &)), this, SLOT(gameJoined(const Event_GameJoined &)));
connect(client, SIGNAL(userMessageEventReceived(const Event_UserMessage &)), this, SLOT(processUserMessageEvent(const Event_UserMessage &))); connect(client, SIGNAL(userMessageEventReceived(const Event_UserMessage &)), this, SLOT(processUserMessageEvent(const Event_UserMessage &)));
connect(client, SIGNAL(maxPingTime(int, int)), this, SLOT(updatePingTime(int, int))); connect(client, SIGNAL(maxPingTime(int, int)), this, SLOT(updatePingTime(int, int)));
connect(client, SIGNAL(notifyUserEventReceived(const Event_NotifyUser &)), this, SLOT(processNotifyUserEvent(const Event_NotifyUser &)));
retranslateUi(); retranslateUi();
} }
...@@ -559,3 +561,13 @@ bool TabSupervisor::getAdminLocked() const ...@@ -559,3 +561,13 @@ bool TabSupervisor::getAdminLocked() const
return true; return true;
return tabAdmin->getLocked(); return tabAdmin->getLocked();
} }
void TabSupervisor::processNotifyUserEvent(const Event_NotifyUser &event)
{
switch ((Event_NotifyUser::NotificationType) event.type()) {
case Event_NotifyUser::PROMOTED: QMessageBox::information(this, tr("Promotion"), tr("You have been promoted to moderator. Please log out and back in for changes to take effect.")); break;
default: ;
}
}
...@@ -22,6 +22,7 @@ class RoomEvent; ...@@ -22,6 +22,7 @@ class RoomEvent;
class GameEventContainer; class GameEventContainer;
class Event_GameJoined; class Event_GameJoined;
class Event_UserMessage; class Event_UserMessage;
class Event_NotifyUser;
class ServerInfo_Room; class ServerInfo_Room;
class ServerInfo_User; class ServerInfo_User;
class GameReplay; class GameReplay;
...@@ -105,6 +106,7 @@ private slots: ...@@ -105,6 +106,7 @@ private slots:
void processRoomEvent(const RoomEvent &event); void processRoomEvent(const RoomEvent &event);
void processGameEventContainer(const GameEventContainer &cont); void processGameEventContainer(const GameEventContainer &cont);
void processUserMessageEvent(const Event_UserMessage &event); void processUserMessageEvent(const Event_UserMessage &event);
void processNotifyUserEvent(const Event_NotifyUser &event);
}; };
#endif #endif
\ No newline at end of file
#include <QAction> #include <QAction>
#include <QMenu> #include <QMenu>
#include <QMessageBox>
#include "user_context_menu.h" #include "user_context_menu.h"
#include "tab_supervisor.h" #include "tab_supervisor.h"
#include "tab_userlists.h" #include "tab_userlists.h"
...@@ -31,6 +32,8 @@ UserContextMenu::UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *p ...@@ -31,6 +32,8 @@ UserContextMenu::UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *p
aRemoveFromIgnoreList = new QAction(QString(), this); aRemoveFromIgnoreList = new QAction(QString(), this);
aKick = new QAction(QString(), this); aKick = new QAction(QString(), this);
aBan = new QAction(QString(), this); aBan = new QAction(QString(), this);
aPromoteToMod = new QAction(QString(), this);
aDemoteFromMod = new QAction(QString(), this);
retranslateUi(); retranslateUi();
} }
...@@ -46,6 +49,8 @@ void UserContextMenu::retranslateUi() ...@@ -46,6 +49,8 @@ void UserContextMenu::retranslateUi()
aRemoveFromIgnoreList->setText(tr("Remove from &ignore list")); aRemoveFromIgnoreList->setText(tr("Remove from &ignore list"));
aKick->setText(tr("Kick from &game")); aKick->setText(tr("Kick from &game"));
aBan->setText(tr("Ban from &server")); aBan->setText(tr("Ban from &server"));
aPromoteToMod->setText(tr("&Promote user to moderator"));
aDemoteFromMod->setText(tr("Dem&ote user from moderator"));
} }
void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer) void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer)
...@@ -89,6 +94,27 @@ void UserContextMenu::banUser_processUserInfoResponse(const Response &r) ...@@ -89,6 +94,27 @@ void UserContextMenu::banUser_processUserInfoResponse(const Response &r)
dlg->show(); dlg->show();
} }
void UserContextMenu::adjustMod_processUserResponse(const Response &resp, const CommandContainer &commandContainer)
{
const Command_AdjustMod &cmd = commandContainer.admin_command(0).GetExtension(Command_AdjustMod::ext);
if (resp.response_code() == Response::RespOk) {
if (cmd.should_be_mod()) {
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Success"), tr("Successfully promoted user."));
} else {
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Success"), tr("Successfully demoted user."));
}
} else {
if (cmd.should_be_mod()) {
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Failed"), tr("Failed to promote user."));
} else {
QMessageBox::information(static_cast<QWidget *>(parent()), tr("Failed"), tr("Failed to demote user."));
}
}
}
void UserContextMenu::banUser_dialogFinished() void UserContextMenu::banUser_dialogFinished()
{ {
BanDialog *dlg = static_cast<BanDialog *>(sender()); BanDialog *dlg = static_cast<BanDialog *>(sender());
...@@ -132,6 +158,14 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName ...@@ -132,6 +158,14 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
if (!tabSupervisor->getAdminLocked()) { if (!tabSupervisor->getAdminLocked()) {
menu->addSeparator(); menu->addSeparator();
menu->addAction(aBan); menu->addAction(aBan);
menu->addSeparator();
if (userLevel.testFlag(ServerInfo_User::IsModerator) && (tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin)) {
menu->addAction(aDemoteFromMod);
} else if (userLevel.testFlag(ServerInfo_User::IsRegistered) && (tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsAdmin)) {
menu->addAction(aPromoteToMod);
}
} }
bool anotherUser = userName != QString::fromStdString(tabSupervisor->getUserInfo()->name()); bool anotherUser = userName != QString::fromStdString(tabSupervisor->getUserInfo()->name());
aDetails->setEnabled(online); aDetails->setEnabled(online);
...@@ -143,6 +177,8 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName ...@@ -143,6 +177,8 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
aRemoveFromIgnoreList->setEnabled(anotherUser); aRemoveFromIgnoreList->setEnabled(anotherUser);
aKick->setEnabled(anotherUser); aKick->setEnabled(anotherUser);
aBan->setEnabled(anotherUser); aBan->setEnabled(anotherUser);
aPromoteToMod->setEnabled(anotherUser);
aDemoteFromMod->setEnabled(anotherUser);
QAction *actionClicked = menu->exec(pos); QAction *actionClicked = menu->exec(pos);
if (actionClicked == aDetails) { if (actionClicked == aDetails) {
...@@ -186,6 +222,7 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName ...@@ -186,6 +222,7 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
} else if (actionClicked == aKick) { } else if (actionClicked == aKick) {
Command_KickFromGame cmd; Command_KickFromGame cmd;
cmd.set_player_id(playerId); cmd.set_player_id(playerId);
game->sendGameCommand(cmd); game->sendGameCommand(cmd);
} else if (actionClicked == aBan) { } else if (actionClicked == aBan) {
Command_GetUserInfo cmd; Command_GetUserInfo cmd;
...@@ -193,7 +230,14 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName ...@@ -193,7 +230,14 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
PendingCommand *pend = client->prepareSessionCommand(cmd); PendingCommand *pend = client->prepareSessionCommand(cmd);
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUser_processUserInfoResponse(Response))); connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUser_processUserInfoResponse(Response)));
client->sendCommand(pend);
} else if (actionClicked == aPromoteToMod || actionClicked == aDemoteFromMod) {
Command_AdjustMod cmd;
cmd.set_user_name(userName.toStdString());
cmd.set_should_be_mod(actionClicked == aPromoteToMod);
PendingCommand *pend = client->prepareAdminCommand(cmd);
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(adjustMod_processUserResponse(Response, CommandContainer)));
client->sendCommand(pend); client->sendCommand(pend);
} }
......
...@@ -27,10 +27,12 @@ private: ...@@ -27,10 +27,12 @@ private:
QAction *aAddToIgnoreList, *aRemoveFromIgnoreList; QAction *aAddToIgnoreList, *aRemoveFromIgnoreList;
QAction *aKick; QAction *aKick;
QAction *aBan; QAction *aBan;
QAction *aPromoteToMod, *aDemoteFromMod;
signals: signals:
void openMessageDialog(const QString &userName, bool focus); void openMessageDialog(const QString &userName, bool focus);
private slots: private slots:
void banUser_processUserInfoResponse(const Response &resp); void banUser_processUserInfoResponse(const Response &resp);
void adjustMod_processUserResponse(const Response &resp, const CommandContainer &commandContainer);
void banUser_dialogFinished(); void banUser_dialogFinished();
void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer); void gamesOfUserReceived(const Response &resp, const CommandContainer &commandContainer);
public: public:
......
...@@ -31,8 +31,7 @@ ...@@ -31,8 +31,7 @@
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <QApplication> #include <QApplication>
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
// for Qt::escape() #include <QtGui/qtextdocument.h> // for Qt::escape()
#include <QtGui/qtextdocument.h>
#endif #endif
#include "main.h" #include "main.h"
...@@ -47,7 +46,6 @@ ...@@ -47,7 +46,6 @@
#include "localclient.h" #include "localclient.h"
#include "settingscache.h" #include "settingscache.h"
#include "tab_game.h" #include "tab_game.h"
#include "version_string.h" #include "version_string.h"
#include "pb/game_replay.pb.h" #include "pb/game_replay.pb.h"
...@@ -55,6 +53,14 @@ ...@@ -55,6 +53,14 @@
#include "pb/event_connection_closed.pb.h" #include "pb/event_connection_closed.pb.h"
#include "pb/event_server_shutdown.pb.h" #include "pb/event_server_shutdown.pb.h"
#define GITHUB_CONTRIBUTORS_URL "https://github.com/Cockatrice/Cockatrice/graphs/contributors?type=c"
#define GITHUB_CONTRIBUTE_URL "https://github.com/Cockatrice/Cockatrice#cockatrice"
#define GITHUB_TRANSLATOR_RECOGNIZE_URL "https://github.com/Cockatrice/Cockatrice/wiki/Translators"
#define GITHUB_TRANSLATOR_FAQ_URL "https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ"
#define GITHUB_ISSUES_URL "https://github.com/Cockatrice/Cockatrice/issues"
#define GITHUB_TROUBLESHOOTING_URL "https://github.com/Cockatrice/Cockatrice/wiki/Troubleshooting"
#define GITHUB_FAQ_URL "https://github.com/Cockatrice/Cockatrice/wiki/Frequently-Asked-Questions"
const QString MainWindow::appName = "Cockatrice"; const QString MainWindow::appName = "Cockatrice";
void MainWindow::updateTabMenu(const QList<QMenu *> &newMenuList) void MainWindow::updateTabMenu(const QList<QMenu *> &newMenuList)
...@@ -85,6 +91,7 @@ void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &even ...@@ -85,6 +91,7 @@ void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &even
} }
case Event_ConnectionClosed::SERVER_SHUTDOWN: reasonStr = tr("Scheduled server shutdown."); break; case Event_ConnectionClosed::SERVER_SHUTDOWN: reasonStr = tr("Scheduled server shutdown."); break;
case Event_ConnectionClosed::USERNAMEINVALID: reasonStr = tr("Invalid username."); break; case Event_ConnectionClosed::USERNAMEINVALID: reasonStr = tr("Invalid username."); break;
case Event_ConnectionClosed::LOGGEDINELSEWERE: reasonStr = tr("You have been logged out due to logging in at another location."); break;
default: reasonStr = QString::fromStdString(event.reason_str()); default: reasonStr = QString::fromStdString(event.reason_str());
} }
QMessageBox::critical(this, tr("Connection closed"), tr("The server has terminated your connection.\nReason: %1").arg(reasonStr)); QMessageBox::critical(this, tr("Connection closed"), tr("The server has terminated your connection.\nReason: %1").arg(reasonStr));
...@@ -268,15 +275,15 @@ void MainWindow::actAbout() ...@@ -268,15 +275,15 @@ void MainWindow::actAbout()
+ "<br><br><b>" + tr("Project Manager:") + "</b><br>Gavin Bisesi<br><br>" + "<br><br><b>" + tr("Project Manager:") + "</b><br>Gavin Bisesi<br><br>"
+ "<b>" + tr("Past Project Managers:") + "</b><br>Max-Wilhelm Bruker<br>Marcus Schütz<br><br>" + "<b>" + tr("Past Project Managers:") + "</b><br>Max-Wilhelm Bruker<br>Marcus Schütz<br><br>"
+ "<b>" + tr("Developers:") + "</b><br>" + "<b>" + tr("Developers:") + "</b><br>"
+ "<a href='https://github.com/Cockatrice/Cockatrice/graphs/contributors?type=c'>" + tr("Our Developers") + "</a><br>" + "<a href='" + GITHUB_CONTRIBUTORS_URL + "'>" + tr("Our Developers") + "</a><br>"
+ "<a href='https://github.com/Cockatrice/Cockatrice#cockatrice'>" + tr("Help Develop!") + "</a><br><br>" + "<a href='" + GITHUB_CONTRIBUTE_URL + "'>" + tr("Help Develop!") + "</a><br><br>"
+ "<b>" + tr("Translators:") + "</b><br>" + "<b>" + tr("Translators:") + "</b><br>"
+ "<a href='https://github.com/Cockatrice/Cockatrice/wiki/Translators'>" + tr("Recognition Page") + "</a><br>" + "<a href='" + GITHUB_TRANSLATOR_RECOGNIZE_URL + "'>" + tr("Recognition Page") + "</a><br>"
+ "<a href='https://github.com/Cockatrice/Cockatrice/wiki/Translation-FAQ'>" + tr("Help Translate!") + "</a><br><br>" + "<a href='" + GITHUB_TRANSLATOR_FAQ_URL + "'>" + tr("Help Translate!") + "</a><br><br>"
+ "<b>" + tr("Support:") + "</b><br>" + "<b>" + tr("Support:") + "</b><br>"
+ "<a href='https://github.com/Cockatrice/Cockatrice/issues'>" + tr("Report an Issue") + "</a><br>" + "<a href='" + GITHUB_ISSUES_URL + "'>" + tr("Report an Issue") + "</a><br>"
+ "<a href='https://github.com/Cockatrice/Cockatrice/wiki/Troubleshooting'>" + tr("Troubleshooting") + "</a><br>" + "<a href='" + GITHUB_TROUBLESHOOTING_URL + "'>" + tr("Troubleshooting") + "</a><br>"
+ "<a href='https://github.com/Cockatrice/Cockatrice/wiki/Frequently-Asked-Questions'>" + tr("F.A.Q.") + "</a><br>" + "<a href='" + GITHUB_FAQ_URL + "'>" + tr("F.A.Q.") + "</a><br>"
)); ));
} }
......
This diff is collapsed.
...@@ -106,6 +106,7 @@ SET(PROTO_FILES ...@@ -106,6 +106,7 @@ SET(PROTO_FILES
event_user_joined.proto event_user_joined.proto
event_user_left.proto event_user_left.proto
event_user_message.proto event_user_message.proto
event_notify_user.proto
game_commands.proto game_commands.proto
game_event_container.proto game_event_container.proto
game_event_context.proto game_event_context.proto
...@@ -127,6 +128,7 @@ SET(PROTO_FILES ...@@ -127,6 +128,7 @@ SET(PROTO_FILES
response_register.proto response_register.proto
response_replay_download.proto response_replay_download.proto
response_replay_list.proto response_replay_list.proto
response_adjust_mod.proto
response.proto response.proto
room_commands.proto room_commands.proto
room_event.proto room_event.proto
......
...@@ -3,6 +3,7 @@ message AdminCommand { ...@@ -3,6 +3,7 @@ message AdminCommand {
UPDATE_SERVER_MESSAGE = 1000; UPDATE_SERVER_MESSAGE = 1000;
SHUTDOWN_SERVER = 1001; SHUTDOWN_SERVER = 1001;
RELOAD_CONFIG = 1002; RELOAD_CONFIG = 1002;
ADJUST_MOD = 1003;
} }
extensions 100 to max; extensions 100 to max;
} }
...@@ -26,3 +27,12 @@ message Command_ReloadConfig { ...@@ -26,3 +27,12 @@ message Command_ReloadConfig {
optional Command_ReloadConfig ext = 1002; optional Command_ReloadConfig ext = 1002;
} }
} }
message Command_AdjustMod {
extend AdminCommand {
optional Command_AdjustMod ext = 1003;
}
required string user_name = 1;
required bool should_be_mod = 2;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment