Skip to content

Commit 689f642

Browse files
committed
Fixed inventory showing up for tanks.
1 parent c573cd9 commit 689f642

2 files changed

Lines changed: 66 additions & 80 deletions

File tree

src/Battlescape/InventoryState.cpp

Lines changed: 65 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ InventoryState::InventoryState(Game *game, bool tu, BattlescapeState *parent) :
6262
_showMoreStatsInInventoryView = Options::getBool("showMoreStatsInInventoryView");
6363

6464
// remove any path preview if in the middle of a battlegame
65-
if(tu || _game->getSavedGame()->getSavedBattle()->getDebugMode())
65+
if (tu || _game->getSavedGame()->getSavedBattle()->getDebugMode())
6666
{
6767
_battleGame->getPathfinding()->removePreview();
6868
}
@@ -72,14 +72,11 @@ InventoryState::InventoryState(Game *game, bool tu, BattlescapeState *parent) :
7272
_soldier = new Surface(320, 200, 0, 0);
7373
_txtName = new Text(200, 17, 36, 6);
7474
_txtTus = new Text(40, 9, 245, _showMoreStatsInInventoryView ? 32 : 24);
75-
if (_showMoreStatsInInventoryView)
76-
{
77-
_txtWeight = new Text(70, 9, 245, 24);
78-
_txtFAcc = new Text(40, 9, 245, 32);
79-
_txtReact = new Text(40, 9, 245, 40);
80-
_txtPSkill = new Text(40, 9, 245, 48);
81-
_txtPStr = new Text(40, 9, 245, 56);
82-
}
75+
_txtWeight = new Text(70, 9, 245, 24);
76+
_txtFAcc = new Text(40, 9, 245, 32);
77+
_txtReact = new Text(40, 9, 245, 40);
78+
_txtPSkill = new Text(40, 9, 245, 48);
79+
_txtPStr = new Text(40, 9, 245, 56);
8380
_txtItem = new Text(160, 9, 128, 140);
8481
_txtAmmo = new Text(66, 24, 254, 64);
8582
_btnOk = new InteractiveSurface(35, 22, 237, 1);
@@ -95,14 +92,11 @@ InventoryState::InventoryState(Game *game, bool tu, BattlescapeState *parent) :
9592
add(_soldier);
9693
add(_txtName);
9794
add(_txtTus);
98-
if (_showMoreStatsInInventoryView)
99-
{
100-
add(_txtWeight);
101-
add(_txtFAcc);
102-
add(_txtReact);
103-
add(_txtPSkill);
104-
add(_txtPStr);
105-
}
95+
add(_txtWeight);
96+
add(_txtFAcc);
97+
add(_txtReact);
98+
add(_txtPSkill);
99+
add(_txtPStr);
106100
add(_txtItem);
107101
add(_txtAmmo);
108102
add(_btnOk);
@@ -127,28 +121,25 @@ InventoryState::InventoryState(Game *game, bool tu, BattlescapeState *parent) :
127121
_txtTus->setSecondaryColor(Palette::blockOffset(1));
128122
_txtTus->setHighContrast(true);
129123

