mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-16 06:39:17 +00:00
HUGO: Cleanup drawRectangle() and keyHandler()
svn-id: r55642
This commit is contained in:
parent
9c17cedd40
commit
98e329bbd1
@ -106,9 +106,9 @@ void Screen::displayRect(int16 x, int16 y, int16 dx, int16 dy) {
|
||||
debugC(3, kDebugDisplay, "displayRect(%d, %d, %d, %d)", x, y, dx, dy);
|
||||
|
||||
int16 xClip, yClip;
|
||||
xClip = CLIP<int16>(x, 0, 320);
|
||||
yClip = CLIP<int16>(y, 0, 200);
|
||||
g_system->copyRectToScreen(&_frontBuffer[x + y * 320], 320, xClip, yClip, CLIP<int16>(dx, 0, 320 - x), CLIP<int16>(dy, 0, 200 - y));
|
||||
xClip = CLIP<int16>(x, 0, 319);
|
||||
yClip = CLIP<int16>(y, 0, 199);
|
||||
g_system->copyRectToScreen(&_frontBuffer[xClip + yClip * 320], 320, xClip, yClip, CLIP<int16>(dx, 0, 319 - xClip), CLIP<int16>(dy, 0, 199 - yClip));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -493,21 +493,20 @@ void Screen::drawShape(int x, int y, int color1, int color2) {
|
||||
void Screen::drawRectangle(bool filledFl, int16 x1, int16 y1, int16 x2, int16 y2, int color) {
|
||||
assert(x1 <= x2);
|
||||
assert(y1 <= y2);
|
||||
int16 x2Clip = CLIP<int16>(x2, 0, 320);
|
||||
int16 y2Clip = CLIP<int16>(y2, 0, 200);
|
||||
|
||||
if (filledFl) {
|
||||
for (int i = y1; i <= CLIP<int16>(y2, 0, 200); i++) {
|
||||
for (int j = x1; j <= CLIP<int16>(x2, 0, 320); j++) {
|
||||
_backBuffer[320 * i + j] = color;
|
||||
for (int i = y1; i < y2Clip; i++) {
|
||||
for (int j = x1; j < x2Clip; j++)
|
||||
_frontBuffer[320 * i + j] = color;
|
||||
_backBufferBackup[320 * i + j] = color;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = y1; i <= CLIP<int16>(y2, 0, 200); i++) {
|
||||
for (int i = y1; i < y2Clip; i++) {
|
||||
_frontBuffer[320 * i + x1] = color;
|
||||
_frontBuffer[320 * i + x2] = color;
|
||||
}
|
||||
for (int i = x1; i < CLIP<int16>(x2, 0, 320); i++) {
|
||||
for (int i = x1; i < x2Clip; i++) {
|
||||
_frontBuffer[320 * y1 + i] = color;
|
||||
_frontBuffer[320 * y2 + i] = color;
|
||||
}
|
||||
|
@ -264,10 +264,6 @@ Common::Error HugoEngine::run() {
|
||||
while (_eventMan->pollEvent(event)) {
|
||||
switch (event.type) {
|
||||
case Common::EVENT_KEYDOWN:
|
||||
if (event.kbd.keycode == Common::KEYCODE_d && event.kbd.hasFlags(Common::KBD_CTRL)) {
|
||||
this->getDebugger()->attach();
|
||||
this->getDebugger()->onFrame();
|
||||
}
|
||||
_parser->keyHandler(event);
|
||||
break;
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
|
@ -33,6 +33,10 @@
|
||||
#include "common/system.h"
|
||||
#include "common/events.h"
|
||||
|
||||
#include "common/random.h"
|
||||
#include "common/EventRecorder.h"
|
||||
#include "common/debug-channels.h"
|
||||
|
||||
#include "hugo/hugo.h"
|
||||
#include "hugo/display.h"
|
||||
#include "hugo/parser.h"
|
||||
@ -131,6 +135,37 @@ void Parser::keyHandler(Common::Event event) {
|
||||
status_t &gameStatus = _vm->getGameStatus();
|
||||
uint16 nChar = event.kbd.keycode;
|
||||
|
||||
if ((event.kbd.hasFlags(Common::KBD_ALT)) || (event.kbd.hasFlags(Common::KBD_SCRL)))
|
||||
return;
|
||||
|
||||
if (event.kbd.hasFlags(Common::KBD_CTRL)) {
|
||||
switch (nChar) {
|
||||
case Common::KEYCODE_d:
|
||||
_vm->getDebugger()->attach();
|
||||
_vm->getDebugger()->onFrame();
|
||||
break;
|
||||
case Common::KEYCODE_l:
|
||||
_vm->_file->restoreGame(-1);
|
||||
_vm->_scheduler->restoreScreen(*_vm->_screen_p);
|
||||
gameStatus.viewState = kViewPlay;
|
||||
break;
|
||||
case Common::KEYCODE_n:
|
||||
warning("STUB: CTRL-N (WIN) - New Game");
|
||||
break;
|
||||
case Common::KEYCODE_s:
|
||||
if (gameStatus.viewState == kViewPlay) {
|
||||
if (gameStatus.gameOverFl)
|
||||
Utils::gameOverMsg();
|
||||
else
|
||||
_vm->_file->saveGame(-1, Common::String());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Process key down event - called from OnKeyDown()
|
||||
switch (nChar) { // Set various toggle states
|
||||
case Common::KEYCODE_ESCAPE: // Escape key, may want to QUIT
|
||||
@ -197,61 +232,6 @@ void Parser::keyHandler(Common::Event event) {
|
||||
case Common::KEYCODE_F9: // Boss button
|
||||
warning("STUB: F9 (DOS) - BossKey");
|
||||
break;
|
||||
case Common::KEYCODE_l:
|
||||
if (event.kbd.hasFlags(Common::KBD_CTRL)) {
|
||||
_vm->_file->restoreGame(-1);
|
||||
_vm->_scheduler->restoreScreen(*_vm->_screen_p);
|
||||
gameStatus.viewState = kViewPlay;
|
||||
} else {
|
||||
if (!gameStatus.storyModeFl) { // Keyboard disabled
|
||||
// Add printable keys to ring buffer
|
||||
uint16 bnext = _putIndex + 1;
|
||||
if (bnext >= sizeof(_ringBuffer))
|
||||
bnext = 0;
|
||||
if (bnext != _getIndex) {
|
||||
_ringBuffer[_putIndex] = event.kbd.ascii;
|
||||
_putIndex = bnext;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Common::KEYCODE_n:
|
||||
if (event.kbd.hasFlags(Common::KBD_CTRL)) {
|
||||
warning("STUB: CTRL-N (WIN) - New Game");
|
||||
} else {
|
||||
if (!gameStatus.storyModeFl) { // Keyboard disabled
|
||||
// Add printable keys to ring buffer
|
||||
uint16 bnext = _putIndex + 1;
|
||||
if (bnext >= sizeof(_ringBuffer))
|
||||
bnext = 0;
|
||||
if (bnext != _getIndex) {
|
||||
_ringBuffer[_putIndex] = event.kbd.ascii;
|
||||
_putIndex = bnext;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Common::KEYCODE_s:
|
||||
if (event.kbd.hasFlags(Common::KBD_CTRL)) {
|
||||
if (gameStatus.viewState == kViewPlay) {
|
||||
if (gameStatus.gameOverFl)
|
||||
Utils::gameOverMsg();
|
||||
else
|
||||
_vm->_file->saveGame(-1, Common::String());
|
||||
}
|
||||
} else {
|
||||
if (!gameStatus.storyModeFl) { // Keyboard disabled
|
||||
// Add printable keys to ring buffer
|
||||
uint16 bnext = _putIndex + 1;
|
||||
if (bnext >= sizeof(_ringBuffer))
|
||||
bnext = 0;
|
||||
if (bnext != _getIndex) {
|
||||
_ringBuffer[_putIndex] = event.kbd.ascii;
|
||||
_putIndex = bnext;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: // Any other key
|
||||
if (!gameStatus.storyModeFl) { // Keyboard disabled
|
||||
// Add printable keys to ring buffer
|
||||
|
Loading…
Reference in New Issue
Block a user