Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
bd39d603
Commit
bd39d603
authored
Feb 02, 2015
by
Jeffrey Oliver
Browse files
Reduce the game descriptions whitespace.
parent
72d1b211
Changes
1
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/dlg_creategame.cpp
View file @
bd39d603
...
@@ -31,13 +31,13 @@ void DlgCreateGame::sharedCtor()
...
@@ -31,13 +31,13 @@ void DlgCreateGame::sharedCtor()
maxPlayersEdit
->
setMaximum
(
100
);
maxPlayersEdit
->
setMaximum
(
100
);
maxPlayersEdit
->
setValue
(
2
);
maxPlayersEdit
->
setValue
(
2
);
maxPlayersLabel
->
setBuddy
(
maxPlayersEdit
);
maxPlayersLabel
->
setBuddy
(
maxPlayersEdit
);
QGridLayout
*
generalGrid
=
new
QGridLayout
;
QGridLayout
*
generalGrid
=
new
QGridLayout
;
generalGrid
->
addWidget
(
descriptionLabel
,
0
,
0
);
generalGrid
->
addWidget
(
descriptionLabel
,
0
,
0
);
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
);
QVBoxLayout
*
gameTypeLayout
=
new
QVBoxLayout
;
QVBoxLayout
*
gameTypeLayout
=
new
QVBoxLayout
;
QMapIterator
<
int
,
QString
>
gameTypeIterator
(
gameTypes
);
QMapIterator
<
int
,
QString
>
gameTypeIterator
(
gameTypes
);
while
(
gameTypeIterator
.
hasNext
())
{
while
(
gameTypeIterator
.
hasNext
())
{
...
@@ -48,7 +48,7 @@ void DlgCreateGame::sharedCtor()
...
@@ -48,7 +48,7 @@ void DlgCreateGame::sharedCtor()
}
}
QGroupBox
*
gameTypeGroupBox
=
new
QGroupBox
(
tr
(
"Game type"
));
QGroupBox
*
gameTypeGroupBox
=
new
QGroupBox
(
tr
(
"Game type"
));
gameTypeGroupBox
->
setLayout
(
gameTypeLayout
);
gameTypeGroupBox
->
setLayout
(
gameTypeLayout
);
passwordLabel
=
new
QLabel
(
tr
(
"&Password:"
));
passwordLabel
=
new
QLabel
(
tr
(
"&Password:"
));
passwordEdit
=
new
QLineEdit
;
passwordEdit
=
new
QLineEdit
;
passwordLabel
->
setBuddy
(
passwordEdit
);
passwordLabel
->
setBuddy
(
passwordEdit
);
...
@@ -60,18 +60,18 @@ void DlgCreateGame::sharedCtor()
...
@@ -60,18 +60,18 @@ void DlgCreateGame::sharedCtor()
onlyRegisteredCheckBox
->
setChecked
(
true
);
onlyRegisteredCheckBox
->
setChecked
(
true
);
}
else
{
}
else
{
onlyBuddiesCheckBox
->
setEnabled
(
false
);
onlyBuddiesCheckBox
->
setEnabled
(
false
);
onlyRegisteredCheckBox
->
setEnabled
(
false
);
onlyRegisteredCheckBox
->
setEnabled
(
false
);
}
}
QGridLayout
*
joinRestrictionsLayout
=
new
QGridLayout
;
QGridLayout
*
joinRestrictionsLayout
=
new
QGridLayout
;
joinRestrictionsLayout
->
addWidget
(
passwordLabel
,
0
,
0
);
joinRestrictionsLayout
->
addWidget
(
passwordLabel
,
0
,
0
);
joinRestrictionsLayout
->
addWidget
(
passwordEdit
,
0
,
1
);
joinRestrictionsLayout
->
addWidget
(
passwordEdit
,
0
,
1
);
joinRestrictionsLayout
->
addWidget
(
onlyBuddiesCheckBox
,
1
,
0
,
1
,
2
);
joinRestrictionsLayout
->
addWidget
(
onlyBuddiesCheckBox
,
1
,
0
,
1
,
2
);
joinRestrictionsLayout
->
addWidget
(
onlyRegisteredCheckBox
,
2
,
0
,
1
,
2
);
joinRestrictionsLayout
->
addWidget
(
onlyRegisteredCheckBox
,
2
,
0
,
1
,
2
);
QGroupBox
*
joinRestrictionsGroupBox
=
new
QGroupBox
(
tr
(
"Joining restrictions"
));
QGroupBox
*
joinRestrictionsGroupBox
=
new
QGroupBox
(
tr
(
"Joining restrictions"
));
joinRestrictionsGroupBox
->
setLayout
(
joinRestrictionsLayout
);
joinRestrictionsGroupBox
->
setLayout
(
joinRestrictionsLayout
);
spectatorsAllowedCheckBox
=
new
QCheckBox
(
tr
(
"&Spectators allowed"
));
spectatorsAllowedCheckBox
=
new
QCheckBox
(
tr
(
"&Spectators allowed"
));
spectatorsAllowedCheckBox
->
setChecked
(
true
);
spectatorsAllowedCheckBox
->
setChecked
(
true
);
connect
(
spectatorsAllowedCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
spectatorsAllowedChanged
(
int
)));
connect
(
spectatorsAllowedCheckBox
,
SIGNAL
(
stateChanged
(
int
)),
this
,
SLOT
(
spectatorsAllowedChanged
(
int
)));
...
@@ -94,7 +94,7 @@ void DlgCreateGame::sharedCtor()
...
@@ -94,7 +94,7 @@ void DlgCreateGame::sharedCtor()
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
);
buttonBox
=
new
QDialogButtonBox
(
QDialogButtonBox
::
Ok
);
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
connect
(
buttonBox
,
SIGNAL
(
rejected
()),
this
,
SLOT
(
reject
()));
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
QVBoxLayout
*
mainLayout
=
new
QVBoxLayout
;
mainLayout
->
addLayout
(
grid
);
mainLayout
->
addLayout
(
grid
);
mainLayout
->
addWidget
(
buttonBox
);
mainLayout
->
addWidget
(
buttonBox
);
...
@@ -108,10 +108,10 @@ DlgCreateGame::DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameType
...
@@ -108,10 +108,10 @@ DlgCreateGame::DlgCreateGame(TabRoom *_room, const QMap<int, QString> &_gameType
:
QDialog
(
parent
),
room
(
_room
),
gameTypes
(
_gameTypes
)
:
QDialog
(
parent
),
room
(
_room
),
gameTypes
(
_gameTypes
)
{
{
sharedCtor
();
sharedCtor
();
buttonBox
->
addButton
(
QDialogButtonBox
::
Cancel
);
buttonBox
->
addButton
(
QDialogButtonBox
::
Cancel
);
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
actOK
()));
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
actOK
()));
setWindowTitle
(
tr
(
"Create game"
));
setWindowTitle
(
tr
(
"Create game"
));
}
}
...
@@ -119,7 +119,7 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
...
@@ -119,7 +119,7 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
:
QDialog
(
parent
),
room
(
0
),
gameTypes
(
_gameTypes
)
:
QDialog
(
parent
),
room
(
0
),
gameTypes
(
_gameTypes
)
{
{
sharedCtor
();
sharedCtor
();
descriptionEdit
->
setEnabled
(
false
);
descriptionEdit
->
setEnabled
(
false
);
maxPlayersEdit
->
setEnabled
(
false
);
maxPlayersEdit
->
setEnabled
(
false
);
passwordEdit
->
setEnabled
(
false
);
passwordEdit
->
setEnabled
(
false
);
...
@@ -129,7 +129,7 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
...
@@ -129,7 +129,7 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
spectatorsNeedPasswordCheckBox
->
setEnabled
(
false
);
spectatorsNeedPasswordCheckBox
->
setEnabled
(
false
);
spectatorsCanTalkCheckBox
->
setEnabled
(
false
);
spectatorsCanTalkCheckBox
->
setEnabled
(
false
);
spectatorsSeeEverythingCheckBox
->
setEnabled
(
false
);
spectatorsSeeEverythingCheckBox
->
setEnabled
(
false
);
descriptionEdit
->
setText
(
QString
::
fromStdString
(
gameInfo
.
description
()));
descriptionEdit
->
setText
(
QString
::
fromStdString
(
gameInfo
.
description
()));
maxPlayersEdit
->
setValue
(
gameInfo
.
max_players
());
maxPlayersEdit
->
setValue
(
gameInfo
.
max_players
());
onlyBuddiesCheckBox
->
setChecked
(
gameInfo
.
only_buddies
());
onlyBuddiesCheckBox
->
setChecked
(
gameInfo
.
only_buddies
());
...
@@ -138,29 +138,29 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
...
@@ -138,29 +138,29 @@ DlgCreateGame::DlgCreateGame(const ServerInfo_Game &gameInfo, const QMap<int, QS
spectatorsNeedPasswordCheckBox
->
setChecked
(
gameInfo
.
spectators_need_password
());
spectatorsNeedPasswordCheckBox
->
setChecked
(
gameInfo
.
spectators_need_password
());
spectatorsCanTalkCheckBox
->
setChecked
(
gameInfo
.
spectators_can_chat
());
spectatorsCanTalkCheckBox
->
setChecked
(
gameInfo
.
spectators_can_chat
());
spectatorsSeeEverythingCheckBox
->
setChecked
(
gameInfo
.
spectators_omniscient
());
spectatorsSeeEverythingCheckBox
->
setChecked
(
gameInfo
.
spectators_omniscient
());
QSet
<
int
>
types
;
QSet
<
int
>
types
;
for
(
int
i
=
0
;
i
<
gameInfo
.
game_types_size
();
++
i
)
for
(
int
i
=
0
;
i
<
gameInfo
.
game_types_size
();
++
i
)
types
.
insert
(
gameInfo
.
game_types
(
i
));
types
.
insert
(
gameInfo
.
game_types
(
i
));
QMapIterator
<
int
,
QString
>
gameTypeIterator
(
gameTypes
);
QMapIterator
<
int
,
QString
>
gameTypeIterator
(
gameTypes
);
while
(
gameTypeIterator
.
hasNext
())
{
while
(
gameTypeIterator
.
hasNext
())
{
gameTypeIterator
.
next
();
gameTypeIterator
.
next
();
QCheckBox
*
gameTypeCheckBox
=
gameTypeCheckBoxes
.
value
(
gameTypeIterator
.
key
());
QCheckBox
*
gameTypeCheckBox
=
gameTypeCheckBoxes
.
value
(
gameTypeIterator
.
key
());
gameTypeCheckBox
->
setEnabled
(
false
);
gameTypeCheckBox
->
setEnabled
(
false
);
gameTypeCheckBox
->
setChecked
(
types
.
contains
(
gameTypeIterator
.
key
()));
gameTypeCheckBox
->
setChecked
(
types
.
contains
(
gameTypeIterator
.
key
()));
}
}
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
accept
()));
connect
(
buttonBox
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
accept
()));
setWindowTitle
(
tr
(
"Game information"
));
setWindowTitle
(
tr
(
"Game information"
));
}
}
void
DlgCreateGame
::
actOK
()
void
DlgCreateGame
::
actOK
()
{
{
Command_CreateGame
cmd
;
Command_CreateGame
cmd
;
cmd
.
set_description
(
descriptionEdit
->
text
().
toStdString
());
cmd
.
set_description
(
descriptionEdit
->
text
().
simplified
().
toStdString
());
cmd
.
set_password
(
passwordEdit
->
text
().
toStdString
());
cmd
.
set_password
(
passwordEdit
->
text
().
toStdString
());
cmd
.
set_max_players
(
maxPlayersEdit
->
value
());
cmd
.
set_max_players
(
maxPlayersEdit
->
value
());
cmd
.
set_only_buddies
(
onlyBuddiesCheckBox
->
isChecked
());
cmd
.
set_only_buddies
(
onlyBuddiesCheckBox
->
isChecked
());
...
@@ -169,18 +169,18 @@ void DlgCreateGame::actOK()
...
@@ -169,18 +169,18 @@ void DlgCreateGame::actOK()
cmd
.
set_spectators_need_password
(
spectatorsNeedPasswordCheckBox
->
isChecked
());
cmd
.
set_spectators_need_password
(
spectatorsNeedPasswordCheckBox
->
isChecked
());
cmd
.
set_spectators_can_talk
(
spectatorsCanTalkCheckBox
->
isChecked
());
cmd
.
set_spectators_can_talk
(
spectatorsCanTalkCheckBox
->
isChecked
());
cmd
.
set_spectators_see_everything
(
spectatorsSeeEverythingCheckBox
->
isChecked
());
cmd
.
set_spectators_see_everything
(
spectatorsSeeEverythingCheckBox
->
isChecked
());
QMapIterator
<
int
,
QCheckBox
*>
gameTypeCheckBoxIterator
(
gameTypeCheckBoxes
);
QMapIterator
<
int
,
QCheckBox
*>
gameTypeCheckBoxIterator
(
gameTypeCheckBoxes
);
while
(
gameTypeCheckBoxIterator
.
hasNext
())
{
while
(
gameTypeCheckBoxIterator
.
hasNext
())
{
gameTypeCheckBoxIterator
.
next
();
gameTypeCheckBoxIterator
.
next
();
if
(
gameTypeCheckBoxIterator
.
value
()
->
isChecked
())
if
(
gameTypeCheckBoxIterator
.
value
()
->
isChecked
())
cmd
.
add_game_type_ids
(
gameTypeCheckBoxIterator
.
key
());
cmd
.
add_game_type_ids
(
gameTypeCheckBoxIterator
.
key
());
}
}
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
);
buttonBox
->
setEnabled
(
false
);
buttonBox
->
setEnabled
(
false
);
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment