From 16a3f7197dfd471355f8d068a8a57b10da1b11e8 Mon Sep 17 00:00:00 2001 From: cinder <cinder@cinderblocks.biz> Date: Fri, 18 Nov 2022 03:59:00 -0600 Subject: [PATCH] Better Teleport Progress --- indra/newview/CMakeLists.txt | 2 + indra/newview/llfloaterprogressview.cpp | 98 +++++++++++++++++++ indra/newview/llfloaterprogressview.h | 60 ++++++++++++ indra/newview/llviewerdisplay.cpp | 37 +++---- indra/newview/llviewerfloaterreg.cpp | 2 + .../default/xui/en/floater_progress_view.xml | 68 +++++++++++++ 6 files changed, 250 insertions(+), 17 deletions(-) create mode 100644 indra/newview/llfloaterprogressview.cpp create mode 100644 indra/newview/llfloaterprogressview.h create mode 100644 indra/newview/skins/default/xui/en/floater_progress_view.xml diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 4e57a359e83..08954bbb8ec 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -333,6 +333,7 @@ set(viewer_SOURCE_FILES llfloaterpreference.cpp llfloaterpreferenceviewadvanced.cpp llfloaterpreviewtrash.cpp + llfloaterprogressview.cpp llfloaterproperties.cpp llfloaterregiondebugconsole.cpp llfloaterregioninfo.cpp @@ -1026,6 +1027,7 @@ set(viewer_HEADER_FILES llfloaterpreference.h llfloaterpreferenceviewadvanced.h llfloaterpreviewtrash.h + llfloaterprogressview.h llfloaterproperties.h llfloaterregiondebugconsole.h llfloaterregioninfo.h diff --git a/indra/newview/llfloaterprogressview.cpp b/indra/newview/llfloaterprogressview.cpp new file mode 100644 index 00000000000..50b37e748cf --- /dev/null +++ b/indra/newview/llfloaterprogressview.cpp @@ -0,0 +1,98 @@ +/** + * @file llfloaterprogressview.cpp + * @brief Progress floater + * + * Copyright (c) 2014, Cinder Roxley <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 "llfloaterprogressview.h" + +#include "llfloaterreg.h" +#include "llprogressbar.h" +#include "lltextbase.h" +#include "lltrans.h" + +#include "llagent.h" + +LLFloaterProgressView::LLFloaterProgressView(const LLSD& key) +: LLFloater(key) +, mProgressBar(nullptr) +, mProgressText(nullptr) +, mLocationText(nullptr) +, mCancelBtn(nullptr) +{ + mCommitCallbackRegistrar.add("cancel", boost::bind(&LLFloaterProgressView::onCommitCancel, this, _1)); +} + +LLFloaterProgressView::~LLFloaterProgressView() +{ +} + +BOOL LLFloaterProgressView::postBuild() +{ + mProgressBar = getChild<LLProgressBar>("progress_bar"); + mProgressText = getChild<LLTextBase>("progress_text"); + mLocationText = getChild<LLTextBase>("location"); + mCancelBtn = getChild<LLButton>("cancel_btn"); + return TRUE; +} + +void LLFloaterProgressView::setRegion(const std::string& region) +{ + if (region.empty()) + mLocationText->setText(getString("teleporting")); + else + { + LLStringUtil::format_map_t arg; + arg["REGION"] = region; + mLocationText->setText(getString("loc_fmt", arg)); + } +} + +void LLFloaterProgressView::setProgressText(const std::string& text) +{ + mProgressText->setValue(text); +} + +void LLFloaterProgressView::setProgressPercent(const F32 percent) +{ + mProgressBar->setValue(percent); +} + +void LLFloaterProgressView::setProgressCancelButtonVisible(BOOL visible, const std::string& label) +{ + mCancelBtn->setVisible(visible); + mCancelBtn->setEnabled(visible); + mCancelBtn->setLabelSelected(label); + mCancelBtn->setLabelUnselected(label); +} + +void LLFloaterProgressView::onCommitCancel(LLUICtrl* ctrl) +{ + gAgent.teleportCancel(); + ctrl->setEnabled(FALSE); +} diff --git a/indra/newview/llfloaterprogressview.h b/indra/newview/llfloaterprogressview.h new file mode 100644 index 00000000000..84ffd0ef807 --- /dev/null +++ b/indra/newview/llfloaterprogressview.h @@ -0,0 +1,60 @@ +/** + * @file llfloaterprogressview.h + * @brief Progress floater + * + * Copyright (c) 2014, Cinder Roxley <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. + * + */ + +#ifndef LL_FLOATERPROGRESSVIEW_H +#define LL_FLOATERPROGRESSVIEW_H + +#include "llfloater.h" + +class LLButton; +class LLProgressBar; +class LLTextBase; + +class LLFloaterProgressView final : public LLFloater +{ +public: + LLFloaterProgressView(const LLSD& key); + BOOL postBuild() override; + void setProgressCancelButtonVisible(BOOL visible, const std::string& label = LLStringUtil::null); + void setProgressText(const std::string& text); + void setProgressPercent(const F32 percent); + void setRegion(const std::string& region = LLStringUtil::null); + +private: + ~LLFloaterProgressView(); + void onCommitCancel(LLUICtrl* ctrl); + + LLProgressBar* mProgressBar; + LLTextBase* mProgressText; + LLTextBase* mLocationText; + LLButton* mCancelBtn; +}; + +#endif // LL_FLOATERPROGRESSVIEW_H diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 860bf853a65..7b6d60f654c 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -42,6 +42,8 @@ #include "lldrawpoolalpha.h" #include "llfeaturemanager.h" //#include "llfirstuse.h" +#include "llfloaterprogressview.h" +#include "llfloaterreg.h" #include "llhudmanager.h" #include "llimagepng.h" #include "llmemory.h" @@ -465,48 +467,49 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) gAgent.setTeleportMessage(LLStringUtil::null); } + LLFloaterProgressView* pProgFloater = LLFloaterReg::getTypedInstance<LLFloaterProgressView>("progress_view"); + const std::string& message = gAgent.getTeleportMessage(); switch( gAgent.getTeleportState() ) { case LLAgent::TELEPORT_PENDING: gTeleportDisplayTimer.reset(); - gViewerWindow->setShowProgress(TRUE); - gViewerWindow->setProgressPercent(llmin(teleport_percent, 0.0f)); + pProgFloater->setVisible(TRUE); + pProgFloater->setProgressPercent(llmin(teleport_percent, 0.f)); gAgent.setTeleportMessage(LLAgent::sTeleportProgressMessages["pending"]); - gViewerWindow->setProgressString(LLAgent::sTeleportProgressMessages["pending"]); + pProgFloater->setProgressText(LLAgent::sTeleportProgressMessages["pending"]); break; case LLAgent::TELEPORT_START: // Transition to REQUESTED. Viewer has sent some kind // of TeleportRequest to the source simulator gTeleportDisplayTimer.reset(); - gViewerWindow->setShowProgress(TRUE); - gViewerWindow->setProgressPercent(llmin(teleport_percent, 0.0f)); + pProgFloater->setVisible(TRUE); + pProgFloater->setProgressPercent(llmin(teleport_percent, 0.f)); LL_INFOS("Teleport") << "A teleport request has been sent, setting state to TELEPORT_REQUESTED" << LL_ENDL; gAgent.setTeleportState( LLAgent::TELEPORT_REQUESTED ); gAgent.setTeleportMessage( LLAgent::sTeleportProgressMessages["requesting"]); - gViewerWindow->setProgressString(LLAgent::sTeleportProgressMessages["requesting"]); - gViewerWindow->setProgressMessage(gAgent.mMOTD); + pProgFloater->setProgressText(LLAgent::sTeleportProgressMessages["requesting"]); break; case LLAgent::TELEPORT_REQUESTED: // Waiting for source simulator to respond - gViewerWindow->setProgressPercent( llmin(teleport_percent, 37.5f) ); - gViewerWindow->setProgressString(message); + pProgFloater->setProgressPercent(llmin(teleport_percent, 37.5f)); + pProgFloater->setProgressText(message); break; case LLAgent::TELEPORT_MOVING: // Viewer has received destination location from source simulator - gViewerWindow->setProgressPercent( llmin(teleport_percent, 75.f) ); - gViewerWindow->setProgressString(message); + pProgFloater->setProgressPercent(llmin(teleport_percent, 75.f)); + pProgFloater->setProgressText(message); break; case LLAgent::TELEPORT_START_ARRIVAL: // Transition to ARRIVING. Viewer has received avatar update, etc., from destination simulator gTeleportArrivalTimer.reset(); - gViewerWindow->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")); - gViewerWindow->setProgressPercent(75.f); +pProgFloater->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")); + pProgFloater->setProgressPercent(75.f); LL_INFOS("Teleport") << "Changing state to TELEPORT_ARRIVING" << LL_ENDL; gAgent.setTeleportState( LLAgent::TELEPORT_ARRIVING ); gAgent.setTeleportMessage( @@ -528,9 +531,9 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LL_INFOS("Teleport") << "arrival_fraction is " << arrival_fraction << " changing state to TELEPORT_NONE" << LL_ENDL; gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); } - gViewerWindow->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")); - gViewerWindow->setProgressPercent( arrival_fraction * 25.f + 75.f); - gViewerWindow->setProgressString(message); + pProgFloater->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")); + pProgFloater->setProgressPercent(arrival_fraction * 25.f + 75.f); + pProgFloater->setProgressText(message); } break; @@ -552,7 +555,7 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) case LLAgent::TELEPORT_NONE: // No teleport in progress - gViewerWindow->setShowProgress(FALSE); + pProgFloater->setVisible(FALSE); gTeleportDisplay = FALSE; // [SL:KB] - Patch: Appearance-TeleportAttachKill | Checked: Catznip-4.0 LLViewerParcelMgr::getInstance()->onTeleportDone(); diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 6b73a0c5eeb..46a0e9e5487 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -126,6 +126,7 @@ #include "llfloaterpreferenceviewadvanced.h" #include "llfloaterpreviewtrash.h" #include "llfloaterprofile.h" +#include "llfloaterprogressview.h" #include "llfloaterproperties.h" #include "llfloaterregiondebugconsole.h" #include "llfloaterregioninfo.h" @@ -424,6 +425,7 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("lightbox", "floater_lightbox_settings.xml", (LLFloaterBuildFunc) &LLFloaterReg::build<ALFloaterLightBox>); LLFloaterReg::add("music_ticker", "floater_music_ticker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>); LLFloaterReg::add("particle_editor", "floater_particle_editor.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<ALFloaterParticleEditor>); + LLFloaterReg::add("progress_view", "floater_progress_view.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterProgressView>); LLFloaterReg::add("quick_settings", "floater_quick_settings.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloater>); LLFloaterReg::add("region_tracker", "floater_region_tracker.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<ALFloaterRegionTracker>); LLFloaterReg::add("search", "floater_directory.xml", (LLFloaterBuildFunc)&LLFloaterReg::build<LLFloaterDirectory>); diff --git a/indra/newview/skins/default/xui/en/floater_progress_view.xml b/indra/newview/skins/default/xui/en/floater_progress_view.xml new file mode 100644 index 00000000000..ddbb235e268 --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_progress_view.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<floater + positioning="centered" + header_height="0" + height="90" + layout="topleft" + name="progress_view" + chrome="false" + can_resize="false" + can_close="false" + can_minimize="false" + single_instance="true" + width="420"> + <floater.string + name="loc_fmt"> +Teleporting to [REGION]... + </floater.string> + <floater.string + name="teleporting"> +Teleporting... + </floater.string> + <text + height="26" + use_ellipses="true" + type="string" + text_color="LabelTextColor" + font="SansSerifHugeBold" + length="1" + follows="top|left" + layout="topleft" + name="location" + top="6" + left="6" + right="-6" + value="[APP_NAME]" /> + <text + height="20" + use_ellipses="true" + font="SanSerifHuge" + type="string" + length="1" + follows="top|right" + layout="topleft" + name="progress_text" + top_pad="10" + left="6" + width="334" /> + <button + height="24" + label="Cancel" + left_pad="4" + name="cancel_btn" + top_delta="-4" + width="70"> + <button.commit_callback + function="cancel" /> + </button> + <progress_bar + height="16" + follows="top|left" + layout="topleft" + name="progress_bar" + top_pad="4" + left="6" + right="-6" + tool_tip="progress bar" + color_bar="EmphasisColor"/> +</floater> -- GitLab