Results 1 to 20 of 20

Thread: Canvas drawing

  1. #1

    Default Canvas drawing

    Code:
    Canvas.DrawText(UTWeapon(PawnOwner.Weapon).MaxAmmoCount);
    For some reason this is only out putting the current AmmoCount.
    Even though I use the same call a couple of lines after:
    Code:
    DrawAmmoBar("",UTWeapon(PawnOwner.Weapon).AmmoCount, UTWeapon(PawnOwner.Weapon).MaxAmmoCount ,10,34,80,80,200);

    I was also wondering how can i print out two text pieces but on the same line?
    I am looking to have a standard "currentAmmo/MaxAmmo" (ie 4/20).

  2. #2
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Location
    Ukraine
    Posts
    137

    Default

    Quote Originally Posted by axelzellalex View Post
    I was also wondering how can i print out two text pieces but on the same line?
    I am looking to have a standard "currentAmmo/MaxAmmo" (ie 4/20).
    If I right understand you looking for this:

    Code:
    Canvas.DrawText("Ammo: "@CurrentAmmoCountVariable@" / "@MaxAmmoCountVariable);

  3. #3

    Default

    where '@curreammocountvariable@' is the name of my variable yes?

  4. #4
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Location
    Ukraine
    Posts
    137

    Default

    curreammocountvariable - name of your variable
    @ - is string continuation symbol

  5. #5
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Location
    Ukraine
    Posts
    137

    Default

    "Ammo: "@CurrentAmmoCountVariable@" / "@MaxAmmoCountVariable - this means:
    "Ammo: "+CurrentAmmoCountVariable+" / "+MaxAmmoCountVariable

    and this print to screen:

    Ammo: 32 / 50

  6. #6

    Default

    Code:
       {
    		MaxAmmoCount = MaxAmmoCount;
    		MaxAmount = ""$MaxAmmoCount;
        AmmoCount = Weapon.GetAmmoCount();
        lastweapon = weapon;
        lastammocount = ammocount;
        Amount = ""$AmmoCount;
        
        Canvas.DrawColor = WhiteColor;
        Canvas.DrawText(Amount);
        Canvas.DrawText(MaxAmount);
    		}
    thats my inital Ammo stuff, so i use the drawtext func:
    Code:
    Canvas.DrawText("Ammo: "@Amount " / " @MaxAmount);

  7. #7
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Location
    Ukraine
    Posts
    137

    Default

    Change to this:
    Code:
    Canvas.DrawText("Ammo: "@Amount@" / "@MaxAmount);

  8. #8

    Default

    Code:
    bad or missing expression after "@" : "Amount"

  9. #9
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Location
    Ukraine
    Posts
    137

    Default

    what type Amount is?

  10. #10

    Default

    Code:
    class MyHud extends UTHUD;
    
    var font MyFont;
    var	const Texture2D WeapIcon;
    var material	HudIconBg;
    var material BulletIcon;
    
    var UTWeapon LastWeapon;
    
    
    function DrawHealthBar(String Title, float Value, float MaxValue,int X, int Y, int R, int G, int B)
    {
    
        local int PosX,NbCases,i;
    
        PosX = X; // Where we should draw the next rectangle
        NbCases = 10 * Value / MaxValue; // Number of active rectangles to draw
        i=0; // Number of rectangles already drawn
    
    			/* Draws Blackbox to act as outline for time being */
    				Canvas.SetPos(PosX,Y);
            Canvas.SetDrawColor(0,0,0,255);
            Canvas.DrawRect(84,16);
    
        /* Displays active rectangles */
        while(i < NbCases && i < 10)
        {
            Canvas.SetPos(PosX +2,Y+2);
            Canvas.SetDrawColor(R,G,B,255);
            Canvas.DrawRect(8,12);
    
            PosX += 8;
            i++;
    
        }
    
        /* Displays desactived rectangles */
        while(i < 10)
        {
            Canvas.SetPos(PosX +2,Y+2);
            Canvas.SetDrawColor(255,255,255,80);
            Canvas.DrawRect(8,12);
    
            PosX += 8;
            i++;
    
        }
    
    }
    
    function DrawWeapon(String Value,int X, int Y, int R, int G, int B)
    {   
    		local int PosX;
        
        /*Display Weapon */
        
        Canvas.SetDrawColor (255,255,255,255);
        Canvas.Font = (MyFont);
        Canvas.DrawText(Value);
        
        
    
    } 
    
    
    function DrawTitle(String Value,int X, int Y, int R, int G, int B)
    {   
    		local int PosX;
    
        PosX = X; // Where we should draw the next rectangle
        
        /*Display Title */
        Canvas.SetPos(PosX +10, Y+ 0);
        Canvas.SetDrawColor (255,255,255,255);
        Canvas.Font = (MyFont);
        Canvas.DrawText(Value);
    
    } 
    
    
    
    function DrawAmmoBar(String Title, float Value, float MaxValue,int X, int Y, int R, int G, int B)
    {
    
        local int PosX,NbCases,i;    
        PosX = X; // Where we should draw the next rectangle
        NbCases = Value; // Number of active rectangles to draw
        i=0; // Number of rectangles already drawn
        
    		Canvas.SetPos(Posx +872, Y +690); /* set inital location*/
    			
        /* Displays active rectangles */
        while(i < NbCases && i < Value)
        {
    				Canvas.DrawMaterialTile(Default.BulletIcon,8,12);
    		
    			  Canvas.SetPos(PosX +882, Y+690);
            PosX += 10;
            i++;
    
        }
    
        /* Displays desactived rectangles */
        while(i < 10)
        {
            Canvas.SetDrawColor(255,255,255,80);
            Canvas.DrawRect(8,12);
           
    				Canvas.SetPos(PosX +882, Y+690);
            PosX += 10;
            i++;
        }
        
    } 
    
    
    
    function DisplayAmmo(UTWeapon Weapon)
    {
        local string Amount;
        local int AmmoCount;
        local int MaxAmmoCount;
        local string Seperater;
        local string MaxAmount;
        local int PosX;
        
        
    
       if (weapon.AmmoDisplayType != EAWDS_BarGraph)
       {
    		MaxAmmoCount = MaxAmmoCount;
    		MaxAmount = ""$MaxAmmoCount;
        AmmoCount = Weapon.GetAmmoCount();
        lastweapon = weapon;
        lastammocount = ammocount;
        Amount = ""$AmmoCount;
        
        Canvas.DrawColor = WhiteColor;
        Canvas.DrawText(Amount);
        Canvas.DrawText(MaxAmount);
    		}
    }
    
    
    function DrawGameHud() /* order seems important in terms of which are drawn first and thus over layed */
    {
    			local float XLength, YLength, X, Y;
    			local vector2d POS;
    			local int PosX; 
    			local int	MaxAmmoCount;
    			
    			local UTWeapon Weapon;
    			XLength = 128;
    			YLength = 64;
    			
    			
    			
    	if ( !PlayerOwner.IsDead() && !UTPlayerOwner.IsInState('Spectating'))
    		{
    			
           DrawHealthBar("",PlayerOwner.Pawn.Health, PlayerOwner.Pawn.HealthMax,20,20,50,205,50);
           DrawTitle ("Life", 20,20,50,205,50);
    
    			 PosX = X; 
        
    			/*	HUD weapon holder	*/
    			 Canvas.SetPos(PosX +800, Y+650);
    			 Canvas.DrawMaterialTile(Default.HudIconBg, 192, 96);
    			
    			
    			/* 	Weapon Icon				*/ 
    			  Canvas.SetPos(PosX +870, Y+655);
    			 Canvas.DrawTile(UTWeapon(PawnOwner.Weapon).IconHud, (XLength), (YLength), 0,0,128, 64);
    			
    			/* Ammo / Max Ammo */
    			Canvas.DrawText("Ammo: "@Amount@ " / "@MaxAmmoCount);
    			/* 	Weapon Name				
    			 Canvas.SetPos(PosX +880, y +720);
    			 DrawWeapon(UTWeapon(PawnOwner.Weapon).ItemName, 20,20,50,205,50);*/
    			 
    			/* 	Weapon Ammo Bullets */
    			
    			DrawAmmoBar("",UTWeapon(PawnOwner.Weapon).AmmoCount, UTWeapon(PawnOwner.Weapon).MaxAmmoCount ,10,34,80,80,200); 
        
        }
    
    }
    
    function ShowWeaponInventory()
    {
    			 //Weapon Name				
    			 
    			 DrawWeapon(UTWeapon(PawnOwner.Weapon).ItemName, 20,20,50,205,50);
    
    
    }
    thats my whole HUD.
    at line 118, DisplayAmmo is where i set Amount and MaxAmount
    then call at line 176.

  11. #11

    Default

    sorry i had it in the wrong place !!
    thank you very much

  12. #12

    Default

    Oh wait, it displays as " 0 / 0 "
    all the time...

  13. #13
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Location
    Ukraine
    Posts
    137

    Default

    Try change this:
    Code:
       if (weapon.AmmoDisplayType != EAWDS_BarGraph)
       {
    		MaxAmmoCount = MaxAmmoCount;
    		MaxAmount = ""$MaxAmmoCount;
        AmmoCount = Weapon.GetAmmoCount();
        lastweapon = weapon;
        lastammocount = ammocount;
        Amount = ""$AmmoCount;
        
        Canvas.DrawColor = WhiteColor;
        Canvas.DrawText(Amount);
        Canvas.DrawText(MaxAmount);
    		}
    to this:

    Code:
       if (weapon.AmmoDisplayType != EAWDS_BarGraph)
       {
           Canvas.DrawColor = WhiteColor;
           Canvas.DrawText("Ammo: "@Weapon.GetAmmoCount()@" / "@Weapon.MaxAmmoCount);
       }
    i think i late with reply

  14. #14

    Default

    It still displays it as " 0 / 0"

  15. #15
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Location
    Ukraine
    Posts
    137

    Default

    Show current code of DisplayAmmo function.

  16. #16

    Default

    i changed to this
    Code:
     Canvas.DrawText(""@UTWeapon(PawnOwner.Weapon).AmmoCount@ "/"@UTWeapon(PawnOwner.Weapon).MaxAmmoCount);
    and it works fine ! thanks
    how do i know when to use @ ?

  17. #17
    MSgt. Shooter Person
    Join Date
    Mar 2010
    Location
    Ukraine
    Posts
    137

    Default

    how do i know when to use @ ?
    use this when you need to add variables to string variable.

  18. #18

    Default

    cool, i think thats the same in php

  19. #19
    Veteran
    Join Date
    Dec 2003
    Location
    Finland
    Posts
    5,996

    Default

    You can use the dollar sign ($) if you don't want a space between the strings.
    Also known as Rask — http://www.ottorask.com/

    UT3 Levels: CTF-Austere (MSU P3 5th place)
    UE3 Tutorials: From Textures To Materials In UE3 Complex Fire In UE3

  20. #20

    Default

    Quote Originally Posted by musilowski View Post
    You can use the dollar sign ($) if you don't want a space between the strings.
    Could you show me an example?
    does $ not also mean Variable ?


 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Copyright ©2009-2011 Epic Games, Inc. All Rights Reserved.
Digital Point modules: Sphinx-based search vBulletin skin by CompletevB.com.