System TexttagUtils

vuongkkk

New Member
Reaction score
1
VTexttag

VTexttag
Version 2.1

System
I have a system and a extension
- DynamicTexttag: this sys provides a very simple method to create your stylish texttag!
- No require​
-VTexttag: this ext for anyone only want to use my stylish texttag or create stylish texttag faster!
- Require DynamicTexttag​

Advantages
- Easy create the texttag color with RGB color (can use mspaint to pick a color)
- Setters have the API like Blizzard native function (easy to use)
- Easy implement the way you want how the texttag changes (with function interfaces)
- Code is clean & clear, can read easily, Documentation, too. Have example of usage
- Have 5 my build-in stylish texttags
- No need to care about destroy or recycle problem

Disadvantages
- Need math knowledge to control the changing of the texttag
- Appear the display problem when string is too long or text size is too big if you are careless

Code
DynamicTexttag
JASS:
// ==============================================
library DynamicTexttag /* ver 2.1c - vuongkkk */
/* ==============================================
*
* - What is it for? -
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* The normal texttag is boring, need more dynamic like changing
* its properties overtime and self-destruct when expire. Then this resource is made
*
* - How does it work? -
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* All you must to do is describle how the texxtag change in a loop func
* then attach that to the new instance of the texttag.
* This system will do remain parts that is loop it overtime
* and change the texttag formation
*
* - How to use? -
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* + struct DTexttag
// The basic properties of a normal textag:
* - used like a setting with no change when running!
* - can retrieve or change them
real age
real fadepoint
real lifespan
integer red
integer green
integer blue
integer alpha
real angle // angle unit is degree
real speed
string text
real size
real posX
real posY
real posZ
 
* - have setters to change them and save lines of code
method setupVelocity takes real speed, real angle returns nothing
method setupColor takes integer r,integer g,integer b,integer a returns nothing
method setupText takes string text, real size returns nothing
method setupPosition takes real x, real y, real z returns nothing
*
static method create takes player p, boolexpr func returns TextTag
* p is player that texttag display for.
* if p == null then display for all players
* func is the code control the changing of texttag over-time
*
readonly texttag tag // use to change how it displays with native funtions
*
* + How create your dynamic texttag:
* Use the textmacro like this Example:
 
public struct YourTexttag extends array
integer yourdata
 
//! runtextmacro DTT_onLoop()
// each 0.025s, the code in here will be executed
// you can access all members of your struct and DTexttag in here like this:
set yourdata=yourdata+1
set tag.color.blue=blue+yourdata
//! runtextmacro DTT_End()
static method create takes player p, unit u, string mes, real height returns thistype
//! runtextmacro DTT_onCreateBeginning("p")
set fadepoint= 1.0
set lifespan= 2.0
call setupText(mes, 10.0)
call setupColor(0, 255, 0, 255)
call setupVelocity(90., 80)
call setupPosition(GetUnitX(u), GetUnitY(u), height)
return this
endmethod
endstruct
*
* - What do you need to note? -
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* + all angles here use degree is unit
* + SetTextTagFadepoint do NOT work with this resource
* + Your dynamic texttag struct should extends array
* + globals vars are faster than local ones. When you calculate,
* you can use static vars below as temporary vars:
DTexttag.R
DTexttag.G
DTexttag.B
DTexttag.Al
DTexttag.A
DTexttag.Spd
* + never set value for DTexttag.current!
* + you should change vars: age, fadepoint and lifespan carefully because it may to be the cause of infinitve loop!
*
* - Credit -
* ¯¯¯¯¯¯¯¯¯¯¯
* Nestharus
* + Queue: help this sys have a good destruction behavior
* + Recycler: make allocate method faster
* Tom_Kazansky: fix bug displayer texttag for a player
*
* =======================================================================================
*/
globals
public constant real PERIOD = 0.025 // how smooth texttags changes
endglobals
 
function SetTextTagVelocityEx takes texttag tag, real speed, real angle returns nothing
call SetTextTagVelocity(tag, speed*Cos(angle* bj_DEGTORAD)*.071/128, speed*Sin(angle* bj_DEGTORAD)*.071/128)
endfunction
 
struct DTexttag extends array
private static integer timerInstanceCount = 0
private static thistype instanceCount = 0
private static integer array recycler
 
private static timer T = CreateTimer()
private static trigger trig=CreateTrigger()
 
private triggercondition la // loop action
 
readonly texttag tag
 
real age
real fadepoint
real lifespan
 
