Advertisement
Jousway

ExpandField.lua

Mar 6th, 2018
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.85 KB | None | 0 0
  1. function ExpandfieldLoad()
  2.     --SCREENMAN:GetTopScreen():GetChild("PlayerP1"):GetChild("NoteField"):visible(false)
  3. end
  4.  
  5. OLDNSKIN = NOTESKIN
  6.  
  7. function NoteskinLoader(pn,Button,Element)
  8.     local Open_Common = RageFileUtil.CreateRageFile()
  9.     local Open_Noteskin = RageFileUtil.CreateRageFile()
  10.            
  11.     local CommonDir = "/NoteSkins/common/common"
  12.     local NoteskinDir = "/NoteSkins/"..GAMESTATE:GetCurrentGame():GetName().."/"..GAMESTATE:GetPlayerState(pn):GetPlayerOptions("ModsLevel_Current"):NoteSkin()
  13.    
  14.     function GetNoteskinFile(file)
  15.         local Dir = FILEMAN:GetDirListing(NoteskinDir.."/")
  16.         local Rvalue = {}
  17.         for i = 1,#Dir do
  18.             if file then
  19.                 file = file:gsub(".png",""):lower()
  20.                 Dir[i] = Dir[i]:lower()
  21.                 if string.find(Dir[i], file) then return NoteskinDir.."/"..Dir[i] end
  22.             end
  23.         end
  24.         return THEME:GetPathG("","_missing")
  25.     end
  26.    
  27.     Open_Common:Open(CommonDir.."/NoteSkin.lua", 1)
  28.     Open_Noteskin:Open(NoteskinDir.."/NoteSkin.lua", 1)
  29.    
  30.     local Common = Open_Common:Read()
  31.     local Common = Common:gsub('','local function thotmania(But,Elm) return "'..NoteskinDir..'/"..But.." "..Elm \n end \n',1)
  32.         :gsub('Var "Button"','"'..Button..'"')
  33.         :gsub('Var "Element"','"'..Element..'"')
  34.         :gsub("NOTESKIN:GetPath",'thotmania')
  35.     local Common = assert(loadstring(Common))
  36.    
  37.     local Noteskin = Open_Noteskin:Read()
  38.     local Noteskin = Noteskin:gsub('','local function thotmania(But,Elm) return "'..NoteskinDir..'/"..But.." "..Elm \n end \n',1)
  39.         :gsub('Var "Button"','"'..Button..'"')
  40.         :gsub('Var "Element"','"'..Element..'"')
  41.         :gsub("NOTESKIN:GetPath",'thotmania')
  42.     local Noteskin = assert(loadstring(Noteskin))
  43.    
  44.     Open_Common:Close()
  45.     Open_Noteskin:Close()
  46.    
  47.     NOTESKIN = {}
  48.     NOTESKIN.GetPath = function(_,BUTTON,ELEMENT) return BUTTON.." "..ELEMENT..".png" end
  49.     NOTESKIN.GetMetricA = function(...) return cmd(diffusealpha,1) end
  50.        
  51.     local Output = GetNoteskinFile(Noteskin(Common())["Load"]()["Texture"])
  52.     local Rotation = Noteskin(Common())["Load"]()["BaseRotationZ"]
  53.    
  54.     if Output ~= THEME:GetPathG("","_missing") then
  55.         Output = {Output}
  56.     else
  57.         RetVal = {}
  58.         for i = 1,#Noteskin(Common())["Load"]() do
  59.             RetVal[#RetVal+1] = GetNoteskinFile(Noteskin(Common())["Load"]()[1]["Texture"])
  60.         end
  61.         Output = RetVal
  62.     end
  63.    
  64.     NOTESKIN = OLDNSKIN
  65.    
  66.     return Output, Rotation
  67. end
  68.  
  69. function SMLoader(Steps)
  70.     local Open_SM = RageFileUtil.CreateRageFile()
  71.    
  72.     local CurGS = ToEnumShortString(Steps:GetStepsType()):lower():gsub("_","-")
  73.     local CurDiff = ToEnumShortString(Steps:GetDifficulty())
  74.     local FBeat = GAMESTATE:GetCurrentSong():GetFirstBeat()
  75.    
  76.     local function CheckGS(Line)
  77.         for i in string.gmatch(Line, "%s+(.-):") do
  78.             if i == CurGS then
  79.                 return true
  80.             end
  81.         end
  82.         return false
  83.     end
  84.    
  85.     local function CheckDiff(Line)
  86.         for i in string.gmatch(Line, "%s+(.-):") do
  87.             if i == CurDiff then
  88.                 return true
  89.             end
  90.         end
  91.         return false
  92.     end
  93.    
  94.     Open_SM:Open(Steps:GetFilename(), 1)
  95.     SM_File = Open_SM:Read()
  96.    
  97.     Output = {}
  98.    
  99.     for i in string.gmatch(SM_File, "#NOTES:.-;") do
  100.         if CheckGS(i) and CheckDiff(i) then
  101.             local Beat = 0
  102.             for i2 in string.gmatch(i:gsub(".+:",""):gsub(";",","):gsub("//.-\n",""):gsub(" ",""), "%s(.-),") do
  103.                 Beat = Beat + 4
  104.                 AL = 0
  105.                 CL = 0
  106.                 for _ in string.gmatch(i2, "%w+") do
  107.                     AL = AL + 1
  108.                 end
  109.                 for i3 in string.gmatch(i2, "%w+") do
  110.                     SBeat = (Beat-4)+((4/AL)*CL)
  111.                     CL = CL + 1
  112.                     CI = 1
  113.                     for i4 in string.gmatch(i3, "%w") do
  114.                         if i4 == "1" or i4 == "2" then
  115.                             Output[#Output+1] = {SBeat,Exp_Buttons[GAMESTATE:GetCurrentGame():GetName()][GAMESTATE:GetCurrentStyle():GetName()][CI]}
  116.                         end
  117.                         CI = CI + 1
  118.                     end
  119.                 end
  120.             end
  121.         end            
  122.     end
  123.     return Output
  124. end
  125.  
  126. Exp_Buttons = {
  127.     dance = {
  128.         single = {"Left","Down","Up","Right"},
  129.         solo = {"Left","UpLeft","Down","Up","UpRight","Right"},
  130.     },
  131.     pump = {},
  132. }
  133.  
  134. Exp_Element = {
  135.     "Receptor",
  136. }
  137.  
  138. function PlayerField(pn)
  139.  
  140.     local Notes = SMLoader(GAMESTATE:GetCurrentSteps(pn))
  141.    
  142.     local Reverse = ((GAMESTATE:GetPlayerState(pn):GetPlayerOptions("ModsLevel_Current"):Reverse()-0.5)*2)*-1
  143.    
  144.     local CurBut = Exp_Buttons[GAMESTATE:GetCurrentGame():GetName()][GAMESTATE:GetCurrentStyle():GetName()]
  145.    
  146.     function ReceptorPos(Reverse)
  147.         if Reverse == 1 then
  148.             return THEME:GetMetric( "Player", "ReceptorArrowsYStandard" )
  149.         else
  150.             return THEME:GetMetric( "Player", "ReceptorArrowsYReverse" )
  151.         end
  152.     end
  153.    
  154.     function GetCount(Note)
  155.         for i3 = 1,#CurBut do
  156.             if CurBut[i3] == Notes[Note][2] then
  157.                 return i3
  158.             end
  159.         end
  160.         return 1
  161.     end
  162.    
  163.     local t = Def.ActorFrame{
  164.         OnCommand=cmd(xy,SCREEN_CENTER_X,SCREEN_CENTER_Y+ReceptorPos(Reverse);zoom,1)
  165.     }
  166.            
  167.     for i = 1,#CurBut do
  168.         for i2 = 1,#Exp_Element do
  169.             local Texture, Rotation = NoteskinLoader(pn,CurBut[i],Exp_Element[i2])
  170.             for i3 = 1,#Texture do
  171.                 t[#t+1] = Def.ActorFrame{
  172.                     OnCommand=function(self)
  173.                         self:x((-(#CurBut*(96/2.5))+(i*(96/1.5)))-((96/1.5)/10))
  174.                     end,
  175.                     LoadActor(Texture[i3])..{
  176.                         OnCommand=function(self)
  177.                             self:rotationz(Rotation)
  178.                         end,
  179.                     },
  180.                 }
  181.             end
  182.         end
  183.     end
  184.    
  185.    
  186.     function TextureActors(Tex,Rot)
  187.         local t2 = Def.ActorFrame{}
  188.         for i = 1,#Tex do
  189.             t2[#t2+1] = LoadActor(Tex[i])..{
  190.                 OnCommand=function(self)
  191.                     self:rotationz(Rot)
  192.                         :animate(false)
  193.                         :setstate(15)
  194.                         :xy(32,32)
  195.                 end,
  196.             }
  197.         end
  198.         return t2
  199.     end
  200.    
  201.     for i = 1,#CurBut do
  202.         Texture, Rotation = NoteskinLoader(pn,CurBut[i],"Tap Note")
  203.         t[#t+1] = Def.ActorFrameTexture {
  204.             InitCommand=function(self)
  205.                 self:SetTextureName( "Tap Note "..CurBut[i] )
  206.                     :SetWidth( 64 )
  207.                     :SetHeight( 64 )
  208.                     :EnableAlphaBuffer( true )
  209.                     :xy(SCREEN_CENTER_X,SCREEN_CENTER_Y)
  210.                     :Create()
  211.             end,
  212.             TextureActors(Texture,Rotation)
  213.         }
  214.     end
  215.    
  216.     for i = 1,#Notes do
  217.    
  218.         local BPM = GAMESTATE:GetCurrentSong():GetTimingData():GetBPMAtBeat(0)
  219.         local FBeat = GAMESTATE:GetCurrentSong():GetFirstBeat()
  220.         local LBeat = GAMESTATE:GetCurrentSong():GetLastBeat()
  221.         local FSecond = GAMESTATE:GetCurrentSong():GetFirstSecond()
  222.         local LSecond = GAMESTATE:GetCurrentSong():GetLastSecond()
  223.    
  224.         local speedmod = 400 / BPM
  225.         local speedmode = "cmod"
  226.         local setmode
  227.        
  228.         if speedmode == "cmod" then
  229.             setmode = 1
  230.         elseif speedmod == "xmod" then
  231.             setmode = i
  232.         end
  233.            
  234.         local BPM = GAMESTATE:GetCurrentSong():GetTimingData():GetBPMAtBeat(Notes[setmode][1])
  235.            
  236.         local arrowsize = 64
  237.         local arrowoffset = 0
  238.         local offset = arrowsize+arrowoffset
  239.        
  240.         local GlobalNotes = (Notes[i][1]*(offset))*speedmod
  241.         local EndNotes = ((LBeat*offset))*speedmod
  242.        
  243.         local NoteField = GlobalNotes+(offset*2)
  244.  
  245.         t[#t+1] = Def.ActorFrame{
  246.             OnCommand=function(self)
  247.                 self:xy((-(#CurBut*(96/2.5))+(GetCount(i)*(96/1.5)))-((96/1.5)/10),(NoteField)*Reverse)
  248.                     :queuecommand("Scroller")
  249.             end,
  250.             ScrollerCommand=function(self)
  251.                 self:sleep(4.65+FSecond):linear(LSecond*2)
  252.                     :y((NoteField-(EndNotes*2))*Reverse)
  253.             end,
  254.             Def.Sprite{
  255.                 Texture="Tap Note "..Notes[i][2],
  256.                 OnCommand=function(self)
  257.                     self:visible(false)
  258.                         --:sleep(((Notes[i][1]/(GAMESTATE:GetSongBPS()))*(GAMESTATE:GetSongBPS()/2.55))-(GAMESTATE:GetCurrentSong():GetFirstBeat()*2.5))
  259.                         :queuecommand("Load")
  260.                 end,
  261.                 LoadCommand=function(self)
  262.                     self:visible(true)
  263.                         :sleep(4.5)
  264.                         --:queuecommand("UnLoad")
  265.                         --print("LOAD"..GAMESTATE:GetCurrentSong():GetFirstBeat())
  266.                 end,
  267.                 UnLoadCommand=function(self)
  268.                     self:visible(false)
  269.                         print("UNLOAD")
  270.                 end,
  271.             },
  272.         }
  273.     end
  274.    
  275.     t[#t+1] = Def.Sound{
  276.         File=GAMESTATE:GetCurrentSong():GetMusicPath();
  277.         OnCommand=function(self)
  278.             self:sleep(4.65)
  279.             self:queuecommand("Play")
  280.             print(GAMESTATE:GetCurrentSong():GetMusicPath());
  281.         end;
  282.         PlayCommand=function(self) self:play() end;
  283.     }
  284.    
  285.     return t
  286.  
  287. end
  288.  
  289. function ExpandField()
  290.     local t = Def.ActorFrame{
  291.         PlayerField(PLAYER_1)
  292.     }
  293.     return t
  294. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement