Skip to content

Commit

Permalink
TSAGE: R2R - WIP work on cursor behavior in scene 1337
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Dec 1, 2013
1 parent 3e85976 commit a6458ab
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
49 changes: 32 additions & 17 deletions engines/tsage/ringworld2/ringworld2_scenes1.cpp
Expand Up @@ -2256,6 +2256,10 @@ Scene1337::Scene1337() {
_field3EF0 = nullptr;
_field3EF4 = nullptr;
_field3EF8 = nullptr;

_cursorCurRes = 0;
_cursorCurStrip = 0;
_cursorCurFrame = 0;
}

void Scene1337::synchronize(Serializer &s) {
Expand Down Expand Up @@ -4482,6 +4486,12 @@ void Scene1337::dispatch() {
suggestInstructions();
}
}

// The following code is in the original in sceneHandler::process(),
// which is terrible as it's checked in every scene of the game.
setCursorData(5, _cursorCurStrip, _cursorCurFrame);
//

Scene::dispatch();
}

Expand Down Expand Up @@ -5262,11 +5272,10 @@ void Scene1337::subC4CD2() {
}

void Scene1337::subC4CEC() {
if (R2_GLOBALS._v57709 != 0)
return;

subD18F5();
subD1940(true);
if (R2_GLOBALS._v57709 == 0) {
subD18F5();
subD1940(true);
}
}

void Scene1337::subC51A0(unkObj1337sub1 *subObj1, unkObj1337sub1 *subObj2) {
Expand Down Expand Up @@ -6830,22 +6839,28 @@ void Scene1337::setCursorData(int resNum, int rlbNum, int frameNum) {
if (!frameNum)
return;

uint size;
byte *cursor = g_resourceManager->getSubResource(resNum, rlbNum, frameNum, &size);
// Decode the cursor
GfxSurface s = surfaceFromRes(cursor);
_cursorCurRes = resNum;
_cursorCurStrip = rlbNum;
_cursorCurFrame = frameNum;

if (!frameNum) {
R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS);
} else {
uint size;
byte *cursor = g_resourceManager->getSubResource(resNum, rlbNum, frameNum, &size);
// Decode the cursor
GfxSurface s = surfaceFromRes(cursor);

Graphics::Surface surface = s.lockSurface();
const byte *cursorData = (const byte *)surface.getPixels();
CursorMan.replaceCursor(cursorData, surface.w, surface.h, s._centroid.x, s._centroid.y, s._transColor);
s.unlockSurface();
Graphics::Surface surface = s.lockSurface();
const byte *cursorData = (const byte *)surface.getPixels();
CursorMan.replaceCursor(cursorData, surface.w, surface.h, s._centroid.x, s._centroid.y, s._transColor);
s.unlockSurface();
}
}

void Scene1337::subD18F5() {
if (R2_GLOBALS._v57709 == 0)
// The cursor looks... very dummy
// To be checked
warning("TODO: CursorManager.setData(R2_GLOBALS.off_57705)");
R2_GLOBALS._events.setCursor(CURSOR_CROSSHAIRS);

++R2_GLOBALS._v57709;
}
Expand All @@ -6854,7 +6869,7 @@ void Scene1337::subD1917() {
if (R2_GLOBALS._v57709 != 0) {
R2_GLOBALS._v57709--;
if (R2_GLOBALS._v57709 != 0)
warning("FIXME: subD195F(_width, _data);");
subD195F(_cursorCurStrip, _cursorCurFrame);
}
}

Expand Down
3 changes: 3 additions & 0 deletions engines/tsage/ringworld2/ringworld2_scenes1.h
Expand Up @@ -316,6 +316,9 @@ class Scene1337 : public SceneExt {
int _field424A;
int _instructionsDisplayedFl;
int _instructionsWaitCount;
int _cursorCurRes;
int _cursorCurStrip;
int _cursorCurFrame;

SceneObject _upperDisplayCard[8];
SceneObject _lowerDisplayCard[8];
Expand Down

0 comments on commit a6458ab

Please sign in to comment.