130-
if (_showMoreStatsInInventoryView)
131-
{
132-
_txtWeight->setColor(Palette::blockOffset(4));
133-
_txtWeight->setSecondaryColor(Palette::blockOffset(1));
134-
_txtWeight->setHighContrast(true);
124+
_txtWeight->setColor(Palette::blockOffset(4));
125+
_txtWeight->setSecondaryColor(Palette::blockOffset(1));
126+
_txtWeight->setHighContrast(true);
135127

136-
_txtFAcc->setColor(Palette::blockOffset(4));
137-
_txtFAcc->setSecondaryColor(Palette::blockOffset(1));
138-
_txtFAcc->setHighContrast(true);
128+
_txtFAcc->setColor(Palette::blockOffset(4));
129+
_txtFAcc->setSecondaryColor(Palette::blockOffset(1));
130+
_txtFAcc->setHighContrast(true);
139131

140-
_txtReact->setColor(Palette::blockOffset(4));
141-
_txtReact->setSecondaryColor(Palette::blockOffset(1));
142-
_txtReact->setHighContrast(true);
132+
_txtReact->setColor(Palette::blockOffset(4));
133+
_txtReact->setSecondaryColor(Palette::blockOffset(1));
134+
_txtReact->setHighContrast(true);
143135

144-
_txtPSkill->setColor(Palette::blockOffset(4));
145-
_txtPSkill->setSecondaryColor(Palette::blockOffset(1));
146-
_txtPSkill->setHighContrast(true);
136+
_txtPSkill->setColor(Palette::blockOffset(4));
137+
_txtPSkill->setSecondaryColor(Palette::blockOffset(1));
138+
_txtPSkill->setHighContrast(true);
147139

148-
_txtPStr->setColor(Palette::blockOffset(4));
149-
_txtPStr->setSecondaryColor(Palette::blockOffset(1));
150-
_txtPStr->setHighContrast(true);
151-
}
140+
_txtPStr->setColor(Palette::blockOffset(4));
141+
_txtPStr->setSecondaryColor(Palette::blockOffset(1));
142+
_txtPStr->setHighContrast(true);
152143

153144
_txtItem->setColor(Palette::blockOffset(3));
154145
_txtItem->setHighContrast(true);
@@ -173,6 +164,13 @@ InventoryState::InventoryState(Game *game, bool tu, BattlescapeState *parent) :
173164
_inv->setTuMode(_tu);
174165
_inv->setSelectedUnit(_game->getSavedGame()->getSavedBattle()->getSelectedUnit());
175166
_inv->onMouseClick((ActionHandler)&InventoryState::invClick, 0);
167+
168+
_txtTus->setVisible(_tu);
169+
_txtWeight->setVisible(_showMoreStatsInInventoryView);
170+
_txtFAcc->setVisible(_showMoreStatsInInventoryView && !_tu);
171+
_txtReact->setVisible(_showMoreStatsInInventoryView && !_tu);
172+
_txtPSkill->setVisible(_showMoreStatsInInventoryView && !_tu);
173+
_txtPStr->setVisible(_showMoreStatsInInventoryView && !_tu);
176174
}
177175

178176
/**
@@ -208,7 +206,7 @@ void InventoryState::init()
208206
_battleGame->selectNextPlayerUnit(false, false, true);
209207
}
210208
// no available unit, close inventory
211-
if (_battleGame->getSelectedUnit() == 0)
209+
if (_battleGame->getSelectedUnit() == 0 || !_battleGame->getSelectedUnit()->hasInventory())
212210
{
213211
// starting a mission with just vehicles
214212
btnOkClick(0);
@@ -267,30 +265,6 @@ void InventoryState::init()
267265
}
268266
}
269267

270-
if (_showMoreStatsInInventoryView && !_tu)
271-
{
272-
_txtFAcc->setText(tr("STR_FACCURACY").arg((int)(unit->getStats()->firing * unit->getAccuracyModifier())));
273-
274-
_txtReact->setText(tr("STR_REACT").arg(unit->getStats()->reactions));
275-
276-
if (unit->getStats()->psiSkill > 0)
277-
{
278-
_txtPSkill->setText(tr("STR_PSKILL").arg(unit->getStats()->psiSkill));
279-
}
280-
else
281-
{
282-
_txtPSkill->setText(L"");
283-
}
284-
285-
if (unit->getStats()->psiSkill > 0 || (Options::getBool("psiStrengthEval") && _game->getSavedGame()->isResearched(_game->getRuleset()->getPsiRequirements())))
286-
{
287-
_txtPStr->setText(tr("STR_PSTRENGTH").arg(unit->getStats()->psiStrength));
288-
}
289-
else
290-
{
291-
_txtPStr->setText(L"");
292-
}
293-
}
294268
updateStats();
295269
}
296270

@@ -300,22 +274,40 @@ void InventoryState::init()
300274
void InventoryState::updateStats()
301275
{
302276
BattleUnit *unit = _battleGame->getSelectedUnit();
303-
if (_showMoreStatsInInventoryView)
277+
278+
_txtTus->setText(tr("STR_TUS").arg(unit->getTimeUnits()));
279+
280+
int weight = unit->getCarriedWeight(_inv->getSelectedItem());
281+
_txtWeight->setText(tr("STR_WEIGHT").arg(weight).arg(unit->getStats()->strength));
282+
if (weight > unit->getStats()->strength)
304283
{
305-
int weight = unit->getCarriedWeight(_inv->getSelectedItem());
306-
_txtWeight->setText(tr("STR_WEIGHT").arg(weight).arg(unit->getStats()->strength));
307-
if (weight > unit->getStats()->strength)
308-
{
309-
_txtWeight->setSecondaryColor(Palette::blockOffset(2));
310-
}
311-
else
312-
{
313-
_txtWeight->setSecondaryColor(Palette::blockOffset(1));
314-
}
284+
_txtWeight->setSecondaryColor(Palette::blockOffset(2));
285+
}
286+
else
287+
{
288+
_txtWeight->setSecondaryColor(Palette::blockOffset(1));
315289
}
316-
if (_tu)
290+
291+
_txtFAcc->setText(tr("STR_FACCURACY").arg((int)(unit->getStats()->firing * unit->getAccuracyModifier())));
292+
293+
_txtReact->setText(tr("STR_REACT").arg(unit->getStats()->reactions));
294+
295+
if (unit->getStats()->psiSkill > 0)
296+
{
297+
_txtPSkill->setText(tr("STR_PSKILL").arg(unit->getStats()->psiSkill));
298+
}
299+
else
300+
{
301+
_txtPSkill->setText(L"");
302+
}
303+
304+
if (unit->getStats()->psiSkill > 0 || (Options::getBool("psiStrengthEval") && _game->getSavedGame()->isResearched(_game->getRuleset()->getPsiRequirements())))
305+
{
306+
_txtPStr->setText(tr("STR_PSTRENGTH").arg(unit->getStats()->psiStrength));
307+
}
308+
else
317309
{
318-
_txtTus->setText(tr("STR_TUS").arg(unit->getTimeUnits()));
310+
_txtPStr->setText(L"");
319311
}
320312
}
321313

src/Resource/XcomResourcePack.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,19 +385,13 @@ XcomResourcePack::XcomResourcePack(std::vector<std::pair<std::string, ExtraSprit
385385
{
386386
SoundSet *s = _sounds["INTRO.CAT"] = new SoundSet();
387387
s->loadCat(CrossPlatform::getDataFile("SOUND/INTRO.CAT"), false);
388-
} else
389-
{
390-
Log(LOG_WARNING) << "INTRO.CAT is missing! :(";
391388
}
392389

393390
if (CrossPlatform::fileExists(CrossPlatform::getDataFile("SOUND/SAMPLE3.CAT")))
394391
{
395392
SoundSet *s = _sounds["SAMPLE3.CAT"] = new SoundSet();
396393
wav = true;
397394
s->loadCat(CrossPlatform::getDataFile("SOUND/SAMPLE3.CAT"), true);
398-
} else
399-
{
400-
Log(LOG_WARNING) << "SAMPLE3.CAT is missing! :(";
401395
}
402396

403397
}
@@ -802,7 +796,7 @@ void XcomResourcePack::loadBattlescapeResources()
802796
}
803797

804798
// Add in custom reserve buttons
805-
Surface *icons = new Surface(50, 24);
799+
Surface *icons = new Surface(59, 24);
806800
icons->loadImage(CrossPlatform::getDataFile("Resources/UI/reserve.png"));
807801
icons->setX(48);
808802
icons->setY(176);

0 commit comments

Comments
 (0)