@@ -97,32 +97,35 @@ def SelectionTracker(replay):
9797 efilter = lambda e : isinstance (e , SelectionEvent ) or isinstance (e , HotkeyEvent )
9898
9999 for person in replay .people :
100- person .selections = GameState (PlayerSelection ())
100+ # TODO: A more robust person interface might be nice
101+ person .selection = GameState (PlayerSelection ())
101102 for event in filter (efilter , person .events ):
102103 if replay .opt .debug :
103104 logger .debug ("Event bytes: " + event .bytes .encode ("hex" ))
104105
105- selections = person .selections [event .frame ]
106+ selection = person .selection [event .frame ]
106107
107108 if isinstance (event , SetToHotkeyEvent ):
108109 # Make a copy to decouple the hotkey from primary selection
109- selections [event .hotkey ] = selections [0x0A ].copy ()
110+ selection [event .hotkey ] = selection [0x0A ].copy ()
110111 logger .info ("[{0}] {1} set hotkey {2} to current selection" .format (Length (seconds = event .second ),person .name ,event .hotkey ))
111112
112113 elif isinstance (event , AddToHotkeyEvent ):
113- selections [event .hotkey ].deselect (* event .deselect )
114- selections [event .hotkey ].select (selections [0x0A ].objects )
114+ selection [event .hotkey ].deselect (* event .deselect )
115+ selection [event .hotkey ].select (selection [0x0A ].objects )
115116 logger .info ("[{0}] {1} added current selection to hotkey {2}" .format (Length (seconds = event .second ),person .name ,event .hotkey ))
116117
117118 elif isinstance (event , GetFromHotkeyEvent ):
118119 # For some reason they leave the hotkey buffer unmodified so make a copy
119- selections [0x0A ] = selections [event .hotkey ].copy ()
120- selections [0x0A ].deselect (* event .deselect )
121- logger .info ("[{0}] {1} retrieved hotkey {2}, {3} units: {4}" .format (Length (seconds = event .second ),person .name ,event .hotkey ,len (selections [0x0A ].objects ),selections [0x0A ]))
120+ selection [0x0A ] = selection [event .hotkey ].copy ()
121+ selection [0x0A ].deselect (* event .deselect )
122+ logger .info ("[{0}] {1} retrieved hotkey {2}, {3} units: {4}" .format (Length (seconds = event .second ),person .name ,event .hotkey ,len (selection [0x0A ].objects ),selection [0x0A ]))
122123
123124 elif isinstance (event , SelectionEvent ):
124- selections [0x0A ].deselect (* event .deselect )
125- selections [0x0A ].select (event .objects )
126- logger .info ("[{0}] {1} selected {2} units: {3}" .format (Length (seconds = event .second ),person .name ,len (selections [0x0A ].objects ),selections [0x0A ]))
125+ selection [0x0A ].deselect (* event .deselect )
126+ selection [0x0A ].select (event .objects )
127+ logger .info ("[{0}] {1} selected {2} units: {3}" .format (Length (seconds = event .second ),person .name ,len (selection [0x0A ].objects ),selection [0x0A ]))
127128
128- event .selected = selections [0x0A ]
129+ # TODO: The event level interface here should be improved
130+ # Possibly use 'added' and 'removed' unit lists as well
131+ event .selected = selection [0x0A ].objects
0 commit comments