Advertisement
Jousway

Barebone ScreenSelelctMusic Overlay

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