integer red
integer green
integer blue
integer alpha
method setupColor takes integer r,integer g,integer b,integer a returns nothing
set this.red = r
set this.green = g
set this.blue = b
set this.alpha = a
call SetTextTagColor(tag,r,g,b,a)
endmethod
real posX
real posY
real posZ
real posOffX
real posOffY
method setupPosition takes real x, real y, real z returns nothing
set posX=x
set posY=y
set posZ=z
call SetTextTagPos(tag, x + posOffX, y + posOffY, z)
endmethod
string text
real size
method setupText takes string text, real size returns nothing
set .text = text
set .size = size
call SetTextTagText(tag, text, size * .0023)
endmethod
private boolean visible_p
method operator visible takes nothing returns boolean
return visible_p
endmethod
method operator visible= takes boolean visible returns nothing
set visible_p = visible
call SetTextTagVisibility(tag, visible)
endmethod
real angle
real speed
method setupVelocity takes real speed, real angle returns nothing
set .angle = angle
set .speed = speed
call SetTextTagVelocity(tag, speed*Cos(angle* bj_DEGTORAD)*.071/128, speed*Sin(angle* bj_DEGTORAD)*.071/128)
endmethod
 
static integer R // Red
static integer G // Green
static integer B // Blue
static integer Al // Alpha
static real A // Angle
static real Spd // Speed
static thistype current
 
readonly thistype next
private thistype prev
private method remove takes nothing returns nothing
call DestroyTextTag(tag)
call TriggerRemoveCondition(trig, la)
set prev.next = next
set next.prev = prev
endmethod
private static method allocate takes boolean createForPlayer returns thistype
local thistype this = recycler[0]
local texttag tt=CreateTextTag()
if GetHandleId(tt)==0 then
set this = thistype(0).next
call remove()
set tt=CreateTextTag()
endif
if (createForPlayer) then
call SetTextTagVisibility(tt, true)
endif
if (0 == this) then
set this = instanceCount + 1
set instanceCount = this
else
set recycler[0] = recycler[this]
endif
// enqueue
set next = 0
set prev = thistype(0).prev
set thistype(0).prev.next = this
set thistype(0).prev = this
set tag=tt
set age=0
set fadepoint = 0
call SetTextTagPermanent(tag,false)
set red=0
set green=0
set blue=0
set alpha=255
set posX = 0
set posY = 0
set posZ = 0
set posOffX = 0
set posOffY = 0
set text = "No text here"
set size = 10
set angle = 90
set speed = 90
return this
endmethod
 
static method create takes player p, boolexpr func returns DTexttag
if p!=null then
set current=allocate(GetLocalPlayer()==p)
else
set current=allocate(true)
endif
 
set current.la=TriggerAddCondition(trig, func)
if (0 == timerInstanceCount) then
call TimerStart(T, PERIOD, true, function thistype.update)
endif
set timerInstanceCount = timerInstanceCount + 1
 
return current
endmethod
 
private static method update takes nothing returns nothing
local thistype this = thistype(0).next
loop
exitwhen 0 == this
if age < lifespan-PERIOD then
set age = age + PERIOD
set this = next
else
call remove()
set recycler[this] = recycler[0]
set recycler[0] = this
set this = next
set timerInstanceCount = timerInstanceCount - 1
endif
endloop
set current=thistype(0).next
if (0 == timerInstanceCount) then
call PauseTimer(T)
else
call TriggerEvaluate(trig)
endif
endmethod
endstruct
 
//! textmacro DTT_onLoop
static method onLoop takes nothing returns boolean
local thistype this=thistype(DTexttag.current)
//! endtextmacro
//! textmacro DTT_End
set DTexttag.current=next
return false
endmethod
private static boolexpr cons
private static method onInit takes nothing returns nothing
set thistype.cons=Condition(function thistype.onLoop)
endmethod
private delegate DTexttag tt
//! endtextmacro
//! textmacro DTT_onCreateBeginning takes agrPlayer
local thistype this=thistype(DTexttag.create($agrPlayer$, cons))
set tt=this
//! endtextmacro
 
endlibrary


