Skip to content

Commit

Permalink
新增更新提示
Browse files Browse the repository at this point in the history
  • Loading branch information
CvCn committed Oct 4, 2024
1 parent a1624e5 commit 2d99688
Show file tree
Hide file tree
Showing 16 changed files with 164 additions and 61 deletions.
33 changes: 27 additions & 6 deletions InputInput/API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ local W, M, U, D, G, L, E, API, LOG = unpack((select(2, ...)))

local version, buildVersion, buildDate, uiVersion = GetBuildInfo()

-- 斩断 ctr+shift+m

local function getVersion(v)
local expansion, majorPatch, minorPatch = (v or "5.0.0"):match("^(%d+)%.(%d+)%.(%d+)")

-- 版本信息
-- @param v 版本号
-- @return 版本号(number)
function W:getVersion(v)
local expansion, majorPatch, minorPatch = (v or "1.0.0"):match("^(%d+)%.(%d+)%.(%d+)")
return (expansion or 0) * 10000 + (majorPatch or 0) * 100 + (minorPatch or 0)
end

Expand All @@ -27,18 +32,18 @@ local function sortTableByKey(t, comp)
return sortedTable
end

local clientVersion = getVersion(version)
local clientVersion = W:getVersion(version)

local function Fun(funTable)
for name, t in pairs(funTable) do
if t then
t = sortTableByKey(t, function (a1, a2)
t = sortTableByKey(t, function(a1, a2)
-- LOG:Debug(a1)
return getVersion(a1) < getVersion(a2)
return W:getVersion(a1) < W:getVersion(a2)
end)
for v, f in pairs(t) do
-- LOG:Debug(name, clientVersion, getVersion(v))
if clientVersion >= getVersion(v) then
if clientVersion >= W:getVersion(v) then
API[name] = f
break
end
Expand Down Expand Up @@ -240,5 +245,21 @@ Fun({
-- Returns the game client locale.
GetLocale = {
['1.0.0'] = GetLocale
},
C_ChatInfo_SendAddonMessage = {
['1.0.0'] = C_ChatInfo and C_ChatInfo.SendAddonMessage
},
C_ChatInfo_RegisterAddonMessagePrefix = {
['1.0.0'] = C_ChatInfo and C_ChatInfo.RegisterAddonMessagePrefix
},
C_AddOns_GetAddOnMetadata = {
['1.0.0'] = C_AddOns and C_AddOns.GetAddOnMetadata
},
C_Timer_After = {
['1.0.0'] = C_Timer and C_Timer.After
}
})


local C_AddOns_GetAddOnMetadata = API.C_AddOns_GetAddOnMetadata
W.version = C_AddOns_GetAddOnMetadata('InputInput', 'Version')
2 changes: 1 addition & 1 deletion InputInput/InIt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local Data = {}
local Locale = {}
local API = {}
local LOG = {}
local Environment = 'PRO'
local Environment = 'PRO' -- DEV PRO

Widget.defaultFontName = GameFontHighlightSmall:GetFont()
AddOnesTable[1] = Widget
Expand Down
4 changes: 2 additions & 2 deletions InputInput/InputInput_Cata.toc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
## Notes-zhCN: 输入框增强
## Notes-zhTW: 輸入框增強
## Author: York
## Version: 1.0.9
## X-Date: 2024-08-18
## Version: 1.0.11
## X-Date: 2024-10-03

## X-Category: Interface Enhancements
## X-Curse-Project-ID: 1076615
Expand Down
6 changes: 3 additions & 3 deletions InputInput/InputInput_Classic.toc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## Interface: 11503
## Interface: 11504, 11503

## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r
## Notes: Input box enhancement
## Notes-zhCN: 输入框增强
## Notes-zhTW: 輸入框增強
## Author: York
## Version: 1.0.9
## X-Date: 2024-08-18
## Version: 1.0.11
## X-Date: 2024-10-03

## X-Category: Interface Enhancements
## X-Curse-Project-ID: 1076615
Expand Down
4 changes: 2 additions & 2 deletions InputInput/InputInput_Mainline.toc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
## Notes-zhCN: 输入框增强
## Notes-zhTW: 輸入框增強
## Author: York
## Version: 1.0.9
## X-Date: 2024-08-18
## Version: 1.0.11
## X-Date: 2024-10-03

## X-Category: Interface Enhancements
## X-Curse-Project-ID: 1076615
Expand Down
4 changes: 2 additions & 2 deletions InputInput/InputInput_Vanilla.toc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
## Notes-zhCN: 输入框增强
## Notes-zhTW: 輸入框增強
## Author: York
## Version: 1.0.9
## X-Date: 2024-08-18
## Version: 1.0.11
## X-Date: 2024-10-03

## X-Category: Interface Enhancements
## X-Curse-Project-ID: 1076615
Expand Down
6 changes: 3 additions & 3 deletions InputInput/InputInput_Wrath.toc
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
## Interface: 30403
## Interface: 30405, 30403

## Title: |cff409EFF|cffF56C6Ci|rnput|cffF56C6Ci|rnput|r
## Notes: Input box enhancement
## Notes-zhCN: 输入框增强
## Notes-zhTW: 輸入框增強
## Author: York
## Version: 1.0.9
## X-Date: 2024-08-18
## Version: 1.0.11
## X-Date: 2024-10-03

## X-Category: Interface Enhancements
## X-Curse-Project-ID: 1076615
Expand Down
13 changes: 12 additions & 1 deletion InputInput/Locales/Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@ local N, T = ...
local W, M, U, D, G, L, E, API, LOG = unpack((select(2, ...)))
local GetLocale = API.GetLocale
local locale = GetLocale() or 'enUS'
T[6] = L[locale]
T[6] = L[locale] or {}

-- 定义元表,重写 __index
local mt = {
-- 定制下标取值的逻辑
__index = function(table, key)
return rawget(table, key) or rawget(L['enUS'], key) -- 如果没有值,返回缺省值
end
}

-- 设置元表
setmetatable(T[6], mt)
4 changes: 3 additions & 1 deletion InputInput/Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,6 @@ L['Chinese word processing module can make input prompts more intelligent'] = 'C
L['Login Information 1'] = "You are using the %s Input Enhancement addon. If you encounter any issues during use, you can provide feedback via %s or on the addon website %s"
L['Login Information 2'] = "Enter %s or %s to open the settings panel"

L['Not enabled, enter/ii to enable'] = 'Not enabled, enter%s to enable'
L['Not enabled, enter/ii to enable'] = 'Not enabled, enter%s to enable'

L['New Version Discovered'] = '%s Discovered a new version %s'
4 changes: 3 additions & 1 deletion InputInput/Locales/zhCN.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,6 @@ L['Chinese word processing module can make input prompts more intelligent'] = '
L['Login Information 1'] = "您正在使用%s输入框增强插件, 使用过程中的任何问题都可以通过 %s 或者 到插件网站 %s 进行反馈"
L['Login Information 2'] = "输入 %s 或者 %s 打开设置面板"

L['Not enabled, enter/ii to enable'] = '未启用,输入%s启用'
L['Not enabled, enter/ii to enable'] = '未启用,输入%s启用'

L['New Version Discovered'] = '%s 发现新版本 %s'
4 changes: 3 additions & 1 deletion InputInput/Locales/zhTW.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,6 @@ L['Chinese word processing module can make input prompts more intelligent'] = '
L['Login Information 1'] = "您正在使用%s輸入框增強插件,使用過程中的任何問題都可以透過 %s 或到插件網站 %s 進行反饋"
L['Login Information 2'] = "輸入 %s 或 %s 打開設定面板"

L['Not enabled, enter/ii to enable'] = '未開啟,輸入%s開啟'
L['Not enabled, enter/ii to enable'] = '未開啟,輸入%s開啟'

L['New Version Discovered'] = '%s 發現新版本 %s'
36 changes: 32 additions & 4 deletions InputInput/Main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ local IsLeftShiftKeyDown = API.IsLeftShiftKeyDown
local C_AddOns_GetAddOnEnableState = API.C_AddOns_GetAddOnEnableState
local C_AddOns_EnableAddOn = API.C_AddOns_EnableAddOn
local C_AddOns_DisableAddOn = API.C_AddOns_DisableAddOn
local C_ChatInfo_RegisterAddonMessagePrefix = API.C_ChatInfo_RegisterAddonMessagePrefix

local measureFontString = UIParent:CreateFontString(nil, "ARTWORK", "GameFontNormal")

Expand Down Expand Up @@ -1138,6 +1139,7 @@ frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:RegisterEvent("CVAR_UPDATE")
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("CHAT_MSG_ADDON")

frame:RegisterEvent("ZONE_CHANGED")
frame:RegisterEvent("ZONE_CHANGED_INDOORS")
Expand All @@ -1153,11 +1155,14 @@ for _, event in pairs(ChatTypeGroup["WHISPER"]) do
frame:RegisterEvent(event);
end
local editBox, bg, border, backdropFrame2, resizeButton, resizeBtnTexture, channel_name, II_TIP, II_LANG, bg3

local SendRecieveGroupSize = 0
local SendMessageWaiting = nil
local versionUpdateMsg = nil
frame:HookScript("OnEvent", function(self_f, event, ...)
if not isInit then
editBox, bg, border, backdropFrame2, resizeButton, resizeBtnTexture, channel_name, II_TIP, II_LANG, bg3 =
MAIN:Init()
C_ChatInfo_RegisterAddonMessagePrefix('INPUTINPUT_V')
end
if event == 'PLAYER_ENTERING_WORLD' or strfind(event, "WHISPER", 0, true) then
for _, chatFrameName in pairs(CHAT_FRAMES) do
Expand Down Expand Up @@ -1191,6 +1196,9 @@ frame:HookScript("OnEvent", function(self_f, event, ...)
end
end)
U:InitZones()
if not SendMessageWaiting then
SendMessageWaiting = U:Delay(10, U.SendVersionMsg)
end
elseif event == 'CVAR_UPDATE' then
local cvarName, value = ...
if cvarName == 'chatStyle' or cvarName == 'whisperMode' then
Expand Down Expand Up @@ -1241,6 +1249,26 @@ frame:HookScript("OnEvent", function(self_f, event, ...)
U:InitZones()
elseif event == 'GROUP_ROSTER_UPDATE' or event == 'RAID_ROSTER_UPDATE' then
U:InitGroupMembers()
local num = GetNumGroupMembers()
if num ~= SendRecieveGroupSize then
if num > 1 and num > SendRecieveGroupSize then
if not SendMessageWaiting then
SendMessageWaiting = U:Delay(10, U.SendVersionMsg)
end
end
SendRecieveGroupSize = num
end
elseif event == 'CHAT_MSG_ADDON' then
local prefix, text, channel, sender, target, zoneChannelID, localID, name, instanceID = ...
if prefix == "INPUTINPUT_V" and (not versionUpdateMsg or time() - versionUpdateMsg > 60 * 30) then
local ver, msg, inCombat = W:getVersion(W.version), W:getVersion(text), InCombatLockdown()
LOG:Debug(ver, msg, text)
if msg and (msg > ver) and not inCombat then
LOG:Info(string.format(L['New Version Discovered'], W.colorName,
'|cFFFFFFFF' .. text .. '|r|cFF909399 (' .. W.version .. ')|r'))
versionUpdateMsg = time()
end
end
else
if (C_AddOns_IsAddOnLoaded("ElvUI") or ElvUI == nil) and
(C_AddOns_IsAddOnLoaded("NDui") or NDui == nil) then
Expand All @@ -1249,16 +1277,16 @@ frame:HookScript("OnEvent", function(self_f, event, ...)

optionSetup(backdropFrame2)

C_Timer.After(5, function(cb)
U:Delay(5, function(cb)
LOG:Info(string.format(L['Login Information 1'],
W.colorName,
"|cff409EFFDiscord|r |cFFFFFFFF[https://discord.gg/qC9RAdXN]|r",
"|cff409EFFCurseForge|r |cFFFFFFFF[https://www.curseforge.com/wow/addons/inputinput/comments]|r"))
end)
C_Timer.After(6, function(cb)
U:Delay(6, function(cb)
LOG:Info(string.format(L['Login Information 2'], "|cff409EFF/ii|r", "|cff409EFF/inputinput|r"))
end)
C_Timer.After(7, function(cb)
U:Delay(7, function(cb)
local isLoad = C_AddOns_GetAddOnEnableState("InputInput_Libraries_zh") == 2
if GetLocale() == 'zhCN' or GetLocale() == 'zhTW' then
if not (C_AddOns_GetAddOnEnableState("InputInput_Libraries_zh") == 2) then
Expand Down
Loading

0 comments on commit 2d99688

Please sign in to comment.