Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Text Output in HUD

Page: 1 of 1
 mad mapper
11-18-2004, 8:25 AM
#1
Hello,

i added a PERSISTANT variable.
The Scores are shown in MP in the lower right like that:
"Scores: 15"

I want to show the Variable I added in the lower left, so I edited the hud.menu in the ui Folder:


menuDef
{
name "lefthud"
fullScreen 0 // MENU_FALSE
rect 0 368 112 112 // Size and position of the menu
visible 1 // Visible on open


// Tells current credits of game********************************************** *******
itemDef
{
name credit_line
forecolor 1 1 1 1
rect 20 20 6 12 // (these positions are relative to the initial position of the menu)
// X pos, Y pos, char size, char height
}
[...]


Afterwards I added this code to CG_DrawHud

const char *creditStr = NULL;
creditStr = va("Credits: %i", cg.snap->ps.persistant[PERS_CREDITS]);
focusItem = Menu_FindItemByName(menuHUD, "credit_line");
if (focusItem)
{
UI_DrawScaledProportionalString(
focusItem->window.rect.x,
focusItem->window.rect.y,
creditStr,
UI_RIGHT|UI_DROPSHADOW,
focusItem->window.foreColor,
0.7);
}


It doesn't work. But if I type this:

char *creditStr = "Credits: ";

It works. I really don't know why.
 razorace
11-18-2004, 8:50 AM
#2
The problem is definately with how you implimented persistant[PERS_CREDITS]);. You're going to have to detail what you did.
 mad mapper
11-18-2004, 9:26 AM
#3
I think the bug is there because of the Output function because when I try this code

creditStr = va("%s: %i", "Credits", 0);
focusItem = Menu_FindItemByName(menuHUD, "credit_line");
if (focusItem)
{
UI_DrawScaledProportionalString(
focusItem->window.rect.x,
focusItem->window.rect.y,
creditStr,
UI_RIGHT|UI_DROPSHADOW,
focusItem->window.foreColor,
0.7);
}


nothing happens as well
 razorace
11-18-2004, 10:13 AM
#4
hmmm. Well, my guess is that va doesn't like it when you use unnessisary alases for testing like that. You got a debugger?
 mad mapper
11-19-2004, 9:33 AM
#5
Sorry, alases???
Don't know what that is
 razorace
11-19-2004, 10:45 AM
#6
Err, I've never seen va used with static varibles for input like that.
 mad mapper
11-20-2004, 1:20 AM
#7
Well,
const char *creditStr is no static variable but a pointer.

Look into the source of CG_DrawMenu. They use const char *scoreStr = va (...)
to print the scores into an AnsiString

Afterwards the output is made with CG_DrawProportionalString (...)
 razorace
11-20-2004, 7:35 AM
#8
Yeah, but you're using two constant values for inputs onto the va. I beleive the easiest way to check this is to see what's in creditStr before the UI_DrawScaledProportionalString is called.
Page: 1 of 1