Commit 59956ced authored by alistert's avatar alistert

Fixed cutscene text positioning in higher resolutions.

parent c1b3814a
...@@ -734,6 +734,7 @@ int Scene::play () { ...@@ -734,6 +734,7 @@ int Scene::play () {
SDL_Rect textRect = {0,0,320,200}; SDL_Rect textRect = {0,0,320,200};
while (true) { while (true) {
if (loop(NORMAL_LOOP) == E_QUIT) return E_QUIT; if (loop(NORMAL_LOOP) == E_QUIT) return E_QUIT;
if (controls.release(C_ESCAPE)) { if (controls.release(C_ESCAPE)) {
...@@ -741,7 +742,9 @@ int Scene::play () { ...@@ -741,7 +742,9 @@ int Scene::play () {
return E_NONE; return E_NONE;
} }
SDL_Delay(T_FRAME); SDL_Delay(T_FRAME);
int upOrLeft = (controls.release(C_UP) || controls.release(C_LEFT)); int upOrLeft = (controls.release(C_UP) || controls.release(C_LEFT));
if((sceneIndex > 0 && upOrLeft) || controls.release(C_RIGHT) || controls.release(C_DOWN) || controls.release(C_ENTER) || if((sceneIndex > 0 && upOrLeft) || controls.release(C_RIGHT) || controls.release(C_DOWN) || controls.release(C_ENTER) ||
((globalTicks-lastTicks)>=pageTime*1000 && pageTime != 256 && pageTime != 0)) { ((globalTicks-lastTicks)>=pageTime*1000 && pageTime != 256 && pageTime != 0)) {
...@@ -801,75 +804,128 @@ int Scene::play () { ...@@ -801,75 +804,128 @@ int Scene::play () {
} else { } else {
clearScreen(0); clearScreen(0);
} }
if(fadein)
{
fadein = false;
firstPE = new FadeInPaletteEffect(250, firstPE);
}
// Draw the texts associated with this page // Draw the texts associated with this page
int x = 0; int x = 0;
int y = 0; int y = 0;
int extralineheight = 0; int extraLineHeight = 0;
for(int text = 0;text<scriptPages[sceneIndex].noScriptTexts;text++) {
Font* font = NULL; for (int text = 0; text < scriptPages[sceneIndex].noScriptTexts; text++) {
Font *font = NULL;
int xOffset, yOffset;
for (int index = 0; index < noScriptFonts; index++) {
if (scriptPages[sceneIndex].scriptTexts[text].fontId == scriptFonts[index].fontId) {
switch (scriptFonts[index].fontType) {
for(int index = 0; index < noScriptFonts; index++) {
if( scriptPages[sceneIndex].scriptTexts[text].fontId == scriptFonts[index].fontId) {
switch(scriptFonts[index].fontType) {
case EFONT2Type: case EFONT2Type:
font = font2; font = font2;
break; break;
case EFONTBIGType: case EFONTBIGType:
font = fontbig; font = fontbig;
break; break;
case EFONTINYType: case EFONTINYType:
font = fontiny; font = fontiny;
break; break;
case EFONTMN1Type: case EFONTMN1Type:
font = fontmn1; font = fontmn1;
break; break;
case EFONTMN2Type: case EFONTMN2Type:
font = fontmn2; font = fontmn2;
break; break;
} }
continue; continue;
} }
} }
if(scriptPages[sceneIndex].scriptTexts[text].x != -1) { if (scriptPages[sceneIndex].scriptTexts[text].x != -1) {
x = scriptPages[sceneIndex].scriptTexts[text].x; x = scriptPages[sceneIndex].scriptTexts[text].x;
y = scriptPages[sceneIndex].scriptTexts[text].y; y = scriptPages[sceneIndex].scriptTexts[text].y;
} }
if(scriptPages[sceneIndex].scriptTexts[text].textRect.x != -1) { if (scriptPages[sceneIndex].scriptTexts[text].textRect.x != -1) {
textRect = scriptPages[sceneIndex].scriptTexts[text].textRect; textRect = scriptPages[sceneIndex].scriptTexts[text].textRect;
x = 0; x = 0;
y = 0; y = 0;
} }
if(scriptPages[sceneIndex].scriptTexts[text].extraLineHeight != -1) { if (scriptPages[sceneIndex].scriptTexts[text].extraLineHeight != -1) {
extralineheight = scriptPages[sceneIndex].scriptTexts[text].extraLineHeight;
extraLineHeight = scriptPages[sceneIndex].scriptTexts[text].extraLineHeight;
} }
switch(scriptPages[sceneIndex].scriptTexts[text].alignment) xOffset = ((screenW - 320) >> 1) + textRect.x;
{ yOffset = ((screenH - 200) >> 1) + textRect.y + y;
switch (scriptPages[sceneIndex].scriptTexts[text].alignment) {
case 0: // left case 0: // left
font->showString(scriptPages[sceneIndex].scriptTexts[text].text, textRect.x+x,textRect.y+y);
xOffset += x;
break; break;
case 1: // right case 1: // right
{
int width = font->getStringWidth(scriptPages[sceneIndex].scriptTexts[text].text); xOffset += textRect.w - font->getStringWidth(scriptPages[sceneIndex].scriptTexts[text].text);
font->showString(scriptPages[sceneIndex].scriptTexts[text].text, textRect.x+textRect.w-width, textRect.y+y);
}
break; break;
case 2: // center case 2: // center
{
int width = font->getStringWidth(scriptPages[sceneIndex].scriptTexts[text].text)/2; xOffset += (textRect.w - font->getStringWidth(scriptPages[sceneIndex].scriptTexts[text].text)) >> 1;
font->showString(scriptPages[sceneIndex].scriptTexts[text].text, textRect.x+(textRect.w/2)-width,textRect.y+ y);
}
break; break;
}
// Drop shadow
font->mapPalette(0, 256, 0, 1);
font->showString(scriptPages[sceneIndex].scriptTexts[text].text, xOffset + 1, yOffset + 1);
font->restorePalette();
// Text itself
font->showString(scriptPages[sceneIndex].scriptTexts[text].text, xOffset, yOffset);
y += extraLineHeight + font->getHeight() / 2;
} }
y+=(extralineheight+font->getHeight()/2);
// Fade in from black
if (fadein) {
fadein = false;
firstPE = new FadeInPaletteEffect(250, firstPE);
clearScreen(0);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment