Mercurial > wow > hansgar_and_franzok_assist
comparison Libs/DF/normal_bar.lua @ 25:6bb668a41455
- framework update.
| author | Tercio |
|---|---|
| date | Thu, 08 Oct 2015 11:52:43 -0300 |
| parents | 7a285d98b95f |
| children | 5da06cb420d4 |
comparison
equal
deleted
inserted
replaced
| 24:7a285d98b95f | 25:6bb668a41455 |
|---|---|
| 195 local _value1, _value2, _value3, _value4 = DF:ParseColors (_value) | 195 local _value1, _value2, _value3, _value4 = DF:ParseColors (_value) |
| 196 | 196 |
| 197 _object.statusbar:SetStatusBarColor (_value1, _value2, _value3, _value4) | 197 _object.statusbar:SetStatusBarColor (_value1, _value2, _value3, _value4) |
| 198 _object._texture.original_colors = {_value1, _value2, _value3, _value4} | 198 _object._texture.original_colors = {_value1, _value2, _value3, _value4} |
| 199 _object.timer_texture:SetVertexColor (_value1, _value2, _value3, _value4) | 199 _object.timer_texture:SetVertexColor (_value1, _value2, _value3, _value4) |
| 200 | |
| 201 _object.timer_textureR:SetVertexColor (_value1, _value2, _value3, _value4) | |
| 202 | |
| 200 return _object._texture:SetVertexColor (_value1, _value2, _value3, _value4) | 203 return _object._texture:SetVertexColor (_value1, _value2, _value3, _value4) |
| 201 end | 204 end |
| 202 --> icon | 205 --> icon |
| 203 local smember_icon = function (_object, _value) | 206 local smember_icon = function (_object, _value) |
| 204 if (type (_value) == "table") then | 207 if (type (_value) == "table") then |
| 216 local smember_texture = function (_object, _value) | 219 local smember_texture = function (_object, _value) |
| 217 if (type (_value) == "table") then | 220 if (type (_value) == "table") then |
| 218 local _value1, _value2 = _unpack (_value) | 221 local _value1, _value2 = _unpack (_value) |
| 219 _object._texture:SetTexture (_value1) | 222 _object._texture:SetTexture (_value1) |
| 220 _object.timer_texture:SetTexture (_value1) | 223 _object.timer_texture:SetTexture (_value1) |
| 224 _object.timer_textureR:SetTexture (_value1) | |
| 221 if (_value2) then | 225 if (_value2) then |
| 222 _object._texture:SetTexCoord (_unpack (_value2)) | 226 _object._texture:SetTexCoord (_unpack (_value2)) |
| 223 _object.timer_texture:SetTexCoord (_unpack (_value2)) | 227 _object.timer_texture:SetTexCoord (_unpack (_value2)) |
| 228 _object.timer_textureR:SetTexCoord (_unpack (_value2)) | |
| 224 end | 229 end |
| 225 else | 230 else |
| 226 if (_value:find ("\\")) then | 231 if (_value:find ("\\")) then |
| 227 _object._texture:SetTexture (_value) | 232 _object._texture:SetTexture (_value) |
| 228 else | 233 else |
| 229 local file = SharedMedia:Fetch ("statusbar", _value) | 234 local file = SharedMedia:Fetch ("statusbar", _value) |
| 230 if (file) then | 235 if (file) then |
| 231 _object._texture:SetTexture (file) | 236 _object._texture:SetTexture (file) |
| 232 _object.timer_texture:SetTexture (file) | 237 _object.timer_texture:SetTexture (file) |
| 238 _object.timer_textureR:SetTexture (file) | |
| 233 else | 239 else |
| 234 _object._texture:SetTexture (_value) | 240 _object._texture:SetTexture (_value) |
| 235 _object.timer_texture:SetTexture (_value) | 241 _object.timer_texture:SetTexture (_value) |
| 242 _object.timer_textureR:SetTexture (_value) | |
| 236 end | 243 end |
| 237 end | 244 end |
| 238 end | 245 end |
| 239 return | 246 return |
| 240 end | 247 end |
| 519 self.div_timer:Hide() | 526 self.div_timer:Hide() |
| 520 self:Hide() | 527 self:Hide() |
| 521 self.timer = false | 528 self.timer = false |
| 522 end | 529 end |
| 523 | 530 |
| 531 function BarMetaFunctions:CancelTimerBar (no_timer_end) | |
| 532 if (not self.HasTimer) then | |
| 533 return | |
| 534 end | |
| 535 if (self.TimerScheduled) then | |
| 536 DF:CancelTimer (self.TimerScheduled) | |
| 537 self.TimerScheduled = nil | |
| 538 else | |
| 539 if (self.statusbar:GetScript ("OnUpdate")) then | |
| 540 self.statusbar:SetScript ("OnUpdate", nil) | |
| 541 end | |
| 542 end | |
| 543 self.righttext = "" | |
| 544 if (not no_timer_end) then | |
| 545 self:OnTimerEnd() | |
| 546 end | |
| 547 end | |
| 548 | |
| 524 local OnUpdate = function (self, elapsed) | 549 local OnUpdate = function (self, elapsed) |
| 525 --> percent of elapsed | 550 --> percent of elapsed |
| 526 local pct = abs (self.end_timer - GetTime() - self.tempo) / self.tempo | 551 local pct = abs (self.end_timer - GetTime() - self.tempo) / self.tempo |
| 527 if (self.inverse) then | 552 if (self.inverse) then |
| 528 self.t:SetWidth (self.total_size * pct) | 553 self.t:SetWidth (self.total_size * pct) |
| 539 end | 564 end |
| 540 | 565 |
| 541 if (pct >= 1) then | 566 if (pct >= 1) then |
| 542 self.righttext:SetText ("") | 567 self.righttext:SetText ("") |
| 543 self:SetScript ("OnUpdate", nil) | 568 self:SetScript ("OnUpdate", nil) |
| 569 self.MyObject.HasTimer = nil | |
| 544 self.MyObject:OnTimerEnd() | 570 self.MyObject:OnTimerEnd() |
| 545 end | 571 end |
| 546 end | 572 end |
| 547 | 573 |
| 548 function BarMetaFunctions:SetTimer (tempo) | 574 function BarMetaFunctions:SetTimer (tempo, end_at) |
| 549 | 575 |
| 550 -- o que é inverso | 576 if (end_at) then |
| 551 -- barra cheia | 577 self.statusbar.tempo = end_at - tempo |
| 552 -- barra vazia | 578 self.statusbar.remaining = end_at - GetTime() |
| 553 -- o que é left to right | 579 self.statusbar.end_timer = end_at |
| 554 -- barra que faz da direita pra esquerda | 580 else |
| 555 -- contrário | 581 self.statusbar.tempo = tempo |
| 556 | 582 self.statusbar.remaining = tempo |
| 557 self.statusbar.tempo = tempo | 583 self.statusbar.end_timer = GetTime() + tempo |
| 558 self.statusbar.remaining = tempo | 584 end |
| 585 | |
| 559 self.statusbar.total_size = self.statusbar:GetWidth() | 586 self.statusbar.total_size = self.statusbar:GetWidth() |
| 560 self.statusbar.end_timer = GetTime() + tempo | |
| 561 self.statusbar.inverse = self.BarIsInverse | 587 self.statusbar.inverse = self.BarIsInverse |
| 562 | 588 |
| 563 self (0) | 589 self (0) |
| 564 | 590 |
| 565 self.div_timer:Show() | 591 self.div_timer:Show() |
| 588 self.statusbar.t:SetWidth (self.statusbar.total_size) | 614 self.statusbar.t:SetWidth (self.statusbar.total_size) |
| 589 end | 615 end |
| 590 | 616 |
| 591 self.timer = true | 617 self.timer = true |
| 592 | 618 |
| 593 DF:ScheduleTimer ("StartTimeBarAnimation", 0.1, self) | 619 self.HasTimer = true |
| 620 self.TimerScheduled = DF:ScheduleTimer ("StartTimeBarAnimation", 0.1, self) | |
| 594 end | 621 end |
| 595 | 622 |
| 596 function DF:StartTimeBarAnimation (timebar) | 623 function DF:StartTimeBarAnimation (timebar) |
| 624 timebar.TimerScheduled = nil | |
| 597 timebar.statusbar:SetScript ("OnUpdate", OnUpdate) | 625 timebar.statusbar:SetScript ("OnUpdate", OnUpdate) |
| 598 end | 626 end |
| 599 | 627 |
| 600 ------------------------------------------------------------------------------------------------------------ | 628 ------------------------------------------------------------------------------------------------------------ |
| 601 --> object constructor | 629 --> object constructor |
| 714 if (texture_name) then | 742 if (texture_name) then |
| 715 smember_texture (BarObject, texture_name) | 743 smember_texture (BarObject, texture_name) |
| 716 end | 744 end |
| 717 | 745 |
| 718 return BarObject | 746 return BarObject |
| 719 end | 747 end --endd |
