Jump to content

UITacticalHud Screen Listener not respecting ScreenClass


kosmo111

Recommended Posts

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

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 by davidlallen
Link to comment
Share on other sites

@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

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

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...