Skip to content

Commit ca6fc2a

Browse files
committed
Try to pad out Geoscape when using higher resolution.
1 parent 0015104 commit ca6fc2a

3 files changed

Lines changed: 67 additions & 17 deletions

File tree

src/Geoscape/GeoscapeState.cpp

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,12 @@ GeoscapeState::GeoscapeState(Game *game) : State(game), _pause(false), _zoomInEf
121121
int screenHeight = Options::baseYGeoscape;
122122

123123
// Create objects
124-
_bg = new Surface(320, 200, screenWidth-320, screenHeight/2-100);
124+
Surface *hd = _game->getResourcePack()->getSurface("ALTGEOBORD.SCR");
125+
_bg = new Surface(hd->getWidth(), hd->getHeight(), 0, 0);
126+
_sidebar = new Surface(64, 200, screenWidth - 64, screenHeight / 2 - 100);
125127
_globe = new Globe(_game, (screenWidth-64)/2, screenHeight/2, screenWidth-64, screenHeight, 0, 0);
128+
_bg->setX((_globe->getWidth() - _bg->getWidth()) / 2);
129+
_bg->setY((_globe->getHeight() - _bg->getHeight()) / 2);
126130

127131
_btnIntercept = new TextButton(63, 11, screenWidth-63, screenHeight/2-100);
128132
_btnBases = new TextButton(63, 11, screenWidth-63, screenHeight/2-88);
@@ -145,6 +149,10 @@ GeoscapeState::GeoscapeState(Game *game) : State(game), _pause(false), _zoomInEf
145149
_btnZoomIn = new InteractiveSurface(23, 23, screenWidth-25, screenHeight/2+56);
146150
_btnZoomOut = new InteractiveSurface(13, 17, screenWidth-20, screenHeight/2+82);
147151

152+
int height = (screenHeight - Screen::ORIGINAL_HEIGHT) / 2 + 10;
153+
_btnTop = new TextButton(63, height, screenWidth-63, _sidebar->getY() - height - 1);
154+
_btnBottom = new TextButton(63, height, screenWidth-63, _sidebar->getY() + _sidebar->getHeight() + 1);
155+
148156
_txtHour = new Text(20, 16, screenWidth-61, screenHeight/2-26);
149157
_txtHourSep = new Text(4, 16, screenWidth-41, screenHeight/2-26);
150158
_txtMin = new Text(20, 16, screenWidth-37, screenHeight/2-26);
@@ -157,7 +165,7 @@ GeoscapeState::GeoscapeState(Game *game) : State(game), _pause(false), _zoomInEf
157165
_txtFunds = new Text(59, 8, screenWidth-61, screenHeight/2-27);
158166

159167
_timeSpeed = _btn5Secs;
160-
_timer = new Timer(Options::geoClockSpeed);
168+
_gameTimer = new Timer(Options::geoClockSpeed);
161169

162170
_zoomInEffectTimer = new Timer(50);
163171
_zoomOutEffectTimer = new Timer(50);
@@ -173,6 +181,7 @@ GeoscapeState::GeoscapeState(Game *game) : State(game), _pause(false), _zoomInEf
173181
_game->getFpsCounter()->setColor(Palette::blockOffset(15)+12);
174182

175183
add(_bg);
184+
add(_sidebar);
176185
add(_globe);
177186

178187
add(_btnIntercept);
@@ -196,6 +205,9 @@ GeoscapeState::GeoscapeState(Game *game) : State(game), _pause(false), _zoomInEf
196205
add(_btnZoomIn);
197206
add(_btnZoomOut);
198207

208+
add(_btnTop);
209+
add(_btnBottom);
210+
199211
add(_txtFunds);
200212
add(_txtHour);
201213
add(_txtHourSep);
@@ -210,7 +222,11 @@ GeoscapeState::GeoscapeState(Game *game) : State(game), _pause(false), _zoomInEf
210222
add(_txtDebug);
211223

212224
// Set up objects
213-
_game->getResourcePack()->getSurface("GEOBORD.SCR")->blit(_bg);
225+
Surface *geobord = _game->getResourcePack()->getSurface("GEOBORD.SCR");
226+
geobord->setX(_sidebar->getX() - geobord->getWidth() + _sidebar->getWidth());
227+
geobord->setY(_sidebar->getY());
228+
_sidebar->copy(geobord);
229+
_game->getResourcePack()->getSurface("ALTGEOBORD.SCR")->blit(_bg);
214230

