diff options
Diffstat (limited to 'linden/indra/newview/llviewercontrol.cpp')
-rw-r--r-- | linden/indra/newview/llviewercontrol.cpp | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/linden/indra/newview/llviewercontrol.cpp b/linden/indra/newview/llviewercontrol.cpp index 3f79654..98d19bc 100644 --- a/linden/indra/newview/llviewercontrol.cpp +++ b/linden/indra/newview/llviewercontrol.cpp | |||
@@ -566,3 +566,124 @@ void settings_setup_listeners() | |||
566 | gSavedSettings.getControl("LipSyncEnabled")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _1)); | 566 | gSavedSettings.getControl("LipSyncEnabled")->getSignal()->connect(boost::bind(&handleVoiceClientPrefsChanged, _1)); |
567 | } | 567 | } |
568 | 568 | ||
569 | template <> eControlType get_control_type<U32>(const U32& in, LLSD& out) | ||
570 | { | ||
571 | out = (LLSD::Integer)in; | ||
572 | return TYPE_U32; | ||
573 | } | ||
574 | |||
575 | template <> eControlType get_control_type<S32>(const S32& in, LLSD& out) | ||
576 | { | ||
577 | out = in; | ||
578 | return TYPE_S32; | ||
579 | } | ||
580 | |||
581 | template <> eControlType get_control_type<F32>(const F32& in, LLSD& out) | ||
582 | { | ||
583 | out = in; | ||
584 | return TYPE_F32; | ||
585 | } | ||
586 | |||
587 | template <> eControlType get_control_type<bool> (const bool& in, LLSD& out) | ||
588 | { | ||
589 | out = in; | ||
590 | return TYPE_BOOLEAN; | ||
591 | } | ||
592 | /* | ||
593 | // Yay BOOL, its really an S32. | ||
594 | template <> eControlType get_control_type<BOOL> (const BOOL& in, LLSD& out) | ||
595 | { | ||
596 | out = in; | ||
597 | return TYPE_BOOLEAN; | ||
598 | } | ||
599 | */ | ||
600 | template <> eControlType get_control_type<std::string>(const std::string& in, LLSD& out) | ||
601 | { | ||
602 | out = in; | ||
603 | return TYPE_STRING; | ||
604 | } | ||
605 | |||
606 | template <> eControlType get_control_type<LLVector3>(const LLVector3& in, LLSD& out) | ||
607 | { | ||
608 | out = in.getValue(); | ||
609 | return TYPE_VEC3; | ||
610 | } | ||
611 | |||
612 | template <> eControlType get_control_type<LLVector3d>(const LLVector3d& in, LLSD& out) | ||
613 | { | ||
614 | out = in.getValue(); | ||
615 | return TYPE_VEC3D; | ||
616 | } | ||
617 | |||
618 | template <> eControlType get_control_type<LLRect>(const LLRect& in, LLSD& out) | ||
619 | { | ||
620 | out = in.getValue(); | ||
621 | return TYPE_RECT; | ||
622 | } | ||
623 | |||
624 | template <> eControlType get_control_type<LLColor4>(const LLColor4& in, LLSD& out) | ||
625 | { | ||
626 | out = in.getValue(); | ||
627 | return TYPE_COL4; | ||
628 | } | ||
629 | |||
630 | template <> eControlType get_control_type<LLColor3>(const LLColor3& in, LLSD& out) | ||
631 | { | ||
632 | out = in.getValue(); | ||
633 | return TYPE_COL3; | ||
634 | } | ||
635 | |||
636 | template <> eControlType get_control_type<LLColor4U>(const LLColor4U& in, LLSD& out) | ||
637 | { | ||
638 | out = in.getValue(); | ||
639 | return TYPE_COL4U; | ||
640 | } | ||
641 | |||
642 | template <> eControlType get_control_type<LLSD>(const LLSD& in, LLSD& out) | ||
643 | { | ||
644 | out = in; | ||
645 | return TYPE_LLSD; | ||
646 | } | ||
647 | |||
648 | |||
649 | #if TEST_CACHED_CONTROL | ||
650 | |||
651 | #define DECL_LLCC(T, V) static LLCachedControl<T> mySetting_##T("TestCachedControl"#T, V) | ||
652 | DECL_LLCC(U32, (U32)666); | ||
653 | DECL_LLCC(S32, (S32)-666); | ||
654 | DECL_LLCC(F32, (F32)-666.666); | ||
655 | DECL_LLCC(bool, true); | ||
656 | DECL_LLCC(BOOL, FALSE); | ||
657 | static LLCachedControl<std::string> mySetting_string("TestCachedControlstring", "Default String Value"); | ||
658 | DECL_LLCC(LLVector3, LLVector3(1.0f, 2.0f, 3.0f)); | ||
659 | DECL_LLCC(LLVector3d, LLVector3d(6.0f, 5.0f, 4.0f)); | ||
660 | DECL_LLCC(LLRect, LLRect(0, 0, 100, 500)); | ||
661 | DECL_LLCC(LLColor4, LLColor4(0.0f, 0.5f, 1.0f)); | ||
662 | DECL_LLCC(LLColor3, LLColor3(1.0f, 0.f, 0.5f)); | ||
663 | DECL_LLCC(LLColor4U, LLColor4U(255, 200, 100, 255)); | ||
664 | |||
665 | LLSD test_llsd = LLSD()["testing1"] = LLSD()["testing2"]; | ||
666 | DECL_LLCC(LLSD, test_llsd); | ||
667 | |||
668 | static LLCachedControl<std::string> test_BrowserHomePage("BrowserHomePage", "hahahahahha", "Not the real comment"); | ||
669 | |||
670 | void test_cached_control() | ||
671 | { | ||
672 | #define TEST_LLCC(T, V) if((T)mySetting_##T != V) llerrs << "Fail "#T << llendl | ||
673 | TEST_LLCC(U32, 666); | ||
674 | TEST_LLCC(S32, (S32)-666); | ||
675 | TEST_LLCC(F32, (F32)-666.666); | ||
676 | TEST_LLCC(bool, true); | ||
677 | TEST_LLCC(BOOL, FALSE); | ||
678 | if((std::string)mySetting_string != "Default String Value") llerrs << "Fail string" << llendl; | ||
679 | TEST_LLCC(LLVector3, LLVector3(1.0f, 2.0f, 3.0f)); | ||
680 | TEST_LLCC(LLVector3d, LLVector3d(6.0f, 5.0f, 4.0f)); | ||
681 | TEST_LLCC(LLRect, LLRect(0, 0, 100, 500)); | ||
682 | TEST_LLCC(LLColor4, LLColor4(0.0f, 0.5f, 1.0f)); | ||
683 | TEST_LLCC(LLColor3, LLColor3(1.0f, 0.f, 0.5f)); | ||
684 | TEST_LLCC(LLColor4U, LLColor4U(255, 200, 100, 255)); | ||
685 | //There's no LLSD comparsion for LLCC yet. TEST_LLCC(LLSD, test_llsd); | ||
686 | |||
687 | if((std::string)test_BrowserHomePage != "http://www.secondlife.com") llerrs << "Fail BrowserHomePage" << llendl; | ||
688 | } | ||
689 | #endif // TEST_CACHED_CONTROL \ No newline at end of file | ||