-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbardice.cpp
More file actions
44 lines (37 loc) · 1.01 KB
/
bardice.cpp
File metadata and controls
44 lines (37 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "bardice.h"
#include "gameview.h"
#include "statusview.h"
#include <QMouseEvent>
/**
* Author: Yunus Rahbar
* Date: 6/10/13
*
*/
/** BarDice
*
* Dice item in the sidebar rolls dice when dropped on the game view
*
*/
BarDice::BarDice(QString imageName, GameView *view, StatusView *sview, QWidget *parent)
: BarItem(imageName,parent), gameView(view), statusView(sview)
{
}
void BarDice::dropAction(QPoint p)
{
}
/**
* Overrides parent's mouseReleaseEvent
* Requests a server dice roll if dropped in gameView or chatView,
* or does a local, private dice roll if dropped in statusView
*/
void BarDice::mouseReleaseEvent(QMouseEvent *ev)
{
movingLabel->hide();
//int y = ev->globalPos().y();
//int gametop = gameView->mapToGlobal(QPoint(0,0)).y();
//int gamebottom = gameView->mapToGlobal(QPoint(0,gameView->height())).y();
if (ev->globalPos().y() < (statusView->mapToGlobal(QPoint(0,0))).y()) {
emit rollDice(2,6,true);
}
else emit rollDice(2,6,false);
}