diff options
Diffstat (limited to 'linden/indra/newview/floatergriddefault.cpp')
-rw-r--r-- | linden/indra/newview/floatergriddefault.cpp | 102 |
1 files changed, 102 insertions, 0 deletions
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 @@ | |||
1 | /** | ||
2 | * @file floatergriddefault.cpp | ||
3 | * @brief prompts user to set the default grid on first use | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2009&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2010, McCabe Maxsted | ||
8 | * | ||
9 | * Imprudence Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided to you | ||
11 | * under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in | ||
13 | * this distribution, or online at | ||
14 | * http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
15 | * | ||
16 | * There are special exceptions to the terms and conditions of the GPL as | ||
17 | * it is applied to this Source Code. View the full text of the exception | ||
18 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
19 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
20 | * | ||
21 | * By copying, modifying or distributing this software, you acknowledge | ||
22 | * that you have read and understood your obligations described above, | ||
23 | * and agree to abide by those obligations. | ||
24 | * | ||
25 | * ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO | ||
26 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
27 | * COMPLETENESS OR PERFORMANCE. | ||
28 | * $/LicenseInfo$ | ||
29 | */ | ||
30 | |||
31 | #include "llviewerprecompiledheaders.h" | ||
32 | |||
33 | #include "floatergriddefault.h" | ||
34 | |||
35 | #include "hippoGridManager.h" | ||
36 | #include "llpanellogin.h" | ||
37 | #include "llscrolllistctrl.h" | ||
38 | #include "lluictrlfactory.h" | ||
39 | |||
40 | FloaterGridDefault::FloaterGridDefault(const LLSD& key) | ||
41 | { | ||
42 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_grid_default_selector.xml"); | ||
43 | } | ||
44 | |||
45 | FloaterGridDefault::~FloaterGridDefault() | ||
46 | { | ||
47 | } | ||
48 | |||
49 | BOOL FloaterGridDefault::postBuild() | ||
50 | { | ||
51 | // populate the grid chooser | ||
52 | LLScrollListCtrl* grid_list = getChild<LLScrollListCtrl>("grid_list"); | ||
53 | grid_list->deleteAllItems(); | ||
54 | |||
55 | LLSD element; | ||
56 | |||
57 | for (HippoGridManager::GridIterator it = gHippoGridManager->beginGrid(); it != gHippoGridManager->endGrid(); ++it) | ||
58 | { | ||
59 | std::string grid_nick = it->second->getGridNick(); | ||
60 | // There's no reason why empty grids nicks should be in this list, ugh | ||
61 | if (!grid_nick.empty()) | ||
62 | { | ||
63 | element["id"] = grid_nick; | ||
64 | element["columns"][0]["column"] = "grid"; | ||
65 | element["columns"][0]["type"] = "text"; | ||
66 | element["columns"][0]["value"] = grid_nick; | ||
67 | grid_list->addElement(element, ADD_BOTTOM); | ||
68 | } | ||
69 | } | ||
70 | |||
71 | grid_list->setFocus(TRUE); | ||
72 | |||
73 | childSetAction("btn_ok", onClickOK, this); | ||
74 | childSetAction("btn_cancel", onClickCancel, this); | ||
75 | |||
76 | return TRUE; | ||
77 | } | ||
78 | |||
79 | // static | ||
80 | void FloaterGridDefault::onClickOK(void* userdata) | ||
81 | { | ||
82 | FloaterGridDefault* self = (FloaterGridDefault*)userdata; | ||
83 | |||
84 | LLScrollListCtrl* grid_list = self->getChild<LLScrollListCtrl>("grid_list"); | ||
85 | std::string selected = grid_list->getFirstSelected()->getValue().asString(); | ||
86 | |||
87 | if (!selected.empty() || selected != gHippoGridManager->getCurrentGridNick()) | ||
88 | { | ||
89 | gHippoGridManager->setDefaultGrid(selected); | ||
90 | gHippoGridManager->setCurrentGridAsConnected(); | ||
91 | gHippoGridManager->saveFile(); | ||
92 | LLPanelLogin::updateGridCombo(selected); | ||
93 | } | ||
94 | self->close(); | ||
95 | } | ||
96 | |||
97 | // static | ||
98 | void FloaterGridDefault::onClickCancel(void* userdata) | ||
99 | { | ||
100 | FloaterGridDefault* self = (FloaterGridDefault*)userdata; | ||
101 | self->close(); | ||
102 | } | ||