ref: c04d757f24fa4505208f00a4c9bf2f6054ad800f
parent: 74ce8304ef22c094c169e714c2c5ee0543c3e02d
author: Iliyas Jorio <[email protected]>
date: Sat Aug 1 11:08:54 EDT 2020
Widescreen mode
--- a/src/SDLU.cpp
+++ b/src/SDLU.cpp
@@ -30,6 +30,8 @@
// for event loop
static MBoolean s_isForeground = true;
+
+extern MBoolean widescreen;
// for checktyping
struct BufferedKey
@@ -433,8 +435,12 @@
{
SDL_UpdateTexture(g_windowTexture, NULL, g_frontSurface->pixels, g_frontSurface->pitch);
SDL_RenderClear(g_renderer);
- SDL_RenderCopy(g_renderer, g_windowTexture, NULL, NULL);
+
+ SDL_Rect crop {0,60,640,360};
+
+ SDL_RenderCopy(g_renderer, g_windowTexture, widescreen ? &crop : NULL, NULL);
SDL_RenderPresent(g_renderer);
+
s_fpsAccumulator++;
int now = SDL_GetTicks();
int elapsed = now - s_fpsSampleStart;
--- a/src/hiscore.cpp
+++ b/src/hiscore.cpp
@@ -28,6 +28,8 @@
using std::min;
+extern MBoolean widescreen;
+
Combo defaultBest =
{
/*bestGrid[kGridAcross][kGridDown] = */
@@ -220,7 +222,6 @@
hiScoreSurface = LoadPICTAsSurface( picBackdrop + (100 * RandomBefore(kLevels)), 32 );
fadeSurface = SDLU_InitSurface( &fullSDLRect, 32 );
- font = GetFont( picHiScoreFont );
SDLU_AcquireSurface( hiScoreSurface );
@@ -230,13 +231,15 @@
anyColor.g = min( 255, anyColor.g + 112 );
anyColor.b = min( 255, anyColor.b + 112 );
- dPoint.v = 20;
+ dPoint.v = widescreen? 100: 20;
dPoint.h = 225;
+ font = GetFont( picHiScoreFont );
for( count=0; highScores[count]; count++ )
{
SurfaceBlitCharacter( font, highScores[count], &dPoint, 255, 255, 255, 1 );
}
+ font = GetFont(widescreen ? picFont : picHiScoreFont);
for( count=0; count<=9; count++ )
{
r = ((255 * (10-count)) + (anyColor.r * count)) / 10;
@@ -243,7 +246,10 @@
g = ((255 * (10-count)) + (anyColor.g * count)) / 10;
b = ((255 * (10-count)) + (anyColor.b * count)) / 10;
- dPoint.v = 75 + count * 38;
+ if (widescreen)
+ dPoint.v = 150 + count * 24;
+ else
+ dPoint.v = 75 + count * 38;
dPoint.h = 85;
if( count<9 )
@@ -327,8 +333,6 @@
MPoint dPoint;
int levelCap;
- font = GetFont( picHiScoreFont );
-
StopBalloon( );
InitGame( kAutoControl, kNobodyControl );
scoreWindowVisible[0] = false;
@@ -348,7 +352,8 @@
SDLU_AcquireSurface( backdropSurface );
- dPoint.v = 40;
+ font = GetFont(picHiScoreFont);
+ dPoint.v = widescreen? 70: 40;
dPoint.h = 225;
for( scan = bestCombo; *scan; scan++ )
{
@@ -356,7 +361,9 @@
}
sprintf( bestInfo, "%s (%d points)", best.name, best.value );
- dPoint.v = 410;
+
+ font = GetFont(widescreen ? picFont : picHiScoreFont);
+ dPoint.v = widescreen? 388: 410;
dPoint.h = 320 - (GetTextWidth( font, bestInfo ) / 2);
for( scan = bestInfo; *scan; scan++ )
--- a/src/level.cpp
+++ b/src/level.cpp
@@ -72,6 +72,7 @@
const int kCursorHeight = 32;
extern MBoolean useNewTitle;
+extern MBoolean widescreen;
static void InsertCursor( MPoint mouseHere, SDL_Surface* scratch, SDL_Surface* surface )
{
@@ -275,8 +276,9 @@
// Get cursor position
SDLU_GetMouse( &mouse );
- if( mouse.v > 460 ) mouse.v = 460;
-
+ if( mouse.v > (widescreen ? 400 : 460) )
+ mouse.v = (widescreen ? 400 : 460);
+
// Erase falling blobs
for( blob=0; blob<kNumSplats; blob++ )
{
@@ -362,14 +364,15 @@
{
if( splatState[blob] == kFallingSplat )
{
- if( splatBlob[blob].bottom >= 480 )
+ int bottom = widescreen? 420: 480;
+ if( splatBlob[blob].bottom >= bottom )
{
- splatBlob[blob].top = 480 - kBlobVertSize;
- splatBlob[blob].bottom = 480;
+ splatBlob[blob].top = bottom - kBlobVertSize;
+ splatBlob[blob].bottom = bottom;
splatState[blob] = 1;
- // Process combos
- if( mouse.v > 420 &&
+ // Process combos
+ if( mouse.v > bottom &&
mouse.h >= (splatBlob[blob].left - 30) &&
mouse.h <= (splatBlob[blob].right + 10) )
{
@@ -703,6 +706,17 @@
CenterRectOnScreen( &opponentWindowRect, 0.5, 0.5 );
}
+ // In widescreen mode, move score/gray windows closer to the playfield
+ // so they fit in the cropped screen.
+ if (widescreen) {
+ for (int i = 0; i < 2; i++) {
+ grayMonitorRect[i].top = playerWindowRect[i].top - 32 - 4;
+ grayMonitorRect[i].bottom = playerWindowRect[i].top - 4;
+ scoreWindowRect[i].top = playerWindowRect[i].bottom + 4;
+ scoreWindowRect[i].bottom = playerWindowRect[i].bottom + 16 + 4;
+ }
+ }
+
nextWindowVisible[0] = ( player1 == kAutoControl )? false: true;
players = (player1 == kPlayerControl) + (player2 == kPlayerControl);
@@ -1196,6 +1210,17 @@
{ "", "" },
{ "Thanks for playing Candy Crisis!", "" },
};
+
+ // In widescreen mode, move vertical text positions closer to the center
+ if (widescreen) {
+ for (auto& dp : dPoint) {
+ if (dp.v >= 130) {
+ dp.v -= 20;
+ } else {
+ dp.v += 20;
+ }
+ }
+ }
textFont = GetFont( picFont );
titleFont = GetFont( picHiScoreFont );
@@ -1207,7 +1232,11 @@
{
for( line=0; line<2; line++ )
{
- msgSetPoint[picture][line].v = ((dPoint[picture].v == 230)? 100: 400) + (line * 30);
+ if (dPoint[picture].v >= 130) {
+ msgSetPoint[picture][line].v = (widescreen? 120: 100) + line * 30;
+ } else {
+ msgSetPoint[picture][line].v = (widescreen? 380: 300) + line * 30;
+ }
msgSetPoint[picture][line].h = 320 - (GetTextWidth( titleFont, messages[picture][line] ) / 2);
}
binary files a/src/main.cpp b/src/main.cpp differ
--- a/src/tutorial.cpp
+++ b/src/tutorial.cpp
@@ -311,7 +311,7 @@
{ kComplete, 0, 0, NULL }
};
-MRect balloonRect = {0, 0, 190, 210};
+MRect balloonRect = {0, 0, 208, 236};
SkittlesFontPtr balloonFont;
MPoint balloonPt;
char* balloonChar;
@@ -432,7 +432,7 @@
SurfaceCurveEdges( balloonSurface, &balloonContentsRect );
balloonTip.v = balloonContentsRect.bottom - 2;
- balloonTip.h = balloonContentsRect.right - 40;
+ balloonTip.h = balloonContentsRect.right - 60;
balloonFill = balloonTip;
SurfaceBlitCharacter( balloonFont, '\x01', &balloonFill, 0, 0, 0, 0 );