kosmo111 Posted February 29, 2016 Share Posted February 29, 2016 I have been having an interesting issue (which I have been ignoring) in that my UITacticalHUD Screen Listener seems to get called OnInit for way more Screens than just the TacticalHUD. For now, I have just forced my listener to ignore any screen that isn't UITacticalHUD-- but I would like to know why this is happening. I'm really not doing anything fancy.... here are the relevant parts of the code: class LifetimeStats_ScreenListener extends UIScreenListener config (LifetimeStats); event OnInit(UIScreen Screen) { // The current screen (hopefully) local UITacticalHUD hud; hud = UITacticalHUD(Screen); if( hud == none ) { `log("FOUND WRONG SCREEN: " $ Screen); return; } ... } ... defaultproperties { ScreenClass = UITacticalHUD; } This same layout is working fine for a few other listeners that I have set up-- it seems to be an issue with the tactical hud specifically. Anyone have any thoughts/have noticed this already? Link to comment Share on other sites More sharing options...
Amineri Posted February 29, 2016 Share Posted February 29, 2016 I hadn't noticed this, and the OfficerPack has a UITacticalHUD screen listener. Which other UIScreens have you noticed getting picked up by it? Link to comment Share on other sites More sharing options...
davidlallen Posted February 29, 2016 Share Posted February 29, 2016 (edited) I do not have a complete understanding of screen listeners. But, you are overriding the base UIScreenListener class. Won't this be called for all screens by definition? Did you mean to override a subclass of this class? Edit: OK, I missed the defaultproperties; but wouldn't you be better off overriding the subclass instead of the main class? Edited February 29, 2016 by davidlallen Link to comment Share on other sites More sharing options...
kosmo111 Posted February 29, 2016 Author Share Posted February 29, 2016 @Amineri Poor timing on my part, I posted this during my lunch break but I do not have access to the logs at the moment. I know that the screen gets semi-flooded when the game first boots up with `log("FOUND WRONG SCREEN: " $ Screen); prints. I'm also fairly confident that many of the popup dialogs (such as hitting escape) cause the OnInit to fire as well. I will post back here tonight with more specific logs. @davidlallen I am not really sure what you are asking. As far as I am aware UIScreenListener is the base class? Also just to try to avoid confusion-- I am extending the UIScreenListener class but not doing any overrides-- I am not replacing the UIScreenListener class with respect to XCom, merely adding a new one. Link to comment Share on other sites More sharing options...
davidlallen Posted February 29, 2016 Share Posted February 29, 2016 Partly terminology override vs extend. Isn't there a more specific subclass UIScreenListener_TacticalHUD or similar, which you could extend? I am also away from my game computer. Link to comment Share on other sites More sharing options...
kosmo111 Posted February 29, 2016 Author Share Posted February 29, 2016 Right OK sorry, I figured that's what you meant just wanted to make sure. Anyway, to my knowledge there are not specific ScreenListeners-- at least there do not appear to be any in the core files anywhere. The documentation just says to extend UIScreenListener and set the defaultproperties properly. Link to comment Share on other sites More sharing options...
davidlallen Posted February 29, 2016 Share Posted February 29, 2016 OK, I looked in one file I could find easily, which listens to the proving ground screen. It operates just like yours. Is there a way to get the text name of a screen? If so, you could add that to your log statement, and see what other screens are causing it to fire. Is the uc source code of ScreenListener available to look at? Maybe it is trying to do some fancy operation using ScreenClass, and it isn't working properly. Link to comment Share on other sites More sharing options...
CaveRat Posted February 29, 2016 Share Posted February 29, 2016 Interesting. Personally, I can't reproduce this. Tried with two dummy mods and two screenlisteners, both set to UITacticalHUD. Working as expected, so I am kinda curious what's causing this issue on your end. Link to comment Share on other sites More sharing options...
kosmo111 Posted February 29, 2016 Author Share Posted February 29, 2016 I'll be home soon where I can be a bit more descriptive about whats happening. The only other thing I can think of is that unlike what I posted above (I'm fairly confident this is the only difference from my actual code) is that my defaultproperty braces are not on new lines. defaultproperties { ScreenClass = UITacticalHUD; } I'm just so accustomed to having braces on the same line that I have been having trouble breaking them. I suppose depending on what exactly defaultproperties is, that could be part of the problem. Link to comment Share on other sites More sharing options...
davidlallen Posted February 29, 2016 Share Posted February 29, 2016 I hope this is not some white-space-dependent language like python. Link to comment Share on other sites More sharing options...
Recommended Posts