UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Miscellaneous Recipes


238

TutorialHUD(H).DrawDebugText(index_array$":
"@command.CommandName,vect2d(0,YPos),
H.Canvas.Font,cmnd_color);

// Draws next line beneath current one
YPos += YL;
}
}
}
}

We start by setting our font to be drawn in the top-left corner, as indicated by the
coordinates 0,0. From there we use an if-else statement to make our currently
highlighted text stand out by coloring it red and all other text white. We also draw a
transparent gray rectangle across the entire screen.
How do we get one line to display beneath the other? Well the line YPos += YL;
represents the Y position for our text, and we set it to be its current position plus
the float YL.
We're also calling our HUD class and telling it to draw the DrawDebugText()
function, which we'll cover shortly.


  1. The final thing we need to do in this class is set the default properties of
    our variables:
    DefaultProperties
    {
    bShowDebugMenu=false
    CurrentPage=-1 // Starts us on the first page
    CurrentIndex=0


/** Look in UDKInput.Ini to find additional debug
commands to add to this list */
CommandDebugPages(0)=(PageName="Debug
Info",PageCommands[0]=(CommandName="Turn off Debug
Info",Command="showdebug none"),
PageCommands[1]=(CommandName="Toggle Camera Debug
Info",Command="showdebug camera"),
PageCommands[2]=(CommandName="Toggle Pawn Debug
Info",Command="showdebug pawn"),
PageCommands[3]=(CommandName="Toggle Pawn Weapon
Info",Command="showdebug weapon"))

CommandDebugPages(1)=(PageName="HUD",PageCommands[0]=
(CommandName="Toggle HUD",Command="ToggleHUD"))
Free download pdf