diff options
author | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
commit | 2a4dea528f670b9bb1f77ef27a8a1dd16603d114 (patch) | |
tree | 95c68e362703c9099d571ecbdc6142b1cda1e005 /linden/indra/newview/llpaneldisplay.cpp | |
parent | Second Life viewer sources 1.20.6 (diff) | |
download | meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.zip meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.gz meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.bz2 meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.xz |
Second Life viewer sources 1.20.7
Diffstat (limited to 'linden/indra/newview/llpaneldisplay.cpp')
-rw-r--r-- | linden/indra/newview/llpaneldisplay.cpp | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/linden/indra/newview/llpaneldisplay.cpp b/linden/indra/newview/llpaneldisplay.cpp index e5072c5..cc70f79 100644 --- a/linden/indra/newview/llpaneldisplay.cpp +++ b/linden/indra/newview/llpaneldisplay.cpp | |||
@@ -82,6 +82,8 @@ | |||
82 | // parent | 82 | // parent |
83 | #include "llfloaterpreference.h" | 83 | #include "llfloaterpreference.h" |
84 | 84 | ||
85 | #include <boost/regex.hpp> | ||
86 | |||
85 | const F32 MAX_USER_FAR_CLIP = 512.f; | 87 | const F32 MAX_USER_FAR_CLIP = 512.f; |
86 | const F32 MIN_USER_FAR_CLIP = 64.f; | 88 | const F32 MIN_USER_FAR_CLIP = 64.f; |
87 | 89 | ||
@@ -164,6 +166,8 @@ BOOL LLPanelDisplay::postBuild() | |||
164 | } | 166 | } |
165 | } | 167 | } |
166 | 168 | ||
169 | initWindowSizeControls(); | ||
170 | |||
167 | if (gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio")) | 171 | if (gSavedSettings.getBOOL("FullScreenAutoDetectAspectRatio")) |
168 | { | 172 | { |
169 | mAspectRatio = gViewerWindow->getDisplayAspectRatio(); | 173 | mAspectRatio = gViewerWindow->getDisplayAspectRatio(); |
@@ -319,6 +323,36 @@ BOOL LLPanelDisplay::postBuild() | |||
319 | return TRUE; | 323 | return TRUE; |
320 | } | 324 | } |
321 | 325 | ||
326 | void LLPanelDisplay::initWindowSizeControls() | ||
327 | { | ||
328 | // Window size | ||
329 | mWindowSizeLabel = getChild<LLTextBox>("WindowSizeLabel"); | ||
330 | mCtrlWindowSize = getChild<LLComboBox>("windowsize combo"); | ||
331 | |||
332 | // Look to see if current window size matches existing window sizes, if so then | ||
333 | // just set the selection value... | ||
334 | const U32 height = gViewerWindow->getWindowDisplayHeight(); | ||
335 | const U32 width = gViewerWindow->getWindowDisplayWidth(); | ||
336 | for (S32 i=0; i < mCtrlWindowSize->getItemCount(); i++) | ||
337 | { | ||
338 | U32 height_test = 0; | ||
339 | U32 width_test = 0; | ||
340 | mCtrlWindowSize->setCurrentByIndex(i); | ||
341 | if (extractWindowSizeFromString(mCtrlWindowSize->getValue().asString().c_str(), width_test, height_test)) | ||
342 | { | ||
343 | if ((height_test == height) && (width_test == width)) | ||
344 | { | ||
345 | return; | ||
346 | } | ||
347 | } | ||
348 | } | ||
349 | // ...otherwise, add a new entry with the current window height/width. | ||
350 | LLUIString resolution_label = getUIString("resolution_format"); | ||
351 | resolution_label.setArg("[RES_X]", llformat("%d", width)); | ||
352 | resolution_label.setArg("[RES_Y]", llformat("%d", height)); | ||
353 | mCtrlWindowSize->add(resolution_label, ADD_TOP); | ||
354 | mCtrlWindowSize->setCurrentByIndex(0); | ||
355 | } | ||
322 | 356 | ||
323 | LLPanelDisplay::~LLPanelDisplay() | 357 | LLPanelDisplay::~LLPanelDisplay() |
324 | { | 358 | { |
@@ -327,6 +361,10 @@ LLPanelDisplay::~LLPanelDisplay() | |||
327 | { | 361 | { |
328 | mCtrlAspectRatio->setCurrentByIndex(i); | 362 | mCtrlAspectRatio->setCurrentByIndex(i); |
329 | } | 363 | } |
364 | for (S32 i = 0; i < mCtrlWindowSize->getItemCount(); i++) | ||
365 | { | ||
366 | mCtrlWindowSize->setCurrentByIndex(i); | ||
367 | } | ||
330 | } | 368 | } |
331 | 369 | ||
332 | void LLPanelDisplay::refresh() | 370 | void LLPanelDisplay::refresh() |
@@ -392,6 +430,7 @@ void LLPanelDisplay::refreshEnabledState() | |||
392 | mAspectRatioLabel1->setVisible(isFullScreen); | 430 | mAspectRatioLabel1->setVisible(isFullScreen); |
393 | mCtrlAutoDetectAspect->setVisible(isFullScreen); | 431 | mCtrlAutoDetectAspect->setVisible(isFullScreen); |
394 | mFullScreenInfo->setVisible(!isFullScreen); | 432 | mFullScreenInfo->setVisible(!isFullScreen); |
433 | mWindowSizeLabel->setVisible(!isFullScreen); | ||
395 | 434 | ||
396 | // disable graphics settings and exit if it's not set to custom | 435 | // disable graphics settings and exit if it's not set to custom |
397 | if(!gSavedSettings.getBOOL("RenderCustomSettings")) | 436 | if(!gSavedSettings.getBOOL("RenderCustomSettings")) |
@@ -656,6 +695,12 @@ void LLPanelDisplay::cancel() | |||
656 | void LLPanelDisplay::apply() | 695 | void LLPanelDisplay::apply() |
657 | { | 696 | { |
658 | applyResolution(); | 697 | applyResolution(); |
698 | |||
699 | // Only set window size if we're not in fullscreen mode | ||
700 | if (mCtrlWindowed->get()) | ||
701 | { | ||
702 | applyWindowSize(); | ||
703 | } | ||
659 | } | 704 | } |
660 | 705 | ||
661 | void LLPanelDisplay::onChangeQuality(LLUICtrl *ctrl, void *data) | 706 | void LLPanelDisplay::onChangeQuality(LLUICtrl *ctrl, void *data) |
@@ -712,7 +757,7 @@ void LLPanelDisplay::applyResolution() | |||
712 | if (mCtrlAspectRatio->getCurrentIndex() == -1) | 757 | if (mCtrlAspectRatio->getCurrentIndex() == -1) |
713 | { | 758 | { |
714 | strncpy(aspect_ratio_text, mCtrlAspectRatio->getSimple().c_str(), sizeof(aspect_ratio_text) -1); /*Flawfinder: ignore*/ | 759 | strncpy(aspect_ratio_text, mCtrlAspectRatio->getSimple().c_str(), sizeof(aspect_ratio_text) -1); /*Flawfinder: ignore*/ |
715 | aspect_ratio_text[sizeof(aspect_ratio_text) -1] = '\0'; | 760 | aspect_ratio_text[sizeof(aspect_ratio_text) -1] = '\0'; |
716 | char *element = strtok(aspect_ratio_text, ":/\\"); | 761 | char *element = strtok(aspect_ratio_text, ":/\\"); |
717 | if (!element) | 762 | if (!element) |
718 | { | 763 | { |
@@ -817,6 +862,36 @@ void LLPanelDisplay::applyResolution() | |||
817 | refresh(); | 862 | refresh(); |
818 | } | 863 | } |
819 | 864 | ||
865 | // Extract from strings of the form "<width> x <height>", e.g. "640 x 480". | ||
866 | bool LLPanelDisplay::extractWindowSizeFromString(const char *sInput, U32 &width, U32 &height) | ||
867 | { | ||
868 | using namespace boost; | ||
869 | cmatch what; | ||
870 | const regex expression("([0-9]+) x ([0-9]+)"); | ||
871 | if (regex_match(sInput, what, expression)) | ||
872 | { | ||
873 | width = atoi(what[1].first); | ||
874 | height = atoi(what[2].first); | ||
875 | return true; | ||
876 | } | ||
877 | |||
878 | width = height = 0; | ||
879 | return false; | ||
880 | } | ||
881 | |||
882 | void LLPanelDisplay::applyWindowSize() | ||
883 | { | ||
884 | if (mCtrlWindowSize->getVisible() && (mCtrlWindowSize->getCurrentIndex() != -1)) | ||
885 | { | ||
886 | U32 width = 0; | ||
887 | U32 height = 0; | ||
888 | if (extractWindowSizeFromString(mCtrlWindowSize->getValue().asString().c_str(), width,height)) | ||
889 | { | ||
890 | LLViewerWindow::movieSize(width, height); | ||
891 | } | ||
892 | } | ||
893 | } | ||
894 | |||
820 | //static | 895 | //static |
821 | void LLPanelDisplay::onCommitWindowedMode(LLUICtrl* ctrl, void *data) | 896 | void LLPanelDisplay::onCommitWindowedMode(LLUICtrl* ctrl, void *data) |
822 | { | 897 | { |