forked from OpenPanzerProject/OP-Config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow_tab_battle.cpp
170 lines (152 loc) · 7.21 KB
/
mainwindow_tab_battle.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#include "mainwindow.h"
#include "ui_mainwindow.h"
//------------------------------------------------------------------------------------------------------------------------>>
// FORM CONTROLS - BATTLE TAB
//------------------------------------------------------------------------------------------------------------------------>>
void MainWindow::SetupControls_BattleTab(void)
{
// Setup the primary and secondary IR protocols
ui->cboFireProtocol->SetupPrimary(); // Primary is the protocol the cannon fires. Damage is also taken with hits from this protocol.
ui->cboHitProtocol_2->SetupSecondary(); // An optional secondary protocol is NOT fired, but you can take damage from it.
// Setup the Team combo. We start it with no entry (just none) and disabled
ui->cboTeam->SetupNone();
ui->cboTeam->setEnabled(false);
// If the primary protocol changes, update the list of secondary protocols
connect(ui->cboFireProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(SetupSecondaryCannonIR(int)));
// If the primary protocol changes, check the team list in case that needs to be set as well.
connect(ui->cboFireProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(SetupIRTeamList(int)));
// If the cannon or MG protocols are disabled, you can disable some other settings
connect(ui->cboFireProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(ShowHideCannonIRSettings(int)));
connect(ui->cboMGProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(ShowHideMGIRSettings(int)));
// If both cannon and MG protocols are disabled, you can disable even more stuff
connect(ui->cboFireProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(ShowHideOtherBattleSettings(int)));
connect(ui->cboMGProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(ShowHideOtherBattleSettings(int)));
// If we don't accept incoming MG hits, we can disable the max MG hits setting
connect(ui->chkAcceptMG, SIGNAL(toggled(bool)), this, SLOT(ShowHideMGHits(bool)));
// RC Tanks Australia Tank ID
// DISABLED FOR NOW
// I don't really like the way RCTA includes an ID number in their transmission. They take a three digit number,
// split it into the individual numbers, and send each number one-by-one in three distinct Sony transmissions.
// So for example, the number 456 is sent as "4", then "5", then "6". If the receiving device misses a single one
// of those codes, the ID will not be read correctly. The silly thing is, each Sony code is 12-bits long, so you could
// easily fit the entire 3-digit number PLUS a bunch of other data into a single code, and then repeat that same
// code 3 times to give the receiver a much better chance of reading it. Overall length of the transmission would be identical,
// and encoding/decoding would be easier as well (instead of trying to break apart a number into characters and then
// reassembling it on the receiving end, you would just send the number as a number).
// I don't think it's a bad idea overall to include an identifier in the IR transmission, so I have already created a variable
// for it. But if we're going to do that we need to use a better method, and probably, the thing should be part of a
// larger discussion about what the ideal Tank IR protocol would be if we were creating a new one from scratch.
ui->lblSendRCTAID->hide();
ui->chkSendTankID->hide();
ui->spinTankID->hide();
ui->lblSpinTankID->hide();
// If we were going to include the tank ID, uncomment the following line:
// User has the option of including a Tank ID number in cannon fire transmissions
//connect(ui->chkSendTankID, SIGNAL(toggled(bool)), this, SLOT(ShowHideTankIDSettings(bool)));
}
void MainWindow::SetupIRTeamList(int)
{
IRTYPES ir = static_cast<IRTYPES>(ui->cboFireProtocol->itemData(ui->cboFireProtocol->currentIndex()).toUInt());
switch (ir)
{
case IR_FOV:
ui->lblTeam->setEnabled(true);
ui->cboTeam->SetupFOVTeams();
ui->cboTeam->setEnabled(true);
break;
default:
ui->lblTeam->setEnabled(false);
ui->cboTeam->SetupNone();
ui->cboTeam->setEnabled(false);
}
}
void MainWindow::SetupSecondaryCannonIR(int)
{ // Any time the primary protocol changes, repopulate the secondary list (it is basically everything except the
// primary selection)
ui->cboHitProtocol_2->SetupSecondary(static_cast<IRTYPES>(ui->cboFireProtocol->currentData().toUInt()));
}
void MainWindow::ShowHideCannonIRSettings(int curIndex)
{ // If cannon IR is disabled, disable some related settings
if (curIndex == 0)
{ // Disable Cannon IR options
ui->lblHitProtocol_2->setEnabled(false);
ui->cboHitProtocol_2->setEnabled(false);
}
else
{
ui->lblHitProtocol_2->setEnabled(true);
ui->cboHitProtocol_2->setEnabled(true);
}
}
void MainWindow::ShowHideMGIRSettings(int curIndex)
{ // If machine gun IR is disabled, disable some related settings
if (curIndex == 0)
{ // Disable MG IR options
ui->lblUseMG->setEnabled(false);
ui->chkUseMG->setChecked(false);
ui->chkUseMG->setEnabled(false);
ui->lblAcceptMG->setEnabled(false);
ui->chkAcceptMG->setChecked(false);
ui->chkAcceptMG->setEnabled(false);
ui->lblMaxMGHits1->setEnabled(false);
ui->lblMaxMGHits2->setEnabled(false);
ui->spinMaxMGHits->setEnabled(false);
}
else
{
ui->lblUseMG->setEnabled(true);
ui->chkUseMG->setEnabled(true);
ui->lblAcceptMG->setEnabled(true);
ui->chkAcceptMG->setEnabled(true);
ShowHideMGHits(ui->chkAcceptMG->isChecked());
}
}
void MainWindow::ShowHideMGHits(bool isChecked)
{
if (isChecked)
{
ui->lblMaxMGHits1->setEnabled(true);
ui->lblMaxMGHits2->setEnabled(true);
ui->spinMaxMGHits->setEnabled(true);
}
else
{
// We aren't accepting hits from MG, so we don't need this setting
ui->lblMaxMGHits1->setEnabled(false);
ui->lblMaxMGHits2->setEnabled(false);
ui->spinMaxMGHits->setEnabled(false);
}
}
void MainWindow::ShowHideOtherBattleSettings(int)
{ // If both cannon and machine gun IR are disabled, disable some related settings
if (ui->cboFireProtocol->currentIndex() == 0 && ui->cboMGProtocol->currentIndex() == 0)
{ // If we aren't using the cannon or the machine gun IR, we also don't need to worry
// about repair IR or damage settings
ui->lblRepairProtocol->setEnabled(false);
ui->cboRepairProtocol->setCurrentIndex(0);
ui->cboRepairProtocol->setEnabled(false);
ui->lblDamageProfile->setEnabled(false);
ui->cboDamageProfile->setCurrentIndex(0);
ui->cboDamageProfile->setEnabled(false);
}
else
{
ui->lblRepairProtocol->setEnabled(true);
ui->cboRepairProtocol->setEnabled(true);
ui->lblDamageProfile->setEnabled(true);
ui->cboDamageProfile->setEnabled(true);
}
}
void MainWindow::ShowHideTankIDSettings(bool checked)
{
if (checked)
{
ui->spinTankID->setEnabled(true);
ui->spinTankID->setValue(DeviceData.TankID);
}
else
{
ui->spinTankID->setEnabled(false);
ui->spinTankID->setValue(1);
}
}