@@ -8,32 +8,47 @@ local string_format = string.format
8
8
local string_gsub = string.gsub
9
9
local string_split = string .split
10
10
local tonumber = tonumber
11
-
12
- local Ambiguate = Ambiguate
13
- local C_ChatInfo_RegisterAddonMessagePrefix = C_ChatInfo .RegisterAddonMessagePrefix
14
- local C_ChatInfo_SendAddonMessage = C_ChatInfo .SendAddonMessage
11
+ local CreateFrame = CreateFrame
15
12
local GetTime = GetTime
13
+ local Ambiguate = Ambiguate
16
14
local IsInGroup = IsInGroup
17
15
local IsInGuild = IsInGuild
16
+ local IsInRaid = IsInRaid
17
+ local IsPartyLFG = IsPartyLFG
18
+ local print = print
19
+
20
+ local C_ChatInfo_RegisterAddonMessagePrefix = C_ChatInfo .RegisterAddonMessagePrefix
21
+ local C_ChatInfo_SendAddonMessage = C_ChatInfo .SendAddonMessage
18
22
19
- local lastVCTime , isVCInit = 0
20
23
local tn = tonumber
24
+ local lastVCTime , isVCInit = 0
25
+ local debugTest = false
21
26
22
- local function HandleVersonTag (version )
23
- local major , minor = strsplit (" ." , version )
27
+ -- Debugging function to track issues
28
+ local function DebugLog (message )
29
+ if K .isDeveloper and debugTest then
30
+ print (" |cffFF0000[DEBUG]:|r " .. message )
31
+ end
32
+ end
33
+
34
+ local function HandleVersonTag (version , author )
35
+ local major , minor = string_split (" ." , version )
24
36
major , minor = tn (major ), tn (minor )
37
+
25
38
if K .LibBase64 :CV (major ) then
26
39
major , minor = 0 , 0
27
40
if K .isDeveloper and author then
28
- print ( " Moron : " .. author )
41
+ DebugLog ( " Invalid version from author : " .. author )
29
42
end
30
43
end
44
+
31
45
return major , minor
32
46
end
33
47
34
48
function Module :VersionCheck_Compare (new , old , author )
35
49
local new1 , new2 = HandleVersonTag (new , author )
36
50
local old1 , old2 = HandleVersonTag (old )
51
+
37
52
if new1 > old1 or (new1 == old1 and new2 > old2 ) then
38
53
return " IsNew"
39
54
elseif new1 < old1 or (new1 == old1 and new2 < old2 ) then
43
58
44
59
function Module :CreateUpdateNoticeFrame ()
45
60
local frame = CreateFrame (" Frame" , " KKUI_UpdateNotice" , UIParent )
46
- frame :SetSize (420 , 150 )
61
+ frame :SetSize (420 , 180 )
47
62
frame :SetPoint (" CENTER" , UIParent , " CENTER" )
48
63
frame :CreateBorder ()
49
64
65
+ -- Set background texture to 'adventureguide-pane-small'
66
+ frame .Background = frame :CreateTexture (nil , " BACKGROUND" )
67
+ frame .Background :SetAtlas (" adventureguide-pane-small" )
68
+ frame .Background :SetAllPoints (frame )
69
+ frame .Background :SetBlendMode (" ADD" )
70
+
50
71
frame .Texture = frame :CreateTexture (nil , " OVERLAY" )
51
72
frame .Texture :SetTexture (" Interface\\ HELPFRAME\\ HelpIcon-ReportAbuse" )
52
- frame .Texture :SetPoint (" TOP" , frame , " TOP" , 0 , 8 )
73
+ frame .Texture :SetPoint (" TOP" , frame , " TOP" , 0 , - 4 )
53
74
54
75
frame .Text = frame :CreateFontString (nil , " OVERLAY" )
55
76
frame .Text :SetWidth (400 )
56
77
frame .Text :SetFontObject (K .UIFont )
57
78
frame .Text :SetFont (select (1 , frame .Text :GetFont ()), 15 , select (3 , frame .Text :GetFont ()))
58
- frame .Text :SetPoint (" CENTER " , frame , " CENTER " )
79
+ frame .Text :SetPoint (" TOP " , frame , " TOP " , 0 , - 70 )
59
80
60
- frame .EditBox = CreateFrame (" EditBox" , nil , frame )
61
- frame .EditBox :SetPoint (" BOTTOM" , frame , " BOTTOM" , 0 , 8 )
62
- frame .EditBox :SetWidth (330 )
63
- frame .EditBox :SetHeight (19 )
64
- frame .EditBox :SetMultiLine (false )
65
- frame .EditBox :SetAutoFocus (false )
66
- frame .EditBox :SetFontObject (K .UIFont )
67
- frame .EditBox :CreateBorder ()
81
+ -- CurseForge link
82
+ frame .CurseLink = CreateFrame (" EditBox" , nil , frame )
83
+ frame .CurseLink :SetPoint (" CENTER" , frame , " CENTER" , 0 , - 40 )
84
+ frame .CurseLink :SetWidth (330 )
85
+ frame .CurseLink :SetHeight (19 )
86
+ frame .CurseLink :SetMultiLine (false )
87
+ frame .CurseLink :SetAutoFocus (false )
88
+ frame .CurseLink :SetFontObject (K .UIFont )
89
+ frame .CurseLink :SetText (" https://www.curseforge.com/wow/addons/kkthnxui" )
90
+ frame .CurseLink :CreateBorder ()
68
91
69
- frame .EditBox .Text = frame .EditBox :CreateFontString (nil , " OVERLAY" )
70
- frame .EditBox .Text :SetFontObject (K .UIFont )
71
- frame .EditBox .Text :SetPoint (" BOTTOM" , frame .EditBox , " TOP" , 0 , 2 )
92
+ -- Tooltip for CurseForge link
93
+ frame .CurseLink :SetScript (" OnEnter" , function ()
94
+ GameTooltip :SetOwner (frame .CurseLink , " ANCHOR_TOP" )
95
+ GameTooltip :AddLine (" CurseForge Link" , 1 , 1 , 1 )
96
+ GameTooltip :AddLine (" This is the stable release version." , 0.7 , 0.7 , 0.7 )
97
+ GameTooltip :Show ()
98
+ end )
99
+ frame .CurseLink :SetScript (" OnLeave" , function ()
100
+ GameTooltip :Hide ()
101
+ end )
102
+
103
+ -- GitHub link
104
+ frame .GitHubLink = CreateFrame (" EditBox" , nil , frame )
105
+ frame .GitHubLink :SetPoint (" CENTER" , frame , " CENTER" , 0 , - 70 )
106
+ frame .GitHubLink :SetWidth (330 )
107
+ frame .GitHubLink :SetHeight (19 )
108
+ frame .GitHubLink :SetMultiLine (false )
109
+ frame .GitHubLink :SetAutoFocus (false )
110
+ frame .GitHubLink :SetFontObject (K .UIFont )
111
+ frame .GitHubLink :SetText (" https://github.com/Kkthnx-Wow/KkthnxUI" )
112
+ frame .GitHubLink :CreateBorder ()
113
+
114
+ -- Tooltip for GitHub link
115
+ frame .GitHubLink :SetScript (" OnEnter" , function ()
116
+ GameTooltip :SetOwner (frame .GitHubLink , " ANCHOR_TOP" )
117
+ GameTooltip :AddLine (" GitHub Link" , 1 , 1 , 1 )
118
+ GameTooltip :AddLine (" This is the bleeding edge version and may contain bugs." , 0.7 , 0.7 , 0.7 )
119
+ GameTooltip :Show ()
120
+ end )
121
+ frame .GitHubLink :SetScript (" OnLeave" , function ()
122
+ GameTooltip :Hide ()
123
+ end )
72
124
73
125
frame .OkayButton = CreateFrame (" Button" , nil , frame )
74
126
frame .OkayButton :SetPoint (" TOP" , frame , " BOTTOM" , 0 , - 6 )
@@ -80,29 +132,29 @@ function Module:CreateUpdateNoticeFrame()
80
132
end
81
133
end )
82
134
135
+ -- Set background texture to 'GarrMissionLocation-Maw-ButtonBG'
136
+ frame .Background = frame :CreateTexture (nil , " BACKGROUND" )
137
+ frame .Background :SetAtlas (" GarrMissionLocation-Maw-ButtonBG" )
138
+ frame .Background :SetAllPoints (frame .OkayButton )
139
+ frame .Background :SetBlendMode (" ADD" )
140
+
83
141
frame .OkayButton .Text = frame .OkayButton :CreateFontString (nil , " ARTWORK" )
84
142
frame .OkayButton .Text :SetFontObject (K .UIFont )
85
143
frame .OkayButton .Text :SetFont (select (1 , frame .OkayButton .Text :GetFont ()), 13 , select (3 , frame .OkayButton .Text :GetFont ()))
86
144
frame .OkayButton .Text :SetText (" I am going to update right now" )
87
145
frame .OkayButton .Text :SetTextColor (0 , 1 , 0 )
88
146
frame .OkayButton .Text :SetPoint (" CENTER" , frame .OkayButton , " CENTER" , 0 , 0 )
89
- K .AddTooltip (frame .OkayButton , " ANCHOR_BOTTOM" , K .SystemColor .. " Obviously |cff669dffKkthnx|r is trusting you to go update and not complain about a missing feature or a bug because you are out of date |CFFFF0000<3|r " )
147
+ K .AddTooltip (frame .OkayButton , " ANCHOR_BOTTOM" , K .SystemColor .. " Please update to the latest version! " )
90
148
91
149
return frame
92
150
end
93
151
94
152
function Module :VersionCheck_Create (text )
95
153
if not C [" General" ].VersionCheck then
154
+ DebugLog (" VersionCheck is disabled in settings." )
96
155
return
97
156
end
98
157
99
- -- HelpTip:Show(ChatFrame1, {
100
- -- text = text,
101
- -- buttonStyle = HelpTip.ButtonStyle.Okay,
102
- -- targetPoint = HelpTip.Point.TopEdgeCenter,
103
- -- offsetY = 10,
104
- -- })
105
-
106
158
local frame = Module :CreateUpdateNoticeFrame ()
107
159
frame .Text :SetText (text )
108
160
frame :Show ()
@@ -111,59 +163,95 @@ end
111
163
function Module :VersionCheck_Init ()
112
164
if not isVCInit then
113
165
local status = Module :VersionCheck_Compare (KkthnxUIDB .DetectVersion , K .Version )
166
+
114
167
if status == " IsNew" then
115
- local release = gsub (KkthnxUIDB .DetectVersion , " (%d+)$" , " 0" )
116
- Module :VersionCheck_Create (format (" |cff669dffKkthnxUI|r is out of date, the latest release is |cff70C0F5%s|r" , release ))
168
+ local release = string_gsub (KkthnxUIDB .DetectVersion , " (%d+)$" , " 0" )
169
+ Module :VersionCheck_Create (string_format (" |cff669dffKkthnxUI|r is out of date!|nPlease update to the latest version: |cff70C0F5%s|r. " , release ))
117
170
elseif status == " IsOld" then
118
171
KkthnxUIDB .DetectVersion = K .Version
119
172
end
120
173
121
174
isVCInit = true
175
+ DebugLog (" VersionCheck initialized." )
176
+ else
177
+ DebugLog (" VersionCheck already initialized." )
122
178
end
123
179
end
124
180
125
181
function Module :VersionCheck_Send (channel )
126
182
if GetTime () - lastVCTime >= 10 then
127
183
C_ChatInfo_SendAddonMessage (" KKUIVersionCheck" , KkthnxUIDB .DetectVersion , channel )
128
184
lastVCTime = GetTime ()
185
+ DebugLog (" VersionCheck message sent to channel: " .. channel )
186
+ else
187
+ DebugLog (" VersionCheck message not sent due to cooldown." )
129
188
end
130
189
end
131
190
132
- function Module :VersionCheck_Update (...)
133
- local prefix , msg , distType , author = ...
191
+ function Module :VersionCheck_Update (prefix , msg , distType , author )
134
192
if prefix ~= " KKUIVersionCheck" then
135
193
return
136
194
end
195
+
137
196
if Ambiguate (author , " none" ) == K .Name then
197
+ DebugLog (" VersionCheck ignored message from self." )
138
198
return
139
199
end
140
200
141
201
local status = Module :VersionCheck_Compare (msg , KkthnxUIDB .DetectVersion , author )
202
+
142
203
if status == " IsNew" then
143
204
KkthnxUIDB .DetectVersion = msg
205
+ DebugLog (" Detected new version: " .. msg )
144
206
elseif status == " IsOld" then
145
207
Module :VersionCheck_Send (distType )
208
+ DebugLog (" Detected outdated version. Sending current version to: " .. distType )
146
209
end
147
210
148
211
Module :VersionCheck_Init ()
149
212
end
150
213
151
214
function Module :VersionCheck_UpdateGroup ()
152
215
if not IsInGroup () then
216
+ DebugLog (" Not in a group, skipping version check." )
153
217
return
154
218
end
155
- Module :VersionCheck_Send (IsPartyLFG () and " INSTANCE_CHAT" or IsInRaid () and " RAID" or " PARTY" )
219
+
220
+ local channel = IsPartyLFG () and " INSTANCE_CHAT" or IsInRaid () and " RAID" or " PARTY"
221
+ Module :VersionCheck_Send (channel )
156
222
end
157
223
158
224
function Module :OnEnable ()
159
225
Module :VersionCheck_Init ()
226
+
160
227
C_ChatInfo_RegisterAddonMessagePrefix (" KKUIVersionCheck" )
161
228
K :RegisterEvent (" CHAT_MSG_ADDON" , Module .VersionCheck_Update )
162
229
163
230
if IsInGuild () then
164
231
C_ChatInfo_SendAddonMessage (" KKUIVersionCheck" , K .Version , " GUILD" )
165
232
lastVCTime = GetTime ()
233
+ DebugLog (" VersionCheck message sent to guild." )
166
234
end
235
+
167
236
Module :VersionCheck_UpdateGroup ()
168
237
K :RegisterEvent (" GROUP_ROSTER_UPDATE" , Module .VersionCheck_UpdateGroup )
169
238
end
239
+
240
+ -- Add this function to manually trigger a test of the version check frame
241
+ function Module :VersionCheck_Test ()
242
+ -- Fake version for testing purposes
243
+ local fakeVersion = " 9.9.9"
244
+
245
+ -- Force the creation of the update notice frame with fake text
246
+ local fakeText = string_format (" |cff669dffKkthnxUI|r is out of date!|nPlease update to the latest version: |cff70C0F5%s|r." , fakeVersion )
247
+ Module :VersionCheck_Create (fakeText )
248
+
249
+ -- Print debug message for testing
250
+ DebugLog (" Triggered VersionCheck test with version: " .. fakeVersion )
251
+ end
252
+
253
+ -- Add a slash command to manually trigger the test during runtime
254
+ SLASH_KKUI_VERSIONCHECK1 = " /vctest"
255
+ SlashCmdList [" KKUI_VERSIONCHECK" ] = function ()
256
+ Module :VersionCheck_Test ()
257
+ end
0 commit comments