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
6c93b1e9
Commit
6c93b1e9
authored
Nov 22, 2009
by
Max-Wilhelm Bruker
Browse files
ping time display is working again
parent
4fac0e5b
Changes
5
Hide whitespace changes
Inline
Side-by-side
cockatrice/src/tab_game.cpp
View file @
6c93b1e9
...
@@ -73,8 +73,6 @@ TabGame::TabGame(Client *_client, int _gameId)
...
@@ -73,8 +73,6 @@ TabGame::TabGame(Client *_client, int _gameId)
connect
(
sayEdit
,
SIGNAL
(
returnPressed
()),
this
,
SLOT
(
actSay
()));
connect
(
sayEdit
,
SIGNAL
(
returnPressed
()),
this
,
SLOT
(
actSay
()));
// connect(client, SIGNAL(maxPingTime(int, int)), pingWidget, SLOT(setPercentage(int, int)));
connect
(
phasesToolbar
,
SIGNAL
(
signalSetPhase
(
int
)),
client
,
SLOT
(
setActivePhase
(
int
)));
connect
(
phasesToolbar
,
SIGNAL
(
signalSetPhase
(
int
)),
client
,
SLOT
(
setActivePhase
(
int
)));
connect
(
phasesToolbar
,
SIGNAL
(
signalNextTurn
()),
client
,
SLOT
(
nextTurn
()));
connect
(
phasesToolbar
,
SIGNAL
(
signalNextTurn
()),
client
,
SLOT
(
nextTurn
()));
...
...
cockatrice/src/tab_supervisor.cpp
View file @
6c93b1e9
...
@@ -5,11 +5,12 @@
...
@@ -5,11 +5,12 @@
#include
"tab_game.h"
#include
"tab_game.h"
#include
"tab_deck_storage.h"
#include
"tab_deck_storage.h"
#include
"protocol_items.h"
#include
"protocol_items.h"
#include
<QPainter>
TabSupervisor
::
TabSupervisor
(
QWidget
*
parent
)
TabSupervisor
::
TabSupervisor
(
QWidget
*
parent
)
:
QTabWidget
(
parent
),
client
(
0
),
tabServer
(
0
),
tabDeckStorage
(
0
)
:
QTabWidget
(
parent
),
client
(
0
),
tabServer
(
0
),
tabDeckStorage
(
0
)
{
{
setIconSize
(
QSize
(
15
,
15
));
}
}
void
TabSupervisor
::
retranslateUi
()
void
TabSupervisor
::
retranslateUi
()
...
@@ -38,10 +39,12 @@ void TabSupervisor::start(Client *_client)
...
@@ -38,10 +39,12 @@ void TabSupervisor::start(Client *_client)
connect
(
client
,
SIGNAL
(
chatEventReceived
(
ChatEvent
*
)),
this
,
SLOT
(
processChatEvent
(
ChatEvent
*
)));
connect
(
client
,
SIGNAL
(
chatEventReceived
(
ChatEvent
*
)),
this
,
SLOT
(
processChatEvent
(
ChatEvent
*
)));
connect
(
client
,
SIGNAL
(
gameEventReceived
(
GameEvent
*
)),
this
,
SLOT
(
processGameEvent
(
GameEvent
*
)));
connect
(
client
,
SIGNAL
(
gameEventReceived
(
GameEvent
*
)),
this
,
SLOT
(
processGameEvent
(
GameEvent
*
)));
connect
(
client
,
SIGNAL
(
gameJoinedEventReceived
(
Event_GameJoined
*
)),
this
,
SLOT
(
gameJoined
(
Event_GameJoined
*
)));
connect
(
client
,
SIGNAL
(
gameJoinedEventReceived
(
Event_GameJoined
*
)),
this
,
SLOT
(
gameJoined
(
Event_GameJoined
*
)));
connect
(
client
,
SIGNAL
(
maxPingTime
(
int
,
int
)),
this
,
SLOT
(
updatePingTime
(
int
,
int
)));
tabServer
=
new
TabServer
(
client
);
tabServer
=
new
TabServer
(
client
);
connect
(
tabServer
,
SIGNAL
(
chatChannelJoined
(
const
QString
&
)),
this
,
SLOT
(
addChatChannelTab
(
const
QString
&
)));
connect
(
tabServer
,
SIGNAL
(
chatChannelJoined
(
const
QString
&
)),
this
,
SLOT
(
addChatChannelTab
(
const
QString
&
)));
addTab
(
tabServer
,
QString
());
addTab
(
tabServer
,
QString
());
updatePingTime
(
0
,
-
1
);
tabDeckStorage
=
new
TabDeckStorage
(
client
);
tabDeckStorage
=
new
TabDeckStorage
(
client
);
addTab
(
tabDeckStorage
,
QString
());
addTab
(
tabDeckStorage
,
QString
());
...
@@ -75,6 +78,27 @@ void TabSupervisor::stop()
...
@@ -75,6 +78,27 @@ void TabSupervisor::stop()
gameTabs
.
clear
();
gameTabs
.
clear
();
}
}
void
TabSupervisor
::
updatePingTime
(
int
value
,
int
max
)
{
if
(
!
tabServer
)
return
;
QPixmap
pixmap
(
15
,
15
);
pixmap
.
fill
(
Qt
::
transparent
);
QPainter
painter
(
&
pixmap
);
QColor
color
;
if
(
max
==
-
1
)
color
=
Qt
::
black
;
else
color
.
setHsv
(
120
*
(
1.0
-
((
double
)
value
/
max
)),
255
,
255
);
QRadialGradient
g
(
QPointF
((
double
)
pixmap
.
width
()
/
2
,
(
double
)
pixmap
.
height
()
/
2
),
qMin
(
pixmap
.
width
(),
pixmap
.
height
())
/
2.0
);
g
.
setColorAt
(
0
,
color
);
g
.
setColorAt
(
1
,
Qt
::
transparent
);
painter
.
fillRect
(
0
,
0
,
pixmap
.
width
(),
pixmap
.
height
(),
QBrush
(
g
));
setTabIcon
(
0
,
QIcon
(
pixmap
));
}
void
TabSupervisor
::
gameJoined
(
Event_GameJoined
*
event
)
void
TabSupervisor
::
gameJoined
(
Event_GameJoined
*
event
)
{
{
TabGame
*
tab
=
new
TabGame
(
client
,
event
->
getGameId
());
TabGame
*
tab
=
new
TabGame
(
client
,
event
->
getGameId
());
...
...
cockatrice/src/tab_supervisor.h
View file @
6c93b1e9
...
@@ -27,6 +27,7 @@ public:
...
@@ -27,6 +27,7 @@ public:
void
start
(
Client
*
_client
);
void
start
(
Client
*
_client
);
void
stop
();
void
stop
();
private
slots
:
private
slots
:
void
updatePingTime
(
int
value
,
int
max
);
void
gameJoined
(
Event_GameJoined
*
event
);
void
gameJoined
(
Event_GameJoined
*
event
);
void
addChatChannelTab
(
const
QString
&
channelName
);
void
addChatChannelTab
(
const
QString
&
channelName
);
void
processChatEvent
(
ChatEvent
*
event
);
void
processChatEvent
(
ChatEvent
*
event
);
...
...
cockatrice/src/window_main.cpp
View file @
6c93b1e9
...
@@ -26,34 +26,6 @@
...
@@ -26,34 +26,6 @@
#include
"window_deckeditor.h"
#include
"window_deckeditor.h"
#include
"tab_supervisor.h"
#include
"tab_supervisor.h"
PingWidget
::
PingWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
setPercentage
(
0
,
-
1
);
}
QSize
PingWidget
::
sizeHint
()
const
{
return
QSize
(
15
,
15
);
}
void
PingWidget
::
paintEvent
(
QPaintEvent
*/
*
event
*/
)
{
QPainter
painter
(
this
);
QRadialGradient
g
(
QPointF
((
double
)
width
()
/
2
,
(
double
)
height
()
/
2
),
qMin
(
width
(),
height
())
/
2.0
);
g
.
setColorAt
(
0
,
color
);
g
.
setColorAt
(
1
,
Qt
::
transparent
);
painter
.
fillRect
(
0
,
0
,
width
(),
height
(),
QBrush
(
g
));
}
void
PingWidget
::
setPercentage
(
int
value
,
int
max
)
{
if
(
max
==
-
1
)
color
=
Qt
::
black
;
else
color
.
setHsv
(
120
*
(
1.0
-
((
double
)
value
/
max
)),
255
,
255
);
update
();
}
/*
/*
void MainWindow::playerAdded(Player *player)
void MainWindow::playerAdded(Player *player)
{
{
...
@@ -75,7 +47,6 @@ void MainWindow::statusChanged(ClientStatus _status)
...
@@ -75,7 +47,6 @@ void MainWindow::statusChanged(ClientStatus _status)
// delete game;
// delete game;
// game = 0;
// game = 0;
// }
// }
// pingWidget->setPercentage(0, -1);
aConnect
->
setEnabled
(
true
);
aConnect
->
setEnabled
(
true
);
aDisconnect
->
setEnabled
(
false
);
aDisconnect
->
setEnabled
(
false
);
// aRestartGame->setEnabled(false);
// aRestartGame->setEnabled(false);
...
...
cockatrice/src/window_main.h
View file @
6c93b1e9
...
@@ -25,19 +25,6 @@
...
@@ -25,19 +25,6 @@
class
TabSupervisor
;
class
TabSupervisor
;
class
PingWidget
:
public
QWidget
{
Q_OBJECT
private:
QColor
color
;
protected:
void
paintEvent
(
QPaintEvent
*
event
);
public:
PingWidget
(
QWidget
*
parent
=
0
);
QSize
sizeHint
()
const
;
public
slots
:
void
setPercentage
(
int
value
,
int
max
);
};
class
MainWindow
:
public
QMainWindow
{
class
MainWindow
:
public
QMainWindow
{
Q_OBJECT
Q_OBJECT
private
slots
:
private
slots
:
...
@@ -63,8 +50,6 @@ private:
...
@@ -63,8 +50,6 @@ private:
QAction
*
aConnect
,
*
aDisconnect
,
*
aDeckEditor
,
*
aFullScreen
,
*
aSettings
,
*
aExit
;
QAction
*
aConnect
,
*
aDisconnect
,
*
aDeckEditor
,
*
aFullScreen
,
*
aSettings
,
*
aExit
;
TabSupervisor
*
tabSupervisor
;
TabSupervisor
*
tabSupervisor
;
PingWidget
*
pingWidget
;
Client
*
client
;
Client
*
client
;
public:
public:
MainWindow
(
QWidget
*
parent
=
0
);
MainWindow
(
QWidget
*
parent
=
0
);
...
...
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