Skip to content

Commit

Permalink
TSAGE: Fixes for R2R text positioning in conversation dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jul 28, 2013
1 parent d969b1b commit 2fefa91
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 50 deletions.
29 changes: 18 additions & 11 deletions engines/tsage/converse.cpp
Expand Up @@ -424,17 +424,15 @@ ConversationChoiceDialog::ConversationChoiceDialog() {
int ConversationChoiceDialog::execute(const Common::StringArray &choiceList) {
_gfxManager._font.setFontNumber(_fontNumber);

_bounds = Rect(20, 0, 20, 0);
_bounds = Rect(40, 0, 40, 0);
_choiceList.clear();

// Set up the list of choices
int yp = 0;
int xp = (g_vm->getGameID() == GType_Ringworld2) ? 40 : 25;

for (uint idx = 0; idx < choiceList.size(); ++idx) {
Rect tempRect;
_gfxManager._font.getStringBounds(choiceList[idx].c_str(), tempRect, 265);
tempRect.moveTo(xp, yp + 10);
_gfxManager._font.getStringBounds(choiceList[idx].c_str(), tempRect, textMaxWidth());
tempRect.moveTo(textLeft(), yp + 10);

_choiceList.push_back(ChoiceEntry(choiceList[idx], tempRect));
yp += tempRect.height() + 5;
Expand Down Expand Up @@ -515,11 +513,8 @@ void ConversationChoiceDialog::draw() {

// Fill in the contents of the entire dialog
_gfxManager._bounds = Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);

if (g_vm->getGameID() == GType_Ringworld2)
GfxElement::drawFrame();
else
drawFrame();

drawFrame();

_gfxManager._bounds = tempRect;
_gfxManager._font._colors.foreground = _stdColor;
Expand All @@ -530,7 +525,7 @@ void ConversationChoiceDialog::draw() {
Common::String strNum = Common::String::format("%d", idx + 1);

// Write the choice number
_gfxManager._font.setPosition(13, _choiceList[idx]._bounds.top);
_gfxManager._font.setPosition(numberLeft(), _choiceList[idx]._bounds.top);
_gfxManager._font.writeString(strNum.c_str());

_gfxManager._font.writeLines(_choiceList[idx]._msg.c_str(), _choiceList[idx]._bounds, ALIGN_LEFT);
Expand All @@ -551,6 +546,18 @@ void ConversationChoiceDialog::remove() {
}
}

int ConversationChoiceDialog::textLeft() const {
return (g_vm->getGameID() == GType_Ringworld2) ? 20 : 25;
}

int ConversationChoiceDialog::textMaxWidth() const {
return (g_vm->getGameID() == GType_Ringworld2) ? 250 : 265;
}

int ConversationChoiceDialog::numberLeft() const {
return (g_vm->getGameID() == GType_Ringworld2) ? 6 : 13;
}

/*--------------------------------------------------------------------------*/

void Obj44::load(const byte *dataP) {
Expand Down
4 changes: 4 additions & 0 deletions engines/tsage/converse.h
Expand Up @@ -145,6 +145,10 @@ class ChoiceEntry {
};

class ConversationChoiceDialog : public ModalDialog {
private:
int textLeft() const;
int textMaxWidth() const;
int numberLeft() const;
public:
int _stdColor;
int _highlightColor;
Expand Down
78 changes: 41 additions & 37 deletions engines/tsage/dialogs.cpp
Expand Up @@ -137,43 +137,47 @@ void ModalDialog::drawFrame() {
Rect origRect = _bounds;
_bounds.collapse(-10, -10);

// Fill the dialog area
g_globals->gfxManager().fillRect(origRect, 54);

// Draw top line
GfxSurface surface = surfaceFromRes(8, 1, 7);
for (int xp = _bounds.left + 10; xp < (_bounds.right - 20); xp += 10)
surface.draw(Common::Point(xp, _bounds.top));
surface.draw(Common::Point(_bounds.right - 20, _bounds.top));

surface = surfaceFromRes(8, 1, 1);
surface.draw(Common::Point(_bounds.left, _bounds.top));

surface = surfaceFromRes(8, 1, 4);
surface.draw(Common::Point(_bounds.right - 10, _bounds.top));

// Draw vertical edges
surface = surfaceFromRes(8, 1, 2);
for (int yp = _bounds.top + 10; yp < (_bounds.bottom - 20); yp += 10)
surface.draw(Common::Point(_bounds.left, yp));
surface.draw(Common::Point(_bounds.left, _bounds.bottom - 20));

surface = surfaceFromRes(8, 1, 5);
for (int yp = _bounds.top + 10; yp < (_bounds.bottom - 20); yp += 10)
surface.draw(Common::Point(_bounds.right - 10, yp));
surface.draw(Common::Point(_bounds.right - 10, _bounds.bottom - 20));

// Draw bottom line
surface = surfaceFromRes(8, 1, 8);
for (int xp = _bounds.left + 10; xp < (_bounds.right - 20); xp += 10)
surface.draw(Common::Point(xp, _bounds.bottom - 10));
surface.draw(Common::Point(_bounds.right - 20, _bounds.bottom - 10));

surface = surfaceFromRes(8, 1, 3);
surface.draw(Common::Point(_bounds.left, _bounds.bottom - 10));

surface = surfaceFromRes(8, 1, 6);
surface.draw(Common::Point(_bounds.right - 10, _bounds.bottom - 10));
if (g_vm->getGameID() == GType_Ringworld2) {
GfxElement::drawFrame();
} else {
// Fill the dialog area
g_globals->gfxManager().fillRect(origRect, 54);

// Draw top line
GfxSurface surface = surfaceFromRes(8, 1, 7);
for (int xp = _bounds.left + 10; xp < (_bounds.right - 20); xp += 10)
surface.draw(Common::Point(xp, _bounds.top));
surface.draw(Common::Point(_bounds.right - 20, _bounds.top));

surface = surfaceFromRes(8, 1, 1);
surface.draw(Common::Point(_bounds.left, _bounds.top));

surface = surfaceFromRes(8, 1, 4);
surface.draw(Common::Point(_bounds.right - 10, _bounds.top));

// Draw vertical edges
surface = surfaceFromRes(8, 1, 2);
for (int yp = _bounds.top + 10; yp < (_bounds.bottom - 20); yp += 10)
surface.draw(Common::Point(_bounds.left, yp));
surface.draw(Common::Point(_bounds.left, _bounds.bottom - 20));

surface = surfaceFromRes(8, 1, 5);
for (int yp = _bounds.top + 10; yp < (_bounds.bottom - 20); yp += 10)
surface.draw(Common::Point(_bounds.right - 10, yp));
surface.draw(Common::Point(_bounds.right - 10, _bounds.bottom - 20));

// Draw bottom line
surface = surfaceFromRes(8, 1, 8);
for (int xp = _bounds.left + 10; xp < (_bounds.right - 20); xp += 10)
surface.draw(Common::Point(xp, _bounds.bottom - 10));
surface.draw(Common::Point(_bounds.right - 20, _bounds.bottom - 10));

surface = surfaceFromRes(8, 1, 3);
surface.draw(Common::Point(_bounds.left, _bounds.bottom - 10));

surface = surfaceFromRes(8, 1, 6);
surface.draw(Common::Point(_bounds.right - 10, _bounds.bottom - 10));
}

// Set the dialog's manager bounds
_gfxManager._bounds = origRect;
Expand Down
7 changes: 5 additions & 2 deletions engines/tsage/ringworld2/ringworld2_scenes0.cpp
Expand Up @@ -3173,6 +3173,9 @@ bool Scene300::Doorway::startAction(CursorType action, Event &event) {
Scene300::Scene300(): SceneExt() {
_stripId = 0;
_rotation = NULL;

_stripManager.setColors(60, 255);
_stripManager.setFontNumber(3);
}

void Scene300::synchronize(Serializer &s) {
Expand All @@ -3194,8 +3197,6 @@ void Scene300::postInit(SceneObjectList *OwnerList) {
R2_GLOBALS._player._characterIndex = R2_QUINN;
}

_stripManager.setColors(60, 255);
_stripManager.setFontNumber(3);
_stripManager.addSpeaker(&_mirandaSpeaker);
_stripManager.addSpeaker(&_seekerSpeaker);
_stripManager.addSpeaker(&_quinnSpeaker);
Expand Down Expand Up @@ -3627,6 +3628,8 @@ void Scene300::signal() {
case 309:
signal309();
R2_GLOBALS._events.setCursor(CURSOR_ARROW);
R2_GLOBALS._events._currentCursor = CURSOR_ARROW;

_sceneMode = 10;
_stripManager.start3(_stripId, this, R2_GLOBALS._stripManager_lookupList);
break;
Expand Down

0 comments on commit 2fefa91

Please sign in to comment.