shithub: candycrisis

Download patch

ref: a6136f2f51b7acc325783ac547cea3ee3a619b23
parent: b4805f6e847e719e08e5f75e09b4f6010f7b43b6
author: Iliyas Jorio <[email protected]>
date: Wed Feb 2 16:05:12 EST 2022

Toggle fullscreen mode from pause menu

--- a/src/main.h
+++ b/src/main.h
@@ -12,6 +12,7 @@
 void RefreshAll( void );
 void ReserveMonitor( void );
 void ReleaseMonitor( void );
+void SetFullscreen( MBoolean fullscreenMode );
 void MaskRect( MRect *r );
 void RefreshPlayerWindow( short player );
 MBoolean IsRegistered( void );
@@ -252,6 +253,7 @@
 extern int chain[2];
 extern int blobTime[2], startTime, endTime;
 extern MBoolean finished, pauseKey, showStartMenu;
+extern MBoolean fullscreen;
 extern signed char grid[2][kGridAcross][kGridDown], suction[2][kGridAcross][kGridDown],
 	charred[2][kGridAcross][kGridDown], glow[2][kGridAcross][kGridDown];
 extern MRect playerWindowZRect, playerWindowRect[2];
--- a/src/pause.cpp
+++ b/src/pause.cpp
@@ -515,10 +515,10 @@
 	kNothing = -1,
 	
 // main pause screen (kEndGame is reused in continue and register)
-	kMusic = 0,		kEndGame,
-	kSound,         kControls,
-	kResume,        kSecret,
-	kWarp,
+	kMusic = 0,		kResume,
+	kSound,         kEndGame,
+	kFullscreen,    kControls,
+	kWarp,          kSecret,
 
 // continue screen
     kContinue,      
@@ -719,17 +719,18 @@
 {
 	MPoint dPoint;
 	int index;
-	const char *line[]  = { "\x01 Music",           "\x03 End Game",
-                            "\x01 Sound",           "\x03 Controls",
-                            "\x03 Resume"
+	const char *line[]  = { "\x01 Music",           "\x03 Resume",
+                            "\x01 Sound",           "\x03 End Game",
+                            "\x01 Fullscreen",      "\x03 Controls"
 	};
 
     const int itemCount = arrsize(line);
 	
-	if( level == kTutorialLevel ) line[1] = "\x03 Skip Tutorial";
+	if( level == kTutorialLevel ) line[kEndGame] = "\x03 Skip Tutorial";
 	
-	if( !musicOn ) line[0] = "\x02 Music";
-	if( !soundOn ) line[2] = "\x02 Sound";
+	if( !musicOn ) line[kMusic] = "\x02 Music";
+	if( !soundOn ) line[kSound] = "\x02 Sound";
+	if( !fullscreen ) line[kFullscreen] = "\x02 Fullscreen";
 
 	SDLU_AcquireSurface( drawSurface );	
 	
@@ -891,14 +892,14 @@
 	
 	MRect targetRect[] = 
 	{	
-		{ 240, 180, 260, 320 },
-		{ 240, 340, 260, 480 },
-		{ 270, 180, 290, 320 },
-		{ 270, 340, 290, 480 },
-		{ 300, 180, 320, 320 },
-		{ 300, 340, 320, 480 },
-		{ 330, 180, 350, 320 },
-	    { 120, 550, 130, 560 }
+		{ 240, 180, 260, 320 },  // music
+		{ 240, 340, 260, 480 },  // resume
+		{ 270, 180, 290, 320 },  // sound
+		{ 270, 340, 290, 480 },  // end game
+		{ 300, 180, 320, 320 },  // fullscreen
+		{ 300, 340, 320, 480 },  // controls
+		{ 330, 180, 350, 320 },  // warp
+	    { 330, 340, 350, 480 },  // secret
 	};
 
 	static MBoolean lastDown = false;
@@ -934,12 +935,30 @@
 			
 			switch( *item )
 			{
-				case kSound:     PlayMono( kClick ); soundOn = !soundOn; PlayMono( kClick );     return false;
-				case kMusic:     PlayMono( kClick ); musicOn = !musicOn; EnableMusic( musicOn ); return false;
-				case kEndGame:   PlayMono( kClick );                                             return true;
-				case kResume:    PlayMono( kClick );                                             return true;
-				case kControls:  PlayMono( kClick );                                             return true;
-				
+				case kSound:
+                    PlayMono( kClick );
+                    soundOn = !soundOn;
+                    PlayMono( kClick );
+                    return false;
+
+				case kMusic:
+                    PlayMono( kClick );
+                    musicOn = !musicOn;
+                    EnableMusic( musicOn );
+                    return false;
+
+				case kFullscreen:
+                    fullscreen = !fullscreen;
+                    SetFullscreen( fullscreen );
+                    PlayMono( kClick );
+                    return false;
+
+                case kEndGame:
+				case kResume:
+                case kControls:
+                    PlayMono( kClick );
+                    return true;
+
 				case kSecret:
 					if( ControlKeyIsPressed( ) )
 					{
--- a/src/prefs.cpp
+++ b/src/prefs.cpp
@@ -41,7 +41,8 @@
     { PREF_NAME("SoundOn"),        &soundOn,     sizeof(MBoolean  ) },
     { PREF_NAME("KeyBindings"),    playerKeys,   sizeof(playerKeys) },
     { PREF_NAME("HighScores"),     scores,       sizeof(scores    ) },
-    { PREF_NAME("BestCombo"),      &best,        sizeof(best      ) }
+    { PREF_NAME("BestCombo"),      &best,        sizeof(best      ) },
+    { PREF_NAME("Fullscreen"),     &fullscreen,  sizeof(fullscreen) },
 };
 
 #if !__APPLE__ && !_WIN32