@@ -72,6 +72,7 @@ private void LoadEntity(bool sameEntity)
7272 EntityScaleXYTextBox . Text = string . Empty ;
7373 EntityScaleZTextBox . Text = string . Empty ;
7474 EntityParentIndexTextBox . Text = string . Empty ;
75+ parentEntityTextBox . Text = string . Empty ;
7576 EntityLodDistTextBox . Text = string . Empty ;
7677 EntityChildLodDistTextBox . Text = string . Empty ;
7778 EntityLodLevelComboBox . SelectedIndex = 0 ; // Math.Max(EntityLodLevelComboBox.FindString(), 0);
@@ -107,6 +108,7 @@ private void LoadEntity(bool sameEntity)
107108 EntityScaleXYTextBox . Text = FloatUtil . ToString ( e . scaleXY ) ;
108109 EntityScaleZTextBox . Text = FloatUtil . ToString ( e . scaleZ ) ;
109110 EntityParentIndexTextBox . Text = e . parentIndex . ToString ( ) ;
111+ parentEntityTextBox . Text = CurrentEntity . Parent ? . Name ?? string . Empty ;
110112 EntityLodDistTextBox . Text = FloatUtil . ToString ( e . lodDist ) ;
111113 EntityChildLodDistTextBox . Text = FloatUtil . ToString ( e . childLodDist ) ;
112114 EntityLodLevelComboBox . SelectedIndex = Math . Max ( EntityLodLevelComboBox . FindString ( e . lodLevel . ToString ( ) ) , 0 ) ;
@@ -152,7 +154,7 @@ private void LoadEntity(bool sameEntity)
152154 MiloFlagsTextBox . Text = string . Empty ;
153155 }
154156
155-
157+ SetupParentEntityAutoComplete ( ) ;
156158 populatingui = false ;
157159
158160
@@ -474,15 +476,30 @@ private void EntityParentIndexTextBox_TextChanged(object sender, EventArgs e)
474476 {
475477 if ( populatingui ) return ;
476478 if ( CurrentEntity == null ) return ;
479+
477480 int pind = 0 ;
478481 int . TryParse ( EntityParentIndexTextBox . Text , out pind ) ;
482+
479483 lock ( ProjectForm . ProjectSyncRoot )
480484 {
481485 if ( CurrentEntity . _CEntityDef . parentIndex != pind )
482486 {
483- CurrentEntity . _CEntityDef . parentIndex = pind ; //Needs more work for LOD linking!
487+ CurrentEntity . _CEntityDef . parentIndex = pind ;
488+
484489 if ( CurrentMCEntity != null )
485490 CurrentMCEntity . _Data . parentIndex = pind ;
491+
492+ string parentName = string . Empty ;
493+ var parentEntities = CurrentEntity . Ymap . Parent . AllEntities ;
494+ if ( parentEntities != null && pind >= 0 && pind < parentEntities . Length )
495+ {
496+ parentName = parentEntities [ pind ] ? . Name ?? string . Empty ;
497+ }
498+
499+ populatingui = true ;
500+ parentEntityTextBox . Text = parentName ;
501+ populatingui = false ;
502+
486503 ProjectItemChanged ( ) ;
487504 }
488505 }
@@ -795,5 +812,60 @@ private void EntityEditArchetypeButton_Click(object sender, EventArgs e)
795812 }
796813 }
797814
815+ private void parentEntityTextBox_TextChanged ( object sender , EventArgs e )
816+ {
817+ if ( populatingui ) return ;
818+ if ( CurrentEntity == null ) return ;
819+
820+ string parentName = parentEntityTextBox . Text ? . Trim ( ) ;
821+ if ( string . IsNullOrEmpty ( parentName ) ) return ;
822+
823+ var parentEntities = CurrentEntity . Ymap . Parent . AllEntities ;
824+ int newIndex = - 1 ;
825+
826+ for ( int i = 0 ; i < parentEntities . Length ; i ++ )
827+ {
828+ if ( parentEntities [ i ] ? . Name == parentName )
829+ {
830+ newIndex = i ;
831+ break ;
832+ }
833+ }
834+
835+ if ( newIndex >= 0 && CurrentEntity . _CEntityDef . parentIndex != newIndex )
836+ {
837+ lock ( ProjectForm . ProjectSyncRoot )
838+ {
839+ CurrentEntity . _CEntityDef . parentIndex = newIndex ;
840+
841+ if ( CurrentMCEntity != null )
842+ CurrentMCEntity . _Data . parentIndex = newIndex ;
843+
844+ populatingui = true ;
845+ EntityParentIndexTextBox . Text = newIndex . ToString ( ) ;
846+ populatingui = false ;
847+
848+ ProjectItemChanged ( ) ;
849+ }
850+ }
851+ }
852+ private void SetupParentEntityAutoComplete ( )
853+ {
854+ if ( CurrentEntity ? . Ymap ? . Parent ? . AllEntities == null ) return ;
855+
856+ var autoComplete = new AutoCompleteStringCollection ( ) ;
857+
858+ foreach ( var entity in CurrentEntity . Ymap . Parent . AllEntities )
859+ {
860+ if ( ! string . IsNullOrEmpty ( entity ? . Name ) )
861+ {
862+ autoComplete . Add ( entity . Name ) ;
863+ }
864+ }
865+
866+ parentEntityTextBox . AutoCompleteMode = AutoCompleteMode . SuggestAppend ;
867+ parentEntityTextBox . AutoCompleteSource = AutoCompleteSource . CustomSource ;
868+ parentEntityTextBox . AutoCompleteCustomSource = autoComplete ;
869+ }
798870 }
799871}
0 commit comments