Skip to content

Commit

Permalink
- Minor fixes and cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
SupSuper committed Mar 6, 2011
1 parent 7fad20b commit 896a429
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ bin/USER/*.bmp
bin/USER/*.sav
deps/
docs/html/
obj/
*.o
Empty file added obj/.gitkeep
Empty file.
20 changes: 10 additions & 10 deletions src/Basescape/PurchaseState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace OpenXcom
* @param game Pointer to the core game.
* @param base Pointer to the base to get info from.
*/
PurchaseState::PurchaseState(Game *game, Base *base) : State(game), _base(base), _sel(0), _total(0), _pQty(0), _cQty(0), _iQty(0.0f)
PurchaseState::PurchaseState(Game *game, Base *base) : State(game), _base(base), _crafts(), _items(), _qtys(), _sel(0), _total(0), _pQty(0), _cQty(0), _iQty(0.0f)
{
// Create objects
_window = new Window(this, 320, 200, 0, 0);
Expand Down Expand Up @@ -119,6 +119,10 @@ PurchaseState::PurchaseState(Game *game, Base *base) : State(game), _base(base),
_lstItems->setSelectable(true);
_lstItems->setBackground(_window);
_lstItems->setMargin(2);
_lstItems->onLeftArrowPress((ActionHandler)&PurchaseState::lstItemsLeftArrowPress);
_lstItems->onLeftArrowRelease((ActionHandler)&PurchaseState::lstItemsLeftArrowRelease);
_lstItems->onRightArrowPress((ActionHandler)&PurchaseState::lstItemsRightArrowPress);
_lstItems->onRightArrowRelease((ActionHandler)&PurchaseState::lstItemsRightArrowRelease);

_crafts.push_back("STR_SKYRANGER");
_crafts.push_back("STR_INTERCEPTOR");
Expand Down Expand Up @@ -158,10 +162,6 @@ PurchaseState::PurchaseState(Game *game, Base *base) : State(game), _base(base),
_qtys.push_back(0);
_lstItems->addRow(3, _game->getLanguage()->getString(*i).c_str(), Text::formatFunding(_game->getRuleset()->getItem(*i)->getCost()).c_str(), L"0");
}
_lstItems->onLeftArrowPress((ActionHandler)&PurchaseState::lstItemsLeftArrowPress);
_lstItems->onLeftArrowRelease((ActionHandler)&PurchaseState::lstItemsLeftArrowRelease);
_lstItems->onRightArrowPress((ActionHandler)&PurchaseState::lstItemsRightArrowPress);
_lstItems->onRightArrowRelease((ActionHandler)&PurchaseState::lstItemsRightArrowRelease);

_timerInc = new Timer(50);
_timerInc->onTimer((StateHandler)&PurchaseState::increase);
Expand Down Expand Up @@ -318,7 +318,7 @@ int PurchaseState::getPrice()
}

/**
* Increases the quantity of the selected item on the list.
* Increases the quantity of the selected item to buy.
*/
void PurchaseState::increase()
{
Expand Down Expand Up @@ -369,7 +369,7 @@ void PurchaseState::increase()
}

/**
* Decreases the quantity of the selected item on the list.
* Decreases the quantity of the selected item to buy.
*/
void PurchaseState::decrease()
{
Expand All @@ -393,10 +393,10 @@ void PurchaseState::decrease()
_lstItems->getCell(_sel, 2)->setText(ss.str());
_lstItems->draw();
_total -= getPrice();
std::wstring s = _game->getLanguage()->getString("STR_COST_OF_PURCHASES");
s += Text::formatFunding(_total);
_txtPurchases->setText(s);
}
std::wstring s = _game->getLanguage()->getString("STR_COST_OF_PURCHASES");
s += Text::formatFunding(_total);
_txtPurchases->setText(s);
}

}
2 changes: 1 addition & 1 deletion src/Battlescape/BattlescapeState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ BattlescapeState::BattlescapeState(Game *game) : State(game)
_btnLeftHandItem->onMouseClick((ActionHandler)&BattlescapeState::btnLeftHandItemClick);
_btnRightHandItem->onMouseClick((ActionHandler)&BattlescapeState::btnRightHandItemClick);

_txtName->setColor(Palette::blockOffset(7));
_txtName->setColor(Palette::blockOffset(8)-1);
_txtName->setHighContrast(true);
_numTimeUnits->setColor(Palette::blockOffset(4));
_numEnergy->setColor(Palette::blockOffset(1));
Expand Down
20 changes: 11 additions & 9 deletions src/Geoscape/GeoscapeState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,15 +839,8 @@ void GeoscapeState::btnBasesClick(Action *action)
*/
void GeoscapeState::btnGraphsClick(Action *action)
{
_game->pushState(new GraphsState(_game));
}
//_game->pushState(new GraphsState(_game));

