Advertisement
Jousway

ScreenSelectMusic overlay.lua

Jan 21st, 2016
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.78 KB | None | 0 0
  1. -- ITS A HACKJOB!
  2. -- I cant theme for shit -Jousway
  3.  
  4. -- I used some code from other themes, mostly the default theme, so massive respect to the creators
  5.  
  6. local t = Def.ActorFrame { 
  7.     OnCommand=function(self) self:sleep(0.1) self:queuecommand("Fix") end;
  8.     CurrentSongChangedMessageCommand=function(self) self:sleep(0.0000001) self:queuecommand("Fix") self:sleep(0.0000001) self:queuecommand("Fix") end;
  9.     CurrentStepsP1ChangedMessageCommand=function(self) self:sleep(0.0000001) self:queuecommand("Fix") end;
  10.     CurrentStepsP2ChangedMessageCommand=function(self) self:sleep(0.0000001) self:queuecommand("Fix") end;
  11.     FixCommand=function(self) ScreenSelectMusicUpdate(self) end;
  12.     --CDTitle Resizer/Container
  13.     Def.ActorFrame{
  14.         Name="Container";
  15.         OnCommand=cmd(x,SCREEN_CENTER_X-160;y,SCREEN_CENTER_Y);
  16.         --main background
  17.         Def.Quad{
  18.             InitCommand=cmd(y,-84;zoomto,294,295;diffuse,color("0.5,0.5,0.5,0.5"));
  19.         };
  20.        
  21.         --banner and title container
  22.         Def.Quad{
  23.             InitCommand=cmd(y,-155;zoomto,289,150;diffuse,color("0,0,0,0.5"));
  24.         };
  25.         --Banner Background
  26.         Def.Quad{
  27.             InitCommand=cmd(y,-160;zoomto,284,89;diffuse,color("0,0,0,0.5"););
  28.         };
  29.         --No Banner Text
  30.         LoadFont("Common Normal") .. {
  31.             Text="No Banner";
  32.             InitCommand=cmd(y,-160;diffuse,color("1,1,1,0.5"));
  33.         };
  34.         --Load Banner
  35.         Def.Sprite {
  36.             Name="Banner";
  37.             InitCommand=cmd(y,-160);
  38.         };
  39.         --Song Title above Banner
  40.         LoadFont("Common Normal") .. {
  41.             Name="title";
  42.             InitCommand=cmd(y,-218;zoom,0.6;maxwidth,460);
  43.         };
  44.        
  45.         --CDTitle Background
  46.         Def.Quad{
  47.             InitCommand=cmd(y,-45;x,102;zoomto,85,65;diffuse,color("0,0,0,0.5"););
  48.         };
  49.         --Load CDTitle
  50.         Def.Sprite {
  51.             Name="CDTitle";
  52.             InitCommand=cmd(y,-45;x,102);
  53.         };     
  54.        
  55.         --NPS Calculator/Display
  56.         LoadFont("Common Normal") .. {
  57.             Text="NPS";
  58.             InitCommand=cmd(x,70;y,-98;zoom,0.75;diffuse,1,1,1,1);
  59.         };
  60.         LoadFont("Common Normal") .. {
  61.             Name="P1NPS";
  62.             InitCommand=cmd(;y,-98;zoom,0.75;diffuse,color("#ef403d"));
  63.         };
  64.         LoadFont("Common Normal") .. {
  65.             Name="P2NPS";
  66.             InitCommand=cmd(y,-98;zoom,0.75;diffuse,color("#0089cf"));
  67.         };
  68.        
  69.         --BPM
  70.         LoadFont("Common Normal") .. {
  71.             Text="BPM";
  72.             InitCommand=cmd(x,-25;y,-98;zoom,0.75;diffuse,1,1,1,1);
  73.         };
  74.         LoadFont("Common Normal") .. {
  75.             Name="BPM";
  76.             InitCommand=cmd(x,25;y,-98;zoom,0.75;diffuse,color("#0089cf"));
  77.         };
  78.        
  79.         --Song Length
  80.         LoadFont("Common Normal") .. {
  81.             Name="length";
  82.             InitCommand=cmd(x,-95;y,-98;zoom,0.75;diffuse,color("#ef403d"));
  83.         };
  84.         LoadFont("Common Normal") .. {
  85.             Name="test";
  86.             InitCommand=cmd();
  87.         };
  88.        
  89.         --difficulty selector
  90.         Def.Quad{
  91.             Name="p2curB";
  92.             InitCommand=cmd(y,-28;diffuse,color("#0089cfaa"));
  93.         };
  94.         LoadFont("Common Normal") .. {
  95.             Name="p2curT";
  96.             Text="P2";
  97.             InitCommand=cmd(y,-28;zoom,0.8;diffuse,color("0,0,0,0.8"));
  98.         };
  99.         Def.Quad{
  100.             Name="p1curB";
  101.             InitCommand=cmd(y,-28;diffuse,color("#ef403daa"));
  102.         };
  103.         LoadFont("Common Normal") .. {
  104.             Name="p1curT";
  105.             Text="P1";
  106.             InitCommand=cmd(y,-28;zoom,0.8;diffuse,color("0,0,0,0.8"));
  107.         };
  108.         LoadActor( THEME:GetPathG("ScreenSelectMusic","DifficultyDisplay") ) .. {
  109.         };
  110.        
  111.         --song stats panel
  112.         Def.Quad{
  113.             InitCommand=cmd(y,25;x,-73;zoomto,143,70;diffuse,color("0,0,0,0.5"));
  114.         };
  115.         LoadFont("Common Normal") .. {
  116.             Name="p1SP";
  117.             Text="Press Start";
  118.             InitCommand=cmd(y,25;x,-73;zoom,0.7;diffuse,color("1,1,1,0.5"));
  119.         };
  120.         LoadActor( THEME:GetPathG("PaneDisplay","p1") ) .. {
  121.             InitCommand=cmd(x,-80;y,30;zoom,0.36);
  122.         };
  123.         Def.Quad{
  124.             InitCommand=cmd(y,25;x,73;zoomto,143,70;diffuse,color("0,0,0,0.5"));
  125.         };
  126.         LoadFont("Common Normal") .. {
  127.             Name="p2SP";
  128.             Text="Press Start";
  129.             InitCommand=cmd(y,25;x,73;zoom,0.7;diffuse,color("1,1,1,0.5"));
  130.         };
  131.         LoadActor( THEME:GetPathG("PaneDisplay","p2") ) .. {
  132.             InitCommand=cmd(x,66;y,30;zoom,0.36);
  133.         };
  134.     };
  135. };
  136.  
  137.  
  138.  
  139.  
  140. function ScreenSelectMusicUpdate(self)
  141.     local song = GAMESTATE:GetCurrentSong();
  142.    
  143.     --load of code just to load group banner
  144.     local musicwheel = SCREENMAN:GetTopScreen():GetMusicWheel();
  145.     local selection = musicwheel:GetSelectedSection();
  146.     local gbanner = SONGMAN:GetSongGroupBannerPath(selection);
  147.  
  148.     --cdtitle and banner
  149.     local cdtitle = self:GetChild("Container"):GetChild("CDTitle");
  150.     local banner = self:GetChild("Container"):GetChild("Banner");
  151.     local cdheight = cdtitle:GetHeight();
  152.     local cdwidth = cdtitle:GetWidth();
  153.     local brheight = banner:GetHeight();
  154.     local brwidth = banner:GetWidth();
  155.            
  156.     if song then
  157.        
  158.         local songmil = "00";
  159.        
  160.         songsec = song:MusicLengthSeconds()%60;
  161.         songmin = math.floor(song:MusicLengthSeconds()/60);
  162.         for c in string.gmatch(songsec,"%d+%p(%d%d)") do
  163.             songmil = c;
  164.         end;
  165.        
  166.         length = string.format("%02d:%02d",  songmin, songsec)..":"..songmil;
  167.        
  168.         title = song:GetDisplayMainTitle();
  169.         if song:HasCDTitle() then
  170.             cdtitle:visible(true);
  171.             cdtitle:Load(song:GetCDTitlePath());
  172.         else
  173.             cdtitle:visible(false);
  174.         end;
  175.         if song:HasBanner() then
  176.             banner:visible(true);
  177.             banner:Load(song:GetBannerPath());
  178.         else
  179.             banner:visible(false);
  180.         end;
  181.     else
  182.         if gbanner ~= "" then
  183.             banner:visible(true);
  184.             banner:Load(gbanner);
  185.         else
  186.             banner:visible(false);
  187.         end;
  188.        
  189.         cdtitle:visible(false);
  190.         title = "";
  191.         length = "00:00";
  192.     end;
  193.        
  194.     self:GetChild("Container"):GetChild("title"):settext(title);
  195.     self:GetChild("Container"):GetChild("length"):settext(length);
  196.    
  197.     if cdheight >= 60 and cdwidth >= 80 then
  198.         if cdheight*(80/60) >= cdwidth then
  199.         cdtitle:zoom(60/cdheight);
  200.         else
  201.         cdtitle:zoom(80/cdwidth);
  202.         end;
  203.     elseif cdheight >= 60 then
  204.         cdtitle:zoom(60/cdheight);
  205.     elseif cdwidth >= 80 then
  206.         cdtitle:zoom(80/cdwidth);
  207.     else
  208.         cdtitle:zoom(1);
  209.     end;
  210.        
  211.     if brheight >= 89 and brwidth >= 284 then
  212.         if brheight*(284/89) >= brwidth then
  213.         banner:zoom(88/brheight);
  214.         else
  215.         banner:zoom(284/brwidth);
  216.         end;
  217.     elseif brheight >= 89 then
  218.         banner:zoom(89/brheight);
  219.     elseif brwidth >= 284 then
  220.         banner:zoom(284/brwidth);
  221.     elseif brwidth/3.22 >= brheight then
  222.         banner:zoom(284/brwidth);
  223.     else
  224.         banner:zoom(89/brheight);
  225.     end;
  226.    
  227.     --nps
  228.     local P1NPS = self:GetChild("Container"):GetChild("P1NPS");
  229.     local P2NPS = self:GetChild("Container"):GetChild("P2NPS");
  230.    
  231.     local difloc = {
  232.         Beginner    = 32*0.40,
  233.         Easy        = 32*1.46,
  234.         Medium      = 32*2.52,
  235.         Hard        = 32*3.58,
  236.         Challenge   = 32*4.64,
  237.         Edit        = 32*5.70,
  238.     };
  239.    
  240.    
  241.     p1curB = self:GetChild("Container"):GetChild("p1curB");
  242.     p1CurT = self:GetChild("Container"):GetChild("p1curT");
  243.     p2curB = self:GetChild("Container"):GetChild("p2curB");
  244.     p2CurT = self:GetChild("Container"):GetChild("p2curT");
  245.     p1SP = self:GetChild("Container"):GetChild("p1SP");
  246.     p2SP = self:GetChild("Container"):GetChild("p2SP");
  247.    
  248.     local function Radar(pn,cat)
  249.         local GetRadar = GAMESTATE:GetCurrentSteps(pn):GetRadarValues(pn);
  250.         return GetRadar:GetValue(cat);
  251.     end;
  252.        
  253.     --all this just to do difficulty, sadly this only works in sm5 beta 4, so beta 3 users need to update :<
  254.     if GAMESTATE:IsHumanPlayer(PLAYER_1) then
  255.         if song then
  256.             local ChartLenghtInSec = song:GetStepsSeconds();
  257.             local P1Taps = Radar(PLAYER_1,'RadarCategory_TapsAndHolds')+Radar(PLAYER_1,'RadarCategory_Jumps')+Radar(PLAYER_1,'RadarCategory_Hands');
  258.             P1NPS:settext(string.format("%0.0f",P1Taps/ChartLenghtInSec));
  259.         else
  260.             P1NPS:settext("0");
  261.         end;       
  262.         if GAMESTATE:GetCurrentSteps(PLAYER_1) then
  263.             local p1d = ToEnumShortString(GAMESTATE:GetCurrentSteps(PLAYER_1):GetDifficulty());
  264.             if song then
  265.                 p1curB:visible(true);
  266.                 p1CurT:visible(true);
  267.             else
  268.                 p1curB:visible(false);
  269.                 p1CurT:visible(false);
  270.             end;
  271.             p1curB:x(-142+difloc[p1d]);
  272.             p1CurT:x(-142+difloc[p1d]);
  273.         else
  274.             p1curB:visible(false);
  275.             p1CurT:visible(false);
  276.         end;
  277.         P2NPS:x(130);
  278.         p1SP:visible(false);
  279.     else
  280.         P2NPS:x(115);
  281.         p1curB:visible(false);
  282.         p1CurT:visible(false);
  283.         p1SP:visible(true);
  284.     end;
  285.    
  286.     if GAMESTATE:IsHumanPlayer(PLAYER_2) then
  287.         if song then
  288.             local ChartLenghtInSec = song:GetStepsSeconds();
  289.             local P2Taps = Radar(PLAYER_2,'RadarCategory_TapsAndHolds')+Radar(PLAYER_2,'RadarCategory_Jumps')+Radar(PLAYER_2,'RadarCategory_Hands');
  290.             P2NPS:settext(string.format("%0.0f",P2Taps/ChartLenghtInSec));
  291.         else
  292.             P2NPS:settext("0");
  293.         end;
  294.         if GAMESTATE:GetCurrentSteps(PLAYER_2) then
  295.             local p2d = ToEnumShortString(GAMESTATE:GetCurrentSteps(PLAYER_2):GetDifficulty());
  296.             if song then
  297.                 p2curB:visible(true);
  298.                 p2CurT:visible(true);
  299.             else
  300.                 p2curB:visible(false);
  301.                 p2CurT:visible(false);
  302.             end;
  303.             p2curB:x(-142+difloc[p2d]);
  304.             p2CurT:x(-142+difloc[p2d]);
  305.         else
  306.             p2curB:visible(false);
  307.             p2CurT:visible(false);
  308.         end;
  309.         P1NPS:x(105);
  310.         p2SP:visible(false);
  311.     else
  312.         P1NPS:x(115);
  313.         p2curB:visible(false);
  314.         p2CurT:visible(false);
  315.         p2SP:visible(true);
  316.     end;
  317.    
  318.     if GAMESTATE:IsHumanPlayer(PLAYER_1) and GAMESTATE:IsHumanPlayer(PLAYER_2) then
  319.         local p1d = ToEnumShortString(GAMESTATE:GetCurrentSteps(PLAYER_1):GetDifficulty());
  320.         local p2d = ToEnumShortString(GAMESTATE:GetCurrentSteps(PLAYER_2):GetDifficulty());
  321.         if p1d == p2d then
  322.             p1curB:zoomto(30,15);
  323.             p1CurT:zoomy(0.5);
  324.             p2curB:zoomto(30,15);
  325.             p2CurT:zoomy(0.5);
  326.             p1curB:y(-36);
  327.             p1CurT:y(-36);
  328.             p2curB:y(-20);
  329.             p2CurT:y(-20);
  330.         else
  331.             p1curB:zoomto(30,30);
  332.             p1CurT:zoomy(1);
  333.             p2curB:zoomto(30,30);
  334.             p2CurT:zoomy(1);
  335.             p1curB:y(-28);
  336.             p1CurT:y(-28);
  337.             p2curB:y(-28);
  338.             p2CurT:y(-28);
  339.         end;
  340.     else
  341.         p1curB:zoomto(30,30);
  342.         p1CurT:zoomy(1);
  343.         p2curB:zoomto(30,30);
  344.         p2CurT:zoomy(1);
  345.     end;--]]
  346. end;
  347.  
  348. local function Update(self)
  349.     local song = GAMESTATE:GetCurrentSong();
  350.    
  351.     if song then
  352.         bpm = string.format("%03.0f",GAMESTATE:GetSongBPS()*60);
  353.     else
  354.         bpm = "000";
  355.     end;
  356.     self:GetChild("Container"):GetChild("BPM"):settext(bpm);
  357.  
  358. end;
  359. t.InitCommand=cmd(SetUpdateFunction,Update);
  360.  
  361. return t;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement