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
122f8ea9
Commit
122f8ea9
authored
Nov 28, 2009
by
Max-Wilhelm Bruker
Browse files
game menu
parent
77015c9e
Changes
15
Hide whitespace changes
Inline
Side-by-side
cockatrice/cockatrice.pro
View file @
122f8ea9
...
...
@@ -41,6 +41,7 @@ HEADERS += src/counter.h \
src
/
phasestoolbar
.
h
\
src
/
gamescene
.
h
\
src
/
arrowitem
.
h
\
src
/
tab
.
h
\
src
/
tab_server
.
h
\
src
/
tab_chatchannel
.
h
\
src
/
tab_game
.
h
\
...
...
cockatrice/src/cardzone.cpp
View file @
122f8ea9
...
...
@@ -2,8 +2,8 @@
#include
"cardzone.h"
#include
"carditem.h"
#include
"player.h"
#include
"client.h"
#include
"zoneviewzone.h"
#include
"protocol_items.h"
CardZone
::
CardZone
(
Player
*
_p
,
const
QString
&
_name
,
bool
_hasCardAttr
,
bool
_isShufflable
,
bool
_contentsKnown
,
QGraphicsItem
*
parent
,
bool
isView
)
:
AbstractGraphicsItem
(
parent
),
player
(
_p
),
name
(
_name
),
cards
(
_contentsKnown
),
view
(
NULL
),
menu
(
NULL
),
doubleClickAction
(
0
),
hasCardAttr
(
_hasCardAttr
),
isShufflable
(
_isShufflable
)
...
...
@@ -128,9 +128,9 @@ CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName,
void
CardZone
::
setCardAttr
(
int
cardId
,
const
QString
&
aname
,
const
QString
&
avalue
)
{
/*
if (hasCardAttr)
player->
client->s
etCardAttr(name, cardId, aname, avalue);
*/
}
if
(
hasCardAttr
)
player
->
sendGameCommand
(
new
Command_S
etCardAttr
(
-
1
,
name
,
cardId
,
aname
,
avalue
)
)
;
}
void
CardZone
::
moveAllToZone
()
{
...
...
cockatrice/src/tab.h
0 → 100644
View file @
122f8ea9
#ifndef TAB_H
#define TAB_H
#include
<QWidget>
class
QMenu
;
class
Tab
:
public
QWidget
{
Q_OBJECT
protected:
QMenu
*
tabMenu
;
public:
Tab
(
QWidget
*
parent
=
0
)
:
QWidget
(
parent
),
tabMenu
(
0
)
{
}
QMenu
*
getTabMenu
()
const
{
return
tabMenu
;
}
};
#endif
cockatrice/src/tab_chatchannel.cpp
View file @
122f8ea9
...
...
@@ -4,7 +4,7 @@
#include
"protocol_items.h"
TabChatChannel
::
TabChatChannel
(
Client
*
_client
,
const
QString
&
_channelName
)
:
QWidget
(),
client
(
_client
),
channelName
(
_channelName
)
:
Tab
(),
client
(
_client
),
channelName
(
_channelName
)
{
playerList
=
new
QListWidget
;
playerList
->
setFixedWidth
(
150
);
...
...
cockatrice/src/tab_chatchannel.h
View file @
122f8ea9
#ifndef TAB_CHATCHANNEL_H
#define TAB_CHATCHANNEL_H
#include
<QWidget>
#include
"tab.h"
class
Client
;
class
QListWidget
;
...
...
@@ -13,7 +13,7 @@ class Event_ChatJoinChannel;
class
Event_ChatLeaveChannel
;
class
Event_ChatSay
;
class
TabChatChannel
:
public
QWidget
{
class
TabChatChannel
:
public
Tab
{
Q_OBJECT
private:
Client
*
client
;
...
...
cockatrice/src/tab_deck_storage.cpp
View file @
122f8ea9
...
...
@@ -7,7 +7,7 @@
#include
"protocol_items.h"
TabDeckStorage
::
TabDeckStorage
(
Client
*
_client
)
:
QWidget
(),
client
(
_client
)
:
Tab
(),
client
(
_client
)
{
localDirModel
=
new
QFileSystemModel
(
this
);
QSettings
settings
;
...
...
cockatrice/src/tab_deck_storage.h
View file @
122f8ea9
#ifndef TAB_DECK_STORAGE_H
#define TAB_DECK_STORAGE_H
#include
<QWidget>
#include
"protocol
_datastructures
.h"
#include
"tab.h"
#include
"protocol.h"
class
Client
;
class
QTreeView
;
...
...
@@ -15,7 +15,7 @@ class QGroupBox;
class
ProtocolResponse
;
class
RemoteDeckList_TreeWidget
;
class
TabDeckStorage
:
public
QWidget
{
class
TabDeckStorage
:
public
Tab
{
Q_OBJECT
private:
Client
*
client
;
...
...
cockatrice/src/tab_game.cpp
View file @
122f8ea9
...
...
@@ -21,7 +21,7 @@
#include
"main.h"
TabGame
::
TabGame
(
Client
*
_client
,
int
_gameId
,
int
_localPlayerId
,
bool
_spectator
)
:
client
(
_client
),
gameId
(
_gameId
),
localPlayerId
(
_localPlayerId
),
spectator
(
_spectator
),
started
(
false
),
currentPhase
(
-
1
)
:
Tab
(),
client
(
_client
),
gameId
(
_gameId
),
localPlayerId
(
_localPlayerId
),
spectator
(
_spectator
),
started
(
false
),
currentPhase
(
-
1
)
{
zoneLayout
=
new
ZoneViewLayout
;
scene
=
new
GameScene
(
zoneLayout
,
this
);
...
...
@@ -61,8 +61,8 @@ TabGame::TabGame(Client *_client, int _gameId, int _localPlayerId, bool _spectat
QVBoxLayout
*
verticalLayout
=
new
QVBoxLayout
;
verticalLayout
->
addWidget
(
cardInfo
);
verticalLayout
->
addWidget
(
playerListWidget
);
verticalLayout
->
addWidget
(
messageLog
);
verticalLayout
->
addWidget
(
playerListWidget
,
1
);
verticalLayout
->
addWidget
(
messageLog
,
3
);
verticalLayout
->
addLayout
(
hLayout
);
QHBoxLayout
*
mainLayout
=
new
QHBoxLayout
;
...
...
@@ -89,11 +89,12 @@ TabGame::TabGame(Client *_client, int _gameId, int _localPlayerId, bool _spectat
aRemoveLocalArrows
=
new
QAction
(
this
);
connect
(
aRemoveLocalArrows
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
actRemoveLocalArrows
()));
gameMenu
=
new
QMenu
(
this
);
gameMenu
->
addAction
(
aNextPhase
);
gameMenu
->
addAction
(
aNextTurn
);
gameMenu
->
addSeparator
();
gameMenu
->
addAction
(
aRemoveLocalArrows
);
tabMenu
=
new
QMenu
(
this
);
playersSeparator
=
tabMenu
->
addSeparator
();
tabMenu
->
addAction
(
aNextPhase
);
tabMenu
->
addAction
(
aNextTurn
);
tabMenu
->
addSeparator
();
tabMenu
->
addAction
(
aRemoveLocalArrows
);
retranslateUi
();
setLayout
(
mainLayout
);
...
...
@@ -103,7 +104,7 @@ TabGame::TabGame(Client *_client, int _gameId, int _localPlayerId, bool _spectat
void
TabGame
::
retranslateUi
()
{
game
Menu
->
setTitle
(
tr
(
"&Game"
));
tab
Menu
->
setTitle
(
tr
(
"&Game"
));
aNextPhase
->
setText
(
tr
(
"Next &phase"
));
aNextPhase
->
setShortcut
(
tr
(
"Ctrl+Space"
));
aNextTurn
->
setText
(
tr
(
"Next &turn"
));
...
...
@@ -167,8 +168,12 @@ Player *TabGame::addPlayer(int playerId, const QString &playerName)
scene
->
addPlayer
(
newPlayer
);
connect
(
newPlayer
,
SIGNAL
(
newCardAdded
(
CardItem
*
)),
this
,
SLOT
(
newCardAdded
(
CardItem
*
)));
connect
(
newPlayer
,
SIGNAL
(
toggleZoneView
(
Player
*
,
QString
,
int
)),
zoneLayout
,
SLOT
(
toggleZoneView
(
Player
*
,
QString
,
int
)));
connect
(
newPlayer
,
SIGNAL
(
closeZoneView
(
ZoneViewZone
*
)),
zoneLayout
,
SLOT
(
removeItem
(
ZoneViewZone
*
)));
messageLog
->
connectToPlayer
(
newPlayer
);
tabMenu
->
insertMenu
(
playersSeparator
,
newPlayer
->
getPlayerMenu
());
players
.
insert
(
playerId
,
newPlayer
);
emit
playerAdded
(
newPlayer
);
...
...
cockatrice/src/tab_game.h
View file @
122f8ea9
#ifndef TAB_GAME_H
#define TAB_GAME_H
#include
<QWidget>
#include
<QMap>
#include
"tab.h"
class
Client
;
class
CardDatabase
;
...
...
@@ -34,7 +34,7 @@ class Player;
class
CardZone
;
class
CardItem
;
class
TabGame
:
public
QWidget
{
class
TabGame
:
public
Tab
{
Q_OBJECT
private:
Client
*
client
;
...
...
@@ -58,9 +58,10 @@ private:
DeckView
*
deckView
;
QWidget
*
deckViewContainer
;
ZoneViewLayout
*
zoneLayout
;
QAction
*
playersSeparator
;
QMenu
*
playersMenu
;
QAction
*
aCloseMostRecentZoneView
,
*
aNextPhase
,
*
aNextTurn
,
*
aRemoveLocalArrows
;
QMenu
*
gameMenu
;
Player
*
addPlayer
(
int
playerId
,
const
QString
&
playerName
);
...
...
cockatrice/src/tab_server.cpp
View file @
122f8ea9
...
...
@@ -225,7 +225,7 @@ void ServerMessageLog::processServerMessageEvent(Event_ServerMessage *event)
}
TabServer
::
TabServer
(
Client
*
_client
,
QWidget
*
parent
)
:
QWidget
(
parent
),
client
(
_client
)
:
Tab
(
parent
),
client
(
_client
)
{
gameSelector
=
new
GameSelector
(
client
);
chatChannelSelector
=
new
ChatChannelSelector
(
client
);
...
...
cockatrice/src/tab_server.h
View file @
122f8ea9
...
...
@@ -2,6 +2,7 @@
#define TAB_SERVER_H
#include
<QGroupBox>
#include
"tab.h"
#include
"protocol_datastructures.h"
class
Client
;
...
...
@@ -71,7 +72,7 @@ public:
void
retranslateUi
();
};
class
TabServer
:
public
QWidget
{
class
TabServer
:
public
Tab
{
Q_OBJECT
signals:
void
chatChannelJoined
(
const
QString
&
channelName
);
...
...
cockatrice/src/tab_supervisor.cpp
View file @
122f8ea9
...
...
@@ -11,6 +11,7 @@ TabSupervisor:: TabSupervisor(QWidget *parent)
:
QTabWidget
(
parent
),
client
(
0
),
tabServer
(
0
),
tabDeckStorage
(
0
)
{
setIconSize
(
QSize
(
15
,
15
));
connect
(
this
,
SIGNAL
(
currentChanged
(
int
)),
this
,
SLOT
(
updateMenu
(
int
)));
}
void
TabSupervisor
::
retranslateUi
()
...
...
@@ -131,3 +132,11 @@ void TabSupervisor::processGameEvent(GameEvent *event)
}
else
qDebug
()
<<
"gameEvent: invalid gameId"
;
}
void
TabSupervisor
::
updateMenu
(
int
index
)
{
if
(
index
!=
-
1
)
emit
setMenu
(
static_cast
<
Tab
*>
(
widget
(
index
))
->
getTabMenu
());
else
emit
setMenu
(
0
);
}
cockatrice/src/tab_supervisor.h
View file @
122f8ea9
...
...
@@ -4,6 +4,7 @@
#include
<QTabWidget>
#include
<QMap>
class
QMenu
;
class
Client
;
class
TabServer
;
class
TabChatChannel
;
...
...
@@ -26,7 +27,10 @@ public:
void
retranslateUi
();
void
start
(
Client
*
_client
);
void
stop
();
signals:
void
setMenu
(
QMenu
*
menu
);
private
slots
:
void
updateMenu
(
int
index
);
void
updatePingTime
(
int
value
,
int
max
);
void
gameJoined
(
Event_GameJoined
*
event
);
void
addChatChannelTab
(
const
QString
&
channelName
);
...
...
cockatrice/src/window_main.cpp
View file @
122f8ea9
...
...
@@ -18,7 +18,6 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include
<QtGui>
//#include <QtOpenGL>
#include
"window_main.h"
#include
"dlg_connect.h"
...
...
@@ -26,14 +25,15 @@
#include
"window_deckeditor.h"
#include
"tab_supervisor.h"
/*
void MainWindow::playerAdded(Player *player)
void
MainWindow
::
updateTabMenu
(
QMenu
*
menu
)
{
menuBar()->addMenu(player->getPlayerMenu());
connect(player, SIGNAL(toggleZoneView(Player *, QString, int)), zoneLayout, SLOT(toggleZoneView(Player *, QString, int)));
connect(player, SIGNAL(closeZoneView(ZoneViewZone *)), zoneLayout, SLOT(removeItem(ZoneViewZone *)));
if
(
tabMenu
)
menuBar
()
->
removeAction
(
tabMenu
->
menuAction
());
tabMenu
=
menu
;
if
(
menu
)
menuBar
()
->
addMenu
(
menu
);
}
*/
void
MainWindow
::
statusChanged
(
ClientStatus
_status
)
{
switch
(
_status
)
{
...
...
@@ -207,12 +207,13 @@ void MainWindow::createMenus()
}
MainWindow
::
MainWindow
(
QWidget
*
parent
)
:
QMainWindow
(
parent
)
:
QMainWindow
(
parent
)
,
tabMenu
(
0
)
{
QPixmapCache
::
setCacheLimit
(
200000
);
client
=
new
Client
(
this
);
tabSupervisor
=
new
TabSupervisor
;
connect
(
tabSupervisor
,
SIGNAL
(
setMenu
(
QMenu
*
)),
this
,
SLOT
(
updateTabMenu
(
QMenu
*
)));
setCentralWidget
(
tabSupervisor
);
/*
...
...
cockatrice/src/window_main.h
View file @
122f8ea9
...
...
@@ -28,7 +28,7 @@ class TabSupervisor;
class
MainWindow
:
public
QMainWindow
{
Q_OBJECT
private
slots
:
//
void
playerAdded(Player *player
);
void
updateTabMenu
(
QMenu
*
menu
);
void
statusChanged
(
ClientStatus
_status
);
void
serverTimeout
();
...
...
@@ -46,7 +46,7 @@ private:
void
retranslateUi
();
void
createActions
();
void
createMenus
();
QMenu
*
cockatriceMenu
;
QMenu
*
cockatriceMenu
,
*
tabMenu
;
QAction
*
aConnect
,
*
aDisconnect
,
*
aDeckEditor
,
*
aFullScreen
,
*
aSettings
,
*
aExit
;
TabSupervisor
*
tabSupervisor
;
...
...
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