[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums | Starcraft II |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Warcraft III Resources > JASS Functions

JASS Functions Approved JASS functions will be located here.
Remember to submit your own resources to the submission forum.

Reply
 
LinkBack Thread Tools
Old 08-30-2009, 06:17 PM   #16 (permalink)
Registered User YourNameHere
wuts dis?
 
Join Date: Apr 2007
Posts: 595
YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)
Updated. Anything else to fix? I think this is also useful enough for people who want to create the texttags by theirselves.
__________________
--YourNameHere
YourNameHere is offline   Reply With Quote
Old 08-30-2009, 06:22 PM   #17 (permalink)
Registered User aznricepuff
OOP freak.
 
Join Date: Feb 2006
Posts: 751
aznricepuff is a jewel in the rough (181)aznricepuff is a jewel in the rough (181)
Former Staff Member: This user used to be on the Hive Workshop staff. 
I don't see the need to recycle text tags.
aznricepuff is offline   Reply With Quote
Old 08-30-2009, 06:29 PM   #18 (permalink)
Registered User YourNameHere
wuts dis?
 
Join Date: Apr 2007
Posts: 595
YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)
Yeah you're right. There was a need when I saved stuff in hashtables to flush them, but now it's just useless. Updated again.
__________________
--YourNameHere
YourNameHere is offline   Reply With Quote
Old 09-01-2009, 02:57 PM   #19 (permalink)
Registered User aznricepuff
OOP freak.
 
Join Date: Feb 2006
Posts: 751
aznricepuff is a jewel in the rough (181)aznricepuff is a jewel in the rough (181)
Former Staff Member: This user used to be on the Hive Workshop staff. 
Well, I tested it, and it works, at least the stuff I tested. So functionality here isn't really a problem. However, I think the API could use a cleanup (or maybe a major rework).

First of all, I dont want to type in 10 parameters every time I create a texttag. It's just annoying, and it's easy to forget what those parameters are, so I have to go back and look at the documentation every time. Instead of emulating BJs with their huge parameter lists, you could make a Template struct, for example:

template

struct Template
    static constant integer DEFAULT_RED = 255
    static constant integer DEFAULT_GREEN = 255
    static constant integer DEFAULT_BLUE = 255
    static constant integer DEFAULT_ALPHA = 255
    static constant integer DEFAULT_SIZE = 12
    static constant boolean DEFAULT_VISIBILITY = true
    static constant boolean DEFAULT_PERMANENT = true
    static constant real DEFAULT_FADEPOINT = 0.0
    static constant real DEFAULT_LIFESPAN = 0.0
    static constant real DEFAULT_X_VELOCITY = 0.0
    static constant real DEFAULT_Y_VELOCITY = 0.0

    integer red
    integer green
    integer blue
    integer alpha
    integer size
    boolean visible
    boolean permanent
    real fadepoint
    real lifespan
    real xVelocity
    real yVelocity

    static method create takes nothing returns nothing
        local Template this = Template.allocate()
        set this.red = .DEFAULT_RED
        set this.green = .DEFAULT_GREEN
set this.blue = .DEFAULT_BLUE
        set this.alpha = .DEFAULT_ALPHA
        set this.size = .DEFAULT_SIZE
        set this.visible = .DEFAULT_VISIBILITY
        set this.permanent = .DEFAULT_PERMANENT
        set this.fadepoint = .DEFAULT_FADEPOINT
        set this.lifespan = .DEFAULT_LIFESPAN
        set this.xVelocity = .DEFAULT_X_VELOCITY
        set this.yVelocity = .DEFAULT_Y_VELOCITY
    endmethod
endstruct

function NewTextTag takes real x, real y, real z, string text, Template template returns texttag
    local texttag tag = CreateTextTag()
    call SetTextTagPos(tag, x, y, z)
    call SetTextTagText(tag, text, template.size * 0.023 / 10)
    call SetTextTagColor(tag, template.red, template.green, template.blue, template.alpha)
    call SetTextTagVisibility(tag, template.visible)
    call SetTextTagPermanent(tag, template.permanent)
    call SetTextTagFadepoint(tag, template.fadepoint)
    call SetTextTagLifespan(tag, template.lifespan)
    call SetTextTagVelocity(tag, template.xVelocity, template.yVelocity)
    return tag
endfunction


Some other things:

Your textbar thing shouldn't really need to take in an existing texttag upon creation. The constructor should create its own texttag. Also, by convention the constructor of any struct is .create(), not .Create() (and more generally, all method identifiers should have their first word in all lowercase, and the rest with first letter capitalized: .create(), .destroy(), .doSomething()).

You should use size and not height when determining text size. It's just easier to work with. Size can be thought of as the same thing as font size in word processing programs, while height is just some random real that probably makes no sense to anybody except the people at blizzard who wrote the natives.

Your documentation should specify what it is that some of the parameters do. Some of them are obvious by their names; others are not. It's best to be clear.

You should rename all "transparency" parameters to "alpha", since the way you handle them you are treating them as alpha values (0=transparent, 255=opaque) and not transparency (0%=opaque, 100%=transparent).

