From 51ccaa26f80b2c896f622b5da19e9b6e8032643c Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sun, 1 Aug 2010 22:33:02 -0700 Subject: Added first use grid selector for selecting the default grid when Imprudence is first run --- linden/indra/newview/CMakeLists.txt | 3 + linden/indra/newview/app_settings/settings.xml | 11 +++ linden/indra/newview/floatergriddefault.cpp | 102 +++++++++++++++++++++ linden/indra/newview/floatergriddefault.h | 49 ++++++++++ linden/indra/newview/llappviewer.cpp | 1 + linden/indra/newview/llfirstuse.cpp | 14 +++ linden/indra/newview/llfirstuse.h | 1 + linden/indra/newview/llpanellogin.cpp | 64 ++++++++----- linden/indra/newview/llpanellogin.h | 2 + .../xui/en-us/floater_grid_default_selector.xml | 19 ++++ 10 files changed, 242 insertions(+), 24 deletions(-) create mode 100644 linden/indra/newview/floatergriddefault.cpp create mode 100644 linden/indra/newview/floatergriddefault.h create mode 100644 linden/indra/newview/skins/default/xui/en-us/floater_grid_default_selector.xml (limited to 'linden/indra') diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt index 7077dde..b64726d 100644 --- a/linden/indra/newview/CMakeLists.txt +++ b/linden/indra/newview/CMakeLists.txt @@ -69,6 +69,7 @@ set(viewer_SOURCE_FILES emeraldboobutils.cpp floaterao.cpp floaterbusy.cpp + floatergriddefault.cpp floatergridmanager.cpp hbfloatergrouptitles.cpp hippoGridManager.cpp @@ -501,6 +502,7 @@ set(viewer_HEADER_FILES emeraldboobutils.h floaterao.h floaterbusy.h + floatergriddefault.h floatergridmanager.h hbfloatergrouptitles.h hippoGridManager.h @@ -1132,6 +1134,7 @@ set(viewer_XUI_FILES skins/default/xui/en-us/floater_font_test.xml skins/default/xui/en-us/floater_gesture.xml skins/default/xui/en-us/floater_god_tools.xml + skins/default/xui/en-us/floater_grid_default_selector.xml skins/default/xui/en-us/floater_grid_manager.xml skins/default/xui/en-us/floater_group_info.xml skins/default/xui/en-us/floater_group_titles.xml diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index c144f95..9c95b1f 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -844,6 +844,17 @@ Value 1 + WarnFirstLoginScreen + + Comment + Enables default grid selector on FirstLoginScreen + Persist + 1 + Type + Boolean + Value + 1 + WarnFirstMiniMap Comment diff --git a/linden/indra/newview/floatergriddefault.cpp b/linden/indra/newview/floatergriddefault.cpp new file mode 100644 index 0000000..2c853df --- /dev/null +++ b/linden/indra/newview/floatergriddefault.cpp @@ -0,0 +1,102 @@ +/** +* @file floatergriddefault.cpp +* @brief prompts user to set the default grid on first use +* +* $LicenseInfo:firstyear=2009&license=viewergpl$ +* +* Copyright (c) 2010, McCabe Maxsted +* +* Imprudence Viewer Source Code +* The source code in this file ("Source Code") is provided to you +* under the terms of the GNU General Public License, version 2.0 +* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in +* this distribution, or online at +* http://secondlifegrid.net/programs/open_source/licensing/gplv2 +* +* There are special exceptions to the terms and conditions of the GPL as +* it is applied to this Source Code. View the full text of the exception +* in the file doc/FLOSS-exception.txt in this software distribution, or +* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception +* +* By copying, modifying or distributing this software, you acknowledge +* that you have read and understood your obligations described above, +* and agree to abide by those obligations. +* +* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO +* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, +* COMPLETENESS OR PERFORMANCE. +* $/LicenseInfo$ +*/ + +#include "llviewerprecompiledheaders.h" + +#include "floatergriddefault.h" + +#include "hippoGridManager.h" +#include "llpanellogin.h" +#include "llscrolllistctrl.h" +#include "lluictrlfactory.h" + +FloaterGridDefault::FloaterGridDefault(const LLSD& key) +{ + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_grid_default_selector.xml"); +} + +FloaterGridDefault::~FloaterGridDefault() +{ +} + +BOOL FloaterGridDefault::postBuild() +{ + // populate the grid chooser + LLScrollListCtrl* grid_list = getChild("grid_list"); + grid_list->deleteAllItems(); + + LLSD element; + + for (HippoGridManager::GridIterator it = gHippoGridManager->beginGrid(); it != gHippoGridManager->endGrid(); ++it) + { + std::string grid_nick = it->second->getGridNick(); + // There's no reason why empty grids nicks should be in this list, ugh + if (!grid_nick.empty()) + { + element["id"] = grid_nick; + element["columns"][0]["column"] = "grid"; + element["columns"][0]["type"] = "text"; + element["columns"][0]["value"] = grid_nick; + grid_list->addElement(element, ADD_BOTTOM); + } + } + + grid_list->setFocus(TRUE); + + childSetAction("btn_ok", onClickOK, this); + childSetAction("btn_cancel", onClickCancel, this); + + return TRUE; +} + +// static +void FloaterGridDefault::onClickOK(void* userdata) +{ + FloaterGridDefault* self = (FloaterGridDefault*)userdata; + + LLScrollListCtrl* grid_list = self->getChild("grid_list"); + std::string selected = grid_list->getFirstSelected()->getValue().asString(); + + if (!selected.empty() || selected != gHippoGridManager->getCurrentGridNick()) + { + gHippoGridManager->setDefaultGrid(selected); + gHippoGridManager->setCurrentGridAsConnected(); + gHippoGridManager->saveFile(); + LLPanelLogin::updateGridCombo(selected); + } + self->close(); +} + +// static +void FloaterGridDefault::onClickCancel(void* userdata) +{ + FloaterGridDefault* self = (FloaterGridDefault*)userdata; + self->close(); +} diff --git a/linden/indra/newview/floatergriddefault.h b/linden/indra/newview/floatergriddefault.h new file mode 100644 index 0000000..009e23f --- /dev/null +++ b/linden/indra/newview/floatergriddefault.h @@ -0,0 +1,49 @@ +/** +* @file floatergriddefault.h +* @brief prompts user to set the default grid on first use +* +* $LicenseInfo:firstyear=2009&license=viewergpl$ +* +* Copyright (c) 2010, McCabe Maxsted +* +* Imprudence Viewer Source Code +* The source code in this file ("Source Code") is provided to you +* under the terms of the GNU General Public License, version 2.0 +* ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in +* this distribution, or online at +* http://secondlifegrid.net/programs/open_source/licensing/gplv2 +* +* There are special exceptions to the terms and conditions of the GPL as +* it is applied to this Source Code. View the full text of the exception +* in the file doc/FLOSS-exception.txt in this software distribution, or +* online at http://secondlifegrid.net/programs/open_source/licensing/flossexception +* +* By copying, modifying or distributing this software, you acknowledge +* that you have read and understood your obligations described above, +* and agree to abide by those obligations. +* +* ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO +* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, +* COMPLETENESS OR PERFORMANCE. +* $/LicenseInfo$ +*/ + +#ifndef FLOATERGRIDDEFAULT_H +#define FLOATERGRIDDEFAULT_H + +#include "llfloater.h" + +class FloaterGridDefault : public LLFloater, public LLFloaterSingleton +{ +public: + FloaterGridDefault(const LLSD& key); + ~FloaterGridDefault(); + + /*virtual*/ BOOL postBuild(); + +private: + static void onClickOK(void* userdata); + static void onClickCancel(void* userdata); +}; + +#endif // FLOATERGRIDDEFAULT_H diff --git a/linden/indra/newview/llappviewer.cpp b/linden/indra/newview/llappviewer.cpp index cba1af1..db2854d 100644 --- a/linden/indra/newview/llappviewer.cpp +++ b/linden/indra/newview/llappviewer.cpp @@ -1827,6 +1827,7 @@ bool LLAppViewer::initConfiguration() LLFirstUse::addConfigVariable("FirstSculptedPrim"); LLFirstUse::addConfigVariable("FirstVoice"); LLFirstUse::addConfigVariable("FirstMedia"); + LLFirstUse::addConfigVariable("FirstLoginScreen"); // - read command line settings. LLControlGroupCLP clp; diff --git a/linden/indra/newview/llfirstuse.cpp b/linden/indra/newview/llfirstuse.cpp index 34e3fcc..c0f07e5 100644 --- a/linden/indra/newview/llfirstuse.cpp +++ b/linden/indra/newview/llfirstuse.cpp @@ -46,6 +46,7 @@ #include "lltracker.h" #include "llvoavatar.h" +#include "floatergriddefault.h" #include "hippoGridManager.h" // [RLVa:KB] - Version: 1.22.11 @@ -308,6 +309,7 @@ void LLFirstUse::useMedia() LLNotifications::instance().add("FirstMedia"); } } + void LLFirstUse::callbackClientTags(const LLSD& notification, const LLSD& response) { gSavedSettings.setWarning("ClientTags", FALSE); @@ -331,6 +333,7 @@ void LLFirstUse::callbackClientTags(const LLSD& notification, const LLSD& respon gSavedSettings.setBOOL("DownloadClientTags",FALSE); } } + // static void LLFirstUse::ClientTags() { @@ -340,3 +343,14 @@ void LLFirstUse::ClientTags() } } +// static +void LLFirstUse::useLoginScreen() +{ + if (gSavedSettings.getWarning("FirstLoginScreen")) + { + gSavedSettings.setWarning("FirstLoginScreen", FALSE); + + FloaterGridDefault::getInstance()->open(); + FloaterGridDefault::getInstance()->center(); + } +} diff --git a/linden/indra/newview/llfirstuse.h b/linden/indra/newview/llfirstuse.h index 6467734..bd44ece 100644 --- a/linden/indra/newview/llfirstuse.h +++ b/linden/indra/newview/llfirstuse.h @@ -112,6 +112,7 @@ public: static void useDebugMenus(); static void useSculptedPrim(); static void useMedia(); + static void useLoginScreen(); static void callbackClientTags(const LLSD& notification, const LLSD& response); static void ClientTags(); diff --git a/linden/indra/newview/llpanellogin.cpp b/linden/indra/newview/llpanellogin.cpp index a95272a..460c67f 100644 --- a/linden/indra/newview/llpanellogin.cpp +++ b/linden/indra/newview/llpanellogin.cpp @@ -52,6 +52,7 @@ #include "llcombobox.h" #include "llcurl.h" #include "llviewercontrol.h" +#include "llfirstuse.h" #include "llfloaterabout.h" #include "llfloatertest.h" #include "llfloaterpreference.h" @@ -329,6 +330,7 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, refreshLocation( false ); #endif + LLFirstUse::useLoginScreen(); } void LLPanelLogin::setSiteIsAlive( bool alive ) @@ -801,9 +803,12 @@ void LLPanelLogin::refreshLoginPage() // kick off a request to grab the url manually gResponsePtr = LLIamHereLogin::build(sInstance); std::string login_page = gHippoGridManager->getCurrentGrid()->getLoginPage(); - if (!login_page.empty()) { + if (!login_page.empty()) + { LLHTTPClient::head(login_page, gResponsePtr); - } else { + } + else + { sInstance->setSiteIsAlive(false); } } @@ -815,7 +820,8 @@ void LLPanelLogin::loadLoginPage() std::string login_page = gHippoGridManager->getCurrentGrid()->getLoginPage(); - if (login_page.empty()) { + if (login_page.empty()) + { sInstance->setSiteIsAlive(false); return; } @@ -1092,35 +1098,45 @@ void LLPanelLogin::onSelectServer(LLUICtrl* ctrl, void*) // *NOTE: The paramters for this method are ignored. // LLPanelLogin::onServerComboLostFocus(LLFocusableElement* fe, void*) // calls this method. + updateGridCombo(LLStringUtil::null); +} - // The user twiddled with the grid choice ui. - // apply the selection to the grid setting. - std::string grid_label; - //S32 grid_index; - +// static +void LLPanelLogin::updateGridCombo(std::string grid_nick) +{ LLComboBox* combo = sInstance->getChild("server_combo"); - LLSD combo_val = combo->getValue(); - - std::string mCurGrid = ctrl->getValue().asString(); - //KOW - gHippoGridManager->setCurrentGrid(mCurGrid); - // HippoGridInfo *gridInfo = gHippoGridManager->getGrid(mCurGrid); - // if (gridInfo) { - // //childSetText("gridnick", gridInfo->getGridNick()); - // //platform->setCurrentByIndex(gridInfo->getPlatform()); - // //childSetText("gridname", gridInfo->getGridName()); - // LLPanelLogin::setFields( gridInfo->getFirstName(), gridInfo->getLastName(), gridInfo->getAvatarPassword(), 1 ); - // } - if (mCurGrid == gHippoGridManager->getConnectedGrid()->getGridNick()) - gHippoLimits->setLimits(); + + if (grid_nick.empty()) + { + // The user twiddled with the grid choice ui. + // apply the selection to the grid setting. + //std::string grid_label; + //S32 grid_index; + + grid_nick = combo->getValue().asString(); + + // HippoGridInfo *gridInfo = gHippoGridManager->getGrid(mCurGrid); + // if (gridInfo) { + // //childSetText("gridnick", gridInfo->getGridNick()); + // //platform->setCurrentByIndex(gridInfo->getPlatform()); + // //childSetText("gridname", gridInfo->getGridName()); + // LLPanelLogin::setFields( gridInfo->getFirstName(), gridInfo->getLastName(), gridInfo->getAvatarPassword(), 1 ); + // } + } + else + { + combo->setSimple(grid_nick); + } - llwarns << "current grid = " << mCurGrid << llendl; + gHippoGridManager->setCurrentGrid(grid_nick); + + llinfos << "current grid set to " << grid_nick << llendl; // grid changed so show new splash screen (possibly) loadLoginPage(); // save grid choice to settings - gSavedSettings.setString("LastSelectedGrid", mCurGrid); + gSavedSettings.setString("LastSelectedGrid", grid_nick); } /* void LLPanelLogin::onServerComboLostFocus(LLFocusableElement* fe, void*) diff --git a/linden/indra/newview/llpanellogin.h b/linden/indra/newview/llpanellogin.h index f2c589d..15c2d28 100644 --- a/linden/indra/newview/llpanellogin.h +++ b/linden/indra/newview/llpanellogin.h @@ -65,6 +65,8 @@ public: static void addServer(const std::string& server); static void refreshLocation( bool force_visible ); + // Updates grid combo at login screen with a specific nick. Use an empty string to refresh + static void updateGridCombo(std::string grid_nick); static void getFields(std::string *firstname, std::string *lastname, std::string *password); diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_grid_default_selector.xml b/linden/indra/newview/skins/default/xui/en-us/floater_grid_default_selector.xml new file mode 100644 index 0000000..2cf9cd7 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/en-us/floater_grid_default_selector.xml @@ -0,0 +1,19 @@ + + + + Or use the Grid Manager to add a new one + + + + +