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++) {
for(int index = 0; index < noScriptFonts; index++) { Font *font = NULL;
if( scriptPages[sceneIndex].scriptTexts[text].fontId == scriptFonts[index].fontId) { int xOffset, yOffset;
switch(scriptFonts[index].fontType) {
case EFONT2Type: for (int index = 0; index < noScriptFonts; index++) {
font = font2;
break; if (scriptPages[sceneIndex].scriptTexts[text].fontId == scriptFonts[index].fontId) {
case EFONTBIGType:
font = fontbig; switch (scriptFonts[index].fontType) {
break;
case EFONTINYType: case EFONT2Type:
font = fontiny;
break; font = font2;
case EFONTMN1Type:
font = fontmn1; break;
break;
case EFONTMN2Type: case EFONTBIGType:
font = fontmn2;
break; font = fontbig;
break;
case EFONTINYType:
font = fontiny;
break;
case EFONTMN1Type:
font = fontmn1;
break;
case EFONTMN2Type:
font = fontmn2;
break;
}
continue;
}
}
if (scriptPages[sceneIndex].scriptTexts[text].x != -1) {
x = scriptPages[sceneIndex].scriptTexts[text].x;
y = scriptPages[sceneIndex].scriptTexts[text].y;
} }
continue;
if (scriptPages[sceneIndex].scriptTexts[text].textRect.x != -1) {
textRect = scriptPages[sceneIndex].scriptTexts[text].textRect;
x = 0;
y = 0;
} }
}
if(scriptPages[sceneIndex].scriptTexts[text].x != -1) { if (scriptPages[sceneIndex].scriptTexts[text].extraLineHeight != -1) {
x = scriptPages[sceneIndex].scriptTexts[text].x;
y = scriptPages[sceneIndex].scriptTexts[text].y; extraLineHeight = scriptPages[sceneIndex].scriptTexts[text].extraLineHeight;
}
if(scriptPages[sceneIndex].scriptTexts[text].textRect.x != -1) {
textRect = scriptPages[sceneIndex].scriptTexts[text].textRect;
x = 0;
y = 0;
} }
if(scriptPages[sceneIndex].scriptTexts[text].extraLineHeight != -1) { xOffset = ((screenW - 320) >> 1) + textRect.x;
extralineheight = scriptPages[sceneIndex].scriptTexts[text].extraLineHeight; yOffset = ((screenH - 200) >> 1) + textRect.y + y;
}
switch (scriptPages[sceneIndex].scriptTexts[text].alignment) {
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;
case 1: // right break;
{
int width = font->getStringWidth(scriptPages[sceneIndex].scriptTexts[text].text); case 1: // right
font->showString(scriptPages[sceneIndex].scriptTexts[text].text, textRect.x+textRect.w-width, textRect.y+y);
} xOffset += textRect.w - font->getStringWidth(scriptPages[sceneIndex].scriptTexts[text].text);
break;
case 2: // center break;
{
int width = font->getStringWidth(scriptPages[sceneIndex].scriptTexts[text].text)/2; case 2: // center
font->showString(scriptPages[sceneIndex].scriptTexts[text].text, textRect.x+(textRect.w/2)-width,textRect.y+ y);
} xOffset += (textRect.w - font->getStringWidth(scriptPages[sceneIndex].scriptTexts[text].text)) >> 1;
break;
break;
} }
y+=(extralineheight+font->getHeight()/2);
// 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;
}
// 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