2003-07-28 01:47:41 +00:00
|
|
|
/* 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"
|
2003-09-18 02:07:18 +00:00
|
|
|
#include "base/engine.h"
|
2003-08-30 18:06:08 +00:00
|
|
|
#include "common/timer.h"
|
2003-10-04 00:52:27 +00:00
|
|
|
#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"
|
2003-09-07 01:51:15 +00:00
|
|
|
#include "bs2/sword2.h"
|
2003-07-28 01:47:41 +00:00
|
|
|
|
2003-10-04 00:52:27 +00:00
|
|
|
namespace Sword2 {
|
|
|
|
|
2003-07-28 01:47:41 +00:00
|
|
|
#define MENUDEEP 40 // Temporary, until menu.h is written!
|
|
|
|
|
2003-09-27 15:20:15 +00:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// OSystem Event Handler. Full of cross platform goodness and 99% fat free!
|
|
|
|
// ---------------------------------------------------------------------------
|
2003-07-28 01:47:41 +00:00
|
|
|
|
2003-10-04 01:09:29 +00:00
|
|
|
void Sword2Engine::parseEvents() {
|
2003-07-28 01:47:41 +00:00
|
|
|
OSystem::Event event;
|
|
|
|
|
|
|
|
while (_system->poll_event(&event)) {
|
|
|
|
switch(event.event_code) {
|
|
|
|
case OSystem::EVENT_KEYDOWN:
|
2003-09-23 15:59:52 +00:00
|
|
|
WriteKey(event.kbd.ascii, event.kbd.keycode, event.kbd.flags);
|
2003-07-28 01:47:41 +00:00
|
|
|
break;
|
|
|
|
case OSystem::EVENT_MOUSEMOVE:
|
|
|
|
mousex = event.mouse.x;
|
2003-08-20 11:41:43 +00:00
|
|
|
mousey = event.mouse.y - MENUDEEP;
|
2003-07-28 01:47:41 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-28 14:13:57 +00:00
|
|
|
/**
|
|
|
|
* Quit the game.
|
|
|
|
*/
|
|
|
|
|
2003-09-27 15:20:15 +00:00
|
|
|
int32 CloseAppWindow(void) {
|
2003-07-28 01:47:41 +00:00
|
|
|
warning("stub CloseAppWindow");
|
|
|
|
/*
|
|
|
|
DestroyWindow(hwnd);
|
|
|
|
*/
|
|
|
|
// just quit for now
|
2003-07-31 15:24:23 +00:00
|
|
|
g_system->quit();
|
2003-09-27 15:20:15 +00:00
|
|
|
return RD_OK;
|
2003-07-28 01:47:41 +00:00
|
|
|
}
|
|
|
|
|
2003-08-29 06:42:34 +00:00
|
|
|
static bool _needRedraw = false;
|
2003-07-28 01:47:41 +00:00
|
|
|
|
2003-08-29 06:42:34 +00:00
|
|
|
void SetNeedRedraw() {
|
|
|
|
_needRedraw = true;
|
|
|
|
}
|
2003-07-28 01:47:41 +00:00
|
|
|
|
2003-09-28 14:13:57 +00:00
|
|
|
/**
|
|
|
|
* This function should be called at a high rate (> 20 per second) to service
|
|
|
|
* windows and the interface it provides.
|
|
|
|
*/
|
|
|
|
|
2003-09-27 15:20:15 +00:00
|
|
|
int32 ServiceWindows(void) {
|
2003-07-30 19:25:31 +00:00
|
|
|
g_sword2->parseEvents();
|
2003-08-25 06:13:28 +00:00
|
|
|
FadeServer();
|
2003-08-28 06:36:15 +00:00
|
|
|
|
|
|
|
// FIXME: We re-render the entire picture area of the screen for each
|
|
|
|
// frame, which is pretty horrible.
|
|
|
|
|
2003-08-29 06:42:34 +00:00
|
|
|
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.
|
2003-08-28 06:36:15 +00:00
|
|
|
g_system->update_screen();
|
2003-08-29 06:42:34 +00:00
|
|
|
|
2003-09-23 16:38:38 +00:00
|
|
|
return RD_OK;
|
2003-07-28 01:47:41 +00:00
|
|
|
}
|
|
|
|
|
2003-09-28 14:13:57 +00:00
|
|
|
/**
|
|
|
|
* Set the window name to windowName and stores this name in gameName for
|
|
|
|
* future use.
|
|
|
|
*/
|
|
|
|
|
2003-09-27 15:20:15 +00:00
|
|
|
void SetWindowName(const char *windowName) {
|
2003-07-28 01:47:41 +00:00
|
|
|
warning("stub SetWindowName( %s )", windowName);
|
2003-09-27 15:20:15 +00:00
|
|
|
// SetWindowText(hwnd, windowName);
|
|
|
|
// strcpy(gameName, windowName);
|
2003-07-28 01:47:41 +00:00
|
|
|
}
|
2003-10-04 00:52:27 +00:00
|
|
|
|
|
|
|
} // End of namespace Sword2
|