diff --git a/src/Basescape/BasescapeState.cpp b/src/Basescape/BasescapeState.cpp
index 76738cd..3988e12 100644
--- a/src/Basescape/BasescapeState.cpp
+++ b/src/Basescape/BasescapeState.cpp
@@ -68,7 +68,13 @@ BasescapeState::BasescapeState(Base *base, Globe *globe) : _base(base), _globe(g
https:// Create objects
_txtFacility = new Text(192, 9, 0, 0);
_view = new BaseView(192, 192, 0,
;
+ if ( _game->getSavedGame()->getBases()->size() > MiniBaseView::ROW_BASES) {
+ _mini = new MiniBaseView(128, 32, 192, 38);
+ }
+ else
+ {
_mini = new MiniBaseView(128, 16, 192, 41);
+ }
_edtBase = new TextEdit(this, 127, 17, 193, 0);
_txtLocation = new Text(126, 9, 194, 16);
_txtFunds = new Text(126, 9, 194, 24);
@@ -203,8 +209,7 @@ void BasescapeState::init()
}
_txtFunds->setText(tr("STR_FUNDS").arg(Text::formatFunding(_game->getSavedGame()->getFunds())));
-
- _btnNewBase->setVisible(_game->getSavedGame()->getBases()->size() < MiniBaseView::MAX_BASES);
+ _btnNewBase->setVisible(_game->getSavedGame()->getBases()->size() <= MiniBaseView::ROW_BASES);
}
/**
@@ -480,7 +485,7 @@ void BasescapeState::viewMouseOut(Action *)
* Selects a new base to display.
* @param action Pointer to an action.
*/
-void BasescapeState::miniLeftClick(Action *)
+void BasescapeState::miniLeftClick(Action *unused)
{
size_t base = _mini->getHoveredBase();
if (base < _game->getSavedGame()->getBases()->size())
@@ -488,13 +493,17 @@ void BasescapeState::miniLeftClick(Action *)
_base = _game->getSavedGame()->getBases()->at(base);
init();
}
+ else
+ {
+ btnNewBaseClick(unused);
+ }
}
/**
* Opens a dialog to make the selected base your HQ.
* @param action Pointer to an action.
*/
-void BasescapeState::miniRightClick(Action *)
+void BasescapeState::miniRightClick(Action *unused)
{
size_t baseIndex = _mini->getHoveredBase();
@@ -510,6 +519,10 @@ void BasescapeState::miniRightClick(Action *)
_game->pushState(new ChangeHeadquartersState(_game->getSavedGame()->getBases()->at(baseIndex)));
}
}
+ else
+ {
+ btnNewBaseClick(unused);
+ }
}
/**
diff --git a/src/Basescape/MiniBaseView.cpp b/src/Basescape/MiniBaseView.cpp
index 0ab1e4a..973197b 100644
--- a/src/Basescape/MiniBaseView.cpp
+++ b/src/Basescape/MiniBaseView.cpp
@@ -94,18 +94,20 @@ void MiniBaseView::draw()
Surface::draw();
for (size_t i = 0; i < MAX_BASES; ++i)
{
+ int cell_x = (i % ROW_BASES) * (MINI_SIZE + 2);
+ int cell_y = (i / ROW_BASES) * (MINI_SIZE + 2);
https:// Draw base squares
if (i == _base)
{
SDL_Rect r;
- r.x = i * (MINI_SIZE + 2);
- r.y = 0;
+ r.x = cell_x;
+ r.y = cell_y;
r.w = MINI_SIZE + 2;
r.h = MINI_SIZE + 2;
drawRect(&r, 1);
}
- _texture->getFrame(41)->setX(i * (MINI_SIZE + 2));
- _texture->getFrame(41)->setY(0);
+ _texture->getFrame(41)->setX(cell_x);
+ _texture->getFrame(41)->setY(cell_y);
_texture->getFrame(41)->blit(this);
https:// Draw facilities
@@ -121,8 +123,8 @@ void MiniBaseView::draw()
else
color = _red;
- r.x = i * (MINI_SIZE + 2) + 2 + (*f)->getX() * 2;
- r.y = 2 + (*f)->getY() * 2;
+ r.x = cell_x + 2 + (*f)->getX() * 2;
+ r.y = cell_y + 2 + (*f)->getY() * 2;
r.w = (*f)->getRules()->getSize() * 2;
r.h = (*f)->getRules()->getSize() * 2;
drawRect(&r, color+3);
@@ -156,6 +158,7 @@ void MiniBaseView::draw()
void MiniBaseView::mouseOver(Action *action, State *state)
{
_hoverBase = (int)floor(action->getRelativeXMouse() / ((MINI_SIZE + 2) * action->getXScale()));
+ _hoverBase += (int)floor(action->getRelativeYMouse() / ((MINI_SIZE + 2) * action->getYScale())) * ROW_BASES;
InteractiveSurface::mouseOver(action, state);
}
diff --git a/src/Basescape/MiniBaseView.h b/src/Basescape/MiniBaseView.h
index 9168634..0bef494 100644
--- a/src/Basescape/MiniBaseView.h
+++ b/src/Basescape/MiniBaseView.h
@@ -43,7 +43,8 @@ private:
size_t _base, _hoverBase;
Uint8 _red, _green;
public:
- static const size_t MAX_BASES = 8;
+ static const size_t MAX_BASES = 16;
+ static const size_t ROW_BASES = 8;
https:/// Creates a new mini base view at the specified position and size.
MiniBaseView(int width, int height, int x = 0, int y = 0);
https:/// Cleans up the mini base view.