/**
* Goes to the Ufopaedia screen.
* @param action Pointer to an action.
*/
void GeoscapeState::btnUfopaediaClick(Action *action)
{
/* Daiky: uncomment this bit to start a terror mission */
_game->getSavedGame()->setBattleGame(new SavedBattleGame());
BattlescapeGenerator *bgen = new BattlescapeGenerator(_game);
Expand All @@ -858,8 +851,17 @@ void GeoscapeState::btnUfopaediaClick(Action *action)
bgen->setCraft(_game->getSavedGame()->getBases()->at(0)->getCrafts()->at(0));
bgen->run();
delete bgen;
_music = false;
_game->pushState(new BattlescapeState(_game));

}

/**
* Goes to the Ufopaedia window.
* @param action Pointer to an action.
*/
void GeoscapeState::btnUfopaediaClick(Action *action)
{

}

/**
Expand Down
15 changes: 14 additions & 1 deletion src/Interface/TextList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ namespace OpenXcom
* @param x X position in pixels.
* @param y Y position in pixels.
*/
TextList::TextList(int width, int height, int x, int y) : InteractiveSurface(width, height, x, y), _texts(), _columns(), _big(0), _small(0), _scroll(0), _visibleRows(0), _color(0), _align(ALIGN_LEFT), _dot(false), _selectable(false), _selRow(0), _bg(0), _selector(0), _margin(0), _arrowLeft(), _arrowRight(), _arrowPos(-1)
TextList::TextList(int width, int height, int x, int y) : InteractiveSurface(width, height, x, y), _texts(), _columns(), _big(0), _small(0), _scroll(0), _visibleRows(0), _color(0), _align(ALIGN_LEFT), _dot(false), _selectable(false), _selRow(0), _bg(0), _selector(0), _margin(0),
_arrowLeft(), _arrowRight(), _arrowPos(-1), _leftClick(0), _leftPress(0), _leftRelease(0), _rightClick(0), _rightPress(0), _rightRelease(0)
{
_up = new ArrowButton(ARROW_BIG_UP, 13, 14, getX() + getWidth() + 4, getY() + 1);
_up->setVisible(false);
Expand Down Expand Up @@ -155,10 +156,16 @@ void TextList::addRow(int cols, ...)
ArrowButton *a1 = new ArrowButton(ARROW_SMALL_UP, 11, 8, getX() + _arrowPos, getY());
a1->setPalette(this->getPalette());
a1->setColor(_up->getColor());
a1->onMouseClick(_leftClick);
a1->onMousePress(_leftPress);
a1->onMouseRelease(_leftRelease);
_arrowLeft.push_back(a1);
ArrowButton *a2 = new ArrowButton(ARROW_SMALL_DOWN, 11, 8, getX() + _arrowPos + 12, getY());
a2->setPalette(this->getPalette());
a2->setColor(_up->getColor());
a2->onMouseClick(_rightClick);
a2->onMousePress(_rightPress);
a2->onMouseRelease(_rightRelease);
_arrowRight.push_back(a2);
}

