From adcc7f0f46f51c509bf8d2bf419dca7ad34bec20 Mon Sep 17 00:00:00 2001 From: Arrehn Date: Wed, 21 Dec 2011 16:00:11 -0500 Subject: [PATCH] Firestorm Tip Tracker initial implemention, also money notification improvements, code cleanup. --- indra/newview/CMakeLists.txt | 6 +- indra/newview/fsmoneytracker.cpp | 90 +++++++++++++++++++ indra/newview/fsmoneytracker.h | 51 +++++++++++ indra/newview/llnotificationhandler.h | 4 +- indra/newview/llviewerfloaterreg.cpp | 3 + indra/newview/llviewermessage.cpp | 84 +++++++++++++++-- .../xui/en/floater_fs_money_tracker.xml | 31 +++++++ .../skins/default/xui/en/menu_viewer.xml | 8 ++ 8 files changed, 266 insertions(+), 11 deletions(-) create mode 100644 indra/newview/fsmoneytracker.cpp create mode 100644 indra/newview/fsmoneytracker.h create mode 100644 indra/newview/skins/default/xui/en/floater_fs_money_tracker.xml diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 69bb471369..2b2f789995 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -88,6 +88,7 @@ set(viewer_SOURCE_FILES floatermedialists.cpp fscontactsfloater.cpp fsareasearch.cpp + fsmoneytracker.cpp fsdata.cpp fskeywords.cpp fslslbridge.cpp @@ -698,6 +699,7 @@ set(viewer_HEADER_FILES fscontactsfloater.h fsradarlistctrl.h fsareasearch.h + fsmoneytracker.h fsdata.h fskeywords.h fslslbridge.h @@ -708,8 +710,8 @@ set(viewer_HEADER_FILES lggbeammaps.h lggbeamscolors.h lggbeamcolormapfloater.h - lggcontactsets.h - lggcontactsetsfloater.h + lggcontactsets.h + lggcontactsetsfloater.h llaccountingcostmanager.h llagent.h llagentaccess.h diff --git a/indra/newview/fsmoneytracker.cpp b/indra/newview/fsmoneytracker.cpp new file mode 100644 index 0000000000..1d10a12479 --- /dev/null +++ b/indra/newview/fsmoneytracker.cpp @@ -0,0 +1,90 @@ +/** + * @file fsmoneytracker.cpp + * @brief Tip Tracker Window + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Copyright (c) 2011 Arrehn Oberlander + * + * 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 + */ + +#include "llviewerprecompiledheaders.h" +#include "fsmoneytracker.h" +#include "llfloaterreg.h" +#include "llviewercontrol.h" +#include "llchathistory.h" +#include "lllineeditor.h" +#include "llnotificationmanager.h" +#include "lltrans.h" + + + +FSMoneyTracker::FSMoneyTracker(const LLSD& seed) +: LLFloater(seed) +{ +} + +FSMoneyTracker::~FSMoneyTracker() +{ + if (mTransactionHistory) + mTransactionHistory->clear(); +} + +BOOL FSMoneyTracker::postBuild() +{ + mTransactionHistory = getChild("money_chat_history"); + mTransactionHistory->clear(); + + // Button Actions + childSetAction("Clear", boost::bind(&FSMoneyTracker::clear,this)); + + return TRUE; +} + +void FSMoneyTracker::addMessage(const LLChat& chat,bool archive,const LLSD &args) +{ + LLChat& tmp_chat = const_cast(chat); + tmp_chat.mFromName = chat.mFromName; + LLSD chat_args = args; + chat_args["use_plain_text_chat_history"] = true; + if(tmp_chat.mTimeStr.empty()) + tmp_chat.mTimeStr = appendTime(); + + mTransactionHistory->appendMessage(tmp_chat, chat_args); +} + +std::string FSMoneyTracker::appendTime() +{ + time_t utc_time; + utc_time = time_corrected(); + std::string timeStr ="["+ LLTrans::getString("TimeHour")+"]:[" + LLTrans::getString("TimeMin")+"]"; + if (gSavedSettings.getBOOL("FSSecondsinChatTimestamps")) + { + timeStr += ":[" + LLTrans::getString("TimeSec")+"]"; + } + + LLSD substitution; + + substitution["datetime"] = (S32) utc_time; + LLStringUtil::format (timeStr, substitution); + + return timeStr; +} + +void FSMoneyTracker::clear() +{ + llinfos << "Cleared." << llendl; + mTransactionHistory->clear(); +} \ No newline at end of file diff --git a/indra/newview/fsmoneytracker.h b/indra/newview/fsmoneytracker.h new file mode 100644 index 0000000000..1a3515969b --- /dev/null +++ b/indra/newview/fsmoneytracker.h @@ -0,0 +1,51 @@ +/** + * @file fsmoneytracker.h + * @brief Tip Tracker Window + * + * $LicenseInfo:firstyear=2001&license=viewerlgpl$ + * Copyright (c) 2011 Arrehn Oberlander + * + * 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 + */ + +#ifndef FS_MONEYTRACKER_H +#define FS_MONEYTRACKER_H + +#include "llfloater.h" +#include "llsingleton.h" +#include "llchathistory.h" +#include "lllineeditor.h" +#include "llchat.h" +#include + +class LLTextBox; +class LLViewerRegion; + +class FSMoneyTracker: public LLFloater +{ +public: + FSMoneyTracker(const LLSD& seed); + virtual ~FSMoneyTracker(); + + BOOL postBuild(); + void addMessage(const LLChat& chat,bool archive,const LLSD &args); + +private: + void clear(); + std::string appendTime(); + LLChatHistory* mTransactionHistory; +}; + +#endif diff --git a/indra/newview/llnotificationhandler.h b/indra/newview/llnotificationhandler.h index e4958f4654..612715c8d1 100644 --- a/indra/newview/llnotificationhandler.h +++ b/indra/newview/llnotificationhandler.h @@ -54,7 +54,9 @@ typedef enum e_notification_type NT_NEARBYCHAT, NT_ALERT, NT_ALERTMODAL, - NT_OFFER + NT_OFFER, + NT_MONEYCHAT, + NT_RADARCHAT } ENotificationType; /** diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 707b49931e..4f2b09e693 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -154,6 +154,7 @@ #include "fscontactsfloater.h" #include "floatermedialists.h" #include "fsareasearch.h" +#include "fsmoneytracker.h" #include "particleeditor.h" #include "quickprefs.h" // Quick Preferences panel -WoLf #include "lggcontactsetsfloater.h" @@ -273,6 +274,8 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("media_settings", "floater_media_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("message_critical", "floater_critical.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("message_tos", "floater_tos.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + // AO: Firestorm Money (tip) tracker + LLFloaterReg::add("money_tracker", "floater_fs_money_tracker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("moveview", "floater_moveview.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("mute_object_by_name", "floater_mute_object.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("mini_map", "floater_map.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index ca826cc78a..bc0884107e 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -116,7 +116,8 @@ //-TT Client LSL Bridge #include "fslslbridge.h" //-TT - +#include "llfloaterreg.h" +#include "fsmoneytracker.h" #include "fsareasearch.h" #include "fsdata.h" @@ -5890,6 +5891,22 @@ static void money_balance_avatar_notify(const LLUUID& agent_id, // Notification is either PaymentReceived or PaymentSent LLNotificationsUtil::add(notification, args, payload); } + + // TipTracker Support + FSMoneyTracker* tipTracker = (FSMoneyTracker*)LLFloaterReg::getInstance("money_tracker"); + if (tipTracker->isShown() || tipTracker->isMinimized()) + { + args["MESSAGE"] = args["SLURLMESSAGE"]; // Always use slurl forms in money tracking + + LLChat chat; + chat.mText = llformat(args["MESSAGE"].asString().c_str(), av_name.getCompleteName().c_str()); + chat.mSourceType = CHAT_SOURCE_SYSTEM; + LLSD chat_args; + chat_args["type"] = LLNotificationsUI::NT_MONEYCHAT; + tipTracker->addMessage(chat,false,chat_args); + } + // + } static void process_money_balance_reply_extended(LLMessageSystem* msg) @@ -5935,8 +5952,8 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg) } else { - source_slurl = - LLSLURL( "agent", source_id, "completename").getSLURLString(); + //source_slurl =LLSLURL( "agent", source_id, "completename").getSLURLString(); + source_slurl =LLSLURL( "agent", source_id, "inspect").getSLURLString(); } std::string dest_slurl; @@ -5947,8 +5964,8 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg) } else { - dest_slurl = - LLSLURL( "agent", dest_id, "completename").getSLURLString(); + //dest_slurl = LLSLURL( "agent", dest_id, "completename").getSLURLString(); + dest_slurl = LLSLURL( "agent", dest_id, "inspect").getSLURLString(); } std::string reason = @@ -5997,10 +6014,44 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg) message = LLTrans::getString("you_paid_ldollars_no_info", args); } } + + //: Additionally, always add a SLURL-enabled form. + args["NAME"] = dest_slurl; + is_name_group = is_dest_group; + name_id = dest_id; + if (!reason.empty()) + { + if (dest_id.notNull()) + { + message = LLTrans::getString("you_paid_ldollars", args); + } + else + { + // transaction fee to the system, eg, to create a group + message = LLTrans::getString("you_paid_ldollars_no_name", args); + } + } + else + { + if (dest_id.notNull()) + { + message = LLTrans::getString("you_paid_ldollars_no_reason", args); + } + else + { + // no target, no reason, you just paid money + message = LLTrans::getString("you_paid_ldollars_no_info", args); + } + } + final_args["SLURLMESSAGE"] = message; + // + + final_args["MESSAGE"] = message; notification = "PaymentSent"; } - else { + else + { // ...someone paid you args["NAME"] = balance_change_in_chat ? "%s" : source_slurl; is_name_group = is_source_group; @@ -6009,11 +6060,28 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg) { message = LLTrans::getString("paid_you_ldollars", args); } - else { + else + { message = LLTrans::getString("paid_you_ldollars_no_reason", args); } final_args["MESSAGE"] = message; - + + + //: Additionally, always add a SLURL-enabled form. + args["NAME"] = source_slurl; + is_name_group = is_source_group; + name_id = source_id; + if (!reason.empty()) + { + message = LLTrans::getString("paid_you_ldollars", args); + } + else + { + message = LLTrans::getString("paid_you_ldollars_no_reason", args); + } + final_args["SLURLMESSAGE"] = message; + // + // make notification loggable payload["from_id"] = source_id; notification = "PaymentReceived"; diff --git a/indra/newview/skins/default/xui/en/floater_fs_money_tracker.xml b/indra/newview/skins/default/xui/en/floater_fs_money_tracker.xml new file mode 100644 index 0000000000..c91be55a93 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_fs_money_tracker.xml @@ -0,0 +1,31 @@ + + + + +