From 09cdedb147db175e38d08b9a6020b8bd3d07dc91 Mon Sep 17 00:00:00 2001 From: Mnikolenko Productengine Date: Mon, 10 Aug 2026 20:56:05 +0300 Subject: Replace LLFloaterBuyCurrencyHTML with new L$ packs web floater --- indra/newview/app_settings/settings.xml | 24 ++++- indra/newview/llbuycurrencyhtml.cpp | 19 ++-- indra/newview/llbuycurrencyhtml.h | 6 +- indra/newview/llfloaterbuycurrencyhtml.cpp | 103 ++++++--------------- indra/newview/llfloaterbuycurrencyhtml.h | 43 ++++----- .../default/xui/en/floater_buy_currency_html.xml | 17 ++-- 6 files changed, 83 insertions(+), 129 deletions(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index ad307f9648..459f8c1b42 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -1172,6 +1172,28 @@ Value 1 + BuyCurrencyHTML + + Comment + Use HTML based L$ packs floater instead of legacy XUI version + Persist + 1 + Type + Boolean + Value + 1 + + BuyCurrencyPacksURL + + Comment + URL for the L$ packs purchase floater + Persist + 1 + Type + String + Value + https://accounts.secondlife.com/packs/floater?lang=[LANGUAGE]&shortfall=[SHORTFALL] + EnableButtonFlashing Comment @@ -7182,7 +7204,7 @@ QuickBuyCurrency Comment - Toggle between HTML based currency purchase floater and legacy XUI version + (Deprecated) Use BuyCurrencyHTML instead Persist 1 Type diff --git a/indra/newview/llbuycurrencyhtml.cpp b/indra/newview/llbuycurrencyhtml.cpp index e6c4d44573..8469eaa6ff 100644 --- a/indra/newview/llbuycurrencyhtml.cpp +++ b/indra/newview/llbuycurrencyhtml.cpp @@ -89,14 +89,14 @@ LLBuyCurrencyHTMLHandler gBuyCurrencyHTMLHandler; //////////////////////////////////////////////////////////////////////////////// // static // Opens the legacy XUI based floater or new HTML based one based on -// the QuickBuyCurrency value in settings.xml - this overload is for +// the BuyCurrencyHTML value in settings.xml - this overload is for // the case where the amount is not requested. void LLBuyCurrencyHTML::openCurrencyFloater() { - if ( gSavedSettings.getBOOL( "QuickBuyCurrency" ) ) + if ( gSavedSettings.getBOOL( "BuyCurrencyHTML" ) ) { // HTML version - LLBuyCurrencyHTML::showDialog( false, "", 0 ); + LLBuyCurrencyHTML::showDialog(); } else { @@ -108,14 +108,13 @@ void LLBuyCurrencyHTML::openCurrencyFloater() //////////////////////////////////////////////////////////////////////////////// // static // Opens the legacy XUI based floater or new HTML based one based on -// the QuickBuyCurrency value in settings.xml - this overload is for +// the BuyCurrencyHTML value in settings.xml - this overload is for // the case where the amount and a string to display are requested. void LLBuyCurrencyHTML::openCurrencyFloater( const std::string& message, S32 sum ) { - if ( gSavedSettings.getBOOL( "QuickBuyCurrency" ) ) + if ( gSavedSettings.getBOOL( "BuyCurrencyHTML" ) ) { - // HTML version - LLBuyCurrencyHTML::showDialog( true, message, sum ); + LLBuyCurrencyHTML::showDialog(sum - gStatusBar->getBalance()); } else { @@ -126,13 +125,13 @@ void LLBuyCurrencyHTML::openCurrencyFloater( const std::string& message, S32 sum //////////////////////////////////////////////////////////////////////////////// // static -void LLBuyCurrencyHTML::showDialog( bool specific_sum_requested, const std::string& message, S32 sum ) +void LLBuyCurrencyHTML::showDialog(S32 shortfall) { LLFloaterBuyCurrencyHTML* buy_currency_floater = dynamic_cast< LLFloaterBuyCurrencyHTML* >( LLFloaterReg::getInstance( "buy_currency_html" ) ); if ( buy_currency_floater ) { // pass on flag indicating if we want to buy specific amount and if so, how much - buy_currency_floater->setParams( specific_sum_requested, message, sum ); + buy_currency_floater->setShortfall(shortfall); // force navigate to new URL buy_currency_floater->navigateToFinalURL(); @@ -144,7 +143,7 @@ void LLBuyCurrencyHTML::showDialog( bool specific_sum_requested, const std::stri buy_currency_floater->setFrontmost( take_focus ); // spec calls for floater to be centered on client window - buy_currency_floater->center(); + //buy_currency_floater->center(); } else { diff --git a/indra/newview/llbuycurrencyhtml.h b/indra/newview/llbuycurrencyhtml.h index 5e3d30dcd0..54ee82159d 100644 --- a/indra/newview/llbuycurrencyhtml.h +++ b/indra/newview/llbuycurrencyhtml.h @@ -29,8 +29,6 @@ #include "llsingleton.h" -class LLFloaterBuyCurrencyHTML; - class LLBuyCurrencyHTML { public: @@ -41,8 +39,8 @@ class LLBuyCurrencyHTML static void openCurrencyFloater( const std::string& message, S32 sum ); // show and give focus to actual currency floater - this is used for both cases - // where the sum is required and where it is not - static void showDialog( bool specific_sum_requested, const std::string& message, S32 sum ); + // where the shortfall is required and where it is not + static void showDialog( S32 shortfall = 0 ); // close (and destroy) the currency floater static void closeDialog(); diff --git a/indra/newview/llfloaterbuycurrencyhtml.cpp b/indra/newview/llfloaterbuycurrencyhtml.cpp index d3712869b0..24ec43e7e4 100644 --- a/indra/newview/llfloaterbuycurrencyhtml.cpp +++ b/indra/newview/llfloaterbuycurrencyhtml.cpp @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2010&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2026, 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 @@ -27,97 +27,46 @@ #include "llviewerprecompiledheaders.h" #include "llfloaterbuycurrencyhtml.h" -#include "llhttpconstants.h" -#include "llstatusbar.h" +#include "llmediactrl.h" +#include "llviewercontrol.h" +#include "llweb.h" -//////////////////////////////////////////////////////////////////////////////// -// -LLFloaterBuyCurrencyHTML::LLFloaterBuyCurrencyHTML( const LLSD& key ): - LLFloater( key ), - mSpecificSumRequested( false ), - mMessage( "" ), - mSum( 0 ) + +LLFloaterBuyCurrencyHTML::LLFloaterBuyCurrencyHTML(const LLSD& key) + : LLFloater(key), + mBrowser(nullptr) { } -//////////////////////////////////////////////////////////////////////////////// -// -bool LLFloaterBuyCurrencyHTML::postBuild() +LLFloaterBuyCurrencyHTML::~LLFloaterBuyCurrencyHTML() { - // observer media events - mBrowser = getChild( "browser" ); - mBrowser->addObserver( this ); +} +bool LLFloaterBuyCurrencyHTML::postBuild() +{ + mBrowser = getChild("browser"); + mBrowser->setErrorPageURL(gSavedSettings.getString("GenericErrorPageURL")); + LLViewerMedia::getInstance()->getOpenIDCookie(mBrowser); return true; } -//////////////////////////////////////////////////////////////////////////////// -// void LLFloaterBuyCurrencyHTML::navigateToFinalURL() { - // URL for actual currency buy contents is in XUI file - std::string buy_currency_url = getString( "buy_currency_url" ); + std::string buy_currency_url = gSavedSettings.getString("BuyCurrencyPacksURL"); - // replace [LANGUAGE] meta-tag with view language LLStringUtil::format_map_t replace; - - // viewer language - replace[ "[LANGUAGE]" ] = LLUI::getLanguage(); - - // flag that specific amount requested - replace[ "[SPECIFIC_AMOUNT]" ] = ( mSpecificSumRequested ? "y":"n" ); - - // amount requested - std::ostringstream codec( "" ); - codec << mSum; - replace[ "[SUM]" ] = codec.str(); - - // users' current balance - codec.clear(); - codec.str( "" ); - codec << gStatusBar->getBalance(); - replace[ "[BAL]" ] = codec.str(); - - // message - "This cost L$x,xxx for example - replace[ "[MSG]" ] = LLURI::escape( mMessage ); - LLStringUtil::format( buy_currency_url, replace ); - - // write final URL to debug console - LL_INFOS() << "Buy currency HTML parsed URL is " << buy_currency_url << LL_ENDL; - - // kick off the navigation - mBrowser->navigateTo( buy_currency_url, HTTP_CONTENT_TEXT_HTML ); -} - -//////////////////////////////////////////////////////////////////////////////// -// -void LLFloaterBuyCurrencyHTML::handleMediaEvent( LLPluginClassMedia* self, EMediaEvent event ) -{ - // placeholder for now - just in case we want to catch media events - if ( LLPluginClassMediaOwner::MEDIA_EVENT_NAVIGATE_COMPLETE == event ) + replace["[LANGUAGE]"] = LLUI::getLanguage(); + if (mShortfall > 0) { - // update currency after we complete a navigation since there are many ways - // this can result in a different L$ balance - LLStatusBar::sendMoneyBalanceRequest(); - }; -} + replace["[SHORTFALL]"] = std::to_string(mShortfall); + } -//////////////////////////////////////////////////////////////////////////////// -// -void LLFloaterBuyCurrencyHTML::onClose( bool app_quitting ) -{ - // Update L$ balance one more time - LLStatusBar::sendMoneyBalanceRequest(); + LLStringUtil::format(buy_currency_url, replace); - destroy(); -} + if (mShortfall <= 0) + { + LLStringUtil::replaceString(buy_currency_url, "&shortfall=[SHORTFALL]", ""); + } -//////////////////////////////////////////////////////////////////////////////// -// -void LLFloaterBuyCurrencyHTML::setParams( bool specific_sum_requested, const std::string& message, S32 sum ) -{ - // save these away - used to construct URL later - mSpecificSumRequested = specific_sum_requested; - mMessage = message; - mSum = sum; + mBrowser->navigateTo(buy_currency_url, HTTP_CONTENT_TEXT_HTML); } diff --git a/indra/newview/llfloaterbuycurrencyhtml.h b/indra/newview/llfloaterbuycurrencyhtml.h index 23a29cae4c..e8dbd0a716 100644 --- a/indra/newview/llfloaterbuycurrencyhtml.h +++ b/indra/newview/llfloaterbuycurrencyhtml.h @@ -4,7 +4,7 @@ * * $LicenseInfo:firstyear=2010&license=viewerlgpl$ * Second Life Viewer Source Code - * Copyright (C) 2010, Linden Research, Inc. + * Copyright (C) 2026, 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 @@ -24,36 +24,25 @@ * $/LicenseInfo$ */ -#ifndef LL_LLFLOATERBUYCURRENCYHTML_H -#define LL_LLFLOATERBUYCURRENCYHTML_H +#pragma once #include "llfloater.h" #include "llmediactrl.h" -class LLFloaterBuyCurrencyHTML : - public LLFloater, - public LLViewerMediaObserver +class LLFloaterBuyCurrencyHTML: + public LLFloater { - public: - LLFloaterBuyCurrencyHTML( const LLSD& key ); - - /*virtual*/ bool postBuild(); - /*virtual*/ void onClose( bool app_quitting ); - - // inherited from LLViewerMediaObserver - /*virtual*/ void handleMediaEvent( LLPluginClassMedia* self, EMediaEvent event ); - - // allow our controlling parent to tell us paramters - void setParams( bool specific_sum_requested, const std::string& message, S32 sum ); - - // parse and construct URL and set browser to navigate there. - void navigateToFinalURL(); - - private: - LLMediaCtrl* mBrowser; - bool mSpecificSumRequested; - std::string mMessage; - S32 mSum; + friend class LLFloaterReg; + +public: + LLFloaterBuyCurrencyHTML(const LLSD& key); + ~LLFloaterBuyCurrencyHTML(); + bool postBuild() override; + void navigateToFinalURL(); + void setShortfall(S32 shortfall) { mShortfall = shortfall; } + +private: + LLMediaCtrl* mBrowser; + S32 mShortfall{0}; }; -#endif // LL_LLFLOATERBUYCURRENCYHTML_H diff --git a/indra/newview/skins/default/xui/en/floater_buy_currency_html.xml b/indra/newview/skins/default/xui/en/floater_buy_currency_html.xml index 996937cd45..782d45120b 100644 --- a/indra/newview/skins/default/xui/en/floater_buy_currency_html.xml +++ b/indra/newview/skins/default/xui/en/floater_buy_currency_html.xml @@ -1,20 +1,17 @@ - - https://quick-buy.secondlife.com/[LANGUAGE]/display/?sa=[SPECIFIC_AMOUNT]&sum=[SUM]&msg=[MSG]&bal=[BAL] - + title="BUY L$">