Skip to content

Commit fe375ef

Browse files
committed
interface improvement; return back some code.
1 parent b489c1d commit fe375ef

5 files changed

Lines changed: 18 additions & 15 deletions

File tree

‎src/Basescape/SoldierInfoState.cpp‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424
#include "../Engine/Language.h"
2525
#include "../Engine/Options.h"
2626
#include "../Engine/Palette.h"
27-
#include "../Geoscape/PsiTrainingState.h"
27+
#include "../Geoscape/AllocatePsiTrainingState.h"
2828
#include "../Interface/Bar.h"
2929
#include "../Interface/TextButton.h"
3030
#include "../Interface/Text.h"
3131
#include "../Interface/TextEdit.h"
32+
#include "../Interface/ToggleTextButton.h"
3233
#include "../Engine/Surface.h"
3334
#include "../Savegame/Base.h"
3435
#include "../Savegame/Craft.h"
@@ -64,7 +65,7 @@ SoldierInfoState::SoldierInfoState(Game *game, Base *base, size_t soldier) : Sta
6465
_txtCraft = new Text(130, 9, 0, 56);
6566
_txtRecovery = new Text(180, 9, 130, 56);
6667
_txtPsionic = new Text(140, 9, 0, 66);
67-
_btnPsionic = new TextButton(46, 24, 274, 33);
68+
_btnPsionic = new ToggleTextButton(140, 14, 0, 65);
6869

6970
_txtTimeUnits = new Text(120, 9, 6, 82);
7071
_numTimeUnits = new Text(18, 9, 131, 82);
@@ -206,7 +207,7 @@ SoldierInfoState::SoldierInfoState(Game *game, Base *base, size_t soldier) : Sta
206207
_txtPsionic->setText(_game->getLanguage()->getString("STR_IN_PSIONIC_TRAINING"));
207208

208209
_btnPsionic->setColor(Palette::blockOffset(15)+6);
209-
_btnPsionic->setText(_game->getLanguage()->getString("STR_IN_TRAINING"));
210+
_btnPsionic->setText(_game->getLanguage()->getString("STR_IN_PSIONIC_TRAINING"));
210211
_btnPsionic->onMouseClick((ActionHandler)&SoldierInfoState::btnPsionicClick);
211212

212213

@@ -444,8 +445,9 @@ void SoldierInfoState::init()
444445
_txtRecovery->setText(L"");
445446
}
446447

447-
_txtPsionic->setVisible(s->isInPsiTraining());
448-
_btnPsionic->setVisible(Options::getBool("quickPsiTraining") && _base->getAvailablePsiLabs() > 0 && !(s->isInPsiTraining()));
448+
_txtPsionic->setVisible(!Options::getBool("quickPsiTraining") && s->isInPsiTraining());
449+
_btnPsionic->setVisible( Options::getBool("quickPsiTraining") && _base->getAvailablePsiLabs() > 0);
450+
_btnPsionic->setPressed(s->isInPsiTraining());
449451

450452
if(current->psiSkill > 0)
451453
{
@@ -549,7 +551,10 @@ void SoldierInfoState::btnArmorClick(Action *)
549551
*/
550552
void SoldierInfoState::btnPsionicClick(Action *)
551553
{
552-
_game->pushState(new PsiTrainingState(_game, "PALETTES.DAT_1"));
554+
if (_btnPsionic->getPressed())
555+
_game->pushState(new AllocatePsiTrainingState(_game, _base));
556+
else
557+
_base->getSoldiers()->at(_soldier)->setPsiTraining();
553558
}
554559

555560
}

‎src/Basescape/SoldierInfoState.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Surface;
2929
class TextButton;
3030
class Text;
3131
class TextEdit;
32+
class ToggleTextButton;
3233
class Bar;
3334

3435
/**
@@ -42,7 +43,8 @@ class SoldierInfoState : public State
4243
size_t _soldier;
4344

4445
Surface *_bg, *_rank;
45-
TextButton *_btnOk, *_btnPrev, *_btnNext, *_btnArmor, *_btnPsionic;
46+
TextButton *_btnOk, *_btnPrev, *_btnNext, *_btnArmor;
47+
ToggleTextButton *_btnPsionic;
4648
Text *_txtArmor, *_txtRank, *_txtMissions, *_txtKills, *_txtCraft, *_txtRecovery, *_txtPsionic;
4749
TextEdit *_edtSoldier;
4850

‎src/Geoscape/MonthlyReportState.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ void MonthlyReportState::btnOkClick(Action *)
343343
{
344344
_game->popState();
345345
if (_psi)
346-
_game->pushState (new PsiTrainingState(_game, "PALETTES.DAT_0"));
346+
_game->pushState (new PsiTrainingState(_game));
347347
}
348348
else
349349
{

‎src/Geoscape/PsiTrainingState.cpp‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,9 @@ namespace OpenXcom
3737
/**
3838
* Initializes all the elements in the Psi Training screen.
3939
* @param game Pointer to the core game.
40-
* @param paletteName - name of restoring palette
4140
*/
42-
PsiTrainingState::PsiTrainingState(Game *game, const std::string & paletteName) : State(game), _base1(0), _base2(0), _base3(0), _base4(0), _base5(0), _base6(0), _base7(0), _base8(0)
41+
PsiTrainingState::PsiTrainingState(Game *game) : State(game), _base1(0), _base2(0), _base3(0), _base4(0), _base5(0), _base6(0), _base7(0), _base8(0)
4342
{
44-
_restoreColors = _game->getResourcePack()->getPalette(paletteName)->getColors();
45-
4643
// Create objects
4744
_window = new Window(this, 320, 200, 0, 0);
4845
_txtTitle = new Text(300, 16, 10, 16);
@@ -169,7 +166,7 @@ void PsiTrainingState::init()
169166
void PsiTrainingState::btnOkClick(Action *)
170167
{
171168
_game->popState();
172-
_game->setPalette(_restoreColors);
169+
_game->setPalette(_game->getResourcePack()->getPalette("PALETTES.DAT_0")->getColors());
173170
}
174171

175172
void PsiTrainingState::btnBase1Click(Action *)

‎src/Geoscape/PsiTrainingState.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ class PsiTrainingState : public State
4141
Window *_window;
4242
Text *_txtTitle;
4343
Base *_base1, *_base2, *_base3, *_base4, *_base5, *_base6, *_base7, *_base8;
44-
SDL_Color *_restoreColors;
4544
public:
4645
/// Creates the Psi Training state.
47-
PsiTrainingState(Game *game, const std::string & paletteName);
46+
PsiTrainingState(Game *game);
4847
/// Cleans up the Psi Training state.
4948
~PsiTrainingState();
5049
/// Updates the palette.

0 commit comments

Comments
 (0)