Merge remote-tracking branch 'origin/master' into show-password-games-by-default
This commit is contained in:
commit
86b92a25de
21 changed files with 216 additions and 165 deletions
|
@ -16,7 +16,7 @@ InstallDir "$PROGRAMFILES\Cockatrice"
|
|||
!define MUI_HEADERIMAGE_UNBITMAP "${NSIS_SOURCE_PATH}\cmake\headerimage.bmp"
|
||||
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Cockatrice.$\r$\n$\r$\nClick Next to continue."
|
||||
!define MUI_FINISHPAGE_RUN "$INSTDIR/oracle.exe"
|
||||
!define MUI_FINISHPAGE_RUN_TEXT "Run "Oracle" now to update your card database"
|
||||
!define MUI_FINISHPAGE_RUN_TEXT "Run 'Oracle' now to update your card database"
|
||||
!define MUI_FINISHPAGE_RUN_PARAMETERS "-dlsets"
|
||||
|
||||
!insertmacro MUI_PAGE_WELCOME
|
||||
|
|
|
@ -31,12 +31,14 @@
|
|||
<file>resources/icon_view.svg</file>
|
||||
<file>resources/hr.jpg</file>
|
||||
<file alias="resources/appicon.svg">resources/cockatrice.svg</file>
|
||||
|
||||
<file>resources/add_to_sideboard.svg</file>
|
||||
<file>resources/decrement.svg</file>
|
||||
<file>resources/increment.svg</file>
|
||||
<file>resources/remove_row.svg</file>
|
||||
<file>resources/arrow_left_green.svg</file>
|
||||
<file>resources/arrow_right_green.svg</file>
|
||||
|
||||
<file>resources/icon_ready_start.svg</file>
|
||||
<file>resources/icon_not_ready_start.svg</file>
|
||||
<file>resources/icon_conceded.svg</file>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
|
@ -13,9 +14,9 @@
|
|||
height="64"
|
||||
id="svg2646"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.46"
|
||||
inkscape:version="0.48.5 r10040"
|
||||
version="1.0"
|
||||
sodipodi:docname="decrement.svg"
|
||||
sodipodi:docname="deck_editor_decrement.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape">
|
||||
<defs
|
||||
id="defs2648">
|
||||
|
@ -161,15 +162,16 @@
|
|||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="7.625"
|
||||
inkscape:cx="-58.636066"
|
||||
inkscape:cy="34.091284"
|
||||
inkscape:cx="26.34754"
|
||||
inkscape:cy="29.107677"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer2"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1272"
|
||||
inkscape:window-height="723"
|
||||
inkscape:window-width="1445"
|
||||
inkscape:window-height="893"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="25" />
|
||||
inkscape:window-y="25"
|
||||
inkscape:window-maximized="0" />
|
||||
<metadata
|
||||
id="metadata2651">
|
||||
<rdf:RDF>
|
||||
|
@ -192,7 +194,7 @@
|
|||
inkscape:label="Pfeil"
|
||||
style="display:inline">
|
||||
<rect
|
||||
style="fill:#96ff96;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline"
|
||||
style="fill:#ff7672;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline"
|
||||
id="rect3548"
|
||||
width="14.386732"
|
||||
height="59.259636"
|
||||
|
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.2 KiB |
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
|
@ -13,9 +14,9 @@
|
|||
height="64"
|
||||
id="svg2646"
|
||||
sodipodi:version="0.32"
|
||||
inkscape:version="0.46"
|
||||
inkscape:version="0.48.5 r10040"
|
||||
version="1.0"
|
||||
sodipodi:docname="remove_row.svg"
|
||||
sodipodi:docname="deck_editor_remove_row.svg"
|
||||
inkscape:output_extension="org.inkscape.output.svg.inkscape">
|
||||
<defs
|
||||
id="defs2648">
|
||||
|
@ -316,15 +317,16 @@
|
|||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="7.625"
|
||||
inkscape:cx="-50.74814"
|
||||
inkscape:cy="31.784541"
|
||||
inkscape:cx="-27.27273"
|
||||
inkscape:cy="30.210771"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer2"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1272"
|
||||
inkscape:window-height="723"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="25" />
|
||||
inkscape:window-y="25"
|
||||
inkscape:window-maximized="0" />
|
||||
<metadata
|
||||
id="metadata2651">
|
||||
<rdf:RDF>
|
||||
|
@ -347,7 +349,7 @@
|
|||
inkscape:label="Pfeil"
|
||||
style="display:inline">
|
||||
<path
|
||||
style="fill:#96ff96;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline"
|
||||
style="fill:#ff7672;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;display:inline"
|
||||
d="M 6.433227,14.50946 L 23.923767,32 L 6.433227,49.490541 L 14.50946,57.566773 L 32,40.076233 L 49.490541,57.566773 L 57.566773,49.490541 L 40.076233,32 L 57.566773,14.50946 L 49.490541,6.433227 L 32,23.923767 L 14.50946,6.433227 L 6.433227,14.50946 z"
|
||||
id="rect3548" />
|
||||
</g>
|
||||
|
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
@ -32,7 +32,7 @@ void DeckStatsInterface::queryFinished(QNetworkReply *reply)
|
|||
QString data(reply->readAll());
|
||||
reply->deleteLater();
|
||||
|
||||
QRegExp rx("id=\"deckstats_deck_url\" value=\"([^\"]+)\"");
|
||||
QRegExp rx("<meta property=\"og:url\" content=\"([^\"]+)\"/>");
|
||||
if (!rx.indexIn(data)) {
|
||||
QMessageBox::critical(0, tr("Error"), tr("The reply from the server could not be parsed."));
|
||||
deleteLater();
|
||||
|
@ -53,11 +53,13 @@ void DeckStatsInterface::getAnalyzeRequestData(DeckList *deck, QByteArray *data)
|
|||
#if QT_VERSION < 0x050000
|
||||
QUrl params;
|
||||
params.addQueryItem("deck", deckWithoutTokens.writeToString_Plain());
|
||||
params.addQueryItem("decktitle", deck->getName());
|
||||
data->append(params.encodedQuery());
|
||||
#else
|
||||
QUrl params;
|
||||
QUrlQuery urlQuery;
|
||||
urlQuery.addQueryItem("deck", deckWithoutTokens.writeToString_Plain());
|
||||
urlQuery.addQueryItem("decktitle", deck->getName());
|
||||
params.setQuery(urlQuery);
|
||||
data->append(params.query(QUrl::EncodeReserved));
|
||||
#endif
|
||||
|
|
|
@ -31,13 +31,13 @@ void DlgCreateGame::sharedCtor()
|
|||
maxPlayersEdit->setMaximum(100);
|
||||
maxPlayersEdit->setValue(2);
|
||||
maxPlayersLabel->setBuddy(maxPlayersEdit);
|
||||
|
||||
|
||||
QGridLayout *generalGrid = new QGridLayout;
|
||||
generalGrid->addWidget(descriptionLabel, 0, 0);
|
||||
generalGrid->addWidget(descriptionEdit, 0, 1);
|
||||
generalGrid->addWidget(maxPlayersLabel, 1, 0);
|
||||
generalGrid->addWidget(maxPlayersEdit, 1, 1);
|
||||
|
||||
|
||||
QVBoxLayout *gameTypeLayout = new QVBoxLayout;
|
||||
QMapIterator<int, QString> gameTypeIterator(gameTypes);
|
||||
while (gameTypeIterator.hasNext()) {
|
||||
|
@ -48,7 +48,7 @@ void DlgCreateGame::sharedCtor()
|
|||
}
|
||||
QGroupBox *gameTypeGroupBox = new QGroupBox(tr("Game type"));
|
||||
gameTypeGroupBox->setLayout(gameTypeLayout);
|
||||
|
||||
|
||||
passwordLabel = new QLabel(tr("&Password:"));
|
||||
passwordEdit = new QLineEdit;
|
||||
passwordLabel->setBuddy(passwordEdit);
|
||||
|
@ -60,18 +60,18 @@ void DlgCreateGame::sharedCtor()
|
|||
onlyRegisteredCheckBox->setChecked(true);
|
||||
} else {
|
||||
onlyBuddiesCheckBox->setEnabled(false);
|
||||
onlyRegisteredCheckBox->setEnabled(false);
|
||||
onlyRegisteredCheckBox->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
QGridLayout *joinRestrictionsLayout = new QGridLayout;
|
||||
joinRestrictionsLayout->addWidget(passwordLabel, 0, 0);
|
||||
joinRestrictionsLayout->addWidget(passwordEdit, 0, 1);
|
||||
joinRestrictionsLayout->addWidget(onlyBuddiesCheckBox, 1, 0, 1, 2);
|
||||
joinRestrictionsLayout->addWidget(onlyRegisteredCheckBox, 2, 0, 1, 2);
|
||||
|
||||
|
||||
QGroupBox *joinRestrictionsGroupBox = new QGroupBox(tr("Joining restrictions"));
|
||||
joinRestrictionsGroupBox->setLayout(joinRestrictionsLayout);
|
||||
|
||||
|
||||
spectatorsAllowedCheckBox = new QCheckBox(tr("&Spectators allowed"));
|
||||
spectatorsAllowedCheckBox->setChecked(true);
|
||||
connect(spectatorsAllowedCheckBox, SIGNAL(stateChanged(int)), this, SLOT(spectatorsAllowedChanged(int)));
|
||||
|
@ -94,7 +94,7 @@ void DlgCreateGame::sharedCtor()
|
|||
|
||||
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
|
||||
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addLayout(grid);
|
||||
mainLayout->addWidget(buttonBox);
|
||||
|
@ -108,10 +108,10 @@ DlgCreateGame::DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameType
|
|||
: QDialog(parent), room(_room), gameTypes(_gameTypes)
|
||||
{
|
||||
sharedCtor();
|
||||
|
||||
|
||||
buttonBox->addButton(QDialogButtonBox::Cancel);
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actOK()));
|
||||
|
||||
|
||||
setWindowTitle(tr("Create game"));
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
|
|||
: QDialog(parent), room(0), gameTypes(_gameTypes)
|
||||
{
|
||||
sharedCtor();
|
||||
|
||||
|
||||
descriptionEdit->setEnabled(false);
|
||||
maxPlayersEdit->setEnabled(false);
|
||||
passwordEdit->setEnabled(false);
|
||||
|
@ -129,7 +129,7 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
|
|||
spectatorsNeedPasswordCheckBox->setEnabled(false);
|
||||
spectatorsCanTalkCheckBox->setEnabled(false);
|
||||
spectatorsSeeEverythingCheckBox->setEnabled(false);
|
||||
|
||||
|
||||
descriptionEdit->setText(QString::fromStdString(gameInfo.description()));
|
||||
maxPlayersEdit->setValue(gameInfo.max_players());
|
||||
onlyBuddiesCheckBox->setChecked(gameInfo.only_buddies());
|
||||
|
@ -138,29 +138,29 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
|
|||
spectatorsNeedPasswordCheckBox->setChecked(gameInfo.spectators_need_password());
|
||||
spectatorsCanTalkCheckBox->setChecked(gameInfo.spectators_can_chat());
|
||||
spectatorsSeeEverythingCheckBox->setChecked(gameInfo.spectators_omniscient());
|
||||
|
||||
|
||||
QSet<int> types;
|
||||
for (int i = 0; i < gameInfo.game_types_size(); ++i)
|
||||
types.insert(gameInfo.game_types(i));
|
||||
|
||||
|
||||
QMapIterator<int, QString> gameTypeIterator(gameTypes);
|
||||
while (gameTypeIterator.hasNext()) {
|
||||
gameTypeIterator.next();
|
||||
|
||||
|
||||
QCheckBox *gameTypeCheckBox = gameTypeCheckBoxes.value(gameTypeIterator.key());
|
||||
gameTypeCheckBox->setEnabled(false);
|
||||
gameTypeCheckBox->setChecked(types.contains(gameTypeIterator.key()));
|
||||
}
|
||||
|
||||
|
||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
|
||||
|
||||
setWindowTitle(tr("Game information"));
|
||||
}
|
||||
|
||||
void DlgCreateGame::actOK()
|
||||
{
|
||||
Command_CreateGame cmd;
|
||||
cmd.set_description(descriptionEdit->text().toStdString());
|
||||
cmd.set_description(descriptionEdit->text().simplified().toStdString());
|
||||
cmd.set_password(passwordEdit->text().toStdString());
|
||||
cmd.set_max_players(maxPlayersEdit->value());
|
||||
cmd.set_only_buddies(onlyBuddiesCheckBox->isChecked());
|
||||
|
@ -169,18 +169,18 @@ void DlgCreateGame::actOK()
|
|||
cmd.set_spectators_need_password(spectatorsNeedPasswordCheckBox->isChecked());
|
||||
cmd.set_spectators_can_talk(spectatorsCanTalkCheckBox->isChecked());
|
||||
cmd.set_spectators_see_everything(spectatorsSeeEverythingCheckBox->isChecked());
|
||||
|
||||
|
||||
QMapIterator<int, QCheckBox *> gameTypeCheckBoxIterator(gameTypeCheckBoxes);
|
||||
while (gameTypeCheckBoxIterator.hasNext()) {
|
||||
gameTypeCheckBoxIterator.next();
|
||||
if (gameTypeCheckBoxIterator.value()->isChecked())
|
||||
cmd.add_game_type_ids(gameTypeCheckBoxIterator.key());
|
||||
}
|
||||
|
||||
|
||||
PendingCommand *pend = room->prepareRoomCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(checkResponse(Response)));
|
||||
room->sendRoomCommand(pend);
|
||||
|
||||
|
||||
buttonBox->setEnabled(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "pb/serverinfo_game.pb.h"
|
||||
#include "pb/response.pb.h"
|
||||
|
||||
GameSelector::GameSelector(AbstractClient *_client, const TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QWidget *parent)
|
||||
GameSelector::GameSelector(AbstractClient *_client, const TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, const bool restoresettings, QWidget *parent)
|
||||
: QGroupBox(parent), client(_client), tabSupervisor(_tabSupervisor), room(_room)
|
||||
{
|
||||
gameListView = new QTreeView;
|
||||
|
@ -36,7 +36,8 @@ GameSelector::GameSelector(AbstractClient *_client, const TabSupervisor *_tabSup
|
|||
if (room)
|
||||
gameTypeMap = gameListModel->getGameTypes().value(room->getRoomId());
|
||||
|
||||
gameListProxyModel->loadFilterParameters(gameTypeMap);
|
||||
if (restoresettings)
|
||||
gameListProxyModel->loadFilterParameters(gameTypeMap);
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
gameListView->header()->setResizeMode(0, QHeaderView::ResizeToContents);
|
||||
|
|
|
@ -36,7 +36,7 @@ private:
|
|||
QPushButton *filterButton, *clearFilterButton, *createButton, *joinButton, *spectateButton;
|
||||
GameTypeMap gameTypeMap;
|
||||
public:
|
||||
GameSelector(AbstractClient *_client, const TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, QWidget *parent = 0);
|
||||
GameSelector(AbstractClient *_client, const TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap<int, QString> &_rooms, const QMap<int, GameTypeMap> &_gameTypes, const bool restoresettings, QWidget *parent = 0);
|
||||
void retranslateUi();
|
||||
void processGameInfo(const ServerInfo_Game &info);
|
||||
};
|
||||
|
|
|
@ -298,7 +298,6 @@ void GamesProxyModel::loadFilterParameters(const QMap<int, QString> &allGameType
|
|||
unavailableGamesVisible = settings.value("unavailable_games_visible", false).toBool();
|
||||
passwordProtectedGamesHidden = settings.value("password_protected_games_hidden", false).toBool();
|
||||
gameNameFilter = settings.value("game_name_filter", "").toString();
|
||||
creatorNameFilter = settings.value("creator_name_filter", "").toString();
|
||||
maxPlayersFilterMin = settings.value("min_players", 1).toInt();
|
||||
maxPlayersFilterMax = settings.value("max_players", DEFAULT_MAX_PLAYERS_MAX).toInt();
|
||||
|
||||
|
@ -324,8 +323,7 @@ void GamesProxyModel::saveFilterParameters(const QMap<int, QString> &allGameType
|
|||
passwordProtectedGamesHidden
|
||||
);
|
||||
settings.setValue("game_name_filter", gameNameFilter);
|
||||
settings.setValue("creator_name_filter", creatorNameFilter);
|
||||
|
||||
|
||||
QMapIterator<int, QString> gameTypeIterator(allGameTypes);
|
||||
while (gameTypeIterator.hasNext()) {
|
||||
gameTypeIterator.next();
|
||||
|
|
|
@ -46,7 +46,7 @@ SettingsCache::SettingsCache()
|
|||
tapAnimation = settings->value("cards/tapanimation", true).toBool();
|
||||
chatMention = settings->value("chat/mention", true).toBool();
|
||||
chatMentionForeground = settings->value("chat/mentionforeground", true).toBool();
|
||||
chatMentionColor = settings->value("chat/mentioncolor", "C21F2F").toString();
|
||||
chatMentionColor = settings->value("chat/mentioncolor", "A6120D").toString();
|
||||
|
||||
zoneViewSortByName = settings->value("zoneview/sortbyname", true).toBool();
|
||||
zoneViewSortByType = settings->value("zoneview/sortbytype", true).toBool();
|
||||
|
|
|
@ -276,8 +276,8 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
deckEditToolBar->addAction(aAddCard);
|
||||
deckEditToolBar->addAction(aAddCardToSideboard);
|
||||
deckEditToolBar->addAction(aRemoveCard);
|
||||
deckEditToolBar->addAction(aIncrement);
|
||||
deckEditToolBar->addAction(aDecrement);
|
||||
deckEditToolBar->addAction(aIncrement);
|
||||
deckEditToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
|
||||
retranslateUi();
|
||||
|
|
|
@ -885,6 +885,7 @@ void TabGame::startGame(bool resuming)
|
|||
gameInfo.set_started(true);
|
||||
static_cast<GameScene *>(gameView->scene())->rearrange();
|
||||
gameView->show();
|
||||
sayEdit->setFocus();
|
||||
}
|
||||
|
||||
void TabGame::stopGame()
|
||||
|
|
|
@ -18,6 +18,7 @@ TabMessage::TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, c
|
|||
chatView = new ChatView(tabSupervisor, 0, true);
|
||||
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||
connect(chatView, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||
connect(chatView, SIGNAL(addMentionTag(QString)), this, SLOT(addMentionTag(QString)));
|
||||
sayEdit = new QLineEdit;
|
||||
connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage()));
|
||||
|
||||
|
@ -43,6 +44,11 @@ TabMessage::~TabMessage()
|
|||
delete otherUserInfo;
|
||||
}
|
||||
|
||||
void TabMessage::addMentionTag(QString mentionTag) {
|
||||
sayEdit->insert(mentionTag + " ");
|
||||
sayEdit->setFocus();
|
||||
}
|
||||
|
||||
void TabMessage::retranslateUi()
|
||||
{
|
||||
messageMenu->setTitle(tr("Personal &talk"));
|
||||
|
|
|
@ -29,6 +29,7 @@ private slots:
|
|||
void sendMessage();
|
||||
void actLeave();
|
||||
void messageSent(const Response &response);
|
||||
void addMentionTag(QString mentionTag);
|
||||
public:
|
||||
TabMessage(TabSupervisor *_tabSupervisor, AbstractClient *_client, const ServerInfo_User &_ownUserInfo, const ServerInfo_User &_otherUserInfo);
|
||||
~TabMessage();
|
||||
|
|
|
@ -34,13 +34,13 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI
|
|||
const int gameTypeListSize = info.gametype_list_size();
|
||||
for (int i = 0; i < gameTypeListSize; ++i)
|
||||
gameTypes.insert(info.gametype_list(i).game_type_id(), QString::fromStdString(info.gametype_list(i).description()));
|
||||
|
||||
|
||||
QMap<int, GameTypeMap> tempMap;
|
||||
tempMap.insert(info.room_id(), gameTypes);
|
||||
gameSelector = new GameSelector(client, tabSupervisor, this, QMap<int, QString>(), tempMap);
|
||||
gameSelector = new GameSelector(client, tabSupervisor, this, QMap<int, QString>(), tempMap, true);
|
||||
userList = new UserList(tabSupervisor, client, UserList::RoomList);
|
||||
connect(userList, SIGNAL(openMessageDialog(const QString &, bool)), this, SIGNAL(openMessageDialog(const QString &, bool)));
|
||||
|
||||
|
||||
chatView = new ChatView(tabSupervisor, 0, true);
|
||||
connect(chatView, SIGNAL(openMessageDialog(QString, bool)), this, SIGNAL(openMessageDialog(QString, bool)));
|
||||
connect(chatView, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||
|
@ -50,7 +50,7 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI
|
|||
sayEdit = new QLineEdit;
|
||||
sayLabel->setBuddy(sayEdit);
|
||||
connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage()));
|
||||
|
||||
|
||||
QMenu *chatSettingsMenu = new QMenu(this);
|
||||
|
||||
aClearChat = chatSettingsMenu->addAction(QString());
|
||||
|
@ -60,32 +60,32 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI
|
|||
|
||||
aOpenChatSettings = chatSettingsMenu->addAction(QString());
|
||||
connect(aOpenChatSettings, SIGNAL(triggered()), this, SLOT(actOpenChatSettings()));
|
||||
|
||||
|
||||
QToolButton *chatSettingsButton = new QToolButton;
|
||||
chatSettingsButton->setIcon(QIcon(":/resources/icon_settings.svg"));
|
||||
chatSettingsButton->setMenu(chatSettingsMenu);
|
||||
chatSettingsButton->setPopupMode(QToolButton::InstantPopup);
|
||||
|
||||
|
||||
QHBoxLayout *sayHbox = new QHBoxLayout;
|
||||
sayHbox->addWidget(sayLabel);
|
||||
sayHbox->addWidget(sayEdit);
|
||||
sayHbox->addWidget(chatSettingsButton);
|
||||
|
||||
|
||||
QVBoxLayout *chatVbox = new QVBoxLayout;
|
||||
chatVbox->addWidget(chatView);
|
||||
chatVbox->addLayout(sayHbox);
|
||||
|
||||
|
||||
chatGroupBox = new QGroupBox;
|
||||
chatGroupBox->setLayout(chatVbox);
|
||||
|
||||
|
||||
QSplitter *splitter = new QSplitter(Qt::Vertical);
|
||||
splitter->addWidget(gameSelector);
|
||||
splitter->addWidget(chatGroupBox);
|
||||
|
||||
|
||||
QHBoxLayout *hbox = new QHBoxLayout;
|
||||
hbox->addWidget(splitter, 3);
|
||||
hbox->addWidget(userList, 1);
|
||||
|
||||
|
||||
aLeaveRoom = new QAction(this);
|
||||
connect(aLeaveRoom, SIGNAL(triggered()), this, SLOT(actLeaveRoom()));
|
||||
|
||||
|
@ -95,12 +95,12 @@ TabRoom::TabRoom(TabSupervisor *_tabSupervisor, AbstractClient *_client, ServerI
|
|||
|
||||
retranslateUi();
|
||||
setLayout(hbox);
|
||||
|
||||
|
||||
const int userListSize = info.user_list_size();
|
||||
for (int i = 0; i < userListSize; ++i)
|
||||
userList->processUserInfo(info.user_list(i), true);
|
||||
userList->sortItems();
|
||||
|
||||
|
||||
const int gameListSize = info.game_list_size();
|
||||
for (int i = 0; i < gameListSize; ++i)
|
||||
gameSelector->processGameInfo(info.game_list(i));
|
||||
|
@ -147,10 +147,10 @@ void TabRoom::sendMessage()
|
|||
{
|
||||
if (sayEdit->text().isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
Command_RoomSay cmd;
|
||||
cmd.set_message(sayEdit->text().toStdString());
|
||||
|
||||
|
||||
PendingCommand *pend = prepareRoomCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(sayFinished(const Response &)));
|
||||
sendRoomCommand(pend);
|
||||
|
|
|
@ -371,7 +371,16 @@ TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus
|
|||
otherUser = twi->getUserInfo();
|
||||
else
|
||||
otherUser.set_name(receiverName.toStdString());
|
||||
TabMessage *tab = new TabMessage(this, client, *userInfo, otherUser);
|
||||
|
||||
TabMessage *tab;
|
||||
tab = messageTabs.value(QString::fromStdString(otherUser.name()));
|
||||
if (tab) {
|
||||
if (focus)
|
||||
setCurrentWidget(tab);
|
||||
return tab;
|
||||
}
|
||||
|
||||
tab = new TabMessage(this, client, *userInfo, otherUser);
|
||||
connect(tab, SIGNAL(talkClosing(TabMessage *)), this, SLOT(talkLeft(TabMessage *)));
|
||||
int tabIndex = myAddTab(tab);
|
||||
addCloseButtonToTab(tab, tabIndex);
|
||||
|
|
|
@ -31,7 +31,7 @@ UserContextMenu::UserContextMenu(const TabSupervisor *_tabSupervisor, QWidget *p
|
|||
aRemoveFromIgnoreList = new QAction(QString(), this);
|
||||
aKick = new QAction(QString(), this);
|
||||
aBan = new QAction(QString(), this);
|
||||
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandCon
|
|||
{
|
||||
const Response_GetGamesOfUser &response = resp.GetExtension(Response_GetGamesOfUser::ext);
|
||||
const Command_GetGamesOfUser &cmd = commandContainer.session_command(0).GetExtension(Command_GetGamesOfUser::ext);
|
||||
|
||||
|
||||
QMap<int, GameTypeMap> gameTypeMap;
|
||||
QMap<int, QString> roomMap;
|
||||
const int roomListSize = response.room_list_size();
|
||||
|
@ -67,12 +67,12 @@ void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandCon
|
|||
}
|
||||
gameTypeMap.insert(roomInfo.room_id(), tempMap);
|
||||
}
|
||||
|
||||
GameSelector *selector = new GameSelector(client, tabSupervisor, 0, roomMap, gameTypeMap);
|
||||
|
||||
GameSelector *selector = new GameSelector(client, tabSupervisor, 0, roomMap, gameTypeMap, false);
|
||||
const int gameListSize = response.game_list_size();
|
||||
for (int i = 0; i < gameListSize; ++i)
|
||||
selector->processGameInfo(response.game_list(i));
|
||||
|
||||
|
||||
selector->setWindowTitle(tr("%1's games").arg(QString::fromStdString(cmd.user_name())));
|
||||
selector->setAttribute(Qt::WA_DeleteOnClose);
|
||||
selector->show();
|
||||
|
@ -81,7 +81,7 @@ void UserContextMenu::gamesOfUserReceived(const Response &resp, const CommandCon
|
|||
void UserContextMenu::banUser_processUserInfoResponse(const Response &r)
|
||||
{
|
||||
const Response_GetUserInfo &response = r.GetExtension(Response_GetUserInfo::ext);
|
||||
|
||||
|
||||
// The dialog needs to be non-modal in order to not block the event queue of the client.
|
||||
BanDialog *dlg = new BanDialog(response.user_info(), static_cast<QWidget *>(parent()));
|
||||
connect(dlg, SIGNAL(accepted()), this, SLOT(banUser_dialogFinished()));
|
||||
|
@ -91,21 +91,21 @@ void UserContextMenu::banUser_processUserInfoResponse(const Response &r)
|
|||
void UserContextMenu::banUser_dialogFinished()
|
||||
{
|
||||
BanDialog *dlg = static_cast<BanDialog *>(sender());
|
||||
|
||||
|
||||
Command_BanFromServer cmd;
|
||||
cmd.set_user_name(dlg->getBanName().toStdString());
|
||||
cmd.set_address(dlg->getBanIP().toStdString());
|
||||
cmd.set_minutes(dlg->getMinutes());
|
||||
cmd.set_reason(dlg->getReason().toStdString());
|
||||
cmd.set_visible_reason(dlg->getVisibleReason().toStdString());
|
||||
|
||||
|
||||
client->sendCommand(client->prepareModeratorCommand(cmd));
|
||||
}
|
||||
|
||||
void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName, UserLevelFlags userLevel, bool online, int playerId)
|
||||
{
|
||||
aUserName->setText(userName);
|
||||
|
||||
|
||||
QMenu *menu = new QMenu(static_cast<QWidget *>(parent()));
|
||||
menu->addAction(aUserName);
|
||||
menu->addSeparator();
|
||||
|
@ -141,7 +141,7 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
|||
aRemoveFromIgnoreList->setEnabled(anotherUser);
|
||||
aKick->setEnabled(anotherUser);
|
||||
aBan->setEnabled(anotherUser);
|
||||
|
||||
|
||||
QAction *actionClicked = menu->exec(pos);
|
||||
if (actionClicked == aDetails) {
|
||||
UserInfoBox *infoWidget = new UserInfoBox(client, true, static_cast<QWidget *>(parent()), Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
||||
|
@ -152,34 +152,34 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
|||
else if (actionClicked == aShowGames) {
|
||||
Command_GetGamesOfUser cmd;
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(gamesOfUserReceived(Response, CommandContainer)));
|
||||
|
||||
|
||||
client->sendCommand(pend);
|
||||
} else if (actionClicked == aAddToBuddyList) {
|
||||
Command_AddToList cmd;
|
||||
cmd.set_list("buddy");
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
|
||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||
} else if (actionClicked == aRemoveFromBuddyList) {
|
||||
Command_RemoveFromList cmd;
|
||||
cmd.set_list("buddy");
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
|
||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||
} else if (actionClicked == aAddToIgnoreList) {
|
||||
Command_AddToList cmd;
|
||||
cmd.set_list("ignore");
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
|
||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||
} else if (actionClicked == aRemoveFromIgnoreList) {
|
||||
Command_RemoveFromList cmd;
|
||||
cmd.set_list("ignore");
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
|
||||
client->sendCommand(client->prepareSessionCommand(cmd));
|
||||
} else if (actionClicked == aKick) {
|
||||
Command_KickFromGame cmd;
|
||||
|
@ -188,12 +188,12 @@ void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName
|
|||
} else if (actionClicked == aBan) {
|
||||
Command_GetUserInfo cmd;
|
||||
cmd.set_user_name(userName.toStdString());
|
||||
|
||||
|
||||
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
||||
connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUser_processUserInfoResponse(Response)));
|
||||
|
||||
|
||||
client->sendCommand(pend);
|
||||
}
|
||||
|
||||
|
||||
delete menu;
|
||||
}
|
||||
|
|
|
@ -67,8 +67,18 @@ void UserInfoBox::updateInfo(const ServerInfo_User &user)
|
|||
realNameLabel2.setText(QString::fromStdString(user.real_name()));
|
||||
genderLabel2.setPixmap(GenderPixmapGenerator::generatePixmap(15, user.gender()));
|
||||
QString country = QString::fromStdString(user.country());
|
||||
countryLabel2.setPixmap(CountryPixmapGenerator::generatePixmap(15, country));
|
||||
countryLabel3.setText(QString("(%1)").arg(country.toUpper()));
|
||||
|
||||
if (country.length() != 0)
|
||||
{
|
||||
countryLabel2.setPixmap(CountryPixmapGenerator::generatePixmap(15, country));
|
||||
countryLabel3.setText(QString("(%1)").arg(country.toUpper()));
|
||||
}
|
||||
else
|
||||
{
|
||||
countryLabel2.setText("");
|
||||
countryLabel3.setText("");
|
||||
}
|
||||
|
||||
userLevelLabel2.setPixmap(UserLevelPixmapGenerator::generatePixmap(15, userLevel, false));
|
||||
QString userLevelText;
|
||||
if (userLevel.testFlag(ServerInfo_User::IsAdmin))
|
||||
|
|
|
@ -56,7 +56,6 @@ Server_Game::Server_Game(const ServerInfo_User &_creatorInfo, int _gameId, const
|
|||
gameStarted(false),
|
||||
gameClosed(false),
|
||||
gameId(_gameId),
|
||||
description(_description),
|
||||
password(_password),
|
||||
maxPlayers(_maxPlayers),
|
||||
gameTypes(_gameTypes),
|
||||
|
@ -77,9 +76,10 @@ Server_Game::Server_Game(const ServerInfo_User &_creatorInfo, int _gameId, const
|
|||
{
|
||||
currentReplay = new GameReplay;
|
||||
currentReplay->set_replay_id(room->getServer()->getDatabaseInterface()->getNextReplayId());
|
||||
|
||||
description = _description.simplified();
|
||||
|
||||
connect(this, SIGNAL(sigStartGameIfReady()), this, SLOT(doStartGameIfReady()), Qt::QueuedConnection);
|
||||
|
||||
|
||||
getInfo(*currentReplay->mutable_game_info());
|
||||
|
||||
if (room->getServer()->getGameShouldPing()) {
|
||||
|
@ -93,36 +93,36 @@ Server_Game::~Server_Game()
|
|||
{
|
||||
room->gamesLock.lockForWrite();
|
||||
gameMutex.lock();
|
||||
|
||||
|
||||
gameClosed = true;
|
||||
sendGameEventContainer(prepareGameEvent(Event_GameClosed(), -1));
|
||||
|
||||
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
while (playerIterator.hasNext())
|
||||
playerIterator.next().value()->prepareDestroy();
|
||||
players.clear();
|
||||
|
||||
|
||||
room->removeGame(this);
|
||||
delete creatorInfo;
|
||||
creatorInfo = 0;
|
||||
|
||||
|
||||
gameMutex.unlock();
|
||||
room->gamesLock.unlock();
|
||||
|
||||
|
||||
currentReplay->set_duration_seconds(secondsElapsed - startTimeOfThisGame);
|
||||
replayList.append(currentReplay);
|
||||
storeGameInformation();
|
||||
|
||||
|
||||
for (int i = 0; i < replayList.size(); ++i)
|
||||
delete replayList[i];
|
||||
|
||||
|
||||
qDebug() << "Server_Game destructor: gameId=" << gameId;
|
||||
}
|
||||
|
||||
void Server_Game::storeGameInformation()
|
||||
{
|
||||
const ServerInfo_Game &gameInfo = replayList.first()->game_info();
|
||||
|
||||
|
||||
Event_ReplayAdded replayEvent;
|
||||
ServerInfo_ReplayMatch *replayMatchInfo = replayEvent.mutable_match_info();
|
||||
replayMatchInfo->set_game_id(gameInfo.game_id());
|
||||
|
@ -130,26 +130,26 @@ void Server_Game::storeGameInformation()
|
|||
replayMatchInfo->set_time_started(QDateTime::currentDateTime().addSecs(-secondsElapsed).toTime_t());
|
||||
replayMatchInfo->set_length(secondsElapsed);
|
||||
replayMatchInfo->set_game_name(gameInfo.description());
|
||||
|
||||
|
||||
const QStringList &allGameTypes = room->getGameTypes();
|
||||
QStringList gameTypes;
|
||||
for (int i = gameInfo.game_types_size() - 1; i >= 0; --i)
|
||||
gameTypes.append(allGameTypes[gameInfo.game_types(i)]);
|
||||
|
||||
|
||||
QSetIterator<QString> playerIterator(allPlayersEver);
|
||||
while (playerIterator.hasNext())
|
||||
replayMatchInfo->add_player_names(playerIterator.next().toStdString());
|
||||
|
||||
|
||||
for (int i = 0; i < replayList.size(); ++i) {
|
||||
ServerInfo_Replay *replayInfo = replayMatchInfo->add_replay_list();
|
||||
replayInfo->set_replay_id(replayList[i]->replay_id());
|
||||
replayInfo->set_replay_name(gameInfo.description());
|
||||
replayInfo->set_duration(replayList[i]->duration_seconds());
|
||||
}
|
||||
|
||||
|
||||
QSet<QString> allUsersInGame = allPlayersEver + allSpectatorsEver;
|
||||
QSetIterator<QString> allUsersIterator(allUsersInGame);
|
||||
|
||||
|
||||
SessionEvent *sessionEvent = Server_ProtocolHandler::prepareSessionEvent(replayEvent);
|
||||
Server *server = room->getServer();
|
||||
server->clientsLock.lockForRead();
|
||||
|
@ -160,7 +160,7 @@ void Server_Game::storeGameInformation()
|
|||
}
|
||||
server->clientsLock.unlock();
|
||||
delete sessionEvent;
|
||||
|
||||
|
||||
server->getDatabaseInterface()->storeGameInformation(room->getName(), gameTypes, gameInfo, allPlayersEver, allSpectatorsEver, replayList);
|
||||
}
|
||||
|
||||
|
@ -168,10 +168,10 @@ void Server_Game::pingClockTimeout()
|
|||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
++secondsElapsed;
|
||||
|
||||
|
||||
GameEventStorage ges;
|
||||
ges.setGameEventContext(Context_PingChanged());
|
||||
|
||||
|
||||
QList<ServerInfo_PlayerPing *> pingList;
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
bool allPlayersInactive = true;
|
||||
|
@ -180,7 +180,7 @@ void Server_Game::pingClockTimeout()
|
|||
Server_Player *player = playerIterator.next().value();
|
||||
if (!player->getSpectator())
|
||||
++playerCount;
|
||||
|
||||
|
||||
const int oldPingTime = player->getPingTime();
|
||||
player->playerMutex.lock();
|
||||
int newPingTime;
|
||||
|
@ -189,20 +189,20 @@ void Server_Game::pingClockTimeout()
|
|||
else
|
||||
newPingTime = -1;
|
||||
player->playerMutex.unlock();
|
||||
|
||||
|
||||
if ((newPingTime != -1) && !player->getSpectator())
|
||||
allPlayersInactive = false;
|
||||
|
||||
|
||||
if ((abs(oldPingTime - newPingTime) > 1) || ((newPingTime == -1) && (oldPingTime != -1)) || ((newPingTime != -1) && (oldPingTime == -1))) {
|
||||
player->setPingTime(newPingTime);
|
||||
|
||||
|
||||
Event_PlayerPropertiesChanged event;
|
||||
event.mutable_player_properties()->set_ping_seconds(newPingTime);
|
||||
ges.enqueueGameEvent(event, player->getPlayerId());
|
||||
}
|
||||
}
|
||||
ges.sendToGame(this);
|
||||
|
||||
|
||||
const int maxTime = room->getServer()->getMaxGameInactivityTime();
|
||||
if (allPlayersInactive) {
|
||||
if (((++inactivityCounter >= maxTime) && (maxTime > 0)) || (playerCount < maxPlayers))
|
||||
|
@ -214,7 +214,7 @@ void Server_Game::pingClockTimeout()
|
|||
int Server_Game::getPlayerCount() const
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
int result = 0;
|
||||
while (playerIterator.hasNext())
|
||||
|
@ -226,7 +226,7 @@ int Server_Game::getPlayerCount() const
|
|||
int Server_Game::getSpectatorCount() const
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
int result = 0;
|
||||
while (playerIterator.hasNext())
|
||||
|
@ -244,7 +244,7 @@ void Server_Game::createGameStateChangedEvent(Event_GameStateChanged *event, Ser
|
|||
event->set_active_phase(0);
|
||||
} else
|
||||
event->set_game_started(false);
|
||||
|
||||
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
while (playerIterator.hasNext())
|
||||
playerIterator.next().value()->getInfo(event->add_player_list(), playerWhosAsking, omniscient, withUserInfo);
|
||||
|
@ -255,13 +255,13 @@ void Server_Game::sendGameStateToPlayers()
|
|||
// game state information for replay and omniscient spectators
|
||||
Event_GameStateChanged omniscientEvent;
|
||||
createGameStateChangedEvent(&omniscientEvent, 0, true, false);
|
||||
|
||||
|
||||
GameEventContainer *replayCont = prepareGameEvent(omniscientEvent, -1);
|
||||
replayCont->set_seconds_elapsed(secondsElapsed - startTimeOfThisGame);
|
||||
replayCont->clear_game_id();
|
||||
currentReplay->add_event_list()->CopyFrom(*replayCont);
|
||||
delete replayCont;
|
||||
|
||||
|
||||
// If spectators are not omniscient, we need an additional createGameStateChangedEvent call, otherwise we can use the data we used for the replay.
|
||||
// All spectators are equal, so we don't need to make a createGameStateChangedEvent call for each one.
|
||||
Event_GameStateChanged spectatorEvent;
|
||||
|
@ -269,7 +269,7 @@ void Server_Game::sendGameStateToPlayers()
|
|||
spectatorEvent = omniscientEvent;
|
||||
else
|
||||
createGameStateChangedEvent(&spectatorEvent, 0, false, false);
|
||||
|
||||
|
||||
// send game state info to clients according to their role in the game
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
while (playerIterator.hasNext()) {
|
||||
|
@ -280,7 +280,7 @@ void Server_Game::sendGameStateToPlayers()
|
|||
else {
|
||||
Event_GameStateChanged event;
|
||||
createGameStateChangedEvent(&event, player, false, false);
|
||||
|
||||
|
||||
gec = prepareGameEvent(event, -1);
|
||||
}
|
||||
player->sendGameEvent(*gec);
|
||||
|
@ -292,7 +292,7 @@ void Server_Game::doStartGameIfReady()
|
|||
{
|
||||
Server_DatabaseInterface *databaseInterface = room->getServer()->getDatabaseInterface();
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
if (getPlayerCount() < maxPlayers)
|
||||
return;
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
|
@ -315,7 +315,7 @@ void Server_Game::doStartGameIfReady()
|
|||
player->setConceded(false);
|
||||
player->setReadyStart(false);
|
||||
}
|
||||
|
||||
|
||||
if (firstGameStarted) {
|
||||
currentReplay->set_duration_seconds(secondsElapsed - startTimeOfThisGame);
|
||||
replayList.append(currentReplay);
|
||||
|
@ -324,27 +324,27 @@ void Server_Game::doStartGameIfReady()
|
|||
ServerInfo_Game *gameInfo = currentReplay->mutable_game_info();
|
||||
getInfo(*gameInfo);
|
||||
gameInfo->set_started(false);
|
||||
|
||||
|
||||
Event_GameStateChanged omniscientEvent;
|
||||
createGameStateChangedEvent(&omniscientEvent, 0, true, true);
|
||||
|
||||
|
||||
GameEventContainer *replayCont = prepareGameEvent(omniscientEvent, -1);
|
||||
replayCont->set_seconds_elapsed(0);
|
||||
replayCont->clear_game_id();
|
||||
currentReplay->add_event_list()->CopyFrom(*replayCont);
|
||||
delete replayCont;
|
||||
|
||||
|
||||
startTimeOfThisGame = secondsElapsed;
|
||||
} else
|
||||
firstGameStarted = true;
|
||||
|
||||
|
||||
sendGameStateToPlayers();
|
||||
|
||||
|
||||
activePlayer = -1;
|
||||
nextTurn();
|
||||
|
||||
|
||||
locker.unlock();
|
||||
|
||||
|
||||
ServerInfo_Game gameInfo;
|
||||
gameInfo.set_room_id(room->getId());
|
||||
gameInfo.set_game_id(gameId);
|
||||
|
@ -360,7 +360,7 @@ void Server_Game::startGameIfReady()
|
|||
void Server_Game::stopGameIfFinished()
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
int playing = 0;
|
||||
while (playerIterator.hasNext()) {
|
||||
|
@ -381,9 +381,9 @@ void Server_Game::stopGameIfFinished()
|
|||
}
|
||||
|
||||
sendGameStateToPlayers();
|
||||
|
||||
|
||||
locker.unlock();
|
||||
|
||||
|
||||
ServerInfo_Game gameInfo;
|
||||
gameInfo.set_room_id(room->getId());
|
||||
gameInfo.set_game_id(gameId);
|
||||
|
@ -417,14 +417,14 @@ Response::ResponseCode Server_Game::checkJoin(ServerInfo_User *user, const QStri
|
|||
}
|
||||
if (!spectator && (gameStarted || (getPlayerCount() >= getMaxPlayers())))
|
||||
return Response::RespGameFull;
|
||||
|
||||
|
||||
return Response::RespOk;
|
||||
}
|
||||
|
||||
bool Server_Game::containsUser(const QString &userName) const
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
while (playerIterator.hasNext())
|
||||
if (playerIterator.next().value()->getUserInfo()->name() == userName.toStdString())
|
||||
|
@ -435,14 +435,14 @@ bool Server_Game::containsUser(const QString &userName) const
|
|||
void Server_Game::addPlayer(Server_AbstractUserInterface *userInterface, ResponseContainer &rc, bool spectator, bool broadcastUpdate)
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
Server_Player *newPlayer = new Server_Player(this, nextPlayerId++, userInterface->copyUserInfo(true, true, true), spectator, userInterface);
|
||||
newPlayer->moveToThread(thread());
|
||||
|
||||
|
||||
Event_Join joinEvent;
|
||||
newPlayer->getProperties(*joinEvent.mutable_player_properties(), true);
|
||||
sendGameEventContainer(prepareGameEvent(joinEvent, -1));
|
||||
|
||||
|
||||
const QString playerName = QString::fromStdString(newPlayer->getUserInfo()->name());
|
||||
if (spectator)
|
||||
allSpectatorsEver.insert(playerName);
|
||||
|
@ -453,7 +453,7 @@ void Server_Game::addPlayer(Server_AbstractUserInterface *userInterface, Respons
|
|||
hostId = newPlayer->getPlayerId();
|
||||
sendGameEventContainer(prepareGameEvent(Event_GameHostChanged(), hostId));
|
||||
}
|
||||
|
||||
|
||||
if (broadcastUpdate) {
|
||||
ServerInfo_Game gameInfo;
|
||||
gameInfo.set_room_id(room->getId());
|
||||
|
@ -462,12 +462,12 @@ void Server_Game::addPlayer(Server_AbstractUserInterface *userInterface, Respons
|
|||
gameInfo.set_spectators_count(getSpectatorCount());
|
||||
emit gameInfoChanged(gameInfo);
|
||||
}
|
||||
|
||||
|
||||
if ((newPlayer->getUserInfo()->user_level() & ServerInfo_User::IsRegistered) && !spectator)
|
||||
room->getServer()->addPersistentPlayer(playerName, room->getId(), gameId, newPlayer->getPlayerId());
|
||||
|
||||
|
||||
userInterface->playerAddedToGame(gameId, room->getId(), newPlayer->getPlayerId());
|
||||
|
||||
|
||||
createGameJoinedEvent(newPlayer, rc, false);
|
||||
}
|
||||
|
||||
|
@ -475,18 +475,18 @@ void Server_Game::removePlayer(Server_Player *player)
|
|||
{
|
||||
room->getServer()->removePersistentPlayer(QString::fromStdString(player->getUserInfo()->name()), room->getId(), gameId, player->getPlayerId());
|
||||
players.remove(player->getPlayerId());
|
||||
|
||||
|
||||
GameEventStorage ges;
|
||||
removeArrowsRelatedToPlayer(ges, player);
|
||||
unattachCards(ges, player);
|
||||
ges.enqueueGameEvent(Event_Leave(), player->getPlayerId());
|
||||
ges.sendToGame(this);
|
||||
|
||||
|
||||
bool playerActive = activePlayer == player->getPlayerId();
|
||||
bool playerHost = hostId == player->getPlayerId();
|
||||
bool spectator = player->getSpectator();
|
||||
player->prepareDestroy();
|
||||
|
||||
|
||||
if (!getPlayerCount()) {
|
||||
gameClosed = true;
|
||||
deleteLater();
|
||||
|
@ -511,7 +511,7 @@ void Server_Game::removePlayer(Server_Player *player)
|
|||
if (gameStarted && playerActive)
|
||||
nextTurn();
|
||||
}
|
||||
|
||||
|
||||
ServerInfo_Game gameInfo;
|
||||
gameInfo.set_room_id(room->getId());
|
||||
gameInfo.set_game_id(gameId);
|
||||
|
@ -523,7 +523,7 @@ void Server_Game::removePlayer(Server_Player *player)
|
|||
void Server_Game::removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_Player *player)
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
// Remove all arrows of other players pointing to the player being removed or to one of his cards.
|
||||
// Also remove all arrows starting at one of his cards. This is necessary since players can create
|
||||
// arrows that start at another person's cards.
|
||||
|
@ -540,7 +540,7 @@ void Server_Game::removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_Play
|
|||
toDelete.append(a);
|
||||
} else if (static_cast<Server_Player *>(a->getTargetItem()) == player)
|
||||
toDelete.append(a);
|
||||
|
||||
|
||||
// Don't use else here! It has to happen regardless of whether targetCard == 0.
|
||||
if (a->getStartCard()->getZone()->getPlayer() == player)
|
||||
toDelete.append(a);
|
||||
|
@ -549,7 +549,7 @@ void Server_Game::removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_Play
|
|||
Event_DeleteArrow event;
|
||||
event.set_arrow_id(toDelete[i]->getId());
|
||||
ges.enqueueGameEvent(event, p->getPlayerId());
|
||||
|
||||
|
||||
p->deleteArrow(toDelete[i]->getId());
|
||||
}
|
||||
}
|
||||
|
@ -558,13 +558,13 @@ void Server_Game::removeArrowsRelatedToPlayer(GameEventStorage &ges, Server_Play
|
|||
void Server_Game::unattachCards(GameEventStorage &ges, Server_Player *player)
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
QMapIterator<QString, Server_CardZone *> zoneIterator(player->getZones());
|
||||
while (zoneIterator.hasNext()) {
|
||||
Server_CardZone *zone = zoneIterator.next().value();
|
||||
for (int i = 0; i < zone->getCards().size(); ++i) {
|
||||
Server_Card *card = zone->getCards().at(i);
|
||||
|
||||
|
||||
// Make a copy of the list because the original one gets modified during the loop
|
||||
QList<Server_Card *> attachedCards = card->getAttachedCards();
|
||||
for (int i = 0; i < attachedCards.size(); ++i)
|
||||
|
@ -576,54 +576,54 @@ void Server_Game::unattachCards(GameEventStorage &ges, Server_Player *player)
|
|||
bool Server_Game::kickPlayer(int playerId)
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
Server_Player *playerToKick = players.value(playerId);
|
||||
if (!playerToKick)
|
||||
return false;
|
||||
|
||||
|
||||
GameEventContainer *gec = prepareGameEvent(Event_Kicked(), -1);
|
||||
playerToKick->sendGameEvent(*gec);
|
||||
delete gec;
|
||||
|
||||
|
||||
removePlayer(playerToKick);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Server_Game::setActivePlayer(int _activePlayer)
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
activePlayer = _activePlayer;
|
||||
|
||||
|
||||
Event_SetActivePlayer event;
|
||||
event.set_active_player_id(activePlayer);
|
||||
sendGameEventContainer(prepareGameEvent(event, -1));
|
||||
|
||||
|
||||
setActivePhase(0);
|
||||
}
|
||||
|
||||
void Server_Game::setActivePhase(int _activePhase)
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
while (playerIterator.hasNext()) {
|
||||
Server_Player *player = playerIterator.next().value();
|
||||
QList<Server_Arrow *> toDelete = player->getArrows().values();
|
||||
for (int i = 0; i < toDelete.size(); ++i) {
|
||||
Server_Arrow *a = toDelete[i];
|
||||
|
||||
|
||||
Event_DeleteArrow event;
|
||||
event.set_arrow_id(a->getId());
|
||||
sendGameEventContainer(prepareGameEvent(event, player->getPlayerId()));
|
||||
|
||||
|
||||
player->deleteArrow(a->getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
activePhase = _activePhase;
|
||||
|
||||
|
||||
Event_SetActivePhase event;
|
||||
event.set_phase(activePhase);
|
||||
sendGameEventContainer(prepareGameEvent(event, -1));
|
||||
|
@ -632,7 +632,7 @@ void Server_Game::setActivePhase(int _activePhase)
|
|||
void Server_Game::nextTurn()
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
const QList<int> keys = players.keys();
|
||||
int listPos = -1;
|
||||
if (activePlayer != -1)
|
||||
|
@ -642,7 +642,7 @@ void Server_Game::nextTurn()
|
|||
if (listPos == keys.size())
|
||||
listPos = 0;
|
||||
} while (players.value(keys[listPos])->getSpectator() || players.value(keys[listPos])->getConceded());
|
||||
|
||||
|
||||
setActivePlayer(keys[listPos]);
|
||||
}
|
||||
|
||||
|
@ -663,13 +663,13 @@ void Server_Game::createGameJoinedEvent(Server_Player *player, ResponseContainer
|
|||
}
|
||||
}
|
||||
rc.enqueuePostResponseItem(ServerMessage::SESSION_EVENT, Server_AbstractUserInterface::prepareSessionEvent(event1));
|
||||
|
||||
|
||||
Event_GameStateChanged event2;
|
||||
event2.set_seconds_elapsed(secondsElapsed);
|
||||
event2.set_game_started(gameStarted);
|
||||
event2.set_active_player_id(activePlayer);
|
||||
event2.set_active_phase(activePhase);
|
||||
|
||||
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
while (playerIterator.hasNext())
|
||||
playerIterator.next().value()->getInfo(event2.add_player_list(), player, player->getSpectator() && spectatorsSeeEverything, true);
|
||||
|
@ -680,7 +680,7 @@ void Server_Game::createGameJoinedEvent(Server_Player *player, ResponseContainer
|
|||
void Server_Game::sendGameEventContainer(GameEventContainer *cont, GameEventStorageItem::EventRecipients recipients, int privatePlayerId)
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
cont->set_game_id(gameId);
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
while (playerIterator.hasNext()) {
|
||||
|
@ -694,7 +694,7 @@ void Server_Game::sendGameEventContainer(GameEventContainer *cont, GameEventStor
|
|||
cont->clear_game_id();
|
||||
currentReplay->add_event_list()->CopyFrom(*cont);
|
||||
}
|
||||
|
||||
|
||||
delete cont;
|
||||
}
|
||||
|
||||
|
@ -714,7 +714,7 @@ GameEventContainer *Server_Game::prepareGameEvent(const ::google::protobuf::Mess
|
|||
void Server_Game::getInfo(ServerInfo_Game &result) const
|
||||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
|
||||
result.set_room_id(room->getId());
|
||||
result.set_game_id(gameId);
|
||||
if (gameClosed)
|
||||
|
@ -722,7 +722,7 @@ void Server_Game::getInfo(ServerInfo_Game &result) const
|
|||
else {
|
||||
for (int i = 0; i < gameTypes.size(); ++i)
|
||||
result.add_game_types(gameTypes[i]);
|
||||
|
||||
|
||||
result.set_max_players(getMaxPlayers());
|
||||
result.set_description(getDescription().toStdString());
|
||||
result.set_with_password(!getPassword().isEmpty());
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include "settingscache.h"
|
||||
#include <QSocketNotifier>
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QTextStream>
|
||||
#include <QDateTime>
|
||||
#include <iostream>
|
||||
|
@ -26,8 +28,23 @@ ServerLogger::~ServerLogger()
|
|||
void ServerLogger::startLog(const QString &logFileName)
|
||||
{
|
||||
if (!logFileName.isEmpty()) {
|
||||
QFileInfo fi(logFileName);
|
||||
QDir fileDir(fi.path());
|
||||
if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath())) {
|
||||
std::cerr << "ERROR: logfile folder doesn't exist and i can't create it." << std::endl;
|
||||
logFile = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
logFile = new QFile(logFileName, this);
|
||||
logFile->open(QIODevice::Append);
|
||||
if(!logFile->open(QIODevice::Append)) {
|
||||
std::cerr << "ERROR: can't open() logfile." << std::endl;
|
||||
delete logFile;
|
||||
logFile = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
::socketpair(AF_UNIX, SOCK_STREAM, 0, sigHupFD);
|
||||
|
||||
|
|
|
@ -9,4 +9,4 @@ if [[ $TRAVIS_OS_NAME == "osx" && $QT4 == 0 ]]; then
|
|||
prefix="-DCMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.4.0/"
|
||||
fi
|
||||
cmake .. -DWITH_SERVER=1 -DWITH_QT4=$QT4 $prefix
|
||||
make
|
||||
make -j2
|
||||
|
|
Loading…
Reference in a new issue