Adding text to screen

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Adding text to screen

Post 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.
User avatar
Wildeblood
---- E L I T E ----
---- E L I T E ----
Posts: 2453
Joined: Sat Jun 11, 2011 6:07 am
Location: Western Australia
Contact:

Re: Adding text to screen

Post 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?
In your heart, you know it's flat.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Adding text to screen

Post 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.
Post Reply