• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Text Tag Question

Status
Not open for further replies.
Level 9
Joined
Oct 28, 2007
Messages
435
Hi,

In one of my new maps I make use of tons of texttags and is it better to destroy/create texttags the entire time or to make use of a texttag stack?

With a stack you will hide your texttags instead of destroying them. If you have free texttags in your stack you wil show them and change their text instead of creating new texttags.

Thanks.

Edit (Sorry.. this prob should have GUI tags, since you can easily do it in gui, but I work mostly in JASS and all I want to know is which is more efficient which require some more advanced knowledge)
 
Level 13
Joined
May 11, 2008
Messages
1,198
i haven't used it yet, but this system might replace whatever you're using...
JASS:
//==============================================================================
//  TEXT TAG - Floating text system by Cohadar - v4.0
//==============================================================================
//
//  PURPOUSE:
//       * Displaying floating text - the easy way
//       * Text is automatically centered depending on it's length
//
//  FUNCTION LIST:
//       * TextTag_XY(x, y, text, color)
//       * TextTag_Unit(unit, text, color)
//       * TextTag_GoldBounty(unit, text, killer)
//       * TextTag_LumberBounty(unit, text, killer)
//
//         color is a color string, example: "|c00FFCC00"
//         killer is a killing player, usually: GetOwningPlayer(GetKillingUnit())
//         (bounty text is visible only to killer)
//
//  HOW TO IMPORT:
//       * Just create a trigger named TextTag
//         convert it to text and replace the whole trigger text with this one
//==============================================================================

library TextTag

globals    
    private constant integer MEAN_CHAR_WIDTH = 8
    private constant integer MAX_TEXT_SHIFT = 32    
    
    private constant real    FONT_SIZE = 0.025
    private constant real    VELOCITY_X = 0
    private constant real    VELOCITY_Y = .04
    private constant real    LIFESPAN = 4
    private constant real    HEIGHT = 16
    private constant real    FADE_POINT = 2.5
endglobals


//===========================================================================
public function XY takes real x, real y, string text, string color returns nothing
    local texttag t = CreateTextTag()
    local integer shift = IMinBJ(StringLength(text), MAX_TEXT_SHIFT) * MEAN_CHAR_WIDTH
   
    call SetTextTagText(t, color+text, FONT_SIZE)
    call SetTextTagPos(t, x-shift, y, HEIGHT)
    call SetTextTagVelocity(t, VELOCITY_X, VELOCITY_Y)
    call SetTextTagVisibility(t, true)
    call SetTextTagFadepoint(t, FADE_POINT)
    call SetTextTagLifespan(t, LIFESPAN)
    call SetTextTagPermanent(t, false)
   
    set t = null
endfunction

//===========================================================================
public function Unit takes unit whichUnit, string text, string color returns nothing
    local texttag t = CreateTextTag()
    local integer shift = IMinBJ(StringLength(text), MAX_TEXT_SHIFT) * MEAN_CHAR_WIDTH
   
    call SetTextTagText(t, color+text, FONT_SIZE)
    call SetTextTagPos(t, GetUnitX(whichUnit)-shift, GetUnitY(whichUnit), HEIGHT)
    call SetTextTagVelocity(t, VELOCITY_X, VELOCITY_Y)
    call SetTextTagVisibility(t, true)
    call SetTextTagFadepoint(t, FADE_POINT)
    call SetTextTagLifespan(t, LIFESPAN)
    call SetTextTagPermanent(t, false)    
   
    set t = null
endfunction

//===========================================================================
public function GoldBounty takes unit whichUnit, string text, player killer returns nothing
    local texttag t = CreateTextTag()
    local integer shift = IMinBJ(StringLength(text), MAX_TEXT_SHIFT) * MEAN_CHAR_WIDTH
   
    call SetTextTagText(t, text, FONT_SIZE)
    call SetTextTagPos(t, GetUnitX(whichUnit)-shift, GetUnitY(whichUnit), HEIGHT)
    call SetTextTagColor(t, 255, 220, 0, 255)
    call SetTextTagVelocity(t, VELOCITY_X, VELOCITY_Y)
    call SetTextTagVisibility(t, GetLocalPlayer()==killer)
    call SetTextTagFadepoint(t, FADE_POINT)
    call SetTextTagLifespan(t, LIFESPAN)
    call SetTextTagPermanent(t, false)
   
    set t = null
endfunction

//==============================================================================
public function LumberBounty takes unit whichUnit, string text, player killer returns nothing
    local texttag t = CreateTextTag()
    local integer shift = IMinBJ(StringLength(text), MAX_TEXT_SHIFT) * MEAN_CHAR_WIDTH
   
    call SetTextTagText(t, text, FONT_SIZE)
    call SetTextTagPos(t, GetUnitX(whichUnit)-shift, GetUnitY(whichUnit), HEIGHT)
    call SetTextTagColor(t, 0, 196, 0, 255)
    call SetTextTagVelocity(t, VELOCITY_X, VELOCITY_Y)
    call SetTextTagVisibility(t, GetLocalPlayer()==killer)
    call SetTextTagFadepoint(t, FADE_POINT)
    call SetTextTagLifespan(t, LIFESPAN)
    call SetTextTagPermanent(t, false)
   
    set t = null
endfunction

endlibrary
 
Status
Not open for further replies.
Top