From 347c53855bb0c983e0300594772a9206f9031065 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 13 Apr 2020 22:41:55 +0300 Subject: SL-12607 Added more icons and draw methods to draw them --- indra/newview/CMakeLists.txt | 3 +- indra/newview/llprogressview.cpp | 221 ++++++++++++++++++++- indra/newview/llprogressview.h | 26 ++- indra/newview/llstartup.cpp | 79 +------- indra/newview/llviewertexturelist.cpp | 31 --- indra/newview/llviewerwindow.cpp | 13 +- indra/newview/llviewerwindow.h | 2 +- .../skins/default/xui/en/panel_progress.xml | 21 +- indra/newview/viewer_manifest.py | 6 + 9 files changed, 259 insertions(+), 143 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 1ede6188fb..a5cb9bc3d3 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -1715,12 +1715,11 @@ endif (OPENAL) if (FMODSTUDIO) set(LLSTARTUP_COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS} -DLL_FMODSTUDIO") - # texture list needs to load fmod icon - set_source_files_properties(llviewertexturelist.cpp PROPERTIES COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS}") set(FMODWRAPPER_LIBRARY ${FMODSTUDIO_LIBRARY}) endif (FMODSTUDIO) set_source_files_properties(llstartup.cpp PROPERTIES COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS}") +set_source_files_properties(llprogressview.cpp PROPERTIES COMPILE_FLAGS "${LLSTARTUP_COMPILE_FLAGS}") list(APPEND viewer_SOURCE_FILES ${viewer_HEADER_FILES}) diff --git a/indra/newview/llprogressview.cpp b/indra/newview/llprogressview.cpp index dfa6c97b26..f745d26864 100644 --- a/indra/newview/llprogressview.cpp +++ b/indra/newview/llprogressview.cpp @@ -42,7 +42,6 @@ #include "llbutton.h" #include "llcallbacklist.h" #include "llfocusmgr.h" -#include "lliconctrl.h" #include "llnotifications.h" #include "llprogressbar.h" #include "llstartup.h" @@ -184,7 +183,6 @@ void LLProgressView::setVisible(BOOL visible) if (getVisible() && !visible) { LLPanel::setVisible(FALSE); - setShowLogos(FALSE); } // showing progress view else if (visible && (!getVisible() || mFadeToWorldTimer.getStarted())) @@ -231,6 +229,33 @@ void LLProgressView::drawStartTexture(F32 alpha) gGL.popMatrix(); } +void LLProgressView::drawLogos(F32 alpha) +{ + if (mLogosList.empty()) + { + return; + } + + // logos are tied to label, + // due to potential resizes we have to figure offsets out on draw or resize + LLTextBox *logos_label = getChild("logos_lbl"); + S32 offset_x, offset_y; + logos_label->localPointToScreen(0, 0, &offset_x, &offset_y); + std::vector::const_iterator iter = mLogosList.begin(); + std::vector::const_iterator end = mLogosList.end(); + for (; iter != end; iter++) + { + gl_draw_scaled_image_with_border(iter->mDrawRect.mLeft + offset_x, + iter->mDrawRect.mBottom + offset_y, + iter->mDrawRect.getWidth(), + iter->mDrawRect.getHeight(), + iter->mTexturep.get(), + UI_VERTEX_COLOR % alpha, + FALSE, + iter->mClipRect, + iter->mOffsetRect); + } +} void LLProgressView::draw() { @@ -247,6 +272,7 @@ void LLProgressView::draw() } LLPanel::draw(); + drawLogos(alpha); return; } @@ -259,6 +285,7 @@ void LLProgressView::draw() drawStartTexture(alpha); LLPanel::draw(); + drawLogos(alpha); // faded out completely - remove panel and reveal world if (mFadeToWorldTimer.getElapsedTimeF32() > FADE_TO_WORLD_TIME ) @@ -285,7 +312,7 @@ void LLProgressView::draw() // FIXME: this causes a crash that i haven't been able to fix mMediaCtrl->unloadMediaSource(); - gStartTexture = NULL; + releaseTextures(); } return; } @@ -293,6 +320,7 @@ void LLProgressView::draw() drawStartTexture(1.0f); // draw children LLPanel::draw(); + drawLogos(1.0f); } void LLProgressView::setText(const std::string& text) @@ -311,16 +339,189 @@ void LLProgressView::setMessage(const std::string& msg) getChild("message_text")->setValue(mMessage); } -void LLProgressView::setShowLogos(const BOOL logos_visible) +void LLProgressView::loadLogo(const std::string &path, + const U8 image_codec, + const LLRect &pos_rect, + const LLRectf &clip_rect, + const LLRectf &offset_rect) +{ + // We need these images very early, so we have to force-load them, otherwise they might not load in time. + if (!gDirUtilp->fileExists(path)) + { + return; + } + + LLPointer start_image_frmted = LLImageFormatted::createFromType(image_codec); + if (!start_image_frmted->load(path)) + { + LL_WARNS("AppInit") << "Image load failed: " << path << LL_ENDL; + return; + } + + LLPointer raw = new LLImageRaw; + if (!start_image_frmted->decode(raw, 0.0f)) + { + LL_WARNS("AppInit") << "Image decode failed " << path << LL_ENDL; + return; + } + // HACK: getLocalTexture allows only power of two dimentions + raw->expandToPowerOfTwo(); + + TextureData data; + data.mTexturep = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE); + data.mDrawRect = pos_rect; + data.mClipRect = clip_rect; + data.mOffsetRect = offset_rect; + mLogosList.push_back(data); +} + +void LLProgressView::initLogos() { - LLIconCtrl* logo = getChild("fmod_logo"); - if (logos_visible) + mLogosList.clear(); + + const U8 image_codec = IMG_CODEC_PNG; + const LLRectf default_clip(0.f, 1.f, 1.f, 0.f); + const S32 default_height = 24; + const S32 default_width = 91; + const S32 default_pad = 7; + + // We don't know final screen rect yet, so we can't precalculate position fully + LLTextBox *logos_label = getChild("logos_lbl"); + S32 texture_start_x = logos_label->getFont()->getWidthF32(logos_label->getText()) + default_pad; + S32 texture_start_y = -3; + + // Normally iamges stay in skins folder, but 3p images come from package instead + // of repository and need special handling +#ifdef LL_WINDOWS + std::string temp_str = gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "3p_icons"); +#elif LL_DARWIN + // On MAC use resource directory + std::string temp_str = gDirUtilp->add(gDirUtilp->getAppRODataDir(), "3p_icons"); +#else + std::string temp_str = gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "3p_icons"); +#endif + temp_str += gDirUtilp->getDirDelimiter(); + +#ifdef LL_FMODSTUDIO + const S32 fmod_y_offset = 2; + loadLogo(temp_str + "fmod.png", + image_codec, + LLRect(texture_start_x, texture_start_y + default_height + fmod_y_offset, texture_start_x + default_width + fmod_y_offset, texture_start_y), + default_clip, + default_clip); + + texture_start_x += default_width + default_pad; +#endif + + loadLogo(temp_str + "havok_logo.png", + image_codec, + LLRect(texture_start_x, texture_start_y + default_height, texture_start_x + default_width, texture_start_y), + default_clip, + default_clip); + + texture_start_x += default_width + default_pad - 2; // offset to compensate for enormous borders for vivox + + const LLRectf vivox_clip(0.0f /*repeats*/, 0.52f /*cut starting from center*/, 0.52f, 0.0f); // non-standard icon, clip it + const LLRectf vivox_offset(0.0f, 0.23f, 0.23f, 0.0f); // keeping clipping identical to not mess up scale + const S32 vivox_y_offset = -5; + loadLogo(temp_str + "vivox_logo.png", + image_codec, + LLRect(texture_start_x, texture_start_y + default_height + vivox_y_offset, texture_start_x + default_width, texture_start_y + vivox_y_offset), + vivox_clip, + vivox_offset); +} + +void LLProgressView::initStartTexture(S32 location_id, bool is_in_production) +{ + if (gStartTexture.notNull()) { - logo->setValue(IMG_LOGO_FMOD); + gStartTexture = NULL; + LL_INFOS("AppInit") << "re-initializing start screen" << LL_ENDL; } - logo->setVisible(logos_visible); - getChild("fmod_text")->setVisible(logos_visible); - getChild("message_text")->setVisible(!logos_visible); + + LL_DEBUGS("AppInit") << "Loading startup bitmap..." << LL_ENDL; + + U8 image_codec = IMG_CODEC_PNG; + std::string temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter(); + + if ((S32)START_LOCATION_ID_LAST == location_id) + { + temp_str += LLStartUp::getScreenLastFilename(); + } + else + { + std::string path = temp_str + LLStartUp::getScreenHomeFilename(); + + if (!gDirUtilp->fileExists(path) && is_in_production) + { + // Fallback to old file, can be removed later + // Home image only sets when user changes home, so it will take time for users to switch to pngs + temp_str += "screen_home.bmp"; + image_codec = IMG_CODEC_BMP; + } + else + { + temp_str = path; + } + } + + LLPointer start_image_frmted = LLImageFormatted::createFromType(image_codec); + + // Turn off start screen to get around the occasional readback + // driver bug + if (!gSavedSettings.getBOOL("UseStartScreen")) + { + LL_INFOS("AppInit") << "Bitmap load disabled" << LL_ENDL; + return; + } + else if (!start_image_frmted->load(temp_str)) + { + LL_WARNS("AppInit") << "Bitmap load failed" << LL_ENDL; + gStartTexture = NULL; + } + else + { + gStartImageWidth = start_image_frmted->getWidth(); + gStartImageHeight = start_image_frmted->getHeight(); + + LLPointer raw = new LLImageRaw; + if (!start_image_frmted->decode(raw, 0.0f)) + { + LL_WARNS("AppInit") << "Bitmap decode failed" << LL_ENDL; + gStartTexture = NULL; + } + else + { + // HACK: getLocalTexture allows only power of two dimentions + raw->expandToPowerOfTwo(); + gStartTexture = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE); + } + } + + if (gStartTexture.isNull()) + { + gStartTexture = LLViewerTexture::sBlackImagep; + gStartImageWidth = gStartTexture->getWidth(); + gStartImageHeight = gStartTexture->getHeight(); + } +} + +void LLProgressView::initTextures(S32 location_id, bool is_in_production) +{ + initStartTexture(location_id, is_in_production); + initLogos(); + + LLTextBox *logos_label = getChild("logos_lbl"); + logos_label->setVisible(true); +} + +void LLProgressView::releaseTextures() +{ + gStartTexture = NULL; + mLogosList.clear(); + + LLTextBox *logos_label = getChild("logos_lbl"); + logos_label->setVisible(false); } void LLProgressView::setCancelButtonVisible(BOOL b, const std::string& label) diff --git a/indra/newview/llprogressview.h b/indra/newview/llprogressview.h index 1d4ae3a66f..56377a5889 100644 --- a/indra/newview/llprogressview.h +++ b/indra/newview/llprogressview.h @@ -35,6 +35,7 @@ class LLImageRaw; class LLButton; class LLProgressBar; +class LLViewerTexture; class LLProgressView : public LLPanel, @@ -51,6 +52,7 @@ public: /*virtual*/ void draw(); void drawStartTexture(F32 alpha); + void drawLogos(F32 alpha); /*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask); /*virtual*/ BOOL handleKeyHere(KEY key, MASK mask); @@ -70,8 +72,9 @@ public: void setStartupComplete(); - // turns on logos, hides message of the day - void setShowLogos(const BOOL logos_visible); + // we have to preload local textures to make sure they won't be grey + void initTextures(S32 location_id, bool is_in_production); + void releaseTextures(); void setCancelButtonVisible(BOOL b, const std::string& label); @@ -98,6 +101,25 @@ protected: bool handleUpdate(const LLSD& event_data); static void onIdle(void* user_data); + void loadLogo(const std::string &path, const U8 image_codec, const LLRect &pos_rect, const LLRectf &clip_rect, const LLRectf &offset_rect); + // logos have unusual location and need to be preloaded to not appear grey, then deleted + void initLogos(); + // Loads a bitmap to display during load + void initStartTexture(S32 location_id, bool is_in_production); + +private: + // We need to draw textures on login, but only once. + // So this vector gets filled up for textures to render and gets cleaned later + // Some textures have unusual requirements, so we are rendering directly + class TextureData + { + public: + LLPointer mTexturep; + LLRect mDrawRect; + LLRectf mClipRect; + LLRectf mOffsetRect; + }; + std::vector mLogosList; }; #endif // LL_LLPROGRESSVIEW_H diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 56e8000400..1510506cd9 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -734,7 +734,6 @@ bool idle_startup() display_startup(); // LLViewerMedia::initBrowser(); LLStartUp::setStartupState( STATE_LOGIN_SHOW ); - gViewerWindow->setShowLogos(TRUE); return FALSE; } @@ -1010,9 +1009,8 @@ bool idle_startup() gViewerWindow->getWindow()->setCursor(UI_CURSOR_WAIT); - init_start_screen(agent_location_id); - // Display the startup progress bar. + gViewerWindow->initTextures(agent_location_id); gViewerWindow->setShowProgress(TRUE); gViewerWindow->setProgressCancelButtonVisible(TRUE, LLTrans::getString("Quit")); @@ -2728,81 +2726,6 @@ std::string LLStartUp::getUserId() return gUserCredential->userID(); } -// Loads a bitmap to display during load -void init_start_screen(S32 location_id) -{ - if (gStartTexture.notNull()) - { - gStartTexture = NULL; - LL_INFOS("AppInit") << "re-initializing start screen" << LL_ENDL; - } - - LL_DEBUGS("AppInit") << "Loading startup bitmap..." << LL_ENDL; - - U8 image_codec = IMG_CODEC_PNG; - std::string temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter(); - - if ((S32)START_LOCATION_ID_LAST == location_id) - { - temp_str += LLStartUp::getScreenLastFilename(); - } - else - { - std::string path = temp_str + LLStartUp::getScreenHomeFilename(); - - if (!gDirUtilp->fileExists(path) && LLGridManager::getInstance()->isInProductionGrid()) - { - // Fallback to old file, can be removed later - // Home image only sets when user changes home, so it will take time for users to switch to pngs - temp_str += "screen_home.bmp"; - image_codec = IMG_CODEC_BMP; - } - else - { - temp_str = path; - } - } - - LLPointer start_image_frmted = LLImageFormatted::createFromType(image_codec); - - // Turn off start screen to get around the occasional readback - // driver bug - if(!gSavedSettings.getBOOL("UseStartScreen")) - { - LL_INFOS("AppInit") << "Bitmap load disabled" << LL_ENDL; - return; - } - else if(!start_image_frmted->load(temp_str) ) - { - LL_WARNS("AppInit") << "Bitmap load failed" << LL_ENDL; - gStartTexture = NULL; - } - else - { - gStartImageWidth = start_image_frmted->getWidth(); - gStartImageHeight = start_image_frmted->getHeight(); - - LLPointer raw = new LLImageRaw; - if (!start_image_frmted->decode(raw, 0.0f)) - { - LL_WARNS("AppInit") << "Bitmap decode failed" << LL_ENDL; - gStartTexture = NULL; - } - else - { - raw->expandToPowerOfTwo(); - gStartTexture = LLViewerTextureManager::getLocalTexture(raw.get(), FALSE) ; - } - } - - if(gStartTexture.isNull()) - { - gStartTexture = LLViewerTexture::sBlackImagep ; - gStartImageWidth = gStartTexture->getWidth() ; - gStartImageHeight = gStartTexture->getHeight() ; - } -} - // frees the bitmap void release_start_screen() diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 4221f941f5..06524847d1 100644 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -190,37 +190,6 @@ void LLViewerTextureList::doPreloadImages() mImagePreloads.insert(image); } - // Normally images are located in 'skins' folder in working directory, - // but 3p images were added from packages and had to stay in separate folder - // with path relative to exe. - -#ifdef LL_FMODSTUDIO -#ifdef LL_WINDOWS - std::string full_path = gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "3p_icons", "fmod.png"); -#elif LL_DARWIN - // On MAC use resource directory - std::string full_path = gDirUtilp->add(gDirUtilp->getAppRODataDir(), "3p_icons", "fmod.png"); -#else - std::string full_path = gDirUtilp->getExpandedFilename(LL_PATH_EXECUTABLE, "3p_icons", "fmod.png"); -#endif - image = LLViewerTextureManager::getFetchedTextureFromUrl("file://" + full_path, FTT_LOCAL_FILE, MIPMAP_YES, LLViewerFetchedTexture::BOOST_UI, LLViewerTexture::FETCHED_TEXTURE, - 0, 0, IMG_LOGO_FMOD); - if (image) - { - image->setAddressMode(LLTexUnit::TAM_WRAP); - mImagePreloads.insert(image); - // Speed up load (this texture will be used early) - image->setKnownDrawSize(364, 98); - image->processTextureStats(); - image->setDecodePriority(LLViewerFetchedTexture::maxDecodePriority()); - image->updateFetch(); - // Fmod logo is only needed at startup, if we will get more logos - // for startup, might be good idea to save resources and do loading - // in scope of llprogressview and then unload everything once no - // longer needed - } -#endif - LLPointer img_blak_square_tex(new LLImageRaw(2, 2, 3)); memset(img_blak_square_tex->getData(), 0, img_blak_square_tex->getDataSize()); LLPointer img_blak_square(new LLViewerFetchedTexture(img_blak_square_tex, FTT_DEFAULT, FALSE)); diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 89f3b17021..86cb43555a 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5098,6 +5098,14 @@ void LLViewerWindow::revealIntroPanel() } } +void LLViewerWindow::initTextures(S32 location_id) +{ + if (mProgressView) + { + mProgressView->initTextures(location_id, LLGridManager::getInstance()->isInProductionGrid()); + } +} + void LLViewerWindow::setShowProgress(const BOOL show) { if (mProgressView) @@ -5151,11 +5159,6 @@ void LLViewerWindow::setProgressCancelButtonVisible( BOOL b, const std::string& } } -void LLViewerWindow::setShowLogos(const BOOL show_3p_logos) -{ - mProgressView->setShowLogos(show_3p_logos); -} - LLProgressView *LLViewerWindow::getProgressView() const { return mProgressView; diff --git a/indra/newview/llviewerwindow.h b/indra/newview/llviewerwindow.h index 9adfe7b5c5..44c1fbd066 100644 --- a/indra/newview/llviewerwindow.h +++ b/indra/newview/llviewerwindow.h @@ -303,13 +303,13 @@ public: BOOL getCursorHidden() { return mCursorHidden; } void moveCursorToCenter(); // move to center of window + void initTextures(S32 location_id); void setShowProgress(const BOOL show); BOOL getShowProgress() const; void setProgressString(const std::string& string); void setProgressPercent(const F32 percent); void setProgressMessage(const std::string& msg); void setProgressCancelButtonVisible( BOOL b, const std::string& label = LLStringUtil::null ); - void setShowLogos(const BOOL show_3p_logos); LLProgressView *getProgressView() const; void revealIntroPanel(); void setStartupComplete(); diff --git a/indra/newview/skins/default/xui/en/panel_progress.xml b/indra/newview/skins/default/xui/en/panel_progress.xml index 03caf8e8ad..f52422c08f 100644 --- a/indra/newview/skins/default/xui/en/panel_progress.xml +++ b/indra/newview/skins/default/xui/en/panel_progress.xml @@ -106,27 +106,20 @@ top="145" right="-90" word_wrap="true"/> - + - Made with FMOD Studio by Firelight Technologies Pty Ltd. + Second Life uses