diff --git a/Core/Config.cpp b/Core/Config.cpp index d146e97bcd..a902d0c515 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -110,6 +110,9 @@ void Config::Load(const char *iniFileName) #else graphics->Get("AnisotropyLevel", &iAnisotropyLevel, 8); #endif + if (iAnisotropyLevel > 4) { + iAnisotropyLevel = 4; + } graphics->Get("VertexCache", &bVertexCache, true); #ifdef _WIN32 graphics->Get("FullScreen", &bFullScreen, false); @@ -191,6 +194,7 @@ void Config::Save() // Need to do this somewhere... bFirstRun = false; general->Set("FirstRun", bFirstRun); + general->Set("NewUI", bNewUI); general->Set("AutoLoadLast", bAutoLoadLast); general->Set("AutoRun", bAutoRun); diff --git a/Core/Config.h b/Core/Config.h index 54f6ab7c2b..6d47f0d657 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -83,7 +83,7 @@ public: #ifdef _WIN32 bool bFullScreenOnLaunch; #endif - int iAnisotropyLevel; + int iAnisotropyLevel; // 0 - 5, powers of 2: 0 = 1x = no aniso bool bTrueColor; bool bFramebuffersToMem; bool bFramebuffersCPUConvert; // for OpenGL devices diff --git a/GPU/GLES/TextureCache.cpp b/GPU/GLES/TextureCache.cpp index e9d372e79f..b43f447878 100644 --- a/GPU/GLES/TextureCache.cpp +++ b/GPU/GLES/TextureCache.cpp @@ -1183,7 +1183,8 @@ void TextureCache::SetTexture() { #endif } - float anisotropyLevel = (float) g_Config.iAnisotropyLevel > maxAnisotropyLevel ? maxAnisotropyLevel : (float) g_Config.iAnisotropyLevel; + int aniso = 1 << g_Config.iAnisotropyLevel; + float anisotropyLevel = (float) aniso > maxAnisotropyLevel ? maxAnisotropyLevel : (float) aniso; glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, anisotropyLevel); UpdateSamplingParams(*entry, true); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 3e174cb6ef..a3562ee2a5 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -19,12 +19,73 @@ #include "i18n/i18n.h" #include "ui/view.h" #include "ui/viewgroup.h" +#include "ui/ui_context.h" #include "UI/EmuScreen.h" #include "UI/PluginScreen.h" #include "UI/GameSettingsScreen.h" #include "UI/GameInfoCache.h" +#include "UI/MiscScreens.h" #include "Core/Config.h" +namespace UI { + +// Reads and writes value to determine the current selection. +class PopupMultiChoice : public Choice { +public: + PopupMultiChoice(int *value, const std::string &text, const char **choices, int numChoices, + I18NCategory *category, ScreenManager *screenManager, LayoutParams *layoutParams = 0) + : Choice(text, "", false, layoutParams), value_(value), choices_(choices), numChoices_(numChoices), + category_(category), screenManager_(screenManager) { + OnClick.Handle(this, &PopupMultiChoice::HandleClick); + UpdateText(); + } + + virtual void Draw(UIContext &dc); + +private: + void UpdateText(); + EventReturn HandleClick(EventParams &e); + + void ChoiceCallback(int num); + + const char **choices_; + int numChoices_; + int *value_; + ScreenManager *screenManager_; + I18NCategory *category_; + std::string valueText_; +}; + +EventReturn PopupMultiChoice::HandleClick(EventParams &e) { + std::vector choices; + for (size_t i = 0; i < numChoices_; i++) { + choices.push_back(category_ ? category_->T(choices_[i]) : choices_[i]); + } + + Screen *popupScreen = new ListPopupScreen(text_, choices, *value_, + std::bind(&PopupMultiChoice::ChoiceCallback, this, placeholder::_1)); + screenManager_->push(popupScreen); + return EVENT_DONE; +} + +void PopupMultiChoice::UpdateText() { + valueText_ = category_ ? category_->T(choices_[*value_]) : choices_[*value_]; +} + +void PopupMultiChoice::ChoiceCallback(int num) { + *value_ = num; + UpdateText(); +} + +void PopupMultiChoice::Draw(UIContext &dc) { + Choice::Draw(dc); + dc.Draw()->DrawText(dc.theme->uiFont, valueText_.c_str(), bounds_.x2() - 8, bounds_.centerY(), 0xFFFFFFFF, ALIGN_RIGHT | ALIGN_VCENTER); +} + + +} + + void GameSettingsScreen::CreateViews() { GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); @@ -58,6 +119,7 @@ void GameSettingsScreen::CreateViews() { ViewGroup *graphicsSettings = new LinearLayout(ORIENT_VERTICAL); graphicsSettingsScroll->Add(graphicsSettings); tabHolder->AddTab("Graphics", graphicsSettingsScroll); + graphicsSettings->Add(new ItemHeader(gs->T("Features"))); graphicsSettings->Add(new CheckBox(&g_Config.bStretchToDisplay, gs->T("Stretch to Display"))); graphicsSettings->Add(new CheckBox(&g_Config.bBufferedRendering, gs->T("Buffered Rendering"))); graphicsSettings->Add(new CheckBox(&g_Config.bDisplayFramebuffer, gs->T("Display Raw Framebuffer"))); @@ -65,15 +127,47 @@ void GameSettingsScreen::CreateViews() { graphicsSettings->Add(new CheckBox(&g_Config.bVertexCache, gs->T("Vertex Cache"))); graphicsSettings->Add(new CheckBox(&g_Config.bUseVBO, gs->T("Stream VBO"))); graphicsSettings->Add(new CheckBox(&g_Config.SSAntiAliasing, gs->T("Anti Aliasing"))); - // graphicsSettings->Add(new CheckBox(&g_Config.iShowFPSCounter, gs->T("Show FPS"))); + graphicsSettings->Add(new CheckBox(&g_Config.bFramebuffersToMem, gs->T("Read Framebuffer to memory"))); + graphicsSettings->Add(new ItemHeader(gs->T("Texture filtering"))); + + static const char *anisoLevels[] = { + "Off", "2 samples", "4 samples", "8 samples", "16 samples" + }; + graphicsSettings->Add(new PopupMultiChoice(&g_Config.iAnisotropyLevel, gs->T("Anisotropic Filtering"), anisoLevels, 5, gs, screenManager())); + graphicsSettings->Add(new ItemHeader(gs->T("Texture scaling"))); + + static const char *texScaleLevels[] = { + "bad", "1x", "2x", "3x", +#ifndef USING_GLES2 + "4x", "5x", +#endif + }; + //graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexScalingLevel, gs->T("Scale"), anisoLevels, 5, gs, screenManager())); + + static const char *texScaleAlgos[] = { + "xBRZ", "Hybrid", "Bicubic", "Hybrid + Bicubic", + }; + graphicsSettings->Add(new PopupMultiChoice(&g_Config.iTexScalingType, gs->T("Texture Scaling Type"), texScaleAlgos, 4, gs, screenManager())); + + + +#ifdef USING_GLES2 + g_Config.bFramebuffersCPUConvert = g_Config.bFramebuffersToMem; +#endif + +#ifdef _WIN32 + graphicsSettings->Add(new CheckBox(&g_Config.bAutoSaveSymbolMap, gs->T("VSync"))); +#endif + + ViewGroup *audioSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); ViewGroup *audioSettings = new LinearLayout(ORIENT_VERTICAL); audioSettingsScroll->Add(audioSettings); tabHolder->AddTab("Audio", audioSettingsScroll); + audioSettings->Add(new Choice(a->T("Download Atrac3+ plugin")))->OnClick.Handle(this, &GameSettingsScreen::OnDownloadPlugin); audioSettings->Add(new CheckBox(&g_Config.bEnableSound, a->T("Enable Sound"))); audioSettings->Add(new CheckBox(&g_Config.bEnableAtrac3plus, a->T("Enable Atrac3+"))); - audioSettings->Add(new Choice(a->T("Download Atrac3+ plugin")))->OnClick.Handle(this, &GameSettingsScreen::OnDownloadPlugin); ViewGroup *controlsSettingsScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, FILL_PARENT)); ViewGroup *controlsSettings = new LinearLayout(ORIENT_VERTICAL); @@ -100,6 +194,45 @@ UI::EventReturn GameSettingsScreen::OnDownloadPlugin(UI::EventParams &e) { void DrawBackground(float alpha); void GameSettingsScreen::DrawBackground(UIContext &dc) { - GameInfo *info = g_gameInfoCache.GetInfo(gamePath_, true); + ::DrawBackground(1.0f); +} + +void GlobalSettingsScreen::CreateViews() { + using namespace UI; + root_ = new ScrollView(ORIENT_VERTICAL); + + I18NCategory *g = GetI18NCategory("General"); + I18NCategory *gs = GetI18NCategory("Graphics"); + + LinearLayout *list = root_->Add(new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(1.0f))); + list->Add(new ItemHeader("General")); + list->Add(new CheckBox(&g_Config.bNewUI, gs->T("New UI"))); + + static const char *fpsChoices[] = { + "None", "Speed", "FPS", "Both" + }; + + list->Add(new PopupMultiChoice(&g_Config.iShowFPSCounter, gs->T("Show FPS"), fpsChoices, 4, gs, screenManager())); + list->Add(new Choice(gs->T("Language")))->OnClick.Handle(this, &GlobalSettingsScreen::OnLanguage); + + list->Add(new Choice(g->T("Back")))->OnClick.Handle(this, &GlobalSettingsScreen::OnBack); +} + +UI::EventReturn GlobalSettingsScreen::OnFactoryReset(UI::EventParams &e) { + screenManager()->push(new PluginScreen()); + return UI::EVENT_DONE; +} + +UI::EventReturn GlobalSettingsScreen::OnLanguage(UI::EventParams &e) { + screenManager()->push(new NewLanguageScreen()); + return UI::EVENT_DONE; +} + +UI::EventReturn GlobalSettingsScreen::OnBack(UI::EventParams &e) { + screenManager()->finishDialog(this, DR_OK); + return UI::EVENT_DONE; +} + +void GlobalSettingsScreen::DrawBackground(UIContext &dc) { ::DrawBackground(1.0f); } diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 196b5c6556..272c16457a 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -31,7 +31,6 @@ protected: virtual void DrawBackground(UIContext &dc); private: - // Event handlers UI::EventReturn OnDownloadPlugin(UI::EventParams &e); std::string gamePath_, gameID_; @@ -39,4 +38,20 @@ private: // As we load metadata in the background, we need to be able to update these after the fact. UI::TextView *tvTitle_; UI::TextView *tvGameSize_; +}; + +// TODO: Move to its own file. +class GlobalSettingsScreen : public UIScreen { +public: + GlobalSettingsScreen() {} + +protected: + virtual void CreateViews(); + virtual void DrawBackground(UIContext &dc); + +private: + // Event handlers + UI::EventReturn OnLanguage(UI::EventParams &e); + UI::EventReturn OnFactoryReset(UI::EventParams &e); + UI::EventReturn OnBack(UI::EventParams &e); }; \ No newline at end of file diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index dd39ee71d2..25f253782d 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -29,6 +29,7 @@ #include "UI/GameScreen.h" #include "UI/MenuScreens.h" #include "UI/GameInfoCache.h" +#include "UI/GameSettingsScreen.h" #include "UI/ui_atlas.h" #include "Core/Config.h" @@ -372,7 +373,8 @@ UI::EventReturn MainScreen::OnGameSelected(UI::EventParams &e) { } UI::EventReturn MainScreen::OnSettings(UI::EventParams &e) { - screenManager()->push(new SettingsScreen()); + // screenManager()->push(new SettingsScreen()); + screenManager()->push(new GlobalSettingsScreen()); return UI::EVENT_DONE; } diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index 89cc32b79f..755d949c91 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -138,17 +138,21 @@ void DrawWatermark() { // ui_draw2d.DrawTextShadow(UBUNTU24, "PRIVATE BUILD", dp_xres / 2, 10, 0xFF0000FF, ALIGN_HCENTER); } +void LogoScreen::Next() { + if (bootFilename_.size()) { + screenManager()->switchScreen(new EmuScreen(bootFilename_)); + } else { + if (g_Config.bNewUI) + screenManager()->switchScreen(new MainScreen()); + else + screenManager()->switchScreen(new MenuScreen()); + } +} + void LogoScreen::update(InputState &input_state) { frames_++; if (frames_ > 180 || input_state.pointer_down[0]) { - if (bootFilename_.size()) { - screenManager()->switchScreen(new EmuScreen(bootFilename_)); - } else { - if (g_Config.bNewUI) - screenManager()->switchScreen(new MainScreen()); - else - screenManager()->switchScreen(new MenuScreen()); - } + Next(); } } @@ -158,6 +162,12 @@ void LogoScreen::sendMessage(const char *message, const char *value) { } } +void LogoScreen::key(const KeyInput &key) { + if (key.deviceId != INPUT_MOUSE) { + Next(); + } +} + void LogoScreen::render() { float t = (float)frames_ / 60.0f; @@ -1008,20 +1018,20 @@ void GraphicsScreenP2::render() { UICheckBox(GEN_ID, x, y += stride, gs->T("Anisotropic Filtering"), ALIGN_TOPLEFT, &AnisotropicFiltering); if (AnisotropicFiltering) { if (g_Config.iAnisotropyLevel == 0) - g_Config.iAnisotropyLevel = 2; + g_Config.iAnisotropyLevel = 1; char showAF[256]; - sprintf(showAF, "%s %dx", gs->T("Level :"), g_Config.iAnisotropyLevel); + sprintf(showAF, "%s %dx", gs->T("Level :"), 1 << g_Config.iAnisotropyLevel); ui_draw2d.DrawTextShadow(UBUNTU24, showAF, x + 60, (y += stride) , 0xFFFFFFFF, ALIGN_LEFT); HLinear hlinear1(x + 300, y , 20); if (UIButton(GEN_ID, hlinear1, 60, 0, gs->T("2x"), ALIGN_LEFT)) - g_Config.iAnisotropyLevel = 2; + g_Config.iAnisotropyLevel = 1; if (UIButton(GEN_ID, hlinear1, 60, 0, gs->T("4x"), ALIGN_LEFT)) - g_Config.iAnisotropyLevel = 4; + g_Config.iAnisotropyLevel = 2; if (UIButton(GEN_ID, hlinear1, 60, 0, gs->T("8x"), ALIGN_LEFT)) - g_Config.iAnisotropyLevel = 8; + g_Config.iAnisotropyLevel = 3; if (UIButton(GEN_ID, hlinear1, 60, 0, gs->T("16x"), ALIGN_LEFT)) - g_Config.iAnisotropyLevel = 16; + g_Config.iAnisotropyLevel = 4; y += 20; } else diff --git a/UI/MenuScreens.h b/UI/MenuScreens.h index 910f69f4c7..c4af912ac4 100644 --- a/UI/MenuScreens.h +++ b/UI/MenuScreens.h @@ -30,11 +30,13 @@ class LogoScreen : public Screen public: LogoScreen(const std::string &bootFilename) : bootFilename_(bootFilename), frames_(0) {} + void key(const KeyInput &key); void update(InputState &input); void render(); void sendMessage(const char *message, const char *value); private: + void Next(); std::string bootFilename_; int frames_; }; diff --git a/Windows/XinputDevice.cpp b/Windows/XinputDevice.cpp index c65e6846e1..30a1b305e5 100644 --- a/Windows/XinputDevice.cpp +++ b/Windows/XinputDevice.cpp @@ -19,7 +19,7 @@ static const struct {int from, to;} xinput_ctrl_map[] = { {XINPUT_GAMEPAD_B, KEYCODE_BUTTON_B}, {XINPUT_GAMEPAD_X, KEYCODE_BUTTON_X}, {XINPUT_GAMEPAD_Y, KEYCODE_BUTTON_Y}, - {XINPUT_GAMEPAD_BACK, KEYCODE_BACK}, + {XINPUT_GAMEPAD_BACK, KEYCODE_BUTTON_SELECT}, {XINPUT_GAMEPAD_START, KEYCODE_BUTTON_START}, {XINPUT_GAMEPAD_LEFT_SHOULDER, KEYCODE_BUTTON_L1}, {XINPUT_GAMEPAD_RIGHT_SHOULDER, KEYCODE_BUTTON_R1}, diff --git a/native b/native index 8559d298f8..07feef3f44 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit 8559d298f86338c779dee368249edc7087d8dd46 +Subproject commit 07feef3f445eba07958eb5c86dfc5a299ca4a1ac