VTexttag
JASS:
// ============================================================
library VTexttag /* ver 2.1 - vuongkkk */uses DynamicTexttag
/* ============================================================
*
* - What is it for? -
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* Same as DynamicTexttag but it's more specific and base on DynamicTexttag
* So that, don't like my way to create dynamic texttag,
* feel free to create another with DynamicTexttag!
*
* - How to use? -
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*
* + Interfaces
*
static method changeRed takes DTexttag t returns integer
static method changeGreen takes DTexttag t returns integer
static method changeBlue takes DTexttag t returns integer
static method changeAlpha takes DTexttag t returns integer
static method changePosition takes DTexttag t returns nothing
static method changeHeight takes DTexttag t returns real
static method changeSpeed takes DTexttag t returns real
static method changeAngle takes DTexttag t returns real
static method changeSize takes DTexttag t returns real
*
* - The defination of those interface must be placed before loop func
* - In them, you dont use native func to update texttag, just calculate
* then return the result
* - method changePosition is an exception: change pos directly in it
*
* + Modules
*
* OnLoopModule (required if using funcs are defined from the interfaces)
* - implement it inside the loop func help the loop func
* to recognize the changing func
* - define local var before implement and do something after implement
* Ex:
//! runtextmacro DTT_onLoop()
local real r=0.1
implement OnLoopModule
set r=r+1.6
//! runtextmacro DTT_End()
*
* - What do you need to note? -
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
* - Can re-use the calculating func
* + Copy and paste
* + recall it in the same type calculating func but you must declare it properly
* Ex:
static method changeAlpha takes DTexttag t returns integer
return VTexttag_Normal.changeAlpha(t)
endmethod
* - Your dynamic texttag struct should extends array
*
* =======================================================================================
*/
public module OnLoopModule
//change xoffset, yoffset and hoffset
static if thistype.changeHeight.exists then
static if thistype.changePosition.exists then
call thistype.changePosition(this)
endif
call SetTextTagPos(tag, posX + posOffX, posY + posOffY, thistype.changeHeight(this))
elseif thistype.changePosition.exists then
call thistype.changePosition(this)
static if thistype.changeHeight.exists then
call SetTextTagPos(tag, posX + posOffX, posY + posOffY, thistype.changeHeight(this))
else
call SetTextTagPos(tag, posX + posOffX, posY + posOffY, posZ)
endif
endif
// change speed and angle
static if thistype.changeSpeed.exists then
set DTexttag.A = angle
set DTexttag.Spd=thistype.changeSpeed(this)
static if thistype.changeAngle.exists then
set DTexttag.A=thistype.changeAngle(this)
endif
call SetTextTagVelocityEx(tag,DTexttag.Spd, DTexttag.A)
elseif thistype.changeAngle.exists then
set DTexttag.Spd = speed
set DTexttag.A = thistype.changeAngle(this)
static if thistype.changeSpeed.exists then
set DTexttag.A=thistype.changeSpeed(this)
endif
call SetTextTagVelocityEx(tag,DTexttag.Spd, DTexttag.A)
endif
// change size
static if thistype.changeSize.exists then
call SetTextTagText(tag,text,thistype.changeSize(this)*.0023)
endif
// change color and alpha
static if thistype.changeRed.exists then
set DTexttag.R = thistype.changeRed(this)
else
set DTexttag.R = red
endif
static if thistype.changeGreen.exists then
set DTexttag.G = thistype.changeGreen(this)
else
set DTexttag.G = green
endif
static if thistype.changeBlue.exists then
set DTexttag.B = thistype.changeBlue(this)
else
set DTexttag.B = blue
endif
set DTexttag.Al = alpha
static if thistype.changeAlpha.exists then
if fadepoint<=age and fadepoint>0 then
set DTexttag.Al = thistype.changeAlpha(this)
endif
endif
call SetTextTagColor(tag,DTexttag.R,DTexttag.G,DTexttag.B,DTexttag.Al)
endmodule
/*
* Useful stuffs
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*/
// This func is very useful!
private function Parabol takes real h, real d, real x returns real
return (4 * h / d) * (d - x) * (x / d)
endfunction
/*
* = Build-in Stylish TextTag =
* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
*/
public struct Normal extends array
static method changeAlpha takes DTexttag t returns integer
return R2I(t.alpha/(t.lifespan-t.fadepoint)*(t.lifespan-t.age))
endmethod
static method changeBlue takes DTexttag t returns integer
return (t.blue+R2I(Parabol(255-t.blue,t.lifespan, t.age)))
endmethod
endstruct
 
public struct Attach extends array
unit owner
static method changePosition takes DTexttag t returns nothing
set t.posX=GetUnitX(thistype(t).owner)
set t.posY=GetUnitY(thistype(t).owner)
endmethod
static method changeAlpha takes DTexttag t returns integer
return VTexttag_Normal.changeAlpha(t)
endmethod
 
//! runtextmacro DTT_onLoop()
implement OnLoopModule
//! runtextmacro DTT_End()
static method create takes unit u, player p, string mes, real h returns thistype
//! runtextmacro DTT_onCreateBeginning("p")
set fadepoint= 1.0
set lifespan= 2.1
call setupText(mes, 12.0)
call setupColor(65, 238, 34, 255)
call setupVelocity(70., 90)
call setupPosition(GetUnitX(u), GetUnitY(u), h)
set owner=u
return this
endmethod
endstruct
 
 
public struct Jump extends array
static method changeAlpha takes DTexttag t returns integer
return VTexttag_Normal.changeAlpha(t)
endmethod
static method changeSpeed takes DTexttag t returns real
return (t.speed+Parabol(52.0,t.lifespan, t.age)+t.age*1.01)
endmethod
static method changeSize takes DTexttag t returns real
return (t.size+Parabol(11.0,t.lifespan, t.age))
endmethod
 
