1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
|
/**
* @file llfloaterworldmap.cpp
* @author James Cook, Tom Yedwab
* @brief LLFloaterWorldMap class implementation
*
* $LicenseInfo:firstyear=2003&license=viewergpl$
*
* Copyright (c) 2003-2009, Linden Research, Inc.
*
* Second Life Viewer Source Code
* The source code in this file ("Source Code") is provided by Linden Lab
* to you under the terms of the GNU General Public License, version 2.0
* ("GPL"), unless you have obtained a separate licensing agreement
* ("Other License"), formally executed by you and Linden Lab. 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 LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
* COMPLETENESS OR PERFORMANCE.
* $/LicenseInfo$
*/
/*
* Map of the entire world, with multiple background images,
* avatar tracking, teleportation by double-click, etc.
*/
#include "llviewerprecompiledheaders.h"
#include "llfloaterworldmap.h"
#include "llagent.h"
#include "llviewerwindow.h"
#include "llbutton.h"
#include "llcallingcard.h"
#include "llcolorscheme.h"
#include "llcombobox.h"
#include "llviewercontrol.h"
#include "lldraghandle.h"
#include "llfirstuse.h"
#include "llfocusmgr.h"
#include "llinventorymodel.h"
#include "lllandmarklist.h"
#include "lllineeditor.h"
#include "llnetmap.h"
#include "llpreviewlandmark.h"
#include "llregionhandle.h"
#include "llscrolllistctrl.h"
#include "lltextbox.h"
#include "lltracker.h"
#include "llurldispatcher.h"
#include "llviewermenu.h"
#include "llviewerregion.h"
#include "llviewerstats.h"
#include "llworldmap.h"
#include "llworldmapview.h"
#include "lluictrlfactory.h"
#include "llappviewer.h"
#include "llmapimagetype.h"
#include "llweb.h"
#include "floaterlogin.h"
#include "llstartup.h"
#include "hippoGridManager.h"
#include "floaterlogin.h"
#include "llpanellogin.h"
#include "llglheaders.h"
//---------------------------------------------------------------------------
// Constants
//---------------------------------------------------------------------------
static const F32 MAP_ZOOM_TIME = 0.2f;
enum EPanDirection
{
PAN_UP,
PAN_DOWN,
PAN_LEFT,
PAN_RIGHT
};
// Values in pixels per region
static const F32 ZOOM_MIN = -8.f; // initial value, updated by adjustZoomSlider
static const F32 ZOOM_MAX = 0.f;
static const F32 ZOOM_INC = 0.2f;
static const F32 SIM_COORD_MIN = 0.f;
static const F32 SIM_COORD_MAX = 255.f;
static const F32 SIM_COORD_DEFAULT = 128.f;
static const F64 MAX_FLY_DISTANCE = 363.f; // Diagonal size of one sim.
static const F64 MAX_FLY_DISTANCE_SQUARED = MAX_FLY_DISTANCE * MAX_FLY_DISTANCE;
//---------------------------------------------------------------------------
// Globals
//---------------------------------------------------------------------------
LLFloaterWorldMap* gFloaterWorldMap = NULL;
class LLMapInventoryObserver : public LLInventoryObserver
{
public:
LLMapInventoryObserver() {}
virtual ~LLMapInventoryObserver() {}
virtual void changed(U32 mask);
};
void LLMapInventoryObserver::changed(U32 mask)
{
// if there's a change we're interested in.
if((mask & (LLInventoryObserver::CALLING_CARD | LLInventoryObserver::ADD |
LLInventoryObserver::REMOVE)) != 0)
{
gFloaterWorldMap->inventoryChanged();
}
}
class LLMapFriendObserver : public LLFriendObserver
{
public:
LLMapFriendObserver() {}
virtual ~LLMapFriendObserver() {}
virtual void changed(U32 mask);
};
void LLMapFriendObserver::changed(U32 mask)
{
// if there's a change we're interested in.
if((mask & (LLFriendObserver::ADD | LLFriendObserver::REMOVE | LLFriendObserver::ONLINE | LLFriendObserver::POWERS)) != 0)
{
gFloaterWorldMap->friendsChanged();
}
}
//---------------------------------------------------------------------------
// Statics
//---------------------------------------------------------------------------
// Used as a pretend asset and inventory id to mean "landmark at my home location."
const LLUUID LLFloaterWorldMap::sHomeID( "10000000-0000-0000-0000-000000000001" );
//---------------------------------------------------------------------------
// Construction and destruction
//---------------------------------------------------------------------------
LLFloaterWorldMap::LLFloaterWorldMap()
: LLFloater(std::string("worldmap")),
mInventory(NULL),
mInventoryObserver(NULL),
mFriendObserver(NULL),
mCompletingRegionName(""),
mWaitingForTracker(FALSE),
mExactMatch(FALSE),
mIsClosing(FALSE),
mSetToUserPosition(TRUE),
mTrackedLocation(0,0,0),
mTrackedStatus(LLTracker::TRACKING_NOTHING)
{
LLCallbackMap::map_t factory_map;
factory_map["objects_mapview"] = LLCallbackMap(createWorldMapView, NULL);
factory_map["terrain_mapview"] = LLCallbackMap(createWorldMapView, NULL);
LLUICtrlFactory::getInstance()->buildFloater(this, "floater_world_map.xml", &factory_map);
}
// static
void* LLFloaterWorldMap::createWorldMapView(void* data)
{
return new LLWorldMapView(std::string("mapview"), LLRect(0,300,400,0));
}
BOOL LLFloaterWorldMap::postBuild()
{
mTabs = getChild<LLTabContainer>("maptab");
if (!mTabs) return FALSE;
LLPanel *panel;
panel = mTabs->getChild<LLPanel>("objects_mapview");
if (panel)
{
mTabs->setTabChangeCallback(panel, onCommitBackground);
mTabs->setTabUserData(panel, this);
}
panel = mTabs->getChild<LLPanel>("terrain_mapview");
if (panel)
{
mTabs->setTabChangeCallback(panel, onCommitBackground);
mTabs->setTabUserData(panel, this);
}
// The following callback syncs the worlmap tabs with the images.
// Commented out since it was crashing when LLWorldMap became a singleton.
// We should be fine without it but override the onOpen method and put it
// there if it turns out to be needed. -MG
//
//onCommitBackground((void*)this, false);
childSetCommitCallback("friend combo", onAvatarComboCommit, this);
LLComboBox *avatar_combo = getChild<LLComboBox>("friend combo");
if (avatar_combo)
{
avatar_combo->selectFirstItem();
avatar_combo->setPrearrangeCallback( onAvatarComboPrearrange );
avatar_combo->setTextEntryCallback( onComboTextEntry );
}
childSetAction("DoSearch", onLocationCommit, this);
childSetFocusChangedCallback("location", onLocationFocusChanged, this);
LLLineEditor *location_editor = getChild<LLLineEditor>("location");
if (location_editor)
{
location_editor->setKeystrokeCallback( onSearchTextEntry );
}
childSetCommitCallback("search_results", onCommitSearchResult, this);
childSetDoubleClickCallback("search_results", onClickTeleportBtn);
childSetCommitCallback("spin x", onCommitLocation, this);
childSetCommitCallback("spin y", onCommitLocation, this);
childSetCommitCallback("spin z", onCommitLocation, this);
childSetCommitCallback("landmark combo", onLandmarkComboCommit, this);
LLComboBox *landmark_combo = getChild<LLComboBox>( "landmark combo");
if (landmark_combo)
{
landmark_combo->selectFirstItem();
landmark_combo->setPrearrangeCallback( onLandmarkComboPrearrange );
landmark_combo->setTextEntryCallback( onComboTextEntry );
}
childSetCommitCallback("grid_combo", onSelectServer, this);
childSetAction("Grid Manager", onGridManager, this);
childSetAction("Go Home", onGoHome, this);
childSetAction("Teleport", onClickTeleportBtn, this);
childSetAction("Show Destination", onShowTargetBtn, this);
childSetAction("Show My Location", onShowAgentBtn, this);
childSetAction("Clear", onClearBtn, this);
childSetAction("copy_slurl", onCopySLURL, this);
mCurZoomVal = log(gMapScale)/log(2.f);
childSetValue("zoom slider", gMapScale);
setDefaultBtn(NULL);
mZoomTimer.stop();
return TRUE;
}
// virtual
LLFloaterWorldMap::~LLFloaterWorldMap()
{
// All cleaned up by LLView destructor
mTabs = NULL;
// Inventory deletes all observers on shutdown
mInventory = NULL;
mInventoryObserver = NULL;
// avatar tracker will delete this for us.
mFriendObserver = NULL;
}
// virtual
void LLFloaterWorldMap::onClose(bool app_quitting)
{
setVisible(FALSE);
}
// static
void LLFloaterWorldMap::show(void*, BOOL center_on_target)
{
// [RLVa:KB] - Checked: 2009-07-05 (RLVa-1.0.0c)
if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWWORLDMAP))
{
return;
}
// [/RLVa:KB]
BOOL was_visible = gFloaterWorldMap->getVisible();
gFloaterWorldMap->mIsClosing = FALSE;
gFloaterWorldMap->open(); /* Flawfinder: ignore */
LLWorldMapView* map_panel;
map_panel = (LLWorldMapView*)gFloaterWorldMap->mTabs->getCurrentPanel();
map_panel->clearLastClick();
if (!was_visible)
{
// reset pan on show, so it centers on you again
if (!center_on_target)
{
LLWorldMapView::setPan(0, 0, TRUE);
}
map_panel->updateVisibleBlocks();
// Reload the agent positions when we show the window
LLWorldMap::getInstance()->eraseItems();
// Reload any maps that may have changed
LLWorldMap::getInstance()->clearSimFlags();
const S32 panel_num = gFloaterWorldMap->mTabs->getCurrentPanelIndex();
const bool request_from_sim = true;
LLWorldMap::getInstance()->setCurrentLayer(panel_num, request_from_sim);
// We may already have a bounding box for the regions of the world,
// so use that to adjust the view.
gFloaterWorldMap->adjustZoomSliderBounds();
// Could be first show
LLFirstUse::useMap();
// Start speculative download of landmarks
LLUUID landmark_folder_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_LANDMARK);
gInventory.startBackgroundFetch(landmark_folder_id);
gFloaterWorldMap->childSetFocus("location", TRUE);
gFocusMgr.triggerFocusFlash();
gFloaterWorldMap->buildAvatarIDList();
gFloaterWorldMap->buildLandmarkIDLists();
// If nothing is being tracked, set flag so the user position will be found
gFloaterWorldMap->mSetToUserPosition = ( LLTracker::getTrackingStatus() == LLTracker::TRACKING_NOTHING );
LLFloaterWorldMap::addServer(gHippoGridManager->getDefaultGridNick());
}
if (center_on_target)
{
gFloaterWorldMap->centerOnTarget(FALSE);
}
}
// static
void LLFloaterWorldMap::reloadIcons(void*)
{
LLWorldMap::getInstance()->eraseItems();
LLWorldMap::getInstance()->sendMapLayerRequest();
}
// static
void LLFloaterWorldMap::toggle(void*)
{
BOOL visible = gFloaterWorldMap->getVisible();
if (!visible)
{
show(NULL, FALSE);
}
else
{
gFloaterWorldMap->mIsClosing = TRUE;
gFloaterWorldMap->close();
}
}
// static
void LLFloaterWorldMap::hide(void*)
{
gFloaterWorldMap->mIsClosing = TRUE;
gFloaterWorldMap->close();
}
// static
void LLFloaterWorldMap::addServer(const std::string& server)
{
const std::string &defaultGrid = gHippoGridManager->getDefaultGridNick();
LLCtrlListInterface *grids = gFloaterWorldMap->childGetListInterface("grid_combo");
if (!grids) return;
// Delete all but the "None" entry
S32 list_size = grids->getItemCount();
while (list_size > 1)
{
grids->selectNthItem(1);
grids->operateOnSelection(LLCtrlListInterface::OP_DELETE);
--list_size;
}
//LLComboBox *grids = gFloaterWorldMap->getChild<LLComboBox>("grid_combo");
S32 selectIndex = -1, i = 0;
//grids->removeall();
if (defaultGrid != "") {
grids->addSimpleElement(defaultGrid);
selectIndex = i++;
}
HippoGridManager::GridIterator it, end = gHippoGridManager->endGrid();
for (it = gHippoGridManager->beginGrid(); it != end; ++it) {
const std::string &grid = it->second->getGridNick();
if (grid != defaultGrid) {
grids->addSimpleElement(grid);
//if (grid == mCurGrid) selectIndex = i;
i++;
}
}
grids->selectFirstItem();
//grids->setCurrentByIndex(0);
//LLComboBox* combo = sInstance->getChild<LLComboBox>("server_combo");
//combo->add(server, LLSD(domain_name) );
//combo->setCurrentByIndex(0);
}
// virtual
void LLFloaterWorldMap::setVisible( BOOL visible )
{
LLFloater::setVisible( visible );
gSavedSettings.setBOOL( "ShowWorldMap", visible );
if( !visible )
{
// While we're not visible, discard the overlay images we're using
LLWorldMap::getInstance()->clearImageRefs();
}
}
// virtual
BOOL LLFloaterWorldMap::handleHover(S32 x, S32 y, MASK mask)
{
BOOL handled;
handled = LLFloater::handleHover(x, y, mask);
return handled;
}
BOOL LLFloaterWorldMap::handleScrollWheel(S32 x, S32 y, S32 clicks)
{
if (!isMinimized() && isFrontmost())
{
LLRect area;
childGetRect("search_results", area);
if(!area.pointInRect(x, y))
{
F32 slider_value = (F32)childGetValue("zoom slider").asReal();
slider_value += ((F32)clicks * -0.3333f);
childSetValue("zoom slider", LLSD(slider_value));
return TRUE;
}
}
return LLFloater::handleScrollWheel(x, y, clicks);
}
// virtual
void LLFloaterWorldMap::reshape( S32 width, S32 height, BOOL called_from_parent )
{
LLFloater::reshape( width, height, called_from_parent );
// Might have changed size of world display area
// JC: Technically, this is correct, but it makes the slider "pop"
// if you resize the window, then draw the slider. Just leaving it
// the way it was when you opened the window seems better.
// adjustZoomSliderBounds();
}
// virtual
void LLFloaterWorldMap::draw()
{
// Hide/Show Mature Events controls
childSetVisible("events_mature_icon", !gAgent.isTeen());
childSetVisible("events_mature_label", !gAgent.isTeen());
childSetVisible("event_mature_chk", !gAgent.isTeen());
// On orientation island, users don't have a home location yet, so don't
// let them teleport "home". It dumps them in an often-crowed welcome
// area (infohub) and they get confused. JC
LLViewerRegion* regionp = gAgent.getRegion();
bool agent_on_prelude = (regionp && regionp->isPrelude());
bool enable_go_home = gAgent.isGodlike() || !agent_on_prelude;
childSetEnabled("Go Home", enable_go_home);
updateLocation();
LLComboBox *grid_combo = getChild<LLComboBox>("grid_combo");
std::string current_grid = gHippoGridManager->getConnectedGrid()->getGridNick();
LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus();
if (LLTracker::TRACKING_AVATAR == tracking_status)
{
childSetColor("avatar_icon", gTrackColor);
}
else
{
childSetColor("avatar_icon", gDisabledTrackColor);
}
if (LLTracker::TRACKING_LANDMARK == tracking_status)
{
childSetColor("landmark_icon", gTrackColor);
}
else
{
childSetColor("landmark_icon", gDisabledTrackColor);
}
if (LLTracker::TRACKING_LOCATION == tracking_status)
{
childSetColor("location_icon", gTrackColor);
}
else
{
if (mCompletingRegionName != "")
{
F64 seconds = LLTimer::getElapsedSeconds();
double value = fmod(seconds, 2);
value = 0.5 + 0.5*cos(value * 3.14159f);
LLColor4 loading_color(0.0, F32(value/2), F32(value), 1.0);
childSetColor("location_icon", loading_color);
}
else
{
childSetColor("location_icon", gDisabledTrackColor);
}
}
// check for completion of tracking data
if (mWaitingForTracker)
{
centerOnTarget(TRUE);
}
//GRID MANAGER
if (grid_combo->getSelectedValue().asString() != "None")
{
childSetEnabled("Teleport", TRUE);
childSetColor("grid_icon", gTrackColor);
}
else
{
childSetEnabled("Teleport", (BOOL)tracking_status);
childSetColor("grid_icon", gDisabledTrackColor);
}
//END GRID MANAGER
// childSetEnabled("Clear", (BOOL)tracking_status);
childSetEnabled("Show Destination", (BOOL)tracking_status || LLWorldMap::getInstance()->mIsTrackingUnknownLocation);
childSetEnabled("copy_slurl", (mSLURL.size() > 0) );
setMouseOpaque(TRUE);
getDragHandle()->setMouseOpaque(TRUE);
//RN: snaps to zoom value because interpolation caused jitter in the text rendering
if (!mZoomTimer.getStarted() && mCurZoomVal != (F32)childGetValue("zoom slider").asReal())
{
mZoomTimer.start();
}
F32 interp = mZoomTimer.getElapsedTimeF32() / MAP_ZOOM_TIME;
if (interp > 1.f)
{
interp = 1.f;
mZoomTimer.stop();
}
mCurZoomVal = lerp(mCurZoomVal, (F32)childGetValue("zoom slider").asReal(), interp);
F32 map_scale = 256.f*pow(2.f, mCurZoomVal);
LLWorldMapView::setScale( map_scale );
LLFloater::draw();
}
//-------------------------------------------------------------------------
// Internal utility functions
//-------------------------------------------------------------------------
void LLFloaterWorldMap::trackAvatar( const LLUUID& avatar_id, const std::string& name )
{
LLCtrlSelectionInterface *iface = childGetSelectionInterface("friend combo");
if (!iface) return;
buildAvatarIDList();
if(iface->setCurrentByID(avatar_id) || gAgent.isGodlike())
{
// *HACK: Adjust Z values automatically for liaisons & gods so
// they swoop down when they click on the map. Requested
// convenience.
if(gAgent.isGodlike())
{
childSetValue("spin z", LLSD(200.f));
}
// Don't re-request info if we already have it or we won't have it in time to teleport
if (mTrackedStatus != LLTracker::TRACKING_AVATAR || name != mTrackedAvatarName)
{
mTrackedStatus = LLTracker::TRACKING_AVATAR;
mTrackedAvatarName = name;
LLTracker::trackAvatar(avatar_id, name);
}
}
else
{
LLTracker::stopTracking(NULL);
}
setDefaultBtn("Teleport");
}
void LLFloaterWorldMap::trackLandmark( const LLUUID& landmark_item_id )
{
LLCtrlSelectionInterface *iface = childGetSelectionInterface("landmark combo");
if (!iface) return;
buildLandmarkIDLists();
BOOL found = FALSE;
S32 idx;
for (idx = 0; idx < mLandmarkItemIDList.count(); idx++)
{
if ( mLandmarkItemIDList.get(idx) == landmark_item_id)
{
found = TRUE;
break;
}
}
if (found && iface->setCurrentByID( landmark_item_id ) )
{
LLUUID asset_id = mLandmarkAssetIDList.get( idx );
std::string name;
LLComboBox* combo = getChild<LLComboBox>( "landmark combo");
if (combo) name = combo->getSimple();
mTrackedStatus = LLTracker::TRACKING_LANDMARK;
LLTracker::trackLandmark(mLandmarkAssetIDList.get( idx ), // assetID
mLandmarkItemIDList.get( idx ), // itemID
name); // name
if( asset_id != sHomeID )
{
// start the download process
gLandmarkList.getAsset( asset_id);
}
// We have to download both region info and landmark data, so set busy. JC
// getWindow()->incBusyCount();
}
else
{
LLTracker::stopTracking(NULL);
}
setDefaultBtn("Teleport");
}
void LLFloaterWorldMap::trackEvent(const LLItemInfo &event_info)
{
mTrackedStatus = LLTracker::TRACKING_LOCATION;
LLTracker::trackLocation(event_info.mPosGlobal, event_info.mName, event_info.mToolTip, LLTracker::LOCATION_EVENT);
setDefaultBtn("Teleport");
}
void LLFloaterWorldMap::trackGenericItem(const LLItemInfo &item)
{
mTrackedStatus = LLTracker::TRACKING_LOCATION;
LLTracker::trackLocation(item.mPosGlobal, item.mName, item.mToolTip, LLTracker::LOCATION_ITEM);
setDefaultBtn("Teleport");
}
void LLFloaterWorldMap::trackLocation(const LLVector3d& pos_global)
{
LLSimInfo* sim_info = LLWorldMap::getInstance()->simInfoFromPosGlobal(pos_global);
if (!sim_info)
{
LLWorldMap::getInstance()->mIsTrackingUnknownLocation = TRUE;
LLWorldMap::getInstance()->mInvalidLocation = FALSE;
LLWorldMap::getInstance()->mUnknownLocation = pos_global;
LLTracker::stopTracking(NULL);
S32 world_x = S32(pos_global.mdV[0] / 256);
S32 world_y = S32(pos_global.mdV[1] / 256);
LLWorldMap::getInstance()->sendMapBlockRequest(world_x, world_y, world_x, world_y, true);
setDefaultBtn("");
return;
}
if (sim_info->mAccess == SIM_ACCESS_DOWN)
{
// Down sim. Show the blue circle of death!
LLWorldMap::getInstance()->mIsTrackingUnknownLocation = TRUE;
LLWorldMap::getInstance()->mUnknownLocation = pos_global;
LLWorldMap::getInstance()->mInvalidLocation = TRUE;
LLTracker::stopTracking(NULL);
setDefaultBtn("");
return;
}
std::string sim_name;
LLWorldMap::getInstance()->simNameFromPosGlobal( pos_global, sim_name );
F32 region_x = (F32)fmod( pos_global.mdV[VX], (F64)REGION_WIDTH_METERS );
F32 region_y = (F32)fmod( pos_global.mdV[VY], (F64)REGION_WIDTH_METERS );
std::string full_name = llformat("%s (%d, %d, %d)",
// sim_name.c_str(),
// [RLVa:KB] - Alternate: Snowglobe-1.0 | Checked: 2009-07-04 (RLVa-1.0.0a)
(!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC)) ? sim_name.c_str() : rlv_handler_t::cstrHiddenRegion.c_str(),
// [/RLVa:KB]
llround(region_x),
llround(region_y),
llround((F32)pos_global.mdV[VZ]));
std::string tooltip("");
mTrackedStatus = LLTracker::TRACKING_LOCATION;
LLTracker::trackLocation(pos_global, full_name, tooltip);
LLWorldMap::getInstance()->mIsTrackingUnknownLocation = FALSE;
LLWorldMap::getInstance()->mIsTrackingDoubleClick = FALSE;
LLWorldMap::getInstance()->mIsTrackingCommit = FALSE;
setDefaultBtn("Teleport");
}
void LLFloaterWorldMap::updateLocation()
{
bool gotSimName;
LLTracker::ETrackingStatus status = LLTracker::getTrackingStatus();
// These values may get updated by a message, so need to check them every frame
// The fields may be changed by the user, so only update them if the data changes
LLVector3d pos_global = LLTracker::getTrackedPositionGlobal();
if (pos_global.isExactlyZero())
{
LLVector3d agentPos = gAgent.getPositionGlobal();
// Set to avatar's current postion if nothing is selected
if ( status == LLTracker::TRACKING_NOTHING && mSetToUserPosition )
{
// Make sure we know where we are before setting the current user position
std::string agent_sim_name;
gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal( agentPos, agent_sim_name );
if ( gotSimName )
{
mSetToUserPosition = FALSE;
// Fill out the location field
childSetValue("location", agent_sim_name);
// Figure out where user is
LLVector3d agentPos = gAgent.getPositionGlobal();
S32 agent_x = llround( (F32)fmod( agentPos.mdV[VX], (F64)REGION_WIDTH_METERS ) );
S32 agent_y = llround( (F32)fmod( agentPos.mdV[VY], (F64)REGION_WIDTH_METERS ) );
S32 agent_z = llround( (F32)agentPos.mdV[VZ] );
childSetValue("spin x", LLSD(agent_x) );
childSetValue("spin y", LLSD(agent_y) );
childSetValue("spin z", LLSD(agent_z) );
// Set the current SLURL
mSLURL = LLURLDispatcher::buildSLURL(agent_sim_name, agent_x, agent_y, agent_z);
// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a)
if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC))
{
childSetValue("location", rlv_handler_t::cstrHiddenRegion);
mSLURL.clear();
}
// [/RLVa:KB]
}
}
return; // invalid location
}
std::string sim_name;
gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal( pos_global, sim_name );
if ((status != LLTracker::TRACKING_NOTHING) &&
(status != mTrackedStatus || pos_global != mTrackedLocation || sim_name != mTrackedSimName))
{
mTrackedStatus = status;
mTrackedLocation = pos_global;
mTrackedSimName = sim_name;
if (status == LLTracker::TRACKING_AVATAR)
{
// *HACK: Adjust Z values automatically for liaisons &
// gods so they swoop down when they click on the
// map. Requested convenience.
if(gAgent.isGodlike())
{
pos_global[2] = 200;
}
}
childSetValue("location", sim_name);
F32 region_x = (F32)fmod( pos_global.mdV[VX], (F64)REGION_WIDTH_METERS );
F32 region_y = (F32)fmod( pos_global.mdV[VY], (F64)REGION_WIDTH_METERS );
childSetValue("spin x", LLSD(region_x) );
childSetValue("spin y", LLSD(region_y) );
childSetValue("spin z", LLSD((F32)pos_global.mdV[VZ]) );
// simNameFromPosGlobal can fail, so don't give the user an invalid SLURL
if ( gotSimName )
{
mSLURL = LLURLDispatcher::buildSLURL(sim_name, llround(region_x), llround(region_y), llround((F32)pos_global.mdV[VZ]));
}
else
{ // Empty SLURL will disable the "Copy SLURL to clipboard" button
mSLURL = "";
}
// [RLVa:KB] - Checked: 2009-07-04 (RLVa-1.0.0a)
if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC))
{
childSetValue("location", rlv_handler_t::cstrHiddenRegion);
mSLURL.clear();
}
// [/RLVa:KB]
}
}
void LLFloaterWorldMap::trackURL(const std::string& region_name, S32 x_coord, S32 y_coord, S32 z_coord)
{
LLSimInfo* sim_info = LLWorldMap::getInstance()->simInfoFromName(region_name);
z_coord = llclamp(z_coord, 0, 1000);
if (sim_info)
{
LLVector3 local_pos;
local_pos.mV[VX] = (F32)x_coord;
local_pos.mV[VY] = (F32)y_coord;
local_pos.mV[VZ] = (F32)z_coord;
LLVector3d global_pos = sim_info->getGlobalPos(local_pos);
trackLocation(global_pos);
setDefaultBtn("Teleport");
}
else
{
// fill in UI based on URL
gFloaterWorldMap->childSetValue("location", region_name);
childSetValue("spin x", LLSD((F32)x_coord));
childSetValue("spin y", LLSD((F32)y_coord));
childSetValue("spin z", LLSD((F32)z_coord));
// pass sim name to combo box
gFloaterWorldMap->mCompletingRegionName = region_name;
LLWorldMap::getInstance()->sendNamedRegionRequest(region_name);
LLStringUtil::toLower(gFloaterWorldMap->mCompletingRegionName);
LLWorldMap::getInstance()->mIsTrackingCommit = TRUE;
}
}
void LLFloaterWorldMap::observeInventory(LLInventoryModel* model)
{
if(mInventory)
{
mInventory->removeObserver(mInventoryObserver);
delete mInventoryObserver;
mInventory = NULL;
mInventoryObserver = NULL;
}
if(model)
{
mInventory = model;
mInventoryObserver = new LLMapInventoryObserver;
// Inventory deletes all observers on shutdown
mInventory->addObserver(mInventoryObserver);
inventoryChanged();
}
}
void LLFloaterWorldMap::inventoryChanged()
{
if(!LLTracker::getTrackedLandmarkItemID().isNull())
{
LLUUID item_id = LLTracker::getTrackedLandmarkItemID();
buildLandmarkIDLists();
trackLandmark(item_id);
}
}
void LLFloaterWorldMap::observeFriends()
{
if(!mFriendObserver)
{
mFriendObserver = new LLMapFriendObserver;
LLAvatarTracker::instance().addObserver(mFriendObserver);
friendsChanged();
}
}
void LLFloaterWorldMap::friendsChanged()
{
LLAvatarTracker& t = LLAvatarTracker::instance();
const LLUUID& avatar_id = t.getAvatarID();
buildAvatarIDList();
if(avatar_id.notNull())
{
LLCtrlSelectionInterface *iface = childGetSelectionInterface("friend combo");
if(!iface || !iface->setCurrentByID(avatar_id) ||
!t.getBuddyInfo(avatar_id)->isRightGrantedFrom(LLRelationship::GRANT_MAP_LOCATION) || gAgent.isGodlike())
{
LLTracker::stopTracking(NULL);
}
}
}
// No longer really builds a list. Instead, just updates mAvatarCombo.
void LLFloaterWorldMap::buildAvatarIDList()
{
LLCtrlListInterface *list = childGetListInterface("friend combo");
if (!list) return;
// Delete all but the "None" entry
S32 list_size = list->getItemCount();
while (list_size > 1)
{
list->selectNthItem(1);
list->operateOnSelection(LLCtrlListInterface::OP_DELETE);
--list_size;
}
LLSD default_column;
default_column["name"] = "friend name";
default_column["label"] = "Friend Name";
default_column["width"] = 500;
list->addColumn(default_column);
// Get all of the calling cards for avatar that are currently online
LLCollectMappableBuddies collector;
LLAvatarTracker::instance().applyFunctor(collector);
LLCollectMappableBuddies::buddy_map_t::iterator it;
LLCollectMappableBuddies::buddy_map_t::iterator end;
it = collector.mMappable.begin();
end = collector.mMappable.end();
for( ; it != end; ++it)
{
list->addSimpleElement((*it).first, ADD_BOTTOM, (*it).second);
}
list->setCurrentByID( LLAvatarTracker::instance().getAvatarID() );
list->selectFirstItem();
}
void LLFloaterWorldMap::buildLandmarkIDLists()
{
LLCtrlListInterface *list = childGetListInterface("landmark combo");
if (!list)
{
return;
}
// Delete all but the "None" entry
S32 list_size = list->getItemCount();
if (list_size > 1)
{
list->selectItemRange(1, -1);
list->operateOnSelection(LLCtrlListInterface::OP_DELETE);
}
mLandmarkItemIDList.reset();
mLandmarkAssetIDList.reset();
// Get all of the current landmarks
mLandmarkAssetIDList.put( LLUUID::null );
mLandmarkItemIDList.put( LLUUID::null );
mLandmarkAssetIDList.put( sHomeID );
mLandmarkItemIDList.put( sHomeID );
LLInventoryModel::cat_array_t cats;
LLInventoryModel::item_array_t items;
LLIsType is_landmark(LLAssetType::AT_LANDMARK);
gInventory.collectDescendentsIf(gAgent.getInventoryRootID(),
cats,
items,
LLInventoryModel::EXCLUDE_TRASH,
is_landmark);
std::sort(items.begin(), items.end(), LLViewerInventoryItem::comparePointers());
S32 count = items.count();
for(S32 i = 0; i < count; ++i)
{
LLInventoryItem* item = items.get(i);
list->addSimpleElement(item->getName(), ADD_BOTTOM, item->getUUID());
mLandmarkAssetIDList.put( item->getAssetUUID() );
mLandmarkItemIDList.put( item->getUUID() );
}
list->sortByColumn(std::string("landmark name"), TRUE);
list->selectFirstItem();
}
F32 LLFloaterWorldMap::getDistanceToDestination(const LLVector3d &destination,
F32 z_attenuation) const
{
LLVector3d delta = destination - gAgent.getPositionGlobal();
// by attenuating the z-component we effectively
// give more weight to the x-y plane
delta.mdV[VZ] *= z_attenuation;
F32 distance = (F32)delta.magVec();
return distance;
}
void LLFloaterWorldMap::clearLocationSelection(BOOL clear_ui)
{
LLCtrlListInterface *list = childGetListInterface("search_results");
if (list)
{
list->operateOnAll(LLCtrlListInterface::OP_DELETE);
}
if (!childHasKeyboardFocus("spin x"))
{
childSetValue("spin x", SIM_COORD_DEFAULT);
}
if (!childHasKeyboardFocus("spin y"))
{
childSetValue("spin y", SIM_COORD_DEFAULT);
}
if (!childHasKeyboardFocus("spin z"))
{
childSetValue("spin z", 0);
}
LLWorldMap::getInstance()->mIsTrackingCommit = FALSE;
mCompletingRegionName = "";
mExactMatch = FALSE;
}
void LLFloaterWorldMap::clearGridSelection(BOOL clear_ui)
{
if (clear_ui || !childHasKeyboardFocus("grid_combo"))
{
LLCtrlListInterface *list = childGetListInterface("grid_combo");
if (list)
{
list->selectByValue( "None" );
}
}
}
void LLFloaterWorldMap::clearLandmarkSelection(BOOL clear_ui)
{
if (clear_ui || !childHasKeyboardFocus("landmark combo"))
{
LLCtrlListInterface *list = childGetListInterface("landmark combo");
if (list)
{
list->selectByValue( "None" );
}
}
}
void LLFloaterWorldMap::clearAvatarSelection(BOOL clear_ui)
{
if (clear_ui || !childHasKeyboardFocus("friend combo"))
{
mTrackedStatus = LLTracker::TRACKING_NOTHING;
LLCtrlListInterface *list = childGetListInterface("friend combo");
if (list)
{
list->selectByValue( "None" );
}
}
}
// Adjust the maximally zoomed out limit of the zoom slider so you
// can see the whole world, plus a little.
void LLFloaterWorldMap::adjustZoomSliderBounds()
{
// World size in regions
S32 world_width_regions = LLWorldMap::getInstance()->getWorldWidth() / REGION_WIDTH_UNITS;
S32 world_height_regions = LLWorldMap::getInstance()->getWorldHeight() / REGION_WIDTH_UNITS;
// Pad the world size a little bit, so we have a nice border on
// the edge
world_width_regions++;
world_height_regions++;
// Find how much space we have to display the world
LLWorldMapView* map_panel;
map_panel = (LLWorldMapView*)mTabs->getCurrentPanel();
LLRect view_rect = map_panel->getRect();
// View size in pixels
S32 view_width = view_rect.getWidth();
S32 view_height = view_rect.getHeight();
// Pixels per region to display entire width/height
F32 width_pixels_per_region = (F32) view_width / (F32) world_width_regions;
F32 height_pixels_per_region = (F32) view_height / (F32) world_height_regions;
F32 pixels_per_region = llmin(width_pixels_per_region,
height_pixels_per_region);
// Round pixels per region to an even number of slider increments
S32 slider_units = llfloor(pixels_per_region / 0.2f);
pixels_per_region = slider_units * 0.2f;
// Make sure the zoom slider can be moved at least a little bit.
// Likewise, less than the increment pixels per region is just silly.
pixels_per_region = llclamp(pixels_per_region, 1.f, (F32)(pow(2.f, ZOOM_MAX) * 128.f));
F32 min_power = log(pixels_per_region/256.f)/log(2.f);
childSetMinValue("zoom slider", min_power);
}
//-------------------------------------------------------------------------
// User interface widget callbacks
//-------------------------------------------------------------------------
// static
void LLFloaterWorldMap::onPanBtn( void* userdata )
{
if( !gFloaterWorldMap ) return;
EPanDirection direction = (EPanDirection)(intptr_t)userdata;
S32 pan_x = 0;
S32 pan_y = 0;
switch( direction )
{
case PAN_UP: pan_y = -1; break;
case PAN_DOWN: pan_y = 1; break;
case PAN_LEFT: pan_x = 1; break;
case PAN_RIGHT: pan_x = -1; break;
default: llassert(0); return;
}
LLWorldMapView* map_panel;
map_panel = (LLWorldMapView*)gFloaterWorldMap->mTabs->getCurrentPanel();
map_panel->translatePan( pan_x, pan_y );
}
// static
void LLFloaterWorldMap::onGridManager(void*)
{
LoginFloater::newShow(std::string("Test"), false, LoginFloater::testCallback, NULL);
//gAgent.teleportHome();
//gFloaterWorldMap->close();
}
// static
void LLFloaterWorldMap::onGoHome(void*)
{
gAgent.teleportHomeConfirm();
gFloaterWorldMap->close();
}
// static
void LLFloaterWorldMap::onLandmarkComboPrearrange( LLUICtrl* ctrl, void* userdata )
{
LLFloaterWorldMap* self = gFloaterWorldMap;
if( !self || self->mIsClosing )
{
return;
}
LLCtrlListInterface *list = self->childGetListInterface("landmark combo");
if (!list) return;
LLUUID current_choice = list->getCurrentID();
gFloaterWorldMap->buildLandmarkIDLists();
if( current_choice.isNull() || !list->setCurrentByID( current_choice ) )
{
LLTracker::stopTracking(NULL);
}
}
void LLFloaterWorldMap::onComboTextEntry( LLLineEditor* ctrl, void* userdata )
{
// Reset the tracking whenever we start typing into any of the search fields,
// so that hitting <enter> does an auto-complete versus teleporting us to the
// previously selected landmark/friend.
LLTracker::clearFocus();
}
// static
void LLFloaterWorldMap::onSearchTextEntry( LLLineEditor* ctrl, void* userdata )
{
onComboTextEntry(ctrl, userdata);
updateSearchEnabled(ctrl, userdata);
}
// static
void LLFloaterWorldMap::onLandmarkComboCommit( LLUICtrl* ctrl, void* userdata )
{
LLFloaterWorldMap* self = gFloaterWorldMap;
if( !self || self->mIsClosing )
{
return;
}
LLCtrlListInterface *list = gFloaterWorldMap->childGetListInterface("landmark combo");
if (!list) return;
LLUUID asset_id;
LLUUID item_id = list->getCurrentID();
LLTracker::stopTracking(NULL);
//RN: stopTracking() clears current combobox selection, need to reassert it here
list->setCurrentByID(item_id);
if( item_id.isNull() )
{
}
else if( item_id == sHomeID )
{
asset_id = sHomeID;
}
else
{
LLInventoryItem* item = gInventory.getItem( item_id );
if( item )
{
asset_id = item->getAssetUUID();
}
else
{
// Something went wrong, so revert to a safe value.
item_id.setNull();
}
}
//GRID MANAGER HAX
self->clearGridSelection(TRUE);
//END GRID MANAGER HAX
self->trackLandmark( item_id);
onShowTargetBtn(self);
// Reset to user postion if nothing is tracked
self->mSetToUserPosition = ( LLTracker::getTrackingStatus() == LLTracker::TRACKING_NOTHING );
}
// static
void LLFloaterWorldMap::onAvatarComboPrearrange( LLUICtrl* ctrl, void* userdata )
{
LLFloaterWorldMap* self = gFloaterWorldMap;
if( !self || self->mIsClosing )
{
return;
}
LLCtrlListInterface *list = self->childGetListInterface("friend combo");
if (!list) return;
LLUUID current_choice;
if( LLAvatarTracker::instance().haveTrackingInfo() )
{
current_choice = LLAvatarTracker::instance().getAvatarID();
}
self->buildAvatarIDList();
if( !list->setCurrentByID( current_choice ) || current_choice.isNull() )
{
LLTracker::stopTracking(NULL);
}
}
// static
void LLFloaterWorldMap::onAvatarComboCommit( LLUICtrl* ctrl, void* userdata )
{
LLFloaterWorldMap* self = gFloaterWorldMap;
if( !self || self->mIsClosing )
{
return;
}
LLCtrlListInterface *list = gFloaterWorldMap->childGetListInterface("friend combo");
if (!list) return;
const LLUUID& new_avatar_id = list->getCurrentID();
if (new_avatar_id.notNull())
{
//GRID MANAGER HAX
self->clearGridSelection(TRUE);
//END GRID MANAGER HAX
std::string name;
LLComboBox* combo = gFloaterWorldMap->getChild<LLComboBox>("friend combo");
if (combo) name = combo->getSimple();
self->trackAvatar(new_avatar_id, name);
onShowTargetBtn(self);
}
else
{ // Reset to user postion if nothing is tracked
self->mSetToUserPosition = ( LLTracker::getTrackingStatus() == LLTracker::TRACKING_NOTHING );
}
}
//static
void LLFloaterWorldMap::onLocationFocusChanged( LLFocusableElement* focus, void* userdata )
{
updateSearchEnabled((LLUICtrl*)focus, userdata);
}
// static
void LLFloaterWorldMap::updateSearchEnabled( LLUICtrl* ctrl, void* userdata )
{
LLFloaterWorldMap *self = gFloaterWorldMap;
if (self->childHasKeyboardFocus("location") &&
self->childGetValue("location").asString().length() > 0)
{
self->setDefaultBtn("DoSearch");
}
else
{
self->setDefaultBtn(NULL);
}
}
// static
void LLFloaterWorldMap::onLocationCommit( void* userdata )
{
LLFloaterWorldMap *self = gFloaterWorldMap;
if( !self || self->mIsClosing )
{
return;
}
self->clearLocationSelection(FALSE);
self->mCompletingRegionName = "";
self->mLastRegionName = "";
std::string str = self->childGetValue("location").asString();
// Trim any leading and trailing spaces in the search target
std::string saved_str = str;
LLStringUtil::trim( str );
if ( str != saved_str )
{ // Set the value in the UI if any spaces were removed
self->childSetValue("location", str);
}
LLStringUtil::toLower(str);
gFloaterWorldMap->mCompletingRegionName = str;
LLWorldMap::getInstance()->mIsTrackingCommit = TRUE;
self->mExactMatch = FALSE;
if (str.length() >= 3)
{
LLWorldMap::getInstance()->sendNamedRegionRequest(str);
}
else
{
str += "#";
LLWorldMap::getInstance()->sendNamedRegionRequest(str);
}
}
// static
void LLFloaterWorldMap::onClearBtn(void* data)
{
LLFloaterWorldMap* self = (LLFloaterWorldMap*)data;
self->mTrackedStatus = LLTracker::TRACKING_NOTHING;
LLTracker::stopTracking((void *)(intptr_t)TRUE);
LLWorldMap::getInstance()->mIsTrackingUnknownLocation = FALSE;
self->mSLURL = ""; // Clear the SLURL since it's invalid
self->mSetToUserPosition = TRUE; // Revert back to the current user position
//KOW TODO clear grid combo red ring, clear grid combo.
//GRID MANAGER HAX
self->clearGridSelection(TRUE);
//END GRID MANAGER HAX
}
// static
void LLFloaterWorldMap::onFlyBtn(void* data)
{
LLFloaterWorldMap* self = (LLFloaterWorldMap*)data;
self->fly();
}
void LLFloaterWorldMap::onShowTargetBtn(void* data)
{
LLFloaterWorldMap* self = (LLFloaterWorldMap*)data;
self->centerOnTarget(TRUE);
}
void LLFloaterWorldMap::onShowAgentBtn(void* data)
{
LLWorldMapView::setPan( 0, 0, FALSE); // FALSE == animate
// Set flag so user's location will be displayed if not tracking anything else
LLFloaterWorldMap* self = (LLFloaterWorldMap*)data;
self->mSetToUserPosition = TRUE;
}
// static
void LLFloaterWorldMap::onClickTeleportBtn(void* data)
{
LLFloaterWorldMap* self = (LLFloaterWorldMap*)data;
self->teleport();
}
// static
void LLFloaterWorldMap::onCopySLURL(void* data)
{
LLFloaterWorldMap* self = (LLFloaterWorldMap*)data;
gViewerWindow->mWindow->copyTextToClipboard(utf8str_to_wstring(self->mSLURL));
LLStringUtil::format_map_t args;
args["[SLURL]"] = self->mSLURL;
LLAlertDialog::showXml("CopySLURL", args);
}
void LLFloaterWorldMap::onCheckEvents(LLUICtrl*, void* data)
{
LLFloaterWorldMap* self = (LLFloaterWorldMap*)data;
if(!self) return;
self->childSetEnabled("event_mature_chk", self->childGetValue("event_chk"));
}
// protected
void LLFloaterWorldMap::centerOnTarget(BOOL animate)
{
LLVector3d pos_global;
if(LLTracker::getTrackingStatus() != LLTracker::TRACKING_NOTHING)
{
LLVector3d tracked_position = LLTracker::getTrackedPositionGlobal();
//RN: tracker doesn't allow us to query completion, so we check for a tracking position of
// absolute zero, and keep trying in the draw loop
if (tracked_position.isExactlyZero())
{
mWaitingForTracker = TRUE;
return;
}
else
{
// We've got the position finally, so we're no longer busy. JC
// getWindow()->decBusyCount();
pos_global = LLTracker::getTrackedPositionGlobal() - gAgent.getCameraPositionGlobal();
}
}
else if(LLWorldMap::getInstance()->mIsTrackingUnknownLocation)
{
pos_global = LLWorldMap::getInstance()->mUnknownLocation - gAgent.getCameraPositionGlobal();;
}
else
{
// default behavior = center on agent
pos_global.clearVec();
}
LLWorldMapView::setPan( -llfloor((F32)(pos_global.mdV[VX] * (F64)LLWorldMapView::sPixelsPerMeter)),
-llfloor((F32)(pos_global.mdV[VY] * (F64)LLWorldMapView::sPixelsPerMeter)),
!animate);
mWaitingForTracker = FALSE;
}
// protected
void LLFloaterWorldMap::fly()
{
LLVector3d pos_global = LLTracker::getTrackedPositionGlobal();
// Start the autopilot and close the floater,
// so we can see where we're flying
if (!pos_global.isExactlyZero())
{
gAgent.startAutoPilotGlobal( pos_global );
close();
}
else
{
make_ui_sound("UISndInvalidOp");
}
}
// protected
void LLFloaterWorldMap::teleport()
{
//BEGIN CROSS GRIP TP//
LLComboBox *grid_combo = getChild<LLComboBox>("grid_combo");
std::string current_grid = gHippoGridManager->getConnectedGrid()->getGridNick();
// BUG: the client crashes if fed an invalid grid through this interface, which shouldn't happen
if(//grid_combo && grid_combo->getSelectedValue().asString() != current_grid || gSavedSettings.getBOOL("CmdLineLoginURI") &&
grid_combo->getSelectedValue().asString() != "None" &&
!grid_combo->getSelectedValue().asString().empty())
{
HippoGridInfo *gridInfo = gHippoGridManager->getGrid(grid_combo->getSelectedValue().asString());
//DEBUG
llwarns << "tp button current grid = " << grid_combo->getSelectedValue().asString() << llendl;
std::string firstName = gridInfo->getFirstName();
std::string lastName = gridInfo->getLastName();
std::string loginPassword = gridInfo->getAvatarPassword();
if(!firstName.empty() && !lastName.empty())
{
gLoginHandler.mFirstName = firstName;
gLoginHandler.mLastName = lastName;
gLoginHandler.mPassword = loginPassword;
}
gHippoGridManager->setCurrentGrid(gridInfo->getGridNick());
gHippoGridManager->setDefaultGrid(gridInfo->getGridNick());
//this doesn't work :( gSavedSettings.setBOOL("CmdLineLoginURI", FALSE);
LLStartUp::setShouldAutoLogin(true);
LLAppViewer::instance()->requestLogout(false);
return;
}
//END CROSS GRID TP//
BOOL teleport_home = FALSE;
LLVector3d pos_global;
LLAvatarTracker& av_tracker = LLAvatarTracker::instance();
LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus();
if (LLTracker::TRACKING_AVATAR == tracking_status
&& av_tracker.haveTrackingInfo() )
{
pos_global = av_tracker.getGlobalPos();
pos_global.mdV[VZ] = childGetValue("spin z");
}
else if ( LLTracker::TRACKING_LANDMARK == tracking_status)
{
if( LLTracker::getTrackedLandmarkAssetID() == sHomeID )
{
teleport_home = TRUE;
}
else
{
LLLandmark* landmark = gLandmarkList.getAsset( LLTracker::getTrackedLandmarkAssetID() );
LLUUID region_id;
if(landmark
&& !landmark->getGlobalPos(pos_global)
&& landmark->getRegionID(region_id))
{
LLLandmark::requestRegionHandle(
gMessageSystem,
gAgent.getRegionHost(),
region_id,
NULL);
}
}
}
else if ( LLTracker::TRACKING_LOCATION == tracking_status)
{
pos_global = LLTracker::getTrackedPositionGlobal();
}
else
{
make_ui_sound("UISndInvalidOp");
}
// Do the teleport, which will also close the floater
if (teleport_home)
{
gAgent.teleportHome();
}
else if (!pos_global.isExactlyZero())
{
if(LLTracker::TRACKING_LANDMARK == tracking_status)
{
gAgent.teleportViaLandmark(LLTracker::getTrackedLandmarkAssetID());
}
else
{
gAgent.teleportViaLocation( pos_global );
}
}
}
// static
void LLFloaterWorldMap::onGoToLandmarkDialog( S32 option, void* userdata )
{
LLFloaterWorldMap* self = (LLFloaterWorldMap*) userdata;
switch( option )
{
case 0:
self->teleportToLandmark();
break;
case 1:
self->flyToLandmark();
break;
default:
// nothing
break;
}
}
void LLFloaterWorldMap::flyToLandmark()
{
LLVector3d destination_pos_global;
if( !LLTracker::getTrackedLandmarkAssetID().isNull() )
{
if (LLTracker::hasLandmarkPosition())
{
gAgent.startAutoPilotGlobal( LLTracker::getTrackedPositionGlobal() );
}
}
}
void LLFloaterWorldMap::teleportToLandmark()
{
BOOL has_destination = FALSE;
LLUUID destination_id; // Null means "home"
if( LLTracker::getTrackedLandmarkAssetID() == sHomeID )
{
has_destination = TRUE;
}
else
{
LLLandmark* landmark = gLandmarkList.getAsset( LLTracker::getTrackedLandmarkAssetID() );
LLVector3d global_pos;
if(landmark && landmark->getGlobalPos(global_pos))
{
destination_id = LLTracker::getTrackedLandmarkAssetID();
has_destination = TRUE;
}
else if(landmark)
{
// pop up an anonymous request request.
LLUUID region_id;
if(landmark->getRegionID(region_id))
{
LLLandmark::requestRegionHandle(
gMessageSystem,
gAgent.getRegionHost(),
region_id,
NULL);
}
}
}
if( has_destination )
{
gAgent.teleportViaLandmark( destination_id );
}
}
void LLFloaterWorldMap::teleportToAvatar()
{
LLAvatarTracker& av_tracker = LLAvatarTracker::instance();
if(av_tracker.haveTrackingInfo())
{
LLVector3d pos_global = av_tracker.getGlobalPos();
gAgent.teleportViaLocation( pos_global );
}
}
void LLFloaterWorldMap::flyToAvatar()
{
if( LLAvatarTracker::instance().haveTrackingInfo() )
{
gAgent.startAutoPilotGlobal( LLAvatarTracker::instance().getGlobalPos() );
}
}
// static
void LLFloaterWorldMap::onCommitBackground(void* userdata, bool from_click)
{
LLFloaterWorldMap* self = (LLFloaterWorldMap*) userdata;
// Find my index
S32 index = self->mTabs->getCurrentPanelIndex();
LLWorldMap::getInstance()->setCurrentLayer(index);
}
void LLFloaterWorldMap::updateSims(bool found_null_sim)
{
if (mCompletingRegionName == "")
{
return;
}
LLScrollListCtrl *list = getChild<LLScrollListCtrl>("search_results");
list->operateOnAll(LLCtrlListInterface::OP_DELETE);
LLSD selected_value = list->getSelectedValue();
S32 name_length = mCompletingRegionName.length();
BOOL match_found = FALSE;
S32 num_results = 0;
std::map<U64, LLSimInfo*>::const_iterator it;
for (it = LLWorldMap::getInstance()->mSimInfoMap.begin(); it != LLWorldMap::getInstance()->mSimInfoMap.end(); ++it)
{
LLSimInfo* info = (*it).second;
std::string sim_name = info->mName;
std::string sim_name_lower = sim_name;
LLStringUtil::toLower(sim_name_lower);
if (sim_name_lower.substr(0, name_length) == mCompletingRegionName)
{
if (LLWorldMap::getInstance()->mIsTrackingCommit)
{
if (sim_name_lower == mCompletingRegionName)
{
selected_value = sim_name;
match_found = TRUE;
}
}
LLSD value;
value["id"] = sim_name;
value["columns"][0]["column"] = "sim_name";
value["columns"][0]["value"] = sim_name;
list->addElement(value);
num_results++;
}
}
list->selectByValue(selected_value);
if (found_null_sim)
{
mCompletingRegionName = "";
}
if (match_found)
{
mExactMatch = TRUE;
childSetFocus("search_results");
onCommitSearchResult(NULL, this);
}
else if (!mExactMatch && num_results > 0)
{
list->selectFirstItem(); // select first item by default
childSetFocus("search_results");
onCommitSearchResult(NULL, this);
}
else
{
list->addCommentText(std::string("None found."));
list->operateOnAll(LLCtrlListInterface::OP_DESELECT);
}
}
// static
void LLFloaterWorldMap::onCommitLocation(LLUICtrl* ctrl, void* userdata)
{
LLFloaterWorldMap* self = (LLFloaterWorldMap*) userdata;
LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus();
if ( LLTracker::TRACKING_LOCATION == tracking_status)
{
LLVector3d pos_global = LLTracker::getTrackedPositionGlobal();
F64 local_x = self->childGetValue("spin x");
F64 local_y = self->childGetValue("spin y");
F64 local_z = self->childGetValue("spin z");
pos_global.mdV[VX] += -fmod(pos_global.mdV[VX], 256.0) + local_x;
pos_global.mdV[VY] += -fmod(pos_global.mdV[VY], 256.0) + local_y;
pos_global.mdV[VZ] = local_z;
self->trackLocation(pos_global);
}
}
// static
void LLFloaterWorldMap::onCommitSearchResult(LLUICtrl*, void* userdata)
{
LLFloaterWorldMap* self = (LLFloaterWorldMap*) userdata;
LLCtrlListInterface *list = self->childGetListInterface("search_results");
if (!list) return;
LLSD selected_value = list->getSelectedValue();
std::string sim_name = selected_value.asString();
if (sim_name.empty())
{
return;
}
LLStringUtil::toLower(sim_name);
std::map<U64, LLSimInfo*>::const_iterator it;
for (it = LLWorldMap::getInstance()->mSimInfoMap.begin(); it != LLWorldMap::getInstance()->mSimInfoMap.end(); ++it)
{
LLSimInfo* info = (*it).second;
std::string info_sim_name = info->mName;
LLStringUtil::toLower(info_sim_name);
if (sim_name == info_sim_name)
{
LLVector3d pos_global = from_region_handle( info->mHandle );
F64 local_x = self->childGetValue("spin x");
F64 local_y = self->childGetValue("spin y");
F64 local_z = self->childGetValue("spin z");
pos_global.mdV[VX] += local_x;
pos_global.mdV[VY] += local_y;
pos_global.mdV[VZ] = local_z;
self->childSetValue("location", sim_name);
self->trackLocation(pos_global);
self->setDefaultBtn("Teleport");
break;
}
}
onShowTargetBtn(self);
}
// static
void LLFloaterWorldMap::onSelectServer(LLUICtrl* ctrl, void* userdata)
{
//GRID MANAGER COMBO BOX CLICKED//
llwarns << "onSelectServer called" << llendl;
//snip from onClearBtn (bless this mess)
LLFloaterWorldMap* self = (LLFloaterWorldMap*) userdata;
self->mTrackedStatus = LLTracker::TRACKING_NOTHING;
LLTracker::stopTracking((void *)(intptr_t)TRUE);
//LLTracker::stopTracking(NULL);
LLWorldMap::getInstance()->mIsTrackingUnknownLocation = FALSE;
self->mSLURL = ""; // Clear the SLURL since it's invalid
self->mSetToUserPosition = TRUE; // Revert back to the current user position
self->setDefaultBtn("Teleport");
}
|