mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-21 01:05:59 +00:00
SAGA2: Save thumbnail before opening menu
This commit is contained in:
parent
0e8d0bc76f
commit
3be7db2a9d
92
engines/saga2/gfx.cpp
Normal file
92
engines/saga2/gfx.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "graphics/surface.h"
|
||||
|
||||
#include "saga2/saga2.h"
|
||||
|
||||
#include "saga2/gfx.h"
|
||||
|
||||
namespace Saga2 {
|
||||
|
||||
Renderer::Renderer(Saga2Engine *vm) : _vm(vm) {
|
||||
for (int i = 0; i < kMaxBackBufferSources; ++i) {
|
||||
_savedBackBuffers[i] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Renderer::~Renderer() {
|
||||
for (int i = 0; i < kMaxBackBufferSources; i++) {
|
||||
if (_savedBackBuffers[i]) {
|
||||
delete[] _savedBackBuffers[i];
|
||||
_savedBackBuffers[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::saveBackBuffer(BackBufferSource source) {
|
||||
if (source >= 0 && source < kMaxBackBufferSources) {
|
||||
if (_savedBackBuffers[source])
|
||||
removeSavedBackBuffer(source);
|
||||
|
||||
Graphics::Surface *surf = g_system->lockScreen();
|
||||
int size = surf->w * surf->h;
|
||||
|
||||
_savedBackBuffers[source] = new byte[size];
|
||||
memcpy(_savedBackBuffers[source], surf->getPixels(), size);
|
||||
|
||||
g_system->unlockScreen();
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::popSavedBackBuffer(BackBufferSource source) {
|
||||
restoreSavedBackBuffer(source);
|
||||
removeSavedBackBuffer(source);
|
||||
}
|
||||
|
||||
void Renderer::restoreSavedBackBuffer(BackBufferSource source) {
|
||||
if (source >= 0 && source < kMaxBackBufferSources) {
|
||||
if (_savedBackBuffers[source]) {
|
||||
Graphics::Surface *surf = g_system->lockScreen();
|
||||
int size = surf->w * surf->h;
|
||||
|
||||
memcpy(surf->getBasePtr(0, 0), _savedBackBuffers[source], size);
|
||||
|
||||
g_system->unlockScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::removeSavedBackBuffer(BackBufferSource source) {
|
||||
if (source >= 0 && source < kMaxBackBufferSources) {
|
||||
if (_savedBackBuffers[source])
|
||||
delete[] _savedBackBuffers[source];
|
||||
|
||||
_savedBackBuffers[source] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool Renderer::hasSavedBackBuffer(BackBufferSource source) {
|
||||
return (source >= 0 && source < kMaxBackBufferSources) && _savedBackBuffers[source];
|
||||
}
|
||||
|
||||
} // end of namespace Saga2
|
59
engines/saga2/gfx.h
Normal file
59
engines/saga2/gfx.h
Normal file
@ -0,0 +1,59 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SAGA2_GFX_H
|
||||
#define SAGA2_GFX_H
|
||||
|
||||
#include "common/noncopyable.h"
|
||||
|
||||
namespace Saga2 {
|
||||
|
||||
enum BackBufferSource {
|
||||
kBeforeOpeningMenu,
|
||||
kBeforeTakingThumbnail,
|
||||
kMaxBackBufferSources
|
||||
};
|
||||
|
||||
class Renderer : public Common::NonCopyable {
|
||||
private:
|
||||
Saga2Engine *_vm;
|
||||
|
||||
byte *_savedBackBuffers[kMaxBackBufferSources];
|
||||
|
||||
public:
|
||||
Renderer(Saga2Engine *vm);
|
||||
~Renderer();
|
||||
|
||||
void saveBackBuffer(BackBufferSource source);
|
||||
|
||||
void popSavedBackBuffer(BackBufferSource source);
|
||||
|
||||
void restoreSavedBackBuffer(BackBufferSource source);
|
||||
|
||||
void removeSavedBackBuffer(BackBufferSource source);
|
||||
|
||||
bool hasSavedBackBuffer(BackBufferSource source);
|
||||
};
|
||||
|
||||
} // end of namespace Saga2
|
||||
|
||||
#endif
|
@ -20,6 +20,7 @@ MODULE_OBJS := \
|
||||
floating.o \
|
||||
gamemode.o \
|
||||
gdraw.o \
|
||||
gfx.o \
|
||||
gpointer.o \
|
||||
grabinfo.o \
|
||||
grequest.o \
|
||||
|
@ -62,6 +62,7 @@ Saga2Engine::Saga2Engine(OSystem *syst)
|
||||
g_vm = this;
|
||||
|
||||
_console = nullptr;
|
||||
_renderer = nullptr;
|
||||
_bandList = nullptr;
|
||||
_mouseInfo = nullptr;
|
||||
_smkDecoder = nullptr;
|
||||
@ -110,6 +111,8 @@ Saga2Engine::~Saga2Engine() {
|
||||
|
||||
// Dispose your resources here
|
||||
delete _rnd;
|
||||
delete _renderer;
|
||||
|
||||
delete _imageCache;
|
||||
delete _mTaskList;
|
||||
delete _bandList;
|
||||
@ -132,6 +135,8 @@ Common::Error Saga2Engine::run() {
|
||||
_console = new Console(this);
|
||||
setDebugger(_console);
|
||||
|
||||
_renderer = new Renderer(this);
|
||||
|
||||
readConfig();
|
||||
|
||||
loadExeResources();
|
||||
@ -177,7 +182,14 @@ Common::Error Saga2Engine::saveGameState(int slot, const Common::String &desc, b
|
||||
CHUNK_BEGIN;
|
||||
uint32 pos = outS->pos() + 4;
|
||||
|
||||
_renderer->saveBackBuffer(kBeforeTakingThumbnail);
|
||||
|
||||
if (_renderer->hasSavedBackBuffer(kBeforeOpeningMenu))
|
||||
_renderer->restoreSavedBackBuffer(kBeforeOpeningMenu);
|
||||
|
||||
getMetaEngine()->appendExtendedSaveToStream(out, g_vm->getTotalPlayTime() / 1000, desc, false, pos);
|
||||
|
||||
_renderer->popSavedBackBuffer(kBeforeTakingThumbnail);
|
||||
CHUNK_END;
|
||||
|
||||
outS->finalize();
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "engines/engine.h"
|
||||
|
||||
#include "saga2/console.h"
|
||||
#include "saga2/gfx.h"
|
||||
#include "saga2/idtypes.h"
|
||||
#include "saga2/weapons.h"
|
||||
#include "saga2/vdraw.h"
|
||||
@ -130,6 +131,7 @@ public:
|
||||
// We need random numbers
|
||||
Common::RandomSource *_rnd;
|
||||
Console *_console;
|
||||
Renderer *_renderer;
|
||||
|
||||
WeaponStuff _weaponRack[kMaxWeapons];
|
||||
weaponID _loadedWeapons;
|
||||
|
@ -777,6 +777,9 @@ void enableUserControls(void);
|
||||
void updateAllUserControls(void);
|
||||
|
||||
int16 OptionsDialog(bool disableSaveResume) {
|
||||
// Save back buffer before opening the dialog
|
||||
g_vm->_renderer->saveBackBuffer(kBeforeOpeningMenu);
|
||||
|
||||
// text for dialog
|
||||
const char *btnStrings[kNumOptionsBtns] = {
|
||||
OPTN_DIALOG_BUTTON1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user