@@ -20,6 +20,8 @@ public fTools(BuilderPlug p) {
2020
2121 chkAdjustAngle . Checked = General . Settings . ReadPluginSetting ( "adjangle" , true ) ;
2222 chkAdjustPitch . Checked = General . Settings . ReadPluginSetting ( "adjpitch" , true ) ;
23+ chkUnusedOnly . Checked = General . Settings . ReadPluginSetting ( "unusedonly" , true ) ;
24+
2325 txtUnitTime . Text = General . Settings . ReadPluginSetting ( "adjtics" , 8 ) . ToString ( ) ;
2426 txtUnitLength . Text = General . Settings . ReadPluginSetting ( "adjlen" , 1024 ) . ToString ( ) ;
2527 txtCreateType . Text = General . Settings . ReadPluginSetting ( "thingtype" , 1 ) . ToString ( ) ;
@@ -572,27 +574,75 @@ private void cmdRetag_Click(object sender, EventArgs e) {
572574 return ;
573575 }
574576
577+ if ( ! chkUnusedOnly . Checked && paths . Count > 1 ) {
578+ MessageBox . Show ( "You may only have one path selected for retagging, when opting to clobber tids." ) ;
579+ return ;
580+ }
581+
582+ General . Settings . WritePluginSetting ( "unusedonly" , chkUnusedOnly . Checked ) ;
575583 General . Map . UndoRedo . CreateUndo ( "Retag path" ) ;
576- foreach ( List < PathNode > path in paths ) {
577- //filter interpolation points for faster lookup during path processing
578- List < Thing > ip = new List < Thing > ( ) ;
579- foreach ( Thing t in General . Map . Map . Things ) {
580- if ( t . Type == 9070 )
581- ip . Add ( t ) ;
582- }
583584
585+ //filter interpolation points for faster lookup during path processing
586+ List < Thing > ip = new List < Thing > ( ) ;
587+ List < Thing > ip_specials = new List < Thing > ( ) ;
588+ List < Thing > ip_movers = new List < Thing > ( ) ;
589+ foreach ( Thing t in General . Map . Map . Things ) {
590+ if ( t . Type == 9070 )
591+ ip . Add ( t ) ;
592+ if ( t . Type == 9075 )
593+ ip_specials . Add ( t ) ;
594+ if ( t . Type == 9071 ) //path follower
595+ ip_movers . Add ( t ) ;
596+ if ( t . Type == 9072 ) //moving camera
597+ ip_movers . Add ( t ) ;
598+ if ( t . Type == 9074 ) //actor mover
599+ ip_movers . Add ( t ) ;
600+ }
601+
602+ void doretag ( List < PathNode > path , int tid , bool unusedonly )
603+ {
584604 //Retag each node in the path
585- foreach ( PathNode node in path ) {
605+ int i = tid ;
606+ foreach ( PathNode node in path ) {
586607 int old = node . ID ;
587- newtag = node . ID = GetNextUnusedTag ( newtag ) ;
608+ if ( unusedonly ) {
609+ tid = GetNextUnusedTag ( tid ) ;
610+ } else {
611+ tid = i ;
612+ }
613+ node . ID = tid ;
588614
589615 //if any ip (anywhere) is pointing to this node, then update it
590616 if ( old > 0 ) {
591- foreach ( Thing t in ip ) {
592- if ( t . Args [ 3 ] == old )
593- t . Args [ 3 ] = newtag ;
617+ //Update any ip's pointing to this node
618+ foreach ( Thing t in ip ) {
619+ if ( t . Args [ 3 ] == old ) {
620+ t . Args [ 3 ] = tid ;
621+ }
622+ }
623+
624+ //Update any assigned ip specials
625+ foreach ( Thing t in ip_specials ) {
626+ if ( t . Tag == old ) {
627+ t . Tag = tid ;
628+ }
629+ }
630+
631+ //Update any assigned ip movers
632+ foreach ( Thing t in ip_movers ) {
633+ if ( t . Args [ 0 ] == old ) {
634+ t . Args [ 0 ] = tid ;
635+ }
594636 }
595637 }
638+ i ++ ;
639+ }
640+ }
641+
642+ foreach ( List < PathNode > path in paths ) {
643+ doretag ( path , newtag , true ) ;
644+ if ( ! chkUnusedOnly . Checked ) {
645+ doretag ( path , newtag , false ) ;
596646 }
597647 }
598648
0 commit comments