215231
_btnIntercept->initText(_game->getResourcePack()->getFont("FONT_GEO_BIG"), _game->getResourcePack()->getFont("FONT_GEO_SMALL"), _game->getLanguage());
216232
_btnIntercept->setColor(Palette::blockOffset(15)+6);
@@ -329,6 +345,9 @@ GeoscapeState::GeoscapeState(Game *game) : State(game), _pause(false), _zoomInEf
329345
_btnZoomOut->onMouseClick((ActionHandler)&GeoscapeState::btnZoomOutLeftClick, SDL_BUTTON_LEFT);
330346
_btnZoomOut->onMouseClick((ActionHandler)&GeoscapeState::btnZoomOutRightClick, SDL_BUTTON_RIGHT);
331347
_btnZoomOut->onKeyboardPress((ActionHandler)&GeoscapeState::btnZoomOutLeftClick, Options::keyGeoZoomOut);
348+
349+
_btnTop->setColor(Palette::blockOffset(15)+6);
350+
_btnBottom->setColor(Palette::blockOffset(15)+6);
332351

333352
_txtFunds->setColor(Palette::blockOffset(15)+4);
334353
_txtFunds->setAlign(ALIGN_CENTER);
@@ -379,8 +398,8 @@ GeoscapeState::GeoscapeState(Game *game) : State(game), _pause(false), _zoomInEf
379398
_txtSec->setX(_txtSec->getX()-10);
380399
}
381400

382-
_timer->onTimer((StateHandler)&GeoscapeState::timeAdvance);
383-
_timer->start();
401+
_gameTimer->onTimer((StateHandler)&GeoscapeState::timeAdvance);
402+
_gameTimer->start();
384403

385404
_zoomInEffectTimer->onTimer((StateHandler)&GeoscapeState::zoomInEffect);
386405
_zoomOutEffectTimer->onTimer((StateHandler)&GeoscapeState::zoomOutEffect);
@@ -394,7 +413,7 @@ GeoscapeState::GeoscapeState(Game *game) : State(game), _pause(false), _zoomInEf
394413
*/
395414
GeoscapeState::~GeoscapeState()
396415
{
397-
delete _timer;
416+
delete _gameTimer;
398417
delete _zoomInEffectTimer;
399418
delete _zoomOutEffectTimer;
400419
delete _dogfightStartTimer;
@@ -454,11 +473,11 @@ void GeoscapeState::handle(Action *action)
454473
{
455474
if (action->getDetails()->key.keysym.sym == Options::keyQuickSave)
456475
{
457-
_game->pushState(new SaveGameState(_game, OPT_GEOSCAPE, SAVE_QUICK));
476+
popup(new SaveGameState(_game, OPT_GEOSCAPE, SAVE_QUICK));
458477
}
459478
else if (action->getDetails()->key.keysym.sym == Options::keyQuickLoad)
460479
{
461-
_game->pushState(new LoadGameState(_game, OPT_GEOSCAPE, SAVE_QUICK));
480+
popup(new LoadGameState(_game, OPT_GEOSCAPE, SAVE_QUICK));
462481
}
463482
}
464483
}
@@ -529,7 +548,7 @@ void GeoscapeState::think()
529548
if (_popups.empty() && _dogfights.empty() && (!_zoomInEffectTimer->isRunning() || _zoomInEffectDone) && (!_zoomOutEffectTimer->isRunning() || _zoomOutEffectDone))
530549
{
531550
// Handle timers
532-
_timer->think(this, 0);
551+
_gameTimer->think(this, 0);
533552
}
534553
else
535554
{
@@ -1388,9 +1407,8 @@ void GeoscapeState::time1Hour()
13881407

13891408
if (Options::storageLimitsEnforced && (*i)->storesOverfull())
13901409
{
1391-
_game->pushState(new SellState(_game, (*i)));
1392-
setPalette("PAL_BASESCAPE", 1);
1393-
_game->pushState(new ErrorMessageState(_game, tr("STR_STORAGE_EXCEEDED").arg((*i)->getName()).c_str(), _palette, Palette::blockOffset(15)+1, "BACK13.SCR", 6));
1410+
popup(new ErrorMessageState(_game, tr("STR_STORAGE_EXCEEDED").arg((*i)->getName()).c_str(), _palette, Palette::blockOffset(15) + 1, "BACK13.SCR", 6));
1411+
popup(new SellState(_game, (*i)));
13941412
}
13951413
}
13961414
}
@@ -1609,11 +1627,11 @@ void GeoscapeState::time1Day()
16091627
{
16101628
if (_game->getSavedGame()->isIronman())
16111629
{
1612-
_game->pushState(new SaveGameState(_game, OPT_GEOSCAPE, SAVE_IRONMAN));
1630+
popup(new SaveGameState(_game, OPT_GEOSCAPE, SAVE_IRONMAN));
16131631
}
16141632
else if (Options::autosave)
16151633
{
1616-
_game->pushState(new SaveGameState(_game, OPT_GEOSCAPE, SAVE_AUTO_GEOSCAPE));
1634+
popup(new SaveGameState(_game, OPT_GEOSCAPE, SAVE_AUTO_GEOSCAPE));
16171635
}
16181636
}
16191637
}
@@ -1973,7 +1991,7 @@ void GeoscapeState::handleDogfights()
19731991
if(_dogfights.size() == _minimizedDogfights)
19741992
{
19751993
_pause = false;
1976-
_timer->think(this, 0);
1994+
_gameTimer->think(this, 0);
19771995
}
19781996
// Handle dogfights logic.
19791997
_minimizedDogfights = 0;
@@ -2230,6 +2248,14 @@ void GeoscapeState::resize(int &dX, int &dY)
22302248
(*i)->setY((*i)->getY() + dY/2);
22312249
}
22322250
}
2251+
2252+
_bg->setX((_globe->getWidth() - _bg->getWidth()) / 2);
2253+
_bg->setY((_globe->getHeight() - _bg->getHeight()) / 2);
2254+
int height = (Options::baseYResolution - Screen::ORIGINAL_HEIGHT) / 2 + 10;
2255+
_btnTop->setHeight(height);
2256+
_btnTop->setY(_sidebar->getY() - height - 1);
2257+
_btnBottom->setHeight(height);
2258+
_btnBottom->setY(_sidebar->getY() + _sidebar->getHeight() + 1);
22332259
}
22342260

