comparison Libs/DF/normal_bar.lua @ 24:7a285d98b95f

- framework update.
author Tercio
date Mon, 14 Sep 2015 17:10:38 -0300
parents dbd417f413a8
children 6bb668a41455
comparison
equal deleted inserted replaced
23:52973d00a183 24:7a285d98b95f
507 ------------------------------------------------------------------------------------------------------------ 507 ------------------------------------------------------------------------------------------------------------
508 --> timer 508 --> timer
509 509
510 function BarMetaFunctions:OnTimerEnd() 510 function BarMetaFunctions:OnTimerEnd()
511 if (self.OnTimerEndHook) then 511 if (self.OnTimerEndHook) then
512 local interrupt = self.OnTimerEndHook() 512 local interrupt = self.OnTimerEndHook (self)
513 if (interrupt) then 513 if (interrupt) then
514 return 514 return
515 end 515 end
516 end 516 end
517 self.timer_texture:Hide() 517 self.timer_texture:Hide()
518 self.timer_textureR:Hide()
518 self.div_timer:Hide() 519 self.div_timer:Hide()
519 self:Hide() 520 self:Hide()
520 self.timer = false 521 self.timer = false
521 end 522 end
522 523
523 local OnUpdate = function (self, elapsed) 524 local OnUpdate = function (self, elapsed)
524 local timepct = (elapsed / self.tempo) * 100 525 --> percent of elapsed
525 self.c = self.c - (timepct*self.width/100) 526 local pct = abs (self.end_timer - GetTime() - self.tempo) / self.tempo
527 if (self.inverse) then
528 self.t:SetWidth (self.total_size * pct)
529 else
530 self.t:SetWidth (self.total_size * abs (pct-1))
531 end
532
533 --> right text
526 self.remaining = self.remaining - elapsed 534 self.remaining = self.remaining - elapsed
527 self.righttext:SetText (_math_floor (self.remaining)) 535 if (self.MyObject.RightTextIsTimer) then
528 self.timertexture:SetWidth (self.c) 536 self.righttext:SetText (DF:IntegerToTimer (self.remaining))
529 if (self.c < 1) then 537 else
538 self.righttext:SetText (_math_floor (self.remaining))
539 end
540
541 if (pct >= 1) then
542 self.righttext:SetText ("")
530 self:SetScript ("OnUpdate", nil) 543 self:SetScript ("OnUpdate", nil)
531 self.MyObject:OnTimerEnd() 544 self.MyObject:OnTimerEnd()
532 end 545 end
533 end 546 end
534 547
535 function BarMetaFunctions:SetTimer (tempo) 548 function BarMetaFunctions:SetTimer (tempo)
536 549
537 self.statusbar.width = self.statusbar:GetWidth() 550 -- o que é inverso
551 -- barra cheia
552 -- barra vazia
553 -- o que é left to right
554 -- barra que faz da direita pra esquerda
555 -- contrário
556
538 self.statusbar.tempo = tempo 557 self.statusbar.tempo = tempo
539 self.statusbar.remaining = tempo 558 self.statusbar.remaining = tempo
540 self.statusbar.c = self.statusbar.width 559 self.statusbar.total_size = self.statusbar:GetWidth()
541 560 self.statusbar.end_timer = GetTime() + tempo
542 self.timer_texture:Show() 561 self.statusbar.inverse = self.BarIsInverse
543 self.timer_texture:SetWidth (self.statusbar.width) 562
544 self.statusbar.t = self.timer_texture 563 self (0)
545 self (1)
546 564
547 self.div_timer:Show() 565 self.div_timer:Show()
548 self.background:Show() 566 self.background:Show()
549 self:Show() 567 self:Show()
550 568
569 if (self.LeftToRight) then
570 self.timer_texture:Hide()
571 self.timer_textureR:Show()
572 self.statusbar.t = self.timer_textureR
573 self.timer_textureR:ClearAllPoints()
574 self.timer_textureR:SetPoint ("right", self.statusbar, "right")
575 self.div_timer:SetPoint ("left", self.timer_textureR, "left", -14, -1)
576 else
577 self.timer_texture:Show()
578 self.timer_textureR:Hide()
579 self.statusbar.t = self.timer_texture
580 self.timer_texture:ClearAllPoints()
581 self.timer_texture:SetPoint ("left", self.statusbar, "left")
582 self.div_timer:SetPoint ("left", self.timer_texture, "right", -16, -1)
583 end
584
585 if (self.BarIsInverse) then
586 self.statusbar.t:SetWidth (1)
587 else
588 self.statusbar.t:SetWidth (self.statusbar.total_size)
589 end
590
551 self.timer = true 591 self.timer = true
552 592
553 self.statusbar:SetScript ("OnUpdate", OnUpdate) 593 DF:ScheduleTimer ("StartTimeBarAnimation", 0.1, self)
594 end
595
596 function DF:StartTimeBarAnimation (timebar)
597 timebar.statusbar:SetScript ("OnUpdate", OnUpdate)
554 end 598 end
555 599
556 ------------------------------------------------------------------------------------------------------------ 600 ------------------------------------------------------------------------------------------------------------
557 --> object constructor 601 --> object constructor
558 602
642 686
643 BarObject.timer_texture = _G [name .. "_timerTexture"] 687 BarObject.timer_texture = _G [name .. "_timerTexture"]
644 BarObject.timer_texture:SetWidth (w) 688 BarObject.timer_texture:SetWidth (w)
645 BarObject.timer_texture:SetHeight (h) 689 BarObject.timer_texture:SetHeight (h)
646 690
691 BarObject.timer_textureR = _G [name .. "_timerTextureR"]
692 BarObject.timer_textureR:Hide()
693
647 BarObject._texture = _G [name .. "_statusbarTexture"] 694 BarObject._texture = _G [name .. "_statusbarTexture"]
648 BarObject.background = _G [name .. "_background"] 695 BarObject.background = _G [name .. "_background"]
649 BarObject._icon = _G [name .. "_icon"] 696 BarObject._icon = _G [name .. "_icon"]
650 BarObject.textleft = _G [name .. "_TextLeft"] 697 BarObject.textleft = _G [name .. "_TextLeft"]
651 BarObject.textright = _G [name .. "_TextRight"] 698 BarObject.textright = _G [name .. "_TextRight"]