Skip to content

Commit

Permalink
kid selection working again
Browse files Browse the repository at this point in the history
The kid names are now displayed in the sentence line (instead of the verb area) as it is done in the original.
  • Loading branch information
tobigun authored and Travis Howell committed Jan 29, 2012
1 parent d57b483 commit f0b97b9
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 83 deletions.
92 changes: 54 additions & 38 deletions engines/scumm/script_v0.cpp
Expand Up @@ -406,6 +406,42 @@ void ScummEngine_v0::decodeParseString() {
actorTalk(buffer);
}

void ScummEngine_v0::clearSentenceLine() {
Common::Rect sentenceline;
sentenceline.top = _virtscr[kVerbVirtScreen].topline;
sentenceline.bottom = _virtscr[kVerbVirtScreen].topline + 8;
sentenceline.left = 0;
sentenceline.right = _virtscr[kVerbVirtScreen].w - 1;
restoreBackground(sentenceline);
}

void ScummEngine_v0::flushSentenceLine() {
byte string[80];
const char *ptr = _sentenceBuf.c_str();
int i = 0, len = 0;

// Maximum length of printable characters
int maxChars = 40;
while (*ptr) {
if (*ptr != '@')
len++;
if (len > maxChars) {
break;
}

string[i++] = *ptr++;

}
string[i] = 0;

_string[2].charset = 1;
_string[2].ypos = _virtscr[kVerbVirtScreen].topline;
_string[2].xpos = 0;
_string[2].right = _virtscr[kVerbVirtScreen].w - 1;
_string[2].color = 16;
drawString(2, (byte *)string);
}

void ScummEngine_v0::drawSentenceObject(int object) {
const byte *temp;
temp = getObjOrActorName(object);
Expand All @@ -415,20 +451,30 @@ void ScummEngine_v0::drawSentenceObject(int object) {
}
}

void ScummEngine_v0::drawSentence() {
Common::Rect sentenceline;

void ScummEngine_v0::drawSentenceLine() {
if (!(_userState & 32))
return;

clearSentenceLine();

if (_activeVerb == kVerbNewKid) {
_sentenceBuf = "";
for (int i = 0; i < 3; ++i) {
Actor *a = derefActor(VAR(97 + i), "drawSentence");
_sentenceBuf += Common::String::format("%-13s", a->getActorName());
}
flushSentenceLine();
return;
}

// Current Verb
if (_activeVerb == kVerbNone)
_activeVerb = kVerbWalkTo;
if (getResourceAddress(rtVerb, _activeVerb)) {
_sentenceBuf = (char *)getResourceAddress(rtVerb, _activeVerb);
} else {
return;
}

char *verbName = (char *)getResourceAddress(rtVerb, _activeVerb);
assert(verbName);
_sentenceBuf = verbName;

if (_activeObjectNr) {
// Draw the 1st active object
Expand All @@ -454,37 +500,7 @@ void ScummEngine_v0::drawSentence() {
}
}

_string[2].charset = 1;
_string[2].ypos = _virtscr[kVerbVirtScreen].topline;
_string[2].xpos = 0;
_string[2].right = _virtscr[kVerbVirtScreen].w - 1;
_string[2].color = 16;

byte string[80];
const char *ptr = _sentenceBuf.c_str();
int i = 0, len = 0;

// Maximum length of printable characters
int maxChars = 40;
while (*ptr) {
if (*ptr != '@')
len++;
if (len > maxChars) {
break;
}

string[i++] = *ptr++;

}
string[i] = 0;

sentenceline.top = _virtscr[kVerbVirtScreen].topline;
sentenceline.bottom = _virtscr[kVerbVirtScreen].topline + 8;
sentenceline.left = 0;
sentenceline.right = _virtscr[kVerbVirtScreen].w - 1;
restoreBackground(sentenceline);

drawString(2, (byte *)string);
flushSentenceLine();
}

void ScummEngine_v0::o_stopCurrentScript() {
Expand Down
5 changes: 3 additions & 2 deletions engines/scumm/scumm_v0.h
Expand Up @@ -101,10 +101,11 @@ class ScummEngine_v0 : public ScummEngine_v2 {
virtual void handleMouseOver(bool updateInventory);
int verbPrepIdType(int verbid);
void resetVerbs();
void setNewKidVerbs();

void clearSentenceLine();
void flushSentenceLine();
void drawSentenceObject(int object);
void drawSentence();
void drawSentenceLine();

void switchActor(int slot);

Expand Down
62 changes: 19 additions & 43 deletions engines/scumm/verbs.cpp
Expand Up @@ -131,37 +131,6 @@ void ScummEngine_v0::resetVerbs() {
}
}

void ScummEngine_v0::setNewKidVerbs() {
VirtScreen *virt = &_virtscr[kVerbVirtScreen];
VerbSlot *vs;
int i;

for (i = 1; i < 16; i++)
killVerb(i);

for (i = 1; i < 4; i++) {
vs = &_verbs[i];
vs->verbid = i;
vs->color = 5;
vs->hicolor = 7;
vs->dimcolor = 11;
vs->type = kTextVerbType;
vs->charset_nr = _string[0]._default.charset;
vs->curmode = 1;
vs->saveid = 0;
vs->key = 0;
vs->center = 0;
vs->imgindex = 0;
vs->prep = 0;
vs->curRect.left = (i * 8) * 8;
vs->curRect.top = virt->topline + 8;

Actor *a = derefActor(VAR(96 + i), "setNewKidVerbs");
loadPtrToResource(rtVerb, i, (const byte*)a->getActorName());
}
setUserState(191);
}

void ScummEngine_v0::switchActor(int slot) {
resetSentence(false);

Expand Down Expand Up @@ -802,7 +771,24 @@ void ScummEngine_v0::checkExecVerbs() {
// TODO: check keypresses
} else if ((_mouseAndKeyboardStat & MBS_MOUSE_MASK) || _activeVerb == kVerbWhatIs) {
if (zone->number == kVerbVirtScreen && _mouse.y <= zone->topline + 8) {
// TODO: handle click into sentence line
if (_activeVerb == kVerbNewKid) {
if (_currentMode == kModeNormal) {
int kid;
int lineX = _mouse.x >> V12_X_SHIFT;
if (lineX < 11)
kid = 0;
else if (lineX < 25)
kid = 1;
else
kid = 2;
// TODO: get clicked kid
_activeVerb = kVerbWalkTo;
drawSentenceLine();
switchActor(kid);
}
_activeVerb = kVerbWalkTo;
return;
}
} else {
int obj = 0;

Expand Down Expand Up @@ -867,23 +853,13 @@ void ScummEngine_v0::checkExecVerbs() {
}

if (sentenceLineChanged) {
drawSentence();
drawSentenceLine();
sentenceLineChanged = false;
}

if (!execute || !_activeVerb)
return;

if (_activeVerb == kVerbNewKid) {
if (_currentMode == kModeNormal) {
// TODO: get clicked kid
_activeVerb = kVerbWalkTo;
drawSentence();
//switchActor(_verbs[over].verbid - 1);
}
_activeVerb = kVerbWalkTo;
}

if (_activeVerb == kVerbWalkTo)
verbExec();
else if (_activeObjectNr) {
Expand Down

0 comments on commit f0b97b9

Please sign in to comment.