Advertisement
Guest User

Untitled

a guest
Mar 14th, 2022
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.19 KB | None | 0 0
  1. local Theme = { };
  2.  
  3. --
  4.  
  5. Theme.Settings = { };
  6.  
  7. -- Theme Settings
  8.  
  9. Theme.Settings.Color = { ['R'] = 255; ['G'] = 255; ['B'] = 255; ['A'] = 255; }; --// Red, Green, Blue, Alpha/Transparency.
  10. Theme.Settings.Rainbow = true; --// If true then it will ignore Settings.Color. If false then the color of the menu will stick to Settings.Color.
  11. Theme.Settings.RainbowRandomStartPoint = math.random() * 10; --// Needed to start at a random starting point in the color cycle.
  12.  
  13. -- SetColor
  14.  
  15. function Theme:SetColor( Color )
  16.     local R, G, B, Alpha = math.floor( tonumber( Color.R ) ), math.floor( tonumber( Color.G ) ), math.floor( tonumber( Color.B ) ), math.floor( tonumber( Color.A ) );
  17.  
  18.     menu.set_color(menu_color.FrameBgActive, R, G, B);
  19.  
  20.     menu.set_color(menu_color.SliderGrab, R, G, B);
  21.     menu.set_color(menu_color.SliderGrabActive, R, G, B);
  22.    
  23.     menu.set_color(menu_color.CheckMark, R, G, B);
  24.  
  25.     menu.set_color(menu_color.ScrollbarGrab, R, G, B);
  26.     menu.set_color(menu_color.ScrollbarGrabHovered, R, G, B);
  27.     menu.set_color(menu_color.ScrollbarGrabActive, R, G, B);
  28.    
  29.     menu.set_widget_color(menu_widget_color.Icons, R, G, B, Alpha);
  30.     menu.set_widget_color(menu_widget_color.ScrollbarGrab, R, G, B, Alpha );
  31.     menu.set_widget_color(menu_widget_color.ScrollbarGrabHovered, R, G, B, Alpha);
  32.     menu.set_widget_color(menu_widget_color.ScrollbarGrabActive, R, G, B, Alpha);
  33.  
  34.     menu.set_widget_color(menu_widget_color.TitleName, R, G, B, Alpha);
  35.     menu.set_widget_color(menu_widget_color.NotifyRectLine, R, G, B, Alpha);
  36.     menu.set_widget_color(menu_widget_color.NotifyIcon, R, G, B, Alpha);
  37.     menu.set_widget_color(menu_widget_color.NotifyDefault, R, G, B, Alpha);
  38.     menu.set_widget_color(menu_widget_color.NotifySuccess, R, G, B, Alpha);
  39.  
  40.     menu.set_alpha( Alpha );
  41. end;
  42.  
  43. -- GetNextColor
  44.  
  45. function Theme:GetNextColor( InitPoint )
  46.     local function GetPositiveAngleDiff( a, b )
  47.         return a < b and a + 360 - b or a - b;
  48.     end;
  49.  
  50.     local Angle = InitPoint * 360;
  51.     local Color = { };
  52.  
  53.     for i = 1, 3 do
  54.         local Start = ( ( i + 1 ) * 120 ) % 360;
  55.         local DiffFromStart = GetPositiveAngleDiff( Angle, Start );
  56.  
  57.         if DiffFromStart < 60 then
  58.             Color[i] = DiffFromStart / 60 * 255;
  59.         elseif DiffFromStart <= 180 then
  60.             Color[i] = 255;
  61.         elseif DiffFromStart < 240 then
  62.             Color[i] = ( 240 - DiffFromStart ) / 60 * 255;
  63.         else
  64.             Color[i] = 0;
  65.         end;
  66.     end;
  67.  
  68.     return Color[1], Color[2], Color[3];
  69. end
  70.  
  71. -- OnDone
  72.  
  73. function OnDone( )
  74.     menu.restore_styles( );
  75. end;
  76.  
  77. -- OnFrame
  78.  
  79. function OnFrame()
  80.     if Theme.Settings.Rainbow and menu.is_menu_opened then
  81.         local Hue = ( system.ticks( ) + Theme.Settings.RainbowRandomStartPoint ) % ( 14250 ) / ( 14250 );
  82.         local R, G, B = Theme:GetNextColor( Hue );
  83.  
  84.         Theme.Settings.Color.R = R;
  85.         Theme.Settings.Color.G = G;
  86.         Theme.Settings.Color.B = B;
  87.  
  88.         Theme:SetColor( Theme.Settings.Color );
  89.     end;
  90. end;
  91.  
  92. -- OnInit
  93.  
  94. function OnInit( )
  95.     menu.restore_styles( );
  96.  
  97.     if not Theme.Settings.Rainbow then
  98.         Theme:SetColor( Theme.Settings.Color );  
  99.     end;
  100. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement