mirror of
https://github.com/libretro/scummvm.git
synced 2025-04-07 09:14:11 +00:00
127 lines
3.2 KiB
C++
127 lines
3.2 KiB
C++
/* Copyright (C) 1994-2003 Revolution Software Ltd
|
|
*
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
*
|
|
* $Header$
|
|
*/
|
|
|
|
#include "common/stdafx.h"
|
|
#include "bs2/sword2.h"
|
|
#include "bs2/driver/driver96.h"
|
|
#include "bs2/driver/_mouse.h"
|
|
#include "bs2/driver/keyboard.h"
|
|
#include "bs2/driver/rdwin.h"
|
|
#include "bs2/driver/d_draw.h"
|
|
#include "bs2/driver/palette.h"
|
|
#include "bs2/driver/render.h"
|
|
#include "bs2/driver/menu.h"
|
|
#include "bs2/driver/d_sound.h"
|
|
|
|
namespace Sword2 {
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// OSystem Event Handler. Full of cross platform goodness and 99% fat free!
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void Sword2Engine::parseEvents() {
|
|
OSystem::Event event;
|
|
|
|
while (_system->poll_event(&event)) {
|
|
switch(event.event_code) {
|
|
case OSystem::EVENT_KEYDOWN:
|
|
WriteKey(event.kbd.ascii, event.kbd.keycode, event.kbd.flags);
|
|
break;
|
|
case OSystem::EVENT_MOUSEMOVE:
|
|
mousex = event.mouse.x;
|
|
mousey = event.mouse.y - MENUDEEP;
|
|
break;
|
|
case OSystem::EVENT_LBUTTONDOWN:
|
|
LogMouseEvent(RD_LEFTBUTTONDOWN);
|
|
break;
|
|
case OSystem::EVENT_RBUTTONDOWN:
|
|
LogMouseEvent(RD_RIGHTBUTTONDOWN);
|
|
break;
|
|
case OSystem::EVENT_LBUTTONUP:
|
|
LogMouseEvent(RD_LEFTBUTTONUP);
|
|
break;
|
|
case OSystem::EVENT_RBUTTONUP:
|
|
LogMouseEvent(RD_RIGHTBUTTONUP);
|
|
break;
|
|
case OSystem::EVENT_QUIT:
|
|
Close_game();
|
|
CloseAppWindow();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Quit the game.
|
|
*/
|
|
|
|
int32 CloseAppWindow(void) {
|
|
warning("stub CloseAppWindow");
|
|
/*
|
|
DestroyWindow(hwnd);
|
|
*/
|
|
// just quit for now
|
|
g_system->quit();
|
|
return RD_OK;
|
|
}
|
|
|
|
static bool _needRedraw = false;
|
|
|
|
void SetNeedRedraw() {
|
|
_needRedraw = true;
|
|
}
|
|
|
|
/**
|
|
* This function should be called at a high rate (> 20 per second) to service
|
|
* windows and the interface it provides.
|
|
*/
|
|
|
|
int32 ServiceWindows(void) {
|
|
g_sword2->parseEvents();
|
|
FadeServer();
|
|
|
|
// FIXME: We re-render the entire picture area of the screen for each
|
|
// frame, which is pretty horrible.
|
|
|
|
if (_needRedraw) {
|
|
g_system->copy_rect(lpBackBuffer + MENUDEEP * screenWide, screenWide, 0, MENUDEEP, screenWide, screenDeep - 2 * MENUDEEP);
|
|
_needRedraw = false;
|
|
}
|
|
|
|
// We still need to update because of fades, menu animations, etc.
|
|
g_system->update_screen();
|
|
|
|
return RD_OK;
|
|
}
|
|
|
|
/**
|
|
* Set the window title
|
|
*/
|
|
|
|
void SetWindowName(const char *windowName) {
|
|
OSystem::Property prop;
|
|
|
|
prop.caption = windowName;
|
|
g_system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
|
|
}
|
|
|
|
} // End of namespace Sword2
|