-
Notifications
You must be signed in to change notification settings - Fork 6
/
itemlistwidget.cpp
105 lines (92 loc) · 2.34 KB
/
itemlistwidget.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
104
#include "itemlistwidget.h"
#include "ui_itemlistwidget.h"
ItemListWidget::ItemListWidget(QWidget *parent)
: QWidget{parent}
, ui(new Ui::ItemListWidget)
{
ui->setupUi(this);
connect(ui->cb, &QCheckBox::stateChanged, this, &ItemListWidget::stateChanged);
}
ItemListWidget::~ItemListWidget()
{
delete ui;
}
void ItemListWidget::setItem(Item item)
{
this_item = item;
ui->cb->setChecked(true);
if(item.name == ID_ECB)
{
ui->toolButton->setIcon(QIcon(":/icon/res/enchanted_book.png"));
ui->weapon_name->setText("附魔书|Enchanted Book");
}
else if(item.name == "")
{
ui->cb->setHidden(true);
ui->toolButton->setIcon(QIcon(":/icon/res/pack.png"));
ui->weapon_name->setText("(双击添加物品 Double click to add item)");
ui->ench_name->setHidden(true);
}
else
{
int p = Basic::searchWeapon(item.name);
ui->toolButton->setIcon(Basic::weapon[p].icon);
ui->weapon_name->setText(Basic::weapon[p].name.simplified());
}
ui->sb->setHidden(true);
}
Item ItemListWidget::item()
{
return Item();
}
void ItemListWidget::setEnch(EnchPlus ench)
{
ui->cb->setChecked(false);
ui->toolButton->setIcon(QIcon(":/icon/res/enchanted_book.png"));
ui->weapon_name->setHidden(true);
ui->ench_name->setText(ench.e.name);
ui->sb->setHidden(false);
ui->sb->setMinimum(ench.e.lvl+1);
ui->sb->setMaximum(ench.mlvl);
ui->sb->setValue(ench.mlvl);
}
Ench ItemListWidget::ench()
{
Ench e;
e.name = ui->ench_name->text();
e.lvl = ui->sb->value();
return e;
}
void ItemListWidget::setChecked(bool a)
{
ui->cb->setChecked(a);
}
bool ItemListWidget::isChecked()
{
return ui->cb->isChecked();
}
void ItemListWidget::checkRepulsion()
{
int p = Basic::searchTable(ui->ench_name->text());
if(p == -1)
return;
for(int i = 0; i < Basic::needed_ench_l; i++)
{
for(int j = 0; j < Basic::ench_table[p].repulsion->count(); j++)
{
if(Basic::needed_ench[i].name == Basic::ench_table[p].repulsion[j])
{
setEnabled(false);
return;
}
}
}
if(!isEnabled())
{
setEnabled(true);
}
}
void ItemListWidget::setLayoutMode(QLayout::SizeConstraint a)
{
ui->horizontalLayout->setSizeConstraint(a);
}