diff --git a/indra/newview/llfloatertransactionlog.cpp b/indra/newview/llfloatertransactionlog.cpp index 508835a08aa5d04a466e460a50f7db55d7ef1979..ddf691408e2c509ae6eee3a70b836b690b602d57 100644 --- a/indra/newview/llfloatertransactionlog.cpp +++ b/indra/newview/llfloatertransactionlog.cpp @@ -1,103 +1,123 @@ - /* - * @file llfloatertransactionlog.h - * @brief Transaction log floater - * - * (C) 2014 Cinder Roxley @ Second Life <cinder@sdf.org> - * - * Permission is hereby granted, free of charge, to any person or organization - * obtaining a copy of the software and accompanying documentation covered by - * this license (the "Software") to use, reproduce, display, distribute, - * execute, and transmit the Software, and to prepare derivative works of the - * Software, and to permit third-parties to whom the Software is furnished to - * do so, all subject to the following: - * - * The copyright notices in the Software and this entire statement, including - * the above license grant, this restriction and the following disclaimer, - * must be included in all copies of the Software, in whole or in part, and - * all derivative works of the Software, unless such copies or derivative - * works are solely in the form of machine-executable object code generated by - * a source language processor. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT - * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE - * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - - #include "llviewerprecompiledheaders.h" - #include "llfloatertransactionlog.h" - - #include "llavataractions.h" - #include "llavatarnamecache.h" - #include "llscrolllistctrl.h" - #include "llscrolllistitem.h" - #include "lltextbase.h" - - LLFloaterTransactionLog::LLFloaterTransactionLog(const LLSD& key) - : LLFloater(key) - , mList(nullptr) - , mTotalText(nullptr) - , mTotal(0) - , mAvatarNameCacheConnection() - { +/* + * @file llfloatertransactionlog.h + * @brief Transaction log floater + * + * (C) 2014 Cinder Roxley @ Second Life <cinder@sdf.org> + * (C) 2024 Improvements by Fallen Kiyori Shadow + * + * Permission is hereby granted, free of charge, to any person or organization + * obtaining a copy of the software and accompanying documentation covered by + * this license (the "Software") to use, reproduce, display, distribute, + * execute, and transmit the Software, and to prepare derivative works of the + * Software, and to permit third-parties to whom the Software is furnished to + * do so, all subject to the following: + * + * The copyright notices in the Software and this entire statement, including + * the above license grant, this restriction and the following disclaimer, + * must be included in all copies of the Software, in whole or in part, and + * all derivative works of the Software, unless such copies or derivative + * works are solely in the form of machine-executable object code generated by + * a source language processor. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT + * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE + * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include "llviewerprecompiledheaders.h" +#include "llfloatertransactionlog.h" + +#include "llavataractions.h" +#include "llavatarnamecache.h" +#include "llscrolllistctrl.h" +#include "llscrolllistitem.h" +#include "lltextbase.h" + +LLFloaterTransactionLog::LLFloaterTransactionLog(const LLSD& key) : + LLFloater(key), + mList(nullptr), + mTotalText(nullptr), + mReceivedTotal(0), + mSpentTotal(0), + mAvatarNameCacheConnection() +{ mCommitCallbackRegistrar.add("TL.Reset", boost::bind(&LLFloaterTransactionLog::reset, this)); - } +} - LLFloaterTransactionLog::~LLFloaterTransactionLog() - { +LLFloaterTransactionLog::~LLFloaterTransactionLog() +{ if (mAvatarNameCacheConnection.connected()) mAvatarNameCacheConnection.disconnect(); - } +} - BOOL LLFloaterTransactionLog::postBuild() - { +BOOL LLFloaterTransactionLog::postBuild() +{ mList = getChild<LLScrollListCtrl>("transaction_list"); mList->setDoubleClickCallback(boost::bind(&LLFloaterTransactionLog::onDoubleClick, this)); mTotalText = getChild<LLTextBase>("total"); return TRUE; - } +} - void LLFloaterTransactionLog::addTransaction(const LLDate& date, const LLUUID& sender, S32 amount) - { +void LLFloaterTransactionLog::addTransaction(const LLDate& date, const LLUUID& sender, S32 amount, bool incoming) +{ // drop it - if (!getVisible()) return; + if (!getVisible()) + return; LLStringUtil::format_map_t args; - args["TOTAL"] = std::to_string(mTotal += amount); + + if (incoming) + { + mReceivedTotal += amount; + } + else + { + mSpentTotal += amount; + } + + args["TOTAL_RECEIVED"] = std::to_string(mReceivedTotal); + args["TOTAL_SPENT"] = std::to_string(mSpentTotal); + mTotalText->setValue(getString("total_fmt", args)); LLSD row; - row["value"] = sender; + row["value"] = sender; row["column"][0]["column"] = "time"; - row["column"][0]["value"] = date.toHTTPDateString(LLStringExplicit("%H:%M:%S"));; + row["column"][0]["value"] = date.toHTTPDateString(LLStringExplicit("%H:%M:%S")); row["column"][2]["column"] = "amount"; - row["column"][2]["value"] = llformat("L$%d", amount); + row["column"][2]["value"] = llformat("L$%d", (incoming ? amount : -amount)); row["column"][2]["halign"] = LLFontGL::RIGHT; - mAvatarNameCacheConnection = LLAvatarNameCache::get(sender, boost::bind(&LLFloaterTransactionLog::onAvatarNameCache, this, _1, _2, row)); - } + mAvatarNameCacheConnection = + LLAvatarNameCache::get(sender, boost::bind(&LLFloaterTransactionLog::onAvatarNameCache, this, _1, _2, row)); +} - void LLFloaterTransactionLog::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name, LLSD& row) - { +void LLFloaterTransactionLog::onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name, LLSD& row) +{ row["column"][1]["column"] = "name"; - row["column"][1]["value"] = av_name.getDisplayName(); + row["column"][1]["value"] = av_name.getDisplayName(); mList->addElement(row); - } +} - void LLFloaterTransactionLog::onDoubleClick() - { +void LLFloaterTransactionLog::onDoubleClick() +{ const LLUUID& id = mList->getFirstSelected()->getValue().asUUID(); LLAvatarActions::showProfile(id); - } +} - void LLFloaterTransactionLog::reset() - { +void LLFloaterTransactionLog::reset() +{ mList->deleteAllItems(); - mTotal = 0; + mReceivedTotal = 0; + mSpentTotal = 0; + LLStringUtil::format_map_t args; - args["TOTAL"] = std::to_string(mTotal); + args["TOTAL_RECEIVED"] = std::to_string(mReceivedTotal); + args["TOTAL_SPENT"] = std::to_string(mSpentTotal); + mTotalText->setValue(getString("total_fmt", args)); - } +} diff --git a/indra/newview/llfloatertransactionlog.h b/indra/newview/llfloatertransactionlog.h index c261bd37ed88fe0811cd325c906103cbaa2e4016..a596f25fd7fc7c0450096642a1778083d55feebd 100644 --- a/indra/newview/llfloatertransactionlog.h +++ b/indra/newview/llfloatertransactionlog.h @@ -41,7 +41,7 @@ class LLFloaterTransactionLog : public LLFloater public: LLFloaterTransactionLog(const LLSD& key); BOOL postBuild(); - void addTransaction(const LLDate& date, const LLUUID& sender, S32 amount); + void addTransaction(const LLDate& date, const LLUUID& sender, S32 amount, bool incoming); private: ~LLFloaterTransactionLog(); @@ -51,7 +51,8 @@ class LLFloaterTransactionLog : public LLFloater LLScrollListCtrl* mList; LLTextBase* mTotalText; - S32 mTotal; + S32 mReceivedTotal; + S32 mSpentTotal; boost::signals2::connection mAvatarNameCacheConnection; }; diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 652bbc25d7480de3298e6df0f732949dd91707ba..67d62ec67463f4b4d09ebeaaf6e2ec68fc03ce80 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -5278,6 +5278,8 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg) final_args["MESSAGE"] = message; payload["dest_id"] = dest_id; notification = success ? "PaymentSent" : "PaymentFailure"; + LLFloaterTransactionLog* floater = LLFloaterReg::findTypedInstance<LLFloaterTransactionLog>("transaction_log"); + if (floater) floater->addTransaction(LLDate::now(), source_id, amount, false); } else { @@ -5305,7 +5307,7 @@ static void process_money_balance_reply_extended(LLMessageSystem* msg) notification = "PaymentReceived"; LLFloaterTransactionLog* floater = LLFloaterReg::findTypedInstance<LLFloaterTransactionLog>("transaction_log"); - if (floater) floater->addTransaction(LLDate::now(), source_id, amount); + if (floater) floater->addTransaction(LLDate::now(), source_id, amount, true); } diff --git a/indra/newview/skins/default/xui/en/floater_transaction_log.xml b/indra/newview/skins/default/xui/en/floater_transaction_log.xml index 321965c7cbdb9c356f4dcff06ba39bde6fb988c0..2161dbf26206037218bcd3eadbc9950907d8afc7 100644 --- a/indra/newview/skins/default/xui/en/floater_transaction_log.xml +++ b/indra/newview/skins/default/xui/en/floater_transaction_log.xml @@ -4,15 +4,17 @@ can_drag_on_left="false" can_minimize="true" can_resize="true" - height="300" - width="300" + height="500" + width="350" + min_width="450" + min_height="200" name="floater_transaction_log" title="Transaction Log" single_instance="true" save_rect="true"> - <floater.string + <floater.string name="total_fmt"> -Total: L$[TOTAL] + Received: L$ [TOTAL_RECEIVED] | Spent: L$ -[TOTAL_SPENT] </floater.string> <scroll_list draw_heading="true" @@ -30,27 +32,28 @@ Total: L$[TOTAL] <column name="name" dynamicwidth="true" label="Name" /> <column name="amount" width="70" label="Amount" /> </scroll_list> - <text + <text type="string" length="1" - follows="bottom|right" + follows="left|bottom" font="SansSerif" height="20" layout="topleft" name="total" - top_pad="2" - width="89" - left="129" - halign="right" - value="Total: L$0" /> - <button - label="Reset" - follows="bottom|right" - height="20" - left_pad="3" - name="btn_reset" - width="75"> - <button.commit_callback + left="15" + value="Received: L$ 0 | Spent: L$ -0"/> + </text> + <button + label="Reset" + top_pad="-20" + name="btn_reset" + font="SansSerif" + mouse_opaque="true" + height="20" + width="75" + right="325" + follows="right|bottom"> + <button.commit_callback function="TL.Reset" /> - </button> + </button> </floater>