22352261
}

src/Geoscape/GeoscapeState.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ class Base;
4343
class GeoscapeState : public State
4444
{
4545
private:
46-
Surface *_bg;
46+
Surface *_bg, *_sidebar;
4747
Globe *_globe;
4848
TextButton *_btnIntercept, *_btnBases, *_btnGraphs, *_btnUfopaedia, *_btnOptions, *_btnFunding;
4949
TextButton *_timeSpeed;
5050
TextButton *_btn5Secs, *_btn1Min, *_btn5Mins, *_btn30Mins, *_btn1Hour, *_btn1Day;
51+
TextButton *_btnTop, *_btnBottom;
5152
InteractiveSurface *_btnRotateLeft, *_btnRotateRight, *_btnRotateUp, *_btnRotateDown, *_btnZoomIn, *_btnZoomOut;
5253
Text *_txtFunds, *_txtHour, *_txtHourSep, *_txtMin, *_txtMinSep, *_txtSec, *_txtWeekday, *_txtDay, *_txtMonth, *_txtYear;
53-
Timer *_timer, *_zoomInEffectTimer, *_zoomOutEffectTimer, *_dogfightStartTimer;
54+
Timer *_gameTimer, *_zoomInEffectTimer, *_zoomOutEffectTimer, *_dogfightStartTimer;
5455
bool _pause, _zoomInEffectDone, _zoomOutEffectDone;
5556
Text *_txtDebug;
5657
std::list<State*> _popups;

src/Resource/XcomResourcePack.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,29 @@ XcomResourcePack::XcomResourcePack(std::vector<std::pair<std::string, ExtraSprit
151151
_surfaces[*i]->loadScr(path);
152152
}
153153

154+
// bigger geoscape background
155+
int newWidth = 320 - 64, newHeight = 200;
156+
Surface *newGeo = new Surface(newWidth*3, newHeight*3);
157+
Surface *oldGeo = _surfaces["GEOBORD.SCR"];
158+
for (int x = 0; x < newWidth; ++x)
159+
{
160+
for (int y = 0; y < newHeight; ++y)
161+
{
162+
newGeo->setPixel(newWidth+x, newHeight+y, oldGeo->getPixel(x, y));
163+
newGeo->setPixel(newWidth-x-1, newHeight+y, oldGeo->getPixel(x, y));
164+
newGeo->setPixel(newWidth*3-x-1, newHeight+y, oldGeo->getPixel(x, y));
165+
166+
newGeo->setPixel(newWidth+x, newHeight-y-1, oldGeo->getPixel(x, y));
167+
newGeo->setPixel(newWidth-x-1, newHeight-y-1, oldGeo->getPixel(x, y));
168+
newGeo->setPixel(newWidth*3-x-1, newHeight-y-1, oldGeo->getPixel(x, y));
169+
170+
newGeo->setPixel(newWidth+x, newHeight*3-y-1, oldGeo->getPixel(x, y));
171+
newGeo->setPixel(newWidth-x-1, newHeight*3-y-1, oldGeo->getPixel(x, y));
172+
newGeo->setPixel(newWidth*3-x-1, newHeight*3-y-1, oldGeo->getPixel(x, y));
173+
}
174+
}
175+
_surfaces["ALTGEOBORD.SCR"] = newGeo;
176+
154177
// here we create an "alternate" background surface for the base info screen.
155178
_surfaces["ALTBACK07.SCR"] = new Surface(320, 200);
156179
_surfaces["ALTBACK07.SCR"]->loadScr(CrossPlatform::getDataFile("GEOGRAPH/BACK07.SCR"));

0 commit comments

Comments
 (0)