From de1cf42eb631b1254193e1f9e6e1236da3c4cfda Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Thu, 11 Feb 2010 12:41:10 -0800 Subject: EXT-5044 substasks: turning the event panel into an event floater. reviewed by Richard. --- indra/newview/llfloaterevent.cpp | 331 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 331 insertions(+) create mode 100644 indra/newview/llfloaterevent.cpp (limited to 'indra/newview/llfloaterevent.cpp') diff --git a/indra/newview/llfloaterevent.cpp b/indra/newview/llfloaterevent.cpp new file mode 100644 index 0000000000..91c2810026 --- /dev/null +++ b/indra/newview/llfloaterevent.cpp @@ -0,0 +1,331 @@ +/** + * @file llfloaterevent.cpp + * @brief Display for events in the finder + * + * $LicenseInfo:firstyear=2004&license=viewergpl$ + * + * Copyright (c) 2004-2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloaterevent.h" + +#include "message.h" +#include "llnotificationsutil.h" +#include "llui.h" + +#include "llagent.h" +#include "llviewerwindow.h" +#include "llbutton.h" +#include "llcachename.h" +#include "llcommandhandler.h" // secondlife:///app/chat/ support +#include "lleventflags.h" +#include "lleventnotifier.h" +#include "llfloater.h" +#include "llfloaterreg.h" +#include "llfloaterworldmap.h" +#include "llinventorymodel.h" +#include "llsecondlifeurls.h" +#include "lltextbox.h" +#include "lltexteditor.h" +#include "lluiconstants.h" +#include "llviewercontrol.h" +#include "llweb.h" +#include "llworldmap.h" +#include "lluictrlfactory.h" +#include "lltrans.h" + + +class LLEventHandler : public LLCommandHandler +{ +public: + // requires trusted browser to trigger + LLEventHandler() : LLCommandHandler("event", UNTRUSTED_THROTTLE) { } + bool handle(const LLSD& params, const LLSD& query_map, + LLMediaCtrl* web) + { + if (params.size() < 1) + { + return false; + } + + LLFloaterEvent* floater = LLFloaterReg::getTypedInstance("event"); + if (floater) + { + floater->setEventID(params[0].asInteger()); + LLFloaterReg::showTypedInstance("event"); + return true; + } + + return false; + } +}; +LLEventHandler gEventHandler; + +LLFloaterEvent::LLFloaterEvent(const LLSD& key) + : LLFloater(key), + + mEventID(0) +{ +} + + +LLFloaterEvent::~LLFloaterEvent() +{ +} + + +BOOL LLFloaterEvent::postBuild() +{ + mTBName = getChild("event_name"); + + mTBCategory = getChild("event_category"); + + mTBDate = getChild("event_date"); + + mTBDuration = getChild("event_duration"); + + mTBDesc = getChild("event_desc"); + mTBDesc->setEnabled(FALSE); + + mTBRunBy = getChild("event_runby"); + mTBLocation = getChild("event_location"); + mTBCover = getChild("event_cover"); + + mTeleportBtn = getChild( "teleport_btn"); + mTeleportBtn->setClickedCallback(onClickTeleport, this); + + mMapBtn = getChild( "map_btn"); + mMapBtn->setClickedCallback(onClickMap, this); + + mNotifyBtn = getChild( "notify_btn"); + mNotifyBtn->setClickedCallback(onClickNotify, this); + + mCreateEventBtn = getChild( "create_event_btn"); + mCreateEventBtn->setClickedCallback(onClickCreateEvent, this); + + return TRUE; +} + +void LLFloaterEvent::setEventID(const U32 event_id) +{ + mEventID = event_id; + // Should reset all of the panel state here + resetInfo(); + + if (event_id != 0) + { + sendEventInfoRequest(); + } +} + + +void LLFloaterEvent::sendEventInfoRequest() +{ + LLMessageSystem *msg = gMessageSystem; + + msg->newMessageFast(_PREHASH_EventInfoRequest); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() ); + msg->nextBlockFast(_PREHASH_EventData); + msg->addU32Fast(_PREHASH_EventID, mEventID); + gAgent.sendReliableMessage(); +} + + +//static +void LLFloaterEvent::processEventInfoReply(LLMessageSystem *msg, void **) +{ + // extract the agent id + LLUUID agent_id; + msg->getUUIDFast(_PREHASH_AgentData, _PREHASH_AgentID, agent_id ); + + LLFloaterEvent* floater = LLFloaterReg::getTypedInstance("event"); + + if(floater) + { + floater->mEventInfo.unpack(msg); + floater->mTBName->setText(floater->mEventInfo.mName); + floater->mTBCategory->setText(floater->mEventInfo.mCategoryStr); + floater->mTBDate->setText(floater->mEventInfo.mTimeStr); + floater->mTBDesc->setText(floater->mEventInfo.mDesc); + + floater->mTBDuration->setText(llformat("%d:%.2d", floater->mEventInfo.mDuration / 60, floater->mEventInfo.mDuration % 60)); + + if (!floater->mEventInfo.mHasCover) + { + floater->mTBCover->setText(floater->getString("none")); + } + else + { + floater->mTBCover->setText(llformat("%d", floater->mEventInfo.mCover)); + } + + F32 global_x = (F32)floater->mEventInfo.mPosGlobal.mdV[VX]; + F32 global_y = (F32)floater->mEventInfo.mPosGlobal.mdV[VY]; + + S32 region_x = llround(global_x) % REGION_WIDTH_UNITS; + S32 region_y = llround(global_y) % REGION_WIDTH_UNITS; + S32 region_z = llround((F32)floater->mEventInfo.mPosGlobal.mdV[VZ]); + + std::string desc = floater->mEventInfo.mSimName + llformat(" (%d, %d, %d)", region_x, region_y, region_z); + floater->mTBLocation->setText(desc); + + if (floater->mEventInfo.mEventFlags & EVENT_FLAG_MATURE) + { + floater->childSetVisible("event_mature_yes", TRUE); + floater->childSetVisible("event_mature_no", FALSE); + } + else + { + floater->childSetVisible("event_mature_yes", FALSE); + floater->childSetVisible("event_mature_no", TRUE); + } + + if (floater->mEventInfo.mUnixTime < time_corrected()) + { + floater->mNotifyBtn->setEnabled(FALSE); + } + else + { + floater->mNotifyBtn->setEnabled(TRUE); + } + + if (gEventNotifier.hasNotification(floater->mEventInfo.mID)) + { + floater->mNotifyBtn->setLabel(floater->getString("dont_notify")); + } + else + { + floater->mNotifyBtn->setLabel(floater->getString("notify")); + } + } +} + + +void LLFloaterEvent::draw() +{ + std::string name; + gCacheName->getFullName(mEventInfo.mRunByID, name); + + mTBRunBy->setText(name); + + LLPanel::draw(); +} + +void LLFloaterEvent::resetInfo() +{ + // Clear all of the text fields. +} + +// static +void LLFloaterEvent::onClickTeleport(void* data) +{ + LLFloaterEvent* self = (LLFloaterEvent*)data; + LLFloaterWorldMap* worldmap_instance = LLFloaterWorldMap::getInstance(); + if (!self->mEventInfo.mPosGlobal.isExactlyZero()&&worldmap_instance) + { + gAgent.teleportViaLocation(self->mEventInfo.mPosGlobal); + worldmap_instance->trackLocation(self->mEventInfo.mPosGlobal); + } +} + + +// static +void LLFloaterEvent::onClickMap(void* data) +{ + LLFloaterEvent* self = (LLFloaterEvent*)data; + LLFloaterWorldMap* worldmap_instance = LLFloaterWorldMap::getInstance(); + + if (!self->mEventInfo.mPosGlobal.isExactlyZero()&&worldmap_instance) + { + worldmap_instance->trackLocation(self->mEventInfo.mPosGlobal); + LLFloaterReg::showInstance("world_map", "center"); + } +} + + +// static +/* +void LLPanelEvent::onClickLandmark(void* data) +{ + LLPanelEvent* self = (LLPanelEvent*)data; + //create_landmark(self->mTBName->getText(), "", self->mEventInfo.mPosGlobal); + LLMessageSystem* msg = gMessageSystem; + msg->newMessage("CreateLandmarkForEvent"); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + msg->nextBlockFast(_PREHASH_EventData); + msg->addU32Fast(_PREHASH_EventID, self->mEventID); + msg->nextBlockFast(_PREHASH_InventoryBlock); + LLUUID folder_id; + folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK); + msg->addUUIDFast(_PREHASH_FolderID, folder_id); + msg->addStringFast(_PREHASH_Name, self->mTBName->getText()); + gAgent.sendReliableMessage(); +} +*/ + +// static +void LLFloaterEvent::onClickCreateEvent(void* data) +{ + LLNotificationsUtil::add("PromptGoToEventsPage");//, LLSD(), LLSD(), callbackCreateEventWebPage); +} + +// static +void LLFloaterEvent::onClickNotify(void *data) +{ + LLFloaterEvent* self = (LLFloaterEvent*)data; + + if (!gEventNotifier.hasNotification(self->mEventID)) + { + gEventNotifier.add(self->mEventInfo); + self->mNotifyBtn->setLabel(self->getString("dont_notify")); + } + else + { + gEventNotifier.remove(self->mEventInfo.mID); + self->mNotifyBtn->setLabel(self->getString("notify")); + } +} +/* +// static +bool LLPanelEvent::callbackCreateEventWebPage(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotificationsUtil::getSelectedOption(notification, response); + if (0 == option) + { + llinfos << "Loading events page " << LLNotifications::instance().getGlobalString("EVENTS_URL") << llendl; + + LLWeb::loadURL( LLNotifications::instance().getGlobalString("EVENTS_URL")); + } + return false; +} +*/ + -- cgit v1.2.3 From c61cb61ecc6beca1560a93cdad4ed1bc055c57f9 Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Fri, 12 Feb 2010 11:09:39 -0800 Subject: EXT-5050 Make sure there is a Delete button in God Mode and that it works reviewed by Monore CC# 108 --- indra/newview/llfloaterevent.cpp | 81 ++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 44 deletions(-) (limited to 'indra/newview/llfloaterevent.cpp') diff --git a/indra/newview/llfloaterevent.cpp b/indra/newview/llfloaterevent.cpp index 91c2810026..a51c613c37 100644 --- a/indra/newview/llfloaterevent.cpp +++ b/indra/newview/llfloaterevent.cpp @@ -45,11 +45,13 @@ #include "llcommandhandler.h" // secondlife:///app/chat/ support #include "lleventflags.h" #include "lleventnotifier.h" +#include "llexpandabletextbox.h" #include "llfloater.h" #include "llfloaterreg.h" #include "llfloaterworldmap.h" #include "llinventorymodel.h" #include "llsecondlifeurls.h" +#include "llslurl.h" #include "lltextbox.h" #include "lltexteditor.h" #include "lluiconstants.h" @@ -109,7 +111,7 @@ BOOL LLFloaterEvent::postBuild() mTBDuration = getChild("event_duration"); - mTBDesc = getChild("event_desc"); + mTBDesc = getChild("event_desc"); mTBDesc->setEnabled(FALSE); mTBRunBy = getChild("event_runby"); @@ -128,6 +130,9 @@ BOOL LLFloaterEvent::postBuild() mCreateEventBtn = getChild( "create_event_btn"); mCreateEventBtn->setClickedCallback(onClickCreateEvent, this); + mGodDeleteEventBtn = getChild( "god_delete_event_btn"); + mGodDeleteEventBtn->setClickedCallback(boost::bind(&LLFloaterEvent::onClickDeleteEvent, this)); + return TRUE; } @@ -143,6 +148,20 @@ void LLFloaterEvent::setEventID(const U32 event_id) } } +void LLFloaterEvent::onClickDeleteEvent() +{ + LLMessageSystem* msg = gMessageSystem; + + msg->newMessageFast(_PREHASH_EventGodDelete); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + + msg->nextBlockFast(_PREHASH_EventData); + msg->addU32Fast(_PREHASH_EventID, mEventID); + + gAgent.sendReliableMessage(); +} void LLFloaterEvent::sendEventInfoRequest() { @@ -157,7 +176,6 @@ void LLFloaterEvent::sendEventInfoRequest() gAgent.sendReliableMessage(); } - //static void LLFloaterEvent::processEventInfoReply(LLMessageSystem *msg, void **) { @@ -174,6 +192,7 @@ void LLFloaterEvent::processEventInfoReply(LLMessageSystem *msg, void **) floater->mTBCategory->setText(floater->mEventInfo.mCategoryStr); floater->mTBDate->setText(floater->mEventInfo.mTimeStr); floater->mTBDesc->setText(floater->mEventInfo.mDesc); + floater->mTBRunBy->setText(LLSLURL::buildCommand("agent", floater->mEventInfo.mRunByID, "inspect")); floater->mTBDuration->setText(llformat("%d:%.2d", floater->mEventInfo.mDuration / 60, floater->mEventInfo.mDuration % 60)); @@ -224,23 +243,33 @@ void LLFloaterEvent::processEventInfoReply(LLMessageSystem *msg, void **) { floater->mNotifyBtn->setLabel(floater->getString("notify")); } + + floater->mMapBtn->setEnabled(TRUE); + floater->mTeleportBtn->setEnabled(TRUE); } } void LLFloaterEvent::draw() { - std::string name; - gCacheName->getFullName(mEventInfo.mRunByID, name); - - mTBRunBy->setText(name); + mGodDeleteEventBtn->setVisible(gAgent.isGodlike()); LLPanel::draw(); } void LLFloaterEvent::resetInfo() { - // Clear all of the text fields. + mTBName->setText(LLStringUtil::null); + mTBCategory->setText(LLStringUtil::null); + mTBDate->setText(LLStringUtil::null); + mTBDesc->setText(LLStringUtil::null); + mTBDuration->setText(LLStringUtil::null); + mTBCover->setText(LLStringUtil::null); + mTBLocation->setText(LLStringUtil::null); + mTBRunBy->setText(LLStringUtil::null); + mNotifyBtn->setEnabled(FALSE); + mMapBtn->setEnabled(FALSE); + mTeleportBtn->setEnabled(FALSE); } // static @@ -270,34 +299,13 @@ void LLFloaterEvent::onClickMap(void* data) } -// static -/* -void LLPanelEvent::onClickLandmark(void* data) -{ - LLPanelEvent* self = (LLPanelEvent*)data; - //create_landmark(self->mTBName->getText(), "", self->mEventInfo.mPosGlobal); - LLMessageSystem* msg = gMessageSystem; - msg->newMessage("CreateLandmarkForEvent"); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - msg->nextBlockFast(_PREHASH_EventData); - msg->addU32Fast(_PREHASH_EventID, self->mEventID); - msg->nextBlockFast(_PREHASH_InventoryBlock); - LLUUID folder_id; - folder_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_LANDMARK); - msg->addUUIDFast(_PREHASH_FolderID, folder_id); - msg->addStringFast(_PREHASH_Name, self->mTBName->getText()); - gAgent.sendReliableMessage(); -} -*/ - // static void LLFloaterEvent::onClickCreateEvent(void* data) { LLNotificationsUtil::add("PromptGoToEventsPage");//, LLSD(), LLSD(), callbackCreateEventWebPage); } + // static void LLFloaterEvent::onClickNotify(void *data) { @@ -314,18 +322,3 @@ void LLFloaterEvent::onClickNotify(void *data) self->mNotifyBtn->setLabel(self->getString("notify")); } } -/* -// static -bool LLPanelEvent::callbackCreateEventWebPage(const LLSD& notification, const LLSD& response) -{ - S32 option = LLNotificationsUtil::getSelectedOption(notification, response); - if (0 == option) - { - llinfos << "Loading events page " << LLNotifications::instance().getGlobalString("EVENTS_URL") << llendl; - - LLWeb::loadURL( LLNotifications::instance().getGlobalString("EVENTS_URL")); - } - return false; -} -*/ - -- cgit v1.2.3 From 21be0916a4b707654e99a8c6c734d24e4bb5da7c Mon Sep 17 00:00:00 2001 From: Leyla Farazha Date: Fri, 12 Feb 2010 12:07:16 -0800 Subject: fixing windows eol --- indra/newview/llfloaterevent.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'indra/newview/llfloaterevent.cpp') diff --git a/indra/newview/llfloaterevent.cpp b/indra/newview/llfloaterevent.cpp index a51c613c37..64efa10ef9 100644 --- a/indra/newview/llfloaterevent.cpp +++ b/indra/newview/llfloaterevent.cpp @@ -150,16 +150,16 @@ void LLFloaterEvent::setEventID(const U32 event_id) void LLFloaterEvent::onClickDeleteEvent() { - LLMessageSystem* msg = gMessageSystem; - - msg->newMessageFast(_PREHASH_EventGodDelete); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - - msg->nextBlockFast(_PREHASH_EventData); - msg->addU32Fast(_PREHASH_EventID, mEventID); - + LLMessageSystem* msg = gMessageSystem; + + msg->newMessageFast(_PREHASH_EventGodDelete); + msg->nextBlockFast(_PREHASH_AgentData); + msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + + msg->nextBlockFast(_PREHASH_EventData); + msg->addU32Fast(_PREHASH_EventID, mEventID); + gAgent.sendReliableMessage(); } -- cgit v1.2.3