@@ -23,6 +23,9 @@ LoadModule("Modules/CalcTools")
2323LoadModule (" Modules/PantheonTools" )
2424LoadModule (" Modules/BuildSiteTools" )
2525
26+ -- Load as global so other modules can access the same instance
27+ ToastNotification = LoadModule (" Modules/ToastNotification" )
28+
2629--[[ if launch.devMode then
2730 for skillName, skill in pairs(data.enchantments.Helmet) do
2831 for _, mod in ipairs(skill.ENDGAME) do
@@ -234,19 +237,14 @@ function main:Init()
234237 self .controls .devMode .shown = function ()
235238 return launch .devMode
236239 end
237- self .controls .dismissToast = new (" ButtonControl" , {" BOTTOMLEFT" ,self .anchorMain ," BOTTOMLEFT" }, {0 , function () return - self .mainBarHeight + self .toastHeight end , 80 , 20 }, " Dismiss" , function ()
238- self .toastMode = " HIDING"
239- self .toastStart = GetTime ()
240- end )
241- self .controls .dismissToast .shown = function ()
242- return self .toastMode == " SHOWN"
243- end
244240
245241 self .mainBarHeight = 58
246- self .toastMessages = { }
242+
243+ -- Initialize toast notification system
244+ ToastNotification :Init (self .anchorMain )
247245
248246 if launch .devMode and GetTime () >= 0 and GetTime () < 15000 then
249- t_insert ( self . toastMessages , [[
247+ ToastNotification : Add ( [[
250248^xFF7700Warning: ^7Developer Mode active!
251249The program is currently running in developer
252250mode, which is not intended for normal use.
@@ -372,56 +370,23 @@ function main:OnFrame()
372370 self :CallMode (" OnFrame" , self .inputEvents , self .viewPort )
373371
374372 if launch .updateErrMsg then
375- t_insert ( self . toastMessages , string.format (" Update check failed!\n %s" , launch .updateErrMsg ))
373+ ToastNotification : Add ( string.format (" Update check failed!\n %s" , launch .updateErrMsg ))
376374 launch .updateErrMsg = nil
377375 end
378376 if launch .updateAvailable then
379377 if launch .updateAvailable == " none" then
380- t_insert ( self . toastMessages , " No update available\n You are running the latest version." )
378+ ToastNotification : Add ( " No update available\n You are running the latest version." )
381379 launch .updateAvailable = nil
382380 elseif not self .updateAvailableShown then
383- t_insert ( self . toastMessages , " Update Available\n An update has been downloaded and is ready\n to be applied." )
381+ ToastNotification : Add ( " Update Available\n An update has been downloaded and is ready\n to be applied." )
384382 self .updateAvailableShown = true
385383 end
386384 end
387385
388- -- Run toasts
389- if self .toastMessages [1 ] then
390- if not self .toastMode then
391- self .toastMode = " SHOWING"
392- self .toastStart = GetTime ()
393- self .toastHeight = # self .toastMessages [1 ]:gsub (" [^\n ]" ," " ) * 16 + 20 + 40
394- end
395- if self .toastMode == " SHOWING" then
396- local now = GetTime ()
397- if now >= self .toastStart + 250 then
398- self .toastMode = " SHOWN"
399- else
400- self .mainBarHeight = 58 + self .toastHeight * (now - self .toastStart ) / 250
401- end
402- end
403- if self .toastMode == " SHOWN" then
404- self .mainBarHeight = 58 + self .toastHeight
405- elseif self .toastMode == " HIDING" then
406- local now = GetTime ()
407- if now >= self .toastStart + 75 then
408- self .toastMode = nil
409- self .mainBarHeight = 58
410- t_remove (self .toastMessages , 1 )
411- else
412- self .mainBarHeight = 58 + self .toastHeight * (1 - (now - self .toastStart ) / 75 )
413- end
414- end
415- if self .toastMode then
416- SetDrawColor (0.85 , 0.85 , 0.85 )
417- DrawImage (nil , 0 , self .screenH - self .mainBarHeight , 312 , self .mainBarHeight )
418- SetDrawColor (0.1 , 0.1 , 0.1 )
419- DrawImage (nil , 0 , self .screenH - self .mainBarHeight + 4 , 308 , self .mainBarHeight - 4 )
420- SetDrawColor (1 , 1 , 1 )
421- DrawString (4 , self .screenH - self .mainBarHeight + 8 , " LEFT" , 20 , " VAR" , self .toastMessages [1 ]:gsub (" \n .*" ," " ))
422- DrawString (4 , self .screenH - self .mainBarHeight + 28 , " LEFT" , 16 , " VAR" , self .toastMessages [1 ]:gsub (" ^[^\n ]*\n ?" ," " ))
423- end
424- end
386+ -- Update and render toasts
387+ ToastNotification :UpdateFrame (self .inputEvents , self .viewPort , self .screenH )
388+ local totalToastHeight = ToastNotification :Render ()
389+ self .mainBarHeight = 58 + totalToastHeight
425390
426391 -- Draw main controls
427392 SetDrawColor (0.85 , 0.85 , 0.85 )
0 commit comments