5757#include " ../Interface/Text.h"
5858#include " ../Interface/Bar.h"
5959#include " ../Interface/ImageButton.h"
60+ #include " ../Interface/BattlescapeButton.h"
6061#include " ../Interface/NumberText.h"
6162#include " ../Savegame/SavedGame.h"
6263#include " ../Savegame/SavedBattleGame.h"
@@ -117,27 +118,27 @@ BattlescapeState::BattlescapeState() : _reserve(0), _popups(), _xBeforeMouseScro
117118 _rank = new Surface (26 , 23 , x + 107 , y + 33 );
118119
119120 // Create buttons
120- _btnUnitUp = new InteractiveSurface (32 , 16 , x + 48 , y);
121- _btnUnitDown = new InteractiveSurface (32 , 16 , x + 48 , y + 16 );
122- _btnMapUp = new InteractiveSurface (32 , 16 , x + 80 , y);
123- _btnMapDown = new InteractiveSurface (32 , 16 , x + 80 , y + 16 );
124- _btnShowMap = new InteractiveSurface (32 , 16 , x + 112 , y);
125- _btnKneel = new InteractiveSurface (32 , 16 , x + 112 , y + 16 );
126- _btnInventory = new InteractiveSurface (32 , 16 , x + 144 , y);
127- _btnCenter = new InteractiveSurface (32 , 16 , x + 144 , y + 16 );
128- _btnNextSoldier = new InteractiveSurface (32 , 16 , x + 176 , y);
129- _btnNextStop = new InteractiveSurface (32 , 16 , x + 176 , y + 16 );
130- _btnShowLayers = new InteractiveSurface (32 , 16 , x + 208 , y);
131- _btnHelp = new InteractiveSurface (32 , 16 , x + 208 , y + 16 );
132- _btnEndTurn = new InteractiveSurface (32 , 16 , x + 240 , y);
133- _btnAbort = new InteractiveSurface (32 , 16 , x + 240 , y + 16 );
121+ _btnUnitUp = new BattlescapeButton (32 , 16 , x + 48 , y);
122+ _btnUnitDown = new BattlescapeButton (32 , 16 , x + 48 , y + 16 );
123+ _btnMapUp = new BattlescapeButton (32 , 16 , x + 80 , y);
124+ _btnMapDown = new BattlescapeButton (32 , 16 , x + 80 , y + 16 );
125+ _btnShowMap = new BattlescapeButton (32 , 16 , x + 112 , y);
126+ _btnKneel = new BattlescapeButton (32 , 16 , x + 112 , y + 16 );
127+ _btnInventory = new BattlescapeButton (32 , 16 , x + 144 , y);
128+ _btnCenter = new BattlescapeButton (32 , 16 , x + 144 , y + 16 );
129+ _btnNextSoldier = new BattlescapeButton (32 , 16 , x + 176 , y);
130+ _btnNextStop = new BattlescapeButton (32 , 16 , x + 176 , y + 16 );
131+ _btnShowLayers = new BattlescapeButton (32 , 16 , x + 208 , y);
132+ _btnHelp = new BattlescapeButton (32 , 16 , x + 208 , y + 16 );
133+ _btnEndTurn = new BattlescapeButton (32 , 16 , x + 240 , y);
134+ _btnAbort = new BattlescapeButton (32 , 16 , x + 240 , y + 16 );
134135 _btnStats = new InteractiveSurface (164 , 23 , x + 107 , y + 33 );
135- _btnReserveNone = new ImageButton (17 , 11 , x + 60 , y + 33 );
136- _btnReserveSnap = new ImageButton (17 , 11 , x + 78 , y + 33 );
137- _btnReserveAimed = new ImageButton (17 , 11 , x + 60 , y + 45 );
138- _btnReserveAuto = new ImageButton (17 , 11 , x + 78 , y + 45 );
139- _btnReserveKneel = new ImageButton (10 , 23 , x + 96 , y + 33 );
140- _btnZeroTUs = new ImageButton (10 , 23 , x + 49 , y + 33 );
136+ _btnReserveNone = new BattlescapeButton (17 , 11 , x + 60 , y + 33 );
137+ _btnReserveSnap = new BattlescapeButton (17 , 11 , x + 78 , y + 33 );
138+ _btnReserveAimed = new BattlescapeButton (17 , 11 , x + 60 , y + 45 );
139+ _btnReserveAuto = new BattlescapeButton (17 , 11 , x + 78 , y + 45 );
140+ _btnReserveKneel = new BattlescapeButton (10 , 23 , x + 96 , y + 33 );
141+ _btnZeroTUs = new BattlescapeButton (10 , 23 , x + 49 , y + 33 );
141142 _btnLeftHandItem = new InteractiveSurface (32 , 48 , x + 8 , y + 5 );
142143 _numAmmoLeft = new NumberText (30 , 5 , x + 8 , y + 4 );
143144 _btnRightHandItem = new InteractiveSurface (32 , 48 , x + 280 , y + 5 );
@@ -151,9 +152,9 @@ BattlescapeState::BattlescapeState() : _reserve(0), _popups(), _xBeforeMouseScro
151152 }
152153 _numVisibleUnit[9 ]->setX (_numVisibleUnit[9 ]->getX () - 2 ); // center number 10
153154 _warning = new WarningMessage (224 , 24 , x + 48 , y + 32 );
154- _btnLaunch = new InteractiveSurface (32 , 24 , screenWidth - 32 , 0 ); // we need screenWidth, because that is independent of the black bars on the screen
155+ _btnLaunch = new BattlescapeButton (32 , 24 , screenWidth - 32 , 0 ); // we need screenWidth, because that is independent of the black bars on the screen
155156 _btnLaunch->setVisible (false );
156- _btnPsi = new InteractiveSurface (32 , 24 , screenWidth - 32 , 25 ); // we need screenWidth, because that is independent of the black bars on the screen
157+ _btnPsi = new BattlescapeButton (32 , 24 , screenWidth - 32 , 25 ); // we need screenWidth, because that is independent of the black bars on the screen
157158 _btnPsi->setVisible (false );
158159
159160 // Create soldier stats summary
@@ -183,7 +184,32 @@ BattlescapeState::BattlescapeState() : _reserve(0), _popups(), _xBeforeMouseScro
183184
184185 add (_map);
185186 add (_icons);
186- add (_numLayers, " numLayers" , " battlescape" , _icons);
187+
188+ // Add in custom reserve buttons
189+ Surface *icons = _game->getResourcePack ()->getSurface (" ICONS.PCK" );
190+ if (_game->getResourcePack ()->getSurface (" TFTDReserve" ))
191+ {
192+ Surface *tftdIcons = _game->getResourcePack ()->getSurface (" TFTDReserve" );
193+ tftdIcons->setX (48 );
194+ tftdIcons->setY (176 );
195+ tftdIcons->blit (icons);
196+ }
197+
198+ // there is some cropping going on here, because the icons image is 320x200 while we only need the bottom of it.
199+ SDL_Rect *r = icons->getCrop ();
200+ r->x = 0 ;
201+ r->y = 200 - iconsHeight;
202+ r->w = iconsWidth;
203+ r->h = iconsHeight;
204+ // we need to blit the icons before we add the battlescape buttons, as they copy the underlying parent surface.
205+ icons->blit (_icons);
206+
207+ // this is a hack to fix the single transparent pixel on TFTD's icon panel.
208+ if (_game->getRuleset ()->getInterface (" battlescape" )->getElement (" icons" )->TFTDMode )
209+ {
210+ _icons->setPixel (46 , 44 , 8 );
211+ }
212+
187213 add (_rank, " rank" , " battlescape" , _icons);
188214 add (_btnUnitUp, " buttonUnitUp" , " battlescape" , _icons);
189215 add (_btnUnitDown, " buttonUnitDown" , " battlescape" , _icons);
@@ -196,6 +222,7 @@ BattlescapeState::BattlescapeState() : _reserve(0), _popups(), _xBeforeMouseScro
196222 add (_btnNextSoldier, " buttonNextSoldier" , " battlescape" , _icons);
197223 add (_btnNextStop, " buttonNextStop" , " battlescape" , _icons);
198224 add (_btnShowLayers, " buttonShowLayers" , " battlescape" , _icons);
225+ add (_numLayers, " numLayers" , " battlescape" , _icons);
199226 add (_btnHelp, " buttonHelp" , " battlescape" , _icons);
200227 add (_btnEndTurn, " buttonEndTurn" , " battlescape" , _icons);
201228 add (_btnAbort, " buttonAbort" , " battlescape" , _icons);
@@ -240,24 +267,6 @@ BattlescapeState::BattlescapeState() : _reserve(0), _popups(), _xBeforeMouseScro
240267 _map->onMouseClick ((ActionHandler)&BattlescapeState::mapClick, 0 );
241268 _map->onMouseIn ((ActionHandler)&BattlescapeState::mapIn);
242269
243- // Add in custom reserve buttons
244- Surface *icons = _game->getResourcePack ()->getSurface (" ICONS.PCK" );
245- if (_game->getResourcePack ()->getSurface (" TFTDReserve" ))
246- {
247- Surface *tftdIcons = _game->getResourcePack ()->getSurface (" TFTDReserve" );
248- tftdIcons->setX (48 );
249- tftdIcons->setY (176 );
250- tftdIcons->blit (icons);
251- }
252-
253- // there is some cropping going on here, because the icons image is 320x200 while we only need the bottom of it.
254- SDL_Rect *r = icons->getCrop ();
255- r->x = 0 ;
256- r->y = 200 - iconsHeight;
257- r->w = iconsWidth;
258- r->h = iconsHeight;
259- icons->blit (_icons);
260-
261270 _numLayers->setColor (Palette::blockOffset (1 )-2 );
262271 _numLayers->setValue (1 );
263272
@@ -397,12 +406,14 @@ BattlescapeState::BattlescapeState() : _reserve(0), _popups(), _xBeforeMouseScro
397406 _btnReserveKneel->setTooltip (" STR_RESERVE_TIME_UNITS_FOR_KNEEL" );
398407 _btnReserveKneel->onMouseIn ((ActionHandler)&BattlescapeState::txtTooltipIn);
399408 _btnReserveKneel->onMouseOut ((ActionHandler)&BattlescapeState::txtTooltipOut);
409+ _btnReserveKneel->allowToggleInversion ();
400410
401411 _btnZeroTUs->onMouseClick ((ActionHandler)&BattlescapeState::btnZeroTUsClick, SDL_BUTTON_RIGHT );
402412 _btnZeroTUs->onKeyboardPress ((ActionHandler)&BattlescapeState::btnZeroTUsClick, Options::keyBattleZeroTUs);
403413 _btnZeroTUs->setTooltip (" STR_EXPEND_ALL_TIME_UNITS" );
404414 _btnZeroTUs->onMouseIn ((ActionHandler)&BattlescapeState::txtTooltipIn);
405415 _btnZeroTUs->onMouseOut ((ActionHandler)&BattlescapeState::txtTooltipOut);
416+ _btnZeroTUs->allowClickInversion ();
406417
407418 // shortcuts without a specific button
408419 _btnStats->onKeyboardPress ((ActionHandler)&BattlescapeState::btnReloadClick, Options::keyBattleReload);
@@ -448,28 +459,11 @@ BattlescapeState::BattlescapeState() : _reserve(0), _popups(), _xBeforeMouseScro
448459
449460 _txtTooltip->setHighContrast (true );
450461
451- _btnReserveNone->copy (_icons);
452- _btnReserveNone->setColor (Palette::blockOffset (4 )+3 );
453462 _btnReserveNone->setGroup (&_reserve);
454-
455- _btnReserveSnap->copy (_icons);
456- _btnReserveSnap->setColor (Palette::blockOffset (2 )+3 );
457463 _btnReserveSnap->setGroup (&_reserve);
458-
459- _btnReserveAimed->copy (_icons);
460- _btnReserveAimed->setColor (Palette::blockOffset (2 )+3 );
461464 _btnReserveAimed->setGroup (&_reserve);
462-
463- _btnReserveAuto->copy (_icons);
464- _btnReserveAuto->setColor (Palette::blockOffset (2 )+3 );
465465 _btnReserveAuto->setGroup (&_reserve);
466-
467- _btnReserveKneel->copy (_icons);
468- _btnReserveKneel->setColor (Palette::blockOffset (2 )+3 );
469-
470- _btnZeroTUs->copy (_icons);
471- _btnZeroTUs->setColor (Palette::blockOffset (2 )+3 );
472-
466+
473467 // Set music
474468 _game->getResourcePack ()->playMusic (" GMTACTIC" );
475469
0 commit comments