Expand Down Expand Up @@ -345,6 +352,7 @@ void TextList::setArrowColumn(int pos)
*/
void TextList::onLeftArrowClick(ActionHandler handler)
{
_leftClick = handler;
for (std::vector<ArrowButton*>::iterator i = _arrowLeft.begin(); i < _arrowLeft.end(); i++)
{
(*i)->onMouseClick(handler);
Expand All @@ -357,6 +365,7 @@ void TextList::onLeftArrowClick(ActionHandler handler)
*/
void TextList::onLeftArrowPress(ActionHandler handler)
{
_leftPress = handler;
for (std::vector<ArrowButton*>::iterator i = _arrowLeft.begin(); i < _arrowLeft.end(); i++)
{
(*i)->onMousePress(handler);
Expand All @@ -369,6 +378,7 @@ void TextList::onLeftArrowPress(ActionHandler handler)
*/
void TextList::onLeftArrowRelease(ActionHandler handler)
{
_leftRelease = handler;
for (std::vector<ArrowButton*>::iterator i = _arrowLeft.begin(); i < _arrowLeft.end(); i++)
{
(*i)->onMouseRelease(handler);
Expand All @@ -381,6 +391,7 @@ void TextList::onLeftArrowRelease(ActionHandler handler)
*/
void TextList::onRightArrowClick(ActionHandler handler)
{
_rightClick = handler;
for (std::vector<ArrowButton*>::iterator i = _arrowRight.begin(); i < _arrowRight.end(); i++)
{
(*i)->onMouseClick(handler);
Expand All @@ -393,6 +404,7 @@ void TextList::onRightArrowClick(ActionHandler handler)
*/
void TextList::onRightArrowPress(ActionHandler handler)
{
_rightPress = handler;
for (std::vector<ArrowButton*>::iterator i = _arrowRight.begin(); i < _arrowRight.end(); i++)
{
(*i)->onMousePress(handler);
Expand All @@ -405,6 +417,7 @@ void TextList::onRightArrowPress(ActionHandler handler)
*/
void TextList::onRightArrowRelease(ActionHandler handler)
{
_rightRelease = handler;
for (std::vector<ArrowButton*>::iterator i = _arrowRight.begin(); i < _arrowRight.end(); i++)
{
(*i)->onMouseRelease(handler);
Expand Down
1 change: 1 addition & 0 deletions src/Interface/TextList.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class TextList : public InteractiveSurface
int _margin;
std::vector<ArrowButton*> _arrowLeft, _arrowRight;
int _arrowPos;
ActionHandler _leftClick, _leftPress, _leftRelease, _rightClick, _rightPress, _rightRelease;

/// Updates the arrow buttons.
void updateArrows();
Expand Down
58 changes: 49 additions & 9 deletions src/OpenXcom.2008.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -611,14 +611,6 @@
<Filter
Name="Battlescape"
>
<File
RelativePath=".\Battlescape\BattleAction.cpp"
>
</File>
<File
RelativePath=".\Battlescape\BattleAction.h"
>
</File>
<File
RelativePath=".\Battlescape\BattlescapeGenerator.cpp"
>
Expand All @@ -634,7 +626,15 @@
<File
RelativePath=".\Battlescape\BattlescapeState.h"
>
</File>
</File>
<File
RelativePath=".\Battlescape\BattleState.cpp"
>
</File>
<File
RelativePath=".\Battlescape\BattleState.h"
>
</File>
<File
RelativePath=".\Battlescape\BriefingCrashState.cpp"
>
Expand All @@ -651,6 +651,22 @@
RelativePath=".\Battlescape\BulletSprite.h"
>
</File>
<File
RelativePath=".\Battlescape\Explosion.cpp"
>
</File>
<File
RelativePath=".\Battlescape\Explosion.h"
>
</File>
<File
RelativePath=".\Battlescape\ExplosionBState.cpp"
>
</File>
<File
RelativePath=".\Battlescape\ExplosionBState.h"
>
</File>
<File
RelativePath=".\Battlescape\Map.cpp"
>
Expand Down Expand Up @@ -691,6 +707,14 @@
RelativePath=".\Battlescape\Projectile.h"
>
</File>
<File
RelativePath=".\Battlescape\ProjectiveFlyBState.cpp"
>
</File>
<File
RelativePath=".\Battlescape\ProjectileFlyBState.h"
>
</File>
<File
RelativePath=".\Battlescape\TerrainModifier.cpp"
>
Expand All @@ -707,6 +731,22 @@
RelativePath=".\Battlescape\UnitSprite.h"
>
</File>
<File
RelativePath=".\Battlescape\UnitTurnBState.cpp"
>
</File>
<File
RelativePath=".\Battlescape\UnitTurnBState.h"
>
</File>
<File
RelativePath=".\Battlescape\UnitWalkBState.cpp"
>
</File>
<File
RelativePath=".\Battlescape\UnitWalkBState.h"
>
</File>
</Filter>
<Filter
Name="Geoscape"
Expand Down
2 changes: 1 addition & 1 deletion src/OpenXcom.cbp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
<Unit filename="Basescape\StoresState.cpp" />
<Unit filename="Basescape\StoresState.h" />
<Unit filename="Basescape\TransfersState.cpp" />
<Unit filename="Battlescape\BattleState.cpp" />
<Unit filename="Basescape\TransfersState.h" />
<Unit filename="Battlescape\BattleState.cpp" />
<Unit filename="Battlescape\BattleState.h" />
<Unit filename="Battlescape\BattlescapeGenerator.cpp" />
<Unit filename="Battlescape\BattlescapeGenerator.h" />
Expand Down

0 comments on commit 896a429

Please sign in to comment.