Permalink
Browse files

SLUDGE: Objectify input and event handler

  • Loading branch information...
yinsimei committed Jul 20, 2017
1 parent caa51ef commit 0fb4a1ddd228cdcedb1313aa8df6ac2b9ba97530
@@ -28,24 +28,23 @@
#include "graphics/palette.h"
#include "sludge/allfiles.h"
#include "sludge/newfatal.h"
#include "sludge/backdrop.h"
#include "sludge/event.h"
#include "sludge/fileset.h"
#include "sludge/graphics.h"
#include "sludge/backdrop.h"
#include "sludge/imgloader.h"
#include "sludge/moreio.h"
#include "sludge/newfatal.h"
#include "sludge/statusba.h"
#include "sludge/talk.h"
#include "sludge/zbuffer.h"
#include "sludge/sludge.h"
#include "sludge/sludger.h"
#include "sludge/talk.h"
#include "sludge/variable.h"
#include "sludge/version.h"
#include "sludge/imgloader.h"
namespace Sludge {
extern InputType input;
Parallax::Parallax() {
_parallaxLayers.clear();
}
@@ -219,11 +218,11 @@ void GraphicsManager::killLightMap() {
bool GraphicsManager::reserveBackdrop() {
_cameraX = 0;
_cameraY = 0;
input.mouseX = (int)((float)input.mouseX * _cameraZoom);
input.mouseY = (int)((float)input.mouseY * _cameraZoom);
_vm->_evtMan->mouseX() = (int)((float)_vm->_evtMan->mouseX() * _cameraZoom);
_vm->_evtMan->mouseY() = (int)((float)_vm->_evtMan->mouseY() * _cameraZoom);
_cameraZoom = 1.0;
input.mouseX = (int)((float)input.mouseX / _cameraZoom);
input.mouseY = (int)((float)input.mouseY / _cameraZoom);
_vm->_evtMan->mouseX() = (int)((float)_vm->_evtMan->mouseX() / _cameraZoom);
_vm->_evtMan->mouseY() = (int)((float)_vm->_evtMan->mouseY() / _cameraZoom);
return true;
}
View
@@ -51,6 +51,7 @@
#include "sludge/sludge.h"
#include "sludge/utf8.h"
#include "sludge/graphics.h"
#include "sludge/event.h"
namespace Sludge {
@@ -63,15 +64,13 @@ extern int lastFramesPerSecond, thumbWidth, thumbHeight;
extern bool allowAnyFilename;
extern bool captureAllKeys;
extern int16 fontSpace;
extern EventHandlers *currentEvents;
extern VariableStack *noStack;
extern StatusStuff *nowStatus;
extern ScreenRegion *overRegion;
extern int numBIFNames, numUserFunc;
extern Common::String *allUserFunc;
extern Common::String *allBIFNames;
extern InputType input;
extern float speechSpeed;
extern byte brightnessLevel;
@@ -135,6 +134,7 @@ struct builtInFunctionData {
#define builtIn(a) static BuiltReturn builtIn_ ## a (int numParams, LoadedFunction *fun)
#define UNUSEDALL (void) (0 && sizeof(numParams) && sizeof (fun));
static BuiltReturn sayCore(int numParams, LoadedFunction *fun, bool sayIt) {
int fileNum = -1;
Common::String newText;
@@ -209,25 +209,25 @@ builtIn(setCursor) {
builtIn(getMouseX) {
UNUSEDALL
setVariable(fun->reg, SVT_INT, input.mouseX + g_sludge->_gfxMan->getCamX());
setVariable(fun->reg, SVT_INT, g_sludge->_evtMan->mouseX() + g_sludge->_gfxMan->getCamX());
return BR_CONTINUE;
}
builtIn(getMouseY) {
UNUSEDALL
setVariable(fun->reg, SVT_INT, input.mouseY + g_sludge->_gfxMan->getCamY());
setVariable(fun->reg, SVT_INT, g_sludge->_evtMan->mouseY() + g_sludge->_gfxMan->getCamY());
return BR_CONTINUE;
}
builtIn(getMouseScreenX) {
UNUSEDALL
setVariable(fun->reg, SVT_INT, input.mouseX * g_sludge->_gfxMan->getCamZoom());
setVariable(fun->reg, SVT_INT, g_sludge->_evtMan->mouseX() * g_sludge->_gfxMan->getCamZoom());
return BR_CONTINUE;
}
builtIn(getMouseScreenY) {
UNUSEDALL
setVariable(fun->reg, SVT_INT, input.mouseY * g_sludge->_gfxMan->getCamZoom());
setVariable(fun->reg, SVT_INT, g_sludge->_evtMan->mouseY() * g_sludge->_gfxMan->getCamZoom());
return BR_CONTINUE;
}
@@ -1839,7 +1839,7 @@ builtIn(onLeftMouse) {
UNUSEDALL
int functionNum;
if (getFuncNumForCallback(numParams, fun, functionNum)) {
currentEvents->leftMouseFunction = functionNum;
g_sludge->_evtMan->setEventFunction(kLeftMouse, functionNum);
return BR_CONTINUE;
}
return BR_ERROR;
@@ -1849,7 +1849,7 @@ builtIn(onLeftMouseUp) {
UNUSEDALL
int functionNum;
if (getFuncNumForCallback(numParams, fun, functionNum)) {
currentEvents->leftMouseUpFunction = functionNum;
g_sludge->_evtMan->setEventFunction(kLeftMouseUp, functionNum);
return BR_CONTINUE;
}
return BR_ERROR;
@@ -1859,7 +1859,7 @@ builtIn(onRightMouse) {
UNUSEDALL
int functionNum;
if (getFuncNumForCallback(numParams, fun, functionNum)) {
currentEvents->rightMouseFunction = functionNum;
g_sludge->_evtMan->setEventFunction(kRightMouse, functionNum);
return BR_CONTINUE;
}
return BR_ERROR;
@@ -1869,7 +1869,7 @@ builtIn(onRightMouseUp) {
UNUSEDALL
int functionNum;
if (getFuncNumForCallback(numParams, fun, functionNum)) {
currentEvents->rightMouseUpFunction = functionNum;
g_sludge->_evtMan->setEventFunction(kRightMouseUp, functionNum);
return BR_CONTINUE;
}
return BR_ERROR;
@@ -1879,7 +1879,7 @@ builtIn(onFocusChange) {
UNUSEDALL
int functionNum;
if (getFuncNumForCallback(numParams, fun, functionNum)) {
currentEvents->focusFunction = functionNum;
g_sludge->_evtMan->setEventFunction(kFocus, functionNum);
return BR_CONTINUE;
}
return BR_ERROR;
@@ -1889,7 +1889,7 @@ builtIn(onMoveMouse) {
UNUSEDALL
int functionNum;
if (getFuncNumForCallback(numParams, fun, functionNum)) {
currentEvents->moveMouseFunction = functionNum;
g_sludge->_evtMan->setEventFunction(kMoveMouse, functionNum);
return BR_CONTINUE;
}
return BR_ERROR;
@@ -1899,7 +1899,7 @@ builtIn(onKeyboard) {
UNUSEDALL
int functionNum;
if (getFuncNumForCallback(numParams, fun, functionNum)) {
currentEvents->spaceFunction = functionNum;
g_sludge->_evtMan->setEventFunction(kSpace, functionNum);
return BR_CONTINUE;
}
return BR_ERROR;
@@ -22,10 +22,11 @@
#include "sludge/allfiles.h"
#include "sludge/cursors.h"
#include "sludge/event.h"
#include "sludge/graphics.h"
#include "sludge/people.h"
#include "sludge/sprites.h"
#include "sludge/sprbanks.h"
#include "sludge/people.h"
#include "sludge/sludge.h"
#include "sludge/sludger.h"
@@ -35,8 +36,6 @@ PersonaAnimation *mouseCursorAnim;
int mouseCursorFrameNum = 0;
int mouseCursorCountUp = 0;
extern InputType input;
void pickAnimCursor(PersonaAnimation *pp) {
deleteAnim(mouseCursorAnim);
mouseCursorAnim = pp;
@@ -63,12 +62,12 @@ void displayCursor() {
if (flipMe != 2) {
if (flipMe) {
g_sludge->_gfxMan->flipFontSprite(
input.mouseX, input.mouseY,
g_sludge->_evtMan->mouseX(), g_sludge->_evtMan->mouseY(),
mouseCursorAnim->theSprites->bank.sprites[spriteNum],
mouseCursorAnim->theSprites->bank.myPalette /* ( spritePalette&) NULL*/);
} else {
g_sludge->_gfxMan->fontSprite(
input.mouseX, input.mouseY,
g_sludge->_evtMan->mouseX(), g_sludge->_evtMan->mouseY(),
mouseCursorAnim->theSprites->bank.sprites[spriteNum],
mouseCursorAnim->theSprites->bank.myPalette /* ( spritePalette&) NULL*/);
}
Oops, something went wrong.

0 comments on commit 0fb4a1d

Please sign in to comment.