@@ -47,7 +47,7 @@ internal class SystemMapRendering : UpdateWindowState
4747 //internal SystemMap_DrawableVM SysMap;
4848 Entity ? _faction ;
4949
50- bool _panned = false ;
50+ bool _updateLabels = false ;
5151
5252 internal SystemMapRendering ( SDL3Window window , GlobalUIState state )
5353 {
@@ -172,7 +172,11 @@ internal SystemMapRendering(SDL3Window window, GlobalUIState state)
172172 }
173173 } ;
174174
175- _camera . PanOccured += ( object sender , Orbital . Vector3 pos ) => _panned = true ;
175+ _camera . PanOccured +=
176+ ( object sender , Orbital . Vector3 pos ) => _updateLabels = true ;
177+
178+ SystemViewPreferences . GetInstance ( ) . ViewUpdateOccured +=
179+ ( object sender , SystemViewPreferences . View view ) => _updateLabels = true ;
176180
177181 // should be empty
178182 _interactableGrouped = _interactable
@@ -210,7 +214,7 @@ internal void Initialize(StarSystem starSys)
210214 AddIconable ( entityItem ) ;
211215 }
212216
213- _panned = true ; // run HandlePan on first frame
217+ _updateLabels = true ; // update labels on first frame
214218 }
215219
216220 public void UpdateSystemState ( SystemState systemState )
@@ -511,18 +515,23 @@ internal void Update()
511515 foreach ( var item in _allLabels )
512516 item . OnFrameUpdate ( matrix , _camera ) ;
513517
514- if ( _panned )
518+ if ( _updateLabels )
515519 {
516- _panned = false ;
520+ _updateLabels = false ;
521+
522+ var prefs = SystemViewPreferences . GetInstance ( ) ;
517523
518524 foreach ( var item in _interactable . Values )
519525 {
520526 foreach ( var i in item )
521527 i . IsDisabled = true ;
522528 }
523529
530+ var lbl = _allLabels
531+ . Where ( x => prefs . ShouldDisplay ( "map" , Utils . EntityBodyType ( x . Entity ) ) ) ;
532+
524533 _visibleLabels . Clear ( ) ;
525- foreach ( var i in _distributor ( _allLabels ) )
534+ foreach ( var i in _distributor ( lbl ) )
526535 {
527536 foreach ( var j in _interactable [ i . Entity . Id ] )
528537 j . IsDisabled = false ;
@@ -539,46 +548,18 @@ internal void Update()
539548
540549 internal void Draw ( )
541550 {
542- DrawIcons ( UIWidgets . Values . ToList ( ) ) ;
543- DrawFilteredIcons ( _orbitRings ) ;
544- DrawFilteredIcons ( _moveIcons ) ;
545- DrawFilteredIcons ( _entityIcons ) ;
546- DrawFilteredIcons ( _bodyIcons ) ;
551+ DrawIcons ( UIWidgets . Values ) ;
552+ DrawIcons ( _orbitRings . Values ) ;
553+ DrawIcons ( _moveIcons . Values ) ;
554+ DrawIcons ( _entityIcons . Values ) ;
555+ DrawIcons ( _bodyIcons . Values ) ;
547556 DrawIcons ( SelectedEntityExtras ) ;
548557
549- var prefs = SystemViewPreferences . GetInstance ( ) ;
550-
551558 foreach ( var i in _visibleLabels )
552- {
553- var type = Utils . EntityBodyType ( i . Entity ) ;
554- if ( ! prefs . ShouldDisplay ( "map" , type ) )
555- continue ;
556-
557559 i . Draw ( _window . Renderer , _camera ) ;
558- }
559- }
560-
561- void DrawFilteredIcons ( ConcurrentDictionary < int , Icon > icons )
562- {
563- if ( _sysState == null )
564- {
565- foreach ( var item in icons . Values )
566- item . Draw ( _window . Renderer , _camera ) ;
567- return ;
568- }
569-
570- var prefs = SystemViewPreferences . GetInstance ( ) ;
571- foreach ( var ( entityId , item ) in icons )
572- {
573- if ( _sysState . EntityStatesWithPosition . TryGetValue ( entityId , out var entityState )
574- && ! prefs . ShouldDisplay ( "map" , entityState . BodyType ) )
575- continue ;
576-
577- item . Draw ( _window . Renderer , _camera ) ;
578- }
579560 }
580561
581- void DrawIcons ( List < IDrawData > icons )
562+ void DrawIcons ( IEnumerable < IDrawData > icons )
582563 {
583564 foreach ( var item in icons )
584565 item . Draw ( _window . Renderer , _camera ) ;
0 commit comments