I've probably forgotten some other things that I thought of while testing. But this is it for now.
aznricepuff is offline   Reply With Quote
Old 09-01-2009, 04:56 PM   #20 (permalink)
Registered User YourNameHere
wuts dis?
 
Join Date: Apr 2007
Posts: 595
YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)
Quote:
Originally Posted by aznricepuff View Post
You should use size and not height when determining text size. It's just easier to work with. Size can be thought of as the same thing as font size in word processing programs, while height is just some random real that probably makes no sense to anybody except the people at blizzard who wrote the natives.
I don't see where I have done that?
Other than that, updated. Fixed alot of things you mentioned.
__________________
--YourNameHere
YourNameHere is offline   Reply With Quote
Old 09-01-2009, 11:55 PM   #21 (permalink)
Registered User aznricepuff
OOP freak.
 
Join Date: Feb 2006
Posts: 751
aznricepuff is a jewel in the rough (181)aznricepuff is a jewel in the rough (181)
Former Staff Member: This user used to be on the Hive Workshop staff. 
You shouldn't use 'this' as a variable/parameter name unless it's in a completely internal block of code. Doing otherwise makes it more likely for users to get confused.
aznricepuff is offline   Reply With Quote
Old 09-02-2009, 05:34 AM   #22 (permalink)
Registered User YourNameHere
wuts dis?
 
Join Date: Apr 2007
Posts: 595
YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)
*sigh* I'm kind of used to that but as you wish, I changed it.
__________________
--YourNameHere
YourNameHere is offline   Reply With Quote
Old 09-02-2009, 01:53 PM   #23 (permalink)
Registered User aznricepuff
OOP freak.
 
Join Date: Feb 2006
Posts: 751
aznricepuff is a jewel in the rough (181)aznricepuff is a jewel in the rough (181)
Former Staff Member: This user used to be on the Hive Workshop staff. 
Like I said, it's fine if you use it in internal/private code sections; just not for public code.

Anyway, approved.
aznricepuff is offline   Reply With Quote
Old 01-22-2010, 03:46 PM   #24 (permalink)
Registered User YourNameHere
wuts dis?
 
Join Date: Apr 2007
Posts: 595
YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)
Buuump. Great update.
__________________
--YourNameHere
YourNameHere is offline   Reply With Quote
Old 01-30-2010, 08:27 PM   #25 (permalink)
Registered User Berbanog
User
 
Join Date: Jan 2006
Posts: 708
Berbanog will become famous soon enough (90)Berbanog will become famous soon enough (90)Berbanog will become famous soon enough (90)
PayPal Donor: This user has donated to The Hive. 
        static method create(texttag which, unit to, real offset) -> thistype
        {
            thistype this = thistype.allocate();

            this.tt = which;
            this.u = to;
            this.z = offset;

            this.t = NewTimer();
            SetTimerData(this.t, this);
            TimerStart(this.t, UPDATE_INTERVAL, true, static method thistype.update);

            return this;
        }

So every time anyone creates a text-tag it starts a new timer? Why not just have all of these in a stack and then run through the stack every interval (one timer).

struct stackNode
    integer index

    static thistype array stack
    static integer n = 0

    method onDestroy takes nothing returns nothing
        set thistype.n=thistype.n-1
        set thistype.stack[this.index] = thistype.stack[thistype.n]
        set thistype.stack[this.index].index = this.index
    endmethod

    static method create takes ... returns thistype
        local thistype dat=thistype.allocate()

        set dat.index = thistype.n
        set thistype.stack[thistype.n] = dat
        set thistype.n=thistype.n+1

        return dat
    endmethod
endstruct

Its in vJass not Zinc, but you can probably understand it.
Berbanog is offline   Reply With Quote
Old 01-31-2010, 09:29 AM   #26 (permalink)
Registered User YourNameHere
wuts dis?
 
Join Date: Apr 2007
Posts: 595
YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)
I know how such indexing works, but I don't see any particular reason for doing so. It might be neccessary for things which you use often, but I don't think you're going to create 50 attached texttags.
__________________
--YourNameHere
YourNameHere is offline   Reply With Quote
Old 01-31-2010, 07:04 PM   #27 (permalink)
Registered User Berbanog
User
 
Join Date: Jan 2006
Posts: 708
Berbanog will become famous soon enough (90)Berbanog will become famous soon enough (90)Berbanog will become famous soon enough (90)
PayPal Donor: This user has donated to The Hive. 
But it doesn't slow anything down, so why would you deliberately use unnecessary resources? Especially in something which would be implementing into someone else' map, you would want it to be as perfected as it can be.
Berbanog is offline   Reply With Quote
Old 02-02-2010, 10:59 AM   #28 (permalink)
Registered User YourNameHere
wuts dis?
 
Join Date: Apr 2007
Posts: 595
YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)YourNameHere has a spectacular aura about (120)
Updated. Hope you're happier now. :)
__________________
--YourNameHere
YourNameHere is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:54 AM.






Hosting by SliceHost 
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.1
Copyright©Ralle