Advertisement
Guest User

./BGAnimations/ScreenSelectMusic decorations/Difficulty.lua

a guest
Dec 17th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.88 KB | None | 0 0
  1. -- This variable was passed in to this file (actor) from the parent default.lua
  2. local player = ...
  3.  
  4. -- initialize this value to be false
  5. local ThisPlayerPaneIsOpen = false
  6.  
  7. local function GetDifListX(self,offset)
  8.     if player==PLAYER_1 then
  9.         self:x(150+offset)
  10.     elseif player==PLAYER_2 then
  11.         self:x(_screen.w-200+offset)
  12.     end
  13. end
  14.  
  15. local function DrawDifListItem(diff)
  16.  
  17.     local DifficultyListItem = Def.ActorFrame {
  18.  
  19.         InitCommand=cmd(y, _screen.cy-204 ),
  20.         CurrentSongChangedMessageCommand=cmd(playcommand,"Set"),
  21.         CurrentStepsP1ChangedMessageCommand=function(self) if player == PLAYER_1 then self:playcommand("Set") end end,
  22.         CurrentStepsP2ChangedMessageCommand=function(self) if player == PLAYER_2 then self:playcommand("Set") end end,
  23.         CurrentTrailP1ChangedMessageCommand=function(self) if player == PLAYER_1 then self:playcommand("Set") end end,
  24.         CurrentTrailP2ChangedMessageCommand=function(self) if player == PLAYER_2 then self:playcommand("Set") end end,
  25.         CurrentCourseChangedMessageCommand=cmd(playcommand,"Set"),
  26.         OffCommand=cmd(sleep,0.15; linear,0.25; addx,-500),
  27.        
  28.         --disabled
  29.         Def.Quad{
  30.             InitCommand=cmd(diffuse,color("#000000");setsize,490,50;zoom,0.7),
  31.             SetCommand=function(self)
  32.  
  33.                 local st=GAMESTATE:GetCurrentStyle():GetStepsType()
  34.                 local song=GAMESTATE:GetCurrentSong()
  35.                 local course = GAMESTATE:GetCurrentCourse()
  36.  
  37.                 if song then
  38.                     GetDifListX(self, 35)
  39.                    
  40.                     self:y( Difficulty:Reverse()[diff] * 42 + 1.5 )
  41.  
  42.                     if song:HasStepsTypeAndDifficulty(st,diff) then
  43.                         self:diffusealpha(0)
  44.                     else
  45.                         self:diffusealpha(0.3)
  46.                     end
  47.                 end
  48.             end
  49.         },
  50.  
  51.         --meter
  52.         LoadFont("Common Normal")..{
  53.             InitCommand=cmd(draworder,99; diffuse,color("#000000"); strokecolor,Color.White; zoom,0.9),
  54.             SetCommand=function(self)
  55.                 self:settext("")
  56.                 local st=GAMESTATE:GetCurrentStyle():GetStepsType()
  57.                 local song=GAMESTATE:GetCurrentSong()
  58.  
  59.                 if song then
  60.                     GetDifListX(self, -119)
  61.                     self:y( Difficulty:Reverse()[diff] * 42 )                  
  62.  
  63.                     if song:HasStepsTypeAndDifficulty( st, diff ) then
  64.                         local steps = song:GetOneSteps( st, diff )
  65.                         self:settext( steps:GetMeter() )
  66.                     end
  67.                 end
  68.             end
  69.         },
  70.  
  71.  
  72.         --score number
  73.         LoadFont("Common Normal")..{
  74.             InitCommand=cmd(zoom,0.8;draworder,2);
  75.             BeginCommand=cmd(playcommand,"Set");
  76.             OffCommand=cmd(decelerate,0.05;diffusealpha,0;);
  77.             SetCommand=function(self)
  78.                 self:settext("")
  79.                
  80.                 local st=GAMESTATE:GetCurrentStyle():GetStepsType()
  81.                 local song=GAMESTATE:GetCurrentSong()
  82.                 local course = GAMESTATE:GetCurrentCourse()
  83.  
  84.                 if song then
  85.                     GetDifListX(self, 130)
  86.                     self:y( (Difficulty:Reverse()[diff]+1) * 42 )
  87.  
  88.                     if song:HasStepsTypeAndDifficulty(st,diff) then
  89.  
  90.                         local steps = song:GetOneSteps( st, diff )
  91.  
  92.                         if PROFILEMAN:IsPersistentProfile(player) then
  93.                             profile = PROFILEMAN:GetProfile(player)
  94.                         else
  95.                             profile = PROFILEMAN:GetMachineProfile()
  96.                         end
  97.  
  98.                         scorelist = profile:GetHighScoreList(song,steps)
  99.                         local scores = scorelist:GetHighScores()
  100.                         local topscore=0
  101.  
  102.                         if scores[1] then
  103.                             topscore = scores[1]:GetScore()
  104.                         end
  105.  
  106.                         self:diffuse(color("1,1,1,1"))
  107.                         self:strokecolor(color("0.2,0.2,0.2,1"))
  108.                         self:diffusealpha(1)
  109.                         self:shadowlength(2)
  110.  
  111.                         if topscore ~= 0  then
  112.                             local scorel3 = topscore%1000
  113.                             local scorel2 = (topscore/1000)%1000
  114.                             local scorel1 = (topscore/1000000)%1000000
  115.                             self:settextf("%01d"..",".."%03d"..",".."%03d",scorel1,scorel2,scorel3)
  116.                         end
  117.                     end
  118.                 end
  119.             end
  120.         },
  121.  
  122.  
  123.         --grade
  124.         Def.Quad{
  125.             InitCommand=cmd(zoom,0.3),
  126.             BeginCommand=cmd(playcommand,"Set"),
  127.             OffCommand=cmd(decelerate,0.05;diffusealpha,0;),
  128.             SetCommand=function(self)
  129.  
  130.                 local st=GAMESTATE:GetCurrentStyle():GetStepsType()
  131.                 local song=GAMESTATE:GetCurrentSong()
  132.                 local course = GAMESTATE:GetCurrentCourse()
  133.  
  134.                 if song then
  135.                     GetDifListX(self,128)
  136.                     self:y( (Difficulty:Reverse()[diff]+1) * 42 )
  137.  
  138.                     if song:HasStepsTypeAndDifficulty(st,diff) then
  139.  
  140.                         local steps = song:GetOneSteps( st, diff )
  141.  
  142.                         if PROFILEMAN:IsPersistentProfile(player) then
  143.                             profile = PROFILEMAN:GetProfile(player)
  144.                         else
  145.                             profile = PROFILEMAN:GetMachineProfile()
  146.                         end
  147.  
  148.                         scorelist = profile:GetHighScoreList(song,steps)
  149.                         local scores = scorelist:GetHighScores()
  150.  
  151.                         local topscore=0
  152.                         if scores[1] then
  153.                             topscore = scores[1]:GetScore()
  154.                         end
  155.  
  156.                         local topgrade
  157.                         if scores[1] then
  158.                             topgrade = scores[1]:GetGrade();
  159.                             assert(topgrade);
  160.                             if scores[1]:GetScore()>1  then
  161.                                 if scores[1]:GetScore()==1000000 and topgrade=="Grade_Tier07" then
  162.                                     self:LoadBackground(THEME:GetPathG("myMusicWheel","Tier01"));
  163.                                     self:diffusealpha(1);
  164.                                     self:addx(-60);
  165.                                 else
  166.                                     self:LoadBackground(THEME:GetPathG("myMusicWheel",ToEnumShortString(topgrade)));
  167.                                     self:diffusealpha(1);
  168.                                     self:addx(-60);
  169.                                 end;
  170.                             else
  171.                                 self:diffusealpha(0);
  172.                             end;
  173.                         else
  174.                             self:diffusealpha(0);
  175.                         end;
  176.                     else
  177.                         self:diffusealpha(0);
  178.                     end;
  179.                 else
  180.                     self:diffusealpha(0);
  181.                 end
  182.             end
  183.         };
  184.  
  185.  
  186.         --FC Ring
  187.         LoadActor(THEME:GetPathG("Player","Badge FullCombo"))..{
  188.             InitCommand=cmd(shadowlength,1;zoom,0;draworder,1);
  189.             BeginCommand=cmd(playcommand,"Set");
  190.             OffCommand=cmd(decelerate,0.05;diffusealpha,0;);
  191.             SetCommand=function(self)
  192.                 local st=GAMESTATE:GetCurrentStyle():GetStepsType();
  193.                 local song=GAMESTATE:GetCurrentSong();
  194.                 local course = GAMESTATE:GetCurrentCourse();
  195.             if song then
  196.                 GetDifListX(self, 110);
  197.                 self:y( (Difficulty:Reverse()[diff]+1) * 42 - 19 );
  198.                 if song:HasStepsTypeAndDifficulty(st,diff) then
  199.                     local steps = song:GetOneSteps( st, diff );
  200.                     if PROFILEMAN:IsPersistentProfile(player) then
  201.                         profile = PROFILEMAN:GetProfile(player);
  202.                     else
  203.                         profile = PROFILEMAN:GetMachineProfile();
  204.                     end;
  205.                     scorelist = profile:GetHighScoreList(song,steps);
  206.                     assert(scorelist);
  207.                     local scores = scorelist:GetHighScores();
  208.                     assert(scores);
  209.                     local topscore;
  210.                     if scores[1] then
  211.                         topscore = scores[1];
  212.                         assert(topscore);
  213.                         local misses = topscore:GetTapNoteScore("TapNoteScore_Miss")+topscore:GetTapNoteScore("TapNoteScore_CheckpointMiss")
  214.                         local boos = topscore:GetTapNoteScore("TapNoteScore_W5")
  215.                         local goods = topscore:GetTapNoteScore("TapNoteScore_W4")
  216.                         local greats = topscore:GetTapNoteScore("TapNoteScore_W3")
  217.                         local perfects = topscore:GetTapNoteScore("TapNoteScore_W2")
  218.                         local marvelous = topscore:GetTapNoteScore("TapNoteScore_W1")
  219.                         self:addx(-31);
  220.                         self:addy(13.5);
  221.                         if (misses+boos) == 0 and scores[1]:GetScore() > 0 and (marvelous+perfects)>0 then
  222.                             if (greats+perfects) == 0 then
  223.                                 self:diffuse(GameColor.Judgment["JudgmentLine_W1"]);
  224.                                 self:glowblink();
  225.                                 self:effectperiod(0.20);
  226.                                 self:zoom(0.25);
  227.                             elseif greats == 0 then
  228.                                 self:diffuse(GameColor.Judgment["JudgmentLine_W2"]);
  229.                                 self:glowshift();
  230.                                 self:zoom(0.25);
  231.                             elseif (misses+boos+goods) == 0 then
  232.                                 self:diffuse(GameColor.Judgment["JudgmentLine_W3"]);
  233.                                 self:stopeffect();
  234.                                 self:zoom(0.25);
  235.                             elseif (misses+boos) == 0 then
  236.                                 self:diffuse(GameColor.Judgment["JudgmentLine_W4"]);
  237.                                 self:stopeffect();
  238.                                 self:zoom(0.25);
  239.                             end;
  240.                             self:diffusealpha(0.8);
  241.                         else
  242.                             self:diffusealpha(0);
  243.                         end;
  244.                     else
  245.                         self:diffusealpha(0);
  246.                     end;
  247.                 else
  248.                     self:diffusealpha(0);
  249.                 end;
  250.             end;
  251.         end
  252.         }
  253.     }
  254.  
  255.     return DifficultyListItem
  256. end
  257.  
  258. local t = Def.ActorFrame {
  259.     CodeMessageCommand=function(self,params)
  260.         if params.PlayerNumber == player then
  261.             if params.Name == "OpenPanes1" and not ThisPlayerPaneIsOpen then
  262.                 self:diffusealpha(1)
  263.                 ThisPlayerPaneIsOpen = true
  264.             end
  265.            
  266.             if params.Name == "ClosePanes" then
  267.                 ThisPlayerPaneIsOpen = false
  268.                 self:diffusealpha(0)
  269.             end
  270.         end
  271.     end
  272.  
  273. }
  274.  
  275. if not GAMESTATE:IsCourseMode() then
  276.  
  277.     t[#t+1] = LoadActor("DiffFrame.png")..{
  278.         InitCommand=cmd(vertalign,top; zoom,0.7),
  279.         OnCommand=function(self)
  280.             GetDifListX(self, 35)
  281.             self:y(_screen.cy-220)
  282.         end,
  283.         OffCommand=cmd(sleep,0.15; linear,0.25; addx,-500)
  284.     }
  285.  
  286.     local difficulties = {"Beginner", "Easy", "Medium", "Hard", "Challenge", "Edit"}
  287.    
  288.     for difficulty in ivalues(difficulties) do
  289.         t[#t+1] = DrawDifListItem("Difficulty_" .. difficulty);
  290.     end
  291.  
  292.     t[#t+1]=Def.ActorFrame {
  293.         InitCommand=cmd(y, 157),
  294.         OffCommand=cmd(zoom,0),
  295.  
  296.         -- Cursor
  297.         Def.Quad{
  298.             InitCommand=function(self)
  299.                 GetDifListX(self, 54)
  300.                 self:zoomto(306, 35)
  301.             end,
  302.             ["CurrentSteps" .. ToEnumShortString(player) .. "ChangedMessageCommand"]=function(self)
  303.                 self:diffusealpha(0)
  304.                 self:finishtweening()
  305.                 self:diffusealpha(1)
  306.                
  307.                 -- FIXME: change these values to something you prefer
  308.                 self:glowshift()
  309.                 self:effectcolor1(color("#666666"))
  310.                 self:effectcolor2(color("#000000"))
  311.                 self:effectclock( "beat" )
  312.                
  313.                 local song=GAMESTATE:GetCurrentSong()
  314.                 if song then
  315.  
  316.                     local steps = GAMESTATE:GetCurrentSteps(player)
  317.                     if steps then
  318.  
  319.                         local diff = steps:GetDifficulty();
  320.                         local st=GAMESTATE:GetCurrentStyle():GetStepsType();
  321.  
  322.                         self:y( Difficulty:Reverse()[diff] * 42 )
  323.  
  324.                         -- What are you trying to do here?
  325.                         -- This will, as far I can see, always be nil (see below)
  326.                         -- local getsavediff = getenv("SaveDifficulty1P")
  327.                         -- if getsavediff then
  328.                         --  local zd = (getsavediff)
  329.                         --  self:diffuse(CustomDifficultyToColor(diff))
  330.                         --
  331.                         --  if song:HasStepsTypeAndDifficulty(st,"Difficulty_Edit") then
  332.                         --      self:addy(23*zd)
  333.                         --      self:linear(0.05)
  334.                         --      self:addy(-23*zd)
  335.                         --  else
  336.                         --      self:addy(26.5*zd)
  337.                         --      self:linear(0.05)
  338.                         --      self:addy(-26.5*zd)
  339.                         --  end
  340.                         -- end
  341.                         -- self:queuecommand("Save");
  342.                     end
  343.                 end
  344.                 end,
  345.             SaveCommand=function(self)             
  346.                 -- There's no need to make a custom function to interpret
  347.                 -- StepMania's enums.  The Reverse() method can be applied to any
  348.                 -- enum to do that for you.  That being said...
  349.                 --
  350.                 -- Whatever you're trying to do here, it'll always be nil because
  351.                 -- your "diff" variable is always nil...
  352.                 --
  353.                 -- I would help you more here, but I have no idea what you're attempting.
  354.                 -- So, to temporarily prevent errors, I'm just going to comment this out.
  355.                
  356.                 -- setenv("SaveDifficulty1P", Difficulty:Reverse()[diff]+1 );
  357.             end
  358.         }
  359.     }
  360.  
  361.     t[#t+1] = LoadActor("DiffTitles.png")..{
  362.         InitCommand=cmd(vertalign,top; zoom,0.7),
  363.         OnCommand=function(self)
  364.             GetDifListX(self, 35)
  365.             self:y(_screen.cy-220)
  366.         end,
  367.         OffCommand=cmd(sleep,0.15; linear,0.25; addx,-500)
  368.     }
  369. end
  370.  
  371. return t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement