Skip to content

Commit 1884a77

Browse files
committed
Merge remote-tracking branch 'supsuperorgin/master' into smaster
2 parents 98037bc + 41b5839 commit 1884a77

22 files changed

Lines changed: 357 additions & 755 deletions

‎bin/data/Language/Portuguese.lng‎

Lines changed: 52 additions & 48 deletions
Large diffs are not rendered by default.

‎bin/data/SoldierName/Portuguese.nam‎

Lines changed: 69 additions & 489 deletions
Large diffs are not rendered by default.

‎src/Battlescape/BattlescapeGame.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ void BattlescapeGame::think()
134134
if (!_playerPanicHandled)
135135
{
136136
_playerPanicHandled = handlePanickingPlayer();
137+
_save->getBattleState()->updateSoldierInfo();
137138
}
138139
}
139140
if (_save->getUnitsFalling())

‎src/Battlescape/BattlescapeState.cpp‎

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ BattlescapeState::BattlescapeState(Game *game) : State(game), _popups()
138138
_numAmmoLeft = new NumberText(30, 5, _icons->getX() + 8, _icons->getY() + 4);
139139
_btnRightHandItem = new InteractiveSurface(32, 48, _icons->getX() + 280, _icons->getY() + 5);
140140
_numAmmoRight = new NumberText(30, 5, _icons->getX() + 280, _icons->getY() + 4);
141-
for (int i = 0; i < 10; ++i)
141+
for (int i = 0; i < VISIBLE_MAX; ++i)
142142
{
143143
_btnVisibleUnit[i] = new InteractiveSurface(15, 12, _icons->getX() + iconsWidth - 20, _icons->getY() - 16 - (i * 13));
144144
_numVisibleUnit[i] = new NumberText(15, 12, _icons->getX() + iconsWidth - 14 , _icons->getY() - 12 - (i * 13));
145145
}
146-
_numVisibleUnit[9]->setX(304); // center number 10
146+
_numVisibleUnit[9]->setX(_numVisibleUnit[9]->getX() - 2); // center number 10
147147
_warning = new WarningMessage(224, 24, _icons->getX() + 48, _icons->getY() + 32);
148148
_btnLaunch = new InteractiveSurface(32, 24, game->getScreen()->getWidth() / game->getScreen()->getXScale() - 32, 0);
149149
_btnLaunch->setVisible(false);
@@ -234,7 +234,7 @@ BattlescapeState::BattlescapeState(Game *game) : State(game), _popups()
234234
add(_numAmmoLeft);
235235
add(_btnRightHandItem);
236236
add(_numAmmoRight);
237-
for (int i = 0; i < 10; ++i)
237+
for (int i = 0; i < VISIBLE_MAX; ++i)
238238
{
239239
add(_btnVisibleUnit[i]);
240240
add(_numVisibleUnit[i]);
@@ -365,13 +365,7 @@ BattlescapeState::BattlescapeState(Game *game) : State(game), _popups()
365365
_btnStats->onMouseOut((ActionHandler)&BattlescapeState::txtTooltipOut);
366366

367367
_btnLeftHandItem->onMouseClick((ActionHandler)&BattlescapeState::btnLeftHandItemClick);
368-
_btnLeftHandItem->setTooltip("STR_LEFT_HAND");
369-
_btnLeftHandItem->onMouseIn((ActionHandler)&BattlescapeState::txtTooltipIn);
370-
_btnLeftHandItem->onMouseOut((ActionHandler)&BattlescapeState::txtTooltipOut);
371368
_btnRightHandItem->onMouseClick((ActionHandler)&BattlescapeState::btnRightHandItemClick);
372-
_btnRightHandItem->setTooltip("STR_RIGHT_HAND");
373-
_btnRightHandItem->onMouseIn((ActionHandler)&BattlescapeState::txtTooltipIn);
374-
_btnRightHandItem->onMouseOut((ActionHandler)&BattlescapeState::txtTooltipOut);
375369

376370
_btnReserveNone->onMouseClick((ActionHandler)&BattlescapeState::btnReserveClick);
377371
_btnReserveNone->onKeyboardPress((ActionHandler)&BattlescapeState::btnReserveClick, (SDLKey)Options::getInt("keyBattleReserveNone"));
@@ -408,7 +402,7 @@ BattlescapeState::BattlescapeState(Game *game) : State(game), _popups()
408402
_btnStats->onKeyboardPress((ActionHandler)&BattlescapeState::btnReloadClick, (SDLKey)Options::getInt("keyBattleReload"));
409403
_btnStats->onKeyboardPress((ActionHandler)&BattlescapeState::btnPersonalLightingClick, (SDLKey)Options::getInt("keyBattlePersonalLighting"));
410404

411-
for (int i = 0; i < 10; ++i)
405+
for (int i = 0; i < VISIBLE_MAX; ++i)
412406
{
413407
std::stringstream key, tooltip;
414408
key << "keyBattleCenterEnemy" << (i+1);
@@ -902,7 +896,7 @@ void BattlescapeState::btnShowLayersClick(Action *)
902896
*/
903897
void BattlescapeState::btnHelpClick(Action *)
904898
{
905-
if (_map->getProjectile() == 0) // we're deliberately not using allowButtons() here, so we can save if something goes wrong during the alien turn, and submit it for dissection.
899+
if (allowButtons(true))
906900
_game->pushState(new BattlescapeOptionsState(_game));
907901
}
908902

@@ -998,7 +992,7 @@ void BattlescapeState::btnVisibleUnitClick(Action *action)
998992
int btnID = -1;
999993

1000994
// got to find out which button was pressed
1001-
for (int i = 0; i < 10 && btnID == -1; ++i)
995+
for (int i = 0; i < VISIBLE_MAX && btnID == -1; ++i)
1002996
{
1003997
if (action->getSender() == _btnVisibleUnit[i])
1004998
{
@@ -1099,7 +1093,7 @@ void BattlescapeState::updateSoldierInfo()
10991093
{
11001094
BattleUnit *battleUnit = _save->getSelectedUnit();
11011095

1102-
for (int i = 0; i < 10; ++i)
1096+
for (int i = 0; i < VISIBLE_MAX; ++i)
11031097
{
11041098
_btnVisibleUnit[i]->setVisible(false);
11051099
_numVisibleUnit[i]->setVisible(false);
@@ -1189,7 +1183,7 @@ void BattlescapeState::updateSoldierInfo()
11891183

11901184
_save->getTileEngine()->calculateFOV(_save->getSelectedUnit());
11911185
int j = 0;
1192-
for (std::vector<BattleUnit*>::iterator i = battleUnit->getVisibleUnits()->begin(); i != battleUnit->getVisibleUnits()->end(); ++i)
1186+
for (std::vector<BattleUnit*>::iterator i = battleUnit->getVisibleUnits()->begin(); i != battleUnit->getVisibleUnits()->end() && j < VISIBLE_MAX; ++i)
11931187
{
11941188
_btnVisibleUnit[j]->setVisible(true);
11951189
_numVisibleUnit[j]->setVisible(true);
@@ -1218,7 +1212,7 @@ void BattlescapeState::blinkVisibleUnitButtons()
12181212
square2.w = 13;
12191213
square2.h = 10;
12201214

1221-
for (int i = 0; i < 10; ++i)
1215+
for (int i = 0; i < VISIBLE_MAX; ++i)
12221216
{
12231217
if (_btnVisibleUnit[i]->getVisible() == true)
12241218
{
@@ -1849,11 +1843,18 @@ bool BattlescapeState::getMouseOverIcons() const
18491843
}
18501844

18511845
/**
1852-
* Determines whether the player is allowed to press buttons?
1846+
* Determines whether the player is allowed to press buttons.
1847+
* Buttons are disabled in the middle of a shot, during the alien turn,
1848+
* and while a player's units are panicking.
1849+
* The save button is an exception as we want to still be able to save if something
1850+
* goes wrong during the alien turn, and submit the save file for dissection.
1851+
* @param allowSaving True, if the help button was clicked.
18531852
*/
1854-
bool BattlescapeState::allowButtons() const
1853+
bool BattlescapeState::allowButtons(bool allowSaving) const
18551854
{
1856-
return (_save->getSide() == FACTION_PLAYER || _save->getDebugMode()) && _map->getProjectile() == 0;
1855+
return ((allowSaving || _save->getSide() == FACTION_PLAYER || _save->getDebugMode())
1856+
&& _battleGame->getPanicHandled()
1857+
&& (_map->getProjectile() == 0));
18571858
}
18581859

18591860
/**

‎src/Battlescape/BattlescapeState.h‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ class BattlescapeState : public State
5757
ImageButton *_reserve;
5858
ImageButton *_btnReserveNone, *_btnReserveSnap, *_btnReserveAimed, *_btnReserveAuto, *_btnReserveKneel, *_btnZeroTUs;
5959
InteractiveSurface *_btnLeftHandItem, *_btnRightHandItem;
60-
InteractiveSurface *_btnVisibleUnit[10];
61-
NumberText *_numVisibleUnit[10];
62-
BattleUnit *_visibleUnit[10];
60+
static const int VISIBLE_MAX = 10;
61+
InteractiveSurface *_btnVisibleUnit[VISIBLE_MAX];
62+
NumberText *_numVisibleUnit[VISIBLE_MAX];
63+
BattleUnit *_visibleUnit[VISIBLE_MAX];
6364
WarningMessage *_warning;
6465
Text *_txtName;
6566
NumberText *_numTimeUnits, *_numEnergy, *_numHealth, *_numMorale, *_numLayers, *_numAmmoLeft, *_numAmmoRight;
@@ -198,7 +199,7 @@ class BattlescapeState : public State
198199
/// Checks if the mouse is over the icons.
199200
bool getMouseOverIcons() const;
200201
/// Is the player allowed to press buttons?
201-
bool allowButtons() const;
202+
bool allowButtons(bool allowSaving = false) const;
202203
/// Handler for clicking the reserve TUs to kneel button.
203204
void btnReserveKneelClick(Action *action);
204205
/// Handler for clicking the expend all TUs button.

‎src/Battlescape/InventoryState.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ InventoryState::InventoryState(Game *game, bool tu, BattlescapeState *parent) :
8080
_txtPSkill = new Text(40, 9, 245, 48);
8181
_txtPStr = new Text(40, 9, 245, 56);
8282
}
83-
_txtItem = new Text(140, 9, 128, 140);
83+
_txtItem = new Text(160, 9, 128, 140);
8484
_txtAmmo = new Text(66, 24, 254, 64);
8585
_btnOk = new InteractiveSurface(35, 22, 237, 1);
8686
_btnPrev = new InteractiveSurface(23, 22, 273, 1);
@@ -192,7 +192,7 @@ void InventoryState::init()
192192
// no selected unit, close inventory
193193
if (unit == 0)
194194
{
195-
_game->popState();
195+
btnOkClick(0);
196196
return;
197197
}
198198
// skip to the first unit with inventory

‎src/Engine/Sound.cpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ void Sound::load(const std::string &filename)
4949
_sound = Mix_LoadWAV(filename.c_str());
5050
if (_sound == 0)
5151
{
52-
std::string err;
53-
err = Mix_GetError() + std::string(":") + filename;
52+
std::string err = filename + ":" + Mix_GetError();
5453
throw Exception(err);
5554
}
5655
}

‎src/Engine/State.cpp‎

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -210,33 +210,16 @@ void State::centerAllSurfaces()
210210
{
211211
for (std::vector<Surface*>::iterator i = _surfaces.begin(); i != _surfaces.end(); ++i)
212212
{
213-
TextList *tl = dynamic_cast<TextList*>(*i);
214-
if (tl)
215-
{
216-
tl->setAllX((*i)->getX() + Screen::getDX());
217-
tl->setAllY((*i)->getY() + Screen::getDY());
218-
}
219-
else
220-
{
221-
(*i)->setX((*i)->getX() + Screen::getDX());
222-
(*i)->setY((*i)->getY() + Screen::getDY());
223-
}
213+
(*i)->setX((*i)->getX() + Screen::getDX());
214+
(*i)->setY((*i)->getY() + Screen::getDY());
224215
}
225216
}
226217

227218
void State::lowerAllSurfaces()
228219
{
229220
for (std::vector<Surface*>::iterator i = _surfaces.begin(); i != _surfaces.end(); ++i)
230221
{
231-
TextList *tl = dynamic_cast<TextList*>(*i);
232-
if (tl)
233-
{
234-
tl->setAllY((*i)->getY() + Screen::getDY() / 2);
235-
}
236-
else
237-
{
238-
(*i)->setY((*i)->getY() + Screen::getDY() / 2);
239-
}
222+
(*i)->setY((*i)->getY() + Screen::getDY() / 2);
240223
}
241224
}
242225

‎src/Engine/Surface.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ void Surface::loadImage(const std::string &filename)
266266
_surface = IMG_Load(utf8.c_str());
267267
if (!_surface)
268268
{
269-
throw Exception(IMG_GetError());
269+
std::string err = filename + ":" + IMG_GetError();
270+
throw Exception(err);
270271
}
271272
}
272273

‎src/Engine/Surface.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,11 @@ class Surface
100100
return _surface->format->palette->colors;
101101
}
102102
/// Sets the X position of the surface.
103-
void setX(int x);
103+
virtual void setX(int x);
104104
/// Gets the X position of the surface.
105105
int getX() const;
106106
/// Sets the Y position of the surface.
107-
void setY(int y);
107+
virtual void setY(int y);
108108
/// Gets the Y position of the surface.
109109
int getY() const;
110110
/// Sets the surface's visibility.

0 commit comments

Comments
 (0)