added simple credits support for the intro.

svn-id: r44047
This commit is contained in:
Vladimir Menshakov 2009-09-13 09:54:53 +00:00
parent 94d7dad3af
commit e53de46b4f
6 changed files with 58 additions and 8 deletions

View file

@ -73,6 +73,10 @@ bool Resources::loadArchives(const ADGameDescription * gd) {
sam_sam.open("sam_sam.res");
font7.load(7);
font7.width_pack = 1;
font7.height = 10;
font8.load(8);
font8.height = 31;
return true;
}

View file

@ -49,7 +49,7 @@ public:
Pack varia, off, on, ons, lan000, lan500, mmm, sam_mmm, sam_sam;
Segment cseg, dseg, eseg;
Font font7;
Font font7, font8;
};
} // End of namespace TeenAgent

View file

@ -276,6 +276,17 @@ bool Scene::processEvent(const Common::Event &event) {
bool Scene::render(OSystem * system) {
//render background
Resources * res = Resources::instance();
if (current_event.type == SceneEvent::CreditsMessage) {
system->fillScreen(0);
Graphics::Surface * surface = system->lockScreen();
res->font8.color = current_event.color;
res->font8.shadow_color = current_event.orientation;
res->font8.render(surface, current_event.dst.x, current_event.dst.y, message);
system->unlockScreen();
return true;
}
bool busy = false;
system->copyRectToScreen((const byte *)background.pixels, background.pitch, 0, 0, background.w, background.h);
@ -373,7 +384,7 @@ bool Scene::render(OSystem * system) {
*/
if (!message.empty()) {
Resources::instance()->font7.render(surface, message_pos.x, message_pos.y, message);
res->font7.render(surface, message_pos.x, message_pos.y, message);
busy = true;
}
@ -439,11 +450,12 @@ bool Scene::processEventQueue() {
moveTo(dst, current_event.orientation);
} break;
case SceneEvent::Message: {
case SceneEvent::CreditsMessage:
case SceneEvent::Message:
//debug(0, "pop(%04x)", current_event.message);
message = current_event.message;
message_pos = messagePosition(message, position);
} break;
break;
case SceneEvent::PlayAnimation: {
debug(0, "playing animation %u", current_event.animation);

View file

@ -43,7 +43,7 @@ struct SceneEvent {
None, Message, Walk, PlayAnimation, PlayActorAnimation,
LoadScene, SetOn, SetLan, PlayMusic,
PlaySound, EnableObject, WaitForAnimation,
Quit
CreditsMessage, Quit
} type;
Common::String message;

View file

@ -329,8 +329,9 @@ Object * TeenAgentEngine::findObject(int id, const Common::Point &point) {
}
void TeenAgentEngine::displayMessage(const Common::String &str, byte color) {
if (str.empty())
if (str.empty()) {
return;
}
SceneEvent event(SceneEvent::Message);
event.message = str;
event.color = color;
@ -338,7 +339,7 @@ void TeenAgentEngine::displayMessage(const Common::String &str, byte color) {
}
void TeenAgentEngine::displayMessage(uint16 addr, byte color) {
Common::String TeenAgentEngine::parseMessage(uint16 addr) {
Common::String message;
for (
const char * str = (const char *)Resources::instance()->dseg.ptr(addr);
@ -348,7 +349,37 @@ void TeenAgentEngine::displayMessage(uint16 addr, byte color) {
char c = str[0];
message += c != 0 && c != -1? c: '\n';
}
displayMessage(message, color);
if (message.empty()) {
warning("empty message parsed for %04x", addr);
}
return message;
}
void TeenAgentEngine::displayMessage(uint16 addr, byte color) {
displayMessage(parseMessage(addr), color);
}
void TeenAgentEngine::displayCredits(uint16 addr) {
SceneEvent event(SceneEvent::CreditsMessage);
const byte * src = Resources::instance()->dseg.ptr(addr);
event.orientation = *src++;
event.color = *src++;
event.dst.y = *src;
while(true) {
++src; //skip y position
Common::String line((const char *)src);
event.message += line;
src += line.size() + 1;
if (*src == 0)
break;
event.message += "\n";
}
int w = Resources::instance()->font8.render(NULL, 0, 0, event.message);
event.dst.x = (320 - w) / 2;
scene->push(event);
}
void TeenAgentEngine::moveTo(const Common::Point & dst, byte o, bool warp) {

View file

@ -64,9 +64,12 @@ public:
bool processCallback(uint16 addr);
inline Scene * getScene() { return scene; }
static Common::String parseMessage(uint16 addr);
//event driven:
void displayMessage(uint16 addr, byte color = 0xd1);
void displayMessage(const Common::String &str, byte color = 0xd1);
void displayCredits(uint16 addr);
void moveTo(const Common::Point & dst, byte o, bool warp = false);
void moveTo(uint16 x, uint16 y, byte o, bool warp = false);
void moveTo(Object * obj);