//! runtextmacro DTT_onLoop()
implement OnLoopModule
//! runtextmacro DTT_End()
static method create takes player p, string mes, real x, real y, real h returns thistype
//! runtextmacro DTT_onCreateBeginning("p")
set fadepoint= 0.6
set lifespan= 1.2
call setupText(mes, 8.0)
call setupColor(25, 208, 24, 255)
call setupVelocity(85., 87)
call setupPosition(x, y, h)
return this
endmethod
endstruct
 
public struct Inclined extends array
static method changeAlpha takes DTexttag t returns integer
return VTexttag_Normal.changeAlpha(t)
endmethod
static method changeSize takes DTexttag t returns real
return (t.size+Parabol(8.0,t.lifespan, t.age))
endmethod
 
//! runtextmacro DTT_onLoop()
implement OnLoopModule
//! runtextmacro DTT_End()
static method create takes player p, string mes, real x, real y, real h returns thistype
//! runtextmacro DTT_onCreateBeginning("p")
set fadepoint= 1.0
set lifespan= 1.8
call setupText(mes, 7.0)
call setupColor(251, 125, 0, 255)
call setupVelocity(95.00, 75)
call setupPosition(x, y, h)
return this
endmethod
endstruct
 
public struct Critical extends array
//! runtextmacro DTT_onLoop()
local real period=lifespan/6
if age < period then
call SetTextTagVelocityEx(tag,speed+Parabol(36.0,period*2, age),angle)
call SetTextTagText(tag,text, (size+Parabol(9.0,period, age))*.0023)
else
if age > period*2 then
call SetTextTagColor(tag,red,green,blue, R2I(245/period/4*(lifespan-age))+10)
endif
endif
//! runtextmacro DTT_End()
static method create takes player p, string mes, real x, real y, real h returns thistype
//! runtextmacro DTT_onCreateBeginning("p")
set lifespan= 2.2
call setupColor(255, 23, 23, 255)
call setupVelocity(46.00, 90)
call setupText(mes, 9.0)
call setupPosition(x, y, h)
return this
endmethod
endstruct
 
public struct HeadUp extends array
static method changeAlpha takes DTexttag t returns integer
return VTexttag_Normal.changeAlpha(t)
endmethod
static method changeHeight takes DTexttag t returns real
if t.age < t.lifespan/2 then
return (t.posZ+Parabol(38.0,t.lifespan/2, t.age))
else
return t.posZ
endif
endmethod
 
//! runtextmacro DTT_onLoop()
implement OnLoopModule
//! runtextmacro DTT_End()
static method create takes player p, string mes, real x, real y, real h returns thistype
//! runtextmacro DTT_onCreateBeginning("p")
set fadepoint= 1.1
set lifespan= 2.0
call setupText(mes, 12.0)
call setupColor(227, 15, 227, 245)
call setupVelocity(90.00, 90)
call setupPosition(x, y, h)
return this
endmethod
endstruct
 
public struct Curved extends array
static method changeAlpha takes DTexttag t returns integer
return VTexttag_Normal.changeAlpha(t)
endmethod
static method changeSize takes DTexttag t returns real
return (t.size+Parabol(10.0,t.lifespan, t.age))
endmethod
static method changeAngle takes DTexttag t returns real
return (t.angle+Parabol(18.0,t.lifespan, t.age))
endmethod
static method changeSpeed takes DTexttag t returns real
if t.age < t.lifespan/2 then
return (t.speed+Parabol(46.0,t.lifespan, t.age))
else
return (t.speed+36.0)*(1+0.05*(t.age-t.lifespan/2)/DynamicTexttag_PERIOD)
endif
endmethod
 
//! runtextmacro DTT_onLoop()
implement OnLoopModule
//! runtextmacro DTT_End()
static method create takes player p, string mes, real x, real y, real h returns thistype
//! runtextmacro DTT_onCreateBeginning("p")
set fadepoint= 0.9
set lifespan= 1.8
call setupText(mes, 7.0)
call setupColor(248, 237, 0, 255)
call setupVelocity(49.00, 90)
call setupPosition(x, y, h)
return this
endmethod
endstruct
 
