[Scummvm-git-logs] scummvm master -> 0532a6cf9aa0bbf69bc9155019fec0c539e3c583
dreammaster
dreammaster at scummvm.org
Sat Mar 27 03:50:45 UTC 2021
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
98cf7e5bb8 AGS: Register AGSPluginz 1 event handler
445f565589 AGS: Creditz plugin is partially showing credits
ec4e8b4d09 AGS: Fix center aligning credit text
9c22d4ff12 AGS: Move agsplugin.cpp global to Globals
0532a6cf9a AGS: Fix AGSCreditz rendering
Commit: 98cf7e5bb82ffabf5a6048255487ee7bb9ff874a
https://github.com/scummvm/scummvm/commit/98cf7e5bb82ffabf5a6048255487ee7bb9ff874a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-26T20:47:23-07:00
Commit Message:
AGS: Register AGSPluginz 1 event handler
Changed paths:
engines/ags/plugins/ags_creditz/ags_creditz1.cpp
engines/ags/plugins/ags_creditz/ags_creditz1.h
diff --git a/engines/ags/plugins/ags_creditz/ags_creditz1.cpp b/engines/ags/plugins/ags_creditz/ags_creditz1.cpp
index 8d7f170e77..e327f726fc 100644
--- a/engines/ags/plugins/ags_creditz/ags_creditz1.cpp
+++ b/engines/ags/plugins/ags_creditz/ags_creditz1.cpp
@@ -34,6 +34,7 @@ AGSCreditz1::AGSCreditz1() : AGSCreditz() {
DLL_METHOD(AGS_GetPluginName);
DLL_METHOD(AGS_EngineStartup);
+ DLL_METHOD(AGS_EngineOnEvent);
}
const char *AGSCreditz1::AGS_GetPluginName() {
@@ -42,6 +43,7 @@ const char *AGSCreditz1::AGS_GetPluginName() {
void AGSCreditz1::AGS_EngineStartup(IAGSEngine *engine) {
_engine = engine;
+ engine->RequestEventHook(AGSE_POSTSCREENDRAW);
SCRIPT_METHOD(SetCredit);
SCRIPT_METHOD(ScrollCredits);
@@ -66,6 +68,13 @@ void AGSCreditz1::AGS_EngineStartup(IAGSEngine *engine) {
SCRIPT_METHOD(IsStaticCreditsFinished);
}
+int64 AGSCreditz1::AGS_EngineOnEvent(int event, NumberPtr data) {
+ if (event & AGSE_POSTSCREENDRAW)
+ draw();
+
+ return 0;
+}
+
void AGSCreditz1::SetCredit(ScriptMethodParams ¶ms) {
PARAMS7(int, ID, string, credit, int, colour, int, font, int, center, int, xpos, int, generateoutline);
@@ -239,7 +248,7 @@ void AGSCreditz1::ShowStaticCredit(ScriptMethodParams ¶ms) {
} else if (res == 1 || (res == 2 && c.credit != "P=A=U=S=E")) {
if (style == 1) {
// TODO: style 1 setup
- warning("TODO: Use %d %d", transtime, sound);
+ warning("TODO: Use %d %d %d", transtime, time, sound);
}
_engine->GetScreenDimensions(&_state->_screenWidth,
@@ -286,6 +295,10 @@ void AGSCreditz1::IsStaticCreditsFinished(ScriptMethodParams ¶ms) {
params._result = _state->_stSeqSettings[0].finished;
}
+void AGSCreditz1::draw() {
+ // TODO
+}
+
} // namespace AGSCreditz
} // namespace Plugins
} // namespace AGS3
diff --git a/engines/ags/plugins/ags_creditz/ags_creditz1.h b/engines/ags/plugins/ags_creditz/ags_creditz1.h
index 87df63fae3..02d3efe208 100644
--- a/engines/ags/plugins/ags_creditz/ags_creditz1.h
+++ b/engines/ags/plugins/ags_creditz/ags_creditz1.h
@@ -33,6 +33,7 @@ class AGSCreditz1 : public AGSCreditz {
private:
static const char *AGS_GetPluginName();
static void AGS_EngineStartup(IAGSEngine *engine);
+ static int64 AGS_EngineOnEvent(int event, NumberPtr data);
static void SetCredit(ScriptMethodParams ¶ms);
static void ScrollCredits(ScriptMethodParams ¶ms);
@@ -56,6 +57,9 @@ private:
static void SetStaticCreditImage(ScriptMethodParams ¶ms);
static void IsStaticCreditsFinished(ScriptMethodParams ¶ms);
+ static void draw();
+ static void drawStaticCredits();
+
public:
AGSCreditz1();
};
Commit: 445f565589ad845e5ca0c4b5e9e6030856364a09
https://github.com/scummvm/scummvm/commit/445f565589ad845e5ca0c4b5e9e6030856364a09
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-26T20:47:23-07:00
Commit Message:
AGS: Creditz plugin is partially showing credits
Changed paths:
engines/ags/plugins/ags_creditz/ags_creditz.cpp
engines/ags/plugins/ags_creditz/ags_creditz.h
engines/ags/plugins/ags_creditz/ags_creditz1.cpp
engines/ags/plugins/ags_creditz/ags_creditz1.h
engines/ags/plugins/ags_creditz/ags_creditz2.cpp
engines/ags/plugins/ags_creditz/ags_creditz2.h
diff --git a/engines/ags/plugins/ags_creditz/ags_creditz.cpp b/engines/ags/plugins/ags_creditz/ags_creditz.cpp
index c2f94e6946..b3f290003e 100644
--- a/engines/ags/plugins/ags_creditz/ags_creditz.cpp
+++ b/engines/ags/plugins/ags_creditz/ags_creditz.cpp
@@ -21,6 +21,7 @@
*/
#include "ags/plugins/ags_creditz/ags_creditz.h"
+#include "ags/lib/allegro/surface.h"
namespace AGS3 {
namespace Plugins {
@@ -39,6 +40,651 @@ AGSCreditz::~AGSCreditz() {
delete _state;
}
+void AGSCreditz::draw() {
+ int endPoint;
+
+ if (_state->_creditsRunning) {
+ _engine->PollSystem();
+
+ if (!_state->_staticCredits) {
+ // Scrolling credits
+ drawMask(_state->_creditSequence, 0);
+
+ if (_state->_seqSettings[_state->_creditSequence].automatic == 1)
+ endPoint = 0 - _state->_calculatedSequenceHeight;
+ else
+ endPoint = _state->_seqSettings[_state->_creditSequence].endpoint;
+
+ if (_state->_yPos >= endPoint) {
+ doCredits();
+ } else {
+ if (_state->_seqSettings[_state->_creditSequence].endwait > 0 && _state->_timer <= _state->_seqSettings[_state->_creditSequence].endwait) {
+ _state->_paused = true;
+ doCredits();
+ _state->_timer++;
+ return;
+ } else {
+ _state->_paused = false;
+ _state->_timer = 0;
+ _state->_creditsRunning = false;
+ _state->_seqSettings[_state->_creditSequence].finished = true;
+ }
+ }
+
+ drawMask(_state->_creditSequence, 1);
+ } else {
+ // Static credits
+ if (!_state->_singleStatic.bool_) {
+ if (_state->_currentStatic < (int)_state->_stCredits[_state->_creditSequence].size()) {
+ if (_state->_stCredits[_state->_creditSequence][_state->_currentStatic].pause > 0) {
+ // Pause
+ if (_state->_timer <= _state->_stCredits[_state->_creditSequence][_state->_currentStatic].pause) {
+ _state->_timer++;
+ } else {
+ _state->_timer = 0;
+ _state->_currentStatic++;
+ }
+ } else {
+ if (_state->_stCredits[_state->_creditSequence][_state->_currentStatic].image) {
+ // Image
+ if (_state->_timer <= _state->_stCredits[_state->_creditSequence][_state->_currentStatic].image_time) {
+ drawCredit(_state->_creditSequence, _state->_currentStatic);
+ _state->_timer++;
+ } else {
+ _state->_timer = 0;
+ _state->_currentStatic++;
+ if (_state->_stCredits[_state->_creditSequence][_state->_currentStatic].pause <= 0 &&
+ _state->_currentStatic < (int)_state->_stCredits[_state->_creditSequence].size())
+ drawCredit(_state->_creditSequence, _state->_currentStatic);
+ else
+ return;
+ }
+ } else {
+ // Text
+ if (_state->_timer <= (_state->_stSeqSettings[_state->_creditSequence].speed *
+ ((int)_state->_stCredits[_state->_creditSequence][_state->_currentStatic].title.size() +
+ (int)_state->_stCredits[_state->_creditSequence][_state->_currentStatic].credit.size()))) {
+ drawCredit(_state->_creditSequence, _state->_currentStatic);
+ _state->_timer++;
+ } else {
+ _state->_timer = 0;
+ _state->_currentStatic++;
+ if (_state->_stCredits[_state->_creditSequence][_state->_currentStatic].pause <= 0 &&
+ (int)_state->_currentStatic <= (int)_state->_stCredits[_state->_creditSequence].size())
+ drawCredit(_state->_creditSequence, _state->_currentStatic);
+ else
+ return;
+ }
+ }
+ }
+ } else {
+ _state->_stSeqSettings[_state->_creditSequence].finished = true;
+ _state->_creditsRunning = false;
+ _state->_creditSequence = -1;
+ _state->_timer = 0;
+ _state->_currentStatic = 1;
+ return;
+ }
+ } else {
+ // Single Static
+ if (_state->_timer <= _state->_singleStatic.time) {
+ if (_state->_singleStatic.style == 0)
+ drawCredit(_state->_creditSequence, _state->_singleStatic.id);
+ else if (_state->_singleStatic.style == 1)
+ drawStEffects(_state->_creditSequence, _state->_singleStatic.id, _state->_singleStatic.style);
+
+ _state->_timer++;
+ } else {
+ _state->_timer = 0;
+ _state->_singleStatic.bool_ = false;
+ _state->_creditsRunning = false;
+ _state->_staticCredits = false;
+ _state->_stSeqSettings[_state->_creditSequence].finished = true;
+ _state->_creditSequence = -1;
+ }
+ }
+ }
+ }
+}
+
+void AGSCreditz::makeMask(int sequence) {
+ int32 wid, hei, cold;
+ _engine->GetBitmapDimensions(_state->_maskScreen, &wid, &hei, &cold);
+
+ int ys = _state->_seqSettings[sequence].topmask,
+ ye = _state->_seqSettings[sequence].bottommask;
+ // See if ys/ye is ever non-zero
+ assert(ys == 0 && ye == 0);
+
+ _engine->MarkRegionDirty(0, 0, wid, hei);
+}
+
+void AGSCreditz::drawMask(int sequence, int getput) {
+ int32 wid, hei, col;
+
+ if (getput == 0) {
+ _engine->GetScreenDimensions(&wid, &hei, &col);
+ _engine->FreeBitmap(_state->_maski);
+ _state->_maski = _engine->CreateBlankBitmap(wid, hei, col);
+ _engine->FreeBitmap(_state->_creditScreen);
+ _state->_creditScreen = _engine->CreateBlankBitmap(wid, hei, col);
+ _state->_maskScreen = _engine->GetBackgroundScene(_engine->GetCurrentBackground());
+
+ } else if (getput == 1) {
+ _engine->SetVirtualScreen(_state->_maski);
+ makeMask(sequence);
+ _engine->ReleaseBitmapSurface(_state->_maskScreen);
+ }
+}
+
+int AGSCreditz::drawCredit(int sequence, int credit) {
+ int font, color;
+ int32 x_pos, leveys, korkeus = 0;
+ int32 scrn_width, scrn_height, coldepth, y_posit;
+ int slot, sprite_height, sprite_width, linecount, line, others;
+ Common::String text;
+ Common::String teksti;
+ BITMAP *sprite;
+ int result = 0;
+
+ _engine->GetScreenDimensions(&scrn_width, &scrn_height, &coldepth);
+
+ if (!_state->_staticCredits) {
+ // Scrolling Credits
+ if ((_state->_yPos + _state->_sequenceHeight) > scrn_height)
+ return 0;
+
+ if (_state->_credits[sequence][credit]._image) {
+ slot = _state->_credits[sequence][credit]._fontSlot;
+ sprite_height = _state->_credits[sequence][credit]._colorHeight;
+ x_pos = _state->_credits[sequence][credit]._x;
+
+ if (x_pos < 0) {
+ sprite_width = _engine->GetSpriteWidth(slot);
+ x_pos = (scrn_width - sprite_width) / 2;
+ } else {
+ x_pos = VGACheck(x_pos);
+ }
+
+ if (sprite_height < 0)
+ sprite_height = _engine->GetSpriteHeight(slot);
+ else
+ sprite_height = VGACheck(sprite_height);
+
+ korkeus = sprite_height;
+
+ sprite = _engine->GetSpriteGraphic(slot);
+ _engine->BlitBitmap(x_pos, _state->_yPos + _state->_sequenceHeight, sprite, 1);
+
+ } else {
+ font = _state->_credits[sequence][credit]._fontSlot;
+ color = _state->_credits[sequence][credit]._colorHeight;
+ text = _state->_credits[sequence][credit]._text;
+ x_pos = _state->_credits[sequence][credit]._x;
+
+ if (!text.empty()) {
+ _engine->GetTextExtent(font, text.c_str(), &leveys, &korkeus);
+
+ if (x_pos < 0) {
+ x_pos = (scrn_width - leveys) / 2;
+ } else {
+ x_pos = VGACheck(x_pos);
+ }
+
+ if (text.contains('<')) {
+ specialEffect(sequence, credit, text, font, color, x_pos);
+ } else {
+ if (_state->_credits[sequence][credit]._outline) {
+ // Outline
+ _engine->DrawText(x_pos - 1, _state->_yPos + _state->_sequenceHeight, font, 16, text.c_str());
+ _engine->DrawText(x_pos + 1, _state->_yPos + _state->_sequenceHeight, font, 16, text.c_str());
+ _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight - 1, font, 16, text.c_str());
+ _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight + 1, font, 16, text.c_str());
+ }
+
+ _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight, font, color, text.c_str());
+ }
+ }
+ }
+
+ result = korkeus;
+ } else {
+
+ if (_state->_stCredits[sequence][credit].image) {
+ x_pos = _state->_stCredits[sequence][credit].x;
+ y_posit = _state->_stCredits[sequence][credit].y;
+ font = _state->_stCredits[sequence][credit].image_slot;
+
+ sprite = _engine->GetSpriteGraphic(font);
+ _engine->GetBitmapDimensions(sprite, &leveys, &korkeus, &coldepth);
+
+ if (x_pos < 0)
+ x_pos = (scrn_width - leveys) / 2;
+ else
+ x_pos = VGACheck(x_pos);
+ if (y_posit < 0)
+ y_posit = (scrn_height - korkeus) / 2;
+ else
+ y_posit = VGACheck(y_posit);
+
+ _engine->BlitBitmap(x_pos, y_posit, sprite, 1);
+ result = 0;
+ } else {
+ // Title
+ font = _state->_stCredits[sequence][credit].title_font;
+ color = _state->_stCredits[sequence][credit].title_color;
+ text = _state->_stCredits[sequence][credit].title;
+ x_pos = _state->_stCredits[sequence][credit].title_x;
+ y_posit = _state->_stCredits[sequence][credit].title_y;
+
+ if (!text.empty()) {
+ _engine->GetTextExtent(font, text.c_str(), &leveys, &korkeus);
+
+ if (x_pos < 0)
+ x_pos = (scrn_width - leveys) / 2;
+ else
+ x_pos = VGACheck(x_pos);
+ if (y_posit < 0)
+ y_posit = (scrn_height - korkeus) / 2;
+ else
+ y_posit = VGACheck(y_posit);
+
+ if (_state->_stCredits[sequence][credit].title_outline) {
+ _engine->DrawText(x_pos - 1, y_posit, font, 16, text.c_str());
+ _engine->DrawText(x_pos + 1, y_posit, font, 16, text.c_str());
+ _engine->DrawText(x_pos, y_posit - 1, font, 16, text.c_str());
+ _engine->DrawText(x_pos, y_posit + 1, font, 16, text.c_str());
+ }
+
+ _engine->DrawText(x_pos, y_posit, font, color, text.c_str());
+ _engine->MarkRegionDirty(x_pos - 15, y_posit - 15, x_pos + leveys + 15, y_posit + korkeus + 15);
+ }
+
+ // Credit
+ font = _state->_stCredits[sequence][credit].font;
+ color = _state->_stCredits[sequence][credit].color;
+ text = _state->_stCredits[sequence][credit].credit;
+ x_pos = _state->_stCredits[sequence][credit].x;
+ y_posit = _state->_stCredits[sequence][credit].y;
+
+ if (!text.empty()) {
+ _engine->GetTextExtent(font, text.c_str(), &leveys, &korkeus);
+
+ if (!text.contains("[[")) {
+ if (x_pos < 0)
+ x_pos = (scrn_width - leveys) / 2;
+ else
+ x_pos = VGACheck(x_pos);
+ if (y_posit < 0)
+ y_posit = (scrn_height - korkeus) / 2;
+ else
+ y_posit = VGACheck(y_posit);
+
+ if (_state->_stCredits[sequence][credit].outline) {
+ _engine->DrawText(x_pos - 1, y_posit, font, 16, text.c_str());
+ _engine->DrawText(x_pos + 1, y_posit, font, 16, text.c_str());
+ _engine->DrawText(x_pos, y_posit - 1, font, 16, text.c_str());
+ _engine->DrawText(x_pos, y_posit + 1, font, 16, text.c_str());
+ }
+
+ _engine->DrawText(x_pos, y_posit, font, color, text.c_str());
+ _engine->MarkRegionDirty(x_pos - 15, y_posit - 15, x_pos + leveys + 15, y_posit + korkeus + 15);
+ } else {
+ linecount = countLines(text);
+ line = 1;
+ teksti = text;
+ others = 0;
+ if (y_posit < 0)
+ y_posit = (scrn_height - (korkeus * (linecount + 1))) / 2;
+ else
+ y_posit = VGACheck(y_posit);
+
+ while (line <= linecount + 1) {
+ text = extractParameter(teksti, "[[");
+ _engine->GetTextExtent(font, text.c_str(), &leveys, &korkeus);
+
+ if (x_pos < 0)
+ x_pos = (scrn_width - leveys) / 2;
+ else
+ x_pos = VGACheck(x_pos);
+
+ if (_state->_stCredits[sequence][credit].outline) {
+ _engine->DrawText(x_pos - 1, y_posit + others, font, 16, text.c_str());
+ _engine->DrawText(x_pos + 1, y_posit + others, font, 16, text.c_str());
+ _engine->DrawText(x_pos, y_posit + others - 1, font, 16, text.c_str());
+ _engine->DrawText(x_pos, y_posit + others + 1, font, 16, text.c_str());
+ }
+ _engine->DrawText(x_pos, y_posit + others, font, color, text.c_str());
+ _engine->MarkRegionDirty(x_pos, y_posit + others, x_pos + leveys, y_posit + others + korkeus + 15);
+ others += korkeus;
+ x_pos = _state->_stCredits[sequence][credit].x;
+ line++;
+ }
+ }
+ }
+
+ result = 0;
+ }
+ }
+
+ return result;
+}
+
+void AGSCreditz::doCredits() {
+ int current_line;
+ int32 increment, dum;
+
+ current_line = 1;
+ _state->_sequenceHeight = 0;
+
+ while (current_line < (int)_state->_credits[_state->_creditSequence].size()) {
+ if (_state->_credits[_state->_creditSequence][current_line]._isSet) {
+ if (_state->_credits[_state->_creditSequence][current_line]._image) {
+ increment = _engine->GetSpriteHeight(_state->_credits[_state->_creditSequence][current_line]._fontSlot);
+
+ if ((_state->_yPos + _state->_sequenceHeight + increment) <= 0) {
+ if (_state->_credits[_state->_creditSequence][current_line]._colorHeight >= 0)
+ increment = VGACheck(_state->_credits[_state->_creditSequence][current_line]._colorHeight);
+ }
+ } else {
+ _engine->GetTextExtent(_state->_credits[_state->_creditSequence][current_line]._fontSlot,
+ _state->_credits[_state->_creditSequence][current_line]._text.c_str(), &dum, &increment);
+ }
+
+ if ((_state->_yPos + _state->_sequenceHeight + increment) > 0)
+ increment = drawCredit(_state->_creditSequence, current_line);
+
+ } else {
+ increment = VGACheck(_state->_emptyLineHeight);
+ }
+
+ _state->_sequenceHeight += increment;
+ current_line++;
+ }
+
+ if (!_state->_paused)
+ speeder(_state->_creditSequence);
+}
+
+int AGSCreditz::countLines(const Common::String &text) {
+ int lines;
+ Common::String teksti;
+
+ teksti = text;
+ lines = 0;
+ while (teksti.contains("[[")) {
+ extractParameter(teksti, "[[");
+ ++lines;
+ }
+
+ return lines;
+}
+
+Common::String AGSCreditz::extractParameter(Common::String &line, const Common::String &separator) {
+ int p;
+ Common::String result;
+
+ p = line.find(separator, 0);
+ if (p != -1) {
+ if (p > 0) {
+ result = line.substr(0, p);
+ result.trim();
+ }
+
+ line = line.substr(p + separator.size());
+ } else if (!line.empty()) {
+ line.trim();
+ result.clear();
+ }
+
+ return result;
+}
+
+void AGSCreditz::specialEffect(int sequence, int credit, const Common::String &text,
+ int font, int color, int32 x_pos) {
+ Common::String creditt[3];
+ Common::String credit_text, dots;
+ int32 scrn_width, dum, rightside_width, leftside_width, dotwidth;
+ int space, dotcount, dotpos;
+
+ _engine->GetScreenDimensions(&scrn_width, &dum, &dum);
+
+ if (text.contains("<>")) {
+ if (x_pos < 0)
+ x_pos = 0;
+
+ credit_text = text;
+ creditt[0] = extractParameter(credit_text, "<");
+ creditt[1] = extractParameter(credit_text, ">");
+ creditt[2] = credit_text;
+
+ _engine->GetTextExtent(font, creditt[2].c_str(), &rightside_width, &dum);
+
+ if (_state->_credits[sequence][credit]._outline) {
+ _engine->DrawText(x_pos - 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
+ _engine->DrawText(x_pos + 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
+ _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight - 1, font, color, creditt[0].c_str());
+ _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight + 1, font, color, creditt[0].c_str());
+ }
+
+ _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
+
+ if (_state->_credits[sequence][credit]._outline) {
+ _engine->DrawText(scrn_width - (x_pos + rightside_width) - 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
+ _engine->DrawText(scrn_width - (x_pos + rightside_width) + 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
+ _engine->DrawText(scrn_width - (x_pos + rightside_width), _state->_yPos + _state->_sequenceHeight - 1, font, color, creditt[2].c_str());
+ _engine->DrawText(scrn_width - (x_pos + rightside_width), _state->_yPos + _state->_sequenceHeight + 1, font, color, creditt[2].c_str());
+ }
+ _engine->DrawText(scrn_width - (x_pos + rightside_width), _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
+ } else if (text.contains("<.>")) {
+ if (x_pos < 0)
+ x_pos = 0;
+
+ credit_text = text;
+ creditt[0] = extractParameter(credit_text, "<");
+ creditt[1] = extractParameter(credit_text, ">");
+ creditt[2] = credit_text;
+
+ _engine->GetTextExtent(font, creditt[2].c_str(), &rightside_width, &dum);
+ _engine->GetTextExtent(font, creditt[0].c_str(), &leftside_width, &dum);
+
+ if (_state->_credits[sequence][credit]._outline) {
+ _engine->DrawText(x_pos - 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
+ _engine->DrawText(x_pos + 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
+ _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight - 1, font, color, creditt[0].c_str());
+ _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight + 1, font, color, creditt[0].c_str());
+ }
+
+ _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
+
+ if (_state->_credits[sequence][credit]._outline) {
+ _engine->DrawText(scrn_width - (x_pos + rightside_width) - 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
+ _engine->DrawText(scrn_width - (x_pos + rightside_width) + 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
+ _engine->DrawText(scrn_width - (x_pos + rightside_width), _state->_yPos + _state->_sequenceHeight - 1, font, color, creditt[2].c_str());
+ _engine->DrawText(scrn_width - (x_pos + rightside_width), _state->_yPos + _state->_sequenceHeight + 1, font, color, creditt[2].c_str());
+ }
+ _engine->DrawText(scrn_width - (x_pos + rightside_width), _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
+
+ _engine->GetTextExtent(font, " .", &dotwidth, &dum);
+ space = scrn_width - (x_pos + leftside_width + x_pos + rightside_width);
+ dotcount = space / dotwidth;
+ dotpos = 0;
+ dots = "";
+ while (dotpos < dotcount) {
+ dots = dots + " .";
+ dotpos++;
+ }
+
+ if (_state->_credits[sequence][credit]._outline) {
+ _engine->DrawText(x_pos + leftside_width - 1, _state->_yPos + _state->_sequenceHeight, font, color, dots.c_str());
+ _engine->DrawText(x_pos + leftside_width + 1, _state->_yPos + _state->_sequenceHeight, font, color, dots.c_str());
+ _engine->DrawText(x_pos + leftside_width, _state->_yPos + _state->_sequenceHeight - 1, font, color, dots.c_str());
+ _engine->DrawText(x_pos + leftside_width, _state->_yPos + _state->_sequenceHeight + 1, font, color, dots.c_str());
+ }
+ _engine->DrawText(x_pos + leftside_width, _state->_yPos + _state->_sequenceHeight, font, color, dots.c_str());
+ } else if (text.contains("<#>")) {
+ if (x_pos < 0)
+ x_pos = 0;
+
+ credit_text = text;
+ creditt[0] = extractParameter(credit_text, "<");
+ creditt[1] = extractParameter(credit_text, ">");
+ creditt[2] = credit_text;
+
+ _engine->GetTextExtent(font, creditt[2].c_str(), &rightside_width, &dum);
+ _engine->GetTextExtent(font, creditt[0].c_str(), &leftside_width, &dum);
+
+ if (_state->_credits[sequence][credit]._outline) {
+ _engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width - 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
+ _engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width + 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
+ _engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width, _state->_yPos + _state->_sequenceHeight - 1, font, color, creditt[0].c_str());
+ _engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width, _state->_yPos + _state->_sequenceHeight + 1, font, color, creditt[0].c_str());
+ }
+ _engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
+
+ if (_state->_credits[sequence][credit]._outline) {
+ _engine->DrawText(scrn_width / 2 + x_pos / 2 - 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
+ _engine->DrawText(scrn_width / 2 + x_pos / 2 + 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
+ _engine->DrawText(scrn_width / 2 + x_pos / 2, _state->_yPos + _state->_sequenceHeight - 1, font, color, creditt[2].c_str());
+ _engine->DrawText(scrn_width / 2 + x_pos / 2, _state->_yPos + _state->_sequenceHeight + 1, font, color, creditt[2].c_str());
+ }
+ _engine->DrawText(scrn_width / 2 + x_pos / 2, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
+ }
+}
+
+void AGSCreditz::drawStEffects(int sequence, int id, int style) {
+ Common::String teksti;
+ Common::String teksti2;
+ int thischar;
+ Common::String text;
+ int font, color, set1, set2;
+ int32 x_pos, y_posit, scrn_width, leveys, scrn_height, korkeus, coldepth;
+
+ teksti = _state->_stCredits[sequence][id].credit;
+ font = _state->_stCredits[sequence][id].font;
+ color = _state->_stCredits[sequence][id].color;
+ x_pos = _state->_stCredits[sequence][id].x;
+ y_posit = _state->_stCredits[sequence][id].y;
+ set1 = _state->_singleStatic.settings1;
+ set2 = _state->_singleStatic.settings2;
+
+ _engine->GetScreenDimensions(&scrn_width, &scrn_height, &coldepth);
+ _engine->GetTextExtent(font, teksti.c_str(), &leveys, &korkeus);
+
+ if (style == 1) {
+ if (set2 >= 0 && _state->_numChars < (int)teksti.size() && _state->_timer2 == 0) {
+ (*_playSound)(set2);
+ }
+
+ if (_state->_timer2 <= set1) {
+ thischar = 0;
+ if (thischar <= _state->_numChars && _state->_numChars <= (int)teksti.size()) {
+ for (thischar = 0; thischar < _state->_numChars; ++thischar)
+ teksti2 = teksti2 + teksti[thischar];
+ text = teksti2;
+ } else {
+ text = teksti;
+ }
+
+ if (x_pos < 0)
+ x_pos = (scrn_width - leveys) / 2;
+ else
+ x_pos = VGACheck(x_pos);
+ if (y_posit < 0)
+ y_posit = (scrn_height - korkeus) / 2;
+ else
+ y_posit = VGACheck(y_posit);
+
+ _engine->DrawText(x_pos, y_posit, font, color, text.c_str());
+ _state->_timer2++;
+ x_pos = _state->_stCredits[sequence][id].x;
+ y_posit = _state->_stCredits[sequence][id].y;
+ } else {
+ _state->_numChars++;
+ thischar = 0;
+ _state->_timer2 = 0;
+ drawStEffects(sequence, id, style);
+ }
+ }
+}
+
+void AGSCreditz::speeder(int sequence) {
+ int speed = _state->_seqSettings[sequence].speed;
+
+ if (_state->_speedPoint == speed) {
+ _state->_yPos -= VGACheck(1);
+ _state->_speedPoint = 0;
+ } else {
+ _state->_speedPoint++;
+ }
+}
+
+
+void AGSCreditz::calculateSequenceHeight(int sequence) {
+ int32 height, creditHeight, dum;
+ height = 0;
+
+ for (uint currentCredit = 0; currentCredit < _state->_credits[sequence].size();
+ ++currentCredit) {
+
+ if (_state->_credits[sequence][currentCredit]._isSet) {
+ if (_state->_credits[sequence][currentCredit]._image) {
+ if (_state->_credits[sequence][currentCredit]._colorHeight < 0)
+ creditHeight = _engine->GetSpriteHeight(_state->_credits[sequence][currentCredit]._fontSlot);
+ else
+ creditHeight = _state->_credits[sequence][currentCredit]._colorHeight;
+ } else {
+ _engine->GetTextExtent(_state->_credits[sequence][currentCredit]._fontSlot,
+ _state->_credits[sequence][currentCredit]._text.c_str(),
+ &dum, &creditHeight);
+ }
+
+ height += creditHeight;
+ } else {
+ height += VGACheck(_state->_emptyLineHeight);
+ }
+ }
+
+ _state->_calculatedSequenceHeight = height;
+}
+
+int AGSCreditz::VGACheck(int value) {
+ int32 screenX, dum;
+ _engine->GetScreenDimensions(&screenX, &dum, &dum);
+
+ if (screenX == 640)
+ return value * 2;
+ else
+ return value;
+}
+
+void AGSCreditz::startSequence(int sequence) {
+ if (!_state->_creditsRunning) {
+ _state->_seqSettings[sequence].finished = false;
+ _state->_creditsRunning = true;
+ _state->_creditSequence = sequence;
+
+ _engine->GetScreenDimensions(&_state->_screenWidth, &_state->_screenHeight,
+ &_state->_screenColorDepth);
+
+ if (_state->_seqSettings[sequence].automatic) {
+ calculateSequenceHeight(sequence);
+ _state->_yPos = _state->_screenHeight + 1;
+ } else {
+ _state->_yPos = _state->_seqSettings[sequence].startpoint;
+ }
+
+ _state->_speedPoint = 0;
+ _state->_timer = 0;
+ draw();
+ } else {
+ _state->_paused = false;
+ _state->_creditsRunning = false;
+ _state->_creditSequence = -1;
+ _state->_seqSettings[sequence].finished = true;
+ }
+}
+
} // namespace AGSCreditz
} // namespace Plugins
} // namespace AGS3
diff --git a/engines/ags/plugins/ags_creditz/ags_creditz.h b/engines/ags/plugins/ags_creditz/ags_creditz.h
index 153041b798..d70f5fd26b 100644
--- a/engines/ags/plugins/ags_creditz/ags_creditz.h
+++ b/engines/ags/plugins/ags_creditz/ags_creditz.h
@@ -24,6 +24,7 @@
#define AGS_PLUGINS_AGSCREDITZ_AGSCREDITZ_H
#include "ags/plugins/plugin_base.h"
+#include "ags/plugins/ags_creditz/drawing.h"
#include "common/array.h"
#include "common/rect.h"
#include "common/str.h"
@@ -32,6 +33,8 @@ namespace AGS3 {
namespace Plugins {
namespace AGSCreditz {
+typedef int (*IntFunction)(int val1);
+
struct Credit {
Common::String _text;
int _x = 0;
@@ -116,7 +119,19 @@ struct State {
bool _staticWidthMatches = false;
};
-class AGSCreditz : public PluginBase {
+class AGSCreditz : public PluginBase, public Drawing {
+private:
+ static void makeMask(int sequence);
+ static void drawMask(int sequence, int getput);
+ static int drawCredit(int sequence, int credit);
+ static void doCredits();
+ static int countLines(const Common::String &text);
+ static Common::String extractParameter(Common::String &line, const Common::String &separator);
+ static void specialEffect(int sequence, int credit, const Common::String &text,
+ int font, int color, int32 x_pos);
+ static void drawStEffects(int sequence, int id, int style);
+ static void speeder(int sequence);
+
protected:
enum Version {
VERSION_11 = 11, VERSION_20 = 20
@@ -125,6 +140,12 @@ protected:
static Version _version;
static State *_state;
static IAGSEngine *_engine;
+ static IntFunction _playSound;
+
+ static void draw();
+ static void calculateSequenceHeight(int sequence);
+ static int VGACheck(int value);
+ static void startSequence(int sequence);
public:
AGSCreditz();
diff --git a/engines/ags/plugins/ags_creditz/ags_creditz1.cpp b/engines/ags/plugins/ags_creditz/ags_creditz1.cpp
index e327f726fc..14fa0f24cf 100644
--- a/engines/ags/plugins/ags_creditz/ags_creditz1.cpp
+++ b/engines/ags/plugins/ags_creditz/ags_creditz1.cpp
@@ -115,7 +115,6 @@ void AGSCreditz1::ScrollCredits(ScriptMethodParams ¶ms) {
PARAMS7(int, onoff, int, speed, int, fromY, int, toY, int, isautom, int, wait, int, resolution);
if (onoff == 1) {
- _state->_creditsRunning = true;
_state->_seqSettings[0].speed = speed;
_state->_seqSettings[0].endwait = wait;
_state->_seqSettings[0].startpoint = fromY;
@@ -130,6 +129,8 @@ void AGSCreditz1::ScrollCredits(ScriptMethodParams ¶ms) {
_state->_resolutionFlag = (resolution != 1) ? 1 : 0;
}
+ startSequence(0);
+
} else if (onoff == 0) {
_state->_creditsRunning = false;
@@ -146,7 +147,7 @@ void AGSCreditz1::GetCredit(ScriptMethodParams ¶ms) {
}
void AGSCreditz1::IsCreditScrollingFinished(ScriptMethodParams ¶ms) {
- params._result = true;
+ params._result = _state->_seqSettings[0].finished;
}
void AGSCreditz1::PauseScroll(ScriptMethodParams ¶ms) {
@@ -295,10 +296,6 @@ void AGSCreditz1::IsStaticCreditsFinished(ScriptMethodParams ¶ms) {
params._result = _state->_stSeqSettings[0].finished;
}
-void AGSCreditz1::draw() {
- // TODO
-}
-
} // namespace AGSCreditz
} // namespace Plugins
} // namespace AGS3
diff --git a/engines/ags/plugins/ags_creditz/ags_creditz1.h b/engines/ags/plugins/ags_creditz/ags_creditz1.h
index 02d3efe208..c887d28eb1 100644
--- a/engines/ags/plugins/ags_creditz/ags_creditz1.h
+++ b/engines/ags/plugins/ags_creditz/ags_creditz1.h
@@ -57,9 +57,6 @@ private:
static void SetStaticCreditImage(ScriptMethodParams ¶ms);
static void IsStaticCreditsFinished(ScriptMethodParams ¶ms);
- static void draw();
- static void drawStaticCredits();
-
public:
AGSCreditz1();
};
diff --git a/engines/ags/plugins/ags_creditz/ags_creditz2.cpp b/engines/ags/plugins/ags_creditz/ags_creditz2.cpp
index 4efa02f7cd..938a72592f 100644
--- a/engines/ags/plugins/ags_creditz/ags_creditz2.cpp
+++ b/engines/ags/plugins/ags_creditz/ags_creditz2.cpp
@@ -75,30 +75,7 @@ int64 AGSCreditz2::AGS_EngineOnEvent(int event, NumberPtr data) {
void AGSCreditz2::RunCreditSequence(ScriptMethodParams ¶ms) {
PARAMS1(int, sequence);
- if (!_state->_creditsRunning) {
- _state->_seqSettings[sequence].finished = false;
- _state->_creditsRunning = true;
- _state->_creditSequence = sequence;
-
- _engine->GetScreenDimensions(&_state->_screenWidth, &_state->_screenHeight,
- &_state->_screenColorDepth);
-
- if (_state->_seqSettings[sequence].automatic) {
- calculateSequenceHeight(sequence);
- _state->_yPos = _state->_screenHeight + 1;
- } else {
- _state->_yPos = _state->_seqSettings[sequence].startpoint;
- }
-
- _state->_speedPoint = 0;
- _state->_timer = 0;
- draw();
- } else {
- _state->_paused = false;
- _state->_creditsRunning = false;
- _state->_creditSequence = -1;
- _state->_seqSettings[sequence].finished = true;
- }
+ startSequence(sequence);
}
void AGSCreditz2::SetCredit(ScriptMethodParams ¶ms) {
@@ -305,673 +282,6 @@ void AGSCreditz2::GetCurrentStaticCredit(ScriptMethodParams ¶ms) {
params._result = result;
}
-void AGSCreditz2::calculateSequenceHeight(int sequence) {
- int32 height, creditHeight, dum;
- height = 0;
-
- for (uint currentCredit = 0; currentCredit < _state->_credits[sequence].size();
- ++currentCredit) {
-
- if (_state->_credits[sequence][currentCredit]._isSet) {
- if (_state->_credits[sequence][currentCredit]._image) {
- if (_state->_credits[sequence][currentCredit]._colorHeight < 0)
- creditHeight = _engine->GetSpriteHeight(_state->_credits[sequence][currentCredit]._fontSlot);
- else
- creditHeight = _state->_credits[sequence][currentCredit]._colorHeight;
- } else {
- _engine->GetTextExtent(_state->_credits[sequence][currentCredit]._fontSlot,
- _state->_credits[sequence][currentCredit]._text.c_str(),
- &dum, &creditHeight);
- }
-
- height += creditHeight;
- } else {
- height += VGACheck(_state->_emptyLineHeight);
- }
- }
-
- _state->_calculatedSequenceHeight = height;
-}
-
-int AGSCreditz2::VGACheck(int value) {
- int32 screenX, dum;
- _engine->GetScreenDimensions(&screenX, &dum, &dum);
-
- if (screenX == 640)
- return value * 2;
- else
- return value;
-}
-
-void AGSCreditz2::draw() {
- int endPoint;
-
- if (_state->_creditsRunning) {
- _engine->PollSystem();
-
- if (!_state->_staticCredits) {
- // Scrolling credits
- drawMask(_state->_creditSequence, 0);
-
- if (_state->_seqSettings[_state->_creditSequence].automatic == 1)
- endPoint = 0 - _state->_calculatedSequenceHeight;
- else
- endPoint = _state->_seqSettings[_state->_creditSequence].endpoint;
-
- if (_state->_yPos >= endPoint) {
- doCredits();
- } else {
- if (_state->_seqSettings[_state->_creditSequence].endwait > 0 && _state->_timer <= _state->_seqSettings[_state->_creditSequence].endwait) {
- _state->_paused = true;
- doCredits();
- _state->_timer++;
- return;
- } else {
- _state->_paused = false;
- _state->_timer = 0;
- _state->_creditsRunning = false;
- _state->_seqSettings[_state->_creditSequence].finished = true;
- }
- }
-
- drawMask(_state->_creditSequence, 1);
- } else {
- // Static credits
- if (!_state->_singleStatic.bool_) {
- if (_state->_currentStatic < (int)_state->_stCredits[_state->_creditSequence].size()) {
- if (_state->_stCredits[_state->_creditSequence][_state->_currentStatic].pause > 0) {
- // Pause
- if (_state->_timer <= _state->_stCredits[_state->_creditSequence][_state->_currentStatic].pause) {
- _state->_timer++;
- } else {
- _state->_timer = 0;
- _state->_currentStatic++;
- }
- } else {
- if (_state->_stCredits[_state->_creditSequence][_state->_currentStatic].image) {
- // Image
- if (_state->_timer <= _state->_stCredits[_state->_creditSequence][_state->_currentStatic].image_time) {
- drawCredit(_state->_creditSequence, _state->_currentStatic);
- _state->_timer++;
- } else {
- _state->_timer = 0;
- _state->_currentStatic++;
- if (_state->_stCredits[_state->_creditSequence][_state->_currentStatic].pause <= 0 &&
- _state->_currentStatic < (int)_state->_stCredits[_state->_creditSequence].size())
- drawCredit(_state->_creditSequence, _state->_currentStatic);
- else
- return;
- }
- } else {
- // Text
- if (_state->_timer <= (_state->_stSeqSettings[_state->_creditSequence].speed *
- ((int)_state->_stCredits[_state->_creditSequence][_state->_currentStatic].title.size() +
- (int)_state->_stCredits[_state->_creditSequence][_state->_currentStatic].credit.size()))) {
- drawCredit(_state->_creditSequence, _state->_currentStatic);
- _state->_timer++;
- } else {
- _state->_timer = 0;
- _state->_currentStatic++;
- if (_state->_stCredits[_state->_creditSequence][_state->_currentStatic].pause <= 0 &&
- (int)_state->_currentStatic <= (int)_state->_stCredits[_state->_creditSequence].size())
- drawCredit(_state->_creditSequence, _state->_currentStatic);
- else
- return;
- }
- }
- }
- } else {
- _state->_stSeqSettings[_state->_creditSequence].finished = true;
- _state->_creditsRunning = false;
- _state->_creditSequence = -1;
- _state->_timer = 0;
- _state->_currentStatic = 1;
- return;
- }
- } else {
- // Single Static
- if (_state->_timer <= _state->_singleStatic.time) {
- if (_state->_singleStatic.style == 0)
- drawCredit(_state->_creditSequence, _state->_singleStatic.id);
- else if (_state->_singleStatic.style == 1)
- drawStEffects(_state->_creditSequence, _state->_singleStatic.id, _state->_singleStatic.style);
-
- _state->_timer++;
- } else {
- _state->_timer = 0;
- _state->_singleStatic.bool_ = false;
- _state->_creditsRunning = false;
- _state->_staticCredits = false;
- _state->_stSeqSettings[_state->_creditSequence].finished = true;
- _state->_creditSequence = -1;
- }
- }
- }
- }
-}
-
-void AGSCreditz2::makeMask(int sequence) {
- int32 wid, hei, cold;
- int32 x, y;
- uint8 *Bitmap, *Bitmap2, *Bitmap3;
-
- _engine->GetBitmapDimensions(_state->_maskScreen, &wid, &hei, &cold);
- Bitmap = _engine->GetRawBitmapSurface(_state->_maski);
- Bitmap2 = _engine->GetRawBitmapSurface(_state->_maskScreen);
- Bitmap3 = _engine->GetRawBitmapSurface(_state->_creditScreen);
-
- uint32 Pitch = _engine->GetBitmapPitch(_state->_maski);
- uint32 Pitch2 = _engine->GetBitmapPitch(_state->_maskScreen);
- uint32 Pitch3 = _engine->GetBitmapPitch(_state->_creditScreen);
-
- // Top Mask
- {
- x = y = 0;
- while (y <= _state->_seqSettings[sequence].topmask) {
- _engine->PollSystem();
- while (x < wid) {
- drawPixel(Bitmap, x, y, 15, Pitch, cold);
- x++;
- }
-
- x = 0;
- y++;
- }
- }
-
- // Credits Iterator
- x = 0;
- y = _state->_seqSettings[sequence].topmask + 1;
- while (y < _state->_seqSettings[sequence].bottommask) {
- _engine->PollSystem();
- while (x < wid) {
- drawPixel(Bitmap, x, y, getPixelColor(Bitmap3, x, y, Pitch3, cold), Pitch, cold);
- x++;
- }
-
- x = 0;
- y++;
- }
-
- // Bottom Mask
- {
- x = 0;
- y = _state->_seqSettings[sequence].bottommask;
- while (y < hei) {
- _engine->PollSystem();
- while (x < wid) {
- drawPixel(Bitmap, x, y, getPixelColor(Bitmap2, x, y, Pitch2, cold), Pitch, cold);
- x++;
- }
-
- x = 0;
- y++;
- }
- }
-
- _engine->MarkRegionDirty(0, 0, wid, hei);
-}
-
-void AGSCreditz2::drawMask(int sequence, int getput) {
- int32 wid, hei, col;
-
- if (getput == 0) {
- _engine->GetScreenDimensions(&wid, &hei, &col);
- _engine->FreeBitmap(_state->_maski);
- _state->_maski = _engine->CreateBlankBitmap(wid, hei, col);
- _engine->FreeBitmap(_state->_creditScreen);
- _state->_creditScreen = _engine->CreateBlankBitmap(wid, hei, col);
- _state->_maskScreen = _engine->GetBackgroundScene(_engine->GetCurrentBackground());
-
- } else if (getput == 1) {
- _engine->SetVirtualScreen(_state->_maski);
- makeMask(sequence);
- _engine->ReleaseBitmapSurface(_state->_maskScreen);
- }
-}
-
-int AGSCreditz2::drawCredit(int sequence, int credit) {
- int font, color;
- int32 x_pos, leveys, korkeus = 0;
- int32 scrn_width, scrn_height, coldepth, y_posit;
- int slot, sprite_height, sprite_width, linecount, line, others;
- Common::String text;
- Common::String teksti;
- BITMAP *sprite;
- int result = 0;
-
- _engine->GetScreenDimensions(&scrn_width, &scrn_height, &coldepth);
-
- if (!_state->_staticCredits) {
- // Scrolling Credits
- if ((_state->_yPos + _state->_sequenceHeight) > scrn_height)
- return 0;
-
- if (_state->_credits[sequence][credit]._image) {
- slot = _state->_credits[sequence][credit]._fontSlot;
- sprite_height = _state->_credits[sequence][credit]._colorHeight;
- x_pos = _state->_credits[sequence][credit]._x;
-
- if (x_pos < 0) {
- sprite_width = _engine->GetSpriteWidth(slot);
- x_pos = (scrn_width - sprite_width) / 2;
- } else {
- x_pos = VGACheck(x_pos);
- }
-
- if (sprite_height < 0)
- sprite_height = _engine->GetSpriteHeight(slot);
- else
- sprite_height = VGACheck(sprite_height);
-
- korkeus = sprite_height;
-
- sprite = _engine->GetSpriteGraphic(slot);
- _engine->BlitBitmap(x_pos, _state->_yPos + _state->_sequenceHeight, sprite, 1);
-
- } else {
- font = _state->_credits[sequence][credit]._fontSlot;
- color = _state->_credits[sequence][credit]._colorHeight;
- text = _state->_credits[sequence][credit]._text;
- x_pos = _state->_credits[sequence][credit]._x;
-
- if (!text.empty()) {
- _engine->GetTextExtent(font, text.c_str(), &leveys, &korkeus);
-
- if (x_pos < 0) {
- x_pos = (scrn_width - leveys) / 2;
- } else {
- x_pos = VGACheck(x_pos);
- }
-
- if (text.contains('<')) {
- specialEffect(sequence, credit, text, font, color, x_pos);
- } else {
- if (_state->_credits[sequence][credit]._outline) {
- // Outline
- _engine->DrawText(x_pos - 1, _state->_yPos + _state->_sequenceHeight, font, 16, text.c_str());
- _engine->DrawText(x_pos + 1, _state->_yPos + _state->_sequenceHeight, font, 16, text.c_str());
- _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight - 1, font, 16, text.c_str());
- _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight + 1, font, 16, text.c_str());
- }
-
- _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight, font, color, text.c_str());
- }
- }
- }
-
- result = korkeus;
- } else {
-
- if (_state->_stCredits[sequence][credit].image) {
- x_pos = _state->_stCredits[sequence][credit].x;
- y_posit = _state->_stCredits[sequence][credit].y;
- font = _state->_stCredits[sequence][credit].image_slot;
-
- sprite = _engine->GetSpriteGraphic(font);
- _engine->GetBitmapDimensions(sprite, &leveys, &korkeus, &coldepth);
-
- if (x_pos < 0)
- x_pos = (scrn_width - leveys) / 2;
- else
- x_pos = VGACheck(x_pos);
- if (y_posit < 0)
- y_posit = (scrn_height - korkeus) / 2;
- else
- y_posit = VGACheck(y_posit);
-
- _engine->BlitBitmap(x_pos, y_posit, sprite, 1);
- result = 0;
- } else {
- // Title
- font = _state->_stCredits[sequence][credit].title_font;
- color = _state->_stCredits[sequence][credit].title_color;
- text = _state->_stCredits[sequence][credit].title;
- x_pos = _state->_stCredits[sequence][credit].title_x;
- y_posit = _state->_stCredits[sequence][credit].title_y;
-
- if (!text.empty()) {
- _engine->GetTextExtent(font, text.c_str(), &leveys, &korkeus);
-
- if (x_pos < 0)
- x_pos = (scrn_width - leveys) / 2;
- else
- x_pos = VGACheck(x_pos);
- if (y_posit < 0)
- y_posit = (scrn_height - korkeus) / 2;
- else
- y_posit = VGACheck(y_posit);
-
- if (_state->_stCredits[sequence][credit].title_outline) {
- _engine->DrawText(x_pos - 1, y_posit, font, 16, text.c_str());
- _engine->DrawText(x_pos + 1, y_posit, font, 16, text.c_str());
- _engine->DrawText(x_pos, y_posit - 1, font, 16, text.c_str());
- _engine->DrawText(x_pos, y_posit + 1, font, 16, text.c_str());
- }
-
- _engine->DrawText(x_pos, y_posit, font, color, text.c_str());
- _engine->MarkRegionDirty(x_pos - 15, y_posit - 15, x_pos + leveys + 15, y_posit + korkeus + 15);
- }
-
- // Credit
- font = _state->_stCredits[sequence][credit].font;
- color = _state->_stCredits[sequence][credit].color;
- text = _state->_stCredits[sequence][credit].credit;
- x_pos = _state->_stCredits[sequence][credit].x;
- y_posit = _state->_stCredits[sequence][credit].y;
-
- if (!text.empty()) {
- _engine->GetTextExtent(font, text.c_str(), &leveys, &korkeus);
-
- if (!text.contains("[[")) {
- if (x_pos < 0)
- x_pos = (scrn_width - leveys) / 2;
- else
- x_pos = VGACheck(x_pos);
- if (y_posit < 0)
- y_posit = (scrn_height - korkeus) / 2;
- else
- y_posit = VGACheck(y_posit);
-
- if (_state->_stCredits[sequence][credit].outline) {
- _engine->DrawText(x_pos - 1, y_posit, font, 16, text.c_str());
- _engine->DrawText(x_pos + 1, y_posit, font, 16, text.c_str());
- _engine->DrawText(x_pos, y_posit - 1, font, 16, text.c_str());
- _engine->DrawText(x_pos, y_posit + 1, font, 16, text.c_str());
- }
-
- _engine->DrawText(x_pos, y_posit, font, color, text.c_str());
- _engine->MarkRegionDirty(x_pos - 15, y_posit - 15, x_pos + leveys + 15, y_posit + korkeus + 15);
- } else {
- linecount = countLines(text);
- line = 1;
- teksti = text;
- others = 0;
- if (y_posit < 0)
- y_posit = (scrn_height - (korkeus * (linecount + 1))) / 2;
- else
- y_posit = VGACheck(y_posit);
-
- while (line <= linecount + 1) {
- text = extractParameter(teksti, "[[");
- _engine->GetTextExtent(font, text.c_str(), &leveys, &korkeus);
-
- if (x_pos < 0)
- x_pos = (scrn_width - leveys) / 2;
- else
- x_pos = VGACheck(x_pos);
-
- if (_state->_stCredits[sequence][credit].outline) {
- _engine->DrawText(x_pos - 1, y_posit + others, font, 16, text.c_str());
- _engine->DrawText(x_pos + 1, y_posit + others, font, 16, text.c_str());
- _engine->DrawText(x_pos, y_posit + others - 1, font, 16, text.c_str());
- _engine->DrawText(x_pos, y_posit + others + 1, font, 16, text.c_str());
- }
- _engine->DrawText(x_pos, y_posit + others, font, color, text.c_str());
- _engine->MarkRegionDirty(x_pos, y_posit + others, x_pos + leveys, y_posit + others + korkeus + 15);
- others += korkeus;
- x_pos = _state->_stCredits[sequence][credit].x;
- line++;
- }
- }
- }
-
- result = 0;
- }
- }
-
- return result;
-}
-
-void AGSCreditz2::doCredits() {
- int current_line;
- int32 increment, dum;
-
- current_line = 1;
- _state->_sequenceHeight = 0;
-
- while (current_line < (int)_state->_credits[_state->_creditSequence].size()) {
- if (_state->_credits[_state->_creditSequence][current_line]._isSet) {
- if (_state->_credits[_state->_creditSequence][current_line]._image) {
- increment = _engine->GetSpriteHeight(_state->_credits[_state->_creditSequence][current_line]._fontSlot);
-
- if ((_state->_yPos + _state->_sequenceHeight + increment) <= 0) {
- if (_state->_credits[_state->_creditSequence][current_line]._colorHeight >= 0)
- increment = VGACheck(_state->_credits[_state->_creditSequence][current_line]._colorHeight);
- }
- } else {
- _engine->GetTextExtent(_state->_credits[_state->_creditSequence][current_line]._fontSlot,
- _state->_credits[_state->_creditSequence][current_line]._text.c_str(), &dum, &increment);
- }
-
- if ((_state->_yPos + _state->_sequenceHeight + increment) > 0)
- increment = drawCredit(_state->_creditSequence, current_line);
-
- } else {
- increment = VGACheck(_state->_emptyLineHeight);
- }
-
- _state->_sequenceHeight += increment;
- current_line++;
- }
-
- if (!_state->_paused)
- speeder(_state->_creditSequence);
-}
-
-int AGSCreditz2::countLines(const Common::String &text) {
- int lines;
- Common::String teksti;
-
- teksti = text;
- lines = 0;
- while (teksti.contains("[[")) {
- extractParameter(teksti, "[[");
- ++lines;
- }
-
- return lines;
-}
-
-Common::String AGSCreditz2::extractParameter(Common::String &line, const Common::String &separator) {
- int p;
- Common::String result;
-
- p = line.find(separator, 0);
- if (p != -1) {
- if (p > 0) {
- result = line.substr(0, p);
- result.trim();
- }
-
- line = line.substr(p + separator.size());
- } else if (!line.empty()) {
- line.trim();
- result.clear();
- }
-
- return result;
-}
-
-void AGSCreditz2::specialEffect(int sequence, int credit, const Common::String &text,
- int font, int color, int32 x_pos) {
- Common::String creditt[3];
- Common::String credit_text, dots;
- int32 scrn_width, dum, rightside_width, leftside_width, dotwidth;
- int space, dotcount, dotpos;
-
- _engine->GetScreenDimensions(&scrn_width, &dum, &dum);
-
- if (text.contains("<>")) {
- if (x_pos < 0)
- x_pos = 0;
-
- credit_text = text;
- creditt[0] = extractParameter(credit_text, "<");
- creditt[1] = extractParameter(credit_text, ">");
- creditt[2] = credit_text;
-
- _engine->GetTextExtent(font, creditt[2].c_str(), &rightside_width, &dum);
-
- if (_state->_credits[sequence][credit]._outline) {
- _engine->DrawText(x_pos - 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
- _engine->DrawText(x_pos + 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
- _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight - 1, font, color, creditt[0].c_str());
- _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight + 1, font, color, creditt[0].c_str());
- }
-
- _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
-
- if (_state->_credits[sequence][credit]._outline) {
- _engine->DrawText(scrn_width - (x_pos + rightside_width) - 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
- _engine->DrawText(scrn_width - (x_pos + rightside_width) + 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
- _engine->DrawText(scrn_width - (x_pos + rightside_width), _state->_yPos + _state->_sequenceHeight - 1, font, color, creditt[2].c_str());
- _engine->DrawText(scrn_width - (x_pos + rightside_width), _state->_yPos + _state->_sequenceHeight + 1, font, color, creditt[2].c_str());
- }
- _engine->DrawText(scrn_width - (x_pos + rightside_width), _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
- } else if (text.contains("<.>")) {
- if (x_pos < 0)
- x_pos = 0;
-
- credit_text = text;
- creditt[0] = extractParameter(credit_text, "<");
- creditt[1] = extractParameter(credit_text, ">");
- creditt[2] = credit_text;
-
- _engine->GetTextExtent(font, creditt[2].c_str(), &rightside_width, &dum);
- _engine->GetTextExtent(font, creditt[0].c_str(), &leftside_width, &dum);
-
- if (_state->_credits[sequence][credit]._outline) {
- _engine->DrawText(x_pos - 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
- _engine->DrawText(x_pos + 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
- _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight - 1, font, color, creditt[0].c_str());
- _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight + 1, font, color, creditt[0].c_str());
- }
-
- _engine->DrawText(x_pos, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
-
- if (_state->_credits[sequence][credit]._outline) {
- _engine->DrawText(scrn_width - (x_pos + rightside_width) - 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
- _engine->DrawText(scrn_width - (x_pos + rightside_width) + 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
- _engine->DrawText(scrn_width - (x_pos + rightside_width), _state->_yPos + _state->_sequenceHeight - 1, font, color, creditt[2].c_str());
- _engine->DrawText(scrn_width - (x_pos + rightside_width), _state->_yPos + _state->_sequenceHeight + 1, font, color, creditt[2].c_str());
- }
- _engine->DrawText(scrn_width - (x_pos + rightside_width), _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
-
- _engine->GetTextExtent(font, " .", &dotwidth, &dum);
- space = scrn_width - (x_pos + leftside_width + x_pos + rightside_width);
- dotcount = space / dotwidth;
- dotpos = 0;
- dots = "";
- while (dotpos < dotcount) {
- dots = dots + " .";
- dotpos++;
- }
-
- if (_state->_credits[sequence][credit]._outline) {
- _engine->DrawText(x_pos + leftside_width - 1, _state->_yPos + _state->_sequenceHeight, font, color, dots.c_str());
- _engine->DrawText(x_pos + leftside_width + 1, _state->_yPos + _state->_sequenceHeight, font, color, dots.c_str());
- _engine->DrawText(x_pos + leftside_width, _state->_yPos + _state->_sequenceHeight - 1, font, color, dots.c_str());
- _engine->DrawText(x_pos + leftside_width, _state->_yPos + _state->_sequenceHeight + 1, font, color, dots.c_str());
- }
- _engine->DrawText(x_pos + leftside_width, _state->_yPos + _state->_sequenceHeight, font, color, dots.c_str());
- } else if (text.contains("<#>")) {
- if (x_pos < 0)
- x_pos = 0;
-
- credit_text = text;
- creditt[0] = extractParameter(credit_text, "<");
- creditt[1] = extractParameter(credit_text, ">");
- creditt[2] = credit_text;
-
- _engine->GetTextExtent(font, creditt[2].c_str(), &rightside_width, &dum);
- _engine->GetTextExtent(font, creditt[0].c_str(), &leftside_width, &dum);
-
- if (_state->_credits[sequence][credit]._outline) {
- _engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width - 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
- _engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width + 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
- _engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width, _state->_yPos + _state->_sequenceHeight - 1, font, color, creditt[0].c_str());
- _engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width, _state->_yPos + _state->_sequenceHeight + 1, font, color, creditt[0].c_str());
- }
- _engine->DrawText(scrn_width / 2 - x_pos / 2 - leftside_width, _state->_yPos + _state->_sequenceHeight, font, color, creditt[0].c_str());
-
- if (_state->_credits[sequence][credit]._outline) {
- _engine->DrawText(scrn_width / 2 + x_pos / 2 - 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
- _engine->DrawText(scrn_width / 2 + x_pos / 2 + 1, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
- _engine->DrawText(scrn_width / 2 + x_pos / 2, _state->_yPos + _state->_sequenceHeight - 1, font, color, creditt[2].c_str());
- _engine->DrawText(scrn_width / 2 + x_pos / 2, _state->_yPos + _state->_sequenceHeight + 1, font, color, creditt[2].c_str());
- }
- _engine->DrawText(scrn_width / 2 + x_pos / 2, _state->_yPos + _state->_sequenceHeight, font, color, creditt[2].c_str());
- }
-}
-
-void AGSCreditz2::drawStEffects(int sequence, int id, int style) {
- Common::String teksti;
- Common::String teksti2;
- int thischar;
- Common::String text;
- int font, color, set1, set2;
- int32 x_pos, y_posit, scrn_width, leveys, scrn_height, korkeus, coldepth;
-
- teksti = _state->_stCredits[sequence][id].credit;
- font = _state->_stCredits[sequence][id].font;
- color = _state->_stCredits[sequence][id].color;
- x_pos = _state->_stCredits[sequence][id].x;
- y_posit = _state->_stCredits[sequence][id].y;
- set1 = _state->_singleStatic.settings1;
- set2 = _state->_singleStatic.settings2;
-
- _engine->GetScreenDimensions(&scrn_width, &scrn_height, &coldepth);
- _engine->GetTextExtent(font, teksti.c_str(), &leveys, &korkeus);
-
- if (style == 1) {
- if (set2 >= 0 && _state->_numChars < (int)teksti.size() && _state->_timer2 == 0) {
- (*_playSound)(set2);
- }
-
- if (_state->_timer2 <= set1) {
- thischar = 0;
- if (thischar <= _state->_numChars && _state->_numChars <= (int)teksti.size()) {
- for (thischar = 0; thischar < _state->_numChars; ++thischar)
- teksti2 = teksti2 + teksti[thischar];
- text = teksti2;
- } else {
- text = teksti;
- }
-
- if (x_pos < 0)
- x_pos = (scrn_width - leveys) / 2;
- else
- x_pos = VGACheck(x_pos);
- if (y_posit < 0)
- y_posit = (scrn_height - korkeus) / 2;
- else
- y_posit = VGACheck(y_posit);
-
- _engine->DrawText(x_pos, y_posit, font, color, text.c_str());
- _state->_timer2++;
- x_pos = _state->_stCredits[sequence][id].x;
- y_posit = _state->_stCredits[sequence][id].y;
- } else {
- _state->_numChars++;
- thischar = 0;
- _state->_timer2 = 0;
- drawStEffects(sequence, id, style);
- }
- }
-}
-
-void AGSCreditz2::speeder(int sequence) {
- int speed = _state->_seqSettings[sequence].speed;
-
- if (_state->_speedPoint == speed) {
- _state->_yPos -= VGACheck(1);
- _state->_speedPoint = 0;
- } else {
- _state->_speedPoint++;
- }
-}
-
} // namespace AGSCreditz
} // namespace Plugins
} // namespace AGS3
diff --git a/engines/ags/plugins/ags_creditz/ags_creditz2.h b/engines/ags/plugins/ags_creditz/ags_creditz2.h
index 37a4a1adc5..368425384e 100644
--- a/engines/ags/plugins/ags_creditz/ags_creditz2.h
+++ b/engines/ags/plugins/ags_creditz/ags_creditz2.h
@@ -24,17 +24,12 @@
#define AGS_PLUGINS_AGSCREDITZ_AGSCREDITZ2_H
#include "ags/plugins/ags_creditz/ags_creditz.h"
-#include "ags/plugins/ags_creditz/drawing.h"
namespace AGS3 {
namespace Plugins {
namespace AGSCreditz {
-typedef int (*IntFunction)(int val1);
-
-class AGSCreditz2 : public AGSCreditz, public Drawing {
-private:
- static IntFunction _playSound;
+class AGSCreditz2 : public AGSCreditz {
private:
static const char *AGS_GetPluginName();
static void AGS_EngineStartup(IAGSEngine *engine);
@@ -59,20 +54,6 @@ private:
static void SetStaticImage(ScriptMethodParams ¶ms);
static void GetCurrentStaticCredit(ScriptMethodParams ¶ms);
- static void makeMask(int sequence);
- static void drawMask(int sequence, int getput);
- static int drawCredit(int sequence, int credit);
- static void doCredits();
- static int countLines(const Common::String &text);
- static Common::String extractParameter(Common::String &line, const Common::String &separator);
- static void specialEffect(int sequence, int credit, const Common::String &text,
- int font, int color, int32 x_pos);
- static void drawStEffects(int sequence, int id, int style);
- static void speeder(int sequence);
-private:
- static void calculateSequenceHeight(int sequence);
- static int VGACheck(int value);
- static void draw();
public:
AGSCreditz2();
};
Commit: ec4e8b4d09cbf794ed4b2ba93c6a3a66f6064c3c
https://github.com/scummvm/scummvm/commit/ec4e8b4d09cbf794ed4b2ba93c6a3a66f6064c3c
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-26T20:47:23-07:00
Commit Message:
AGS: Fix center aligning credit text
Changed paths:
engines/ags/plugins/ags_creditz/ags_creditz.h
engines/ags/plugins/ags_creditz/ags_creditz1.cpp
diff --git a/engines/ags/plugins/ags_creditz/ags_creditz.h b/engines/ags/plugins/ags_creditz/ags_creditz.h
index d70f5fd26b..d9f5866b28 100644
--- a/engines/ags/plugins/ags_creditz/ags_creditz.h
+++ b/engines/ags/plugins/ags_creditz/ags_creditz.h
@@ -41,7 +41,6 @@ struct Credit {
int _y = 0;
int _fontSlot = 0;
int _colorHeight = 0;
- int _center = 0;
bool _isSet = false;
bool _image = false;
bool _outline = false;
@@ -63,7 +62,6 @@ struct StCredit {
Common::String title;
int x = 0;
int y = 0;
- bool centered = false;
int font = 0;
int color = 0;
int title_x = 0;
diff --git a/engines/ags/plugins/ags_creditz/ags_creditz1.cpp b/engines/ags/plugins/ags_creditz/ags_creditz1.cpp
index 14fa0f24cf..f393af6a6d 100644
--- a/engines/ags/plugins/ags_creditz/ags_creditz1.cpp
+++ b/engines/ags/plugins/ags_creditz/ags_creditz1.cpp
@@ -44,6 +44,8 @@ const char *AGSCreditz1::AGS_GetPluginName() {
void AGSCreditz1::AGS_EngineStartup(IAGSEngine *engine) {
_engine = engine;
engine->RequestEventHook(AGSE_POSTSCREENDRAW);
+ _engine->GetScreenDimensions(&_state->_screenWidth,
+ &_state->_screenHeight, &_state->_screenColorDepth);
SCRIPT_METHOD(SetCredit);
SCRIPT_METHOD(ScrollCredits);
@@ -76,15 +78,20 @@ int64 AGSCreditz1::AGS_EngineOnEvent(int event, NumberPtr data) {
}
void AGSCreditz1::SetCredit(ScriptMethodParams ¶ms) {
- PARAMS7(int, ID, string, credit, int, colour, int, font, int, center, int, xpos, int, generateoutline);
+ PARAMS7(int, ID, string, credit, int, colour, int, font, bool, center, int, xpos, int, generateoutline);
if (ID >= (int)_state->_credits[0].size())
_state->_credits[0].resize(ID + 1);
+ if (center) {
+ int32 creditW, creditH;
+ _engine->GetTextExtent(font, credit, &creditW, &creditH);
+ xpos = (_state->_screenWidth - creditW) / 2;
+ }
+
Credit &c = _state->_credits[0][ID];
c._text = credit;
c._fontSlot = font;
- c._center = center;
c._x = xpos;
c._isSet = true;
c._outline = generateoutline;
@@ -92,21 +99,23 @@ void AGSCreditz1::SetCredit(ScriptMethodParams ¶ms) {
}
void AGSCreditz1::SetCreditImage(ScriptMethodParams ¶ms) {
- PARAMS5(int, ID, int, slot, int, center, int, xpos, int, pixtonext);
+ PARAMS5(int, ID, int, slot, bool, center, int, xpos, int, pixtonext);
if (ID >= (int)_state->_credits[0].size())
_state->_credits[0].resize(ID + 1);
+ BITMAP *gfx = _engine->GetSpriteGraphic(slot);
+ if (center)
+ xpos = (_state->_screenWidth - gfx->w) / 2;
+
_state->_credits[0][ID]._image = true;
_state->_credits[0][ID]._isSet = true;
_state->_credits[0][ID]._x = xpos;
- _state->_credits[0][ID]._center = center;
_state->_credits[0][ID]._fontSlot = slot;
if (pixtonext != -1) {
_state->_credits[0][ID]._colorHeight = pixtonext;
} else {
- BITMAP *gfx = _engine->GetSpriteGraphic(slot);
_state->_credits[0][ID]._colorHeight = gfx->h;
}
}
@@ -121,8 +130,6 @@ void AGSCreditz1::ScrollCredits(ScriptMethodParams ¶ms) {
_state->_seqSettings[0].endpoint = toY;
_state->_seqSettings[0].automatic = isautom;
- _engine->GetScreenDimensions(&_state->_screenWidth,
- &_state->_screenHeight, &_state->_screenColorDepth);
if (_state->_screenWidth == 320) {
_state->_resolutionFlag = (resolution != 2) ? 1 : 0;
} else if (_state->_screenWidth == 640) {
@@ -169,20 +176,25 @@ void AGSCreditz1::GetEmptyLineHeight(ScriptMethodParams ¶ms) {
}
void AGSCreditz1::SetStaticCredit(ScriptMethodParams ¶ms) {
- PARAMS8(int, ID, int, x, int, y, int, creditfont, int, creditcolour, \
- int, centered, int, generateoutline, string, credit);
+ PARAMS8(int, ID, int, x, int, y, int, font, int, creditcolour, \
+ bool, center, int, generateoutline, string, credit);
if (ID >= (int)_state->_credits[0].size())
_state->_credits[0].resize(ID + 1);
+ if (center) {
+ int32 creditW, creditH;
+ _engine->GetTextExtent(font, credit, &creditW, &creditH);
+ x = (_state->_screenWidth - creditW) / 2;
+ }
+
StCredit &c = _state->_stCredits[0][ID];
c.credit = credit;
- c.font = creditfont;
+ c.font = font;
c.color = creditcolour;
c.x = x;
c.y = y;
c.outline = generateoutline;
- c.centered = centered;
}
void AGSCreditz1::GetStaticCredit(ScriptMethodParams ¶ms) {
@@ -279,14 +291,19 @@ void AGSCreditz1::GetStaticCreditTitle(ScriptMethodParams ¶ms) {
void AGSCreditz1::SetStaticCreditImage(ScriptMethodParams ¶ms) {
PARAMS7(int, ID, int, x, int, y, int, slot, int, Hcentered, \
- int, Vcentered, int, time);
+ bool, Vcentered, int, time);
+
+ if (Hcentered) {
+ BITMAP *gfx = _engine->GetSpriteGraphic(slot);
+ if (Hcentered)
+ x = (_state->_screenWidth - gfx->w) / 2;
+ }
StCredit &c = _state->_stCredits[0][ID];
c.credit = "I=M=A=G=E";
c.x = x;
c.y = y;
c.font = slot;
- c.centered = Hcentered;
// TODO: Below seems *weird*
c.outline = Vcentered;
c.color = time;
Commit: 9c22d4ff12639399b2bde5336ed9ce7f54371b05
https://github.com/scummvm/scummvm/commit/9c22d4ff12639399b2bde5336ed9ce7f54371b05
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-26T20:47:24-07:00
Commit Message:
AGS: Move agsplugin.cpp global to Globals
Changed paths:
engines/ags/globals.cpp
engines/ags/globals.h
engines/ags/plugins/agsplugin.cpp
diff --git a/engines/ags/globals.cpp b/engines/ags/globals.cpp
index bf9d42ea4e..5905981149 100644
--- a/engines/ags/globals.cpp
+++ b/engines/ags/globals.cpp
@@ -100,6 +100,9 @@ Globals *g_globals;
Globals::Globals() {
g_globals = this;
+ // agsplugin.cpp globals
+ _glVirtualScreenWrap = new AGS::Shared::Bitmap();
+
// agsstaticobject.cpp globals
_GlobalStaticManager = new AGSStaticObject();
_GameStaticManager = new StaticGame();
@@ -331,6 +334,9 @@ Globals::Globals() {
Globals::~Globals() {
g_globals = nullptr;
+ // agsplugin.cpp globals
+ delete _glVirtualScreenWrap;
+
// agsstaticobject.cpp globals
delete _GlobalStaticManager;
delete _GameStaticManager;
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 0fea69cdec..a93971cd77 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -220,6 +220,15 @@ public:
/**@}*/
+ /**
+ * \defgroup agsplugin globals
+ * @{
+ */
+
+ AGS::Shared::Bitmap *_glVirtualScreenWrap;
+
+ /**@}*/
+
/**
* \defgroup agsstaticobject globals
* @{
diff --git a/engines/ags/plugins/agsplugin.cpp b/engines/ags/plugins/agsplugin.cpp
index 375010c4f3..cede66e99e 100644
--- a/engines/ags/plugins/agsplugin.cpp
+++ b/engines/ags/plugins/agsplugin.cpp
@@ -343,7 +343,6 @@ void IAGSEngine::DrawTextWrapped(int32 xx, int32 yy, int32 wid, int32 font, int3
draw_and_invalidate_text(ds, xx, yy + linespacing * i, font, text_color, _GP(fontLines)[i]);
}
-Bitmap glVirtualScreenWrap;
void IAGSEngine::SetVirtualScreen(BITMAP *bmp) {
if (!_G(gfxDriver)->UsesMemoryBackBuffer()) {
debug_script_warn("SetVirtualScreen: this plugin requires software graphics driver to work correctly.");
@@ -351,10 +350,10 @@ void IAGSEngine::SetVirtualScreen(BITMAP *bmp) {
}
if (bmp) {
- glVirtualScreenWrap.WrapAllegroBitmap(bmp, true);
- _G(gfxDriver)->SetMemoryBackBuffer(&glVirtualScreenWrap);
+ _GP(glVirtualScreenWrap).WrapAllegroBitmap(bmp, true);
+ _G(gfxDriver)->SetMemoryBackBuffer(&_GP(glVirtualScreenWrap));
} else {
- glVirtualScreenWrap.Destroy();
+ _GP(glVirtualScreenWrap).Destroy();
_G(gfxDriver)->SetMemoryBackBuffer(nullptr);
}
}
Commit: 0532a6cf9aa0bbf69bc9155019fec0c539e3c583
https://github.com/scummvm/scummvm/commit/0532a6cf9aa0bbf69bc9155019fec0c539e3c583
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-26T20:47:24-07:00
Commit Message:
AGS: Fix AGSCreditz rendering
The text is now rendered directly to the existing virtual screen,
rather than creating a new one then blitting over the background,
applying the text on it, and then making it the active screen
Changed paths:
engines/ags/plugins/ags_creditz/ags_creditz.cpp
engines/ags/plugins/ags_creditz/ags_creditz.h
diff --git a/engines/ags/plugins/ags_creditz/ags_creditz.cpp b/engines/ags/plugins/ags_creditz/ags_creditz.cpp
index b3f290003e..5fde129882 100644
--- a/engines/ags/plugins/ags_creditz/ags_creditz.cpp
+++ b/engines/ags/plugins/ags_creditz/ags_creditz.cpp
@@ -44,12 +44,11 @@ void AGSCreditz::draw() {
int endPoint;
if (_state->_creditsRunning) {
+ _state->_virtScreen = _engine->GetVirtualScreen();
_engine->PollSystem();
if (!_state->_staticCredits) {
// Scrolling credits
- drawMask(_state->_creditSequence, 0);
-
if (_state->_seqSettings[_state->_creditSequence].automatic == 1)
endPoint = 0 - _state->_calculatedSequenceHeight;
else
@@ -71,7 +70,7 @@ void AGSCreditz::draw() {
}
}
- drawMask(_state->_creditSequence, 1);
+ _engine->MarkRegionDirty(0, 0, _state->_screenWidth, _state->_screenHeight);
} else {
// Static credits
if (!_state->_singleStatic.bool_) {
@@ -147,36 +146,6 @@ void AGSCreditz::draw() {
}
}
-void AGSCreditz::makeMask(int sequence) {
- int32 wid, hei, cold;
- _engine->GetBitmapDimensions(_state->_maskScreen, &wid, &hei, &cold);
-
- int ys = _state->_seqSettings[sequence].topmask,
- ye = _state->_seqSettings[sequence].bottommask;
- // See if ys/ye is ever non-zero
- assert(ys == 0 && ye == 0);
-
- _engine->MarkRegionDirty(0, 0, wid, hei);
-}
-
-void AGSCreditz::drawMask(int sequence, int getput) {
- int32 wid, hei, col;
-
- if (getput == 0) {
- _engine->GetScreenDimensions(&wid, &hei, &col);
- _engine->FreeBitmap(_state->_maski);
- _state->_maski = _engine->CreateBlankBitmap(wid, hei, col);
- _engine->FreeBitmap(_state->_creditScreen);
- _state->_creditScreen = _engine->CreateBlankBitmap(wid, hei, col);
- _state->_maskScreen = _engine->GetBackgroundScene(_engine->GetCurrentBackground());
-
- } else if (getput == 1) {
- _engine->SetVirtualScreen(_state->_maski);
- makeMask(sequence);
- _engine->ReleaseBitmapSurface(_state->_maskScreen);
- }
-}
-
int AGSCreditz::drawCredit(int sequence, int credit) {
int font, color;
int32 x_pos, leveys, korkeus = 0;
diff --git a/engines/ags/plugins/ags_creditz/ags_creditz.h b/engines/ags/plugins/ags_creditz/ags_creditz.h
index d9f5866b28..ad8ba9bbe5 100644
--- a/engines/ags/plugins/ags_creditz/ags_creditz.h
+++ b/engines/ags/plugins/ags_creditz/ags_creditz.h
@@ -106,9 +106,7 @@ struct State {
SequenceSettings _seqSettings[10];
StSequenceSettings _stSeqSettings[10];
SingleStatic _singleStatic;
- BITMAP *_maskScreen = nullptr;
- BITMAP *_maski = nullptr;
- BITMAP *_creditScreen = nullptr;
+ BITMAP *_virtScreen = nullptr;
// Version 1.1 specific
bool _resolutionFlag = false;
@@ -119,8 +117,6 @@ struct State {
class AGSCreditz : public PluginBase, public Drawing {
private:
- static void makeMask(int sequence);
- static void drawMask(int sequence, int getput);
static int drawCredit(int sequence, int credit);
static void doCredits();
static int countLines(const Common::String &text);
More information about the Scummvm-git-logs
mailing list