From 5490a992cabbf1d9f15747506f2f2fbab36d0122 Mon Sep 17 00:00:00 2001 From: Inusaito Sayori Date: Mon, 16 Jun 2014 21:43:43 -0400 Subject: [PATCH] Revert "[Preferences Refactor] Remove window size combo box from graphics preferences" The issue wasn't the resolution box, and it apparently has its uses. This reverts commit ac106b0aff3cb0c710b6473d7582e2d8f6b6def4. Conflicts: indra/newview/skins/default/xui/en-us/panel_preferences_graphics1.xml --- indra/newview/llpaneldisplay.cpp | 79 +++++++++++++++++++ indra/newview/llpaneldisplay.h | 5 ++ .../xui/de/panel_preferences_graphics1.xml | 16 ++++ .../xui/en-us/panel_preferences_graphics1.xml | 16 ++++ .../xui/es/panel_preferences_graphics1.xml | 44 +++++++++++ .../xui/fr/panel_preferences_graphics1.xml | 8 ++ .../xui/it/panel_preferences_graphics1.xml | 3 + .../xui/pt/panel_preferences_graphics1.xml | 20 +++++ 8 files changed, 191 insertions(+) diff --git a/indra/newview/llpaneldisplay.cpp b/indra/newview/llpaneldisplay.cpp index fb1f0cb3e..43ebbcc34 100644 --- a/indra/newview/llpaneldisplay.cpp +++ b/indra/newview/llpaneldisplay.cpp @@ -168,6 +168,8 @@ BOOL LLPanelDisplay::postBuild() } } + initWindowSizeControls(); + if (gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio")) { mAspectRatio = gViewerWindow->getDisplayAspectRatio(); @@ -330,8 +332,48 @@ BOOL LLPanelDisplay::postBuild() return TRUE; } +void LLPanelDisplay::initWindowSizeControls() +{ + // Window size + mWindowSizeLabel = getChild("WindowSizeLabel"); + mCtrlWindowSize = getChild("windowsize combo"); + + // Look to see if current window size matches existing window sizes, if so then + // just set the selection value... + const U32 height = gViewerWindow->getWindowDisplayHeight(); + const U32 width = gViewerWindow->getWindowDisplayWidth(); + for (S32 i=0; i < mCtrlWindowSize->getItemCount(); i++) + { + U32 height_test = 0; + U32 width_test = 0; + mCtrlWindowSize->setCurrentByIndex(i); + if (extractWindowSizeFromString(mCtrlWindowSize->getValue().asString(), width_test, height_test)) + { + if ((height_test == height) && (width_test == width)) + { + return; + } + } + } + // ...otherwise, add a new entry with the current window height/width. + LLUIString resolution_label = getString("resolution_format"); + resolution_label.setArg("[RES_X]", llformat("%d", width)); + resolution_label.setArg("[RES_Y]", llformat("%d", height)); + mCtrlWindowSize->add(resolution_label, ADD_TOP); + mCtrlWindowSize->setCurrentByIndex(0); +} + LLPanelDisplay::~LLPanelDisplay() { + // clean up user data + for (S32 i = 0; i < mCtrlAspectRatio->getItemCount(); i++) + { + mCtrlAspectRatio->setCurrentByIndex(i); + } + for (S32 i = 0; i < mCtrlWindowSize->getItemCount(); i++) + { + mCtrlWindowSize->setCurrentByIndex(i); + } } void LLPanelDisplay::refresh() @@ -412,6 +454,8 @@ void LLPanelDisplay::refreshEnabledState() mCtrlAspectRatio->setVisible(isFullScreen); mAspectRatioLabel1->setVisible(isFullScreen); mCtrlAutoDetectAspect->setVisible(isFullScreen); + mWindowSizeLabel->setVisible(!isFullScreen); + mCtrlWindowSize->setVisible(!isFullScreen); // Hardware tab getChild("GrapicsCardTextureMemory")->setMinValue(LLViewerTextureList::getMinVideoRamSetting()); @@ -679,6 +723,12 @@ void LLPanelDisplay::apply() applyResolution(); + // Only set window size if we're not in fullscreen mode + if (mCtrlWindowed->get()) + { + applyWindowSize(); + } + // Hardware tab //Still do a bit of voodoo here. V2 forces restart to change FSAA with FBOs off. //Let's not do that, and instead do pre-V2 FSAA change handling for that particular case @@ -766,6 +816,35 @@ void LLPanelDisplay::applyResolution() refresh(); } +// Extract from strings of the form " x ", e.g. "640 x 480". +bool LLPanelDisplay::extractWindowSizeFromString(const std::string& instr, U32 &width, U32 &height) +{ + using namespace boost; + cmatch what; + const regex expression("([0-9]+) x ([0-9]+)"); + if (regex_match(instr.c_str(), what, expression)) + { + width = atoi(what[1].first); + height = atoi(what[2].first); + return true; + } + width = height = 0; + return false; +} + +void LLPanelDisplay::applyWindowSize() +{ + if (mCtrlWindowSize->getVisible() && (mCtrlWindowSize->getCurrentIndex() != -1)) + { + U32 width = 0; + U32 height = 0; + if (extractWindowSizeFromString(mCtrlWindowSize->getValue().asString().c_str(), width,height)) + { + LLViewerWindow::movieSize(width, height); + } + } +} + void LLPanelDisplay::onCommitWindowedMode() { refresh(); diff --git a/indra/newview/llpaneldisplay.h b/indra/newview/llpaneldisplay.h index b2432b10e..688757f9a 100644 --- a/indra/newview/llpaneldisplay.h +++ b/indra/newview/llpaneldisplay.h @@ -72,9 +72,12 @@ public: void disableUnavailableSettings(); void apply(); // Apply the changed values. void applyResolution(); + void applyWindowSize(); void cancel(); protected: + void initWindowSizeControls(); + bool extractWindowSizeFromString(const std::string& instr, U32 &width, U32 &height); // aspect ratio sliders and boxes LLComboBox *mCtrlFullScreen; // Fullscreen resolution @@ -82,6 +85,7 @@ protected: LLComboBox *mCtrlAspectRatio; // user provided aspect ratio LLCheckBoxCtrl *mCtrlWindowed; // windowed mode + LLComboBox *mCtrlWindowSize; // window size for windowed mode /// performance radio group LLSliderCtrl *mCtrlSliderQuality; @@ -103,6 +107,7 @@ protected: LLTextBox *mAspectRatioLabel1; LLTextBox *mDisplayResLabel; + LLTextBox *mWindowSizeLabel; LLCheckBoxCtrl *mVBO; diff --git a/indra/newview/skins/default/xui/de/panel_preferences_graphics1.xml b/indra/newview/skins/default/xui/de/panel_preferences_graphics1.xml index d7600a3c4..54f2fbd43 100644 --- a/indra/newview/skins/default/xui/de/panel_preferences_graphics1.xml +++ b/indra/newview/skins/default/xui/de/panel_preferences_graphics1.xml @@ -2,6 +2,22 @@