|
| 1 | +--[[ |
| 2 | + Copyright (C) 2006-2007 Nymbia |
| 3 | +
|
| 4 | + This program is free software; you can redistribute it and/or modify |
| 5 | + it under the terms of the GNU General Public License as published by |
| 6 | + the Free Software Foundation; either version 2 of the License, or |
| 7 | + (at your option) any later version. |
| 8 | +
|
| 9 | + This program is distributed in the hope that it will be useful, |
| 10 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + GNU General Public License for more details. |
| 13 | +
|
| 14 | + You should have received a copy of the GNU General Public License along |
| 15 | + with this program; if not, write to the Free Software Foundation, Inc., |
| 16 | + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 17 | +]] |
| 18 | +if Quartz:HasModule('Flight') then |
| 19 | + return |
| 20 | +end |
| 21 | + |
| 22 | +local L = AceLibrary("AceLocale-2.2"):new("Quartz") |
| 23 | + |
| 24 | +local Quartz = Quartz |
| 25 | +local QuartzFlight = Quartz:NewModule('Flight', 'AceHook-2.1', 'AceEvent-2.0') |
| 26 | +local QuartzPlayer = Quartz:GetModule('Player') |
| 27 | +local db |
| 28 | +function QuartzFlight:OnInitialize() |
| 29 | + db = Quartz:AcquireDBNamespace("Flight") |
| 30 | + Quartz:RegisterDefaults("Flight", "profile", { |
| 31 | + color = {0.7, 1, 0.7}, |
| 32 | + deplete = false, |
| 33 | + }) |
| 34 | +end |
| 35 | +if InFlight then |
| 36 | + function QuartzFlight:OnEnable() |
| 37 | + LoadAddOn('InFlight') --!!delete |
| 38 | + self:Hook(InFlight, "StartTimer") |
| 39 | + end |
| 40 | + function QuartzFlight:StartTimer(object, ...) |
| 41 | + self.hooks[object].StartTimer(object, ...) |
| 42 | + |
| 43 | + local f = InFlightBar |
| 44 | + local _, duration = f:GetMinMaxValues() |
| 45 | + local _, locText = f:GetRegions() |
| 46 | + local destination = locText:GetText() |
| 47 | + |
| 48 | + self:BeginFlight(duration, destination) |
| 49 | + end |
| 50 | +elseif ToFu then |
| 51 | + function QuartzFlight:OnEnable() |
| 52 | + self:RegisterEvent("ToFu_StartFlight") |
| 53 | + end |
| 54 | + function QuartzFlight:ToFu_StartFlight(start, destination, duration) |
| 55 | + if duration and duration > 0 then |
| 56 | + self:BeginFlight(duration, destination) |
| 57 | + end |
| 58 | + end |
| 59 | +elseif FlightMapTimes_BeginFlight then |
| 60 | + function QuartzFlight:OnEnable() |
| 61 | + self:Hook("FlightMapTimes_BeginFlight") |
| 62 | + end |
| 63 | + function QuartzFlight:FlightMapTimes_BeginFlight(duration, destination) |
| 64 | + if duration and duration > 0 then |
| 65 | + self:BeginFlight(duration, destination) |
| 66 | + end |
| 67 | + return self.hooks.FlightMapTimes_BeginFlight(duration, destination) |
| 68 | + end |
| 69 | +end |
| 70 | +function QuartzFlight:BeginFlight(duration, destination) |
| 71 | + QuartzPlayer.casting = true |
| 72 | + QuartzPlayer.startTime = GetTime() |
| 73 | + QuartzPlayer.endTime = GetTime() + duration |
| 74 | + QuartzPlayer.delay = 0 |
| 75 | + QuartzPlayer.fadeOut = nil |
| 76 | + if db.profile.deplete then |
| 77 | + QuartzPlayer.casting = nil |
| 78 | + QuartzPlayer.channeling = true |
| 79 | + else |
| 80 | + QuartzPlayer.casting = true |
| 81 | + QuartzPlayer.channeling = nil |
| 82 | + end |
| 83 | + |
| 84 | + QuartzPlayer.castBar:SetStatusBarColor(unpack(db.profile.color)) |
| 85 | + |
| 86 | + QuartzPlayer.castBar:SetValue(0) |
| 87 | + QuartzPlayer.castBarParent:Show() |
| 88 | + QuartzPlayer.castBarParent:SetAlpha(QuartzPlayer.db.profile.alpha) |
| 89 | + |
| 90 | + QuartzPlayer.castBarSpark:Show() |
| 91 | + QuartzPlayer.castBarIcon:SetTexture(nil) |
| 92 | + QuartzPlayer.castBarText:SetText(destination) |
| 93 | + |
| 94 | + local position = QuartzPlayer.db.profile.timetextposition |
| 95 | + if position == L["Cast Start Side"] then |
| 96 | + QuartzPlayer.castBarTimeText:SetPoint('LEFT', QuartzPlayer.castBar, 'LEFT', QuartzPlayer.db.profile.timetextx, QuartzPlayer.db.profile.timetexty) |
| 97 | + QuartzPlayer.castBarTimeText:SetJustifyH("LEFT") |
| 98 | + elseif position == L["Cast End Side"] then |
| 99 | + QuartzPlayer.castBarTimeText:SetPoint('RIGHT', QuartzPlayer.castBar, 'RIGHT', -1 * QuartzPlayer.db.profile.timetextx, QuartzPlayer.db.profile.timetexty) |
| 100 | + QuartzPlayer.castBarTimeText:SetJustifyH("RIGHT") |
| 101 | + end |
| 102 | +end |
| 103 | +do |
| 104 | + local function setcolor(field, ...) |
| 105 | + db.profile[field] = {...} |
| 106 | + Quartz.ApplySettings() |
| 107 | + end |
| 108 | + local function getcolor(field) |
| 109 | + return unpack(db.profile[field]) |
| 110 | + end |
| 111 | + local function set(field, value) |
| 112 | + db.profile[field] = value |
| 113 | + Quartz.ApplySettings() |
| 114 | + end |
| 115 | + local function get(field) |
| 116 | + return db.profile[field] |
| 117 | + end |
| 118 | + Quartz.options.args.Flight = { |
| 119 | + type = 'group', |
| 120 | + name = L["Flight"], |
| 121 | + desc = L["Flight"], |
| 122 | + order = 600, |
| 123 | + args = { |
| 124 | + toggle = { |
| 125 | + type = 'toggle', |
| 126 | + name = L["Enable"], |
| 127 | + desc = L["Enable"], |
| 128 | + get = function() |
| 129 | + return Quartz:IsModuleActive('Flight') |
| 130 | + end, |
| 131 | + set = function(v) |
| 132 | + Quartz:ToggleModuleActive('Flight', v) |
| 133 | + end, |
| 134 | + order = 100, |
| 135 | + }, |
| 136 | + color = { |
| 137 | + type = 'color', |
| 138 | + name = L["Flight Map Color"], |
| 139 | + desc = L["Set the color to turn the cast bar when taking a flight path"], |
| 140 | + get = getcolor, |
| 141 | + set = setcolor, |
| 142 | + passValue = 'color', |
| 143 | + order = 101, |
| 144 | + }, |
| 145 | + deplete = { |
| 146 | + type = 'toggle', |
| 147 | + name = L["Deplete"], |
| 148 | + desc = L["Deplete"], |
| 149 | + get = get, |
| 150 | + set = set, |
| 151 | + passValue = 'deplete', |
| 152 | + order = 102, |
| 153 | + }, |
| 154 | + }, |
| 155 | + } |
| 156 | +end |
0 commit comments