Controlling message GUI with the hud.plist - How to do it?

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

Moderators: winston, another_commander

Post Reply
User avatar
Dr. Nil
---- E L I T E ----
---- E L I T E ----
Posts: 983
Joined: Thu Sep 28, 2006 5:11 pm
Location: Nearest Hoopy Casino
Contact:

Controlling message GUI with the hud.plist - How to do it?

Post by Dr. Nil »

Does the following in any way mean that there already is a way to make the sticky messages bug less intrusive by moving and resizing the message display with the hud.plist? If yes, does anybody have an idea of what a plist entry for doing that should look like?
- (void) resizeGuis:(NSDictionary*) info
{
// check for entries in hud plist for comm_log_gui and message_gui
// resize and reposition them accordingly

if (!player)
return;
Universe* universe = [player universe];
if (!universe)
return;

GuiDisplayGen* message_gui = [universe message_gui];
if ((message_gui)&&([info objectForKey:@"message_gui"]))
{
NSDictionary* gui_info = (NSDictionary*)[info objectForKey:@"message_gui"];
Vector pos = [message_gui drawPosition];
if ([gui_info objectForKey:X_KEY])
pos.x = [[gui_info objectForKey:X_KEY] floatValue];
if ([gui_info objectForKey:Y_KEY])
pos.y = [[gui_info objectForKey:Y_KEY] floatValue];
[message_gui setDrawPosition:pos];
NSSize siz = [message_gui size];
int rht = [message_gui rowHeight];
NSString* title = [message_gui title];
if ([gui_info objectForKey:WIDTH_KEY])
siz.width = [[gui_info objectForKey:WIDTH_KEY] floatValue];
if ([gui_info objectForKey:HEIGHT_KEY])
siz.height = [[gui_info objectForKey:HEIGHT_KEY] floatValue];
if ([gui_info objectForKey:ROW_HEIGHT_KEY])
rht = [[gui_info objectForKey:ROW_HEIGHT_KEY] intValue];
if ([gui_info objectForKey:TITLE_KEY])
title = [NSString stringWithFormat:@"%@", [gui_info objectForKey:TITLE_KEY]];
[message_gui resizeTo: siz characterHeight: rht Title: title];
if ([gui_info objectForKey:ALPHA_KEY])
[message_gui setAlpha: [[gui_info objectForKey:ALPHA_KEY] floatValue]];
else
[message_gui setAlpha: 1.0];
if ([gui_info objectForKey:BACKGROUND_RGBA_KEY])
[message_gui setBackgroundColor:[OOColor colorFromString:(NSString *)[gui_info objectForKey:BACKGROUND_RGBA_KEY]]];
}
http://svn.berlios.de/viewcvs/oolite-li ... iew=markup
Image

300 billboards in Your Ad Here!
Astromines and more in Commies.
AVAILABLE HERE along with other Oolite eXpansion Packs.
User avatar
Judebert
Dangerous
Dangerous
Posts: 88
Joined: Sat Aug 19, 2006 4:56 pm
Location: Orlando, FL
Contact:

Post by Judebert »

Yes and no. You can access the function, but you can't pass it the parameters it needs.

The only functions available from scripts are those with void or NSString* arguments. I'm not sure about return type; I expect you can use them regardless of return, but void return is probably safer.

For reference, this function would have to look like:

- (void) resizeGuis:(NSString*) info

or

- (void) resizeGuis:() info

to work from a script.
User avatar
Dr. Nil
---- E L I T E ----
---- E L I T E ----
Posts: 983
Joined: Thu Sep 28, 2006 5:11 pm
Location: Nearest Hoopy Casino
Contact:

Post by Dr. Nil »

Judebert wrote:
Yes and no. You can access the function, but you can't pass it the parameters it needs.

The only functions available from scripts are those with void or NSString* arguments. I'm not sure about return type; I expect you can use them regardless of return, but void return is probably safer.

For reference, this function would have to look like:

- (void) resizeGuis:(NSString*) info

or

- (void) resizeGuis:() info

to work from a script.
Thanks. I didn't understand it, though :lol: Complete n00b that I am. But I guess your point is that I can't use a .plist entry to resize or move the on screen messages :?
Image

300 billboards in Your Ad Here!
Astromines and more in Commies.
AVAILABLE HERE along with other Oolite eXpansion Packs.
User avatar
Judebert
Dangerous
Dangerous
Posts: 88
Joined: Sat Aug 19, 2006 4:56 pm
Location: Orlando, FL
Contact:

Post by Judebert »

Well, that's the end result. It looks like you're comfortable with looking in the code, since you found the original function. If you see anything that looks like I mentioned above, you can use it. Otherwise, you can't.
User avatar
Dr. Nil
---- E L I T E ----
---- E L I T E ----
Posts: 983
Joined: Thu Sep 28, 2006 5:11 pm
Location: Nearest Hoopy Casino
Contact:

Post by Dr. Nil »

Judebert wrote:
Well, that's the end result. It looks like you're comfortable with looking in the code, since you found the original function. If you see anything that looks like I mentioned above, you can use it. Otherwise, you can't.
Thanks

I did get a friend to direct me toward the correct folder ('src' - which should tell you something about how illiterate I am in the world of compiled programming :lol:). But I'll look more into it. I guess that if I for look long enough at it, it starts to make sense - that's how it worked out with those mysterious files in the .oxp folders.
Image

300 billboards in Your Ad Here!
Astromines and more in Commies.
AVAILABLE HERE along with other Oolite eXpansion Packs.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

I just came across this while searching for documentation on some hud.plist features unused by the default HUD. The method in question does in fact do what Dr Nil wants. However, it has some side effects: it causes text to disappear after one frame, and the background is always shown (but can be set to fully transparent). Possibly having no messages is better than having sticky messages, so here’s an example (which doesn’t actually move anything and doesn’t define any of the normal HUD stuff like the scanner, so isn’t entirely useful):

Code: Select all

{
    dials =
    (
        {
            selector = "resizeGuis:";
            message_gui =
            {
                x = 0;
                y = -40;
                width = 480;
                height = 160;
                row_height = 20;
                alpha = 1;
                background_rgba = "0 0 0 0";
                title = "Message GUI";    // Doesn't seem to do anything.
            };
            comm_log_gui =
            {
                x = 0;
                y = 180;
                width = 360;
                height = 120;
                row_height = 12;
                alpha = 1;
                background_rgba = "0 13 115 128";
                title = "Comm log GUI";    // Doesn't seem to do anything.
            };
        }
    ); 
}
Post Reply