Make Settings look much better in Portrait mode

This commit is contained in:
Henrik Rydgard 2014-07-22 10:37:20 +02:00
parent fe10c64cea
commit 2835110256
4 changed files with 41 additions and 15 deletions

View File

@ -53,6 +53,15 @@
extern bool iosCanUseJit;
#endif
GameSettingsScreen::GameSettingsScreen(std::string gamePath, std::string gameID)
: UIDialogScreenWithGameBackground(gamePath), gameID_(gameID), enableReports_(false) {
lastVertical_ = UseVerticalLayout();
}
bool GameSettingsScreen::UseVerticalLayout() const {
return dp_yres > dp_xres * 1.1f;
}
void GameSettingsScreen::CreateViews() {
GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE);
@ -60,6 +69,8 @@ void GameSettingsScreen::CreateViews() {
iAlternateSpeedPercent_ = (g_Config.iFpsLimit * 100) / 60;
bool vertical = UseVerticalLayout();
// Information in the top left.
// Back button to the bottom left.
// Scrolling action menu to the right.
@ -73,16 +84,22 @@ void GameSettingsScreen::CreateViews() {
I18NCategory *ms = GetI18NCategory("MainSettings");
I18NCategory *dev = GetI18NCategory("Developer");
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
if (vertical) {
root_ = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT));
} else {
root_ = new AnchorLayout(new LayoutParams(FILL_PARENT, FILL_PARENT));
}
ViewGroup *leftColumn = new AnchorLayout(new LinearLayoutParams(1.0f));
root_->Add(leftColumn);
root_->Add(new Choice(d->T("Back"), "", false, new AnchorLayoutParams(150, 64, 10, NONE, NONE, 10)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
TabHolder *tabHolder = new TabHolder(ORIENT_VERTICAL, 200, new AnchorLayoutParams(10, 0, 10, 0, false));
root_->Add(tabHolder);
TabHolder *tabHolder;
if (vertical) {
tabHolder = new TabHolder(ORIENT_HORIZONTAL, 200, new LinearLayoutParams(1.0f));
root_->Add(tabHolder);
root_->Add(new Choice(d->T("Back"), "", false, new LinearLayoutParams(0.0f)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
} else {
tabHolder = new TabHolder(ORIENT_VERTICAL, 200, new AnchorLayoutParams(10, 0, 10, 0, false));
root_->Add(tabHolder);
root_->Add(new Choice(d->T("Back"), "", false, new AnchorLayoutParams(150, 64, 10, NONE, NONE, 10)))->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);
}
root_->SetDefaultFocusView(tabHolder);
// TODO: These currently point to global settings, not game specific ones.
@ -401,7 +418,6 @@ void GameSettingsScreen::CreateViews() {
systemSettings->Add(new ItemHeader(s->T("Cheats", "Cheats (experimental, see forums)")));
systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, s->T("Enable Cheats")));
//#endif
LinearLayout *list = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f)));
systemSettings->SetSpacing(0);
systemSettings->Add(new ItemHeader(s->T("PSP Settings")));
@ -545,6 +561,12 @@ void GameSettingsScreen::update(InputState &input) {
g_Config.iForceMaxEmulatedFPS = cap60FPS_ ? 60 : 0;
g_Config.iFpsLimit = (iAlternateSpeedPercent_ * 60) / 100;
bool vertical = UseVerticalLayout();
if (vertical != lastVertical_) {
RecreateViews();
lastVertical_ = vertical;
}
}
void GameSettingsScreen::sendMessage(const char *message, const char *value) {

View File

@ -24,8 +24,7 @@
// per game.
class GameSettingsScreen : public UIDialogScreenWithGameBackground {
public:
GameSettingsScreen(std::string gamePath, std::string gameID = "")
: UIDialogScreenWithGameBackground(gamePath), gameID_(gameID), enableReports_(false) {}
GameSettingsScreen(std::string gamePath, std::string gameID = "");
virtual void update(InputState &input);
virtual void onFinish(DialogResult result);
@ -37,9 +36,11 @@ protected:
virtual void sendMessage(const char *message, const char *value);
void CallbackRestoreDefaults(bool yes);
bool UseVerticalLayout() const;
private:
std::string gameID_;
bool lastVertical_;
// As we load metadata in the background, we need to be able to update these after the fact.
UI::TextView *tvTitle_;
UI::TextView *tvGameSize_;

View File

@ -17,6 +17,7 @@
#include "GamepadEmu.h"
#include "base/colorutil.h"
#include "base/display.h"
#include "base/NativeApp.h"
#include "math/math_util.h"
#include "ui/virtual_input.h"
@ -339,7 +340,10 @@ void InitPadLayout(float xres, float yres, float globalScale) {
//select, start, throttle--------------------------------------------
//space between the bottom keys (space between select, start and un-throttle)
const int bottom_key_spacing = 100 * scale;
float bottom_key_spacing = 100;
if (dp_xres < 750) {
bottom_key_spacing *= 0.8f;
}
int start_key_X = xres / 2 + (bottom_key_spacing) * scale;
int start_key_Y = yres - 60 * scale;

View File

@ -721,7 +721,6 @@ void MainScreen::CreateViews() {
// Scrolling action menu to the right.
using namespace UI;
// Vertical mode is not finished.
bool vertical = UseVerticalLayout();
I18NCategory *m = GetI18NCategory("MainMenu");