diff options
author | AndreyL ProductEngine <alihatskiy@productengine.com> | 2018-09-14 08:14:05 +0300 |
---|---|---|
committer | AndreyL ProductEngine <alihatskiy@productengine.com> | 2018-09-14 08:14:05 +0300 |
commit | de52689954f575914cc91745808fa6cd6ece021a (patch) | |
tree | 0b88ef6ed913c623c26c9ca3edc41c216a086d8a /indra/newview | |
parent | fd83e889642518803b0041761a3d4bf81df21e3e (diff) |
SL-1956 added support for temporary bans to parcel ban list
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/llfloaterbanduration.cpp | 92 | ||||
-rw-r--r-- | indra/newview/llfloaterbanduration.h | 52 | ||||
-rw-r--r-- | indra/newview/llfloaterland.cpp | 75 | ||||
-rw-r--r-- | indra/newview/llfloaterland.h | 1 | ||||
-rw-r--r-- | indra/newview/llviewerfloaterreg.cpp | 2 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_about_land.xml | 28 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_ban_duration.xml | 100 |
8 files changed, 329 insertions, 23 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 2fc722d4c3..de4bb6cf06 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -207,6 +207,7 @@ set(viewer_SOURCE_FILES llfloateravatarpicker.cpp llfloateravatarrendersettings.cpp llfloateravatartextures.cpp + llfloaterbanduration.cpp llfloaterbeacons.cpp llfloaterbigpreview.cpp llfloaterbuildoptions.cpp @@ -829,6 +830,7 @@ set(viewer_HEADER_FILES llfloateravatarpicker.h llfloateravatarrendersettings.h llfloateravatartextures.h + llfloaterbanduration.h llfloaterbeacons.h llfloaterbigpreview.h llfloaterbuildoptions.h diff --git a/indra/newview/llfloaterbanduration.cpp b/indra/newview/llfloaterbanduration.cpp new file mode 100644 index 0000000000..6ba6c30cab --- /dev/null +++ b/indra/newview/llfloaterbanduration.cpp @@ -0,0 +1,92 @@ +/** +* @file llfloaterbanduration.cpp +* +* $LicenseInfo:firstyear=2004&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2018, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" +#include "llfloaterbanduration.h" + +#include "llfloaterreg.h" +#include "llspinctrl.h" +#include "llradiogroup.h" + +LLFloaterBanDuration::LLFloaterBanDuration(const LLSD& target) + : LLFloater(target) +{ +} + +BOOL LLFloaterBanDuration::postBuild() +{ + childSetAction("ok_btn", boost::bind(&LLFloaterBanDuration::onClickBan, this)); + childSetAction("cancel_btn", boost::bind(&LLFloaterBanDuration::onClickCancel, this)); + + getChild<LLUICtrl>("ban_duration_radio")->setCommitCallback(boost::bind(&LLFloaterBanDuration::onClickRadio, this)); + getChild<LLRadioGroup>("ban_duration_radio")->setSelectedIndex(0); + getChild<LLUICtrl>("ban_hours")->setEnabled(FALSE); + + return TRUE; +} + +LLFloaterBanDuration* LLFloaterBanDuration::show(select_callback_t callback, uuid_vec_t ids) +{ + LLFloaterBanDuration* floater = LLFloaterReg::showTypedInstance<LLFloaterBanDuration>("ban_duration"); + if (!floater) + { + LL_WARNS() << "Cannot instantiate ban duration floater" << LL_ENDL; + return NULL; + } + + floater->mSelectionCallback = callback; + floater->mAvatar_ids = ids; + + return floater; +} + +void LLFloaterBanDuration::onClickRadio() +{ + getChild<LLUICtrl>("ban_hours")->setEnabled(getChild<LLRadioGroup>("ban_duration_radio")->getSelectedIndex() != 0); +} + +void LLFloaterBanDuration::onClickCancel() +{ + closeFloater(); +} + +void LLFloaterBanDuration::onClickBan() +{ + if (mSelectionCallback) + { + S32 time = 0; + if (getChild<LLRadioGroup>("ban_duration_radio")->getSelectedIndex() != 0) + { + LLSpinCtrl* hours_spin = getChild<LLSpinCtrl>("ban_hours"); + if (hours_spin) + { + time = LLDate::now().secondsSinceEpoch() + (hours_spin->getValue().asInteger() * 3600); + } + } + mSelectionCallback(mAvatar_ids, time); + } + closeFloater(); +} + diff --git a/indra/newview/llfloaterbanduration.h b/indra/newview/llfloaterbanduration.h new file mode 100644 index 0000000000..e8ec7cc669 --- /dev/null +++ b/indra/newview/llfloaterbanduration.h @@ -0,0 +1,52 @@ +/** +* @file llfloaterbanduration.h +* +* $LicenseInfo:firstyear=2004&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2018, Linden Research, Inc. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; +* version 2.1 of the License only. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +* +* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA +* $/LicenseInfo$ +*/ + + +#ifndef LL_FLOATERBANDURATION_H +#define LL_FLOATERBANDURATION_H + +#include "llfloater.h" + +class LLFloaterBanDuration : public LLFloater +{ + typedef boost::function<void(const uuid_vec_t&, const S32 duration)> select_callback_t; + +public: + LLFloaterBanDuration(const LLSD& target); + BOOL postBuild(); + static LLFloaterBanDuration* show(select_callback_t callback, uuid_vec_t id); + +private: + ~LLFloaterBanDuration() {}; + void onClickBan(); + void onClickCancel(); + void onClickRadio(); + + uuid_vec_t mAvatar_ids; + select_callback_t mSelectionCallback; +}; + +#endif // LL_FLOATERBANDURATION_H + diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp index 88b3fb7b96..2ecb6f21cd 100644 --- a/indra/newview/llfloaterland.cpp +++ b/indra/newview/llfloaterland.cpp @@ -46,6 +46,7 @@ #include "llfloaterreg.h" #include "llfloateravatarpicker.h" #include "llfloaterauction.h" +#include "llfloaterbanduration.h" #include "llfloatergroups.h" #include "llfloaterscriptlimits.h" #include "llavataractions.h" @@ -2502,33 +2503,49 @@ void LLPanelLandAccess::refresh() cit != parcel->mBanList.end(); ++cit) { const LLAccessEntry& entry = (*cit).second; - std::string prefix; + std::string duration; if (entry.mTime != 0) { LLStringUtil::format_map_t args; S32 now = time(NULL); - S32 seconds = entry.mTime - now; + S32 seconds = entry.mTime - now; if (seconds < 0) seconds = 0; - prefix.assign(" ("); - if (seconds >= 120) + + if (seconds >= 7200) { - args["[MINUTES]"] = llformat("%d", (seconds/60)); - std::string buf = parent_floater->getString ("Minutes", args); - prefix.append(buf); + args["[HOURS]"] = llformat("%d", (seconds / 7200)); + duration = parent_floater->getString("Hours", args); + } + if (seconds >= 3600) + { + duration = "1 " + parent_floater->getString("Hour"); + } + else if (seconds >= 120) + { + args["[MINUTES]"] = llformat("%d", (seconds / 60)); + duration = parent_floater->getString("Minutes", args); } else if (seconds >= 60) { - prefix.append("1 " + parent_floater->getString("Minute")); + duration = "1 " + parent_floater->getString("Minute"); } else { args["[SECONDS]"] = llformat("%d", seconds); - std::string buf = parent_floater->getString ("Seconds", args); - prefix.append(buf); + duration = parent_floater->getString("Seconds", args); } - prefix.append(" " + parent_floater->getString("Remaining") + ") "); } - mListBanned->addNameItem(entry.mID, ADD_DEFAULT, TRUE, "", prefix); + else + { + duration = parent_floater->getString("Always"); + } + LLSD item; + item["id"] = entry.mID; + LLSD& columns = item["columns"]; + columns[0]["column"] = "name"; // to be populated later + columns[1]["column"] = "duration"; + columns[1]["value"] = duration; + mListBanned->addElement(item); } mListBanned->sortByName(TRUE); } @@ -2880,7 +2897,7 @@ void LLPanelLandAccess::onClickAddBanned() LLView * button = findChild<LLButton>("add_banned"); LLFloater * root_floater = gFloaterView->getParentFloater(this); LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show( - boost::bind(&LLPanelLandAccess::callbackAvatarCBBanned, this, _1), FALSE, FALSE, FALSE, root_floater->getName(), button); + boost::bind(&LLPanelLandAccess::callbackAvatarCBBanned, this, _1), TRUE, FALSE, FALSE, root_floater->getName(), button); if (picker) { root_floater->addDependentFloater(picker); @@ -2890,23 +2907,41 @@ void LLPanelLandAccess::onClickAddBanned() // static void LLPanelLandAccess::callbackAvatarCBBanned(const uuid_vec_t& ids) { - if (!ids.empty()) + LLFloater * root_floater = gFloaterView->getParentFloater(this); + LLFloaterBanDuration* duration_floater = LLFloaterBanDuration::show( + boost::bind(&LLPanelLandAccess::callbackAvatarCBBanned2, this, _1, _2), ids); + if (duration_floater) { - LLUUID id = ids[0]; - LLParcel* parcel = mParcel->getParcel(); - if (parcel && parcel->addToBanList(id, 0)) + root_floater->addDependentFloater(duration_floater); + } +} + +void LLPanelLandAccess::callbackAvatarCBBanned2(const uuid_vec_t& ids, S32 duration) +{ + LLParcel* parcel = mParcel->getParcel(); + if (!parcel) return; + + U32 lists_to_update = 0; + + for (uuid_vec_t::const_iterator it = ids.begin(); it < ids.end(); it++) + { + LLUUID id = *it; + if (parcel->addToBanList(id, duration)) { - U32 lists_to_update = AL_BAN; + lists_to_update |= AL_BAN; // agent was successfully added to ban list // but we also need to check access list to ensure that agent will not be in two lists simultaneously if (parcel->removeFromAccessList(id)) { lists_to_update |= AL_ACCESS; } - LLViewerParcelMgr::getInstance()->sendParcelAccessListUpdate(lists_to_update); - refresh(); } } + if (lists_to_update > 0) + { + LLViewerParcelMgr::getInstance()->sendParcelAccessListUpdate(lists_to_update); + refresh(); + } } // static diff --git a/indra/newview/llfloaterland.h b/indra/newview/llfloaterland.h index 0540ddb880..e846d42666 100644 --- a/indra/newview/llfloaterland.h +++ b/indra/newview/llfloaterland.h @@ -378,6 +378,7 @@ public: void onClickAddAccess(); void onClickAddBanned(); void callbackAvatarCBBanned(const uuid_vec_t& ids); + void callbackAvatarCBBanned2(const uuid_vec_t& ids, S32 duration); void callbackAvatarCBAccess(const uuid_vec_t& ids); protected: diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 0ebacddd9b..af687b97b1 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -40,6 +40,7 @@ #include "llfloateravatarpicker.h" #include "llfloateravatarrendersettings.h" #include "llfloateravatartextures.h" +#include "llfloaterbanduration.h" #include "llfloaterbigpreview.h" #include "llfloaterbeacons.h" #include "llfloaterbuildoptions.h" @@ -200,6 +201,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("avatar_render_settings", "floater_avatar_render_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarRenderSettings>); LLFloaterReg::add("avatar_textures", "floater_avatar_textures.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterAvatarTextures>); + LLFloaterReg::add("ban_duration", "floater_ban_duration.xml", &LLFloaterReg::build<LLFloaterBanDuration>); LLFloaterReg::add("beacons", "floater_beacons.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBeacons>); LLFloaterReg::add("bulk_perms", "floater_bulk_perms.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterBulkPermission>); LLFloaterReg::add("buy_currency", "floater_buy_currency.xml", &LLFloaterBuyCurrency::buildFloater); diff --git a/indra/newview/skins/default/xui/en/floater_about_land.xml b/indra/newview/skins/default/xui/en/floater_about_land.xml index 535af317d9..841b11e3bc 100644 --- a/indra/newview/skins/default/xui/en/floater_about_land.xml +++ b/indra/newview/skins/default/xui/en/floater_about_land.xml @@ -22,6 +22,14 @@ "Parcel_R_Dark" </floater.string> <floater.string + name="Hours"> + [HOURS] hrs. + </floater.string> + <floater.string + name="Hour"> + hr. + </floater.string> + <floater.string name="Minutes"> [MINUTES] min. </floater.string> @@ -37,6 +45,10 @@ name="Remaining"> remaining </floater.string> + <floater.string + name="Always"> + Always + </floater.string> <tab_container follows="all" halign="left" @@ -2063,19 +2075,29 @@ Only large parcels can be listed in search. name="BanCheck" top="0" width="200"> - Always banned ([COUNT], max [MAX]) + Banned ([COUNT], max [MAX]) </text> <name_list column_padding="0" follows="top|bottom" - heading_height="14" + heading_height="16" height="125" layout="topleft" left="0" multi_select="true" + draw_heading="true" name="BannedList" tool_tip="([LISTED] listed, [MAX] max)" - width="230" /> + width="230"> + <columns + label="Name" + name="name" + width="160" /> + <columns + label="Duration" + name="duration" + width="70" /> + </name_list> <button follows="bottom" height="23" diff --git a/indra/newview/skins/default/xui/en/floater_ban_duration.xml b/indra/newview/skins/default/xui/en/floater_ban_duration.xml new file mode 100644 index 0000000000..2d9e69f7c7 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_ban_duration.xml @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + can_minimize="false" + can_tear_off="false" + can_resize="false" + can_drag_on_left="false" + can_close="true" + height="150" + layout="topleft" + name="ban_duration" + title="Ban duration" + single_instance="true" + width="180"> + <text + type="string" + length="1" + follows="left|top" + height="15" + layout="topleft" + left="15" + name="duration_textbox" + top="10" + width="75"> + Ban duration: + </text> + + <radio_group + draw_border="false" + enabled="true" + follows="left|top" + height="40" + left="20" + mouse_opaque="true" + name="ban_duration_radio" + tab_stop="true" + width="200"> + <radio_item + type="string" + follows="left|top" + height="20" + width="200" + label="Always" + name="always_radio"> + Always + </radio_item> + <radio_item + type="string" + follows="left|top" + height="20" + width="200" + label="Temporary" + name="temporary_radio"> + Temporary + </radio_item> + </radio_group> + + <spinner + allow_text_entry="true" + decimal_digits="0" + follows="left|top" + height="20" + increment="1" + max_val="8766" + min_val="1" + initial_val="1" + name="ban_hours" + top_delta="50" + left="40" + width="40"/> + <text + type="string" + length="1" + follows="left|top" + height="15" + left_delta="50" + name="hours_textbox" + top_delta="5" + width="75"> + hours. + </text> + + <button + follows="left|top" + height="23" + label="Ok" + left="15" + name="ok_btn" + top_delta="30" + width="75"> + </button> + <button + follows="left|top" + height="23" + label="Cancel" + left_pad="0" + name="cancel_btn" + top_delta="0" + width="75"> + </button> +</floater> |