public struct Whirl extends array
static method changeAlpha takes DTexttag t returns integer
return R2I(Parabol(255,t.lifespan, t.age))
endmethod
static method changeAngle takes DTexttag t returns real
return (t.angle+Parabol(460.0,t.lifespan, t.age))
endmethod
static method changeSize takes DTexttag t returns real
return (t.size+Parabol(9.0,t.lifespan, t.age))
endmethod
static method changeSpeed takes DTexttag t returns real
return (t.speed+Parabol(42.0,t.lifespan, t.age)+t.age*1.01)
endmethod
//! runtextmacro DTT_onLoop()
implement OnLoopModule
//! runtextmacro DTT_End()
static method create takes player p, string mes, real x, real y, real h returns thistype
//! runtextmacro DTT_onCreateBeginning("p")
set fadepoint= 0.01
set lifespan= 1.9
call setupText(mes, 7.0)
call setupColor(224, 200, 27, 0)
call setupVelocity(29.00, 0)
call setupPosition(x, y, h)
return this
endmethod
endstruct
endlibrary


TexttagControllers
JASS:
library TexttagControllers requires VTexttag
//=================================================
// Author: vuongkkk
// Version: 1.6
//=================================================
/*
* You can see the API in there is not change althought VTTexttag is completely different
* So don't worry about anything if you use these func to create a VTexttag
*
* Even this code is not neccessary for who uses vjass
* Just VTexttag and DynamicTexttag is enough
*
* All you need is Math knowledge to create a interesting texttag !
*/
globals
// only for test
constant integer TexttagStyle_Attach = 1
constant integer TexttagStyle_HeadUp = 2
constant integer TexttagStyle_Inclined=3
constant integer TexttagStyle_Jump = 4
constant integer TexttagStyle_Critical =5
constant integer TexttagStyle_Curved =6
constant integer TexttagStyle_Whirl =7
endglobals
 
// Note:
// - If you don't specify a player (p=null) then texttag will display for all players
 
function AttachVTexttag_Create takes string mes, player p, unit u, real h returns nothing
call VTexttag_Attach.create(u,p,mes, 50)
endfunction
 
function JumpVTexttag_Create takes string mes, player p, real x, real y, real h returns nothing
call VTexttag_Jump.create(p,mes,x,y, 70)
endfunction
 
function InclinedVTexttag_Create takes string mes, player p, real x, real y, real h returns nothing
call VTexttag_Inclined.create(p,mes,x,y, 70)
endfunction
 
function CriticalVTexttag_Create takes string mes, player p, real x, real y, real h returns nothing
call VTexttag_Critical.create(p,mes,x,y, 70)
endfunction
 
function HeadUpVTexttag_Create takes string mes, player p, real x, real y, real h returns nothing
call VTexttag_HeadUp.create(p,mes,x,y, 70)
endfunction
 
function CurvedVTexttag_Create takes string mes, player p, real x, real y, real h returns nothing
call VTexttag_Curved.create(p,mes,x,y, 70)
endfunction
 
function WhirlVTexttag_Create takes string mes, player p, real x, real y, real h returns nothing
call VTexttag_Whirl.create(p,mes,x,y, 70)
endfunction
 
// for test performance
// type chat string "/fps" to display FPS
struct VTTTester
private static real x
private static real y
private static unit sheep
 
static method onTimer takes nothing returns nothing
call VTexttag_Attach.create(.sheep,Player(0),"Attach!", 50)
call VTexttag_Inclined.create(Player(0),"Inclined!",.x-200,.y, 70)
call VTexttag_Jump.create(Player(0),"Jump!",.x+200,.y, 70)
call VTexttag_Critical.create(Player(0),"Critical!",.x,.y+300, 70)
call VTexttag_HeadUp.create(Player(0),"HeadUp!",.x,.y-300, 70)
call VTexttag_Curved.create(Player(0),"Curved!",.x-200,.y-300, 70)
call VTexttag_Whirl.create(Player(0),"Whirl!",.x+200,.y-300, 70)
 
call VTexttag_Attach.create(.sheep,Player(1),"Attach!", 50)
call VTexttag_Inclined.create(Player(1),"Inclined!",.x-200,.y, 70)
call VTexttag_Jump.create(Player(1),"Jump!",.x+200,.y, 70)
call VTexttag_Critical.create(Player(1),"Critical!",.x,.y+300, 70)
call VTexttag_HeadUp.create(Player(1),"HeadUp!",.x,.y-300, 70)
call VTexttag_Curved.create(Player(1),"Curved!",.x-200,.y-300, 70)
call VTexttag_Whirl.create(Player(1),"Whirl!",.x+200,.y-300, 70)
endmethod
 
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0.325, true)
call TriggerAddAction(t, function thistype.onTimer)
set .x=GetRectCenterX(bj_mapInitialPlayableArea)
set .y=GetRectCenterY(bj_mapInitialPlayableArea)
set .sheep = CreateUnit(Player(0),'nsha',.x,.y,0)
endmethod
endstruct
endlibrary


Demo map
VTexttag Ver 2.1c Demo map

Special thank:
Nestharus, Tom_Kazansky
 

vuongkkk

New Member
Reaction score
1
Let see some screens of my VTT in demo map

