-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathaskBoneDialog.cpp
132 lines (110 loc) · 3.37 KB
/
askBoneDialog.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* OpenBRF -- by marco tarini. Provided under GNU General Public License */
#include "askBoneDialog.h"
#include "ui_askBoneDialog.h"
AskBoneDialog::AskBoneDialog(QWidget *parent,const std::vector<BrfSkeleton> &s,
const std::vector<CarryPosition> &_cp) :
QDialog(parent),
//sv(s),
ui(new Ui::AskBoneDialog)
{
sv=s;
carrypos=_cp;
ui->setupUi(this);
for (int i=0; i<(int)sv.size(); i++)
ui->cbSlel->addItem( sv[i].name );
onSelectSkel(0);
ui->radioButton->setChecked(true);
ui->radioButton_2->setChecked(false);
connect(ui->cbSlel, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectSkel(int)) );
connect(ui->cbCarryPos, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectCarryPos(int)) );
connect(ui->cbBone, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectBone(int)) );
}
void AskBoneDialog::onSelectBone(int /*i*/){
if (ui->cbCarryPos->currentIndex()!=0)
ui->cbCarryPos->setCurrentIndex(0);
}
void AskBoneDialog::onSelectCarryPos(int i){
/*
i--;
if (i<0) return;
int boneIndex = sv[ ui->cbSlel->currentIndex() ].FindBoneByName(
carrypos[i].boneName
);
qDebug("Found bone %d for name %s",boneIndex, carrypos[i].boneName);
ui->cbBone->blockSignals(true);
ui->cbBone->setCurrentIndex( boneIndex );
ui->cbBone->blockSignals(false);
*/
i--;
if (i<0) {
ui->cbBone->setEnabled(true);
ui->radioButton->setEnabled(true);
ui->radioButton_2->setEnabled(true);
} else {
int boneIndex = sv[ ui->cbSlel->currentIndex() ].FindBoneByName(
carrypos[i].boneName
);
//qDebug("Found bone %d for name %s",boneIndex, carrypos[i].boneName);
ui->cbBone->blockSignals(true);
ui->cbBone->setCurrentIndex( boneIndex );
ui->radioButton->setChecked(true);
ui->radioButton_2->setChecked(false);
ui->cbBone->blockSignals(false);
ui->cbBone->setEnabled(false);
ui->radioButton->setEnabled(false);
ui->radioButton_2->setEnabled(false);
}
}
void AskBoneDialog::sayNotSkinned(bool say){
ui->label_3->setVisible(say);
}
bool AskBoneDialog::pieceAtOrigin()const{
return ui->radioButton->isChecked();
}
void AskBoneDialog::onSelectSkel(int i){
ui->cbBone->clear();
for (unsigned int j=0; j<sv[i].bone.size(); j++)
ui->cbBone->addItem( sv[i].bone[j].name );
QString currText = ui->cbCarryPos->currentText();
int currIndex = 0;
ui->cbCarryPos->clear();
// update carrypos array (show only ones with bones)
ui->cbCarryPos->blockSignals(true);
BrfSkeleton &s(sv[i]);
ui->cbCarryPos->addItem( tr("<none>"));
for (unsigned int j=0; j<carrypos.size(); j++){
if (s.FindBoneByName(carrypos[j].boneName)!=-1) {
QString carryName(carrypos[j].name);
//if (carryName.startsWith("itcf_carry_"))
// carryName = carryName.remove(0,11);
ui->cbCarryPos->addItem( carryName );
if (carryName==currText) currIndex = j+1;
}
}
ui->cbCarryPos->setCurrentIndex(currIndex);
ui->cbCarryPos->blockSignals(false);
}
int AskBoneDialog::getSkel() const {
return ui->cbSlel->currentIndex();
}
int AskBoneDialog::getCarryPos() const{
return ui->cbCarryPos->currentIndex()-1; // -1 for <none>
}
int AskBoneDialog::getBone() const {
return ui->cbBone->currentIndex();
}
AskBoneDialog::~AskBoneDialog()
{
delete ui;
}
void AskBoneDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}