nemo's tweaks to bubbles
authorunc0rr
Fri, 01 May 2009 11:58:22 +0000
changeset 2022 9bbf8af42ace
parent 2021 a591afb43768
child 2023 41d3afaa20c7
nemo's tweaks to bubbles
hedgewars/CCHandlers.inc
hedgewars/uStore.pas
--- a/hedgewars/CCHandlers.inc	Fri May 01 09:01:44 2009 +0000
+++ b/hedgewars/CCHandlers.inc	Fri May 01 11:58:22 2009 +0000
@@ -414,7 +414,7 @@
     // If I knew how to add a gear without it becoming immediately active, I'd
     // just create/attach the hedgehog SpeechGear here, then activate it where
     // SpeechType/SpeechText are activated
-    SpeechType:= byte(s[1]);
+    SpeechType:= byte(s[1])-3;
     SpeechText:= text
     end;
 end;
--- a/hedgewars/uStore.pas	Fri May 01 09:01:44 2009 +0000
+++ b/hedgewars/uStore.pas	Fri May 01 11:58:22 2009 +0000
@@ -708,14 +708,14 @@
 cornerWidth:= SpritesData[corner].Width;
 cornerHeight:= SpritesData[corner].Height;
 // This one screws it up
-s:= 'This is the song that never ends.  ''cause it goes on and on my friends. Some people, started singing it not knowing what it was. And they''ll just go on singing it forever just because... This is the song that never ends...';
+//s:= 'This is the song that never ends.  ''cause it goes on and on my friends. Some people, started singing it not knowing what it was. And they''ll just go on singing it forever just because... This is the song that never ends...';
 // This one doesn't
 //s:= 'This is the song that never ends.  cause it goes on and on my friends. Some people, started singing it not knowing what it was. And theyll just go on singing it forever just because... This is the song that never ends... ';
 // Also screws up, but only action
 //s:= 'This is the song that never ends.  cause it goes on and on .';
 // ok in all
 // s:= 'This is the song that never ends.  cause it goes on .';
-numLines:= 1;
+numLines:= 0;
 
 if length(s) = 0 then s:= '...';
 
@@ -730,19 +730,18 @@
         if (s[pos] = #1) or (pos = length(s)) then
             inc(numLines);
 
-    // TODO - find out why this calc doesn't do what I expect
-    if numLines = 2 then textWidth:= w div 2
-    else if numlines > 2 then textWidth:= w div (numLines-1);
+    textWidth:= round(w/(numLines)) + 12;
     end;
 
 textWidth:=((textWidth-(cornerWidth-edgeWidth)*2) div edgeWidth)*edgeWidth+edgeWidth;
-textHeight:=(((numlines * h)-((cornerHeight-edgeWidth)*2)) div edgeWidth)*edgeWidth+edgeWidth;
+textHeight:=(((numlines * h + 2)-((cornerHeight-edgeWidth)*2)) div edgeWidth)*edgeWidth;
 
+textHeight:=max(textHeight,edgeWidth);
 //textWidth:=max(textWidth,SpritesData[tail].Width);
 rect.x:= 0;
 rect.y:= 0;
-rect.w:= textWidth + cornerWidth * 2;
-rect.h:= textHeight + cornerHeight * 2 - edgeHeight + SpritesData[tail].Height;
+rect.w:= textWidth + (cornerWidth * 2);
+rect.h:= textHeight + cornerHeight*2 - edgeHeight + SpritesData[tail].Height;
 //s:= inttostr(h) + ' ' + inttostr(numlines) + ' ' + inttostr(rect.x) + ' '+inttostr(rect.y) + ' ' + inttostr(rect.w) + ' ' + inttostr(rect.h) + ' ' + s;
 
 Result:= SDL_CreateRGBSurface(SDL_SWSURFACE, rect.w, rect.h, 32, RMask, GMask, BMask, AMask);
@@ -828,8 +827,9 @@
         if Length(substr) <> 0 then
            begin
            tmpsurf:= TTF_RenderUTF8_Blended(Fontz[Font].Handle, Str2PChar(substr), cColorNearBlack);
-           rect.x:= edgeHeight;
-           rect.y:= edgeHeight + line * h;
+           rect.x:= edgeHeight+4;
+           // trying to more evenly position the text, vertically
+           rect.y:= max(edgeHeight,3+(rect.h-(numLines*h)) div 2) + line * h;
            SDLTry(tmpsurf <> nil, true);
            SDL_UpperBlit(tmpsurf, nil, Result, @rect);
            SDL_FreeSurface(tmpsurf);