aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/floatergridmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/floatergridmanager.cpp217
1 files changed, 115 insertions, 102 deletions
diff --git a/linden/indra/newview/floatergridmanager.cpp b/linden/indra/newview/floatergridmanager.cpp
index efd02ca..1ca7ae3 100644
--- a/linden/indra/newview/floatergridmanager.cpp
+++ b/linden/indra/newview/floatergridmanager.cpp
@@ -53,32 +53,6 @@ FloaterGridManager::~FloaterGridManager()
53 53
54BOOL FloaterGridManager::postBuild() 54BOOL FloaterGridManager::postBuild()
55{ 55{
56 /*requires<LLScrollListCtrl>("grid_selector");
57 requires<LLLineEditor>("gridnick");
58 requires<LLLineEditor>("gridname");
59 requires<LLLineEditor>("loginuri");
60 requires<LLLineEditor>("loginpage");
61 requires<LLLineEditor>("helperuri");
62 requires<LLLineEditor>("website");
63 requires<LLLineEditor>("support");
64 requires<LLLineEditor>("register");
65 requires<LLLineEditor>("password");
66 requires<LLLineEditor>("first_name");
67 requires<LLLineEditor>("last_name");
68 requires<LLLineEditor>("avatar_password");
69 //requires<LLLineEditor>("search");
70 requires<LLButton>("btn_delete");
71 requires<LLButton>("btn_add");
72 requires<LLButton>("btn_copy");
73 requires<LLButton>("set_default");
74 requires<LLButton>("btn_gridinfo");*/
75 //requires<LLButton>("btn_help_render_compat");
76
77 /*if (!checkRequirements())
78 {
79 return false;
80 }*/
81
82 LLLineEditor* password_edit = getChild<LLLineEditor>("avatar_password"); 56 LLLineEditor* password_edit = getChild<LLLineEditor>("avatar_password");
83 if (password_edit) 57 if (password_edit)
84 { 58 {
@@ -105,49 +79,120 @@ BOOL FloaterGridManager::postBuild()
105 return TRUE; 79 return TRUE;
106} 80}
107 81
82void FloaterGridManager::clearInfo()
83{
84 //getChild<LLScrollListCtrl>("grid_selector")->clear();
85 //getChild<LLLineEditor>("gridnick")->clear();
86 //getChild<LLLineEditor>("gridname")->clear();
87 //getChild<LLLineEditor>("loginuri")->clear();
88 getChild<LLLineEditor>("loginpage")->clear();
89 getChild<LLLineEditor>("helperuri")->clear();
90 getChild<LLLineEditor>("website")->clear();
91 getChild<LLLineEditor>("support")->clear();
92 getChild<LLLineEditor>("register")->clear();
93 getChild<LLLineEditor>("password")->clear();
94 //getChild<LLLineEditor>("first_name")->clear();
95 //getChild<LLLineEditor>("last_name")->clear();
96 //getChild<LLLineEditor>("avatar_password")->clear();
97 //getChild<LLLineEditor>("search")->clear();
98 //getChild<LLButton>("btn_delete");
99 //getChild<LLButton>("btn_add")
100 //getChild<LLButton>("btn_copy");
101 //getChild<LLButton>("set_default")->setEnabled(FALSE);
102 getChild<LLButton>("btn_gridinfo")->setEnabled(TRUE);
103 //getChild<LLButton>("btn_clear");
104 //getChild<LLButton>("btn_help_render_compat")->setEnabled(FALSE);
105}
106
107void FloaterGridManager::draw()
108{
109 refresh();
110
111 LLFloater::draw();
112}
113
114void FloaterGridManager::refresh()
115{
116 //TODO: these should just be set in a prompt
117 bool can_edit = (!getChild<LLLineEditor>("gridnick")->getText().empty() &&
118 !getChild<LLLineEditor>("loginuri")->getText().empty() &&
119 getChild<LLLineEditor>("gridnick")->getText() != "<required>" &&
120 getChild<LLLineEditor>("loginuri")->getText() != "<required>");
121
122 //getChild<LLLineEditor>("gridname");
123 getChild<LLLineEditor>("loginpage")->setEnabled(can_edit);
124 getChild<LLLineEditor>("helperuri")->setEnabled(can_edit);
125 getChild<LLLineEditor>("website")->setEnabled(can_edit);
126 getChild<LLLineEditor>("support")->setEnabled(can_edit);
127 getChild<LLLineEditor>("register")->setEnabled(can_edit);
128 getChild<LLLineEditor>("password")->setEnabled(can_edit);
129 //getChild<LLLineEditor>("first_name")->setEnabled(can_edit);
130 //getChild<LLLineEditor>("last_name")->setEnabled(can_edit);
131 //getChild<LLLineEditor>("avatar_password")->setEnabled(can_edit);
132 //getChild<LLLineEditor>("search")->setEnabled(can_edit);
133 getChild<LLButton>("btn_delete")->setEnabled(can_edit);
134 //getChild<LLButton>("btn_add")
135 //getChild<LLButton>("btn_copy")->setEnabled(can_edit);
136 //getChild<LLButton>("set_default")->setEnabled(can_dit);
137 getChild<LLButton>("btn_gridinfo")->setEnabled(can_edit);
138 getChild<LLButton>("btn_clear")->setEnabled(can_edit);
139 //getChild<LLButton>("btn_help_render_compat")->setEnabled(can_edit);
140}
141
108void FloaterGridManager::refreshGrids() 142void FloaterGridManager::refreshGrids()
109{ 143{
110 const std::string &defaultGrid = gHippoGridManager->getDefaultGridNick();
111 LLScrollListCtrl *grids = FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector"); 144 LLScrollListCtrl *grids = FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector");
112 grids->deleteAllItems(); 145 std::string lastSelectedItem;
146 LLSD element;
113 147
114 S32 selectIndex = -1; 148 if (grids->getFirstSelected())
115 S32 i = 0;
116 if (defaultGrid != "")
117 { 149 {
118 LLSD value; 150 lastSelectedItem = grids->getFirstSelected()->getValue().asString();
119 value["id"] = defaultGrid;
120 value["columns"][0]["column"] = "grid";
121 value["columns"][0]["value"] = defaultGrid;
122 grids->addElement(value);
123 selectIndex = i++;
124 } 151 }
125 152
126 HippoGridManager::GridIterator it = gHippoGridManager->beginGrid(); 153 grids->deleteAllItems();
127 HippoGridManager::GridIterator end = gHippoGridManager->endGrid(); 154
128 for (it; it != end; ++it) 155 for (HippoGridManager::GridIterator it = gHippoGridManager->beginGrid(); it != gHippoGridManager->endGrid(); ++it)
129 { 156 {
130 const std::string &grid = it->second->getGridNick(); 157 std::string grid_nick = it->second->getGridNick();
131 if (grid != defaultGrid) 158 // There's no reason why empty grids nicks should be in this list, ugh
159 if (!grid_nick.empty() && grid_nick != gHippoGridManager->getCurrentGridNick())
132 { 160 {
133 LLSD value; 161 element["id"] = grid_nick;
134 value["id"] = grid; 162 element["columns"][0]["column"] = "grid";
135 value["columns"][0]["column"] = "grid"; 163 element["columns"][0]["type"] = "text";
136 value["columns"][0]["value"] = grid; 164 element["columns"][0]["value"] = grid_nick;
137 grids->addElement(value); 165 grids->addElement(element, ADD_BOTTOM);
138
139 if (grid == FloaterGridManager::getInstance()->getCurGrid())
140 {
141 selectIndex = i;
142 }
143 i++;
144 } 166 }
145 } 167 }
146 168
169 // Setting the default needs to be rethought.
170 // Right now, we just use the last-selected grid,
171 // but leaving this as the current behavior for now
172 if (!gHippoGridManager->getCurrentGridNick().empty())
173 {
174 element["id"] = gHippoGridManager->getCurrentGridNick();
175 element["columns"][0]["column"] = "grid";
176 element["columns"][0]["type"] = "text";
177 element["columns"][0]["font-style"] = "BOLD";
178 element["columns"][0]["value"] = gHippoGridManager->getCurrentGridNick();
179 grids->addElement(element, ADD_TOP);
180 }
181
182 // Reselect the item if we had one selected
183 if (lastSelectedItem.empty())
184 {
185 grids->selectItemByLabel(gHippoGridManager->getCurrentGridNick());
186 }
187 else
188 {
189 grids->selectItemByLabel(lastSelectedItem);
190 }
191
192 // TODO: get rid of all this state junk
147 if ((FloaterGridManager::getInstance()->getState() == ADD_NEW) || (FloaterGridManager::getInstance()->getState() == ADD_COPY)) 193 if ((FloaterGridManager::getInstance()->getState() == ADD_NEW) || (FloaterGridManager::getInstance()->getState() == ADD_COPY))
148 { 194 {
149 grids->addElement("<new>"); 195 grids->addElement("<new>", ADD_BOTTOM);
150 selectIndex = i++;
151 } 196 }
152 197
153 //if (selectIndex >= 0) 198 //if (selectIndex >= 0)
@@ -161,9 +206,10 @@ void FloaterGridManager::refreshGrids()
161 206
162 // FloaterGridManager::getInstance()->childSetTextArg("default_grid", "[DEFAULT]", (defaultGrid != "")? defaultGrid: " "); 207 // FloaterGridManager::getInstance()->childSetTextArg("default_grid", "[DEFAULT]", (defaultGrid != "")? defaultGrid: " ");
163 208
164 FloaterGridManager::getInstance()->childSetEnabled("btn_delete", (selectIndex >= 0)); 209 FloaterGridManager::getInstance()->childSetEnabled("btn_delete", grids->getItemCount() > 0);
165 FloaterGridManager::getInstance()->childSetEnabled("btn_copy", (FloaterGridManager::getInstance()->getState() == NORMAL) && (selectIndex >= 0)); 210
166 // FloaterGridManager::getInstance()->childSetEnabled("set_default", (FloaterGridManager::getInstance()->getState() == NORMAL) && (selectIndex > 0)); 211 FloaterGridManager::getInstance()->childSetEnabled("btn_copy", (FloaterGridManager::getInstance()->getState() == NORMAL) && (grids->getItemCount() > 0));
212 // FloaterGridManager::getInstance()->childSetEnabled("set_default", (FloaterGridManager::getInstance()->getState() == NORMAL) && (grids->getItemCount() > 0));
167 FloaterGridManager::getInstance()->childSetEnabled("gridnick", (FloaterGridManager::getInstance()->getState() == ADD_NEW) || (FloaterGridManager::getInstance()->getState() == ADD_COPY)); 213 FloaterGridManager::getInstance()->childSetEnabled("gridnick", (FloaterGridManager::getInstance()->getState() == ADD_NEW) || (FloaterGridManager::getInstance()->getState() == ADD_COPY));
168 214
169 if (FloaterGridManager::getInstance()->getState() == NORMAL) 215 if (FloaterGridManager::getInstance()->getState() == NORMAL)
@@ -309,15 +355,15 @@ bool FloaterGridManager::createNewGrid()
309 355
310 if (gridnick.empty()) 356 if (gridnick.empty())
311 { 357 {
312 //KOW gViewerWindow->alertXml("GridsNoNick"); 358 LLNotifications::instance().add("GridsNoNick");
313 return false; 359 return false;
314 } 360 }
315 361
316 if (gHippoGridManager->getGrid(gridnick)) 362 if (gHippoGridManager->getGrid(gridnick))
317 { 363 {
318 //LLStringUtil::format_map_t args; 364 LLSD args;
319 //args["[NAME]"] = gridnick; 365 args["[NAME]"] = gridnick;
320 //KOW gViewerWindow->alertXml("GridExists", args); 366 LLNotifications::instance().add("GridExists", args);
321 return false; 367 return false;
322 } 368 }
323 369
@@ -325,9 +371,9 @@ bool FloaterGridManager::createNewGrid()
325 std::string loginuri = childGetValue("loginuri"); 371 std::string loginuri = childGetValue("loginuri");
326 if ((loginuri.empty()) || (loginuri == "<required>")) 372 if ((loginuri.empty()) || (loginuri == "<required>"))
327 { 373 {
328 //LLStringUtil::format_map_t args; 374 LLSD args;
329 //args["[NAME]"] = gridnick; 375 args["[NAME]"] = gridnick;
330 //KOW gViewerWindow->alertXml("GridsNoLoginUri", args); 376 LLNotifications::instance().add("GridsNoLoginUri", args);
331 return false; 377 return false;
332 } 378 }
333 379
@@ -365,7 +411,7 @@ void FloaterGridManager::retrieveGridInfo()
365 std::string loginuri = childGetValue("loginuri"); 411 std::string loginuri = childGetValue("loginuri");
366 if ((loginuri == "") || (loginuri == "<required>")) 412 if ((loginuri == "") || (loginuri == "<required>"))
367 { 413 {
368 //KOW gViewerWindow->alertXml("GridInfoNoLoginUri"); 414 LLNotifications::instance().add("GridInfoNoLoginUri");
369 return; 415 return;
370 } 416 }
371 417
@@ -408,7 +454,7 @@ void FloaterGridManager::retrieveGridInfo()
408 } 454 }
409 else 455 else
410 { 456 {
411 //KOW gViewerWindow->alertXml("GridInfoError"); 457 LLNotifications::instance().add("GridInfoError");
412 } 458 }
413 459
414 if (cleanupGrid) delete grid; 460 if (cleanupGrid) delete grid;
@@ -533,8 +579,7 @@ void FloaterGridManager::onClickApply(void* data)
533// static 579// static
534void FloaterGridManager::onClickClear(void* data) 580void FloaterGridManager::onClickClear(void* data)
535{ 581{
536 gHippoGridManager->discardAndReload(); 582 FloaterGridManager::getInstance()->clearInfo();
537 FloaterGridManager::getInstance()->update();
538} 583}
539 584
540//static 585//static
@@ -595,38 +640,6 @@ void FloaterGridManager::onClickCancel(void* data)
595 //FloaterGridManager::getInstance()->childSetVisible("server_combo", TRUE); 640 //FloaterGridManager::getInstance()->childSetVisible("server_combo", TRUE);
596//} 641//}
597 642
598//void FloaterGridManager::newShow(const std::string &grid, bool initialLogin)
599//{
600// llinfos << "newShow called" << llendl;
601// /*if (!FloaterGridManager::getInstance())
602// {
603// FloaterGridManager::sGrid = grid;
604// FloaterGridManager::sIsInitialLogin = initialLogin;
605// FloaterGridManager::getInstance() = new FloaterGridManager();
606//
607// llinfos << "FloaterGridManager::getInstance() assigned. FloaterGridManager::getInstance()=" << FloaterGridManager::getInstance() << llendl;
608// }*/
609//
610// llinfos << "newshow called" << llendl;
611// FloaterGridManager::getInstance()->setCurGrid(gHippoGridManager->getCurrentGridNick());
612// refreshGrids();
613//
614// FloaterGridManager::getInstance()->open();
615// // we're important
616// //FloaterGridManager::getInstance()->setFrontmost(TRUE);
617// //FloaterGridManager::getInstance()->setFocus(TRUE);
618//
619//}
620
621//void FloaterGridManager::show(const LLRect &rect, BOOL show_server,
622// void (*callback)(S32 option, void* user_data),
623// void* callback_data)
624//{
625// // we don't need a grid passed in because this is old-style login
626// std::string grid = "";
627// newShow(grid, TRUE);
628//}
629
630//void FloaterGridManager::setFocus(BOOL b) 643//void FloaterGridManager::setFocus(BOOL b)
631//{ 644//{
632// if(b != hasFocus()) 645// if(b != hasFocus())