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
|
/**
* @file llpaneleditwearable.cpp
* @brief UI panel for editing of a particular wearable item.
*
* $LicenseInfo:firstyear=2009&license=viewergpl$
*
* Copyright (c) 2009-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$
*/
#include "llviewerprecompiledheaders.h"
#include "llpaneleditwearable.h"
#include "llpanel.h"
#include "llwearable.h"
#include "lluictrl.h"
#include "llscrollingpanellist.h"
#include "llvisualparam.h"
#include "lltoolmorph.h"
#include "llviewerjointmesh.h"
#include "lltrans.h"
#include "llbutton.h"
#include "llsliderctrl.h"
#include "llagent.h"
#include "llvoavatarself.h"
#include "lltexteditor.h"
#include "lltextbox.h"
#include "llaccordionctrltab.h"
#include "llagentwearables.h"
#include "llscrollingpanelparam.h"
#include "llradiogroup.h"
#include "llnotificationsutil.h"
#include "llcolorswatch.h"
#include "lltexturectrl.h"
#include "lltextureentry.h"
#include "llviewercontrol.h" // gSavedSettings
#include "llviewertexturelist.h"
#include "llagentcamera.h"
#include "llmorphview.h"
// register panel with appropriate XML
static LLRegisterPanelClassWrapper<LLPanelEditWearable> t_edit_wearable("panel_edit_wearable");
// subparts of the UI for focus, camera position, etc.
enum ESubpart {
SUBPART_SHAPE_HEAD = 1, // avoid 0
SUBPART_SHAPE_EYES,
SUBPART_SHAPE_EARS,
SUBPART_SHAPE_NOSE,
SUBPART_SHAPE_MOUTH,
SUBPART_SHAPE_CHIN,
SUBPART_SHAPE_TORSO,
SUBPART_SHAPE_LEGS,
SUBPART_SHAPE_WHOLE,
SUBPART_SHAPE_DETAIL,
SUBPART_SKIN_COLOR,
SUBPART_SKIN_FACEDETAIL,
SUBPART_SKIN_MAKEUP,
SUBPART_SKIN_BODYDETAIL,
SUBPART_HAIR_COLOR,
SUBPART_HAIR_STYLE,
SUBPART_HAIR_EYEBROWS,
SUBPART_HAIR_FACIAL,
SUBPART_EYES,
SUBPART_SHIRT,
SUBPART_PANTS,
SUBPART_SHOES,
SUBPART_SOCKS,
SUBPART_JACKET,
SUBPART_GLOVES,
SUBPART_UNDERSHIRT,
SUBPART_UNDERPANTS,
SUBPART_SKIRT,
SUBPART_ALPHA,
SUBPART_TATTOO
};
using namespace LLVOAvatarDefines;
typedef std::vector<ESubpart> subpart_vec_t;
// Locally defined classes
class LLEditWearableDictionary : public LLSingleton<LLEditWearableDictionary>
{
//--------------------------------------------------------------------
// Constructors and Destructors
//--------------------------------------------------------------------
public:
LLEditWearableDictionary();
virtual ~LLEditWearableDictionary();
//--------------------------------------------------------------------
// Wearable Types
//--------------------------------------------------------------------
public:
struct WearableEntry : public LLDictionaryEntry
{
WearableEntry(LLWearableType::EType type,
const std::string &title,
const std::string &desc_title,
U8 num_color_swatches, // number of 'color_swatches'
U8 num_texture_pickers, // number of 'texture_pickers'
U8 num_subparts, ... ); // number of subparts followed by a list of ETextureIndex and ESubparts
const LLWearableType::EType mWearableType;
const std::string mTitle;
const std::string mDescTitle;
subpart_vec_t mSubparts;
texture_vec_t mColorSwatchCtrls;
texture_vec_t mTextureCtrls;
};
struct Wearables : public LLDictionary<LLWearableType::EType, WearableEntry>
{
Wearables();
} mWearables;
const WearableEntry* getWearable(LLWearableType::EType type) const { return mWearables.lookup(type); }
//--------------------------------------------------------------------
// Subparts
//--------------------------------------------------------------------
public:
struct SubpartEntry : public LLDictionaryEntry
{
SubpartEntry(ESubpart part,
const std::string &joint,
const std::string &edit_group,
const std::string ¶m_list,
const std::string &accordion_tab,
const LLVector3d &target_offset,
const LLVector3d &camera_offset,
const ESex &sex);
ESubpart mSubpart;
std::string mTargetJoint;
std::string mEditGroup;
std::string mParamList;
std::string mAccordionTab;
LLVector3d mTargetOffset;
LLVector3d mCameraOffset;
ESex mSex;
};
struct Subparts : public LLDictionary<ESubpart, SubpartEntry>
{
Subparts();
} mSubparts;
const SubpartEntry* getSubpart(ESubpart subpart) const { return mSubparts.lookup(subpart); }
//--------------------------------------------------------------------
// Picker Control Entries
//--------------------------------------------------------------------
public:
struct PickerControlEntry : public LLDictionaryEntry
{
PickerControlEntry(ETextureIndex tex_index,
const std::string name,
const LLUUID default_image_id = LLUUID::null,
const bool allow_no_texture = false);
ETextureIndex mTextureIndex;
const std::string mControlName;
const LLUUID mDefaultImageId;
const bool mAllowNoTexture;
};
struct ColorSwatchCtrls : public LLDictionary<ETextureIndex, PickerControlEntry>
{
ColorSwatchCtrls();
} mColorSwatchCtrls;
struct TextureCtrls : public LLDictionary<ETextureIndex, PickerControlEntry>
{
TextureCtrls();
} mTextureCtrls;
const PickerControlEntry* getTexturePicker(ETextureIndex index) const { return mTextureCtrls.lookup(index); }
const PickerControlEntry* getColorSwatch(ETextureIndex index) const { return mColorSwatchCtrls.lookup(index); }
};
LLEditWearableDictionary::LLEditWearableDictionary()
{
}
//virtual
LLEditWearableDictionary::~LLEditWearableDictionary()
{
}
LLEditWearableDictionary::Wearables::Wearables()
{
// note the subpart that is listed first is treated as "default", regardless of what order is in enum.
// Please match the order presented in XUI. -Nyx
// this will affect what camera angle is shown when first editing a wearable
addEntry(LLWearableType::WT_SHAPE, new WearableEntry(LLWearableType::WT_SHAPE,"edit_shape_title","shape_desc_text",0,0,9, SUBPART_SHAPE_WHOLE, SUBPART_SHAPE_HEAD, SUBPART_SHAPE_EYES, SUBPART_SHAPE_EARS, SUBPART_SHAPE_NOSE, SUBPART_SHAPE_MOUTH, SUBPART_SHAPE_CHIN, SUBPART_SHAPE_TORSO, SUBPART_SHAPE_LEGS ));
addEntry(LLWearableType::WT_SKIN, new WearableEntry(LLWearableType::WT_SKIN,"edit_skin_title","skin_desc_text",0,3,4, TEX_HEAD_BODYPAINT, TEX_UPPER_BODYPAINT, TEX_LOWER_BODYPAINT, SUBPART_SKIN_COLOR, SUBPART_SKIN_FACEDETAIL, SUBPART_SKIN_MAKEUP, SUBPART_SKIN_BODYDETAIL));
addEntry(LLWearableType::WT_HAIR, new WearableEntry(LLWearableType::WT_HAIR,"edit_hair_title","hair_desc_text",0,1,4, TEX_HAIR, SUBPART_HAIR_COLOR, SUBPART_HAIR_STYLE, SUBPART_HAIR_EYEBROWS, SUBPART_HAIR_FACIAL));
addEntry(LLWearableType::WT_EYES, new WearableEntry(LLWearableType::WT_EYES,"edit_eyes_title","eyes_desc_text",0,1,1, TEX_EYES_IRIS, SUBPART_EYES));
addEntry(LLWearableType::WT_SHIRT, new WearableEntry(LLWearableType::WT_SHIRT,"edit_shirt_title","shirt_desc_text",1,1,1, TEX_UPPER_SHIRT, TEX_UPPER_SHIRT, SUBPART_SHIRT));
addEntry(LLWearableType::WT_PANTS, new WearableEntry(LLWearableType::WT_PANTS,"edit_pants_title","pants_desc_text",1,1,1, TEX_LOWER_PANTS, TEX_LOWER_PANTS, SUBPART_PANTS));
addEntry(LLWearableType::WT_SHOES, new WearableEntry(LLWearableType::WT_SHOES,"edit_shoes_title","shoes_desc_text",1,1,1, TEX_LOWER_SHOES, TEX_LOWER_SHOES, SUBPART_SHOES));
addEntry(LLWearableType::WT_SOCKS, new WearableEntry(LLWearableType::WT_SOCKS,"edit_socks_title","socks_desc_text",1,1,1, TEX_LOWER_SOCKS, TEX_LOWER_SOCKS, SUBPART_SOCKS));
addEntry(LLWearableType::WT_JACKET, new WearableEntry(LLWearableType::WT_JACKET,"edit_jacket_title","jacket_desc_text",1,2,1, TEX_UPPER_JACKET, TEX_UPPER_JACKET, TEX_LOWER_JACKET, SUBPART_JACKET));
addEntry(LLWearableType::WT_GLOVES, new WearableEntry(LLWearableType::WT_GLOVES,"edit_gloves_title","gloves_desc_text",1,1,1, TEX_UPPER_GLOVES, TEX_UPPER_GLOVES, SUBPART_GLOVES));
addEntry(LLWearableType::WT_UNDERSHIRT, new WearableEntry(LLWearableType::WT_UNDERSHIRT,"edit_undershirt_title","undershirt_desc_text",1,1,1, TEX_UPPER_UNDERSHIRT, TEX_UPPER_UNDERSHIRT, SUBPART_UNDERSHIRT));
addEntry(LLWearableType::WT_UNDERPANTS, new WearableEntry(LLWearableType::WT_UNDERPANTS,"edit_underpants_title","underpants_desc_text",1,1,1, TEX_LOWER_UNDERPANTS, TEX_LOWER_UNDERPANTS, SUBPART_UNDERPANTS));
addEntry(LLWearableType::WT_SKIRT, new WearableEntry(LLWearableType::WT_SKIRT,"edit_skirt_title","skirt_desc_text",1,1,1, TEX_SKIRT, TEX_SKIRT, SUBPART_SKIRT));
addEntry(LLWearableType::WT_ALPHA, new WearableEntry(LLWearableType::WT_ALPHA,"edit_alpha_title","alpha_desc_text",0,5,1, TEX_LOWER_ALPHA, TEX_UPPER_ALPHA, TEX_HEAD_ALPHA, TEX_EYES_ALPHA, TEX_HAIR_ALPHA, SUBPART_ALPHA));
addEntry(LLWearableType::WT_TATTOO, new WearableEntry(LLWearableType::WT_TATTOO,"edit_tattoo_title","tattoo_desc_text",1,3,1, TEX_HEAD_TATTOO, TEX_LOWER_TATTOO, TEX_UPPER_TATTOO, TEX_HEAD_TATTOO, SUBPART_TATTOO));
}
LLEditWearableDictionary::WearableEntry::WearableEntry(LLWearableType::EType type,
const std::string &title,
const std::string &desc_title,
U8 num_color_swatches,
U8 num_texture_pickers,
U8 num_subparts, ... ) :
LLDictionaryEntry(title),
mWearableType(type),
mTitle(title),
mDescTitle(desc_title)
{
va_list argp;
va_start(argp, num_subparts);
for (U8 i = 0; i < num_color_swatches; ++i)
{
ETextureIndex index = (ETextureIndex)va_arg(argp,int);
mColorSwatchCtrls.push_back(index);
}
for (U8 i = 0; i < num_texture_pickers; ++i)
{
ETextureIndex index = (ETextureIndex)va_arg(argp,int);
mTextureCtrls.push_back(index);
}
for (U8 i = 0; i < num_subparts; ++i)
{
ESubpart part = (ESubpart)va_arg(argp,int);
mSubparts.push_back(part);
}
}
LLEditWearableDictionary::Subparts::Subparts()
{
addEntry(SUBPART_SHAPE_WHOLE, new SubpartEntry(SUBPART_SHAPE_WHOLE, "mPelvis", "shape_body","shape_body_param_list", "shape_body_tab", LLVector3d(0.f, 0.f, 0.1f), LLVector3d(-2.5f, 0.5f, 0.8f),SEX_BOTH));
addEntry(SUBPART_SHAPE_HEAD, new SubpartEntry(SUBPART_SHAPE_HEAD, "mHead", "shape_head", "shape_head_param_list", "shape_head_tab", LLVector3d(0.f, 0.f, 0.05f), LLVector3d(-0.5f, 0.05f, 0.07f),SEX_BOTH));
addEntry(SUBPART_SHAPE_EYES, new SubpartEntry(SUBPART_SHAPE_EYES, "mHead", "shape_eyes", "shape_eyes_param_list", "shape_eyes_tab", LLVector3d(0.f, 0.f, 0.05f), LLVector3d(-0.5f, 0.05f, 0.07f),SEX_BOTH));
addEntry(SUBPART_SHAPE_EARS, new SubpartEntry(SUBPART_SHAPE_EARS, "mHead", "shape_ears", "shape_ears_param_list", "shape_ears_tab", LLVector3d(0.f, 0.f, 0.05f), LLVector3d(-0.5f, 0.05f, 0.07f),SEX_BOTH));
addEntry(SUBPART_SHAPE_NOSE, new SubpartEntry(SUBPART_SHAPE_NOSE, "mHead", "shape_nose", "shape_nose_param_list", "shape_nose_tab", LLVector3d(0.f, 0.f, 0.05f), LLVector3d(-0.5f, 0.05f, 0.07f),SEX_BOTH));
addEntry(SUBPART_SHAPE_MOUTH, new SubpartEntry(SUBPART_SHAPE_MOUTH, "mHead", "shape_mouth", "shape_mouth_param_list", "shape_mouth_tab", LLVector3d(0.f, 0.f, 0.05f), LLVector3d(-0.5f, 0.05f, 0.07f),SEX_BOTH));
addEntry(SUBPART_SHAPE_CHIN, new SubpartEntry(SUBPART_SHAPE_CHIN, "mHead", "shape_chin", "shape_chin_param_list", "shape_chin_tab", LLVector3d(0.f, 0.f, 0.05f), LLVector3d(-0.5f, 0.05f, 0.07f),SEX_BOTH));
addEntry(SUBPART_SHAPE_TORSO, new SubpartEntry(SUBPART_SHAPE_TORSO, "mTorso", "shape_torso", "shape_torso_param_list", "shape_torso_tab", LLVector3d(0.f, 0.f, 0.3f), LLVector3d(-1.f, 0.15f, 0.3f),SEX_BOTH));
addEntry(SUBPART_SHAPE_LEGS, new SubpartEntry(SUBPART_SHAPE_LEGS, "mPelvis", "shape_legs", "shape_legs_param_list", "shape_legs_tab", LLVector3d(0.f, 0.f, -0.5f), LLVector3d(-1.6f, 0.15f, -0.5f),SEX_BOTH));
addEntry(SUBPART_SKIN_COLOR, new SubpartEntry(SUBPART_SKIN_COLOR, "mHead", "skin_color", "skin_color_param_list", "skin_color_tab", LLVector3d(0.f, 0.f, 0.05f), LLVector3d(-0.5f, 0.05f, 0.07f),SEX_BOTH));
addEntry(SUBPART_SKIN_FACEDETAIL, new SubpartEntry(SUBPART_SKIN_FACEDETAIL, "mHead", "skin_facedetail", "skin_face_param_list", "skin_face_tab", LLVector3d(0.f, 0.f, 0.05f), LLVector3d(-0.5f, 0.05f, 0.07f),SEX_BOTH));
addEntry(SUBPART_SKIN_MAKEUP, new SubpartEntry(SUBPART_SKIN_MAKEUP, "mHead", "skin_makeup", "skin_makeup_param_list", "skin_makeup_tab", LLVector3d(0.f, 0.f, 0.05f), LLVector3d(-0.5f, 0.05f, 0.07f),SEX_BOTH));
addEntry(SUBPART_SKIN_BODYDETAIL, new SubpartEntry(SUBPART_SKIN_BODYDETAIL, "mPelvis", "skin_bodydetail", "skin_body_param_list", "skin_body_tab", LLVector3d(0.f, 0.f, -0.2f), LLVector3d(-2.5f, 0.5f, 0.5f),SEX_BOTH));
addEntry(SUBPART_HAIR_COLOR, new SubpartEntry(SUBPART_HAIR_COLOR, "mHead", "hair_color", "hair_color_param_list", "hair_color_tab", LLVector3d(0.f, 0.f, 0.10f), LLVector3d(-0.4f, 0.05f, 0.10f),SEX_BOTH));
addEntry(SUBPART_HAIR_STYLE, new SubpartEntry(SUBPART_HAIR_STYLE, "mHead", "hair_style", "hair_style_param_list", "hair_style_tab", LLVector3d(0.f, 0.f, 0.10f), LLVector3d(-0.4f, 0.05f, 0.10f),SEX_BOTH));
addEntry(SUBPART_HAIR_EYEBROWS, new SubpartEntry(SUBPART_HAIR_EYEBROWS, "mHead", "hair_eyebrows", "hair_eyebrows_param_list", "hair_eyebrows_tab", LLVector3d(0.f, 0.f, 0.05f), LLVector3d(-0.5f, 0.05f, 0.07f),SEX_BOTH));
addEntry(SUBPART_HAIR_FACIAL, new SubpartEntry(SUBPART_HAIR_FACIAL, "mHead", "hair_facial", "hair_facial_param_list", "hair_facial_tab", LLVector3d(0.f, 0.f, 0.05f), LLVector3d(-0.5f, 0.05f, 0.07f),SEX_MALE));
addEntry(SUBPART_EYES, new SubpartEntry(SUBPART_EYES, "mHead", "eyes", "eyes_main_param_list", "eyes_main_tab", LLVector3d(0.f, 0.f, 0.05f), LLVector3d(-0.5f, 0.05f, 0.07f),SEX_BOTH));
addEntry(SUBPART_SHIRT, new SubpartEntry(SUBPART_SHIRT, "mTorso", "shirt", "shirt_main_param_list", "shirt_main_tab", LLVector3d(0.f, 0.f, 0.3f), LLVector3d(-1.f, 0.15f, 0.3f),SEX_BOTH));
addEntry(SUBPART_PANTS, new SubpartEntry(SUBPART_PANTS, "mPelvis", "pants", "pants_main_param_list", "pants_main_tab", LLVector3d(0.f, 0.f, -0.5f), LLVector3d(-1.6f, 0.15f, -0.5f),SEX_BOTH));
addEntry(SUBPART_SHOES, new SubpartEntry(SUBPART_SHOES, "mPelvis", "shoes", "shoes_main_param_list", "shoes_main_tab", LLVector3d(0.f, 0.f, -0.5f), LLVector3d(-1.6f, 0.15f, -0.5f),SEX_BOTH));
addEntry(SUBPART_SOCKS, new SubpartEntry(SUBPART_SOCKS, "mPelvis", "socks", "socks_main_param_list", "socks_main_tab", LLVector3d(0.f, 0.f, -0.5f), LLVector3d(-1.6f, 0.15f, -0.5f),SEX_BOTH));
addEntry(SUBPART_JACKET, new SubpartEntry(SUBPART_JACKET, "mTorso", "jacket", "jacket_main_param_list", "jacket_main_tab", LLVector3d(0.f, 0.f, 0.f), LLVector3d(-2.f, 0.1f, 0.3f),SEX_BOTH));
addEntry(SUBPART_SKIRT, new SubpartEntry(SUBPART_SKIRT, "mPelvis", "skirt", "skirt_main_param_list", "skirt_main_tab", LLVector3d(0.f, 0.f, -0.5f), LLVector3d(-1.6f, 0.15f, -0.5f),SEX_BOTH));
addEntry(SUBPART_GLOVES, new SubpartEntry(SUBPART_GLOVES, "mTorso", "gloves", "gloves_main_param_list", "gloves_main_tab", LLVector3d(0.f, 0.f, 0.f), LLVector3d(-1.f, 0.15f, 0.f),SEX_BOTH));
addEntry(SUBPART_UNDERSHIRT, new SubpartEntry(SUBPART_UNDERSHIRT, "mTorso", "undershirt", "undershirt_main_param_list", "undershirt_main_tab", LLVector3d(0.f, 0.f, 0.3f), LLVector3d(-1.f, 0.15f, 0.3f),SEX_BOTH));
addEntry(SUBPART_UNDERPANTS, new SubpartEntry(SUBPART_UNDERPANTS, "mPelvis", "underpants", "underpants_main_param_list", "underpants_main_tab", LLVector3d(0.f, 0.f, -0.5f), LLVector3d(-1.6f, 0.15f, -0.5f),SEX_BOTH));
addEntry(SUBPART_ALPHA, new SubpartEntry(SUBPART_ALPHA, "mPelvis", "alpha", "alpha_main_param_list", "alpha_main_tab", LLVector3d(0.f, 0.f, 0.1f), LLVector3d(-2.5f, 0.5f, 0.8f),SEX_BOTH));
addEntry(SUBPART_TATTOO, new SubpartEntry(SUBPART_TATTOO, "mPelvis", "tattoo", "tattoo_main_param_list", "tattoo_main_tab", LLVector3d(0.f, 0.f, 0.1f), LLVector3d(-2.5f, 0.5f, 0.8f),SEX_BOTH));
}
LLEditWearableDictionary::SubpartEntry::SubpartEntry(ESubpart part,
const std::string &joint,
const std::string &edit_group,
const std::string ¶m_list,
const std::string &accordion_tab,
const LLVector3d &target_offset,
const LLVector3d &camera_offset,
const ESex &sex) :
LLDictionaryEntry(edit_group),
mSubpart(part),
mTargetJoint(joint),
mEditGroup(edit_group),
mParamList(param_list),
mAccordionTab(accordion_tab),
mTargetOffset(target_offset),
mCameraOffset(camera_offset),
mSex(sex)
{
}
LLEditWearableDictionary::ColorSwatchCtrls::ColorSwatchCtrls()
{
addEntry ( TEX_UPPER_SHIRT, new PickerControlEntry (TEX_UPPER_SHIRT, "Color/Tint" ));
addEntry ( TEX_LOWER_PANTS, new PickerControlEntry (TEX_LOWER_PANTS, "Color/Tint" ));
addEntry ( TEX_LOWER_SHOES, new PickerControlEntry (TEX_LOWER_SHOES, "Color/Tint" ));
addEntry ( TEX_LOWER_SOCKS, new PickerControlEntry (TEX_LOWER_SOCKS, "Color/Tint" ));
addEntry ( TEX_UPPER_JACKET, new PickerControlEntry (TEX_UPPER_JACKET, "Color/Tint" ));
addEntry ( TEX_SKIRT, new PickerControlEntry (TEX_SKIRT, "Color/Tint" ));
addEntry ( TEX_UPPER_GLOVES, new PickerControlEntry (TEX_UPPER_GLOVES, "Color/Tint" ));
addEntry ( TEX_UPPER_UNDERSHIRT, new PickerControlEntry (TEX_UPPER_UNDERSHIRT, "Color/Tint" ));
addEntry ( TEX_LOWER_UNDERPANTS, new PickerControlEntry (TEX_LOWER_UNDERPANTS, "Color/Tint" ));
addEntry ( TEX_HEAD_TATTOO, new PickerControlEntry(TEX_HEAD_TATTOO, "Color/Tint" ));
}
LLEditWearableDictionary::TextureCtrls::TextureCtrls()
{
addEntry ( TEX_HEAD_BODYPAINT, new PickerControlEntry (TEX_HEAD_BODYPAINT, "Head Tattoos", LLUUID::null, TRUE ));
addEntry ( TEX_UPPER_BODYPAINT, new PickerControlEntry (TEX_UPPER_BODYPAINT, "Upper Tattoos", LLUUID::null, TRUE ));
addEntry ( TEX_LOWER_BODYPAINT, new PickerControlEntry (TEX_LOWER_BODYPAINT, "Lower Tattoos", LLUUID::null, TRUE ));
addEntry ( TEX_HAIR, new PickerControlEntry (TEX_HAIR, "Texture", LLUUID( gSavedSettings.getString( "UIImgDefaultHairUUID" ) ), FALSE ));
addEntry ( TEX_EYES_IRIS, new PickerControlEntry (TEX_EYES_IRIS, "Iris", LLUUID( gSavedSettings.getString( "UIImgDefaultEyesUUID" ) ), FALSE ));
addEntry ( TEX_UPPER_SHIRT, new PickerControlEntry (TEX_UPPER_SHIRT, "Fabric", LLUUID( gSavedSettings.getString( "UIImgDefaultShirtUUID" ) ), FALSE ));
addEntry ( TEX_LOWER_PANTS, new PickerControlEntry (TEX_LOWER_PANTS, "Fabric", LLUUID( gSavedSettings.getString( "UIImgDefaultPantsUUID" ) ), FALSE ));
addEntry ( TEX_LOWER_SHOES, new PickerControlEntry (TEX_LOWER_SHOES, "Fabric", LLUUID( gSavedSettings.getString( "UIImgDefaultShoesUUID" ) ), FALSE ));
addEntry ( TEX_LOWER_SOCKS, new PickerControlEntry (TEX_LOWER_SOCKS, "Fabric", LLUUID( gSavedSettings.getString( "UIImgDefaultSocksUUID" ) ), FALSE ));
addEntry ( TEX_UPPER_JACKET, new PickerControlEntry (TEX_UPPER_JACKET, "Upper Fabric", LLUUID( gSavedSettings.getString( "UIImgDefaultJacketUUID" ) ), FALSE ));
addEntry ( TEX_LOWER_JACKET, new PickerControlEntry (TEX_LOWER_JACKET, "Lower Fabric", LLUUID( gSavedSettings.getString( "UIImgDefaultJacketUUID" ) ), FALSE ));
addEntry ( TEX_SKIRT, new PickerControlEntry (TEX_SKIRT, "Fabric", LLUUID( gSavedSettings.getString( "UIImgDefaultSkirtUUID" ) ), FALSE ));
addEntry ( TEX_UPPER_GLOVES, new PickerControlEntry (TEX_UPPER_GLOVES, "Fabric", LLUUID( gSavedSettings.getString( "UIImgDefaultGlovesUUID" ) ), FALSE ));
addEntry ( TEX_UPPER_UNDERSHIRT, new PickerControlEntry (TEX_UPPER_UNDERSHIRT, "Fabric", LLUUID( gSavedSettings.getString( "UIImgDefaultUnderwearUUID" ) ), FALSE ));
addEntry ( TEX_LOWER_UNDERPANTS, new PickerControlEntry (TEX_LOWER_UNDERPANTS, "Fabric", LLUUID( gSavedSettings.getString( "UIImgDefaultUnderwearUUID" ) ), FALSE ));
addEntry ( TEX_LOWER_ALPHA, new PickerControlEntry (TEX_LOWER_ALPHA, "Lower Alpha", LLUUID( gSavedSettings.getString( "UIImgDefaultAlphaUUID" ) ), TRUE ));
addEntry ( TEX_UPPER_ALPHA, new PickerControlEntry (TEX_UPPER_ALPHA, "Upper Alpha", LLUUID( gSavedSettings.getString( "UIImgDefaultAlphaUUID" ) ), TRUE ));
addEntry ( TEX_HEAD_ALPHA, new PickerControlEntry (TEX_HEAD_ALPHA, "Head Alpha", LLUUID( gSavedSettings.getString( "UIImgDefaultAlphaUUID" ) ), TRUE ));
addEntry ( TEX_EYES_ALPHA, new PickerControlEntry (TEX_EYES_ALPHA, "Eye Alpha", LLUUID( gSavedSettings.getString( "UIImgDefaultAlphaUUID" ) ), TRUE ));
addEntry ( TEX_HAIR_ALPHA, new PickerControlEntry (TEX_HAIR_ALPHA, "Hair Alpha", LLUUID( gSavedSettings.getString( "UIImgDefaultAlphaUUID" ) ), TRUE ));
addEntry ( TEX_LOWER_TATTOO, new PickerControlEntry (TEX_LOWER_TATTOO, "Lower Tattoo", LLUUID::null, TRUE ));
addEntry ( TEX_UPPER_TATTOO, new PickerControlEntry (TEX_UPPER_TATTOO, "Upper Tattoo", LLUUID::null, TRUE ));
addEntry ( TEX_HEAD_TATTOO, new PickerControlEntry (TEX_HEAD_TATTOO, "Head Tattoo", LLUUID::null, TRUE ));
}
LLEditWearableDictionary::PickerControlEntry::PickerControlEntry(ETextureIndex tex_index,
const std::string name,
const LLUUID default_image_id,
const bool allow_no_texture) :
LLDictionaryEntry(name),
mTextureIndex(tex_index),
mControlName(name),
mDefaultImageId(default_image_id),
mAllowNoTexture(allow_no_texture)
{
}
// Helper functions.
static const texture_vec_t null_texture_vec;
// Specializations of this template function return a vector of texture indexes of particular control type
// (i.e. LLColorSwatchCtrl or LLTextureCtrl) which are contained in given WearableEntry.
template <typename T>
const texture_vec_t&
get_pickers_indexes(const LLEditWearableDictionary::WearableEntry *wearable_entry) { return null_texture_vec; }
// Specializations of this template function return picker control entry for particular control type.
template <typename T>
const LLEditWearableDictionary::PickerControlEntry*
get_picker_entry (const ETextureIndex index) { return NULL; }
typedef boost::function<void(LLPanel* panel, const LLEditWearableDictionary::PickerControlEntry*)> function_t;
typedef struct PickerControlEntryNamePredicate
{
PickerControlEntryNamePredicate(const std::string name) : mName (name) {};
bool operator()(const LLEditWearableDictionary::PickerControlEntry* entry) const
{
return (entry && entry->mName == mName);
}
private:
const std::string mName;
} PickerControlEntryNamePredicate;
// A full specialization of get_pickers_indexes for LLColorSwatchCtrl
template <>
const texture_vec_t&
get_pickers_indexes<LLColorSwatchCtrl> (const LLEditWearableDictionary::WearableEntry *wearable_entry)
{
if (!wearable_entry)
{
llwarns << "could not get LLColorSwatchCtrl indexes for null wearable entry." << llendl;
return null_texture_vec;
}
return wearable_entry->mColorSwatchCtrls;
}
// A full specialization of get_pickers_indexes for LLTextureCtrl
template <>
const texture_vec_t&
get_pickers_indexes<LLTextureCtrl> (const LLEditWearableDictionary::WearableEntry *wearable_entry)
{
if (!wearable_entry)
{
llwarns << "could not get LLTextureCtrl indexes for null wearable entry." << llendl;
return null_texture_vec;
}
return wearable_entry->mTextureCtrls;
}
// A full specialization of get_picker_entry for LLColorSwatchCtrl
template <>
const LLEditWearableDictionary::PickerControlEntry*
get_picker_entry<LLColorSwatchCtrl> (const ETextureIndex index)
{
return LLEditWearableDictionary::getInstance()->getColorSwatch(index);
}
// A full specialization of get_picker_entry for LLTextureCtrl
template <>
const LLEditWearableDictionary::PickerControlEntry*
get_picker_entry<LLTextureCtrl> (const ETextureIndex index)
{
return LLEditWearableDictionary::getInstance()->getTexturePicker(index);
}
template <typename CtrlType, class Predicate>
const LLEditWearableDictionary::PickerControlEntry*
find_picker_ctrl_entry_if(LLWearableType::EType type, const Predicate pred)
{
const LLEditWearableDictionary::WearableEntry *wearable_entry
= LLEditWearableDictionary::getInstance()->getWearable(type);
if (!wearable_entry)
{
llwarns << "could not get wearable dictionary entry for wearable of type: " << type << llendl;
return NULL;
}
const texture_vec_t& indexes = get_pickers_indexes<CtrlType>(wearable_entry);
for (texture_vec_t::const_iterator
iter = indexes.begin(),
iter_end = indexes.end();
iter != iter_end; ++iter)
{
const ETextureIndex te = *iter;
const LLEditWearableDictionary::PickerControlEntry* entry
= get_picker_entry<CtrlType>(te);
if (!entry)
{
llwarns << "could not get picker dictionary entry (" << te << ") for wearable of type: " << type << llendl;
continue;
}
if (pred(entry))
{
return entry;
}
}
return NULL;
}
template <typename CtrlType>
void
for_each_picker_ctrl_entry(LLPanel* panel, LLWearableType::EType type, function_t fun)
{
if (!panel)
{
llwarns << "the panel wasn't passed for wearable of type: " << type << llendl;
return;
}
const LLEditWearableDictionary::WearableEntry *wearable_entry
= LLEditWearableDictionary::getInstance()->getWearable(type);
if (!wearable_entry)
{
llwarns << "could not get wearable dictionary entry for wearable of type: " << type << llendl;
return;
}
const texture_vec_t& indexes = get_pickers_indexes<CtrlType>(wearable_entry);
for (texture_vec_t::const_iterator
iter = indexes.begin(),
iter_end = indexes.end();
iter != iter_end; ++iter)
{
const ETextureIndex te = *iter;
const LLEditWearableDictionary::PickerControlEntry* entry
= get_picker_entry<CtrlType>(te);
if (!entry)
{
llwarns << "could not get picker dictionary entry (" << te << ") for wearable of type: " << type << llendl;
continue;
}
fun (panel, entry);
}
}
// The helper functions for pickers management
static void init_color_swatch_ctrl(LLPanelEditWearable* self, LLPanel* panel, const LLEditWearableDictionary::PickerControlEntry* entry)
{
LLColorSwatchCtrl* color_swatch_ctrl = panel->getChild<LLColorSwatchCtrl>(entry->mControlName);
if (color_swatch_ctrl)
{
// Can't get the color from the wearable here, since the wearable may not be set when this is called.
color_swatch_ctrl->setOriginal(LLColor4::white);
}
}
static void init_texture_ctrl(LLPanelEditWearable* self, LLPanel* panel, const LLEditWearableDictionary::PickerControlEntry* entry)
{
LLTextureCtrl* texture_ctrl = panel->getChild<LLTextureCtrl>(entry->mControlName);
if (texture_ctrl)
{
texture_ctrl->setDefaultImageAssetID(entry->mDefaultImageId);
texture_ctrl->setAllowNoTexture(entry->mAllowNoTexture);
// Don't allow (no copy) or (notransfer) textures to be selected.
texture_ctrl->setImmediateFilterPermMask(PERM_NONE);
texture_ctrl->setNonImmediateFilterPermMask(PERM_NONE);
}
}
static void update_color_swatch_ctrl(LLPanelEditWearable* self, LLPanel* panel, const LLEditWearableDictionary::PickerControlEntry* entry)
{
LLColorSwatchCtrl* color_swatch_ctrl = panel->getChild<LLColorSwatchCtrl>(entry->mControlName);
if (color_swatch_ctrl)
{
color_swatch_ctrl->set(self->getWearable()->getClothesColor(entry->mTextureIndex));
}
}
static void update_texture_ctrl(LLPanelEditWearable* self, LLPanel* panel, const LLEditWearableDictionary::PickerControlEntry* entry)
{
LLTextureCtrl* texture_ctrl = panel->getChild<LLTextureCtrl>(entry->mControlName);
if (texture_ctrl)
{
LLUUID new_id;
LLLocalTextureObject *lto = self->getWearable()->getLocalTextureObject(entry->mTextureIndex);
if( lto && (lto->getID() != IMG_DEFAULT_AVATAR) )
{
new_id = lto->getID();
}
else
{
new_id = LLUUID::null;
}
LLUUID old_id = texture_ctrl->getImageAssetID();
if (old_id != new_id)
{
// texture has changed, close the floater to avoid DEV-22461
texture_ctrl->closeDependentFloater();
}
texture_ctrl->setImageAssetID(new_id);
}
}
static void set_enabled_color_swatch_ctrl(bool enabled, LLPanel* panel, const LLEditWearableDictionary::PickerControlEntry* entry)
{
LLColorSwatchCtrl* color_swatch_ctrl = panel->getChild<LLColorSwatchCtrl>(entry->mControlName);
if (color_swatch_ctrl)
{
color_swatch_ctrl->setEnabled(enabled);
}
}
static void set_enabled_texture_ctrl(bool enabled, LLPanel* panel, const LLEditWearableDictionary::PickerControlEntry* entry)
{
LLTextureCtrl* texture_ctrl = panel->getChild<LLTextureCtrl>(entry->mControlName);
if (texture_ctrl)
{
texture_ctrl->setEnabled(enabled);
}
}
// LLPanelEditWearable
LLPanelEditWearable::LLPanelEditWearable()
: LLPanel()
, mWearablePtr(NULL)
, mWearableItem(NULL)
{
mCommitCallbackRegistrar.add("ColorSwatch.Commit", boost::bind(&LLPanelEditWearable::onColorSwatchCommit, this, _1));
mCommitCallbackRegistrar.add("TexturePicker.Commit", boost::bind(&LLPanelEditWearable::onTexturePickerCommit, this, _1));
}
//virtual
LLPanelEditWearable::~LLPanelEditWearable()
{
}
// virtual
BOOL LLPanelEditWearable::postBuild()
{
// buttons
mBtnRevert = getChild<LLButton>("revert_button");
mBtnRevert->setClickedCallback(boost::bind(&LLPanelEditWearable::onRevertButtonClicked, this));
mBtnBack = getChild<LLButton>("back_btn");
// handled at appearance panel level?
//mBtnBack->setClickedCallback(boost::bind(&LLPanelEditWearable::onBackButtonClicked, this));
mTextEditor = getChild<LLTextEditor>("description");
mPanelTitle = getChild<LLTextBox>("edit_wearable_title");
mDescTitle = getChild<LLTextBox>("description_text");
getChild<LLRadioGroup>("sex_radio")->setCommitCallback(boost::bind(&LLPanelEditWearable::onCommitSexChange, this));
getChild<LLButton>("save_as_button")->setCommitCallback(boost::bind(&LLPanelEditWearable::onSaveAsButtonClicked, this));
// The following panels will be shown/hidden based on what wearable we're editing
// body parts
mPanelShape = getChild<LLPanel>("edit_shape_panel");
mPanelSkin = getChild<LLPanel>("edit_skin_panel");
mPanelEyes = getChild<LLPanel>("edit_eyes_panel");
mPanelHair = getChild<LLPanel>("edit_hair_panel");
//clothes
mPanelShirt = getChild<LLPanel>("edit_shirt_panel");
mPanelPants = getChild<LLPanel>("edit_pants_panel");
mPanelShoes = getChild<LLPanel>("edit_shoes_panel");
mPanelSocks = getChild<LLPanel>("edit_socks_panel");
mPanelJacket = getChild<LLPanel>("edit_jacket_panel");
mPanelGloves = getChild<LLPanel>("edit_gloves_panel");
mPanelUndershirt = getChild<LLPanel>("edit_undershirt_panel");
mPanelUnderpants = getChild<LLPanel>("edit_underpants_panel");
mPanelSkirt = getChild<LLPanel>("edit_skirt_panel");
mPanelAlpha = getChild<LLPanel>("edit_alpha_panel");
mPanelTattoo = getChild<LLPanel>("edit_tattoo_panel");
mTxtAvatarHeight = mPanelShape->getChild<LLTextBox>("avatar_height");
mWearablePtr = NULL;
configureAlphaCheckbox(LLVOAvatarDefines::TEX_LOWER_ALPHA, "lower alpha texture invisible");
configureAlphaCheckbox(LLVOAvatarDefines::TEX_UPPER_ALPHA, "upper alpha texture invisible");
configureAlphaCheckbox(LLVOAvatarDefines::TEX_HEAD_ALPHA, "head alpha texture invisible");
configureAlphaCheckbox(LLVOAvatarDefines::TEX_EYES_ALPHA, "eye alpha texture invisible");
configureAlphaCheckbox(LLVOAvatarDefines::TEX_HAIR_ALPHA, "hair alpha texture invisible");
// configure tab expanded callbacks
for (U32 type_index = 0; type_index < (U32)LLWearableType::WT_COUNT; ++type_index)
{
LLWearableType::EType type = (LLWearableType::EType) type_index;
const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(type);
if (!wearable_entry)
{
llwarns << "could not get wearable dictionary entry for wearable of type: " << type << llendl;
continue;
}
U8 num_subparts = wearable_entry->mSubparts.size();
for (U8 index = 0; index < num_subparts; ++index)
{
// dive into data structures to get the panel we need
ESubpart subpart_e = wearable_entry->mSubparts[index];
const LLEditWearableDictionary::SubpartEntry *subpart_entry = LLEditWearableDictionary::getInstance()->getSubpart(subpart_e);
if (!subpart_entry)
{
llwarns << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << llendl;
continue;
}
const std::string accordion_tab = subpart_entry->mAccordionTab;
LLAccordionCtrlTab *tab = getChild<LLAccordionCtrlTab>(accordion_tab);
if (!tab)
{
llwarns << "could not get llaccordionctrltab from UI with name: " << accordion_tab << llendl;
continue;
}
// initialize callback to ensure camera view changes appropriately.
tab->setDropDownStateChangedCallback(boost::bind(&LLPanelEditWearable::onTabExpandedCollapsed,this,_2,index));
}
// initialize texture and color picker controls
for_each_picker_ctrl_entry <LLColorSwatchCtrl> (getPanel(type), type, boost::bind(init_color_swatch_ctrl, this, _1, _2));
for_each_picker_ctrl_entry <LLTextureCtrl> (getPanel(type), type, boost::bind(init_texture_ctrl, this, _1, _2));
}
return TRUE;
}
// virtual
// LLUICtrl
BOOL LLPanelEditWearable::isDirty() const
{
BOOL isDirty = FALSE;
if (mWearablePtr)
{
if (mWearablePtr->isDirty() ||
mWearablePtr->getName().compare(mTextEditor->getText()) != 0)
{
isDirty = TRUE;
}
}
return isDirty;
}
//virtual
void LLPanelEditWearable::draw()
{
updateVerbs();
if (getWearable() && getWearable()->getType() == LLWearableType::WT_SHAPE)
{
//updating avatar height
updateTypeSpecificControls(LLWearableType::WT_SHAPE);
}
LLPanel::draw();
}
void LLPanelEditWearable::setWearable(LLWearable *wearable)
{
showWearable(mWearablePtr, FALSE);
mWearablePtr = wearable;
showWearable(mWearablePtr, TRUE);
}
//static
void LLPanelEditWearable::onRevertButtonClicked(void* userdata)
{
LLPanelEditWearable *panel = (LLPanelEditWearable*) userdata;
panel->revertChanges();
}
void LLPanelEditWearable::onSaveAsButtonClicked()
{
LLSD args;
args["DESC"] = mTextEditor->getText();
LLNotificationsUtil::add("SaveWearableAs", args, LLSD(), boost::bind(&LLPanelEditWearable::saveAsCallback, this, _1, _2));
}
void LLPanelEditWearable::saveAsCallback(const LLSD& notification, const LLSD& response)
{
S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
if (0 == option)
{
std::string wearable_name = response["message"].asString();
LLStringUtil::trim(wearable_name);
if( !wearable_name.empty() )
{
mTextEditor->setText(wearable_name);
saveChanges();
}
}
}
void LLPanelEditWearable::onCommitSexChange()
{
if (!isAgentAvatarValid()) return;
LLWearableType::EType type = mWearablePtr->getType();
U32 index = gAgentWearables.getWearableIndex(mWearablePtr);
if( !gAgentWearables.isWearableModifiable(type, index))
{
return;
}
LLViewerVisualParam* param = static_cast<LLViewerVisualParam*>(gAgentAvatarp->getVisualParam( "male" ));
if( !param )
{
return;
}
bool is_new_sex_male = (gSavedSettings.getU32("AvatarSex") ? SEX_MALE : SEX_FEMALE) == SEX_MALE;
LLWearable* wearable = gAgentWearables.getWearable(type, index);
if (wearable)
{
wearable->setVisualParamWeight(param->getID(), is_new_sex_male, FALSE);
}
param->setWeight( is_new_sex_male, FALSE );
gAgentAvatarp->updateSexDependentLayerSets( FALSE );
gAgentAvatarp->updateVisualParams();
updateScrollingPanelUI();
}
void LLPanelEditWearable::onTexturePickerCommit(const LLUICtrl* ctrl)
{
const LLTextureCtrl* texture_ctrl = dynamic_cast<const LLTextureCtrl*>(ctrl);
if (!texture_ctrl)
{
llwarns << "got commit signal from not LLTextureCtrl." << llendl;
return;
}
if (getWearable())
{
LLWearableType::EType type = getWearable()->getType();
const PickerControlEntryNamePredicate name_pred(texture_ctrl->getName());
const LLEditWearableDictionary::PickerControlEntry* entry
= find_picker_ctrl_entry_if<LLTextureCtrl, PickerControlEntryNamePredicate>(type, name_pred);
if (entry)
{
// Set the new version
LLViewerFetchedTexture* image = LLViewerTextureManager::getFetchedTexture(texture_ctrl->getImageAssetID());
if( image->getID().isNull() )
{
image = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT_AVATAR);
}
if (getWearable())
{
U32 index = gAgentWearables.getWearableIndex(getWearable());
gAgentAvatarp->setLocalTexture(entry->mTextureIndex, image, FALSE, index);
LLVisualParamHint::requestHintUpdates();
gAgentAvatarp->wearableUpdated(type, FALSE);
}
}
else
{
llwarns << "could not get texture picker dictionary entry for wearable of type: " << type << llendl;
}
}
}
void LLPanelEditWearable::onColorSwatchCommit(const LLUICtrl* ctrl)
{
if (getWearable())
{
LLWearableType::EType type = getWearable()->getType();
const PickerControlEntryNamePredicate name_pred(ctrl->getName());
const LLEditWearableDictionary::PickerControlEntry* entry
= find_picker_ctrl_entry_if<LLColorSwatchCtrl, PickerControlEntryNamePredicate>(type, name_pred);
if (entry)
{
const LLColor4& old_color = getWearable()->getClothesColor(entry->mTextureIndex);
const LLColor4& new_color = LLColor4(ctrl->getValue());
if( old_color != new_color )
{
getWearable()->setClothesColor(entry->mTextureIndex, new_color, TRUE);
LLVisualParamHint::requestHintUpdates();
gAgentAvatarp->wearableUpdated(getWearable()->getType(), FALSE);
}
}
else
{
llwarns << "could not get color swatch dictionary entry for wearable of type: " << type << llendl;
}
}
}
void LLPanelEditWearable::updatePanelPickerControls(LLWearableType::EType type)
{
LLPanel* panel = getPanel(type);
if (!panel)
return;
bool is_modifiable = false;
bool is_complete = false;
bool is_copyable = false;
if(mWearableItem)
{
const LLPermissions& perm = mWearableItem->getPermissions();
is_modifiable = perm.allowModifyBy(gAgent.getID(), gAgent.getGroupID());
is_copyable = perm.allowCopyBy(gAgent.getID(), gAgent.getGroupID());
is_complete = mWearableItem->isFinished();
}
if (is_modifiable && is_complete)
{
// Update picker controls
for_each_picker_ctrl_entry <LLColorSwatchCtrl> (panel, type, boost::bind(update_color_swatch_ctrl, this, _1, _2));
for_each_picker_ctrl_entry <LLTextureCtrl> (panel, type, boost::bind(update_texture_ctrl, this, _1, _2));
}
if (!is_modifiable || !is_complete || !is_copyable)
{
// Disable controls
for_each_picker_ctrl_entry <LLColorSwatchCtrl> (panel, type, boost::bind(set_enabled_color_swatch_ctrl, false, _1, _2));
for_each_picker_ctrl_entry <LLTextureCtrl> (panel, type, boost::bind(set_enabled_texture_ctrl, false, _1, _2));
}
}
void LLPanelEditWearable::saveChanges()
{
if (!mWearablePtr || !isDirty())
{
// do nothing if no unsaved changes
return;
}
U32 index = gAgentWearables.getWearableIndex(mWearablePtr);
if (mWearablePtr->getName().compare(mTextEditor->getText()) != 0)
{
// the name of the wearable has changed, re-save wearable with new name
gAgentWearables.saveWearableAs(mWearablePtr->getType(), index, mTextEditor->getText(), FALSE);
}
else
{
gAgentWearables.saveWearable(mWearablePtr->getType(), index);
}
}
void LLPanelEditWearable::revertChanges()
{
if (!mWearablePtr || !isDirty())
{
// no unsaved changes to revert
return;
}
mWearablePtr->revertValues();
mTextEditor->setText(mWearablePtr->getName());
}
void LLPanelEditWearable::showWearable(LLWearable* wearable, BOOL show)
{
if (!wearable)
{
return;
}
mWearableItem = gInventory.getItem(mWearablePtr->getItemID());
llassert(mWearableItem);
LLWearableType::EType type = wearable->getType();
LLPanel *targetPanel = NULL;
std::string title;
std::string description_title;
const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(type);
if (!wearable_entry)
{
llwarns << "called LLPanelEditWearable::showWearable with an invalid wearable type! (" << type << ")" << llendl;
return;
}
targetPanel = getPanel(type);
title = getString(wearable_entry->mTitle);
description_title = getString(wearable_entry->mDescTitle);
// Update picker controls state
for_each_picker_ctrl_entry <LLColorSwatchCtrl> (targetPanel, type, boost::bind(set_enabled_color_swatch_ctrl, show, _1, _2));
for_each_picker_ctrl_entry <LLTextureCtrl> (targetPanel, type, boost::bind(set_enabled_texture_ctrl, show, _1, _2));
targetPanel->setVisible(show);
toggleTypeSpecificControls(type);
if (show)
{
mPanelTitle->setText(title);
mDescTitle->setText(description_title);
// set name
mTextEditor->setText(wearable->getName());
updatePanelPickerControls(type);
updateTypeSpecificControls(type);
// clear and rebuild visual param list
U8 num_subparts = wearable_entry->mSubparts.size();
for (U8 index = 0; index < num_subparts; ++index)
{
// dive into data structures to get the panel we need
ESubpart subpart_e = wearable_entry->mSubparts[index];
const LLEditWearableDictionary::SubpartEntry *subpart_entry = LLEditWearableDictionary::getInstance()->getSubpart(subpart_e);
if (!subpart_entry)
{
llwarns << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << llendl;
continue;
}
const std::string scrolling_panel = subpart_entry->mParamList;
const std::string accordion_tab = subpart_entry->mAccordionTab;
LLScrollingPanelList *panel_list = getChild<LLScrollingPanelList>(scrolling_panel);
LLAccordionCtrlTab *tab = getChild<LLAccordionCtrlTab>(accordion_tab);
if (!panel_list)
{
llwarns << "could not get scrolling panel list: " << scrolling_panel << llendl;
continue;
}
if (!tab)
{
llwarns << "could not get llaccordionctrltab from UI with name: " << accordion_tab << llendl;
continue;
}
// what edit group do we want to extract params for?
const std::string edit_group = subpart_entry->mEditGroup;
// storage for ordered list of visual params
value_map_t sorted_params;
getSortedParams(sorted_params, edit_group);
buildParamList(panel_list, sorted_params, tab);
updateScrollingPanelUI();
}
showDefaultSubpart();
updateVerbs();
}
}
void LLPanelEditWearable::showDefaultSubpart()
{
changeCamera(0);
}
void LLPanelEditWearable::onTabExpandedCollapsed(const LLSD& param, U8 index)
{
bool expanded = param.asBoolean();
if (!mWearablePtr || !gAgentCamera.cameraCustomizeAvatar())
{
// we don't have a valid wearable we're editing, or we've left the wearable editor
return;
}
if (expanded)
{
changeCamera(index);
}
}
void LLPanelEditWearable::changeCamera(U8 subpart)
{
const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(mWearablePtr->getType());
if (!wearable_entry)
{
llinfos << "could not get wearable dictionary entry for wearable type: " << mWearablePtr->getType() << llendl;
return;
}
if (subpart >= wearable_entry->mSubparts.size())
{
llinfos << "accordion tab expanded for invalid subpart. Wearable type: " << mWearablePtr->getType() << " subpart num: " << subpart << llendl;
return;
}
ESubpart subpart_e = wearable_entry->mSubparts[subpart];
const LLEditWearableDictionary::SubpartEntry *subpart_entry = LLEditWearableDictionary::getInstance()->getSubpart(subpart_e);
if (!subpart_entry)
{
llwarns << "could not get wearable subpart dictionary entry for subpart: " << subpart_e << llendl;
return;
}
// Update the camera
gMorphView->setCameraDistToDefault();
gMorphView->setCameraTargetJoint( gAgentAvatarp->getJoint( subpart_entry->mTargetJoint ) );
gMorphView->setCameraTargetOffset( subpart_entry->mTargetOffset );
gMorphView->setCameraOffset( subpart_entry->mCameraOffset );
if (gSavedSettings.getBOOL("AppearanceCameraMovement"))
{
gMorphView->updateCamera();
}
}
void LLPanelEditWearable::updateScrollingPanelList()
{
updateScrollingPanelUI();
}
void LLPanelEditWearable::toggleTypeSpecificControls(LLWearableType::EType type)
{
// Toggle controls specific to shape editing panel.
{
bool is_shape = (type == LLWearableType::WT_SHAPE);
childSetVisible("sex_radio", is_shape);
childSetVisible("female_icon", is_shape);
childSetVisible("male_icon", is_shape);
}
}
void LLPanelEditWearable::updateTypeSpecificControls(LLWearableType::EType type)
{
// Update controls specific to shape editing panel.
if (type == LLWearableType::WT_SHAPE)
{
// Update avatar height
std::string avatar_height_str = llformat("%.2f", gAgentAvatarp->mBodySize.mV[VZ]);
mTxtAvatarHeight->setTextArg("[HEIGHT]", avatar_height_str);
}
if (LLWearableType::WT_ALPHA == type)
{
updateAlphaCheckboxes();
initPreviousAlphaTextures();
}
}
void LLPanelEditWearable::updateScrollingPanelUI()
{
// do nothing if we don't have a valid wearable we're editing
if (mWearablePtr == NULL)
{
return;
}
LLWearableType::EType type = mWearablePtr->getType();
LLPanel *panel = getPanel(type);
if(panel && (mWearablePtr->getItemID().notNull()))
{
const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(type);
llassert(wearable_entry);
if (!wearable_entry) return;
U8 num_subparts = wearable_entry->mSubparts.size();
LLScrollingPanelParam::sUpdateDelayFrames = 0;
for (U8 index = 0; index < num_subparts; ++index)
{
// dive into data structures to get the panel we need
ESubpart subpart_e = wearable_entry->mSubparts[index];
const LLEditWearableDictionary::SubpartEntry *subpart_entry = LLEditWearableDictionary::getInstance()->getSubpart(subpart_e);
const std::string scrolling_panel = subpart_entry->mParamList;
LLScrollingPanelList *panel_list = getChild<LLScrollingPanelList>(scrolling_panel);
if (!panel_list)
{
llwarns << "could not get scrolling panel list: " << scrolling_panel << llendl;
continue;
}
panel_list->updatePanels(TRUE);
}
}
}
LLPanel* LLPanelEditWearable::getPanel(LLWearableType::EType type)
{
switch (type)
{
case LLWearableType::WT_SHAPE:
return mPanelShape;
break;
case LLWearableType::WT_SKIN:
return mPanelSkin;
break;
case LLWearableType::WT_HAIR:
return mPanelHair;
break;
case LLWearableType::WT_EYES:
return mPanelEyes;
break;
case LLWearableType::WT_SHIRT:
return mPanelShirt;
break;
case LLWearableType::WT_PANTS:
return mPanelPants;
break;
case LLWearableType::WT_SHOES:
return mPanelShoes;
break;
case LLWearableType::WT_SOCKS:
return mPanelSocks;
break;
case LLWearableType::WT_JACKET:
return mPanelJacket;
break;
case LLWearableType::WT_GLOVES:
return mPanelGloves;
break;
case LLWearableType::WT_UNDERSHIRT:
return mPanelUndershirt;
break;
case LLWearableType::WT_UNDERPANTS:
return mPanelUnderpants;
break;
case LLWearableType::WT_SKIRT:
return mPanelSkirt;
break;
case LLWearableType::WT_ALPHA:
return mPanelAlpha;
break;
case LLWearableType::WT_TATTOO:
return mPanelTattoo;
break;
default:
break;
}
return NULL;
}
void LLPanelEditWearable::getSortedParams(value_map_t &sorted_params, const std::string &edit_group)
{
LLWearable::visual_param_vec_t param_list;
ESex avatar_sex = gAgentAvatarp->getSex();
mWearablePtr->getVisualParams(param_list);
for (LLWearable::visual_param_vec_t::iterator iter = param_list.begin();
iter != param_list.end();
++iter)
{
LLViewerVisualParam *param = (LLViewerVisualParam*) *iter;
if (param->getID() == -1
|| param->getGroup() != VISUAL_PARAM_GROUP_TWEAKABLE
|| param->getEditGroup() != edit_group
|| !(param->getSex() & avatar_sex))
{
continue;
}
value_map_t::value_type vt(-param->getDisplayOrder(), param);
llassert( sorted_params.find(-param->getDisplayOrder()) == sorted_params.end() ); //check for duplicates
sorted_params.insert(vt);
}
}
void LLPanelEditWearable::buildParamList(LLScrollingPanelList *panel_list, value_map_t &sorted_params, LLAccordionCtrlTab *tab)
{
// sorted_params is sorted according to magnitude of effect from
// least to greatest. Adding to the front of the child list
// reverses that order.
if( panel_list )
{
panel_list->clearPanels();
value_map_t::iterator end = sorted_params.end();
S32 height = 0;
for(value_map_t::iterator it = sorted_params.begin(); it != end; ++it)
{
LLPanel::Params p;
p.name("LLScrollingPanelParam");
LLScrollingPanelParam* panel_param = new LLScrollingPanelParam( p, NULL, (*it).second, TRUE, this->getWearable());
height = panel_list->addPanel( panel_param );
}
}
}
void LLPanelEditWearable::updateVerbs()
{
bool can_copy = false;
if(mWearableItem)
{
can_copy = mWearableItem->getPermissions().allowCopyBy(gAgentID);
}
BOOL is_dirty = isDirty();
mBtnRevert->setEnabled(is_dirty);
childSetEnabled("save_as_button", is_dirty && can_copy);
if(isAgentAvatarValid())
{
// Update viewer's radio buttons (of RadioGroup with control_name="AvatarSex") of Avatar's gender
// with value from "AvatarSex" setting
gSavedSettings.setU32("AvatarSex", (gAgentAvatarp->getSex() == SEX_MALE) );
}
}
void LLPanelEditWearable::configureAlphaCheckbox(LLVOAvatarDefines::ETextureIndex te, const std::string& name)
{
LLCheckBoxCtrl* checkbox = mPanelAlpha->getChild<LLCheckBoxCtrl>(name);
checkbox->setCommitCallback(boost::bind(&LLPanelEditWearable::onInvisibilityCommit, this, checkbox, te));
mAlphaCheckbox2Index[name] = te;
}
void LLPanelEditWearable::onInvisibilityCommit(LLCheckBoxCtrl* checkbox_ctrl, LLVOAvatarDefines::ETextureIndex te)
{
if (!checkbox_ctrl) return;
if (!getWearable()) return;
llinfos << "onInvisibilityCommit, self " << this << " checkbox_ctrl " << checkbox_ctrl << llendl;
bool new_invis_state = checkbox_ctrl->get();
if (new_invis_state)
{
LLLocalTextureObject *lto = getWearable()->getLocalTextureObject(te);
mPreviousAlphaTexture[te] = lto->getID();
LLViewerFetchedTexture* image = LLViewerTextureManager::getFetchedTexture( IMG_INVISIBLE );
U32 index = gAgentWearables.getWearableIndex(getWearable());
gAgentAvatarp->setLocalTexture(te, image, FALSE, index);
gAgentAvatarp->wearableUpdated(getWearable()->getType(), FALSE);
}
else
{
// Try to restore previous texture, if any.
LLUUID prev_id = mPreviousAlphaTexture[te];
if (prev_id.isNull() || (prev_id == IMG_INVISIBLE))
{
prev_id = LLUUID( gSavedSettings.getString( "UIImgDefaultAlphaUUID" ) );
}
if (prev_id.isNull()) return;
LLViewerFetchedTexture* image = LLViewerTextureManager::getFetchedTexture(prev_id);
if (!image) return;
U32 index = gAgentWearables.getWearableIndex(getWearable());
gAgentAvatarp->setLocalTexture(te, image, FALSE, index);
gAgentAvatarp->wearableUpdated(getWearable()->getType(), FALSE);
}
updatePanelPickerControls(getWearable()->getType());
}
void LLPanelEditWearable::updateAlphaCheckboxes()
{
for(string_texture_index_map_t::iterator iter = mAlphaCheckbox2Index.begin();
iter != mAlphaCheckbox2Index.end(); ++iter )
{
LLVOAvatarDefines::ETextureIndex te = (LLVOAvatarDefines::ETextureIndex)iter->second;
LLCheckBoxCtrl* ctrl = mPanelAlpha->getChild<LLCheckBoxCtrl>(iter->first);
if (ctrl)
{
ctrl->set(!gAgentAvatarp->isTextureVisible(te, mWearablePtr));
}
}
}
void LLPanelEditWearable::initPreviousAlphaTextures()
{
initPreviousAlphaTextureEntry(TEX_LOWER_ALPHA);
initPreviousAlphaTextureEntry(TEX_UPPER_ALPHA);
initPreviousAlphaTextureEntry(TEX_HEAD_ALPHA);
initPreviousAlphaTextureEntry(TEX_EYES_ALPHA);
initPreviousAlphaTextureEntry(TEX_LOWER_ALPHA);
}
void LLPanelEditWearable::initPreviousAlphaTextureEntry(LLVOAvatarDefines::ETextureIndex te)
{
LLLocalTextureObject *lto = getWearable()->getLocalTextureObject(te);
if (lto)
{
mPreviousAlphaTexture[te] = lto->getID();
}
}
// EOF
|