-
Notifications
You must be signed in to change notification settings - Fork 0
/
QRogueWidget.cpp
103 lines (86 loc) · 2.52 KB
/
QRogueWidget.cpp
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "QRogueWidget.h"
#include <iostream>
using namespace std;
/** QRogueWidget **
*
* See header file for comments
*
**/
QRogueWidget::QRogueWidget()
{
layout = new QHBoxLayout();
rightSide = new QWidget();
rightSide->setMinimumSize(370,300);
rightLayout = new QVBoxLayout();
QPalette pal = rightSide->palette();
pal.setColor(rightSide->backgroundRole(), Qt::black);
rightSide->setPalette(pal);
rogueDrawing = new rogueText();
rogueDrawing->setFixedSize(370, 160);
rightLayout->addWidget(rogueDrawing);
closingInButton = new QPushButton("Closing In");
closingInButton->setMaximumSize(150, 30);
closingInButton->setFocusPolicy(Qt::NoFocus);
connect(closingInButton, SIGNAL(clicked()), this, SLOT(showClosingIn()));
gauntletButton = new QPushButton("Gauntlet");
gauntletButton->setFocusPolicy(Qt::NoFocus);
gauntletButton->setMaximumSize(150, 30);
connect(gauntletButton, SIGNAL(clicked()), this, SLOT(showGauntlet()));
dungeonButton = new QPushButton("Dungeon");
dungeonButton->setMaximumSize(150, 30);
dungeonButton->setFocusPolicy(Qt::NoFocus);
connect(dungeonButton, SIGNAL(clicked()), this, SLOT(showDungeon()));
rightLayout->addWidget(closingInButton);
rightLayout->addWidget(gauntletButton);
rightLayout->addWidget(dungeonButton);
rightLayout->setAlignment(closingInButton, Qt::AlignHCenter);
rightLayout->setAlignment(gauntletButton, Qt::AlignHCenter);
rightLayout->setAlignment(dungeonButton, Qt::AlignHCenter);
rightSide->setLayout(rightLayout);
layout->addWidget(rightSide);
this->setLayout(layout);
closingIn = NULL;
gauntlet = NULL;
}
void QRogueWidget::showClosingIn()
{
clearDisplay();
closingIn = new ClosingIn();
closingIn->grabKeyboard();
layout->addWidget(closingIn);
}
void QRogueWidget::showGauntlet()
{
clearDisplay();
gauntlet = new Window(40, 40, Window::GAUNTLET);
gauntlet->grabKeyboard();
layout->addWidget(gauntlet);
}
void QRogueWidget::showDungeon()
{
clearDisplay();
dungeon = new Window(40, 40, Window::DUNGEON);
dungeon->grabKeyboard();
layout->addWidget(dungeon);
}
void QRogueWidget::clearDisplay()
{
if(closingIn != NULL)
{
layout->removeWidget(closingIn);
delete closingIn;
closingIn = NULL;
}
else if(gauntlet != NULL)
{
layout->removeWidget(gauntlet);
delete gauntlet;
gauntlet = NULL;
}
else if(dungeon != NULL)
{
layout->removeWidget(dungeon);
delete dungeon;
dungeon = NULL;
}
}