97e1a4d7af26763db293cd0cd0f6514c314a31761c5b3217215fd227f5da23e26g.jpg
0d629bef2f29c7a971f275111e1664fad2b7c9e98d7813a79b7ad1e91ba1ed856g.jpg
5a69dcce74ea43900037add0d8975247e866b6c817e11761680a656be74a51806g.jpg
94195c6f787006168290b08636f06ea4fffa72136725b63d6727ed41fdbed31d6g.jpg
29d64ccd1e3255728a991a6f41a19ac343237b428f7ca5dc55ca86643724d0066g.jpg


They are screens then they are static. They look quite good in demo map
 

Deaod

Member
Reaction score
6
Im not sure i should even bother with this.

How about you try and not leak texttag instances when a user makes multiple calls to VTexttag.display() (in order to, for example, change the text of the texttag)?
Why do you even bother making the alpha channel available to the user? Have you even tested it? Hint: it doesnt work.
Your tick-counting is atrocious, whats so bad about using a real?
Why do you sanitize fadpoint values, but not lifetime values?
Why are there underscores in public facing functions?
Why is a user allowed direct access to the native texttag object? Doesnt that nullify the whole point of this library?
Why do you use degrees for angles (while nearly all other native functions use radians)?
 

vuongkkk

New Member
Reaction score
1
How about you try and not leak texttag instances when a user makes multiple calls to VTexttag.display() (in order to, for example, change the text of the texttag)
yep, at the beginning, i intented to re-use texttag and had multi-calls like you said.However, i have a bug with position of texttag is NOT at where I want. I will clear this problem soon.

Why do you even bother making the alpha channel available to the user?
Oh, i tested and knew what problem is. If you want to texttag fade out then have 2 case:
Case 1 Dont implement function change color
Case 1 Implement function change color and function change alpha.
Reason :
JASS:
native SetTextTagColor takes texttag t, integer red, integer green, integer blue, integer alpha returns nothing

So dont split two lovers, color and alpha. And i will fix it later.

Your tick-counting is atrocious, whats so bad about using a real?
Thanks, I forgot that because i always uses integer.

Why do you use degrees for angles (while nearly all other native functions use radians)
I think degrees is more friendly than radians. Do you known 34 degrees = ? radians :banghead: I dont know :confused:

Why is a user allowed direct access to the native texttag object? Doesnt that nullify the whole point of this library?
I want to you guys have full permission to modify data, except texttag. if you think it's not neccessary then i will modify system.:thup: OK ?

Why do you sanitize fadpoint values, but not lifetime values?
It is my fault :D

P/S: Thank for your comment. Maybe my system have many disadvantages that i dont know, help me to find them by more comments, please
 

Dirac

22710180
Reaction score
147
Radians work this way:
Pi=3.141592....
you can use [ljass]bj_PI[/ljass] to reffer to this constant in your script
Pi=180 degrees
Pi/2=90 degrees
Pi*2=360 degrees
34*[ljass]bj_DEGTORAD[/ljass]=34 degrees
Pi*[ljass]bj_RADTODEG[/ljass]=180 degrees
[ljass]bj_DEGTORAD[/ljass]=Pi/180
[ljass]bj_RADTODEG[/ljass]=180/Pi
[ljass]Cos()[/ljass] takes radians returns a number between -1 and 1
[ljass]Sin()[/ljass] same thing
 

vuongkkk

New Member
Reaction score
1
I can't handle if my system allow to multi-calls .display() because

