From a35fbddb910fa0dd068622c3dc64af1b27ca19b7 Mon Sep 17 00:00:00 2001 From: angela Date: Wed, 18 Nov 2009 20:52:53 +0800 Subject: EXT-2094 --- indra/newview/app_settings/keywords.ini | 1 + indra/newview/lltoolpie.cpp | 12 ++++++++++++ indra/newview/skins/default/xui/en/floater_tools.xml | 4 ++++ 3 files changed, 17 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini index 5f6fd6e4a7..71ea12bacd 100644 --- a/indra/newview/app_settings/keywords.ini +++ b/indra/newview/app_settings/keywords.ini @@ -508,6 +508,7 @@ CLICK_ACTION_SIT Used with llSetClickAction to set sit as the default act CLICK_ACTION_BUY Used with llSetClickAction to set buy as the default action when object is clicked CLICK_ACTION_PAY Used with llSetClickAction to set pay as the default action when object is clicked CLICK_ACTION_OPEN Used with llSetClickAction to set open as the default action when object is clicked +CLICK_ACTION_ZOOM Used with llSetClickAction to set zoom in as the default action when object is clicked CLICK_ACTION_PLAY Used with llSetClickAction to set play as the default action when object is clicked CLICK_ACTION_OPEN_MEDIA Used with llSetClickAction to set open-media as the default action when object is clicked diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index 9c8fca3552..d0350507ed 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -209,6 +209,7 @@ BOOL LLToolPie::pickLeftMouseDownCallback() // touch behavior down below... break; case CLICK_ACTION_SIT: + if ((gAgent.getAvatarObject() != NULL) && (!gAgent.getAvatarObject()->isSitting())) // agent not already sitting { handle_object_sit_or_stand(); @@ -253,6 +254,11 @@ BOOL LLToolPie::pickLeftMouseDownCallback() } } return TRUE; + case CLICK_ACTION_ZOOM: + gAgent.setFocusOnAvatar(FALSE, FALSE); + gAgent.setFocusGlobal(mPick); + gAgent.setCameraZoomFraction(0.9); + return TRUE; case CLICK_ACTION_PLAY: handle_click_action_play(); return TRUE; @@ -413,6 +419,9 @@ ECursorType cursor_from_object(LLViewerObject* object) cursor = UI_CURSOR_HAND; } break; + case CLICK_ACTION_ZOOM: + cursor = UI_CURSOR_TOOLZOOMIN; + break; case CLICK_ACTION_PLAY: case CLICK_ACTION_OPEN_MEDIA: cursor = cursor_from_parcel_media(click_action); @@ -551,6 +560,9 @@ BOOL LLToolPie::handleMouseUp(S32 x, S32 y, MASK mask) case CLICK_ACTION_BUY: case CLICK_ACTION_PAY: case CLICK_ACTION_OPEN: + case CLICK_ACTION_ZOOM: + case CLICK_ACTION_PLAY: + case CLICK_ACTION_OPEN_MEDIA: // Because these actions open UI dialogs, we won't change // the cursor again until the next hover and GL pick over // the world. Keep the cursor an arrow, assuming that diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 944b4cda98..59964ef39f 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -983,6 +983,10 @@ label="Open" name="Open" value="Open" /> + Date: Wed, 18 Nov 2009 19:21:09 -0800 Subject: EXT-1743 People inspectors should show Age, not Date born, fixed date math Changed date math to correctly account for month lengths and leap years. Extended unit test. Review pending. --- indra/newview/lldateutil.cpp | 71 ++++++++++++++++++++++++++++++--- indra/newview/llinspectavatar.cpp | 3 +- indra/newview/tests/lldateutil_test.cpp | 26 ++++++++++-- 3 files changed, 90 insertions(+), 10 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/lldateutil.cpp b/indra/newview/lldateutil.cpp index 040fad3c4a..1fe1715995 100644 --- a/indra/newview/lldateutil.cpp +++ b/indra/newview/lldateutil.cpp @@ -66,23 +66,82 @@ static S32 age_days_from_date(const std::string& date_string, return age_days; } +static S32 DAYS_PER_MONTH_NOLEAP[] = + { 31, 28, 21, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; +static S32 DAYS_PER_MONTH_LEAP[] = + { 31, 29, 21, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; + +static S32 days_from_month(S32 year, S32 month) +{ + if (year % 4 == 0 + && year % 100 != 0) + { + // leap year + return DAYS_PER_MONTH_LEAP[month]; + } + else + { + return DAYS_PER_MONTH_NOLEAP[month]; + } +} + std::string LLDateUtil::ageFromDate(const std::string& date_string, const LLDate& now) { +#define BAD_DATE_MATH 0 +#if BAD_DATE_MATH S32 age_days = age_days_from_date(date_string, now); if (age_days == S32_MIN) return "???"; - - // Noun pluralization depends on language - std::string lang = LLUI::getLanguage(); - - // Try for age in round number of years - LLStringUtil::format_map_t args; S32 age_years = age_days / 365; age_days = age_days % 365; // *NOTE: This is wrong. Not all months have 30 days, but we don't have a library // for relative date arithmetic. :-( JC S32 age_months = age_days / 30; age_days = age_days % 30; +#else + S32 born_month, born_day, born_year; + S32 matched = sscanf(date_string.c_str(), "%d/%d/%d", &born_month, &born_day, &born_year); + if (matched != 3) return "???"; + LLDate born_date; + born_date.fromYMDHMS(born_year, born_month, born_day); + F64 born_date_secs_since_epoch = born_date.secondsSinceEpoch(); + // Correct for the fact that account creation dates are in Pacific time, + // == UTC - 8 + born_date_secs_since_epoch += 8.0 * 60.0 * 60.0; + born_date.secondsSinceEpoch(born_date_secs_since_epoch); + // explode out to month/day/year again + born_date.split(&born_year, &born_month, &born_day); + + S32 now_year, now_month, now_day; + now.split(&now_year, &now_month, &now_day); + + // Do grade-school subtraction, from right-to-left, borrowing from the left + // when things go negative + S32 age_days = (now_day - born_day); + if (age_days < 0) + { + now_month -= 1; + if (now_month == 0) + { + now_year -= 1; + now_month = 12; + } + age_days += days_from_month(now_year, now_month); + } + S32 age_months = (now_month - born_month); + if (age_months < 0) + { + now_year -= 1; + age_months += 12; + } + S32 age_years = (now_year - born_year); +#endif + + // Noun pluralization depends on language + std::string lang = LLUI::getLanguage(); + + // Try for age in round number of years + LLStringUtil::format_map_t args; if (age_months > 0 || age_years > 0) { diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp index baddd90d46..866669f326 100644 --- a/indra/newview/llinspectavatar.cpp +++ b/indra/newview/llinspectavatar.cpp @@ -39,6 +39,7 @@ #include "llavataractions.h" #include "llavatarpropertiesprocessor.h" #include "llcallingcard.h" +#include "lldateutil.h" #include "llfloaterreporter.h" #include "llfloaterworldmap.h" #include "llinspect.h" @@ -351,7 +352,7 @@ void LLInspectAvatar::processAvatarData(LLAvatarData* data) { LLStringUtil::format_map_t args; args["[BORN_ON]"] = data->born_on; - args["[AGE]"] = data->born_on; + args["[AGE]"] = LLDateUtil::ageFromDate(data->born_on, LLDate::now()); args["[SL_PROFILE]"] = data->about_text; args["[RW_PROFILE"] = data->fl_about_text; args["[ACCTTYPE]"] = LLAvatarPropertiesProcessor::accountType(data); diff --git a/indra/newview/tests/lldateutil_test.cpp b/indra/newview/tests/lldateutil_test.cpp index ed753b6ff7..142a5eb5e6 100644 --- a/indra/newview/tests/lldateutil_test.cpp +++ b/indra/newview/tests/lldateutil_test.cpp @@ -60,6 +60,11 @@ std::string LLTrans::getString(const std::string &xml_desc, const LLStringUtil:: std::string LLTrans::getCountString(const std::string& language, const std::string& xml_desc, S32 count) { + count_string_t key(xml_desc, count); + if (gCountString.find(key) == gCountString.end()) + { + return std::string("Couldn't find ") + xml_desc; + } return gCountString[ count_string_t(xml_desc, count) ]; } @@ -91,8 +96,11 @@ namespace tut gCountString[ count_string_t("AgeYears", 2) ] = "2 years"; gCountString[ count_string_t("AgeMonths", 1) ] = "1 month"; gCountString[ count_string_t("AgeMonths", 2) ] = "2 months"; + gCountString[ count_string_t("AgeMonths", 11) ]= "11 months"; gCountString[ count_string_t("AgeWeeks", 1) ] = "1 week"; gCountString[ count_string_t("AgeWeeks", 2) ] = "2 weeks"; + gCountString[ count_string_t("AgeWeeks", 3) ] = "3 weeks"; + gCountString[ count_string_t("AgeWeeks", 4) ] = "4 weeks"; gCountString[ count_string_t("AgeDays", 1) ] = "1 day"; gCountString[ count_string_t("AgeDays", 2) ] = "2 days"; } @@ -113,12 +121,18 @@ namespace tut ensure_equals("years", LLDateUtil::ageFromDate("12/31/2007", mNow), "2 years old" ); - ensure_equals("single year", - LLDateUtil::ageFromDate("12/31/2008", mNow), - "1 year old" ); + ensure_equals("years", + LLDateUtil::ageFromDate("1/1/2008", mNow), + "1 year 11 months old" ); + ensure_equals("single year + one month", + LLDateUtil::ageFromDate("11/30/2008", mNow), + "1 year 1 month old" ); ensure_equals("single year + a bit", LLDateUtil::ageFromDate("12/12/2008", mNow), "1 year old" ); + ensure_equals("single year", + LLDateUtil::ageFromDate("12/31/2008", mNow), + "1 year old" ); } template<> template<> @@ -128,6 +142,9 @@ namespace tut ensure_equals("months", LLDateUtil::ageFromDate("10/30/2009", mNow), "2 months old" ); + ensure_equals("months 2", + LLDateUtil::ageFromDate("10/31/2009", mNow), + "2 months old" ); ensure_equals("single month", LLDateUtil::ageFromDate("11/30/2009", mNow), "1 month old" ); @@ -137,6 +154,9 @@ namespace tut void dateutil_object_t::test<3>() { set_test_name("Weeks"); + ensure_equals("4 weeks", + LLDateUtil::ageFromDate("12/1/2009", mNow), + "4 weeks old" ); ensure_equals("weeks", LLDateUtil::ageFromDate("12/17/2009", mNow), "2 weeks old" ); -- cgit v1.2.3 From b6ad65c04edc6e79637bf8ac9daf40b3654d80a6 Mon Sep 17 00:00:00 2001 From: angela Date: Thu, 19 Nov 2009 15:02:05 +0800 Subject: EXT-2094 Add click-to-zoom as a one-click settable option for objects --- indra/newview/app_settings/keywords.ini | 2 +- indra/newview/llpanelpermissions.cpp | 71 ++++++++++++++++++++-- indra/newview/lltoolpie.cpp | 30 +++++++-- .../newview/skins/default/xui/en/floater_tools.xml | 8 +-- 4 files changed, 95 insertions(+), 16 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/app_settings/keywords.ini b/indra/newview/app_settings/keywords.ini index 71ea12bacd..14025c8061 100644 --- a/indra/newview/app_settings/keywords.ini +++ b/indra/newview/app_settings/keywords.ini @@ -508,9 +508,9 @@ CLICK_ACTION_SIT Used with llSetClickAction to set sit as the default act CLICK_ACTION_BUY Used with llSetClickAction to set buy as the default action when object is clicked CLICK_ACTION_PAY Used with llSetClickAction to set pay as the default action when object is clicked CLICK_ACTION_OPEN Used with llSetClickAction to set open as the default action when object is clicked -CLICK_ACTION_ZOOM Used with llSetClickAction to set zoom in as the default action when object is clicked CLICK_ACTION_PLAY Used with llSetClickAction to set play as the default action when object is clicked CLICK_ACTION_OPEN_MEDIA Used with llSetClickAction to set open-media as the default action when object is clicked +CLICK_ACTION_ZOOM Used with llSetClickAction to set zoom in as the default action when object is clicked TOUCH_INVALID_TEXCOORD Value returned by llDetectedTouchUV() and llDetectedTouchST() when the touch position is not valid. TOUCH_INVALID_VECTOR Value returned by llDetectedTouchPos(), llDetectedTouchNormal(), and llDetectedTouchBinormal() when the touch position is not valid. diff --git a/indra/newview/llpanelpermissions.cpp b/indra/newview/llpanelpermissions.cpp index 0dc010e2e7..d8e0d91d88 100644 --- a/indra/newview/llpanelpermissions.cpp +++ b/indra/newview/llpanelpermissions.cpp @@ -66,6 +66,65 @@ #include "roles_constants.h" #include "llgroupactions.h" + +U8 string_value_to_click_action(std::string p_value); +std::string click_action_to_string_value( U8 action); + +U8 string_value_to_click_action(std::string p_value) +{ + if(p_value == "Touch") + { + return CLICK_ACTION_TOUCH; + } + if(p_value == "Sit") + { + return CLICK_ACTION_SIT; + } + if(p_value == "Buy") + { + return CLICK_ACTION_BUY; + } + if(p_value == "Pay") + { + return CLICK_ACTION_PAY; + } + if(p_value == "Open") + { + return CLICK_ACTION_OPEN; + } + if(p_value == "Zoom") + { + return CLICK_ACTION_ZOOM; + } + return CLICK_ACTION_TOUCH; +} + +std::string click_action_to_string_value( U8 action) +{ + switch (action) + { + case CLICK_ACTION_TOUCH: + default: + return "Touch"; + break; + case CLICK_ACTION_SIT: + return "Sit"; + break; + case CLICK_ACTION_BUY: + return "Buy"; + break; + case CLICK_ACTION_PAY: + return "Pay"; + break; + case CLICK_ACTION_OPEN: + return "Open"; + break; + case CLICK_ACTION_ZOOM: + return "Zoom"; + break; + } +} + ///---------------------------------------------------------------------------- /// Class llpanelpermissions ///---------------------------------------------------------------------------- @@ -774,7 +833,8 @@ void LLPanelPermissions::refresh() LLComboBox* ComboClickAction = getChild("clickaction"); if(ComboClickAction) { - ComboClickAction->setCurrentByIndex((S32)click_action); + std::string combo_value = click_action_to_string_value(click_action); + ComboClickAction->setValue(LLSD(combo_value)); } } childSetEnabled("label click action",is_perm_modify && all_volume); @@ -1015,8 +1075,9 @@ void LLPanelPermissions::onCommitClickAction(LLUICtrl* ctrl, void*) { LLComboBox* box = (LLComboBox*)ctrl; if (!box) return; - - U8 click_action = (U8)box->getCurrentIndex(); + std::string value = box->getValue().asString(); + U8 click_action = string_value_to_click_action(value); + if (click_action == CLICK_ACTION_BUY) { LLSaleInfo sale_info; @@ -1028,8 +1089,8 @@ void LLPanelPermissions::onCommitClickAction(LLUICtrl* ctrl, void*) // Set click action back to its old value U8 click_action = 0; LLSelectMgr::getInstance()->selectionGetClickAction(&click_action); - box->setCurrentByIndex((S32)click_action); - + std::string item_value = click_action_to_string_value(click_action); + box->setValue(LLSD(item_value)); return; } } diff --git a/indra/newview/lltoolpie.cpp b/indra/newview/lltoolpie.cpp index d0350507ed..5ed8dc5fb9 100644 --- a/indra/newview/lltoolpie.cpp +++ b/indra/newview/lltoolpie.cpp @@ -253,12 +253,7 @@ BOOL LLToolPie::pickLeftMouseDownCallback() selectionPropertiesReceived(); } } - return TRUE; - case CLICK_ACTION_ZOOM: - gAgent.setFocusOnAvatar(FALSE, FALSE); - gAgent.setFocusGlobal(mPick); - gAgent.setCameraZoomFraction(0.9); - return TRUE; + return TRUE; case CLICK_ACTION_PLAY: handle_click_action_play(); return TRUE; @@ -266,6 +261,29 @@ BOOL LLToolPie::pickLeftMouseDownCallback() // mClickActionObject = object; handle_click_action_open_media(object); return TRUE; + case CLICK_ACTION_ZOOM: + { + const F32 PADDING_FACTOR = 2.f; + LLViewerObject* object = gObjectList.findObject(mPick.mObjectID); + + if (object) + { + gAgent.setFocusOnAvatar(FALSE, ANIMATE); + + LLBBox bbox = object->getBoundingBoxAgent() ; + F32 angle_of_view = llmax(0.1f, LLViewerCamera::getInstance()->getAspect() > 1.f ? LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect() : LLViewerCamera::getInstance()->getView()); + F32 distance = bbox.getExtentLocal().magVec() * PADDING_FACTOR / atan(angle_of_view); + + LLVector3 obj_to_cam = LLViewerCamera::getInstance()->getOrigin() - bbox.getCenterAgent(); + obj_to_cam.normVec(); + + LLVector3d object_center_global = gAgent.getPosGlobalFromAgent(bbox.getCenterAgent()); + gAgent.setCameraPosAndFocusGlobal(object_center_global + LLVector3d(obj_to_cam * distance), + object_center_global, + mPick.mObjectID ); + } + } + return TRUE; default: // nothing break; diff --git a/indra/newview/skins/default/xui/en/floater_tools.xml b/indra/newview/skins/default/xui/en/floater_tools.xml index 87d31b8f9b..8b6f0f03fe 100644 --- a/indra/newview/skins/default/xui/en/floater_tools.xml +++ b/indra/newview/skins/default/xui/en/floater_tools.xml @@ -968,19 +968,19 @@ + value="Touch" /> + value="Sit" /> + value="Buy" /> + value="Pay" /> Date: Thu, 19 Nov 2009 15:03:03 -0500 Subject: Edited to have elements follow panel bottom. https://jira.secondlife.com/browse/EXT-2446 --- indra/newview/skins/default/xui/en/floater_buy_contents.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/skins/default/xui/en/floater_buy_contents.xml b/indra/newview/skins/default/xui/en/floater_buy_contents.xml index 833e8beb8d..77a0e9b91b 100644 --- a/indra/newview/skins/default/xui/en/floater_buy_contents.xml +++ b/indra/newview/skins/default/xui/en/floater_buy_contents.xml @@ -56,7 +56,7 @@ Date: Thu, 19 Nov 2009 17:39:54 -0500 Subject: Increased size of floater in floater_region_info.xml and modified layout in panel_region_estate.xml. Also made button sizes to spec and did a general clean-up of the layout. http://jira.secondlife.com/browse/EXT-2658 --- .../skins/default/xui/en/floater_region_info.xml | 4 +- .../skins/default/xui/en/panel_region_estate.xml | 104 ++++++++++----------- 2 files changed, 54 insertions(+), 54 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/skins/default/xui/en/floater_region_info.xml b/indra/newview/skins/default/xui/en/floater_region_info.xml index 9bb30f8e86..262bcd07a0 100644 --- a/indra/newview/skins/default/xui/en/floater_region_info.xml +++ b/indra/newview/skins/default/xui/en/floater_region_info.xml @@ -1,7 +1,7 @@ Abuse email address: + top_pad="-5" + width="230" />