Skip to content

Commit

Permalink
front: Fixed additional resolution issue in portrait mode.
Browse files Browse the repository at this point in the history
Also, made the ratio for 16:9 to 4:3 be a dynamic value instead of
hardcoded.
  • Loading branch information
fzurita committed Dec 17, 2015
1 parent ce821fa commit 5a5b092
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
19 changes: 16 additions & 3 deletions src/paulscode/android/mupen64plusae/persistent/GamePrefs.java
Expand Up @@ -14,6 +14,7 @@
import paulscode.android.mupen64plusae.util.Plugin; import paulscode.android.mupen64plusae.util.Plugin;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.text.TextUtils; import android.text.TextUtils;


public class GamePrefs public class GamePrefs
Expand Down Expand Up @@ -175,7 +176,7 @@ public class GamePrefs
public int videoRenderWidth; public int videoRenderWidth;


/** The height of the OpenGL rendering context, in pixels. */ /** The height of the OpenGL rendering context, in pixels. */
public final int videoRenderHeight; public int videoRenderHeight;


/** The zoom value applied to the viewing surface, in percent. */ /** The zoom value applied to the viewing surface, in percent. */
public final int videoSurfaceZoom; public final int videoSurfaceZoom;
Expand Down Expand Up @@ -331,8 +332,20 @@ public GamePrefs( Context context, String romMd5, String crc, String headerName,


if(globalPrefs.mStretch) if(globalPrefs.mStretch)
{ {
float newWidth = videoRenderWidth * 1.333333f; //If we are in stretch mode we have to increase the approppriate dimension by the corresponding
videoRenderWidth = Math.round(newWidth); //ratio to make it full screen
if(globalPrefs.displayOrientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT ||
globalPrefs.displayOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT)
{

float newWidth = videoRenderHeight * globalPrefs.heightRatio;
videoRenderHeight = Math.round(newWidth);
}
else
{
float newWidth = videoRenderWidth * globalPrefs.widthRatio;
videoRenderWidth = Math.round(newWidth);
}
} }


videoSurfaceZoom = getSafeInt( mPreferences, "displayZoom", 100 ); videoSurfaceZoom = getSafeInt( mPreferences, "displayZoom", 100 );
Expand Down
10 changes: 9 additions & 1 deletion src/paulscode/android/mupen64plusae/persistent/GlobalPrefs.java
Expand Up @@ -181,6 +181,12 @@ public class GlobalPrefs
/** The height of the viewing surface, in pixels with the correct aspect ratio. */ /** The height of the viewing surface, in pixels with the correct aspect ratio. */
public final int videoSurfaceHeightOriginal; public final int videoSurfaceHeightOriginal;


/** Screen width ratio from 16:9 to 4:3*/
public final float widthRatio;

/** Screen width ratio from 16:9 to 4:3*/
public final float heightRatio;

/** The action bar transparency value. */ /** The action bar transparency value. */
public final int displayActionBarTransparency; public final int displayActionBarTransparency;


Expand Down Expand Up @@ -462,13 +468,15 @@ else if( AppData.IS_KITKAT && isImmersiveModeEnabled )
stretchWidth = dimensions.x; stretchWidth = dimensions.x;
stretchHeight = dimensions.y; stretchHeight = dimensions.y;
} }

float aspect = 0.75f; // TODO: Handle PAL float aspect = 0.75f; // TODO: Handle PAL
boolean isLetterboxed = ( (float) stretchHeight / (float) stretchWidth ) > aspect; boolean isLetterboxed = ( (float) stretchHeight / (float) stretchWidth ) > aspect;
int originalWidth = isLetterboxed ? stretchWidth : Math.round( (float) stretchHeight / aspect ); int originalWidth = isLetterboxed ? stretchWidth : Math.round( (float) stretchHeight / aspect );
int originalHeight = isLetterboxed ? Math.round( (float) stretchWidth * aspect ) : stretchHeight; int originalHeight = isLetterboxed ? Math.round( (float) stretchWidth * aspect ) : stretchHeight;


String scaling = mPreferences.getString( "displayScaling", "original" ); String scaling = mPreferences.getString( "displayScaling", "original" );
widthRatio = (float)stretchWidth/(float)originalWidth;
heightRatio = (float)stretchHeight/(float)originalHeight;


videoSurfaceWidthOriginal = originalWidth; videoSurfaceWidthOriginal = originalWidth;
videoSurfaceHeightOriginal = originalHeight; videoSurfaceHeightOriginal = originalHeight;
Expand Down

0 comments on commit 5a5b092

Please sign in to comment.