Now, texttag in my sys change over time.To manipulate, i use T32. If a texttag do NOT "die", call .display() = call .startPeriodic() when VTexttag have called .stopPeriodic() => This is a error for sure
If i use the way of xecast does to store dummy, then i can't change texttag over time :banghead:
And i dont have another way to clear this issue :( SR

Now i know how Radians work. If i use radians as parameter to replace degrees, so you must calculate 34 degrees = ? radians before input parameter ... What do you want?
 

vuongkkk

New Member
Reaction score
1
Release Version 1.3

Release Version 1.3
  • System can recycle texttags. (Performance)
  • No need T32 more. (Independence)
  • System have two objs: config và runtime. (Mean)
    Config save attribute values of VTexttag, and runtime is the real texttag that is running.
  • Beside auto-destroy ability(.createA method),VTTConfig have normal mode(.create method)
  • Althought API, even the name of system changed but the meaning has NOT changed yet
  • Config should be create only one time (NOT remove),then we re-use later (only need call .display method to display texttag) and no need to create and setting again.


P/S You should use version 1.5, the lastest ver to be good ...... for yourself
 

Nestharus

o-o
Reaction score
84
If I decided to use a struct initializer or module initializer with this, it'd break.


Do proper ini please : (
 

vuongkkk

New Member
Reaction score
1
If I decided to use a struct initializer or module initializer with this, it'd break.
Do proper ini please : (

Want to create your own stylish texttag? Try to use code in CustomLib category in my demo map ver 1.5
Feel free to use a struct initializer or module initializer now, man ;)
 

Laiev

Hey Listen!!
Reaction score
188
I dont know how you used this well? Do you mean VTTConfig? Maybe have a example about your usage ?

put everthing that is in Init function inside a module and init by the struct... then implement it..

JASS:
private module A
    static method onInit takes nothing returns nothing
        //~~
    endmethod
endmodule

private struct B
    implement A
endstruct
 

vuongkkk

New Member
Reaction score
1
If that is I have tested and have no problem with that. This is test code
JASS:
struct VTTTester
    private static VTTConfig cfg
    private static real x
    private static real y
    
    static method onTimer takes nothing returns nothing
        call .cfg.display()
    endmethod
    
    private static method onInit takes nothing returns nothing
    local trigger t = CreateTrigger()
        set .cfg = VTTConfig.create()
        set .cfg.changeSize = Jump_ChangeSize
        call .cfg.setText("Test VTexttag", 9.00)
        call .cfg.setColor(25, 208, 24, 255)
        call .cfg.setVelocity(75.00, 80)
        set .cfg.fadepoint = 1.1
        set .cfg.lifetime = 2.0
        set .x=GetRectCenterX(bj_mapInitialPlayableArea)
        set .y=GetRectCenterY(bj_mapInitialPlayableArea)
        call .cfg.setPosition(thistype.x, thistype.y, 60)
    call TriggerRegisterTimerEvent(t, 2.0, true)
    call TriggerAddAction(t, function thistype.onTimer)
    endmethod
endstruct


Do you use the lastest version ??? Version 1.3 is very different from 1.2.
Or your mean is different, isn't it? So send me your test map
 

Laiev

Hey Listen!!
Reaction score
188
not in the struct, but use the way i show you to do the init function inside your system, because modules initialize before everything :|
 

vuongkkk

New Member
Reaction score
1
VTexttag system only have 2 block code used to init.
One in VTexttag trigger
I rewrited like that
JASS:
private struct VTTRuntime
    private static integer count = 0
    readonly texttag tt
    readonly integer data
    real age
    
    static method create takes integer data returns thistype
        local thistype new
        if Top > 0 then
            set Top=Top-1
            set new = thistype(DS[Top])
            call SetTextTagAge(new.tt,0)
            call SetTextTagSuspended(new.tt,false)
        else
            set .count=.count+1
            set new = thistype(.count)
            set new.tt=CreateTextTag()
        endif
        set new.data=data
        set new.age=0
        return new
    endmethod
    
    method release takes nothing returns nothing
        call SetTextTagVisibility(.tt,false)
        call SetTextTagSuspended(.tt,true)
        set DS[Top]=integer(this)
        set Top=Top+1
    endmethod
    
    private static method onInit takes nothing returns nothing
    local integer i=INIT_TEXTTAG_COUNT
    loop
        exitwhen (i==0)
            set .count=.count+1
            set DS[Top]=.count
            set thistype(.count).tt=CreateTextTag()
            set Top=Top+1
        set i=i-1
    endloop
    endmethod
endstruct


and one in TexttagControllers
It can write like i said above.

P/S: I'm a amateur coder and have less knowledge to write a good system:(
Hope you can say as much details as possible about what you mean
 

Laiev

Hey Listen!!
Reaction score
188
JASS:
private function Init takes nothing returns nothing
local integer i=INIT_TEXTTAG_COUNT
loop
    exitwhen (i==0)
        call VTTRuntime.prepare()
    set i=i-1
endloop
endfunction


>>

JASS:
private module A
    static method onInit takes nothing returns nothing
        local integer i=INIT_TEXTTAG_COUNT
        loop
            exitwhen (i==0)
            call VTTRuntime.prepare()
            set i=i-1
        endloop
    endmethod
endmodule

private struct B
    implement A
endstruct



and


JASS:
private function Init takes nothing returns nothing
    set NormalConfig = VTTConfig.create()
    call NormalConfig.setColor(65, 238, 34, 255)
    call NormalConfig.setVelocity(70.00, 90)
    set NormalConfig.fadepoint = 1.1
    set NormalConfig.lifetime = 2.6
    
    set JumpConfig = VTTConfig.create()
    set JumpConfig.changeSpeed= Jump_ChangeSpeed
    set JumpConfig.changeSize = Jump_ChangeSize
    set JumpConfig.changeBlue = Jump_ChangeBlue
    call JumpConfig.setColor(25, 208, 24, 255)
    call JumpConfig.setVelocity(65.00, 80)
    set JumpConfig.fadepoint = 1.1
    set JumpConfig.lifetime = 2.0
    
    set CriticalConfig = VTTConfig.create()
    set CriticalConfig.changeCustom = Critical_ChangeCustom
    call CriticalConfig.setColor(255, 23, 23, 255)
    call CriticalConfig.setVelocity(36.00, 90)
    set CriticalConfig.lifetime = 3.0
    
    set CurvedConfig = VTTConfig.create()
    set CurvedConfig.changeSize = Jump_ChangeSize
    set CurvedConfig.changeAngle= Curved_ChangeAngle
    set CurvedConfig.changeSpeed= Curved_ChangeSpeed
    call CurvedConfig.setColor(248, 237, 0, 255)
    call CurvedConfig.setVelocity(49.00, 90)
    set CurvedConfig.fadepoint = 1.1
    set CurvedConfig.lifetime = 2.0
endfunction


>>

JASS:
private module C
    private static method onInit takes nothing returns nothing
        set NormalConfig = VTTConfig.create()
        call NormalConfig.setColor(65, 238, 34, 255)
        call NormalConfig.setVelocity(70.00, 90)
        set NormalConfig.fadepoint = 1.1
        set NormalConfig.lifetime = 2.6
        
        set JumpConfig = VTTConfig.create()
        set JumpConfig.changeSpeed= Jump_ChangeSpeed
        set JumpConfig.changeSize = Jump_ChangeSize
        set JumpConfig.changeBlue = Jump_ChangeBlue
        call JumpConfig.setColor(25, 208, 24, 255)
        call JumpConfig.setVelocity(65.00, 80)
        set JumpConfig.fadepoint = 1.1
        set JumpConfig.lifetime = 2.0
        
        set CriticalConfig = VTTConfig.create()
        set CriticalConfig.changeCustom = Critical_ChangeCustom
        call CriticalConfig.setColor(255, 23, 23, 255)
        call CriticalConfig.setVelocity(36.00, 90)
        set CriticalConfig.lifetime = 3.0
        
        set CurvedConfig = VTTConfig.create()
        set CurvedConfig.changeSize = Jump_ChangeSize
        set CurvedConfig.changeAngle= Curved_ChangeAngle
        set CurvedConfig.changeSpeed= Curved_ChangeSpeed
        call CurvedConfig.setColor(248, 237, 0, 255)
        call CurvedConfig.setVelocity(49.00, 90)
        set CurvedConfig.fadepoint = 1.1
        set CurvedConfig.lifetime = 2.0
    endmethod
endmodule

private struct D
    implement C
endstruct


Why?

Because if I use your system oninit like this above, your system will bug because it is not initialized yet, struct with module initialize before anything else in vjass
 

vuongkkk

New Member
Reaction score
1
With the update of ver 1.4, now VTexttag can be used in a real map.
Maybe it is not a perfect system but i tried my best to work. So i guest you can you this system.

BTW, create a new style texttag is fun
 

vuongkkk

New Member
Reaction score
1
Update Ver 1.5
- changes API and code too (except func ###VTexttag_Create in TexttagControllers) then you need update VTexttag and TexttagControllers
- Recommend you guys use this ver for the best of performance
 

Bribe

vJass errors are legion
Reaction score
67
I don't think you have an idea about what kind of bloated trash this code will compile to.

You should learn more about function interfaces, how they compile, and how structs compile when you call methods from above their position.

This resource has a very messy API, off-topic function names and very poor description why it even requires so much overhead.

There are many good text tag utils libraries out there which operate just fine but with much less overhead.
 

vuongkkk

New Member
Reaction score
1
  1. what kind of bloated trash this code will compile to:You are total right about that. The size of map demo is lagger ~15kb than the origin system code size (~30kb)! However, all i care are: how fast it runs (the first priority) and how easy to use this system(the second priority)
  2. You should learn more about function interfaces, how they compile, and how structs compile when you call methods from above their position
    Ah, here is the problem: i uses vjass like a normal user, not a coder
  3. very poor description, it's the true. But how easy it is used and i used all funcs and methods have in VTexttag to create my owning styles of the texttag then i don't know to describe what.
    off-topic function names plz show me where they are and how to make it better !
  4. There are many good text tag utils libraries out there which operate just fine but with much less overhead
    I posted this resource because i did NOT find out any library that can create a texttag like my owning one.
P/S:
Function intefaces: it's the easiest method to change how texttag change
- If it's wrong then help me find out what is the best....
a very messy API
- Is it really bad so much? I tryed my best to name them near what they mean...

Anyway thank for your comment :D
 

vuongkkk

New Member
Reaction score
1
Big update: ver 2.0

Changelog
- Change all except the function name. Sure i'm not good at naming
- Added more description

=> Result
- Sure the code and the description are clear now
- How to use? I think it can't be easier...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top