Page 1 of 1

Adding text to screen

Posted: Tue Oct 13, 2015 4:29 am
by phkb
According to the wiki, I can add some message text to a screen by doing something like this:

Code: Select all

this.guiScreenChanged = function(to, from) {
	if (to == "GUI_SCREEN_SYSTEM_DATA") {
		mission.addMessageText("Testing adding text to screen");
	}
}
This works fine, and I get this no matter how many times I press F7 and visit the system info page:

Image

But! If I change my code to this:

Code: Select all

this.guiScreenChanged = function(to, from) {
	if (to == "GUI_SCREEN_EQUIP_SHIP") {
		mission.addMessageText("Testing adding text to screen");
	}
}
and then repeatedly visit the F3 equip screen, I see this:

Image

Notice how the text I added slowly moves down the page.

So my question is, is it possible to add text to the top of the F3 equip screen so it stays in one place? I know I could do a test and only let the code run once, but if the text I wanted to add is dynamic, I might need to update it on each refresh of the page.

Re: Adding text to screen

Posted: Tue Oct 13, 2015 3:27 pm
by Wildeblood
You're going to have to code to only add it once. What's happening, I would guess, is that it's being added every time and then the core code that suppresses the display of duplicate messages is blanking the previous lines; that's why it's appearing to "move" down the screen.

I done never saw anyone use that function on screens other than system data or manifest, though. (Why do you have to meddle with obscure parts of Oolite?) It works properly on those screens because they're compiled anew each time you view them, in case the target system or manifest has changed, I guess.

So I'm curious now, did you try it on the other screens too?

Re: Adding text to screen

Posted: Tue Oct 13, 2015 10:39 pm
by phkb
Wildeblood wrote:
Why do you have to meddle with obscure parts of Oolite?
But I enjoy it so much! Plus I'm working on a hush-hush super-super secret project that will change the course of history, and alter the very fabric of the cosmos! Yes, mountains will fall, kingdoms will rise, all through the power of the OXP! Oh, can you feel it? CAN YOU FEEL IT?

Ooookay, time to adjust my meds....
Wildeblood wrote:
So I'm curious now, did you try it on the other screens too?
Not yet. I'll give it a try though and report back.