| 10-14-2009, 06:16 PM | #1 |
why does the f***ing texttag not show up?:globals constant real TT_HEIGHT=10 constant real TT_HEIGHT_OFFSET=10 constant integer TT_RED=255 constant integer TT_GREEN=255 constant integer TT_BLUE=255 constant integer TT_ALPHA=255 //Tried also with TT_ALPHA=0 constant force TT_SHOW_FORCE=GetPlayeresAll() endglobals function blah takes nothing returns nothing local texttag tt=CreateTextTag() local string temp="test" call SetTextTagText(tt,temp,TT_HEIGHT) call SetTextTagPosUnit(tt,this.base,TT_HEIGHT_OFFSET) call SetTextTagColor(tt,TT_RED,TT_GREEN,TT_BLUE,TT_ALPHA) call SetTextTagVisibility(tt,IsPlayerInForce(GetLocalPlayer(),TT_SHOW_FORCE)) endfunction the func is called, everything i can remember is done, but it doesn't show up ingame ![]() |
| 10-15-2009, 01:31 AM | #2 |
It might have to do with the height - height goes through 1 or two conversion factors, try using the BJ functions or imitating what they do precisely. |
| 10-15-2009, 07:33 AM | #3 |
Output of my documentation. (Link) JASS:
//: Sets the default textsize
//: of the texttag.
//: Note: This is the wc3 size,
//: not the normal word one,
//: so we recalculate it with
//: the formula.
TT_DEFAULT_SIZE = 7.5 * 0.023 / 10
a very very small number in wc3 format. Just add this JASS:* 0.023 / 10 If you have any questions about texttags further, just check my system. |
| 10-15-2009, 01:54 PM | #4 |
JASS:globals constant real TT_HEIGHT=10 constant real TT_HEIGHT_OFFSET=10 constant integer TT_RED=255 constant integer TT_GREEN=255 constant integer TT_BLUE=255 constant integer TT_ALPHA=255 //Tried also with TT_ALPHA=0 constant force TT_SHOW_FORCE=GetPlayeresAll() endglobals |
| 10-15-2009, 02:29 PM | #5 |
fixed prob of not showing up, but now...look for your self Full code of TBars:library TBar initializer Init uses ARGB globals //Bar-constants constant real MIXFACTOR =0.5 constant string FULLCHAR_G ="I" constant string EMPTYCHAR_G =" " constant string FULLCHAR_T ="'" constant string EMPTYCHAR_T ="'" constant string STARTCHAR_G ="#" constant string ENDCHAR_G ="#" constant string STARTCHAR_T ="" constant string ENDCHAR_T ="" //TextBar-constants constant integer BARMAX =4 constant real TT_HEIGHT =9 constant real TT_HEIGHT_OFFSET =10 constant force TT_SHOW_FORCE =bj_FORCE_ALL_PLAYERS constant integer TT_RED =255 constant integer TT_GREEN =255 constant integer TT_BLUE =255 constant integer TT_ALPHA =255 //Update-constant constant real UPDATE_PERIOD =0.10 endglobals //!DO NOT CHANGE ANYTHING BELOW THIS LINE globals private timer UPDATER=CreateTimer() private TextBar array TXTBARS private integer TXTBARmax //Function-constants private Bar FUNCTION_BAR private unit FUNCTION_UNIT endglobals private function GetUnitTextBar takes unit u returns TextBar local integer i=0 loop exitwhen i>TXTBARmax if TXTBARS[i].getBase()==u then return TXTBARS[i] endif set i=i+1 endloop return 0 endfunction private function RegisterUnit takes unit u returns boolean local TextBar tb=GetUnitTextBar(u) if tb!=0 then return false endif set TXTBARS[TXTBARmax]=TextBar.create(u) set TXTBARmax=TXTBARmax+1 return true endfunction private function DeregisterUnit takes unit u returns boolean local TextBar tb=GetUnitTextBar(u) local integer i=0 if tb==0 then return false endif call tb.remove() loop exitwhen i>TXTBARmax if TXTBARS[i]==0 or TXTBARS[i]==null then set TXTBARS[i]=TXTBARS[i+1] set TXTBARS[i+1]=0 endif set i=i+1 endloop set TXTBARmax=TXTBARmax-1 return true endfunction //! USEABLE FUNCTIONS function UnitAddBar takes unit u, string name, real max, ARGB startcol, ARGB endcol,integer length, boolean gradient, boolean full, barfunc UpdateFunc returns nothing call GetUnitTextBar(u).addBar(Bar.create(name,max,startcol,endcol,length,gradient,full,UpdateFunc)) call BJDebugMsg("Bar added") endfunction function UnitRemoveBarById takes unit u, integer id returns nothing local TextBar tb=GetUnitTextBar(u) call tb.remBar(tb.getBarById(id)) endfunction function UnitRemoveBarByName takes unit u, string name returns nothing local TextBar tb=GetUnitTextBar(u) call tb.remBar(tb.getBarByName(name)) endfunction function GetBarUnit takes nothing returns unit return FUNCTION_UNIT endfunction function GetBar takes nothing returns Bar return FUNCTION_BAR endfunction //! textmacro FUNC takes NAME,TYPE function SetBar$NAME$ takes $TYPE$ new returns nothing call FUNCTION_BAR.set$NAME$(new) endfunction function GetBar$NAME$ takes nothing returns $TYPE$ return FUNCTION_BAR.get$NAME$() endfunction //! endtextmacro //! runtextmacro FUNC("Name","string") //! runtextmacro FUNC("Max","real") //! runtextmacro FUNC("Current","real") //! runtextmacro FUNC("StartColor","ARGB") //! runtextmacro FUNC("EndColor","ARGB") //! runtextmacro FUNC("Length","integer") //! runtextmacro FUNC("Gradient","boolean") //! USEABLE FUNCTIONS struct TextBar private unit base private texttag tt private Bar array Bars[BARMAX] private integer used static method create takes unit u returns TextBar local TextBar this=TextBar.allocate() set this.base=u set this.used=0 // set this.tt=CreateTextTag() return this endmethod method addBar takes Bar b returns boolean if this.used+1>=BARMAX then return false endif set this.Bars[this.used]=b set this.used=this.used+1 return true endmethod method remBar takes Bar b returns boolean local integer i=0 local boolean rem=false loop exitwhen i>this.used if this.Bars[i]==b then call this.Bars[i].remove() set rem=true endif set i=i+1 endloop if rem then set i=0 loop exitwhen i>this.used if this.Bars[i]==0 or this.Bars[i]==null then set this.Bars[i]=this.Bars[i+1] set this.Bars[i+1]=0 endif set i=i+1 endloop set this.used=this.used-1 endif return rem endmethod // method update takes nothing returns nothing // local integer i=0 // local string temp="" // set FUNCTION_UNIT=this.base // loop // exitwhen i>this.used // if temp!="" and i!=this.used then // set temp=temp+"|n" // endif // set temp=this.Bars[i].update() // set i=i+1 // endloop // call SetTextTagText(this.tt,temp,TT_HEIGHT) // call SetTextTagPosUnit(this.tt,this.base,TT_HEIGHT_OFFSET) // call SetTextTagColor(this.tt,TT_RED,TT_GREEN,TT_BLUE,TT_ALPHA) // call SetTextTagVisibility(this.tt,IsPlayerInForce(GetLocalPlayer(),TT_SHOW_FORCE)) // endmethod method update takes nothing returns nothing local integer i=0 local string temp="" call DestroyTextTag(this.tt) set FUNCTION_UNIT=this.base loop exitwhen i>this.used if temp!="" and i!=this.used then set temp=temp+"|n" endif set temp=temp+this.Bars[i].update() set i=i+1 endloop set this.tt=CreateTextTagUnitBJ(temp,this.base,TT_HEIGHT_OFFSET,TT_HEIGHT,TT_RED,TT_GREEN,TT_BLUE,TT_ALPHA) // call SetTextTagVisibility(this.tt,IsPlayerInForce(GetLocalPlayer(),TT_SHOW_FORCE)) call SetTextTagVisibility(this.tt,true) endmethod method remove takes nothing returns nothing local integer i=0 loop exitwhen i>BARMAX call this.Bars[i].remove() set i=i+1 endloop set this.base=null set this.used=0 call DestroyTextTag(this.tt) call this.destroy() endmethod method getBarById takes integer id returns Bar return this.Bars[id] endmethod method getBarByName takes string name returns Bar local integer i=0 loop exitwhen i>this.used if this.Bars[i].getName()==name then return this.Bars[i] endif set i=i+1 endloop return 0 endmethod method getBase takes nothing returns unit return this.base endmethod method getUsed takes nothing returns integer return this.used endmethod endstruct //! textmacro SETGET takes NAME, name, TYPE method set$NAME$ takes $TYPE$ new returns nothing set this.$name$=new endmethod method get$NAME$ takes nothing returns $TYPE$ return this.$name$ endmethod //! endtextmacro struct Bar private string name private real max private real cur private ARGB startcol private ARGB endcol private integer length private boolean gradient private barfunc UpdateFunc static method create takes string n, real m, ARGB sc, ARGB ec,integer l, boolean g, boolean full, barfunc UF returns Bar local Bar this=Bar.allocate() set this.name=n set this.max=m if full then set this.cur=m else set this.cur=0.0 endif set this.startcol=sc set this.endcol=ec set this.length=l set this.gradient=g set this.UpdateFunc=UF return this endmethod method update takes nothing returns string local integer percentage=R2I((this.cur/this.max)*this.length) local integer i=0 local string temp="" local ARGB charcol set FUNCTION_BAR=this call this.UpdateFunc.evaluate() if this.max<this.cur then set this.cur=this.max endif if this.gradient then loop exitwhen i>this.length set charcol=ARGB.mix(this.startcol,this.endcol,MIXFACTOR) if i<=percentage then set temp=temp+charcol.str(FULLCHAR_G) else set temp=temp+EMPTYCHAR_G endif set i=i+1 endloop return this.name+STARTCHAR_G+temp+ENDCHAR_G else loop exitwhen i>this.length if i<=percentage then set temp=temp+this.startcol.str(FULLCHAR_T) else set temp=temp+this.endcol.str(EMPTYCHAR_T) endif set i=i+1 endloop return this.name+STARTCHAR_T+temp+ENDCHAR_T endif return "" endmethod method remove takes nothing returns nothing set this.name="" set this.max=0.0 set this.cur=0.0 set this.startcol=0 set this.endcol=0 set this.length=0 set this.gradient=false set this.UpdateFunc=0 call this.destroy() endmethod //! runtextmacro SETGET("Name","name","string") //! runtextmacro SETGET("Max","max","real") //! runtextmacro SETGET("Current","cur","real") //! runtextmacro SETGET("StartColor","startcol","ARGB") //! runtextmacro SETGET("EndColor","endcol","ARGB") //! runtextmacro SETGET("Length","length","integer") //! runtextmacro SETGET("Gradient","gradient","boolean") endstruct function interface barfunc takes nothing returns nothing private function Update takes nothing returns nothing local integer i=0 loop exitwhen i>TXTBARmax call TXTBARS[i].update() set i=i+1 endloop call BJDebugMsg(I2S(TXTBARmax)+" Bars") endfunction private function Rem takes nothing returns nothing call DeregisterUnit(GetTriggerUnit()) call BJDebugMsg(GetUnitName(GetTriggerUnit())+" deregistrated") endfunction private function Add takes nothing returns nothing call RegisterUnit(GetTriggerUnit()) call BJDebugMsg(GetUnitName(GetTriggerUnit())+" registrated") endfunction private function Init takes nothing returns nothing local trigger RemTrigger=CreateTrigger() local trigger AddTrigger=CreateTrigger() set TXTBARmax=0 call TimerStart(UPDATER,UPDATE_PERIOD,true,function Update) call TriggerRegisterLeaveRectSimple(RemTrigger, bj_mapInitialPlayableArea) call TriggerAddAction( RemTrigger, function Rem ) call TriggerRegisterAnyUnitEventBJ(AddTrigger, EVENT_PLAYER_UNIT_DEATH) call TriggerAddAction( AddTrigger, function Add) endfunction endlibrary Doing: now some strange bars appear and he's performing random actions Should do: One bar named "GradientBar" and one named "StaticBar" should at least appear for the mountainking the bars value depends on the units stat (one Bar depends on Life, the other one on Mana of the mountainking) help is needed an welcome |
| 10-15-2009, 03:39 PM | #6 |
Just one question? How is your system better as mine? You have just removed all my default stuff, and made everything in a few function calls only, which really sucks horribly. As for the problem, I am checking it right now. Edit: JASS:call this.UpdateFunc.evaluate() Edit2: Yours is worse, compared to mine. Sorry for being rough, I just see that its not giving you anything better, but removing much of my functionality I wanted the user to allow. Edit3: JASS:function HP takes nothing returns nothing local unit u=GetBarUnit() call SetBarMax(GetUnitState(u,UNIT_STATE_MAX_LIFE)) call SetBarCurrent(GetUnitState(u,UNIT_STATE_LIFE)) call BJDebugMsg("HP") endfunction function MP takes nothing returns nothing local unit u=GetBarUnit() call SetBarMax(GetUnitState(u,UNIT_STATE_MAX_MANA)) call SetBarCurrent(GetUnitState(u,UNIT_STATE_MANA)) call BJDebugMsg("MP") endfunction function Actions takes nothing returns nothing local unit u= CreateUnit(Player(0),'Hmkg',0.0,0.0,0.0) call UnitAddBar(u, "GradientBar: ",GetUnitState(u,UNIT_STATE_MAX_LIFE), ARGB.create(255,255,0,0), ARGB.create(255,0,255,0),25,true, true, HP) call UnitAddBar(u, "StaticBar: ",GetUnitState(u,UNIT_STATE_MAX_MANA), ARGB.create(255,255,0,0), ARGB.create(255,0,255,0),25,false, true, MP) endfunction //=========================================================================== function InitTrig_Demo takes nothing returns nothing set gg_trg_Demo = CreateTrigger( ) call TriggerRegisterTimerEventSingle( gg_trg_Demo, 1.00 ) call TriggerAddAction( gg_trg_Demo, function Actions ) endfunction JASS:globals private timer UPDATER=CreateTimer() private TextBar array TXTBARS private integer TXTBARmax //Function-constants private Bar FUNCTION_BAR private unit FUNCTION_UNIT endglobals Initialize that stuff, so its... JASS:globals private timer UPDATER=CreateTimer() private TextBar array TXTBARS private integer TXTBARmax = 0 //Function-constants private Bar FUNCTION_BAR = 0 private unit FUNCTION_UNIT = null endglobals |
| 10-15-2009, 03:53 PM | #7 | |||
The only funcs the user has to use are JASS:function UnitAddBar takes unit u, string name, real max, ARGB startcol, ARGB endcol,integer length, boolean gradient, boolean full, barfunc UpdateFunc returns nothing call GetUnitTextBar(u).addBar(Bar.create(name,max,startcol,endcol,length,gradient,full,UpdateFunc)) call BJDebugMsg("Bar added") endfunction function UnitRemoveBarById takes unit u, integer id returns nothing local TextBar tb=GetUnitTextBar(u) call tb.remBar(tb.getBarById(id)) endfunction function UnitRemoveBarByName takes unit u, string name returns nothing local TextBar tb=GetUnitTextBar(u) call tb.remBar(tb.getBarByName(name)) endfunction function GetBarUnit takes nothing returns unit return FUNCTION_UNIT endfunction function GetBar takes nothing returns Bar return FUNCTION_BAR endfunction //! textmacro FUNC takes NAME,TYPE function SetBar$NAME$ takes $TYPE$ new returns nothing call FUNCTION_BAR.set$NAME$(new) endfunction function GetBar$NAME$ takes nothing returns $TYPE$ return FUNCTION_BAR.get$NAME$() endfunction //! endtextmacro //! runtextmacro FUNC("Name","string") //! runtextmacro FUNC("Max","real") //! runtextmacro FUNC("Current","real") //! runtextmacro FUNC("StartColor","ARGB") //! runtextmacro FUNC("EndColor","ARGB") //! runtextmacro FUNC("Length","integer") //! runtextmacro FUNC("Gradient","boolean") and all except the first three funcs are only used for the UpdateFuncs Quote:
they return nothing --> nothing to save Quote:
In my oppinion to much defaults only confuse the user, when setting up a system and you've to set hundrets of Defaults, you get only confused. what's wrong with only having 1 func to call? Quote:
It has not to be functional, it has to show x bars for a unit and nothing more. Due to the fact that I need it for my MOW-project it has to be foolproof, cause some of my helpers have even problemes with GUI --> being foolproof is important for this sys |
| 10-15-2009, 03:58 PM | #8 | |||||
Quote:
Quote:
Quote:
Quote:
Btw, you can't do that with your system. How can the user fade texttags with your system? Or get the texttagtext? Quote:
|
| 10-15-2009, 04:54 PM | #9 | ||||
Quote:
Quote:
Quote:
He doesn't need to get the texttag's text and fading for always present bars? Quote:
|
| 10-15-2009, 05:55 PM | #10 |
Deaod's is actually incredibly intuitive. I would use it before Anachron's or yours, personally. |
| 10-15-2009, 07:49 PM | #11 | |
Quote:
|
| 10-15-2009, 07:56 PM | #12 |
The word advanced being used in a sentence to describe something without support means nothing. Deaod's does everything it needs to do and does it well and in a way that is easy to understand. That's as 'advanced' as it should be. |
| 10-15-2009, 07:58 PM | #13 | |
Quote:
hrrmpf..... |
| 10-16-2009, 07:41 AM | #14 | |
Quote:
|
