From d36fc7bdfc90ab13479cd9e9734ac3407a2ff0cc Mon Sep 17 00:00:00 2001 From: Kkthnx <40672673+Kkthnx@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:22:40 -0500 Subject: [PATCH] Various updates and fixes. Release soon! --- .../Config/Elements/AuraWatchList/All.lua | 13 +- .../Config/Elements/AuraWatchList/Hunter.lua | 1 + .../Elements/FilterLists/NameplateAuras.lua | 5 +- KkthnxUI/Config/GUI.lua | 1 - KkthnxUI/Config/Settings.lua | 1 - KkthnxUI/Core/GUI.lua | 3 +- KkthnxUI/Developer/Core.lua | 102 +++- KkthnxUI/Libraries/LibAnim/LibAnim.lua | 6 +- KkthnxUI/Libraries/LibDeflate/LibDeflate.lua | 563 ++++++------------ .../LibRangeCheck-3.0/LibRangeCheck-3.0.lua | 2 +- .../Modules/ActionBars/Elements/Extrabar.lua | 20 + KkthnxUI/Modules/Auras/Lumos/Evoker.lua | 8 +- .../Automation/Elements/Screenshot.lua | 8 +- KkthnxUI/Modules/Blizzard/Elements/Fixes.lua | 127 ++++ KkthnxUI/Modules/DataText/Elements/Gold.lua | 24 +- KkthnxUI/Modules/DataText/Elements/Time.lua | 1 + KkthnxUI/Modules/Load_Modules.xml | 2 + KkthnxUI/Modules/Miscellaneous/Core.lua | 141 +---- .../Miscellaneous/Elements/QuickJoin.lua | 2 +- .../Modules/Skins/Blizzard/FrameXML/Menu.lua | 1 + .../Skins/Blizzard/ProfessionsBook.lua | 99 +++ .../Modules/UnitFrames/Elements/Tracking.lua | 24 +- KkthnxUI/Modules/UnitFrames/Groups/Raid.lua | 6 - .../UnitFrames/Plugins/oUF_RaidDebuffs.lua | 191 +++--- .../Modules/UnitFrames/Units/Nameplates.lua | 34 +- 25 files changed, 735 insertions(+), 650 deletions(-) create mode 100644 KkthnxUI/Modules/Blizzard/Elements/Fixes.lua create mode 100644 KkthnxUI/Modules/Skins/Blizzard/ProfessionsBook.lua diff --git a/KkthnxUI/Config/Elements/AuraWatchList/All.lua b/KkthnxUI/Config/Elements/AuraWatchList/All.lua index 0c6aac93..d38082b5 100644 --- a/KkthnxUI/Config/Elements/AuraWatchList/All.lua +++ b/KkthnxUI/Config/Elements/AuraWatchList/All.lua @@ -15,8 +15,13 @@ local list = { { AuraID = 371024, UnitID = "player" }, -- 元素强能药水 { AuraID = 371028, UnitID = "player" }, -- 究极元素强能药水 -- 11.0 饰品 + { AuraID = 92099, UnitID = "player" }, -- 灰鳞的优雅 + { AuraID = 268769, UnitID = "player" }, -- 望远镜饰品 { AuraID = 443531, UnitID = "player" }, -- 振奋之光 { AuraID = 435493, UnitID = "player" }, -- 死亡之吻 + { AuraID = 455451, UnitID = "player" }, -- 迅芯烛台 + { AuraID = 449954, UnitID = "player" }, -- 奸邪发射机 + { AuraID = 449947, UnitID = "player", Text = NPE_JUMP }, -- 奸邪发射机,跳3下 -- 10.0 饰品 { AuraID = 381476, UnitID = "player" }, -- 爆发烈焰 { AuraID = 383941, UnitID = "player" }, -- 崩坏之力 @@ -230,6 +235,7 @@ local list = { { AuraID = 464748, UnitID = "player", Flash = true }, -- 束缚之网,流丝 }, ["Warning"] = { -- 目标重要光环组 + { AuraID = 268756, UnitID = "target", Caster = "player" }, -- 望远镜饰品 { AuraID = 355596, UnitID = "target", Flash = true }, -- 橙弓,哀痛箭 -- 大幻象 { AuraID = 304975, UnitID = "target", Value = true }, -- 虚空哀嚎,吸收盾 @@ -237,6 +243,7 @@ local list = { -- 大米 { AuraID = 226510, UnitID = "target" }, -- 血池回血 { AuraID = 343502, UnitID = "target" }, -- 鼓舞光环 + { AuraID = 462704, UnitID = "target" }, -- 碎裂精华,TWW S1 -- 5人 { AuraID = 372988, UnitID = "target", Value = true }, -- 寒冰壁垒,红玉 { AuraID = 391050, UnitID = "target", Value = true }, -- 暴风骤雨之盾,红玉 @@ -284,12 +291,16 @@ local list = { { AuraID = 321754, UnitID = "target", Value = true }, -- 通灵战潮,冰缚之盾 { AuraID = 343470, UnitID = "target", Value = true }, -- 通灵战潮,碎骨之盾 { AuraID = 328351, UnitID = "target", Flash = true }, -- 通灵战潮,染血长枪 + { AuraID = 273721, UnitID = "target", Flash = true }, -- 围攻,1号易伤 + { AuraID = 423588, UnitID = "target", Value = true }, -- 修道院,圣光屏障 -- S1 { AuraID = 445409, UnitID = "target", Value = true }, -- 加固壳壁,斯卡莫拉克 -- Raids { AuraID = 440177, UnitID = "target", Flash = true }, -- 准备饕餮,噬灭者乌格拉克斯 { AuraID = 450980, UnitID = "target", Value = true }, -- 存在瓦解,阿努巴拉什 { AuraID = 451277, UnitID = "target", Value = true }, -- 尖刺风暴,阿努巴拉什 + { AuraID = 440179, UnitID = "target", Value = true }, -- 缠绕,阿努巴拉什 + { AuraID = 456245, UnitID = "target", Value = true }, -- 刺痛谵妄,阿努巴拉什 { AuraID = 448488, UnitID = "target", Value = true }, -- 崇拜者的保护,尾王 -- PVP { AuraID = 498, UnitID = "target" }, -- 圣佑术 @@ -334,7 +345,7 @@ local list = { { AuraID = 228323, UnitID = "target", Value = true }, -- 克罗塔的护盾 }, ["InternalCD"] = { -- 自定义内置冷却组 - { IntID = 450978, Duration = 15.4 }, -- 皎月风暴,猎人英雄天赋 + { IntID = 450978, Duration = 13.7 }, -- 皎月风暴,猎人英雄天赋 { IntID = 114018, Duration = 15, OnSuccess = true, UnitID = "all" }, -- 帷幕 -- {IntID = 240447, Duration = 20}, -- 大米,践踏 -- {IntID = 316958, Duration = 30, OnSuccess = true, UnitID = "all"}, -- 红土 diff --git a/KkthnxUI/Config/Elements/AuraWatchList/Hunter.lua b/KkthnxUI/Config/Elements/AuraWatchList/Hunter.lua index b07a122a..2a00a4c1 100644 --- a/KkthnxUI/Config/Elements/AuraWatchList/Hunter.lua +++ b/KkthnxUI/Config/Elements/AuraWatchList/Hunter.lua @@ -52,6 +52,7 @@ local list = { { AuraID = 392956, UnitID = "player" }, -- 巨熊之韧 { AuraID = 407405, UnitID = "player" }, -- 弦之韵律 { AuraID = 359844, UnitID = "player" }, -- 荒野的召唤 + { AuraID = 360952, UnitID = "player" }, -- 协同进攻 { AuraID = 388045, UnitID = "player", Flash = true }, -- 警戒 { AuraID = 378770, UnitID = "player", Flash = true }, -- 夺命打击 { AuraID = 378747, UnitID = "player", Flash = true }, -- 凶暴兽群 diff --git a/KkthnxUI/Config/Elements/FilterLists/NameplateAuras.lua b/KkthnxUI/Config/Elements/FilterLists/NameplateAuras.lua index 5c1a63d4..4859fb0f 100644 --- a/KkthnxUI/Config/Elements/FilterLists/NameplateAuras.lua +++ b/KkthnxUI/Config/Elements/FilterLists/NameplateAuras.lua @@ -1,6 +1,7 @@ local C = KkthnxUI[2] C.NameplateWhiteList = { + [268756] = true, -- 望远镜饰品 -- Buffs [642] = true, -- Divine Shield [1022] = true, -- Hand of Protection @@ -94,7 +95,7 @@ C.NameplateShowPowerList = { } C.NameplateTargetNPCs = { - [165251] = true, -- Sylvan Fox + -- [165251] = true, -- Sylvan Fox [174773] = true, -- Spiteful Fiend } @@ -188,7 +189,7 @@ C.MajorSpells = { [381694] = true, -- Decaying Senses, Fernskin [388060] = true, -- Stinking Breath, Fernskin [383385] = true, -- Rotting Surge, Fernskin - [382172] = true, -- Necrotic Breath, Fernskin + [382712] = true, -- Necrotic Breath, Fernskin [384899] = true, -- Bone Arrow Rain, Fernskin [378282] = true, -- Molten Core, Nassarius [383651] = true, -- Molten Legion, Nassarius diff --git a/KkthnxUI/Config/GUI.lua b/KkthnxUI/Config/GUI.lua index 59f014c0..d12f0b73 100644 --- a/KkthnxUI/Config/GUI.lua +++ b/KkthnxUI/Config/GUI.lua @@ -839,7 +839,6 @@ local Misc = function(self) end Window:CreateSwitch("Misc", "QuickJoin", newFeatureIcon .. L["QuickJoin"], L["QuickJoinTip"]) Window:CreateSwitch("Misc", "ItemLevel", L["Show Character/Inspect ItemLevel Info"]) - Window:CreateSwitch("Misc", "DeathCounter", "Track and display the total deaths and level-specific deaths") end local Nameplate = function(self) diff --git a/KkthnxUI/Config/Settings.lua b/KkthnxUI/Config/Settings.lua index 9c040d2f..08f553b0 100644 --- a/KkthnxUI/Config/Settings.lua +++ b/KkthnxUI/Config/Settings.lua @@ -422,7 +422,6 @@ C["Misc"] = { MaxCameraZoom = 2.6, MuteSounds = true, NoTalkingHead = false, - DeathCounter = true, ParagonEnable = false, QuestTool = false, QueueTimers = false, diff --git a/KkthnxUI/Core/GUI.lua b/KkthnxUI/Core/GUI.lua index c62a9c8a..fbfc296b 100644 --- a/KkthnxUI/Core/GUI.lua +++ b/KkthnxUI/Core/GUI.lua @@ -397,7 +397,6 @@ local SwitchOnLeave = function(self) end local CreateSwitch = function(self, group, option, text, tooltip, hook) - -- print("group:", group, "option:", option) local Value = C[group][option] local Anchor = CreateFrame("Frame", nil, self) @@ -440,7 +439,7 @@ local CreateSwitch = function(self, group, option, text, tooltip, hook) Switch.Label = Switch:CreateFontString(nil, "OVERLAY") Switch.Label:SetPoint("LEFT", Switch, "RIGHT", Spacing, 0) - Switch.Label:SetWidth(WidgetListWidth - SwitchWidth - (Spacing * 4)) + Switch.Label:SetWidth(WidgetListWidth - SwitchWidth - 40, WidgetHeight) Switch.Label:SetJustifyH("LEFT") Switch.Label:SetFontObject(K.UIFont) Switch.Label:SetText(text) diff --git a/KkthnxUI/Developer/Core.lua b/KkthnxUI/Developer/Core.lua index a58dc06d..46550cd8 100644 --- a/KkthnxUI/Developer/Core.lua +++ b/KkthnxUI/Developer/Core.lua @@ -1,5 +1,5 @@ local K, C, L = KkthnxUI[1], KkthnxUI[2], KkthnxUI[3] --- local Module = K:NewModule("Developer") +local Module = K:NewModule("Developer") K.Devs = { ["Kkthnx-Area 52"] = true, @@ -14,3 +14,103 @@ K.isDeveloper = isDeveloper if not K.isDeveloper then return end + +local _G = _G +local ShowUIPanel = ShowUIPanel +local GetInstanceInfo = GetInstanceInfo +local InCombatLockdown = InCombatLockdown + +local C_TalkingHead_SetConversationsDeferred = C_TalkingHead.SetConversationsDeferred + +local Config_ObjectiveFrameAutoHideInKeystone = true +local Config_ObjectiveFrameAutoHide = true + +local function IsQuestTrackerLoaded() + return C_AddOns.IsAddOnLoaded("!KalielsTracker") or C_AddOns.IsAddOnLoaded("DugisGuideViewerZ") +end + +local function IsObjectiveTrackerCollapsed(frame) + return frame:GetParent() == K.UIFrameHider +end + +local function CollapseObjectiveTracker(frame) + frame:SetParent(K.UIFrameHider) +end + +local function ExpandObjectiveTracker(frame) + frame:SetParent(_G.UIParent) +end + +local function AutoHideObjectiveTrackerOnShow() + local tracker = _G.ObjectiveTrackerFrame + if tracker and IsObjectiveTrackerCollapsed(tracker) then + ExpandObjectiveTracker(tracker) + end +end + +local function AutoHideObjectiveTrackerOnHide() + local tracker = _G.ObjectiveTrackerFrame + if not tracker or IsObjectiveTrackerCollapsed(tracker) then + return + end + + if Config_ObjectiveFrameAutoHideInKeystone then + CollapseObjectiveTracker(tracker) + else + local _, _, difficultyID = GetInstanceInfo() + if difficultyID ~= 8 then -- ignore hide in keystone runs + CollapseObjectiveTracker(tracker) + end + end +end + +local function AutoHideObjectiveTracker() + local tracker = _G.ObjectiveTrackerFrame + if not tracker then + return + end + + if not AutoHider then + AutoHider = CreateFrame("Frame", nil, UIParent, "SecureHandlerStateTemplate") + AutoHider:SetAttribute("_onstate-objectiveHider", "if newstate == 1 then self:Hide() else self:Show() end") + AutoHider:SetScript("OnHide", AutoHideObjectiveTrackerOnHide) + AutoHider:SetScript("OnShow", AutoHideObjectiveTrackerOnShow) + end + + if Config_ObjectiveFrameAutoHide then + RegisterStateDriver(AutoHider, "objectiveHider", "[@arena1,exists][@arena2,exists][@arena3,exists][@arena4,exists][@arena5,exists][@boss1,exists][@boss2,exists][@boss3,exists][@boss4,exists][@boss5,exists]1;0") + else + UnregisterStateDriver(AutoHider, "objectiveHider") + AutoHideObjectiveTrackerOnShow() -- reshow it when needed + end +end + +local function SplashFrame_OnHide(frame) + local fromGameMenu = frame.screenInfo and frame.screenInfo.gameMenuRequest + frame.screenInfo = nil + + C_TalkingHead_SetConversationsDeferred(false) + _G.AlertFrame:SetAlertsEnabled(true, "splashFrame") + + if fromGameMenu and not frame.showingQuestDialog and not InCombatLockdown() then + ShowUIPanel(_G.GameMenuFrame) + end + + frame.showingQuestDialog = nil +end + +local function SetupObjectiveTracker() + AutoHideObjectiveTracker() + + local splash = _G.SplashFrame + if splash then + splash:SetScript("OnHide", SplashFrame_OnHide) + end +end + +-- Module's OnEnable function. +function Module:OnEnable() + if not IsQuestTrackerLoaded() then + SetupObjectiveTracker() + end +end diff --git a/KkthnxUI/Libraries/LibAnim/LibAnim.lua b/KkthnxUI/Libraries/LibAnim/LibAnim.lua index 22d0271a..4003264d 100644 --- a/KkthnxUI/Libraries/LibAnim/LibAnim.lua +++ b/KkthnxUI/Libraries/LibAnim/LibAnim.lua @@ -1,5 +1,5 @@ -- LibAnim by Hydra -local Version = 2.901 -- based on 2.03 +local Version = 2.902 -- based on 2.03 -- Note, deprecated items will be removed next version. -- Please update your usage accordingly. (ctrl + f - "Deprecated") @@ -1102,11 +1102,11 @@ Update.color = function(self, elapsed, i) elseif self.children then self.ColorOffset = Easing[self.Easing](self.Timer, 0, self.Duration, self.Duration) for _, child in pairs(self.children) do - Set[self.ColorType](child, GetColor(self.Timer / self.Duration, self.StartR, self.StartG, self.StartB, self.EndR, self.EndG, self.EndB)) + Set[self.ColorType](child, GetColor(self.ColorOffset / self.Duration, self.StartR, self.StartG, self.StartB, self.EndR, self.EndG, self.EndB)) end else self.ColorOffset = Easing[self.Easing](self.Timer, 0, self.Duration, self.Duration) - Set[self.ColorType](self.Parent, GetColor(self.Timer / self.Duration, self.StartR, self.StartG, self.StartB, self.EndR, self.EndG, self.EndB)) + Set[self.ColorType](self.Parent, GetColor(self.ColorOffset / self.Duration, self.StartR, self.StartG, self.StartB, self.EndR, self.EndG, self.EndB)) end end diff --git a/KkthnxUI/Libraries/LibDeflate/LibDeflate.lua b/KkthnxUI/Libraries/LibDeflate/LibDeflate.lua index 055114ba..f6fb7e09 100644 --- a/KkthnxUI/Libraries/LibDeflate/LibDeflate.lua +++ b/KkthnxUI/Libraries/LibDeflate/LibDeflate.lua @@ -5,7 +5,7 @@ DEFLATE/zlib format. @file LibDeflate.lua @author Haoqian He (Github: SafeteeWoW; World of Warcraft: Safetyy-Illidan(US)) -@copyright LibDeflate <2018-2020> Haoqian He +@copyright LibDeflate <2018-2021> Haoqian He @license zlib License This library is implemented according to the following specifications.
@@ -24,11 +24,10 @@ the library.
Submit suggestions or report bugs to https://github.com/safeteeWow/LibDeflate/issues ]] - --[[ zlib License -(C) 2018-2020 Haoqian He +(C) 2018-2021 Haoqian He This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -75,7 +74,6 @@ Their original licenses shall be comply when used. Licensed under GPLv2. For the 6bit encoding and decoding. ]] - --[[ Curseforge auto-packaging replacements: @@ -83,7 +81,6 @@ Their original licenses shall be comply when used. Project Hash: @project-hash@ Project Version: @project-version@ --]] - local LibDeflate do @@ -107,7 +104,7 @@ do -- 3 : v1.0.2 local _MINOR = 3 - local _COPYRIGHT = "LibDeflate " .. _VERSION .. " Copyright (C) 2018-2020 Haoqian He." .. " Licensed under the zlib License" + local _COPYRIGHT = "LibDeflate " .. _VERSION .. " Copyright (C) 2018-2021 Haoqian He." .. " Licensed under the zlib License" -- Register in the World of Warcraft library "LibStub" if detected. if LibStub then @@ -144,10 +141,6 @@ local table_concat = table.concat local table_sort = table.sort local tostring = tostring local type = type -local coroutine_create = coroutine.create -local coroutine_status = coroutine.status -local coroutine_resume = coroutine.resume -local coroutine_yield = coroutine.yield -- Converts i to 2^i, (0<=i<=32) -- This is used to implement bit left shift and bit right shift. @@ -329,7 +322,27 @@ local _dist_deflate_code_to_extra_bitlen = { -- The code order of the first huffman header in the dynamic deflate block. -- See the page 12 of RFC1951 -local _rle_codes_huffman_bitlen_order = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 } +local _rle_codes_huffman_bitlen_order = { + 16, + 17, + 18, + 0, + 8, + 7, + 9, + 6, + 10, + 5, + 11, + 4, + 12, + 3, + 13, + 2, + 14, + 1, + 15, +} -- The following tables are used by fixed deflate block. -- The value of these tables are assigned at the bottom of the source. @@ -647,45 +660,45 @@ local function IsValidDictionary(dictionary) end --[[ - key of the configuration table is the compression level, - and its value stores the compression setting. - These numbers come from zlib source code. - - Higher compression level usually means better compression. - (Because LibDeflate uses a simplified version of zlib algorithm, - there is no guarantee that higher compression level does not create - bigger file than lower level, but I can say it's 99% likely) - - Be careful with the high compression level. This is a pure lua - implementation compressor/decompressor, which is significant slower than - a C/C++ equivalant compressor/decompressor. Very high compression level - costs significant more CPU time, and usually compression size won't be - significant smaller when you increase compression level by 1, when the - level is already very high. Benchmark yourself if you can afford it. - - See also https://github.com/madler/zlib/blob/master/doc/algorithm.txt, - https://github.com/madler/zlib/blob/master/deflate.c for more information. - - The meaning of each field: - @field 1 use_lazy_evaluation: - true/false. Whether the program uses lazy evaluation. - See what is "lazy evaluation" in the link above. - lazy_evaluation improves ratio, but relatively slow. - @field 2 good_prev_length: - Only effective if lazy is set, Only use 1/4 of max_chain, - if prev length of lazy match is above this. - @field 3 max_insert_length/max_lazy_match: - If not using lazy evaluation, - insert new strings in the hash table only if the match length is not - greater than this length. - If using lazy evaluation, only continue lazy evaluation, - if previous match length is strictly smaller than this value. - @field 4 nice_length: - Number. Don't continue to go down the hash chain, - if match length is above this. - @field 5 max_chain: - Number. The maximum number of hash chains we look. ---]] + key of the configuration table is the compression level, + and its value stores the compression setting. + These numbers come from zlib source code. + + Higher compression level usually means better compression. + (Because LibDeflate uses a simplified version of zlib algorithm, + there is no guarantee that higher compression level does not create + bigger file than lower level, but I can say it's 99% likely) + + Be careful with the high compression level. This is a pure lua + implementation compressor/decompressor, which is significant slower than + a C/C++ equivalant compressor/decompressor. Very high compression level + costs significant more CPU time, and usually compression size won't be + significant smaller when you increase compression level by 1, when the + level is already very high. Benchmark yourself if you can afford it. + + See also https://github.com/madler/zlib/blob/master/doc/algorithm.txt, + https://github.com/madler/zlib/blob/master/deflate.c for more information. + + The meaning of each field: + @field 1 use_lazy_evaluation: + true/false. Whether the program uses lazy evaluation. + See what is "lazy evaluation" in the link above. + lazy_evaluation improves ratio, but relatively slow. + @field 2 good_prev_length: + Only effective if lazy is set, Only use 1/4 of max_chain, + if prev length of lazy match is above this. + @field 3 max_insert_length/max_lazy_match: + If not using lazy evaluation, + insert new strings in the hash table only if the match length is not + greater than this length. + If using lazy evaluation, only continue lazy evaluation, + if previous match length is strictly smaller than this value. + @field 4 nice_length: + Number. Don't continue to go down the hash chain, + if match length is above this. + @field 5 max_chain: + Number. The maximum number of hash chains we look. + --]] local _compression_level_configs = { [0] = { false, nil, 0, 0, 0 }, -- level 0, no compression [1] = { false, nil, 4, 8, 4 }, -- level 1, similar to zlib level 1 @@ -695,7 +708,7 @@ local _compression_level_configs = { [5] = { true, 8, 16, 32, 32 }, -- level 5, similar to zlib level 5 [6] = { true, 8, 16, 128, 128 }, -- level 6, similar to zlib level 6 [7] = { true, 8, 32, 128, 256 }, -- (SLOW) level 7, similar to zlib level 7 - [8] = { true, 32, 128, 258, 1024 }, --(SLOW) level 8,similar to zlib level 8 + [8] = { true, 32, 128, 258, 1024 }, -- (SLOW) level 8,similar to zlib level 8 [9] = { true, 32, 258, 258, 4096 }, -- (VERY SLOW) level 9, similar to zlib level 9 } @@ -725,7 +738,7 @@ local function IsValidArguments(str, check_dictionary, dictionary, check_configs end if type_configs == "table" then for k, v in pairs(configs) do - if k ~= "level" and k ~= "strategy" and k ~= "chunksMode" and k ~= "yieldOnChunkSize" and k ~= "yieldOnChunkTime" and k ~= "timeFn" then + if k ~= "level" and k ~= "strategy" then return false, ("'configs' - unsupported table key in the configs: '%s'."):format(k) elseif k == "level" and not _compression_level_configs[v] then return false, ("'configs' - unsupported 'level': %s."):format(tostring(v)) @@ -740,8 +753,8 @@ local function IsValidArguments(str, check_dictionary, dictionary, check_configs end --[[ -------------------------------------------------------------------------- - Compress code ---]] + Compress code + --]] -------------------------------------------------------------------------- -- partial flush to save memory @@ -754,12 +767,12 @@ local _FLUSH_MODE_BYTE_BOUNDARY = 2 local _FLUSH_MODE_NO_FLUSH = 3 --[[ - Create an empty writer to easily write stuffs as the unit of bits. - Return values: - 1. WriteBits(code, bitlen): - 2. WriteString(str): - 3. Flush(mode): ---]] + Create an empty writer to easily write stuffs as the unit of bits. + Return values: + 1. WriteBits(code, bitlen): + 2. WriteString(str): + 3. Flush(mode): + --]] local function CreateWriter() local buffer_size = 0 local cache = 0 @@ -994,11 +1007,11 @@ local function GetHuffmanBitlenAndCode(symbol_counts, max_bitlen, max_symbol) local bitlen_counts = {} --[[ - tree[1]: weight, temporarily used as parent and bitLengths - tree[2]: symbol - tree[3]: left child - tree[4]: right child - --]] + tree[1]: weight, temporarily used as parent and bitLengths + tree[2]: symbol + tree[3]: left child + tree[4]: right child + --]] local number_unique_symbols = 0 for symbol, count in pairs(symbol_counts) do number_unique_symbols = number_unique_symbols + 1 @@ -1194,21 +1207,15 @@ end -- @param end str[index] will be the last character to be loaded -- @param offset str[index] will be loaded into t[index-offset] -- @return t -local function LoadStringToTable(str, t, start, stop, offset, chunks) +local function LoadStringToTable(str, t, start, stop, offset) local i = start - offset while i <= stop - 15 - offset do t[i], t[i + 1], t[i + 2], t[i + 3], t[i + 4], t[i + 5], t[i + 6], t[i + 7], t[i + 8], t[i + 9], t[i + 10], t[i + 11], t[i + 12], t[i + 13], t[i + 14], t[i + 15] = string_byte(str, i + offset, i + 15 + offset) i = i + 16 - if chunks then - chunks:doYield(stop - start) - end end while i <= stop - offset do t[i] = string_byte(str, i + offset, i + offset) i = i + 1 - if chunks then - chunks:doYield(stop - start) - end end return t end @@ -1259,7 +1266,7 @@ local function GetBlockLZ77Result(level, string_table, hash_tables, block_start, local config = _compression_level_configs[level] local config_use_lazy, config_good_prev_length, config_max_lazy_match, config_nice_length, config_max_hash_chain = config[1], config[2], config[3], config[4], config[5] - local config_max_insert_length = not config_use_lazy and config_max_lazy_match or 2147483646 + local config_max_insert_length = (not config_use_lazy) and config_max_lazy_match or 2147483646 local config_good_hash_chain = (config_max_hash_chain - config_max_hash_chain % 4 / 4) local hash @@ -1468,7 +1475,7 @@ local function GetBlockLZ77Result(level, string_table, hash_tables, block_start, end index = index + prev_len - (config_use_lazy and 1 or 0) match_available = false - elseif not config_use_lazy or match_available then + elseif (not config_use_lazy) or match_available then local code = string_table[config_use_lazy and (string_table_index - 1) or string_table_index] lcode_tblsize = lcode_tblsize + 1 lcodes[lcode_tblsize] = code @@ -1750,7 +1757,6 @@ local function Deflate(configs, WriteBits, WriteString, FlushWriter, str, dictio local level local strategy - local chunks if configs then if configs.level then level = configs.level @@ -1758,29 +1764,6 @@ local function Deflate(configs, WriteBits, WriteString, FlushWriter, str, dictio if configs.strategy then strategy = configs.strategy end - if configs.chunksMode then - chunks = { - currentSize = 0, - yieldOnChunkSize = configs.yieldOnChunkSize or 32 * 1024 * 1024, - currentTime = nil, - yieldOnChunkTime = configs.yieldOnChunkTime, - timeFn = configs.getTimeFn, - } - function chunks:doYield(addSize) - if not self.currentTime and self.timeFn then - self.currentTime = self.timeFn() - end - - self.currentSize = self.currentSize + addSize - if self.currentSize > self.yieldOnChunkSize or (self.currentTime and self.timeFn() - self.currentTime > self.yieldOnChunkTime) then - self.currentSize = 0 - if self.timeFn then - self.currentTime = self.timeFn() - end - coroutine_yield() - end - end - end end if not level then @@ -1821,7 +1804,7 @@ local function Deflate(configs, WriteBits, WriteString, FlushWriter, str, dictio if level ~= 0 then -- GetBlockLZ77 needs block_start to block_end+3 to be loaded. - LoadStringToTable(str, string_table, block_start, block_end + 3, offset, chunks) + LoadStringToTable(str, string_table, block_start, block_end + 3, offset) if block_start == 1 and dictionary then local dict_string_table = dictionary.string_table local dict_strlen = dictionary.strlen @@ -1832,7 +1815,7 @@ local function Deflate(configs, WriteBits, WriteString, FlushWriter, str, dictio if strategy == "huffman_only" then lcodes = {} - LoadStringToTable(str, lcodes, block_start, block_end, block_start - 1, nil, chunks) + LoadStringToTable(str, lcodes, block_start, block_end, block_start - 1) lextra_bits = {} lcodes_counts = {} lcodes[block_end - block_start + 2] = 256 -- end of block @@ -1847,7 +1830,10 @@ local function Deflate(configs, WriteBits, WriteString, FlushWriter, str, dictio lcodes, lextra_bits, lcodes_counts, dcodes, dextra_bits, dcodes_counts = GetBlockLZ77Result(level, string_table, hash_tables, block_start, block_end, offset, dictionary) end - HLIT, HDIST, HCLEN, rle_codes_huffman_bitlens, rle_codes_huffman_codes, rle_deflate_codes, rle_extra_bits, lcodes_huffman_bitlens, lcodes_huffman_codes, dcodes_huffman_bitlens, dcodes_huffman_codes = GetBlockDynamicHuffmanHeader(lcodes_counts, dcodes_counts) + -- LuaFormatter off + HLIT, HDIST, HCLEN, rle_codes_huffman_bitlens, rle_codes_huffman_codes, rle_deflate_codes, rle_extra_bits, lcodes_huffman_bitlens, lcodes_huffman_codes, dcodes_huffman_bitlens, dcodes_huffman_codes = + -- LuaFormatter on + GetBlockDynamicHuffmanHeader(lcodes_counts, dcodes_counts) dynamic_block_bitlen = GetDynamicHuffmanBlockSize(lcodes, dcodes, HCLEN, rle_codes_huffman_bitlens, rle_deflate_codes, lcodes_huffman_bitlens, dcodes_huffman_bitlens) fixed_block_bitlen = GetFixedHuffmanBlockSize(lcodes, dcodes) end @@ -1930,43 +1916,15 @@ end -- @field strategy The compression strategy. "fixed" to only use fixed deflate -- compression block. "dynamic" to only use dynamic block. "huffman_only" to -- do no LZ77 compression. Only do huffman compression. --- @field chunksMode If true, function will return a coroutine handler --- to resume the coroutine. See the readme for an example. --- @field yieldOnChunkSize If chunksMode is true, how large should the buffer --- be before yielding the coroutine. Defaults to 32 * 1024 * 1024. --- @field yieldOnChunkTime If chunksMode is true, maximum duration between --- yields. Requires timeFn. --- @field timeFn If chunksMode is true, include a function to use to calculate --- the current time for your environment. -- @see LibDeflate:CompressDeflate(str, configs) -- @see LibDeflate:CompressDeflateWithDict(str, dictionary, configs) local function CompressDeflateInternal(str, dictionary, configs) local WriteBits, WriteString, FlushWriter = CreateWriter() - - if configs and configs.chunksMode then - local thread = coroutine_create(Deflate) - -- return coroutine handler - return function() - local co_success = coroutine_resume(thread, configs, WriteBits, WriteString, FlushWriter, str, dictionary) - if not co_success then - return false - elseif coroutine_status(thread) ~= "dead" then - return true - else - local total_bitlen, result = FlushWriter(_FLUSH_MODE_OUTPUT) - local padding_bitlen = (8 - total_bitlen % 8) % 8 - return false, result, padding_bitlen - end - end - else - -- if synchronous mode - Deflate(configs, WriteBits, WriteString, FlushWriter, str, dictionary) - - local total_bitlen, result = FlushWriter(_FLUSH_MODE_OUTPUT) - local padding_bitlen = (8 - total_bitlen % 8) % 8 - return result, padding_bitlen - end + Deflate(configs, WriteBits, WriteString, FlushWriter, str, dictionary) + local total_bitlen, result = FlushWriter(_FLUSH_MODE_OUTPUT) + local padding_bitlen = (8 - total_bitlen % 8) % 8 + return result, padding_bitlen end -- @see LibDeflate:CompressZlib @@ -1975,7 +1933,7 @@ local function CompressZlibInternal(str, dictionary, configs) local WriteBits, WriteString, FlushWriter = CreateWriter() local CM = 8 -- Compression method - local CINFO = 7 --Window Size = 32K + local CINFO = 7 -- Window Size = 32K local CMF = CINFO * 16 + CM WriteBits(CMF, 8) @@ -2004,63 +1962,27 @@ local function CompressZlibInternal(str, dictionary, configs) WriteBits(byte0, 8) end - if configs and configs.chunksMode then - local thread = coroutine_create(Deflate) + Deflate(configs, WriteBits, WriteString, FlushWriter, str, dictionary) + FlushWriter(_FLUSH_MODE_BYTE_BOUNDARY) - -- return coroutine handler - return function() - local co_success, result, status = coroutine_resume(thread, configs, WriteBits, WriteString, FlushWriter, str, dictionary) - if not co_success then - return false - elseif coroutine_status(thread) ~= "dead" then - return true - else - FlushWriter(_FLUSH_MODE_BYTE_BOUNDARY) - - local adler32 = LibDeflate:Adler32(str) - - -- Most significant byte first - local byte3 = adler32 % 256 - adler32 = (adler32 - byte3) / 256 - local byte2 = adler32 % 256 - adler32 = (adler32 - byte2) / 256 - local byte1 = adler32 % 256 - adler32 = (adler32 - byte1) / 256 - local byte0 = adler32 % 256 - - WriteBits(byte0, 8) - WriteBits(byte1, 8) - WriteBits(byte2, 8) - WriteBits(byte3, 8) - local total_bitlen, result = FlushWriter(_FLUSH_MODE_OUTPUT) - local padding_bitlen = (8 - total_bitlen % 8) % 8 - return false, result, padding_bitlen - end - end - else - Deflate(configs, WriteBits, WriteString, FlushWriter, str, dictionary) + local adler32 = LibDeflate:Adler32(str) - FlushWriter(_FLUSH_MODE_BYTE_BOUNDARY) + -- Most significant byte first + local byte3 = adler32 % 256 + adler32 = (adler32 - byte3) / 256 + local byte2 = adler32 % 256 + adler32 = (adler32 - byte2) / 256 + local byte1 = adler32 % 256 + adler32 = (adler32 - byte1) / 256 + local byte0 = adler32 % 256 - local adler32 = LibDeflate:Adler32(str) - - -- Most significant byte first - local byte3 = adler32 % 256 - adler32 = (adler32 - byte3) / 256 - local byte2 = adler32 % 256 - adler32 = (adler32 - byte2) / 256 - local byte1 = adler32 % 256 - adler32 = (adler32 - byte1) / 256 - local byte0 = adler32 % 256 - - WriteBits(byte0, 8) - WriteBits(byte1, 8) - WriteBits(byte2, 8) - WriteBits(byte3, 8) - local total_bitlen, result = FlushWriter(_FLUSH_MODE_OUTPUT) - local padding_bitlen = (8 - total_bitlen % 8) % 8 - return result, padding_bitlen - end + WriteBits(byte0, 8) + WriteBits(byte1, 8) + WriteBits(byte2, 8) + WriteBits(byte3, 8) + local total_bitlen, result = FlushWriter(_FLUSH_MODE_OUTPUT) + local padding_bitlen = (8 - total_bitlen % 8) % 8 + return result, padding_bitlen end --- Compress using the raw deflate format. @@ -2148,19 +2070,19 @@ function LibDeflate:CompressZlibWithDict(str, dictionary, configs) end --[[ -------------------------------------------------------------------------- - Decompress code ---]] + Decompress code + --]] -------------------------------------------------------------------------- --[[ - Create a reader to easily reader stuffs as the unit of bits. - Return values: - 1. ReadBits(bitlen) - 2. ReadBytes(bytelen, buffer, buffer_size) - 3. Decode(huffman_bitlen_count, huffman_symbol, min_bitlen) - 4. ReaderBitlenLeft() - 5. SkipToByteBoundary() ---]] + Create a reader to easily reader stuffs as the unit of bits. + Return values: + 1. ReadBits(bitlen) + 2. ReadBytes(bytelen, buffer, buffer_size) + 3. Decode(huffman_bitlen_count, huffman_symbol, min_bitlen) + 4. ReaderBitlenLeft() + 5. SkipToByteBoundary() + --]] local function CreateReader(input_string) local input = input_string local input_strlen = #input_string @@ -2404,11 +2326,6 @@ local function DecodeUntilEndOfBlock(state, lcodes_huffman_bitlens, lcodes_huffm repeat local symbol = Decode(lcodes_huffman_bitlens, lcodes_huffman_symbols, lcodes_huffman_min_bitlen) - - if state.chunksMode then - state.chunksMode:doYield(symbol) - end - if symbol < 0 or symbol > 285 then -- invalid literal/length or distance code in fixed or dynamic block return -10 @@ -2604,7 +2521,7 @@ local function DecompressDynamicBlock(state) end local lcodes_err, lcodes_huffman_bitlen_counts, lcodes_huffman_symbols, lcodes_huffman_min_bitlen = GetHuffmanForDecode(lcodes_huffman_bitlens, nlen - 1, 15) - --dynamic block code description: invalid literal/length code lengths, + -- dynamic block code description: invalid literal/length code lengths, -- Incomplete code ok only for single length 1 code if lcodes_err ~= 0 and (lcodes_err < 0 or nlen ~= (lcodes_huffman_bitlen_counts[0] or 0) + (lcodes_huffman_bitlen_counts[1] or 0)) then return -7 @@ -2651,78 +2568,23 @@ local function Inflate(state) return result end ---- The description to decompression configuration table.
--- Any field can be nil to use its default.
--- Table with keys other than those below is an invalid table. --- @class table --- @name decompression_configs --- @field chunksMode If true, function will return a coroutine handler --- to resume the coroutine. See the readme for an example. --- @field yieldOnChunkSize If chunksMode is true, how large should the buffer --- be before yielding the coroutine. Defaults to 32 * 1024 * 1024. --- @field yieldOnChunkTime If chunksMode is true, maximum duration between --- yields. Requires timeFn. --- @field timeFn If chunksMode is true, include a function to use to calculate --- the current time for your environment. - --- @see LibDeflate:DecompressDeflate(str, configs) --- @see LibDeflate:DecompressDeflateWithDict(str, dictionary, configs) -local function DecompressDeflateInternal(str, dictionary, configs) +-- @see LibDeflate:DecompressDeflate(str) +-- @see LibDeflate:DecompressDeflateWithDict(str, dictionary) +local function DecompressDeflateInternal(str, dictionary) local state = CreateDecompressState(str, dictionary) - if configs and configs.chunksMode then - local thread = coroutine_create(Inflate) - state.chunksMode = { - currentSize = 0, - yieldOnChunkSize = configs.yieldOnChunkSize or 32 * 1024 * 1024, - currentTime = nil, - yieldOnChunkTime = configs.yieldOnChunkTime, - timeFn = configs.getTimeFn, - } - function state.chunksMode:doYield(addSize) - if not self.currentTime and self.timeFn then - self.currentTime = self.timeFn() - end - - self.currentSize = self.currentSize + addSize - if self.currentSize > self.yieldOnChunkSize or (self.currentTime and self.timeFn() - self.currentTime > self.yieldOnChunkTime) then - self.currentSize = 0 - if self.timeFn then - self.currentTime = self.timeFn() - end - coroutine_yield() - end - end - local result, status - -- return coroutine handler - return function() - local co_success, result, status = coroutine_resume(thread, state) - if not co_success then - return false - elseif coroutine_status(thread) ~= "dead" then - return true - elseif not result then - return false, nil, status - else - local bitlen_left = state.ReaderBitlenLeft() - local bytelen_left = (bitlen_left - bitlen_left % 8) / 8 - return false, result, bytelen_left - end - end - else - local result, status = Inflate(state, configs) - if not result then - return nil, status - end - - local bitlen_left = state.ReaderBitlenLeft() - local bytelen_left = (bitlen_left - bitlen_left % 8) / 8 - return result, bytelen_left + local result, status = Inflate(state) + if not result then + return nil, status end + + local bitlen_left = state.ReaderBitlenLeft() + local bytelen_left = (bitlen_left - bitlen_left % 8) / 8 + return result, bytelen_left end --- @see LibDeflate:DecompressZlib(str, configs) --- @see LibDeflate:DecompressZlibWithDict(str, dictionary, configs) -local function DecompressZlibInternal(str, dictionary, configs) +-- @see LibDeflate:DecompressZlib(str) +-- @see LibDeflate:DecompressZlibWithDict(str) +local function DecompressZlibInternal(str, dictionary) local state = CreateDecompressState(str, dictionary) local ReadBits = state.ReadBits @@ -2766,65 +2628,29 @@ local function DecompressZlibInternal(str, dictionary, configs) return nil, -17 -- dictionary adler32 does not match end end + local result, status = Inflate(state) + if not result then + return nil, status + end + state.SkipToByteBoundary() - if configs and configs.chunksMode then - local thread = coroutine_create(Inflate) - -- return coroutine handler - return function() - local co_success, result, status = coroutine_resume(thread, state, configs) - if not co_success then - return false - elseif coroutine_status(thread) ~= "dead" then - return true - elseif not result then - return false, nil, status - else - state.SkipToByteBoundary() - - local adler_byte0 = ReadBits(8) - local adler_byte1 = ReadBits(8) - local adler_byte2 = ReadBits(8) - local adler_byte3 = ReadBits(8) - if state.ReaderBitlenLeft() < 0 then - return nil, 2 -- available inflate data did not terminate - end - - local adler32_expected = adler_byte0 * 16777216 + adler_byte1 * 65536 + adler_byte2 * 256 + adler_byte3 - local adler32_actual = LibDeflate:Adler32(result) - if not IsEqualAdler32(adler32_expected, adler32_actual) then - return nil, -15 -- Adler32 checksum does not match - end - - local bitlen_left = state.ReaderBitlenLeft() - local bytelen_left = (bitlen_left - bitlen_left % 8) / 8 - return false, result, bytelen_left - end - end - else - local result, status = Inflate(state, configs) - if not result then - return nil, status - end - state.SkipToByteBoundary() - - local adler_byte0 = ReadBits(8) - local adler_byte1 = ReadBits(8) - local adler_byte2 = ReadBits(8) - local adler_byte3 = ReadBits(8) - if state.ReaderBitlenLeft() < 0 then - return nil, 2 -- available inflate data did not terminate - end - - local adler32_expected = adler_byte0 * 16777216 + adler_byte1 * 65536 + adler_byte2 * 256 + adler_byte3 - local adler32_actual = LibDeflate:Adler32(result) - if not IsEqualAdler32(adler32_expected, adler32_actual) then - return nil, -15 -- Adler32 checksum does not match - end + local adler_byte0 = ReadBits(8) + local adler_byte1 = ReadBits(8) + local adler_byte2 = ReadBits(8) + local adler_byte3 = ReadBits(8) + if state.ReaderBitlenLeft() < 0 then + return nil, 2 -- available inflate data did not terminate + end - local bitlen_left = state.ReaderBitlenLeft() - local bytelen_left = (bitlen_left - bitlen_left % 8) / 8 - return result, bytelen_left + local adler32_expected = adler_byte0 * 16777216 + adler_byte1 * 65536 + adler_byte2 * 256 + adler_byte3 + local adler32_actual = LibDeflate:Adler32(result) + if not IsEqualAdler32(adler32_expected, adler32_actual) then + return nil, -15 -- Adler32 checksum does not match end + + local bitlen_left = state.ReaderBitlenLeft() + local bytelen_left = (bitlen_left - bitlen_left % 8) / 8 + return result, bytelen_left end --- Decompress a raw deflate compressed data. @@ -2840,15 +2666,12 @@ end -- If the decompression fails (The first return value of this function is nil), -- this return value is undefined. -- @see LibDeflate:CompressDeflate -function LibDeflate:DecompressDeflate(str, configs) - if not configs then - configs = {} - end +function LibDeflate:DecompressDeflate(str) local arg_valid, arg_err = IsValidArguments(str) if not arg_valid then - error(("Usage: LibDeflate:DecompressDeflate(str, configs): " .. arg_err), 2) + error(("Usage: LibDeflate:DecompressDeflate(str): " .. arg_err), 2) end - return DecompressDeflateInternal(str, nil, configs) + return DecompressDeflateInternal(str) end --- Decompress a raw deflate compressed data with a preset dictionary. @@ -2869,15 +2692,12 @@ end -- If the decompression fails (The first return value of this function is nil), -- this return value is undefined. -- @see LibDeflate:CompressDeflateWithDict -function LibDeflate:DecompressDeflateWithDict(str, dictionary, configs) - if not configs then - configs = {} - end +function LibDeflate:DecompressDeflateWithDict(str, dictionary) local arg_valid, arg_err = IsValidArguments(str, true, dictionary) if not arg_valid then error(("Usage: LibDeflate:DecompressDeflateWithDict(str, dictionary): " .. arg_err), 2) end - return DecompressDeflateInternal(str, dictionary, configs) + return DecompressDeflateInternal(str, dictionary) end --- Decompress a zlib compressed data. @@ -2893,15 +2713,12 @@ end -- If the decompression fails (The first return value of this function is nil), -- this return value is undefined. -- @see LibDeflate:CompressZlib -function LibDeflate:DecompressZlib(str, configs) - if not configs then - configs = {} - end +function LibDeflate:DecompressZlib(str) local arg_valid, arg_err = IsValidArguments(str) if not arg_valid then error(("Usage: LibDeflate:DecompressZlib(str): " .. arg_err), 2) end - return DecompressZlibInternal(str, nil, configs) + return DecompressZlibInternal(str) end --- Decompress a zlib compressed data with a preset dictionary. @@ -2922,15 +2739,12 @@ end -- If the decompression fails (The first return value of this function is nil), -- this return value is undefined. -- @see LibDeflate:CompressZlibWithDict -function LibDeflate:DecompressZlibWithDict(str, dictionary, configs) - if not configs then - configs = {} - end +function LibDeflate:DecompressZlibWithDict(str, dictionary) local arg_valid, arg_err = IsValidArguments(str, true, dictionary) if not arg_valid then error(("Usage: LibDeflate:DecompressZlibWithDict(str, dictionary): " .. arg_err), 2) end - return DecompressZlibInternal(str, dictionary, configs) + return DecompressZlibInternal(str, dictionary) end -- Calculate the huffman code of fixed block @@ -3537,20 +3351,20 @@ LibDeflate.internals = { } --[[-- Commandline options -@class table -@name CommandlineOptions -@usage lua LibDeflate.lua [OPTION] [INPUT] [OUTPUT] -\-0 store only. no compression. -\-1 fastest compression. -\-9 slowest and best compression. -\-d do decompression instead of compression. -\--dict specify the file that contains -the entire preset dictionary. -\-h give this help. -\--strategy specify a special compression strategy. -\-v print the version and copyright info. -\--zlib use zlib format instead of raw deflate. -]] + @class table + @name CommandlineOptions + @usage lua LibDeflate.lua [OPTION] [INPUT] [OUTPUT] + \-0 store only. no compression. + \-1 fastest compression. + \-9 slowest and best compression. + \-d do decompression instead of compression. + \--dict specify the file that contains + the entire preset dictionary. + \-h give this help. + \--strategy specify a special compression strategy. + \-v print the version and copyright info. + \--zlib use zlib format instead of raw deflate. + ]] -- currently no plan to support stdin and stdout. -- Because Lua in Windows does not set stdout with binary mode. @@ -3558,7 +3372,7 @@ if io and os and debug and _G.arg then local io = io local os = os local debug = debug - local arg = arg + local arg = _G.arg local debug_info = debug.getinfo(1) if debug_info.source == arg[0] or debug_info.short_src == arg[0] then -- We are indeed runnning THIS file from the commandline. @@ -3574,7 +3388,21 @@ if io and os and debug and _G.arg then while arg[i] do local a = arg[i] if a == "-h" then - print(LibDeflate._COPYRIGHT .. "\nUsage: lua LibDeflate.lua [OPTION] [INPUT] [OUTPUT]\n" .. " -0 store only. no compression.\n" .. " -1 fastest compression.\n" .. " -9 slowest and best compression.\n" .. " -d do decompression instead of compression.\n" .. " --dict specify the file that contains" .. " the entire preset dictionary.\n" .. " -h give this help.\n" .. " --strategy " .. " specify a special compression strategy.\n" .. " -v print the version and copyright info.\n" .. " --zlib use zlib format instead of raw deflate.\n") + print( + LibDeflate._COPYRIGHT + .. "\nUsage: lua LibDeflate.lua [OPTION] [INPUT] [OUTPUT]\n" + .. " -0 store only. no compression.\n" + .. " -1 fastest compression.\n" + .. " -9 slowest and best compression.\n" + .. " -d do decompression instead of compression.\n" + .. " --dict specify the file that contains" + .. " the entire preset dictionary.\n" + .. " -h give this help.\n" + .. " --strategy " + .. " specify a special compression strategy.\n" + .. " -v print the version and copyright info.\n" + .. " --zlib use zlib format instead of raw deflate.\n" + ) os.exit(0) elseif a == "-v" then print(LibDeflate._COPYRIGHT) @@ -3636,10 +3464,7 @@ if io and os and debug and _G.arg then end local input_data = input:read("*all") - local configs = { - level = level, - strategy = strategy, - } + local configs = { level = level, strategy = strategy } local output_data if not is_decompress then if not is_zlib then diff --git a/KkthnxUI/Libraries/LibRangeCheck-3.0/LibRangeCheck-3.0.lua b/KkthnxUI/Libraries/LibRangeCheck-3.0/LibRangeCheck-3.0.lua index 7fa898b5..16a3dfb5 100644 --- a/KkthnxUI/Libraries/LibRangeCheck-3.0/LibRangeCheck-3.0.lua +++ b/KkthnxUI/Libraries/LibRangeCheck-3.0/LibRangeCheck-3.0.lua @@ -40,7 +40,7 @@ License: MIT -- @class file -- @name LibRangeCheck-3.0 local MAJOR_VERSION = "LibRangeCheck-3.0-KkthnxUI" -local MINOR_VERSION = 23 -- based off real minor version: 26 +local MINOR_VERSION = 24 -- based off real minor version: 26 -- GLOBALS: LibStub, CreateFrame diff --git a/KkthnxUI/Modules/ActionBars/Elements/Extrabar.lua b/KkthnxUI/Modules/ActionBars/Elements/Extrabar.lua index 19659184..69f26fc1 100644 --- a/KkthnxUI/Modules/ActionBars/Elements/Extrabar.lua +++ b/KkthnxUI/Modules/ActionBars/Elements/Extrabar.lua @@ -69,4 +69,24 @@ function Module:CreateExtrabar() self:SetParent(zoneFrame) end end) + + -- Extra button range, needs review + hooksecurefunc("ActionButton_UpdateRangeIndicator", function(self, checksRange, inRange) + if not self.action then + return + end + + if checksRange and not inRange then + self.icon:SetVertexColor(0.8, 0.1, 0.1) + else + local isUsable, notEnoughMana = IsUsableAction(self.action) + if isUsable then + self.icon:SetVertexColor(1, 1, 1) + elseif notEnoughMana then + self.icon:SetVertexColor(0.5, 0.5, 1) + else + self.icon:SetVertexColor(0.4, 0.4, 0.4) + end + end + end) end diff --git a/KkthnxUI/Modules/Auras/Lumos/Evoker.lua b/KkthnxUI/Modules/Auras/Lumos/Evoker.lua index bf249450..38e7495c 100644 --- a/KkthnxUI/Modules/Auras/Lumos/Evoker.lua +++ b/KkthnxUI/Modules/Auras/Lumos/Evoker.lua @@ -58,9 +58,9 @@ function Module:ChantLumos(self) local hasBurst = GetUnitAura("player", 359618, "HELPFUL") --高亮精华迸发 if hasBurst then K.ShowOverlayGlow(button3) - K.ShowOverlayGlow(button3) + K.ShowOverlayGlow(button4) else - K.HideOverlayGlow(button4) + K.HideOverlayGlow(button3) K.HideOverlayGlow(button4) end end @@ -81,9 +81,9 @@ function Module:ChantLumos(self) local hasBurst = GetUnitAura("player", 369299, "HELPFUL") --高亮精华迸发 if hasBurst then K.ShowOverlayGlow(button2) - K.ShowOverlayGlow(button2) + K.ShowOverlayGlow(button3) else - K.HideOverlayGlow(button3) + K.HideOverlayGlow(button2) K.HideOverlayGlow(button3) end end diff --git a/KkthnxUI/Modules/Automation/Elements/Screenshot.lua b/KkthnxUI/Modules/Automation/Elements/Screenshot.lua index af7d21c9..4d234d91 100644 --- a/KkthnxUI/Modules/Automation/Elements/Screenshot.lua +++ b/KkthnxUI/Modules/Automation/Elements/Screenshot.lua @@ -8,9 +8,11 @@ local Screenshot = Screenshot -- Achievement screenshot local ScreenShotFrame -local function ScreenShotOnEvent(alreadyEarnedOnAccount) - print(alreadyEarnedOnAccount) - if alreadyEarnedOnAccount then +local function ScreenShotOnEvent(achievementID, alreadyEarned) + print("achievementID", achievementID) + print("alreadyEarned", alreadyEarned) + + if alreadyEarned then return end diff --git a/KkthnxUI/Modules/Blizzard/Elements/Fixes.lua b/KkthnxUI/Modules/Blizzard/Elements/Fixes.lua new file mode 100644 index 00000000..29f5a034 --- /dev/null +++ b/KkthnxUI/Modules/Blizzard/Elements/Fixes.lua @@ -0,0 +1,127 @@ +local K = KkthnxUI[1] + +-- Unregister talent event +if PlayerTalentFrame then + PlayerTalentFrame:UnregisterEvent("ACTIVE_TALENT_GROUP_CHANGED") +else + hooksecurefunc("TalentFrame_LoadUI", function() + PlayerTalentFrame:UnregisterEvent("ACTIVE_TALENT_GROUP_CHANGED") + end) +end + +-- Fix blizz bug in addon list +local _AddonTooltip_Update = AddonTooltip_Update +function AddonTooltip_Update(owner) + if not owner then + return + end + if owner:GetID() < 1 then + return + end + _AddonTooltip_Update(owner) +end + +-- Fix Drag Collections taint +do + local done + local function setupMisc(event, addon) + if event == "ADDON_LOADED" and addon == "Blizzard_Collections" then + -- Fix undragable issue + local checkBox = WardrobeTransmogFrame.ToggleSecondaryAppearanceCheckbox + checkBox.Label:ClearAllPoints() + checkBox.Label:SetPoint("LEFT", checkBox, "RIGHT", 2, 1) + checkBox.Label:SetWidth(152) + + CollectionsJournal:HookScript("OnShow", function() + if not done then + if InCombatLockdown() then + K:RegisterEvent("PLAYER_REGEN_ENABLED", setupMisc) + else + K.CreateMoverFrame(CollectionsJournal) + end + done = true + end + end) + K:UnregisterEvent(event, setupMisc) + elseif event == "PLAYER_REGEN_ENABLED" then + K.CreateMoverFrame(CollectionsJournal) + K:UnregisterEvent(event, setupMisc) + end + end + + K:RegisterEvent("ADDON_LOADED", setupMisc) +end + +-- Select target when click on raid units +do + local function fixRaidGroupButton() + for i = 1, 40 do + local bu = _G["RaidGroupButton" .. i] + if bu and bu.unit and not bu.clickFixed then + bu:SetAttribute("type", "target") + bu:SetAttribute("unit", bu.unit) + + bu.clickFixed = true + end + end + end + + local function setupMisc(event, addon) + if event == "ADDON_LOADED" and addon == "Blizzard_RaidUI" then + if not InCombatLockdown() then + fixRaidGroupButton() + else + K:RegisterEvent("PLAYER_REGEN_ENABLED", setupMisc) + end + K:UnregisterEvent(event, setupMisc) + elseif event == "PLAYER_REGEN_ENABLED" then + if RaidGroupButton1 and RaidGroupButton1:GetAttribute("type") ~= "target" then + fixRaidGroupButton() + K:UnregisterEvent(event, setupMisc) + end + end + end + + K:RegisterEvent("ADDON_LOADED", setupMisc) +end + +-- Fix blizz guild news hyperlink error +do + local function fixGuildNews(event, addon) + if addon ~= "Blizzard_GuildUI" then + return + end + + local _GuildNewsButton_OnEnter = GuildNewsButton_OnEnter + function GuildNewsButton_OnEnter(self) + if not (self.newsInfo and self.newsInfo.whatText) then + return + end + _GuildNewsButton_OnEnter(self) + end + + K:UnregisterEvent(event, fixGuildNews) + end + + K:RegisterEvent("ADDON_LOADED", fixGuildNews) +end + +-- Fix guild news jam +do + local lastTime, timeGap = 0, 1.5 + local function updateGuildNews(self, event) + if event == "PLAYER_ENTERING_WORLD" then + QueryGuildNews() + else + if self:IsVisible() then + local nowTime = GetTime() + if nowTime - lastTime > timeGap then + CommunitiesGuildNews_Update(self) + lastTime = nowTime + end + end + end + end + + CommunitiesFrameGuildDetailsFrameNews:SetScript("OnEvent", updateGuildNews) +end diff --git a/KkthnxUI/Modules/DataText/Elements/Gold.lua b/KkthnxUI/Modules/DataText/Elements/Gold.lua index 4677fa7b..46a7b03c 100644 --- a/KkthnxUI/Modules/DataText/Elements/Gold.lua +++ b/KkthnxUI/Modules/DataText/Elements/Gold.lua @@ -15,7 +15,6 @@ local C_Timer_NewTicker = C_Timer.NewTicker local C_WowTokenPublic_GetCurrentMarketPrice = C_WowTokenPublic.GetCurrentMarketPrice local C_WowTokenPublic_UpdateMarketPrice = C_WowTokenPublic.UpdateMarketPrice local GameTooltip = GameTooltip -local GetAutoCompleteRealms = GetAutoCompleteRealms local GetMoney = GetMoney local IsControlKeyDown = IsControlKeyDown local NO = NO @@ -25,6 +24,7 @@ local YES = YES -- Variables local slotString = BAGSLOTTEXT .. ": %s%d" +local showGoldGap = 100 * 1e4 local ticker local profit = 0 local spent = 0 @@ -213,11 +213,13 @@ local function OnEnter(self) -- We need self for the bags since we use this on t GameTooltip:AddLine(CHARACTER_BUTTON .. ":", 0.5, 0.7, 1) if KkthnxUIDB.Gold[myRealm] then for k, v in pairs(KkthnxUIDB.Gold[myRealm]) do - local name = Ambiguate(k .. "-" .. myRealm, "none") local gold, class, faction = unpack(v) - local r, g, b = K.ColorClass(class) - GameTooltip:AddDoubleLine(getFactionIcon(faction) .. getClassIcon(class) .. name, K.FormatMoney(gold), r, g, b, 1, 1, 1) - totalGold = totalGold + gold + local name = Ambiguate(k .. "-" .. myRealm, "none") + if gold > showGoldGap or UnitIsUnit(name, "player") then + local r, g, b = K.ColorClass(class) + GameTooltip:AddDoubleLine(getFactionIcon(faction) .. getClassIcon(class) .. name, K.FormatMoney(gold), r, g, b, 1, 1, 1) + totalGold = totalGold + gold + end end end @@ -226,12 +228,14 @@ local function OnEnter(self) -- We need self for the bags since we use this on t if realm ~= myRealm then for k, v in pairs(data) do local gold, class, faction = unpack(v) - if isShiftKeyDown then -- show other realms while holding shift - local name = Ambiguate(k .. "-" .. realm, "none") - local r, g, b = K.ColorClass(class) - GameTooltip:AddDoubleLine(getFactionIcon(faction) .. getClassIcon(class) .. name, K.FormatMoney(gold), r, g, b, 1, 1, 1) + if gold > showGoldGap then + if isShiftKeyDown then -- show other realms while holding shift + local name = Ambiguate(k .. "-" .. realm, "none") + local r, g, b = K.ColorClass(class) + GameTooltip:AddDoubleLine(getFactionIcon(faction) .. getClassIcon(class) .. name, K.FormatMoney(gold), r, g, b, 1, 1, 1) + end + totalGold = totalGold + gold end - totalGold = totalGold + gold end end end diff --git a/KkthnxUI/Modules/DataText/Elements/Time.lua b/KkthnxUI/Modules/DataText/Elements/Time.lua index fcd11ad3..5d56d599 100644 --- a/KkthnxUI/Modules/DataText/Elements/Time.lua +++ b/KkthnxUI/Modules/DataText/Elements/Time.lua @@ -90,6 +90,7 @@ local mapAreaPoiIDs = { local questlist = { { name = "Feast of Winter Veil", id = 6983 }, { name = "Blingtron Daily Gift", id = 34774 }, + { name = "500 Timewarped Badges", id = 83285, texture = 6006158 }, -- Vanilla { name = "500 Timewarped Badges", id = 40168, texture = 1129674 }, -- TBC { name = "500 Timewarped Badges", id = 40173, texture = 1129686 }, -- WotLK { name = "500 Timewarped Badges", id = 40786, texture = 1304688 }, -- Cata diff --git a/KkthnxUI/Modules/Load_Modules.xml b/KkthnxUI/Modules/Load_Modules.xml index a27c5150..3750925b 100644 --- a/KkthnxUI/Modules/Load_Modules.xml +++ b/KkthnxUI/Modules/Load_Modules.xml @@ -17,6 +17,7 @@