-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapsizeselector.cpp
More file actions
84 lines (75 loc) · 1.81 KB
/
mapsizeselector.cpp
File metadata and controls
84 lines (75 loc) · 1.81 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
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
#include "mapsizeselector.h"
#include "ui_mapsizeselector.h"
#include "project.h"
extern Project project;
MapSizeSelector::MapSizeSelector(QWidget *parent)
: QWidget(parent)
, ui(new Ui::MapSizeSelector)
{
ui->setupUi(this);
if (project.current_mapcanvas)
{
ui->spbWidth->setValue(project.current_mapcanvas->Size().width()*TILE_W);
ui->spbHeight->setValue(project.current_mapcanvas->Size().height()*TILE_H);
}
else
close();
}
MapSizeSelector::~MapSizeSelector()
{
delete ui;
}
void MapSizeSelector::on_cmbPresetSize_currentIndexChanged(int index)
{
if (index)
{
ui->spbWidth->setEnabled(false);
ui->spbHeight->setEnabled(false);
}
else
{
ui->spbWidth->setEnabled(true);
ui->spbHeight->setEnabled(true);
}
switch (index)
{
case 1:
ui->spbWidth->setValue(128);
ui->spbHeight->setValue(128);
break;
case 2:
ui->spbWidth->setValue(256);
ui->spbHeight->setValue(256);
break;
case 3:
ui->spbWidth->setValue(512);
ui->spbHeight->setValue(256);
break;
case 4:
ui->spbWidth->setValue(256);
ui->spbHeight->setValue(512);
break;
case 5:
ui->spbWidth->setValue(512);
ui->spbHeight->setValue(512);
break;
case 6:
ui->spbWidth->setValue(1024);
ui->spbHeight->setValue(1024);
break;
}
}
void MapSizeSelector::on_bnbDialogButtons_rejected()
{
this->close();
}
void MapSizeSelector::on_bnbDialogButtons_accepted()
{
if (project.current_mapcanvas)
{
project.current_mapcanvas->Resize(ui->spbWidth->value()/TILE_W, ui->spbHeight->value()/TILE_H);
}
else
return; //TODO: add this case for when creating a new project
this->close();
}