ASYLUM: Added a back buffer again. The icons in the top row should be highlighted properly now
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@64 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
parent
f6ab0ab24f
commit
ce37ad7248
3 changed files with 33 additions and 10 deletions
|
@ -45,6 +45,7 @@ AsylumEngine::AsylumEngine(OSystem *system, Common::Language language)
|
||||||
AsylumEngine::~AsylumEngine() {
|
AsylumEngine::~AsylumEngine() {
|
||||||
//Common::clearAllDebugChannels();
|
//Common::clearAllDebugChannels();
|
||||||
delete _resMgr;
|
delete _resMgr;
|
||||||
|
_backBuffer.free();
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Error AsylumEngine::run() {
|
Common::Error AsylumEngine::run() {
|
||||||
|
@ -60,6 +61,8 @@ Common::Error AsylumEngine::init() {
|
||||||
// initialize engine objects
|
// initialize engine objects
|
||||||
|
|
||||||
initGraphics(640, 480, true);
|
initGraphics(640, 480, true);
|
||||||
|
_backBuffer.create(640, 480, 1);
|
||||||
|
|
||||||
_resMgr = new ResourceManager(this);
|
_resMgr = new ResourceManager(this);
|
||||||
|
|
||||||
// initializing game
|
// initializing game
|
||||||
|
@ -76,6 +79,7 @@ Common::Error AsylumEngine::init() {
|
||||||
|
|
||||||
Common::Error AsylumEngine::go() {
|
Common::Error AsylumEngine::go() {
|
||||||
// Play intro movie
|
// Play intro movie
|
||||||
|
int mouseX = 0, mouseY = 0;
|
||||||
|
|
||||||
_resMgr->loadVideo(0);
|
_resMgr->loadVideo(0);
|
||||||
|
|
||||||
|
@ -90,6 +94,8 @@ Common::Error AsylumEngine::go() {
|
||||||
while (!shouldQuit()) {
|
while (!shouldQuit()) {
|
||||||
Common::Event ev;
|
Common::Event ev;
|
||||||
|
|
||||||
|
// Copy background image
|
||||||
|
_system->copyRectToScreen((byte *)_backBuffer.pixels, _backBuffer.w, 0, 0, _backBuffer.w, _backBuffer.h);
|
||||||
|
|
||||||
if (em->pollEvent(ev)) {
|
if (em->pollEvent(ev)) {
|
||||||
if (ev.type == Common::EVENT_KEYDOWN) {
|
if (ev.type == Common::EVENT_KEYDOWN) {
|
||||||
|
@ -101,18 +107,21 @@ Common::Error AsylumEngine::go() {
|
||||||
}
|
}
|
||||||
//if (ev.kbd.keycode == Common::KEYCODE_RETURN)
|
//if (ev.kbd.keycode == Common::KEYCODE_RETURN)
|
||||||
} else if (ev.type == Common::EVENT_MOUSEMOVE) {
|
} else if (ev.type == Common::EVENT_MOUSEMOVE) {
|
||||||
|
mouseX = ev.mouse.x;
|
||||||
|
mouseY = ev.mouse.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Just some proof-of concept to change icons here for now
|
// TODO: Just some proof-of concept to change icons here for now
|
||||||
if (ev.mouse.y >= 20 && ev.mouse.y <= 20 + 48) {
|
if (mouseY >= 20 && mouseY <= 20 + 48) {
|
||||||
for (int i = 0; i <= 5; i++) {
|
for (int i = 0; i <= 5; i++) {
|
||||||
int curX = 40 + i * 100;
|
int curX = 40 + i * 100;
|
||||||
if (ev.mouse.x >= curX && ev.mouse.x <= curX + 55) {
|
if (mouseX >= curX && mouseX <= curX + 55) {
|
||||||
GraphicResource *res = _resMgr->getGraphic(1, i + 4, 0);
|
GraphicResource *res = _resMgr->getGraphic(1, i + 4, 0);
|
||||||
_system->copyRectToScreen(res->data, res->width, curX, 20, res->width, res->height);
|
_system->copyRectToScreen(res->data, res->width, curX, 20, res->width, res->height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_system->updateScreen();
|
_system->updateScreen();
|
||||||
_system->delayMillis(10);
|
_system->delayMillis(10);
|
||||||
|
@ -129,4 +138,14 @@ void AsylumEngine::showMainMenu() {
|
||||||
_resMgr->loadMusic();
|
_resMgr->loadMusic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AsylumEngine::copyToBackBuffer(int x, int y, int width, int height, byte *buffer) {
|
||||||
|
int h = height;
|
||||||
|
byte *dest = (byte *)_backBuffer.pixels;
|
||||||
|
|
||||||
|
while (h--) {
|
||||||
|
memcpy(dest, buffer, width);
|
||||||
|
dest += 640;
|
||||||
|
buffer += width;
|
||||||
|
}
|
||||||
|
}
|
||||||
} // namespace Asylum
|
} // namespace Asylum
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "engines/engine.h"
|
#include "engines/engine.h"
|
||||||
#include "asylum/resman.h"
|
#include "asylum/resman.h"
|
||||||
|
#include "graphics/surface.h"
|
||||||
|
|
||||||
namespace Asylum {
|
namespace Asylum {
|
||||||
|
|
||||||
|
@ -47,11 +48,14 @@ public:
|
||||||
virtual Common::Error run();
|
virtual Common::Error run();
|
||||||
virtual bool hasFeature(EngineFeature f) const;
|
virtual bool hasFeature(EngineFeature f) const;
|
||||||
|
|
||||||
|
void copyToBackBuffer(int x, int y, int width, int height, byte *buffer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Common::Language _language;
|
Common::Language _language;
|
||||||
Common::RandomSource _rnd;
|
Common::RandomSource _rnd;
|
||||||
|
|
||||||
ResourceManager *_resMgr;
|
ResourceManager *_resMgr;
|
||||||
|
Graphics::Surface _backBuffer;
|
||||||
|
|
||||||
void showMainMenu();
|
void showMainMenu();
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ bool ResourceManager::loadVideo(uint8 fileNum) {
|
||||||
|
|
||||||
bool ResourceManager::loadGraphic(uint8 fileNum, uint32 offset, uint32 index) {
|
bool ResourceManager::loadGraphic(uint8 fileNum, uint32 offset, uint32 index) {
|
||||||
GraphicResource *res = getGraphic(fileNum, offset, index);
|
GraphicResource *res = getGraphic(fileNum, offset, index);
|
||||||
_vm->_system->copyRectToScreen(res->data, res->width, 0, 0, res->width, res->height);
|
_vm->copyToBackBuffer(0, 0, res->width, res->height, res->data);
|
||||||
|
|
||||||
// TODO proper error check
|
// TODO proper error check
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue