summaryrefslogtreecommitdiff
path: root/indra/newview/llpanelenvironment.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpanelenvironment.cpp')
-rw-r--r--indra/newview/llpanelenvironment.cpp133
1 files changed, 75 insertions, 58 deletions
diff --git a/indra/newview/llpanelenvironment.cpp b/indra/newview/llpanelenvironment.cpp
index 51e2c05070..d3df88b65e 100644
--- a/indra/newview/llpanelenvironment.cpp
+++ b/indra/newview/llpanelenvironment.cpp
@@ -48,6 +48,7 @@
#include "llappviewer.h"
#include "llcallbacklist.h"
+#include "llviewercontrol.h"
#include "llviewerparcelmgr.h"
#include "llinventorymodel.h"
@@ -58,14 +59,6 @@ namespace
const std::string FLOATER_DAY_CYCLE_EDIT("env_edit_extdaycycle");
const std::string STRING_REGION_ENV("str_region_env");
const std::string STRING_EMPTY_NAME("str_empty");
-
- inline bool ends_with(std::string const & value, std::string const & ending)
- {
- if (ending.size() > value.size())
- return false;
- return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
- }
-
}
//=========================================================================
@@ -400,8 +393,10 @@ std::string LLPanelEnvironmentInfo::getNameForTrackIndex(U32 index)
if (invname.empty())
{
invname = getNameForTrackIndex(index - 1);
- if (invname[0] != '(')
+ if (!invname.empty() && invname.front() != '(')
+ {
invname = "(" + invname + ")";
+ }
}
return invname;
@@ -766,7 +761,7 @@ void LLPanelEnvironmentInfo::commitDayLenOffsetChanges(bool need_callback)
(S32)mCurrentEnvironment->mDayLength.value(),
(S32)mCurrentEnvironment->mDayOffset.value(),
LLEnvironment::altitudes_vect_t(),
- [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); });
+ [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { onEnvironmentReceived(that_h, parcel_id, envifo); });
}
else
{
@@ -854,7 +849,7 @@ void LLPanelEnvironmentInfo::onBtnDefault()
if (opt == 0)
{
LLEnvironment::instance().resetParcel(parcel_id,
- [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); });
+ [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { onEnvironmentReceived(that_h, parcel_id, envifo); });
}
});
}
@@ -866,31 +861,30 @@ void LLPanelEnvironmentInfo::onBtnEdit()
LLFloaterEditExtDayCycle *dayeditor = getEditFloater();
LLSD params(LLSDMap(LLFloaterEditExtDayCycle::KEY_EDIT_CONTEXT, isRegion() ? LLFloaterEditExtDayCycle::VALUE_CONTEXT_REGION : LLFloaterEditExtDayCycle::VALUE_CONTEXT_PARCEL)
- (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, mCurrentEnvironment ? (S32)(mCurrentEnvironment->mDayLength.value()) : FOURHOURS)
- (LLFloaterEditExtDayCycle::KEY_CANMOD, LLSD::Boolean(true)));
+ (LLFloaterEditExtDayCycle::KEY_DAY_LENGTH, mCurrentEnvironment ? (S32)(mCurrentEnvironment->mDayLength.value()) : FOURHOURS));
dayeditor->openFloater(params);
+
if (mCurrentEnvironment && mCurrentEnvironment->mDayCycle)
{
dayeditor->setEditDayCycle(mCurrentEnvironment->mDayCycle);
- if (!ends_with(mCurrentEnvironment->mDayCycle->getName(), "(customized)"))
- {
- dayeditor->setEditName(mCurrentEnvironment->mDayCycle->getName() + "(customized)");
- }
+ dayeditor->setEditName(mCurrentEnvironment->mDayCycleName);
}
else
+ {
dayeditor->setEditDefaultDayCycle();
+ }
}
void LLPanelEnvironmentInfo::onBtnSelect()
{
- LLFloaterSettingsPicker *picker = getSettingsPicker();
- if (picker)
+ if (LLFloaterSettingsPicker* picker = getSettingsPicker())
{
LLUUID item_id;
if (mCurrentEnvironment && mCurrentEnvironment->mDayCycle)
{
- item_id = LLFloaterSettingsPicker::findItemID(mCurrentEnvironment->mDayCycle->getAssetId(), false, false);
+ LLUUID asset_id = mCurrentEnvironment->mDayCycle->getAssetId();
+ item_id = LLFloaterSettingsPicker::findItemID(asset_id, false);
}
picker->setSettingsFilter(LLSettingsType::ST_NONE);
picker->setSettingsItemId(item_id);
@@ -921,7 +915,7 @@ void LLPanelEnvironmentInfo::onBtnRstAltitudes()
mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayLength.value() : -1,
mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayOffset.value() : -1,
alts,
- [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); });
+ [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { onEnvironmentReceived(that_h, parcel_id, envifo); });
}
}
@@ -946,19 +940,29 @@ void LLPanelEnvironmentInfo::udpateApparentTimeOfDay()
S32Hours hourofday(secondofday);
S32Seconds secondofhour(secondofday - hourofday);
S32Minutes minutesofhour(secondofhour);
+ static bool use_24h = gSavedSettings.getBOOL("Use24HourClock");
bool am_pm(hourofday.value() >= 12);
- if (hourofday.value() < 1)
- hourofday = S32Hours(12);
- if (hourofday.value() > 12)
- hourofday -= S32Hours(12);
+ if (!use_24h)
+ {
+ if (hourofday.value() < 1)
+ hourofday = S32Hours(12);
+ if (hourofday.value() > 12)
+ hourofday -= S32Hours(12);
+ }
std::string lblminute(((minutesofhour.value() < 10) ? "0" : "") + LLSD(minutesofhour.value()).asString());
-
mLabelApparentTime->setTextArg("[HH]", LLSD(hourofday.value()).asString());
mLabelApparentTime->setTextArg("[MM]", lblminute);
- mLabelApparentTime->setTextArg("[AP]", std::string(am_pm ? "PM" : "AM"));
+ if (use_24h)
+ {
+ mLabelApparentTime->setTextArg("[AP]", std::string());
+ }
+ else
+ {
+ mLabelApparentTime->setTextArg("[AP]", std::string(am_pm ? "PM" : "AM"));
+ }
mLabelApparentTime->setTextArg("[PRC]", LLSD((S32)(100 * perc)).asString());
}
@@ -987,32 +991,41 @@ void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id, std::string sourc
void LLPanelEnvironmentInfo::onPickerCommitted(LLUUID item_id, S32 track_num)
{
- LLInventoryItem *itemp = gInventory.getItem(item_id);
- if (itemp)
+ if (LLInventoryItem* itemp = gInventory.getItem(item_id))
{
+ LL_INFOS("ENVPANEL") << "item '" << item_id << "' : '" << itemp->getDescription() << "'" << LL_ENDL;
+
LLHandle<LLPanel> that_h = getHandle();
clearDirtyFlag(DIRTY_FLAG_DAYLENGTH);
clearDirtyFlag(DIRTY_FLAG_DAYOFFSET);
U32 flags(0);
- if (itemp)
+ if (!itemp->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID()))
{
- if (!itemp->getPermissions().allowOperationBy(PERM_MODIFY, gAgent.getID()))
- flags |= LLSettingsBase::FLAG_NOMOD;
- if (!itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()))
- flags |= LLSettingsBase::FLAG_NOTRANS;
+ flags |= LLSettingsBase::FLAG_NOMOD;
}
- LLEnvironment::instance().updateParcel(getParcelId(),
- itemp->getAssetUUID(),
- itemp->getName(),
- track_num,
- mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayLength.value() : -1,
- mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayOffset.value() : -1,
- flags,
- LLEnvironment::altitudes_vect_t(),
- [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); });
+ if (!itemp->getPermissions().allowOperationBy(PERM_TRANSFER, gAgent.getID()))
+ {
+ flags |= LLSettingsBase::FLAG_NOTRANS;
+ }
+
+ LLEnvironment::instance().updateParcel
+ (
+ getParcelId(),
+ itemp->getAssetUUID(),
+ itemp->getName(),
+ track_num,
+ mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayLength.value() : -1,
+ mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayOffset.value() : -1,
+ flags,
+ LLEnvironment::altitudes_vect_t(),
+ [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo)
+ {
+ onEnvironmentReceived(that_h, parcel_id, envifo);
+ }
+ );
}
}
@@ -1020,17 +1033,20 @@ void LLPanelEnvironmentInfo::onEditCommitted(LLSettingsDay::ptr_t newday)
{
LLEnvironment::instance().clearEnvironment(LLEnvironment::ENV_EDIT);
LLEnvironment::instance().updateEnvironment();
+
if (!newday)
{
LL_WARNS("ENVPANEL") << "Editor committed an empty day. Do nothing." << LL_ENDL;
return;
}
+
if (!mCurrentEnvironment)
{
// Attempting to save mid update?
LL_WARNS("ENVPANEL") << "Failed to apply changes from editor! Dirty state: " << mDirtyFlag << " env version: " << mCurEnvVersion << LL_ENDL;
return;
}
+
size_t newhash(newday->getHash());
size_t oldhash((mCurrentEnvironment->mDayCycle) ? mCurrentEnvironment->mDayCycle->getHash() : 0);
@@ -1045,7 +1061,7 @@ void LLPanelEnvironmentInfo::onEditCommitted(LLSettingsDay::ptr_t newday)
mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayLength.value() : -1,
mCurrentEnvironment ? (S32)mCurrentEnvironment->mDayOffset.value() : -1,
LLEnvironment::altitudes_vect_t(),
- [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { _onEnvironmentReceived(that_h, parcel_id, envifo); });
+ [that_h](S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo) { onEnvironmentReceived(that_h, parcel_id, envifo); });
}
}
@@ -1082,8 +1098,7 @@ void LLPanelEnvironmentInfo::onEnvironmentChanged(LLEnvironment::EnvSelection_t
else if ((env == LLEnvironment::ENV_PARCEL)
&& (getParcelId() == LLViewerParcelMgr::instance().getAgentParcelId()))
{
- LLParcel *parcel = getParcel();
- if (parcel)
+ if (LLParcel* parcel = getParcel())
{
// first for parcel own settings, second is for case when parcel uses region settings
if (mCurEnvVersion < new_version
@@ -1145,17 +1160,21 @@ void LLPanelEnvironmentInfo::onEnvironmentReceived(S32 parcel_id, LLEnvironment:
// todo: we have envifo and parcel env version, should we just setEnvironment() and parcel's property to prevent dupplicate requests?
}
-void LLPanelEnvironmentInfo::_onEnvironmentReceived(LLHandle<LLPanel> that_h, S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo)
+// static
+void LLPanelEnvironmentInfo::onEnvironmentReceived(LLHandle<LLPanel> that_h, S32 parcel_id, LLEnvironment::EnvironmentInfo::ptr_t envifo)
{
- LLPanelEnvironmentInfo *that = (LLPanelEnvironmentInfo *)that_h.get();
- if (!that)
- return;
- that->onEnvironmentReceived(parcel_id, envifo);
+ if (LLPanelEnvironmentInfo* that = (LLPanelEnvironmentInfo*)that_h.get())
+ {
+ that->onEnvironmentReceived(parcel_id, envifo);
+ }
}
LLSettingsDropTarget::LLSettingsDropTarget(const LLSettingsDropTarget::Params& p)
- : LLView(p), mEnvironmentInfoPanel(NULL), mDndEnabled(false)
-{}
+ : LLView(p)
+ , mEnvironmentInfoPanel(NULL)
+ , mDndEnabled(false)
+{
+}
bool LLSettingsDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
EDragAndDropType cargo_type,
@@ -1172,11 +1191,9 @@ bool LLSettingsDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
switch (cargo_type)
{
case DAD_SETTINGS:
- {
- LLViewerInventoryItem* inv_item = (LLViewerInventoryItem*)cargo_data;
- if (inv_item && mEnvironmentInfoPanel)
+ if (cargo_data && mEnvironmentInfoPanel)
{
- LLUUID item_id = inv_item->getUUID();
+ LLUUID item_id = ((LLViewerInventoryItem*)cargo_data)->getUUID();
if (gInventory.getItem(item_id))
{
*accept = ACCEPT_YES_COPY_SINGLE;
@@ -1192,11 +1209,11 @@ bool LLSettingsDropTarget::handleDragAndDrop(S32 x, S32 y, MASK mask, bool drop,
*accept = ACCEPT_NO;
}
break;
- }
default:
*accept = ACCEPT_NO;
break;
}
}
+
return handled;
}