@@ -121,6 +121,7 @@ public class MpPedCustomization
121121 private float _shapeMixValue ;
122122 private float _skinMixValue ;
123123 private readonly Dictionary < int , int > shapeFaceValues = [ ] ;
124+ // TODO: Chris: Replace with enums or something more sane - updating with index/magic numbers is nuts
124125 private readonly Dictionary < int , Tuple < int , int , float > > appearanceValues = [ ] ;
125126 private int _hairSelection ;
126127 private int _hairColorSelection ;
@@ -157,6 +158,28 @@ private void MakeCreateCharacterMenu(bool male, bool editPed = false)
157158
158159 SetPlayerClothing ( ) ;
159160 }
161+ else
162+ {
163+ PedHeadBlendData headBlendData = currentCharacter . PedHeadBlendData ;
164+
165+ _dadSelection = headBlendData . FirstFaceShape ;
166+ _mumSelection = headBlendData . SecondFaceShape ;
167+ _shapeMixValue = headBlendData . ParentFaceShapePercent ;
168+ _skinMixValue = headBlendData . ParentSkinTonePercent ;
169+
170+ if ( _shapeMixValue > 1f )
171+ {
172+ Log ( "Shape mix value was incorrectly saved with a value higher than the possible maximum. Resetting to max value" ) ;
173+ _shapeMixValue = 1f ;
174+ }
175+
176+ if ( _skinMixValue > 1f )
177+ {
178+ Log ( "Skin mix value was incorrectly saved with a value higher than the possible maximum. Resetting to max value" ) ;
179+ _skinMixValue = 1f ;
180+ }
181+ }
182+
160183 currentCharacter . DrawableVariations . clothes ??= new Dictionary < int , KeyValuePair < int , int > > ( ) ;
161184 currentCharacter . PropVariations . props ??= new Dictionary < int , KeyValuePair < int , int > > ( ) ;
162185
@@ -183,15 +206,41 @@ private void MakeCreateCharacterMenu(bool male, bool editPed = false)
183206 propsMenu . ClearMenuItems ( ) ;
184207
185208 #region appearance menu.
186- // Clears any saved appearance values from prior peds
187- _hairSelection = 0 ;
188- _hairColorSelection = 0 ;
189- _hairHighlightColorSelection = 0 ;
190- _eyeColorSelection = 0 ;
209+ if ( ! editPed )
210+ {
211+ // Clears any saved appearance values from prior peds
212+ _hairSelection = 0 ;
213+ _hairColorSelection = 0 ;
214+ _hairHighlightColorSelection = 0 ;
215+ _eyeColorSelection = 0 ;
191216
192- for ( int i = 0 ; i < 12 ; i ++ )
217+ for ( int i = 0 ; i < 12 ; i ++ )
218+ {
219+ appearanceValues [ i ] = new Tuple < int , int , float > ( 0 , 0 , 0f ) ;
220+ }
221+ }
222+ else
193223 {
194- appearanceValues [ i ] = new Tuple < int , int , float > ( 0 , 0 , 0f ) ;
224+ PedAppearance appearanceData = currentCharacter . PedAppearance ;
225+
226+ _hairSelection = appearanceData . hairStyle ;
227+ _hairColorSelection = appearanceData . hairColor ;
228+ _hairHighlightColorSelection = appearanceData . hairHighlightColor ;
229+
230+ appearanceValues [ 0 ] = new ( appearanceData . blemishesStyle , 0 , appearanceData . blemishesOpacity ) ;
231+ appearanceValues [ 1 ] = new ( appearanceData . beardStyle , appearanceData . beardColor , appearanceData . beardOpacity ) ;
232+ appearanceValues [ 2 ] = new ( appearanceData . eyebrowsStyle , appearanceData . eyebrowsColor , appearanceData . eyebrowsOpacity ) ;
233+ appearanceValues [ 3 ] = new ( appearanceData . ageingStyle , 0 , appearanceData . ageingOpacity ) ;
234+ appearanceValues [ 4 ] = new ( appearanceData . makeupStyle , appearanceData . makeupColor , appearanceData . makeupOpacity ) ;
235+ appearanceValues [ 5 ] = new ( appearanceData . blushStyle , appearanceData . blushColor , appearanceData . blushOpacity ) ;
236+ appearanceValues [ 6 ] = new ( appearanceData . complexionStyle , 0 , appearanceData . complexionOpacity ) ;
237+ appearanceValues [ 7 ] = new ( appearanceData . sunDamageStyle , 0 , appearanceData . sunDamageOpacity ) ;
238+ appearanceValues [ 8 ] = new ( appearanceData . lipstickStyle , appearanceData . lipstickColor , appearanceData . lipstickOpacity ) ;
239+ appearanceValues [ 9 ] = new ( appearanceData . molesFrecklesStyle , 0 , appearanceData . molesFrecklesOpacity ) ;
240+ appearanceValues [ 10 ] = new ( appearanceData . chestHairStyle , appearanceData . chestHairColor , appearanceData . chestHairOpacity ) ;
241+ appearanceValues [ 11 ] = new ( appearanceData . bodyBlemishesStyle , 0 , appearanceData . bodyBlemishesOpacity ) ;
242+
243+ _eyeColorSelection = appearanceData . eyeColor ;
195244 }
196245
197246 var opacity = new List < string > ( ) { "0%" , "10%" , "20%" , "30%" , "40%" , "50%" , "60%" , "70%" , "80%" , "90%" , "100%" } ;
@@ -719,8 +768,19 @@ private void MakeCreateCharacterMenu(bool male, bool editPed = false)
719768 List < MenuItem . Icon > categoryIcons = GetCategoryIcons ( categoryNames ) ;
720769
721770 categoryBtn . ItemData = new Tuple < List < string > , List < MenuItem . Icon > > ( categoryNames , categoryIcons ) ;
722- categoryBtn . ListItems = categoryNames ;
723- categoryBtn . ListIndex = 0 ;
771+ categoryBtn . ListItems = categoryNames ;
772+
773+ if ( editPed )
774+ {
775+ int characterCategoryIndex = categoryNames . IndexOf ( currentCharacter . Category ) ;
776+
777+ categoryBtn . ListIndex = characterCategoryIndex ;
778+ }
779+ else
780+ {
781+ categoryBtn . ListIndex = 0 ;
782+ }
783+
724784 categoryBtn . RightIcon = categoryIcons [ categoryBtn . ListIndex ] ;
725785
726786 createCharacterMenu . RefreshIndex ( ) ;
@@ -2016,57 +2076,55 @@ void ApplySavedTattoos()
20162076 }
20172077 else if ( item == appearanceButton )
20182078 {
2019- List < MenuItem > items = appearanceMenu . GetMenuItems ( ) ;
2079+ List < MenuListItem > menuListItems = [ .. appearanceMenu . GetMenuItems ( ) . OfType < MenuListItem > ( ) ] ;
2080+
2081+ menuListItems . First ( i => i . Text == "Hair Style" ) . ListIndex = _hairSelection ;
2082+ menuListItems . First ( i => i . Text == "Hair Color" ) . ListIndex = _hairColorSelection ;
2083+ menuListItems . First ( i => i . Text == "Hair Highlight Color" ) . ListIndex = _hairHighlightColorSelection ;
20202084
2021- // Chris: This is so, so terrible... (and I wrote it)
2022- // This needs to be re-done at some point.
2023- // TODO: Make not trash
2024- ( ( MenuListItem ) items [ 0 ] ) . ListIndex = _hairSelection ;
2025- ( ( MenuListItem ) items [ 1 ] ) . ListIndex = _hairColorSelection ;
2026- ( ( MenuListItem ) items [ 2 ] ) . ListIndex = _hairHighlightColorSelection ;
2027- ( ( MenuListItem ) items [ 33 ] ) . ListIndex = _eyeColorSelection ;
2085+ menuListItems . First ( i => i . Text == "Blemishes Style" ) . ListIndex = appearanceValues [ 0 ] . Item1 ;
2086+ menuListItems . First ( i => i . Text == "Blemishes Opacity" ) . ListIndex = ( int ) ( appearanceValues [ 0 ] . Item3 * 10 ) ;
20282087
2029- ( ( MenuListItem ) items [ 3 ] ) . ListIndex = appearanceValues [ 0 ] . Item1 ;
2030- ( ( MenuListItem ) items [ 4 ] ) . ListIndex = ( int ) ( appearanceValues [ 0 ] . Item3 * 10 ) ;
2088+ menuListItems . First ( i => i . Text == "Beard Style" ) . ListIndex = appearanceValues [ 1 ] . Item1 ;
2089+ menuListItems . First ( i => i . Text == "Beard Opacity" ) . ListIndex = ( int ) ( appearanceValues [ 1 ] . Item3 * 10 ) ;
2090+ menuListItems . First ( i => i . Text == "Beard Color" ) . ListIndex = appearanceValues [ 1 ] . Item2 ;
20312091
2032- ( ( MenuListItem ) items [ 5 ] ) . ListIndex = appearanceValues [ 1 ] . Item1 ;
2033- ( ( MenuListItem ) items [ 6 ] ) . ListIndex = ( int ) ( appearanceValues [ 1 ] . Item3 * 10 ) ;
2034- ( ( MenuListItem ) items [ 7 ] ) . ListIndex = appearanceValues [ 1 ] . Item1 ;
2092+ menuListItems . First ( i => i . Text == "Eyebrows Style" ) . ListIndex = appearanceValues [ 2 ] . Item1 ;
2093+ menuListItems . First ( i => i . Text == "Eyebrows Opacity" ) . ListIndex = ( int ) ( appearanceValues [ 2 ] . Item3 * 10 ) ;
2094+ menuListItems . First ( i => i . Text == "Eyebrows Color" ) . ListIndex = appearanceValues [ 2 ] . Item2 ;
20352095
2036- ( ( MenuListItem ) items [ 8 ] ) . ListIndex = appearanceValues [ 2 ] . Item1 ;
2037- ( ( MenuListItem ) items [ 9 ] ) . ListIndex = ( int ) ( appearanceValues [ 2 ] . Item3 * 10 ) ;
2038- ( ( MenuListItem ) items [ 10 ] ) . ListIndex = appearanceValues [ 2 ] . Item1 ;
2096+ menuListItems . First ( i => i . Text == "Ageing Style" ) . ListIndex = appearanceValues [ 3 ] . Item1 ;
2097+ menuListItems . First ( i => i . Text == "Ageing Opacity" ) . ListIndex = ( int ) ( appearanceValues [ 3 ] . Item3 * 10 ) ;
20392098
2040- ( ( MenuListItem ) items [ 11 ] ) . ListIndex = appearanceValues [ 3 ] . Item1 ;
2041- ( ( MenuListItem ) items [ 12 ] ) . ListIndex = ( int ) ( appearanceValues [ 3 ] . Item3 * 10 ) ;
2099+ menuListItems . First ( i => i . Text == "Makeup Style" ) . ListIndex = appearanceValues [ 4 ] . Item1 ;
2100+ menuListItems . First ( i => i . Text == "Makeup Opacity" ) . ListIndex = ( int ) ( appearanceValues [ 4 ] . Item3 * 10 ) ;
2101+ menuListItems . First ( i => i . Text == "Makeup Color" ) . ListIndex = appearanceValues [ 4 ] . Item2 ;
20422102
2043- ( ( MenuListItem ) items [ 13 ] ) . ListIndex = appearanceValues [ 4 ] . Item1 ;
2044- ( ( MenuListItem ) items [ 14 ] ) . ListIndex = ( int ) ( appearanceValues [ 4 ] . Item3 * 10 ) ;
2045- ( ( MenuListItem ) items [ 15 ] ) . ListIndex = appearanceValues [ 4 ] . Item1 ;
2103+ menuListItems . First ( i => i . Text == "Blush Style" ) . ListIndex = appearanceValues [ 5 ] . Item1 ;
2104+ menuListItems . First ( i => i . Text == "Blush Opacity" ) . ListIndex = ( int ) ( appearanceValues [ 5 ] . Item3 * 10 ) ;
2105+ menuListItems . First ( i => i . Text == "Blush Color" ) . ListIndex = appearanceValues [ 5 ] . Item2 ;
20462106
2047- ( ( MenuListItem ) items [ 16 ] ) . ListIndex = appearanceValues [ 5 ] . Item1 ;
2048- ( ( MenuListItem ) items [ 17 ] ) . ListIndex = ( int ) ( appearanceValues [ 5 ] . Item3 * 10 ) ;
2049- ( ( MenuListItem ) items [ 18 ] ) . ListIndex = appearanceValues [ 5 ] . Item1 ;
2107+ menuListItems . First ( i => i . Text == "Complexion Style" ) . ListIndex = appearanceValues [ 6 ] . Item1 ;
2108+ menuListItems . First ( i => i . Text == "Complexion Opacity" ) . ListIndex = ( int ) ( appearanceValues [ 6 ] . Item3 * 10 ) ;
20502109
2051- ( ( MenuListItem ) items [ 19 ] ) . ListIndex = appearanceValues [ 6 ] . Item1 ;
2052- ( ( MenuListItem ) items [ 20 ] ) . ListIndex = ( int ) ( appearanceValues [ 6 ] . Item3 * 10 ) ;
2110+ menuListItems . First ( i => i . Text == "Sun Damage Style" ) . ListIndex = appearanceValues [ 7 ] . Item1 ;
2111+ menuListItems . First ( i => i . Text == "Sun Damage Opacity" ) . ListIndex = ( int ) ( appearanceValues [ 7 ] . Item3 * 10 ) ;
20532112
2054- ( ( MenuListItem ) items [ 21 ] ) . ListIndex = appearanceValues [ 7 ] . Item1 ;
2055- ( ( MenuListItem ) items [ 22 ] ) . ListIndex = ( int ) ( appearanceValues [ 7 ] . Item3 * 10 ) ;
2113+ menuListItems . First ( i => i . Text == "Lipstick Style" ) . ListIndex = appearanceValues [ 8 ] . Item1 ;
2114+ menuListItems . First ( i => i . Text == "Lipstick Opacity" ) . ListIndex = ( int ) ( appearanceValues [ 8 ] . Item3 * 10 ) ;
2115+ menuListItems . First ( i => i . Text == "Lipstick Color" ) . ListIndex = appearanceValues [ 8 ] . Item2 ;
20562116
2057- ( ( MenuListItem ) items [ 23 ] ) . ListIndex = appearanceValues [ 8 ] . Item1 ;
2058- ( ( MenuListItem ) items [ 24 ] ) . ListIndex = ( int ) ( appearanceValues [ 8 ] . Item3 * 10 ) ;
2059- ( ( MenuListItem ) items [ 25 ] ) . ListIndex = appearanceValues [ 8 ] . Item1 ;
2117+ menuListItems . First ( i => i . Text == "Moles and Freckles Style" ) . ListIndex = appearanceValues [ 9 ] . Item1 ;
2118+ menuListItems . First ( i => i . Text == "Moles and Freckles Opacity" ) . ListIndex = ( int ) ( appearanceValues [ 9 ] . Item3 * 10 ) ;
20602119
2061- ( ( MenuListItem ) items [ 26 ] ) . ListIndex = appearanceValues [ 9 ] . Item1 ;
2062- ( ( MenuListItem ) items [ 27 ] ) . ListIndex = ( int ) ( appearanceValues [ 9 ] . Item3 * 10 ) ;
2120+ menuListItems . First ( i => i . Text == "Chest Hair Style" ) . ListIndex = appearanceValues [ 10 ] . Item1 ;
2121+ menuListItems . First ( i => i . Text == "Chest Hair Opacity" ) . ListIndex = ( int ) ( appearanceValues [ 10 ] . Item3 * 10 ) ;
2122+ menuListItems . First ( i => i . Text == "Chest Hair Color" ) . ListIndex = appearanceValues [ 10 ] . Item2 ;
20632123
2064- ( ( MenuListItem ) items [ 28 ] ) . ListIndex = appearanceValues [ 10 ] . Item1 ;
2065- ( ( MenuListItem ) items [ 29 ] ) . ListIndex = ( int ) ( appearanceValues [ 10 ] . Item3 * 10 ) ;
2066- ( ( MenuListItem ) items [ 30 ] ) . ListIndex = appearanceValues [ 10 ] . Item1 ;
2124+ menuListItems . First ( i => i . Text == "Body Blemishes Style" ) . ListIndex = appearanceValues [ 11 ] . Item1 ;
2125+ menuListItems . First ( i => i . Text == "Body Blemishes Opacity" ) . ListIndex = ( int ) ( appearanceValues [ 11 ] . Item3 * 10 ) ;
20672126
2068- ( ( MenuListItem ) items [ 31 ] ) . ListIndex = appearanceValues [ 11 ] . Item1 ;
2069- ( ( MenuListItem ) items [ 32 ] ) . ListIndex = ( int ) ( appearanceValues [ 11 ] . Item3 * 10 ) ;
2127+ menuListItems . First ( i => i . Text == "Eye Colors" ) . ListIndex = _eyeColorSelection ;
20702128
20712129 appearanceMenu . RefreshIndex ( ) ;
20722130
0 commit comments