annotate Hansgar_And_Franzok_Assist.lua @ 12:6dd01dcec75e

- Lib Update.
author Tercio
date Sat, 25 Apr 2015 14:13:17 -0300
parents 2f09fe4be15c
children f635adb94909
rev   line source
Tercio@11 1
Tercio@11 2 local DF = _G ["DetailsFramework"]
Tercio@11 3 if (not DF) then
Tercio@11 4 print ("|cFFFFAA00Please restart your client to finish update some AddOns.|c")
Tercio@11 5 return
Tercio@11 6 end
Tercio@11 7
Tercio@0 8 local floor = floor
Tercio@0 9 local min = min
Tercio@0 10 local UnitExists = UnitExists
Tercio@0 11 local GetPlayerMapPosition = GetPlayerMapPosition
Tercio@0 12 local UnitHealth = UnitHealth
Tercio@4 13 local GetNumGroupMembers = GetNumGroupMembers
Tercio@4 14 local abs = abs
Tercio@6 15 local GetPlayerFacing = GetPlayerFacing
Tercio@11 16 local db
Tercio@11 17 local _
Tercio@0 18
Tercio@11 19 --local f = CreateFrame ("frame", "Hansgar_And_Franzok_Assist", UIParent)
Tercio@11 20 local f = DF:Create1PxPanel (_, 155, 166, "Hans & Franz", "Hansgar_And_Franzok_Assist", nil, "top") --
Tercio@0 21 f:SetFrameStrata ("DIALOG")
Tercio@11 22 f.version = "v0.12"
Tercio@11 23
Tercio@11 24 f.Close:SetScript ("OnClick", function (self)
Tercio@11 25 if (f.StampersPhase) then
Tercio@11 26 return f:StopTracking()
Tercio@11 27 end
Tercio@11 28 f:EndTrackPlayerPosition()
Tercio@11 29 end)
Tercio@11 30
Tercio@11 31 f.Lock:SetScript ("OnClick", function (self)
Tercio@11 32 if (db.FRAME_LOCK) then
Tercio@11 33 f:SetLockState()
Tercio@11 34 print ("|cFFFFAA00Hansgar and Franzok Assist|r frame unlocked.")
Tercio@11 35
Tercio@11 36 f.unlocked_frame = true
Tercio@11 37 f.player_pos_frame:Show()
Tercio@11 38 f.player_bar:Show()
Tercio@11 39 f.stop_casting_frame:Show()
Tercio@11 40 else
Tercio@11 41 f:SetLockState()
Tercio@11 42 print ("|cFFFFAA00Hansgar and Franzok Assist|r frame locked.")
Tercio@11 43 f.unlocked_frame = false
Tercio@11 44 f.stop_casting_frame:Hide()
Tercio@11 45 end
Tercio@11 46 end)
Tercio@0 47
Tercio@4 48 local tframe = CreateFrame ("frame", "Hansgar_And_Franzok_Assist_PTrack", UIParent)
Tercio@4 49
Tercio@11 50 f:SetSize (155, 159)
Tercio@0 51 f:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = -1, right = -1, top = -1, bottom = -1},
Tercio@0 52 edgeFile = "Interface\\AddOns\\Hansgar_And_Franzok_Assist\\border_2", edgeSize = 8})
Tercio@7 53 f:SetPoint ("center", UIParent, "center", 300, 200)
Tercio@0 54 f:SetBackdropColor (0, 0, 0, 0)
Tercio@0 55 f:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@0 56 f:SetMovable (true)
Tercio@0 57 f:EnableMouse (true)
Tercio@5 58 f.all_blocks = {}
Tercio@0 59 f:Hide()
Tercio@0 60
Tercio@11 61 --local title = f:CreateFontString (nil, "overlay", "GameFontNormal")
Tercio@11 62 --title:SetText ("Hansgar & Franzok Assist")
Tercio@11 63 --title:SetPoint ("center", f, "center")
Tercio@11 64 --title:SetPoint ("bottom", f, "top", 0, 2)
Tercio@0 65
Tercio@0 66 --
Tercio@0 67 local frame_event = CreateFrame ("frame", "Hansgar_And_Franzok_AssistEvents", f)
Tercio@0 68 frame_event:RegisterEvent ("ENCOUNTER_START")
Tercio@0 69 frame_event:RegisterEvent ("ENCOUNTER_END")
Tercio@0 70 frame_event:RegisterEvent ("ADDON_LOADED")
Tercio@0 71
Tercio@0 72 --
Tercio@7 73 local player_bar = CreateFrame ("statusbar", "Hansgar_And_Franzok_PlayerAssistBar", UIParent)
Tercio@7 74
Tercio@7 75 --player_bar:SetPoint ("topleft", f, "bottomleft", 0, -3)
Tercio@7 76 --player_bar:SetPoint ("topright", f, "bottomright", 0, -3)
Tercio@7 77
Tercio@7 78 player_bar:SetPoint ("center", UIParent, "center", 0, 300)
Tercio@9 79 player_bar:SetSize (280, 16)
Tercio@7 80
Tercio@7 81 player_bar:SetMovable (true)
Tercio@7 82 player_bar:EnableMouse (true)
Tercio@7 83 player_bar:SetResizable (true)
Tercio@0 84 player_bar:SetStatusBarColor (0, 0, 0, 0)
Tercio@0 85 player_bar:SetMinMaxValues (0, 100)
Tercio@0 86 player_bar:SetValue (0)
Tercio@7 87 player_bar:SetMinResize (50, 15)
Tercio@7 88 player_bar:SetMaxResize (500, 40)
Tercio@7 89 player_bar:Hide()
Tercio@7 90
Tercio@7 91 local player_bar_backgroud = player_bar:CreateTexture (nil, "background")
Tercio@7 92 player_bar_backgroud:SetTexture (0, 0, 0, 0.2)
Tercio@7 93 player_bar_backgroud:SetAllPoints()
Tercio@7 94
Tercio@7 95 local icon = player_bar:CreateTexture (nil, "overlay")
Tercio@7 96 icon:SetTexture ([[Interface\HELPFRAME\ReportLagIcon-Movement]])
Tercio@7 97 icon:SetPoint ("left", player_bar, "left")
Tercio@7 98 icon:SetDesaturated (true)
Tercio@7 99 player_bar.icon = icon
Tercio@7 100
Tercio@7 101 local text = player_bar:CreateFontString (nil, "overlay", "GameFontNormal")
Tercio@7 102 text:SetPoint ("right", player_bar, "right", -2, 0)
Tercio@7 103 player_bar.text = text
Tercio@7 104
Tercio@7 105 player_bar:SetScript ("OnMouseDown", function (self)
Tercio@7 106 if (not self.isMoving) then
Tercio@7 107 self:StartMoving()
Tercio@7 108 self.isMoving = true
Tercio@7 109 end
Tercio@7 110 end)
Tercio@7 111 player_bar:SetScript ("OnMouseUp", function (self)
Tercio@7 112 if (self.isMoving) then
Tercio@7 113 self:StopMovingOrSizing()
Tercio@7 114 self.isMoving = false
Tercio@7 115 end
Tercio@7 116 end)
Tercio@7 117 player_bar:SetScript ("OnSizeChanged", function (self)
Tercio@7 118 self.icon:SetSize (self:GetHeight(), self:GetHeight())
Tercio@7 119
Tercio@7 120 end)
Tercio@7 121 local grip = CreateFrame ("button", "Hansgar_And_Franzok_AssistPlayerBarButton", player_bar)
Tercio@7 122 grip:SetPoint ("bottomright", player_bar, "bottomright")
Tercio@7 123 grip:SetSize (16, 16)
Tercio@7 124 grip:SetScript ("OnMouseDown", function (self, button)
Tercio@7 125 if (not player_bar.isMoving and button == "LeftButton") then
Tercio@7 126 player_bar:StartSizing ("bottomright")
Tercio@7 127 player_bar.isMoving = true
Tercio@7 128 end
Tercio@7 129 end)
Tercio@7 130 grip:SetScript ("OnMouseUp", function (self, button)
Tercio@7 131 if (player_bar.isMoving and button == "LeftButton") then
Tercio@7 132 player_bar:StopMovingOrSizing()
Tercio@7 133 player_bar.isMoving = false
Tercio@7 134 end
Tercio@7 135 end)
Tercio@7 136 grip:SetNormalTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Up]])
Tercio@7 137 grip:SetHighlightTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Highlight]])
Tercio@7 138 grip:SetPushedTexture ([[Interface\CHATFRAME\UI-ChatIM-SizeGrabber-Down]])
Tercio@7 139
Tercio@7 140 player_bar.grip = grip
Tercio@0 141 f.player_bar = player_bar
Tercio@0 142
Tercio@7 143
Tercio@0 144 player_bar.texture = player_bar:CreateTexture (nil, "overlay")
Tercio@0 145 player_bar.texture:SetTexture ("Interface\\AddOns\\Hansgar_And_Franzok_Assist\\bar_skyline")
Tercio@0 146 player_bar:SetStatusBarTexture (player_bar.texture)
Tercio@0 147
Tercio@0 148 --
Tercio@0 149
Tercio@7 150 local player_pos_frame = CreateFrame ("frame", "Hansgar_And_Franzok_Assist_BarDance", UIParent)
Tercio@7 151 --player_pos_frame:SetPoint ("topleft", player_bar, "bottomleft", 0, -3)
Tercio@7 152 --player_pos_frame:SetPoint ("topright", player_bar, "bottomright", 0, -3)
Tercio@7 153
Tercio@7 154 player_pos_frame:SetPoint ("center", UIParent, "center", 0, -75)
Tercio@7 155
Tercio@7 156 player_pos_frame:SetSize (155, 6)
Tercio@9 157 player_pos_frame:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = -1, right = -1, top = -1, bottom = -1}})
Tercio@9 158 player_pos_frame:SetBackdropColor (0, 0, 0, 1)
Tercio@7 159 player_pos_frame:SetMovable (true)
Tercio@7 160 player_pos_frame:EnableMouse (true)
Tercio@7 161 player_pos_frame:SetScript ("OnMouseDown", function (self)
Tercio@7 162 if (not self.isMoving) then
Tercio@7 163 self:StartMoving()
Tercio@7 164 self.isMoving = true
Tercio@7 165 end
Tercio@7 166 end)
Tercio@7 167 player_pos_frame:SetScript ("OnMouseUp", function (self)
Tercio@7 168 if (self.isMoving) then
Tercio@7 169 self:StopMovingOrSizing()
Tercio@7 170 self.isMoving = false
Tercio@7 171 end
Tercio@7 172 end)
Tercio@4 173 player_pos_frame:Hide()
Tercio@11 174 f.player_pos_frame = player_pos_frame
Tercio@4 175
Tercio@4 176 --red
Tercio@4 177 local t1 = player_pos_frame:CreateTexture (nil, "artwork")
Tercio@4 178 t1:SetPoint ("left", player_pos_frame, "left")
Tercio@7 179 t1:SetSize (player_pos_frame:GetWidth()*0.30, 6)
Tercio@4 180 t1:SetTexture (1, 1, 1)
Tercio@4 181 --t1:SetTexCoord (260/512, 430/512, 29/256, 82/256)
Tercio@4 182 t1:SetVertexColor (1, 0.2, 0.2, 0.4)
Tercio@4 183
Tercio@4 184 --green
Tercio@4 185 local t2 = player_pos_frame:CreateTexture (nil, "artwork")
Tercio@4 186 t2:SetPoint ("left", t1, "right")
Tercio@7 187 t2:SetSize (player_pos_frame:GetWidth()*0.15, 6)
Tercio@4 188 t2:SetTexture (0.2, 1, 0.2, 0.4)
Tercio@4 189
Tercio@4 190 --red
Tercio@4 191 local middle = player_pos_frame:CreateTexture (nil, "artwork")
Tercio@4 192 middle:SetPoint ("left", t2, "right")
Tercio@7 193 middle:SetSize (player_pos_frame:GetWidth()*0.10, 6)
Tercio@4 194 middle:SetTexture (1, 1, 1)
Tercio@4 195 --middle:SetTexCoord (260/512, 430/512, 29/256, 82/256)
Tercio@4 196 middle:SetVertexColor (1, 0.2, 0.2, 0.4)
Tercio@4 197
Tercio@4 198 --green
Tercio@4 199 local t3 = player_pos_frame:CreateTexture (nil, "artwork")
Tercio@4 200 t3:SetPoint ("left", middle, "right")
Tercio@7 201 t3:SetSize (player_pos_frame:GetWidth()*0.15, 6)
Tercio@4 202 t3:SetTexture (0.2, 1, 0.2, 0.4)
Tercio@4 203
Tercio@4 204 --red
Tercio@4 205 local t4 = player_pos_frame:CreateTexture (nil, "artwork")
Tercio@4 206 t4:SetPoint ("left", t3, "right")
Tercio@7 207 t4:SetSize (player_pos_frame:GetWidth()*0.30, 6)
Tercio@4 208 t4:SetTexture (1, 1, 1)
Tercio@4 209 --t4:SetTexCoord (260/512, 430/512, 29/256, 82/256)
Tercio@4 210 t4:SetVertexColor (1, 0.2, 0.2, 0.4)
Tercio@4 211
Tercio@4 212 local div = player_pos_frame:CreateTexture (nil, "overlay")
Tercio@4 213 div:SetPoint ("left", player_pos_frame, "left", 0, 0)
Tercio@4 214 div:SetTexture (1, 1, 1, 1)
Tercio@4 215 div:SetSize (1, 16)
Tercio@4 216 div:Hide()
Tercio@4 217 --
Tercio@4 218
Tercio@4 219 local AceTimer = LibStub:GetLibrary ("AceTimer-3.0")
Tercio@4 220 AceTimer:Embed (f)
Tercio@4 221 local AceComm = LibStub:GetLibrary ("AceComm-3.0")
Tercio@4 222 AceComm:Embed (f)
Tercio@4 223
Tercio@5 224 function f:CommReceived (_, data, _, source)
Tercio@5 225 if (data == "US") then
Tercio@5 226 f:SendCommMessage ("HAFR", UnitName ("player") .. " " .. f.version, "RAID")
Tercio@6 227 elseif (f.users) then
Tercio@5 228 f.users [data] = true
Tercio@5 229 end
Tercio@5 230 end
Tercio@5 231 function f:ShowUsers()
Tercio@5 232
Tercio@5 233 local users_frame = Hansgar_And_Franzok_Assist_UsersPanel
Tercio@5 234 if (not users_frame) then
Tercio@5 235 users_frame = CreateFrame ("frame", "Hansgar_And_Franzok_Assist_UsersPanel", UIParent)
Tercio@5 236 users_frame:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = -1, right = -1, top = -1, bottom = -1},
Tercio@5 237 edgeFile = "Interface\\AddOns\\Hansgar_And_Franzok_Assist\\border_2", edgeSize = 8})
Tercio@5 238 users_frame:SetBackdropColor (0, 0, 0, 1)
Tercio@5 239 tinsert (UISpecialFrames, "Hansgar_And_Franzok_Assist_UsersPanel")
Tercio@5 240 users_frame:SetSize (200, 500)
Tercio@5 241 users_frame:SetPoint ("right", f, "left", -15, 0)
Tercio@5 242 users_frame.text = users_frame:CreateFontString (nil, "overlay", "GameFontHighlight")
Tercio@5 243 users_frame.text:SetPoint ("topleft", users_frame, "topleft", 10, -10)
Tercio@5 244 users_frame.text:SetJustifyH ("left")
Tercio@5 245
Tercio@5 246 users_frame.title = users_frame:CreateFontString (nil, "overlay", "GameFontNormal")
Tercio@5 247 users_frame.title:SetText ("Hansgar & Franzok Assist: Users")
Tercio@5 248 users_frame.title:SetPoint ("center", users_frame, "center")
Tercio@5 249 users_frame.title:SetPoint ("bottom", users_frame, "top", 0, 2)
Tercio@5 250
Tercio@5 251 end
Tercio@5 252
Tercio@5 253 local s = ""
Tercio@5 254
Tercio@5 255 for key, value in pairs (f.users) do
Tercio@5 256 s = s .. "|cFF33FF33" .. key .. "\n"
Tercio@5 257 end
Tercio@5 258
Tercio@5 259 s = s .. "|r\n\n\n|cFFFFFFFFOut of Date or Not installed:|r\n\n"
Tercio@5 260
Tercio@5 261 for i = 1, GetNumGroupMembers() do
Tercio@5 262 local name = UnitName ("raid" .. i)
Tercio@5 263 if (not s:find (name)) then
Tercio@5 264 s = s .. "|cFFFF3333" .. name .. "|r\n"
Tercio@5 265 end
Tercio@5 266 end
Tercio@5 267
Tercio@5 268 users_frame.text:SetText (s)
Tercio@5 269
Tercio@5 270 users_frame:Show()
Tercio@6 271
Tercio@6 272 f.users = nil
Tercio@6 273 f.users_schedule = nil
Tercio@5 274
Tercio@5 275 end
Tercio@5 276 f:RegisterComm ("HAFR", "CommReceived")
Tercio@5 277
Tercio@4 278 f.block_tracker = {}
Tercio@4 279
Tercio@0 280 frame_event:SetFrameStrata ("FULLSCREEN")
Tercio@0 281
Tercio@0 282 frame_event:SetScript ("OnEvent", function (self, event, ...)
Tercio@0 283
Tercio@0 284 if (event == "ADDON_LOADED" and select (1, ...) == "Hansgar_And_Franzok_Assist") then
Tercio@12 285 --/dump Hansgar_And_Franzok_DB.STAMPERS_DELAY
Tercio@0 286 db = Hansgar_And_Franzok_DB
Tercio@0 287 if (not db) then
Tercio@0 288 db = {}
Tercio@0 289 Hansgar_And_Franzok_DB = db
Tercio@0 290 end
Tercio@4 291 --
Tercio@0 292 db.STAMPERS_DELAY = db.STAMPERS_DELAY or 5
Tercio@4 293 if (db.CD_NUMBER == nil) then
Tercio@4 294 db.CD_NUMBER = false
Tercio@4 295 end
Tercio@4 296 if (db.SHOW_DANCE == nil) then
Tercio@4 297 db.SHOW_DANCE = true
Tercio@4 298 end
Tercio@5 299 if (db.FRAME_LOCK == nil) then
Tercio@5 300 db.FRAME_LOCK = false
Tercio@5 301 end
Tercio@6 302 if (db.AUTO_FACING == nil) then
Tercio@6 303 db.AUTO_FACING = true
Tercio@6 304 end
Tercio@6 305 if (db.FACING_SIDE == nil) then
Tercio@6 306 db.FACING_SIDE = 1
Tercio@6 307 end
Tercio@7 308 if (db.SHOW_MAIN_FRAME == nil) then
Tercio@7 309 db.SHOW_MAIN_FRAME = true
Tercio@7 310 end
Tercio@7 311 if (db.PLAY_SOUND == nil) then
Tercio@7 312 db.PLAY_SOUND = false
Tercio@7 313 end
Tercio@9 314 if (db.STOP_CAST == nil) then
Tercio@9 315 db.STOP_CAST = true
Tercio@9 316 end
Tercio@4 317 --
Tercio@7 318
Tercio@7 319 f:SetLockState (true)
Tercio@7 320
Tercio@0 321 elseif (event == "ENCOUNTER_START" or event == "ENCOUNTER_END") then
Tercio@0 322
Tercio@0 323 local encounterID, encounterName, difficultyID, raidSize = select (1, ...)
Tercio@4 324
Tercio@4 325 if (encounterID == 1693) then
Tercio@9 326 if (f.unlocked_frame) then
Tercio@9 327 f.unlocked_frame = false
Tercio@9 328 end
Tercio@9 329
Tercio@4 330 if (event == "ENCOUNTER_START") then
Tercio@4 331 f.on_encounter = true
Tercio@9 332 f:RegisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
Tercio@9 333
Tercio@4 334 elseif (event == "ENCOUNTER_END") then
Tercio@4 335 f.on_encounter = false
Tercio@9 336 f:UnregisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
Tercio@4 337 end
Tercio@4 338 end
Tercio@4 339
Tercio@4 340 if (encounterID == 1693 and db.SHOW_DANCE) then
Tercio@4 341 if (event == "ENCOUNTER_START") then
Tercio@4 342 SetMapToCurrentZone()
Tercio@4 343 f:StartTrackPlayerPosition()
Tercio@4 344 elseif (event == "ENCOUNTER_END") then
Tercio@4 345 f:EndTrackPlayerPosition()
Tercio@4 346 end
Tercio@4 347 end
Tercio@4 348
Tercio@0 349 if (encounterID == 1693 and difficultyID == 16) then
Tercio@0 350
Tercio@0 351 if (event == "ENCOUNTER_START") then
Tercio@0 352 print ("|cFFFFAA00Hansgar and Franzok Assist|r: addon enabled, good look!")
Tercio@0 353
Tercio@0 354 if (f.StampersPhase) then
Tercio@0 355 f:StopTracking()
Tercio@0 356 end
Tercio@0 357
Tercio@0 358 elseif (event == "ENCOUNTER_END") then
Tercio@0 359 if (f.StampersPhase) then
Tercio@0 360 f:StopTracking()
Tercio@0 361 end
Tercio@4 362
Tercio@4 363 f:EndTrackPlayerPosition()
Tercio@0 364 end
Tercio@0 365 end
Tercio@0 366 end
Tercio@0 367
Tercio@0 368 end)
Tercio@0 369
Tercio@6 370 SLASH_Hansgar_And_Franzok_Assist1, SLASH_Hansgar_And_Franzok_Assist2 = "/hansgar", "/franzok"
Tercio@6 371 function SlashCmdList.Hansgar_And_Franzok_Assist (msg, editbox)
Tercio@6 372
Tercio@6 373 local command, rest = msg:match ("^(%S*)%s*(.-)$")
Tercio@6 374
Tercio@6 375 if (command == "users") then
Tercio@6 376 if (f.users_schedule) then
Tercio@6 377 print ("|cFFFFAA00Hansgar and Franzok Assist|r please wait 5 seconds...")
Tercio@6 378 elseif (IsInRaid()) then
Tercio@6 379 f.users = {}
Tercio@6 380 f:SendCommMessage ("HAFR", "US", "RAID")
Tercio@6 381 f.users_schedule = f:ScheduleTimer ("ShowUsers", 5)
Tercio@6 382 print ("|cFFFFAA00Hansgar and Franzok Assist|r please wait 5 seconds...")
Tercio@6 383 else
Tercio@6 384 print ("|cFFFFAA00Hansgar and Franzok Assist|r you aren't in a raid group.")
Tercio@6 385 end
Tercio@6 386
Tercio@10 387 elseif (command == "st") then
Tercio@10 388 f.stop_casting_frame:Show()
Tercio@10 389 f.stop_casting_frame.alert.animOut:Stop()
Tercio@10 390 f.stop_casting_frame.alert.animIn:Play()
Tercio@10 391 f:ScheduleTimer ("HideStopSpellAlert", 1.2)
Tercio@10 392
Tercio@9 393 elseif (command == "stopcast") then
Tercio@9 394 db.STOP_CAST = not db.STOP_CAST
Tercio@9 395
Tercio@9 396 if (db.STOP_CAST) then
Tercio@9 397 print ("|cFFFFAA00Hansgar and Franzok Assist|r stop cast alert enabled.")
Tercio@9 398 else
Tercio@9 399 print ("|cFFFFAA00Hansgar and Franzok Assist|r stop cast alert disabled.")
Tercio@9 400 end
Tercio@9 401
Tercio@9 402 elseif (command == "resetpos") then
Tercio@9 403 f:ClearAllPoints()
Tercio@9 404 f:SetPoint ("center", UIParent, "center")
Tercio@9 405
Tercio@9 406 player_bar:ClearAllPoints()
Tercio@9 407 player_bar:SetPoint ("center", UIParent, "center")
Tercio@9 408
Tercio@9 409 player_pos_frame:ClearAllPoints()
Tercio@9 410 player_pos_frame:SetPoint ("center", UIParent, "center")
Tercio@9 411
Tercio@9 412 if (f.StampersPhase) then
Tercio@9 413 f:EndTrackPlayerPosition()
Tercio@9 414 f:StopTracking()
Tercio@9 415 end
Tercio@9 416
Tercio@9 417 db.FRAME_LOCK = true
Tercio@9 418 f:SetLockState()
Tercio@9 419
Tercio@9 420 f.unlocked_frame = true
Tercio@9 421
Tercio@9 422 f:StartTracking()
Tercio@9 423 f:StartTrackPlayerPosition()
Tercio@9 424
Tercio@9 425 print ("|cFFFFAA00Hansgar and Franzok Assist|r: position reseted.")
Tercio@9 426 print ("|cFFFFAA00Hansgar and Franzok Assist|r: move between the tracks to show the other frames.")
Tercio@9 427 print ("|cFFFFAA00Hansgar and Franzok Assist|r: type '/hansgar lock' to lock the frames.")
Tercio@9 428
Tercio@6 429 elseif (command == "delay") then
Tercio@6 430 local t = tonumber (rest)
Tercio@6 431 if (t) then
Tercio@6 432 db.STAMPERS_DELAY = t
Tercio@6 433 print ("|cFFFFAA00Hansgar and Franzok Assist|r delay set to: ", t)
Tercio@6 434 else
Tercio@6 435 print ("|cFFFFAA00Hansgar and Franzok Assist|r invalid time.", t)
Tercio@6 436 end
Tercio@6 437
Tercio@6 438 elseif (command == "test" or command == "show") then
Tercio@6 439 if (f.StampersPhase) then
Tercio@6 440 f:EndTrackPlayerPosition()
Tercio@6 441 return f:StopTracking()
Tercio@6 442 end
Tercio@6 443
Tercio@6 444 f:StartTracking()
Tercio@6 445 f:StartTrackPlayerPosition()
Tercio@6 446
Tercio@6 447 elseif (command == "hide") then
Tercio@6 448 if (f.StampersPhase) then
Tercio@6 449 return f:StopTracking()
Tercio@6 450 end
Tercio@6 451 f:EndTrackPlayerPosition()
Tercio@6 452
Tercio@7 453 elseif (command == "unlock") then
Tercio@7 454 db.FRAME_LOCK = true
Tercio@7 455 f:SetLockState()
Tercio@7 456 print ("|cFFFFAA00Hansgar and Franzok Assist|r frame unlocked.")
Tercio@9 457
Tercio@9 458 f.unlocked_frame = true
Tercio@9 459 player_pos_frame:Show()
Tercio@9 460 player_bar:Show()
Tercio@10 461 f.stop_casting_frame:Show()
Tercio@7 462
Tercio@6 463 elseif (command == "lock") then
Tercio@6 464 f:SetLockState()
Tercio@6 465
Tercio@6 466 if (db.FRAME_LOCK) then
Tercio@6 467 print ("|cFFFFAA00Hansgar and Franzok Assist|r frame locked.")
Tercio@9 468 f.unlocked_frame = false
Tercio@10 469 f.stop_casting_frame:Hide()
Tercio@6 470 else
Tercio@6 471 print ("|cFFFFAA00Hansgar and Franzok Assist|r frame unlocked.")
Tercio@9 472
Tercio@9 473 f.unlocked_frame = true
Tercio@9 474 player_pos_frame:Show()
Tercio@9 475 player_bar:Show()
Tercio@10 476 f.stop_casting_frame:Show()
Tercio@9 477
Tercio@6 478 end
Tercio@6 479
Tercio@6 480 elseif (command == "facing") then
Tercio@6 481 if (rest == "1") then
Tercio@6 482 db.FACING_SIDE = 1
Tercio@6 483 tframe.facing = true
Tercio@6 484 print ("|cFFFFAA00Hansgar and Franzok Assist|r facing set to south.")
Tercio@6 485
Tercio@6 486 elseif (rest == "2") then
Tercio@6 487 db.FACING_SIDE = 2
Tercio@6 488 tframe.facing = false
Tercio@6 489 print ("|cFFFFAA00Hansgar and Franzok Assist|r facing set to north.")
Tercio@6 490
Tercio@6 491 elseif (rest == "auto") then
Tercio@6 492 db.AUTO_FACING = true
Tercio@6 493 print ("|cFFFFAA00Hansgar and Franzok Assist|r auto facing enabled.")
Tercio@6 494
Tercio@6 495 else
Tercio@6 496 print ("|cFFFFFF00/hansgar facing|r: |cFF00FF001|r = south |cFF00FF002|r = north, use to set the dance bar when auto facing is disabled.")
Tercio@6 497 end
Tercio@6 498
Tercio@6 499 elseif (command == "autofacing") then
Tercio@6 500 db.AUTO_FACING = not db.AUTO_FACING
Tercio@6 501 if (db.AUTO_FACING) then
Tercio@6 502 print ("|cFFFFAA00Hansgar and Franzok Assist|r auto facing enabled.")
Tercio@6 503 else
Tercio@6 504 print ("|cFFFFAA00Hansgar and Franzok Assist|r auto facing disabled.")
Tercio@6 505 tframe.facing = db.FACING_SIDE == 1
Tercio@6 506 end
Tercio@6 507
Tercio@6 508 elseif (command == "dance") then
Tercio@6 509 db.SHOW_DANCE = not db.SHOW_DANCE
Tercio@6 510 if (db.SHOW_DANCE) then
Tercio@6 511 if (f.on_encounter) then
Tercio@6 512 f:StartTrackPlayerPosition()
Tercio@6 513 end
Tercio@6 514 print ("|cFFFFAA00Hansgar and Franzok Assist|r dance bars enabled.")
Tercio@6 515 else
Tercio@6 516 f:EndTrackPlayerPosition()
Tercio@6 517 print ("|cFFFFAA00Hansgar and Franzok Assist|r dance bars disabled.")
Tercio@6 518 end
Tercio@6 519
Tercio@6 520 elseif (command == "cooldown") then
Tercio@6 521 db.CD_NUMBER = not db.CD_NUMBER
Tercio@6 522 f:RefreshCooldownSettings()
Tercio@6 523
Tercio@6 524 else
Tercio@11 525
Tercio@11 526 if (f.StampersPhase) then
Tercio@11 527 f:EndTrackPlayerPosition()
Tercio@11 528 return f:StopTracking()
Tercio@11 529 end
Tercio@11 530
Tercio@11 531 f:StartTracking()
Tercio@11 532 f:StartTrackPlayerPosition()
Tercio@11 533
Tercio@6 534 print ("|cFFFFAA00Hansgar and Franzok Assist|r |cFF00FF00" .. f.version .. "|r Commands:")
Tercio@9 535 print ("|cFFFFFF00/hansgar resetpos|r: reset the position of all frames.")
Tercio@6 536 print ("|cFFFFFF00/hansgar lock|r: toggle lock and unlock on the frame.")
Tercio@6 537 print ("|cFFFFFF00/hansgar test show hide|r: active the addon on test mode or hide it.")
Tercio@6 538 print ("|cFFFFFF00/hansgar delay <time>|r: time in seconds until the percentage goes from 0 to 100.")
Tercio@6 539 print ("|cFFFFFF00/hansgar dance|r: toggle dance bar (used to dodge regular stampers and searing plates).")
Tercio@6 540 print ("|cFFFFFF00/hansgar autofacing|r: toggle if the dance bar auto switch left and right when looking to north or south.")
Tercio@6 541 print ("|cFFFFFF00/hansgar facing|r: |cFF00FF001|r = south |cFF00FF002|r = north, use to set the dance bar when auto facing is disabled.")
Tercio@6 542 print ("|cFFFFFF00/hansgar users|r: show who is using the addon in the raid.")
Tercio@6 543 print ("|cFFFFFF00/hansgar cooldown|r: show the countdown text for each stamper go back up to the ceiling.")
Tercio@9 544 print ("|cFFFFFF00/hansgar stopcast|r: show the alert to stop casting for Disrupting Roar.")
Tercio@6 545 end
Tercio@6 546 end
Tercio@6 547
Tercio@0 548 --
Tercio@0 549
Tercio@11 550 local options_panel = {
Tercio@11 551 {
Tercio@11 552 type = "range",
Tercio@11 553 get = function() return db.STAMPERS_DELAY end,
Tercio@11 554 set = function (self, fixedparam, value) db.STAMPERS_DELAY = value end,
Tercio@11 555 min = 4,
Tercio@11 556 max = 8,
Tercio@11 557 step = 1,
Tercio@11 558 desc = "Time in seconds to move out from a heating up stamper.",
Tercio@11 559 name = "Stampers Delay",
Tercio@11 560 },
Tercio@11 561 {
Tercio@11 562 type = "toggle",
Tercio@11 563 get = function() return db.FRAME_LOCK end,
Tercio@11 564 set = function (self, fixedparam, value)
Tercio@11 565 db.FRAME_LOCK = not value;
Tercio@11 566 if (db.FRAME_LOCK) then
Tercio@11 567 f:SetLockState()
Tercio@11 568 print ("|cFFFFAA00Hansgar and Franzok Assist|r frame unlocked.")
Tercio@11 569
Tercio@11 570 f.unlocked_frame = true
Tercio@11 571 f.player_pos_frame:Show()
Tercio@11 572 f.player_bar:Show()
Tercio@11 573 f.stop_casting_frame:Show()
Tercio@11 574 else
Tercio@11 575 f:SetLockState()
Tercio@11 576 print ("|cFFFFAA00Hansgar and Franzok Assist|r frame locked.")
Tercio@11 577 f.unlocked_frame = false
Tercio@11 578 f.stop_casting_frame:Hide()
Tercio@11 579 end
Tercio@11 580 end,
Tercio@11 581 desc = "Lock or unlock the frames.",
Tercio@11 582 name = "Frame Locked"
Tercio@11 583 },
Tercio@11 584 {
Tercio@11 585 type = "toggle",
Tercio@11 586 get = function() return db.SHOW_DANCE end,
Tercio@11 587 set = function (self, fixedparam, value)
Tercio@11 588 db.SHOW_DANCE = not db.SHOW_DANCE
Tercio@11 589 if (db.SHOW_DANCE) then
Tercio@11 590 if (f.on_encounter) then
Tercio@11 591 f:StartTrackPlayerPosition()
Tercio@11 592 end
Tercio@11 593 else
Tercio@11 594 f:EndTrackPlayerPosition()
Tercio@11 595 end
Tercio@11 596 end,
Tercio@11 597 desc = "Enable or disable the dance bar.",
Tercio@11 598 name = "Dance Bar"
Tercio@11 599 },
Tercio@11 600 {
Tercio@11 601 type = "toggle",
Tercio@11 602 get = function() return db.CD_NUMBER end,
Tercio@11 603 set = function (self, fixedparam, value)
Tercio@11 604 db.CD_NUMBER = not db.CD_NUMBER
Tercio@11 605 f:RefreshCooldownSettings()
Tercio@11 606 end,
Tercio@11 607 desc = "When enabled, shows the number countdown on each block.",
Tercio@11 608 name = "Show Cooldown Number"
Tercio@11 609 },
Tercio@11 610 {
Tercio@11 611 type = "toggle",
Tercio@11 612 get = function() return db.STOP_CAST end,
Tercio@11 613 set = function (self, fixedparam, value)
Tercio@11 614 db.STOP_CAST = not db.STOP_CAST
Tercio@11 615 end,
Tercio@11 616 desc = "When enabled, shows an alert for Disrupting Roar.",
Tercio@11 617 name = "Stop Cast Alert"
Tercio@11 618 },
Tercio@11 619 {
Tercio@11 620 type = "execute",
Tercio@11 621 func = function()
Tercio@11 622 if (f.StampersPhase) then
Tercio@11 623 f:EndTrackPlayerPosition()
Tercio@11 624 return f:StopTracking()
Tercio@11 625 end
Tercio@11 626 f:StartTracking()
Tercio@11 627 f:StartTrackPlayerPosition()
Tercio@11 628 end,
Tercio@11 629 desc = "Test the addon, run over the tracks in the room.",
Tercio@11 630 name = "Start Test Mode"
Tercio@11 631 },
Tercio@11 632 {
Tercio@11 633 type = "execute",
Tercio@11 634 func = function()
Tercio@11 635 f:ClearAllPoints()
Tercio@11 636 f:SetPoint ("center", UIParent, "center")
Tercio@11 637
Tercio@11 638 player_bar:ClearAllPoints()
Tercio@11 639 player_bar:SetPoint ("center", UIParent, "center")
Tercio@11 640
Tercio@11 641 player_pos_frame:ClearAllPoints()
Tercio@11 642 player_pos_frame:SetPoint ("center", UIParent, "center")
Tercio@11 643
Tercio@11 644 if (f.StampersPhase) then
Tercio@11 645 f:EndTrackPlayerPosition()
Tercio@11 646 f:StopTracking()
Tercio@11 647 end
Tercio@11 648
Tercio@11 649 db.FRAME_LOCK = true
Tercio@11 650 f:SetLockState()
Tercio@11 651
Tercio@11 652 f.unlocked_frame = true
Tercio@11 653
Tercio@11 654 f:StartTracking()
Tercio@11 655 f:StartTrackPlayerPosition()
Tercio@11 656
Tercio@11 657 print ("|cFFFFAA00Hansgar and Franzok Assist|r: position reseted and frames are unlocked.")
Tercio@11 658 print ("|cFFFFAA00Hansgar and Franzok Assist|r: move between the tracks to show the other frames.")
Tercio@11 659 end,
Tercio@11 660 desc = "Reset the position of all frames and start the test mode.",
Tercio@11 661 name = "Reset Position"
Tercio@11 662 },
Tercio@11 663 {
Tercio@11 664 type = "execute",
Tercio@11 665 func = function()
Tercio@11 666 if (f.users_schedule) then
Tercio@11 667 print ("|cFFFFAA00Hansgar and Franzok Assist|r please wait 5 seconds...")
Tercio@11 668 elseif (IsInRaid()) then
Tercio@11 669 f.users = {}
Tercio@11 670 f:SendCommMessage ("HAFR", "US", "RAID")
Tercio@11 671 f.users_schedule = f:ScheduleTimer ("ShowUsers", 5)
Tercio@11 672 print ("|cFFFFAA00Hansgar and Franzok Assist|r please wait 5 seconds...")
Tercio@11 673 else
Tercio@11 674 print ("|cFFFFAA00Hansgar and Franzok Assist|r you aren't in a raid group.")
Tercio@11 675 end
Tercio@11 676 end,
Tercio@11 677 desc = "Show raid members which are also using this addon.",
Tercio@11 678 name = "Version Check"
Tercio@11 679 },
Tercio@11 680 {
Tercio@11 681 type = "execute",
Tercio@11 682 func = function()
Tercio@11 683 f.feedback_func()
Tercio@11 684 end,
Tercio@11 685 desc = "Send a feedback for us on our Curse page or MMO-Champion forum Thread.",
Tercio@11 686 name = "Send Feedback"
Tercio@11 687 },
Tercio@11 688 }
Tercio@11 689
Tercio@11 690 local build_options_panel = function()
Tercio@11 691 local options_frame = DF:CreateOptionsFrame ("HansgarFranzokAssistOptions", "Hans & Franz Assist", 1)
Tercio@11 692 options_frame:SetHeight (180)
Tercio@11 693 DF:BuildMenu (options_frame, options_panel, 15, -60, 180)
Tercio@11 694 options_frame:SetBackdropColor (0, 0, 0, .9)
Tercio@11 695 end
Tercio@11 696
Tercio@11 697 f.OpenOptionsPanel = function()
Tercio@11 698 if (not HansgarFranzokAssistOptions) then
Tercio@11 699 build_options_panel()
Tercio@11 700 end
Tercio@11 701 HansgarFranzokAssistOptions:Show()
Tercio@11 702 end
Tercio@11 703
Tercio@11 704 -- /run Hansgar_And_Franzok_Assist.OpenOptionsPanel()
Tercio@11 705 local options = DF:CreateOptionsButton (f, f.OpenOptionsPanel, "Hansgar_And_Franzok_Assist_OPButton")
Tercio@11 706 options:SetPoint ("right", f.Lock, "left", 1, 0)
Tercio@11 707 f.Options = options
Tercio@11 708
Tercio@11 709 --
Tercio@11 710 local feedback_func = function()
Tercio@11 711 local feedback1 = {icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\feedback_sites]], coords = DF.www_icons.mmoc, desc = "Post on our thread on MMO-Champion Forum.", link = [[http://www.mmo-champion.com/threads/1725970-Hans-gar-and-Franzok-Assist-(addon)]]}
Tercio@11 712 local feedback2 = {icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\feedback_sites]], coords = DF.www_icons.curse, desc = "Leave a comment on our page at Curse.com.", link = [[http://www.curse.com/addons/wow/hansgar_and_franzok_assist]]}
Tercio@11 713
Tercio@11 714 local same1 = {name = "Details! Damage Meter", desc = "A Damage Meter with a lot of tools for raiders and leaders.", link = [[http://www.curse.com/addons/wow/details]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {0, 128/512, 0, 64/512}}
Tercio@11 715 local same2 = {name = "Gold Token Price", desc = "Adds the slash command '/gold'. This command tells you the current price of WoW Token.", link = [[http://www.curse.com/addons/wow/gold-token-price]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {128/512, 256/512, 0, 64/512}}
Tercio@11 716 local same3 = {name = "Salvage Yard Seller", desc = "Sells stuff gathered from salvage crates respecting item level limit.", link = [[http://www.curse.com/addons/wow/salvage-yard-seller]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {384/512, 512/512, 64/512, 128/512}}
Tercio@11 717 local same4 = {name = "AddOns CPU Usage", desc = "Measure the CPU usage by addons. Important to get rid of FPS drops during boss encounters.", link = [[http://www.curse.com/addons/wow/addons-cpu-usage]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {384/512, 512/512, 0, 64/512}}
Tercio@11 718 local same5 = {name = "Keep World Map Zoom", desc = "Because it's a pain having to re-zoom the world map after close and reopening in a short period of time.", link = [[http://www.curse.com/addons/wow/world-map-zoom]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {0/512, 128/512, 64/512, 128/512}}
Tercio@11 719 local same6 = {name = "PvPScan", desc = "Show a unit frame with enemy players near you.", link = [[http://www.wowace.com/addons/pvpscan/]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {128/512, 256/512, 64/512, 128/512}}
Tercio@11 720 local same7 = {name = "HotCorners", desc = "Show a hotcorner when poiting the mouse on the absolute top left of your screen (similar of those on Windows 8).", link = [[http://www.curse.com/addons/wow/hotcorners]], icon = [[Interface\AddOns\Hansgar_And_Franzok_Assist\libs\DF\all_addons]], coords = {256/512, 384/512, 64/512, 128/512}}
Tercio@11 721
Tercio@11 722 DF:ShowFeedbackPanel ("Hans & Franz Assist", f.version, {feedback2, feedback1}, {same1, same2, same3, same4, same5, same6, same7})
Tercio@11 723 end
Tercio@11 724 f.feedback_func = feedback_func
Tercio@11 725 local feedback_button = DF:CreateFeedbackButton (f, feedback_func, "Hansgar_And_Franzok_AssistFBButton")
Tercio@11 726 feedback_button:SetPoint ("right", f.Options, "left", 0, -1)
Tercio@11 727 --
Tercio@11 728
Tercio@10 729 local stop_casting_frame = CreateFrame ("frame", "Hansgar_And_Franzok_AssistStopCasting", UIParent)
Tercio@9 730 stop_casting_frame:SetSize (200, 30)
Tercio@9 731 stop_casting_frame:SetPoint ("center", UIParent, "center", 0, 75)
Tercio@9 732 stop_casting_frame:SetFrameStrata ("FULLSCREEN")
Tercio@10 733 f.stop_casting_frame = stop_casting_frame
Tercio@9 734 stop_casting_frame:Hide()
Tercio@10 735
Tercio@10 736 stop_casting_frame:SetMovable (false)
Tercio@10 737 stop_casting_frame:EnableMouse (false)
Tercio@10 738
Tercio@10 739 stop_casting_frame:SetScript ("OnMouseDown", function (self)
Tercio@10 740 if (not self.isMoving) then
Tercio@10 741 self:StartMoving()
Tercio@10 742 self.isMoving = true
Tercio@10 743 end
Tercio@9 744 end)
Tercio@10 745 stop_casting_frame:SetScript ("OnMouseUp", function (self)
Tercio@10 746 if (self.isMoving) then
Tercio@10 747 self:StopMovingOrSizing()
Tercio@10 748 self.isMoving = false
Tercio@10 749 end
Tercio@9 750 end)
Tercio@9 751
Tercio@10 752 local alert = CreateFrame ("frame", "Hansgar_And_Franzok_AssistStopCastingAlert", stop_casting_frame, "ActionBarButtonSpellActivationAlert")
Tercio@10 753 alert:SetPoint ("topleft", stop_casting_frame, "topleft", -10, 2)
Tercio@10 754 alert:SetPoint ("bottomright", stop_casting_frame, "bottomright", 10, -2)
Tercio@10 755 stop_casting_frame.alert = alert
Tercio@10 756
Tercio@9 757 local text = stop_casting_frame:CreateFontString (nil, "overlay", "GameFontNormal")
Tercio@9 758 text:SetText ("STOP CASTING!")
Tercio@9 759 text:SetPoint ("center", stop_casting_frame, "center")
Tercio@9 760
Tercio@9 761 stop_casting_frame:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16})
Tercio@10 762 stop_casting_frame:SetBackdropColor (0, 0, 0, 0.3)
Tercio@9 763
Tercio@10 764 function f:HideStopSpellAlert2()
Tercio@10 765 stop_casting_frame.alert.animOut:Stop()
Tercio@10 766 stop_casting_frame:Hide()
Tercio@10 767 end
Tercio@9 768 function f:HideStopSpellAlert()
Tercio@10 769 stop_casting_frame.alert.animIn:Stop()
Tercio@10 770 stop_casting_frame.alert.animOut:Play()
Tercio@10 771 f:ScheduleTimer ("HideStopSpellAlert2", 0.3)
Tercio@9 772 end
Tercio@9 773
Tercio@9 774 --3/22 13:44:48.995 SPELL_INTERRUPT,Vehicle-0-3132-1205-24243-76974-00000EF077,"Franzok",0x10a48,0x0,Player-00-063,"Grubdruid",0x514,0x0,160838,"Disrupting Roar",0x1,5185,"Healing Touch",8
Tercio@9 775
Tercio@9 776 f:SetScript ("OnEvent", function (self, event, time, token, _, who_serial, who_name, who_flags, _, target_serial, target_name, target_flags, _, spellid, spellname, spellschool, buff_type, buff_name)
Tercio@0 777
Tercio@2 778 if (token == "SPELL_AURA_APPLIED" and spellid == 162124 and not f.StampersPhase) then
Tercio@0 779 f:StartTracking()
Tercio@5 780 f:EndTrackPlayerPosition()
Tercio@0 781
Tercio@2 782 elseif (token == "SPELL_AURA_REMOVED" and spellid == 162124 and f.StampersPhase) then
Tercio@0 783 f:StopTracking()
Tercio@5 784 if (db.SHOW_DANCE) then
Tercio@5 785 f:StartTrackPlayerPosition()
Tercio@5 786 end
Tercio@0 787
Tercio@9 788 elseif (token == "SPELL_CAST_START" and spellid == 160838 and db.STOP_CAST) then --Disrupting Roar
Tercio@10 789 f.stop_casting_frame:Show()
Tercio@10 790 f.stop_casting_frame.alert.animOut:Stop()
Tercio@10 791 f.stop_casting_frame.alert.animIn:Play()
Tercio@10 792 f:ScheduleTimer ("HideStopSpellAlert", 1.2)
Tercio@10 793
Tercio@0 794 end
Tercio@9 795
Tercio@9 796 if (token == "SPELL_INTERRUPT" and spellid == 160838 and db.STOP_CAST) then
Tercio@9 797 local link = GetSpellLink (buff_type)
Tercio@9 798 print ("Stop Cast Fail:", target_name, link)
Tercio@9 799 end
Tercio@9 800
Tercio@9 801 --if (spellid == 160838) then
Tercio@9 802 -- print ("event:", token, 160838, db.STOP_CAST)
Tercio@9 803 --end
Tercio@0 804
Tercio@0 805 end)
Tercio@10 806 -- /run Hansgar_And_Franzok_AssistStopCastingAlert.animIn:Play()
Tercio@0 807
Tercio@9 808 --Hansgar_And_Franzok_AssistStopCasting:Show(); Hansgar_And_Franzok_Assist:ScheduleTimer ("HideStopSpellAlert", 1)
Tercio@9 809 --Hansgar_And_Franzok_Assist:RegisterEvent ("COMBAT_LOG_EVENT_UNFILTERED")
Tercio@9 810
Tercio@0 811 local frame_tracker = CreateFrame ("frame", "Hansgar_And_Franzok_AssistTracker", UIParent)
Tercio@0 812 local on_update_tracker = function (self, elapsed)
Tercio@0 813
Tercio@4 814 local raid_size = GetNumGroupMembers()
Tercio@4 815
Tercio@4 816 for i = 1, raid_size do
Tercio@0 817 local x, y = GetPlayerMapPosition ("raid"..i)
Tercio@0 818 if (UnitExists ("raid"..i) and UnitHealth ("raid"..i) > 1 and x and y) then
Tercio@0 819 local block = f:WhichBlock (x, y)
Tercio@0 820 if (block) then
Tercio@0 821 if (not f.block_tracker [block]) then --> was a clear block
Tercio@0 822 f.block_tracker [block] = GetTime()
Tercio@0 823 f:Paint (f.all_blocks [block])
Tercio@0 824 end
Tercio@0 825 end
Tercio@0 826 end
Tercio@0 827 end
Tercio@0 828
Tercio@0 829 local px, py = GetPlayerMapPosition ("player")
Tercio@0 830 local player_block = f:WhichBlock (px, py)
Tercio@6 831 if (player_block and f.block_tracker [player_block] and raid_size > 0) then
Tercio@0 832
Tercio@0 833 local time_limit_at = f.block_tracker [player_block] + db.STAMPERS_DELAY
Tercio@0 834 local time_now = GetTime()
Tercio@0 835
Tercio@7 836 local timeleft = time_limit_at - time_now
Tercio@7 837 f.player_bar:SetValue ((timeleft) / db.STAMPERS_DELAY * 100)
Tercio@7 838 if (timeleft > 0) then
Tercio@7 839 f.player_bar.text:SetText (format ("%.1f", timeleft))
Tercio@7 840 else
Tercio@7 841 f.player_bar.text:SetText ("Move!")
Tercio@7 842 end
Tercio@0 843 f.player_bar:Show()
Tercio@7 844
Tercio@0 845 local block_frame = f.all_blocks [player_block]
Tercio@0 846 f.player_loc_box:SetPoint ("center", block_frame, "center")
Tercio@0 847 f.player_loc_box:Show()
Tercio@7 848
Tercio@0 849 else
Tercio@9 850 if (f.unlocked_frame) then
Tercio@9 851 f.player_loc_box:Show()
Tercio@9 852 f.player_bar:Show()
Tercio@9 853 f.player_bar:SetValue (100)
Tercio@9 854 else
Tercio@9 855 f.player_loc_box:Hide()
Tercio@9 856 f.player_bar:Hide()
Tercio@9 857 end
Tercio@0 858 end
Tercio@0 859 end
Tercio@0 860
Tercio@0 861 function f:StartTracking()
Tercio@0 862
Tercio@0 863 print ("|cFFFFAA00Hansgar and Franzok Assist|r: Smart Stampers phase started.")
Tercio@0 864
Tercio@0 865 f.StampersPhase = true
Tercio@0 866
Tercio@0 867 if (not f.frames_built) then
Tercio@0 868 f:CreateWindow()
Tercio@0 869 end
Tercio@7 870
Tercio@0 871 f:ResetBlocks()
Tercio@0 872 f.player_loc_box:Hide()
Tercio@0 873
Tercio@0 874 f.block_tracker = f.block_tracker or {}
Tercio@0 875 table.wipe (f.block_tracker)
Tercio@7 876
Tercio@0 877 SetMapToCurrentZone()
Tercio@7 878
Tercio@0 879 frame_tracker:SetScript ("OnUpdate", on_update_tracker)
Tercio@0 880 f:Show()
Tercio@7 881 f.player_bar:Show()
Tercio@7 882
Tercio@0 883 end
Tercio@0 884
Tercio@0 885 function f:StopTracking()
Tercio@0 886 print ("|cFFFFAA00Hansgar and Franzok Assist|r: Smart Stampers phase ended.")
Tercio@0 887
Tercio@0 888 f.StampersPhase = false
Tercio@0 889 frame_tracker:SetScript ("OnUpdate", nil)
Tercio@0 890 table.wipe (f.block_tracker)
Tercio@0 891 f.player_loc_box:Hide()
Tercio@0 892 f:Hide()
Tercio@7 893 f.player_bar:SetValue (0)
Tercio@7 894 f.player_bar:Hide()
Tercio@0 895 end
Tercio@0 896
Tercio@0 897 local on_mouse_down = function (self)
Tercio@5 898 if (not self.isMoving and not db.FRAME_LOCK) then
Tercio@0 899 self.isMoving = true
Tercio@0 900 f:StartMoving()
Tercio@0 901 end
Tercio@0 902 end
Tercio@0 903 local on_mouse_up = function (self)
Tercio@0 904 if (self.isMoving) then
Tercio@0 905 self.isMoving = nil
Tercio@0 906 f:StopMovingOrSizing()
Tercio@0 907 end
Tercio@0 908 end
Tercio@0 909
Tercio@0 910 local painting = function (self, elapsed)
Tercio@0 911 self.step = self.step + elapsed
Tercio@0 912 self.total_time = self.total_time + elapsed
Tercio@0 913
Tercio@0 914 if (self.step > 0.2) then
Tercio@0 915 self.step = 0
Tercio@0 916 local percent = self.total_time / db.STAMPERS_DELAY * 100
Tercio@0 917
Tercio@0 918 percent = min (percent, 100)
Tercio@0 919
Tercio@0 920 local r, g, b = f:percent_color (percent, true)
Tercio@0 921 self:SetBackdropColor (r, g, b, 0.5)
Tercio@0 922
Tercio@0 923 self.number:SetText (floor (percent) .. "%")
Tercio@0 924 self.number:SetTextColor (1, 1, 1, 1)
Tercio@0 925
Tercio@0 926 if (percent == 100) then
Tercio@0 927 self:SetScript ("OnUpdate", nil)
Tercio@0 928 self.stamper_icon:Show()
Tercio@0 929 self.number:Hide()
Tercio@5 930 self.cooldown:Show()
Tercio@4 931 self.cooldown:SetCooldown (GetTime(), 37 - db.STAMPERS_DELAY, 0, 0)
Tercio@0 932 end
Tercio@0 933 end
Tercio@0 934 end
Tercio@4 935
Tercio@4 936 function f:UnPaint (block)
Tercio@4 937 f:ResetBlock (block)
Tercio@4 938 end
Tercio@0 939 function f:Paint (block)
Tercio@0 940 block.step = 0
Tercio@0 941 block.total_time = 0
Tercio@0 942 block:SetScript ("OnUpdate", painting)
Tercio@4 943 local unpaint = f:ScheduleTimer ("UnPaint", 37, block)
Tercio@4 944 block.unpaint_process = unpaint
Tercio@4 945 end
Tercio@4 946
Tercio@4 947 function f:ResetBlock (block)
Tercio@4 948 block:SetScript ("OnUpdate", nil)
Tercio@4 949 block:SetBackdropColor (.8, .8, .8, 0.5)
Tercio@4 950 block.number:SetText (block.id)
Tercio@4 951 block.number:SetTextColor (1, 1, 1, 0.5)
Tercio@4 952 block.number:Show()
Tercio@4 953 block.stamper_icon:Hide()
Tercio@4 954 block.cooldown:SetCooldown (0, 0, 0, 0)
Tercio@5 955 block.cooldown:Hide()
Tercio@4 956
Tercio@4 957 f.block_tracker [block.id] = nil
Tercio@4 958 if (block.unpaint_process) then
Tercio@4 959 f:CancelTimer (block.unpaint_process)
Tercio@4 960 block.unpaint_process = nil
Tercio@4 961 end
Tercio@0 962 end
Tercio@0 963
Tercio@0 964 function f:ResetBlocks()
Tercio@0 965 for _, block in ipairs (f.all_blocks) do
Tercio@4 966 f:ResetBlock (block)
Tercio@4 967 end
Tercio@4 968 end
Tercio@4 969
Tercio@4 970 function f:RefreshCooldownSettings()
Tercio@4 971 for _, block in ipairs (f.all_blocks) do
Tercio@4 972 if (not db.CD_NUMBER) then
Tercio@4 973 block.cooldown:SetHideCountdownNumbers (true)
Tercio@4 974 block.cooldown:SetDrawEdge (false)
Tercio@4 975 else
Tercio@4 976 block.cooldown:SetHideCountdownNumbers (false)
Tercio@4 977 block.cooldown:SetDrawEdge (true)
Tercio@4 978 end
Tercio@0 979 end
Tercio@0 980 end
Tercio@0 981
Tercio@7 982 function f:SetLockState (just_refresh)
Tercio@7 983
Tercio@7 984 if (not just_refresh) then
Tercio@7 985 db.FRAME_LOCK = not db.FRAME_LOCK
Tercio@7 986 end
Tercio@7 987
Tercio@5 988 if (db.FRAME_LOCK) then
Tercio@5 989 --locked
Tercio@5 990 f:EnableMouse (false)
Tercio@7 991 player_bar:EnableMouse (false)
Tercio@7 992 player_pos_frame:EnableMouse (false)
Tercio@10 993 stop_casting_frame:SetMovable (false)
Tercio@10 994 stop_casting_frame:EnableMouse (false)
Tercio@7 995
Tercio@5 996 for _, block in ipairs (f.all_blocks) do
Tercio@5 997 block:EnableMouse (false)
Tercio@5 998 end
Tercio@7 999
Tercio@7 1000 if (f.StampersPhase and not just_refresh) then
Tercio@7 1001 f:EndTrackPlayerPosition()
Tercio@7 1002 f:StopTracking()
Tercio@7 1003 end
Tercio@10 1004
Tercio@5 1005 else
Tercio@5 1006 --unlocked
Tercio@5 1007 f:EnableMouse (true)
Tercio@7 1008 player_bar:EnableMouse (true)
Tercio@7 1009 player_pos_frame:EnableMouse (true)
Tercio@10 1010 stop_casting_frame:SetMovable (true)
Tercio@10 1011 stop_casting_frame:EnableMouse (true)
Tercio@7 1012
Tercio@5 1013 for _, block in ipairs (f.all_blocks) do
Tercio@5 1014 block:EnableMouse (true)
Tercio@5 1015 end
Tercio@7 1016
Tercio@7 1017 if (not f.StampersPhase and not just_refresh) then
Tercio@7 1018 f:StartTracking()
Tercio@7 1019 f:StartTrackPlayerPosition()
Tercio@7 1020 end
Tercio@10 1021
Tercio@7 1022 end
Tercio@7 1023
Tercio@7 1024 if (not db.FRAME_LOCK) then
Tercio@7 1025 player_bar.grip:Show()
Tercio@7 1026 else
Tercio@7 1027 player_bar.grip:Hide()
Tercio@5 1028 end
Tercio@5 1029 end
Tercio@5 1030
Tercio@0 1031 function f:CreateWindow()
Tercio@0 1032 local x = 0
Tercio@0 1033 local y = 0
Tercio@0 1034
Tercio@0 1035 f.player_loc_box = frame_event:CreateTexture (nil, "overlay")
Tercio@0 1036 f.player_loc_box:SetSize (32, 40)
Tercio@0 1037 f.player_loc_box:SetTexture ([[Interface\ContainerFrame\UI-Icon-QuestBorder]])
Tercio@0 1038 f.player_loc_box:Hide()
Tercio@0 1039
Tercio@0 1040 f.all_blocks = {}
Tercio@0 1041
Tercio@0 1042 for i = 1, 20 do
Tercio@0 1043
Tercio@0 1044 local block = CreateFrame ("frame", "Hansgar_And_Franzok_Assist_Block" .. i, f)
Tercio@0 1045 block:SetSize (30, 38)
Tercio@0 1046 block:SetBackdrop ({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16, insets = {left = 0, right = 0, top = 0, bottom = 0},
Tercio@0 1047 })
Tercio@0 1048 block:SetBackdropBorderColor (0, 0, 0, 1)
Tercio@0 1049 block:SetBackdropColor (.8, .8, .8, 0.5)
Tercio@0 1050 block:SetPoint ("TopLeft", f, "TopLeft", x, y)
Tercio@0 1051
Tercio@0 1052 block:SetScript ("OnMouseDown", on_mouse_down)
Tercio@0 1053 block:SetScript ("OnMouseUp", on_mouse_up)
Tercio@0 1054
Tercio@4 1055 local cooldown = CreateFrame ("cooldown", "Hansgar_And_Franzok_Assist_BlockCooldown" .. i, block, "CooldownFrameTemplate")
Tercio@4 1056 cooldown:SetAllPoints()
Tercio@4 1057 cooldown:SetFrameLevel (block:GetFrameLevel()+2)
Tercio@4 1058
Tercio@4 1059 if (not db.CD_NUMBER) then
Tercio@4 1060 cooldown:SetHideCountdownNumbers (true)
Tercio@4 1061 cooldown:SetDrawEdge (false)
Tercio@4 1062 end
Tercio@4 1063
Tercio@4 1064 block.cooldown = cooldown
Tercio@4 1065
Tercio@0 1066 block.id = i
Tercio@0 1067
Tercio@0 1068 local number = block:CreateFontString (nil, "artwork", "GameFontHighlight")
Tercio@0 1069 number:SetPoint ("center", block, "center")
Tercio@0 1070 number:SetText (i)
Tercio@0 1071 number:SetTextColor (1, 1, 1, 0.5)
Tercio@0 1072 block.number = number
Tercio@0 1073
Tercio@0 1074 local stamper_icon = block:CreateTexture (nil, "overlay")
Tercio@0 1075 stamper_icon:SetTexture ([[Interface\ICONS\Warrior_talent_icon_LambsToTheSlaughter]])
Tercio@0 1076 stamper_icon:SetTexCoord (4/64, 60/64, 4/64, 60/64)
Tercio@0 1077 stamper_icon:SetSize (24, 24)
Tercio@0 1078 stamper_icon:SetPoint ("center", block, "center")
Tercio@0 1079 stamper_icon:Hide()
Tercio@0 1080 block.stamper_icon = stamper_icon
Tercio@0 1081
Tercio@0 1082 x = x + 31
Tercio@0 1083 if (x >= 155) then
Tercio@0 1084 x = 0
Tercio@0 1085 y = y - 40
Tercio@0 1086 end
Tercio@0 1087
Tercio@0 1088 tinsert (f.all_blocks, block)
Tercio@0 1089
Tercio@0 1090 end
Tercio@0 1091
Tercio@7 1092 f:SetLockState (true)
Tercio@5 1093
Tercio@0 1094 f.frames_built = true
Tercio@0 1095
Tercio@0 1096 end
Tercio@0 1097
Tercio@4 1098 local safe_track = {
Tercio@4 1099 --space 1
Tercio@4 1100 {
Tercio@4 1101 block = {x1 = 0.50154542922974, x2 = 0.49563668874741},
Tercio@8 1102 left = {x1 = 0.49963343143463, x2 = 0.49963343143463 - 0.000624573974608},
Tercio@8 1103 right = {x1 = 0.49710285663605, x2 = 0.49710285663605 + 0.000992229919432},
Tercio@4 1104 -- {x1 = 0.49963343143463, y1 = 0.73492467403412} -- {x1 = 0.49710285663605, y1 = 0.74445152282715}
Tercio@4 1105 },
Tercio@4 1106 --space 2
Tercio@4 1107 {
Tercio@4 1108 block = {x1 = 0.4858917593956, x2 = 0.48044270277023},
Tercio@4 1109 left = {x1 = 0.48433673381805, x2 = 0.48433673381805 - 0.00091059207916},
Tercio@4 1110 right = {x1 = 0.48206025362015, x2 = 0.48206025362015 + 0.00075059207916},
Tercio@4 1111 -- {x1 = 0.48433673381805, y1 = 0.74292266368866} -- {x1 = 0.48206025362015, y1 = 0.78930181264877}
Tercio@4 1112 },
Tercio@4 1113 --space 3
Tercio@4 1114 {
Tercio@4 1115 block = {x1 = 0.47047740221024, x2 = 0.4648859500885},
Tercio@8 1116 left = {x1 = 0.46893924474716, x2 = 0.46893924474716 - 0.000902948493956},
Tercio@8 1117 right = {x1 = 0.46635687351227, x2 = 0.46635687351227 + 0.000970948493956},
Tercio@4 1118 --{x1 = 0.46893924474716, y1 = 0.7981019616127} -- {x1 = 0.46635687351227, y1 = 0.73558133840561}
Tercio@4 1119 },
Tercio@4 1120 --space 4
Tercio@4 1121 {
Tercio@4 1122 block = {x1 = 0.45503282546997, x2 = 0.44976264238358},
Tercio@8 1123 left = {x1 = 0.4533554315567, x2 = 0.4533554315567 - 0.000714573974608},
Tercio@4 1124 right = {x1 = 0.45124399662018, x2 = 0.45124399662018 + 0.000770009999999},
Tercio@4 1125 --{x1 = 0.4533554315567, y1 = 0.74078941345215} -- {x1 = 0.45124399662018, y1 = 0.74088287353516}
Tercio@4 1126 }
Tercio@4 1127 }
Tercio@4 1128 Hansgar_safe_track = safe_track
Tercio@4 1129
Tercio@4 1130 -- /hansgar test
Tercio@8 1131 -- /run Hansgar_safe_track [4].left.x2 = 0.4533554315567 - 0.000714573974608
Tercio@4 1132
Tercio@7 1133 local red_alpha_disabled = 0.2
Tercio@4 1134 local red_alpha_enabled = 0.5
Tercio@4 1135
Tercio@4 1136 local green_alpha_disabled = 0.05
Tercio@4 1137 local green_alpha_enabled = 0.9
Tercio@4 1138
Tercio@6 1139 -- true north -> south
Tercio@6 1140 -- false south -> north
Tercio@4 1141 local track_function = function (self, elapsed)
Tercio@6 1142
Tercio@4 1143 local x, _ = GetPlayerMapPosition ("player")
Tercio@4 1144 local block
Tercio@4 1145
Tercio@6 1146 if (db.AUTO_FACING and x) then
Tercio@6 1147 local facing = GetPlayerFacing()
Tercio@6 1148
Tercio@6 1149 if (self.facing and (facing > 5.3 or facing < 1.053)) then --north -> south -- ~30º tolerance
Tercio@6 1150 self.facing = false
Tercio@6 1151 --print ("changing face to south")
Tercio@6 1152 elseif (not self.facing and (facing > 2.3 and facing < 4.3)) then --south -> north -- ~30º tolerance
Tercio@6 1153 self.facing = true
Tercio@6 1154 --print ("changing face to north")
Tercio@6 1155 end
Tercio@6 1156 end
Tercio@6 1157
Tercio@6 1158 if (x) then
Tercio@6 1159 for i = 1, #safe_track do
Tercio@6 1160 local loc = safe_track [i]
Tercio@6 1161 if (x >= loc.block.x2 and x <= loc.block.x1) then
Tercio@6 1162 block = i
Tercio@6 1163 break
Tercio@6 1164 end
Tercio@4 1165 end
Tercio@4 1166 end
Tercio@4 1167
Tercio@6 1168 if (block and safe_track [block]) then
Tercio@4 1169
Tercio@4 1170 player_pos_frame:Show()
Tercio@4 1171 block = safe_track [block]
Tercio@4 1172
Tercio@4 1173 if (x >= block.left.x2 and x <= block.left.x1) then
Tercio@6 1174 if (self.facing) then
Tercio@6 1175 t2:SetTexture (0.1, 1, 0.1, green_alpha_enabled)
Tercio@6 1176 t3:SetTexture (0.2, 1, 0.2, green_alpha_disabled)
Tercio@6 1177 else
Tercio@6 1178 t3:SetTexture (0.2, 232/255, 1, green_alpha_enabled)
Tercio@6 1179 t2:SetTexture (0.2, 232/255, 1, green_alpha_disabled)
Tercio@6 1180 end
Tercio@4 1181
Tercio@4 1182 t1:SetVertexColor (1, 0.2, 0.2, red_alpha_disabled) --red
Tercio@4 1183 t4:SetVertexColor (1, 0.2, 0.2, red_alpha_disabled) --red
Tercio@4 1184 middle:SetVertexColor (1, 0.2, 0.2, red_alpha_disabled) --red
Tercio@4 1185
Tercio@4 1186 elseif (x <= block.right.x2 and x >= block.right.x1) then
Tercio@6 1187 if (self.facing) then
Tercio@6 1188 t3:SetTexture (0.1, 1, 0.1, green_alpha_enabled)
Tercio@6 1189 t2:SetTexture (0.2, 1, 0.2, green_alpha_disabled)
Tercio@6 1190 else
Tercio@6 1191 t2:SetTexture (0.2, 232/255, 1, green_alpha_enabled)
Tercio@6 1192 t3:SetTexture (0.2, 232/255, 1, green_alpha_disabled)
Tercio@6 1193 end
Tercio@4 1194
Tercio@4 1195 t1:SetVertexColor (1, 0.2, 0.2, red_alpha_disabled) --red
Tercio@4 1196 t4:SetVertexColor (1, 0.2, 0.2, red_alpha_disabled) --red
Tercio@4 1197 middle:SetVertexColor (1, 0.2, 0.2, red_alpha_disabled) --red
Tercio@4 1198
Tercio@4 1199 else
Tercio@4 1200 t1:SetVertexColor (1, 0.2, 0.2, red_alpha_enabled) --red
Tercio@4 1201 t4:SetVertexColor (1, 0.2, 0.2, red_alpha_enabled) --red
Tercio@4 1202 middle:SetVertexColor (1, 0.2, 0.2, red_alpha_enabled) --red
Tercio@4 1203
Tercio@4 1204 t2:SetTexture (0.2, 1, 0.2, green_alpha_disabled)
Tercio@4 1205 t3:SetTexture (0.2, 1, 0.2, green_alpha_disabled)
Tercio@4 1206
Tercio@4 1207 end
Tercio@4 1208
Tercio@4 1209 --x = x - block.block.x2
Tercio@4 1210 --local at = abs ((x / (block.block.x1 - block.block.x2) * 100) - 100)
Tercio@4 1211 --div:SetPoint ("left", player_pos_frame, "left", self.width_pixel * at, 0)
Tercio@4 1212
Tercio@4 1213 else
Tercio@9 1214 if (f.unlocked_frame) then
Tercio@9 1215 player_pos_frame:Show()
Tercio@9 1216 else
Tercio@9 1217 player_pos_frame:Hide()
Tercio@9 1218 end
Tercio@4 1219 end
Tercio@4 1220 end
Tercio@4 1221
Tercio@4 1222 function f:StartTrackPlayerPosition()
Tercio@4 1223 player_pos_frame:Show()
Tercio@4 1224 tframe.width = player_pos_frame:GetWidth()
Tercio@4 1225 tframe.width_pixel = tframe.width / 100
Tercio@6 1226 tframe.facing = db.FACING_SIDE == 1
Tercio@4 1227 tframe:SetScript ("OnUpdate", track_function)
Tercio@4 1228 end
Tercio@4 1229 function f:EndTrackPlayerPosition()
Tercio@4 1230 player_pos_frame:Hide()
Tercio@4 1231 tframe:SetScript ("OnUpdate", nil)
Tercio@4 1232 end
Tercio@4 1233
Tercio@0 1234 local locs = {
Tercio@0 1235 --block 1:
Tercio@1 1236 {x1 = 0.51103663444519, y1 = 0.79726493358612, x2 = 0.50061076879501, y2 = 0.8241291642189},
Tercio@0 1237 --block 2:
Tercio@1 1238 {x1 = 0.49670505523682, y1 = 0.79692482948303, x2 = 0.48469054698944, y2 = 0.82489335536957},
Tercio@0 1239 --block 3:
Tercio@1 1240 {x1 = 0.48130965232849, y1 = 0.79742962121964, x2 = 0.46962946653366, y2 = 0.82453238964081},
Tercio@0 1241 --block 4:
Tercio@1 1242 {x1 = 0.46575212478638, y1 = 0.79766929149628, x2 = 0.45400339365005, y2 = 0.82176661491394},
Tercio@0 1243 --block 5:
Tercio@1 1244 {x1 = 0.45073217153549, y1 = 0.79751670360565, x2 = 0.43945103883743, y2 = 0.82504689693451},
Tercio@0 1245
Tercio@0 1246 --block 6
Tercio@1 1247 {x1 = 0.51104211807251, y1 = 0.76532691717148, x2 = 0.50021582841873, y2 = 0.79546189308167},
Tercio@1 1248 --block 7
Tercio@1 1249 {x1 = 0.4964514374733, y1 = 0.76603573560715, x2 = 0.48449218273163, y2 = 0.79527854919434},
Tercio@1 1250 --block 8
Tercio@1 1251 {x1 = 0.48101079463959, y1 = 0.76503103971481, x2 = 0.46944016218185, y2 = 0.79543298482895},
Tercio@1 1252 --block 9
Tercio@1 1253 {x1 = 0.46541726589203, y1 = 0.7654857635498, x2 = 0.45369201898575, y2 = 0.79529416561127},
Tercio@1 1254 --block 10
Tercio@1 1255 {x1 = 0.45051556825638, y1 = 0.76583826541901, x2 = 0.43931984901428, y2 = 0.79570162296295},
Tercio@1 1256
Tercio@1 1257
Tercio@1 1258 --block 11
Tercio@0 1259 {x1 = 0.51104187965393, y1 = 0.73422884941101, x2 = 0.49990028142929, y2 = 0.76343530416489},
Tercio@1 1260 --block 12
Tercio@0 1261 {x1 = 0.49673527479172, y1 = 0.73338270187378, x2 = 0.48483556509018, y2 = 0.76356953382492},
Tercio@1 1262 --block 13
Tercio@0 1263 {x1 = 0.48133307695389, y1 = 0.73373115062714, x2 = 0.46920585632324, y2 = 0.76366758346558},
Tercio@1 1264 --block 14
Tercio@0 1265 {x1 = 0.46568286418915, y1 = 0.73440700769424, x2 = 0.45381307601929, y2 = 0.76358675956726},
Tercio@1 1266 --block 15
Tercio@0 1267 {x1 = 0.45046973228455, y1 = 0.73361301422119, x2 = 0.43929302692413, y2 = 0.76388084888458},
Tercio@0 1268
Tercio@0 1269 --block 16
Tercio@1 1270 {x1 = 0.51104891300201, y1 = 0.70877063274384, x2 = 0.50024521350861, y2 = 0.73220580816269},
Tercio@0 1271 --block 17
Tercio@1 1272 {x1 = 0.49676024913788, y1 = 0.70914703607559, x2 = 0.48485481739044, y2 = 0.73210543394089},
Tercio@0 1273 --block 18
Tercio@1 1274 {x1 = 0.48142266273499, y1 = 0.70876735448837, x2 = 0.46925610303879, y2 = 0.73205661773682},
Tercio@0 1275 --block 19
Tercio@1 1276 {x1 = 0.46603119373322, y1 = 0.70929777622223, x2 = 0.45397216081619, y2 = 0.73167610168457},
Tercio@0 1277 --block 20
Tercio@1 1278 {x1 = 0.45079308748245, y1 = 0.70926278829575, x2 = 0.43927478790283, y2 = 0.73225915431976},
Tercio@0 1279 }
Tercio@0 1280
Tercio@0 1281 function f:WhichBlock (x, y)
Tercio@0 1282 for i = 1, #locs do
Tercio@0 1283 local loc = locs [i]
Tercio@0 1284 if (x >= loc.x2 and x <= loc.x1 and y >= loc.y1 and y <= loc.y2) then
Tercio@0 1285 return i
Tercio@0 1286 end
Tercio@0 1287 end
Tercio@0 1288 end
Tercio@0 1289
Tercio@0 1290 function f:percent_color (value, inverted)
Tercio@0 1291 local r, g
Tercio@0 1292 if (value < 50) then
Tercio@0 1293 r = 255
Tercio@0 1294 else
Tercio@0 1295 r = floor ( 255 - (value * 2 - 100) * 255 / 100)
Tercio@0 1296 end
Tercio@0 1297
Tercio@0 1298 if (value > 50) then
Tercio@0 1299 g = 255
Tercio@0 1300 else
Tercio@0 1301 g = floor ( (value * 2) * 255 / 100)
Tercio@0 1302 end
Tercio@0 1303
Tercio@0 1304 if (inverted) then
Tercio@0 1305 return g/255, r/255, 0
Tercio@0 1306 else
Tercio@0 1307 return r/255, g/255, 0
Tercio@0 1308 end
Tercio@0 1309 end