Move "Display Rotation" to display layout editor.

Fix portrait rotation representation in the editor with auto setting.
Minor cleanup.
This commit is contained in:
LunaMoo 2015-11-07 01:10:43 +01:00 committed by Luna
parent 067095e2b4
commit 284600b1a7
5 changed files with 45 additions and 50 deletions

View File

@ -40,49 +40,41 @@ void CenterDisplayOutputRect(float *x, float *y, float *w, float *h, float origW
outW = frameW;
outH = frameH;
} else {
bool fullScreenZoom = true;
#ifndef MOBILE_DEVICE
// This would turn off small display in window mode. I think it's better to allow it.
// fullScreenZoom = g_Config.bFullScreen;
#endif
if (fullScreenZoom) {
if (g_Config.iSmallDisplayZoom != 0) {
float offsetX = (g_Config.fSmallDisplayOffsetX - 0.5f) * 2.0f * frameW;
float offsetY = (g_Config.fSmallDisplayOffsetY - 0.5f) * 2.0f * frameH;
// Have to invert Y for GL
if (GetGPUBackend() == GPUBackend::OPENGL) {
offsetY = offsetY * -1.0f;
}
float customZoom = g_Config.fSmallDisplayCustomZoom / 8.0f;
float smallDisplayW = origW * customZoom;
float smallDisplayH = origH * customZoom;
if (!rotated) {
*x = floorf(((frameW - smallDisplayW) / 2.0f) + offsetX);
*y = floorf(((frameH - smallDisplayH) / 2.0f) + offsetY);
*w = floorf(smallDisplayW);
*h = floorf(smallDisplayH);
return;
} else {
*x = floorf(((frameW - smallDisplayH) / 2.0f) + offsetX);
*y = floorf(((frameH - smallDisplayW) / 2.0f) + offsetY);
*w = floorf(smallDisplayH);
*h = floorf(smallDisplayW);
return;
}
if (g_Config.iSmallDisplayZoom != 0) {
float offsetX = (g_Config.fSmallDisplayOffsetX - 0.5f) * 2.0f * frameW;
float offsetY = (g_Config.fSmallDisplayOffsetY - 0.5f) * 2.0f * frameH;
// Have to invert Y for GL
if (GetGPUBackend() == GPUBackend::OPENGL) {
offsetY = offsetY * -1.0f;
}
float customZoom = g_Config.fSmallDisplayCustomZoom / 8.0f;
float smallDisplayW = origW * customZoom;
float smallDisplayH = origH * customZoom;
if (!rotated) {
*x = floorf(((frameW - smallDisplayW) / 2.0f) + offsetX);
*y = floorf(((frameH - smallDisplayH) / 2.0f) + offsetY);
*w = floorf(smallDisplayW);
*h = floorf(smallDisplayH);
return;
} else {
float pixelCrop = frameH / 270.0f;
float resCommonWidescreen = pixelCrop - floor(pixelCrop);
if (!rotated && resCommonWidescreen == 0.0f) {
*x = 0;
*y = floorf(-pixelCrop);
*w = floorf(frameW);
*h = floorf(pixelCrop * 272.0f);
return;
}
*x = floorf(((frameW - smallDisplayH) / 2.0f) + offsetX);
*y = floorf(((frameH - smallDisplayW) / 2.0f) + offsetY);
*w = floorf(smallDisplayH);
*h = floorf(smallDisplayW);
return;
}
} else {
float pixelCrop = frameH / 270.0f;
float resCommonWidescreen = pixelCrop - floor(pixelCrop);
if (!rotated && resCommonWidescreen == 0.0f) {
*x = 0;
*y = floorf(-pixelCrop);
*w = floorf(frameW);
*h = floorf(pixelCrop * 272.0f);
return;
}
}
float origRatio = !rotated ? origW / origH : origH / origW;
float frameRatio = frameW / frameH;

View File

@ -27,6 +27,7 @@
#include "Core/Config.h"
#include "Core/System.h"
#include "DisplayLayoutEditor.h"
#include "GPU/GLES/Framebuffer.h"
static const int leftColumnWidth = 200;
@ -151,7 +152,6 @@ UI::EventReturn DisplayLayoutScreen::OnZoomChange(UI::EventParams &e) {
return UI::EVENT_DONE;
};
void DisplayLayoutScreen::dialogFinished(const Screen *dialog, DialogResult result) {
RecreateViews();
}
@ -193,10 +193,13 @@ void DisplayLayoutScreen::CreateViews() {
Choice *back = new Choice(di->T("Back"), "", false, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 10));
static const char *zoomLevels[] = { "Auto", "1x", "2x", "3x", "4x", "5x", "6x", "7x", "8x", "9x", "10x" };
zoom_ = new PopupMultiChoice(&g_Config.iSmallDisplayZoom, gr->T("Zoom settings"), zoomLevels, 0, ARRAY_SIZE(zoomLevels), gr->GetName(), screenManager(), new AnchorLayoutParams(300, WRAP_CONTENT, verticalBoundaryPositionL * 2 - 150, NONE, NONE, 10));
zoom_ = new PopupMultiChoice(&g_Config.iSmallDisplayZoom, gr->T("Zoom settings"), zoomLevels, 0, ARRAY_SIZE(zoomLevels), gr->GetName(), screenManager(), new AnchorLayoutParams(300, WRAP_CONTENT, local_dp_xres / 2 - 150, NONE, NONE, 10));
zoom_->OnChoice.Handle(this, &DisplayLayoutScreen::OnZoomChange);
static const char *displayRotation[] = { "Landscape", "Portrait", "Landscape Reversed", "Portrait Reversed" };
rotation_ = new PopupMultiChoice(&g_Config.iInternalScreenRotation, gr->T("Rotation"), displayRotation, 1, ARRAY_SIZE(displayRotation), gr->GetName(), screenManager(), new AnchorLayoutParams(400, WRAP_CONTENT, local_dp_xres / 2 - 200, NONE, NONE, local_dp_yres - 64));
rotation_->SetEnabledPtr(&displayRotEnable_);
displayRotEnable_ = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
mode_ = new ChoiceStrip(ORIENT_VERTICAL, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 158 + 64 + 10));
if (g_Config.iSmallDisplayZoom == 0) {
@ -205,6 +208,10 @@ void DisplayLayoutScreen::CreateViews() {
g_Config.fSmallDisplayCustomZoom = autoBound;
g_Config.fSmallDisplayOffsetX = 0.5f;
g_Config.fSmallDisplayOffsetY = 0.5f;
if (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && (g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180)) {
float autoBound = bounds.h / 480.0f * 8.0f;
g_Config.fSmallDisplayCustomZoom = autoBound;
}
} else {
Choice *center = new Choice(di->T("Center"), "", false, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 84));
center->OnClick.Handle(this, &DisplayLayoutScreen::OnCenter);
@ -218,10 +225,11 @@ void DisplayLayoutScreen::CreateViews() {
back->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
root_->Add(mode_);
root_->Add(zoom_);
root_->Add(rotation_);
root_->Add(back);
displayRepresentation_ = new DragDropDisplay(g_Config.fSmallDisplayOffsetX, g_Config.fSmallDisplayOffsetY, I_PSP_DISPLAY, g_Config.fSmallDisplayCustomZoom);
if (g_Config.iInternalScreenRotation == 2 || g_Config.iInternalScreenRotation == 4) {
if (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE && (g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180)) {
displayRepresentation_->SetAngle(90.0f);
}
root_->Add(displayRepresentation_);

View File

@ -42,6 +42,8 @@ private:
DragDropDisplay *displayRepresentation_;
UI::ChoiceStrip *mode_;
UI::PopupMultiChoice *zoom_;
UI::PopupMultiChoice *rotation_;
bool displayRotEnable_;
// Touch down state for drag to resize etc
float startX_;
float startY_;

View File

@ -194,11 +194,6 @@ void GameSettingsScreen::CreateViews() {
resolutionEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
resolutionChoice_->SetEnabledPtr(&resolutionEnable_);
static const char *displayRotation[] = {"Landscape", "Portrait", "Landscape Reversed", "Portrait Reversed"};
PopupMultiChoice *dispRotChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInternalScreenRotation, gr->T("Display Rotation"), displayRotation, 1, ARRAY_SIZE(displayRotation), co->GetName(), screenManager()));
dispRotChoice->SetEnabledPtr(&displayRotEnable_);
displayRotEnable_ = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
#ifdef ANDROID
static const char *deviceResolutions[] = { "Native device resolution", "Auto (same as Rendering)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" };
int max_res_temp = std::max(System_GetPropertyInt(SYSPROP_DISPLAY_XRES), System_GetPropertyInt(SYSPROP_DISPLAY_YRES)) / 480 + 2;
@ -682,7 +677,6 @@ UI::EventReturn GameSettingsScreen::OnRenderingMode(UI::EventParams &e) {
postProcEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
resolutionEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
displayRotEnable_ = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE);
if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
g_Config.bAutoFrameSkip = false;

View File

@ -115,7 +115,6 @@ private:
bool postProcEnable_;
bool resolutionEnable_;
bool bloomHackEnable_;
bool displayRotEnable_;
};
class DeveloperToolsScreen : public UIDialogScreenWithBackground {