349 lines
10 KiB
Lua
349 lines
10 KiB
Lua
local t = LoadFallbackB();
|
|
|
|
-- Legacy StepMania 4 Function
|
|
local function StepsDisplay(pn)
|
|
local function set(self, player)
|
|
self:SetFromGameState( player );
|
|
end
|
|
|
|
local t = Def.StepsDisplay {
|
|
InitCommand=function(self)
|
|
self:Load("StepsDisplay", GAMESTATE:GetPlayerState(pn));
|
|
end;
|
|
};
|
|
|
|
if pn == PLAYER_1 then
|
|
t.CurrentStepsP1ChangedMessageCommand=function(self) set(self, pn); end;
|
|
t.CurrentTrailP1ChangedMessageCommand=function(self) set(self, pn); end;
|
|
else
|
|
t.CurrentStepsP2ChangedMessageCommand=function(self) set(self, pn); end;
|
|
t.CurrentTrailP2ChangedMessageCommand=function(self) set(self, pn); end;
|
|
end
|
|
|
|
return t;
|
|
end
|
|
t[#t+1] = StandardDecorationFromFileOptional("AlternateHelpDisplay","AlternateHelpDisplay");
|
|
|
|
local function PercentScore(pn)
|
|
local t = LoadFont("Common normal")..{
|
|
InitCommand=function(self)
|
|
self:zoom(0.625);
|
|
self:shadowlength(1);
|
|
end;
|
|
BeginCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
SetCommand=function(self)
|
|
local SongOrCourse, StepsOrTrail;
|
|
if GAMESTATE:IsCourseMode() then
|
|
SongOrCourse = GAMESTATE:GetCurrentCourse();
|
|
StepsOrTrail = GAMESTATE:GetCurrentTrail(pn);
|
|
else
|
|
SongOrCourse = GAMESTATE:GetCurrentSong();
|
|
StepsOrTrail = GAMESTATE:GetCurrentSteps(pn);
|
|
end;
|
|
|
|
local profile, scorelist;
|
|
local text = "";
|
|
if SongOrCourse and StepsOrTrail then
|
|
local st = StepsOrTrail:GetStepsType();
|
|
local diff = StepsOrTrail:GetDifficulty();
|
|
local courseType = GAMESTATE:IsCourseMode() and SongOrCourse:GetCourseType() or nil;
|
|
local cd = GetCustomDifficulty(st, diff, courseType);
|
|
self:diffuse(CustomDifficultyToColor(cd));
|
|
self:shadowcolor(CustomDifficultyToDarkColor(cd));
|
|
|
|
if PROFILEMAN:IsPersistentProfile(pn) then
|
|
-- player profile
|
|
profile = PROFILEMAN:GetProfile(pn);
|
|
else
|
|
-- machine profile
|
|
profile = PROFILEMAN:GetMachineProfile();
|
|
end;
|
|
|
|
scorelist = profile:GetHighScoreList(SongOrCourse,StepsOrTrail);
|
|
assert(scorelist)
|
|
local scores = scorelist:GetHighScores();
|
|
local topscore = scores[1];
|
|
if topscore then
|
|
text = string.format("%.2f%%", topscore:GetPercentDP()*100.0);
|
|
-- 100% hack
|
|
if text == "100.00%" then
|
|
text = "100%";
|
|
end;
|
|
else
|
|
text = string.format("%.2f%%", 0);
|
|
end;
|
|
else
|
|
text = "";
|
|
end;
|
|
self:settext(text);
|
|
end;
|
|
CurrentSongChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
CurrentCourseChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
};
|
|
|
|
if pn == PLAYER_1 then
|
|
t.CurrentStepsP1ChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
t.CurrentTrailP1ChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
else
|
|
t.CurrentStepsP2ChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
t.CurrentTrailP2ChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
end
|
|
|
|
return t;
|
|
end
|
|
|
|
-- Legacy StepMania 4 Function
|
|
for pn in ivalues(PlayerNumber) do
|
|
local MetricsName = "StepsDisplay" .. PlayerNumberToString(pn);
|
|
t[#t+1] = StepsDisplay(pn) .. {
|
|
InitCommand=function(self) self:player(pn); self:name(MetricsName); ActorUtil.LoadAllCommandsAndSetXY(self,Var "LoadingScreen"); end;
|
|
PlayerJoinedMessageCommand=function(self, params)
|
|
if params.Player == pn then
|
|
self:visible(true);
|
|
self:zoom(0);
|
|
self:bounceend(0.3);
|
|
self:zoom(1);
|
|
end;
|
|
end;
|
|
PlayerUnjoinedMessageCommand=function(self, params)
|
|
if params.Player == pn then
|
|
self:visible(true);
|
|
self:bouncebegin(0.3);
|
|
self:zoom(0);
|
|
end;
|
|
end;
|
|
};
|
|
if ShowStandardDecoration("PercentScore"..ToEnumShortString(pn)) then
|
|
t[#t+1] = StandardDecorationFromTable("PercentScore"..ToEnumShortString(pn), PercentScore(pn));
|
|
end;
|
|
end
|
|
|
|
t[#t+1] = StandardDecorationFromFileOptional("BannerFrame","BannerFrame");
|
|
t[#t+1] = StandardDecorationFromFileOptional("PaneDisplayFrameP1","PaneDisplayFrame");
|
|
t[#t+1] = StandardDecorationFromFileOptional("PaneDisplayFrameP2","PaneDisplayFrame");
|
|
t[#t+1] = StandardDecorationFromFileOptional("PaneDisplayTextP1","PaneDisplayTextP1");
|
|
t[#t+1] = StandardDecorationFromFileOptional("PaneDisplayTextP2","PaneDisplayTextP2");
|
|
t[#t+1] = StandardDecorationFromFileOptional("DifficultyList","DifficultyList");
|
|
t[#t+1] = StandardDecorationFromFileOptional("CourseContentsList","CourseContentsList");
|
|
t[#t+1] = StandardDecorationFromFileOptional("BPMDisplay","BPMDisplay");
|
|
t[#t+1] = StandardDecorationFromFileOptional("BPMLabel","BPMLabel");
|
|
t[#t+1] = StandardDecorationFromFileOptional("SegmentDisplay","SegmentDisplay");
|
|
--[[ t[#t+1] = StandardDecorationFromFileOptional("NegativeDisplay","NegativeDisplay") .. {
|
|
}; --]]
|
|
|
|
t[#t+1] = StandardDecorationFromFileOptional("SongTime","SongTime") .. {
|
|
SetCommand=function(self)
|
|
local curSelection = nil;
|
|
local length = 0.0;
|
|
if GAMESTATE:IsCourseMode() then
|
|
curSelection = GAMESTATE:GetCurrentCourse();
|
|
self:playcommand("Reset");
|
|
if curSelection then
|
|
local trail = GAMESTATE:GetCurrentTrail(GAMESTATE:GetMasterPlayerNumber());
|
|
if trail then
|
|
length = TrailUtil.GetTotalSeconds(trail);
|
|
else
|
|
length = 0.0;
|
|
end;
|
|
else
|
|
length = 0.0;
|
|
end;
|
|
else
|
|
curSelection = GAMESTATE:GetCurrentSong();
|
|
self:playcommand("Reset");
|
|
if curSelection then
|
|
length = curSelection:MusicLengthSeconds();
|
|
if curSelection:IsLong() then
|
|
self:playcommand("Long");
|
|
elseif curSelection:IsMarathon() then
|
|
self:playcommand("Marathon");
|
|
else
|
|
self:playcommand("Reset");
|
|
end
|
|
else
|
|
length = 0.0;
|
|
self:playcommand("Reset");
|
|
end;
|
|
end;
|
|
self:settext( SecondsToMSS(length) );
|
|
end;
|
|
CurrentSongChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
CurrentCourseChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
CurrentTrailP1ChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
CurrentTrailP2ChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
}
|
|
|
|
if not GAMESTATE:IsCourseMode() then
|
|
local function CDTitleUpdate(self)
|
|
local song = GAMESTATE:GetCurrentSong();
|
|
local cdtitle = self:GetChild("CDTitle");
|
|
local height = cdtitle:GetHeight();
|
|
local width = cdtitle:GetWidth();
|
|
|
|
if song then
|
|
if song:HasCDTitle() then
|
|
cdtitle:visible(true);
|
|
cdtitle:Load(song:GetCDTitlePath());
|
|
else
|
|
cdtitle:visible(false);
|
|
end;
|
|
else
|
|
cdtitle:visible(false);
|
|
end;
|
|
|
|
if height >= 60 and width >= 80 then
|
|
if height*(80/60) >= width then
|
|
cdtitle:zoom(60/height);
|
|
else
|
|
cdtitle:zoom(80/width);
|
|
end;
|
|
elseif height >= 60 then
|
|
cdtitle:zoom(60/height);
|
|
elseif width >= 80 then
|
|
cdtitle:zoom(80/width);
|
|
else
|
|
cdtitle:zoom(1);
|
|
end;
|
|
end;
|
|
t[#t+1] = Def.ActorFrame {
|
|
OnCommand=function(self)
|
|
self:draworder(105);
|
|
self:x(SCREEN_CENTER_X-76);
|
|
self:y(SCREEN_CENTER_Y-72);
|
|
self:zoomy(0);
|
|
self:sleep(0.5);
|
|
self:decelerate(0.25);
|
|
self:zoomy(1);
|
|
self:SetUpdateFunction(CDTitleUpdate);
|
|
end;
|
|
OffCommand=function(self)
|
|
self:bouncebegin(0.15);
|
|
self:zoomx(0);
|
|
end;
|
|
Def.Sprite {
|
|
Name="CDTitle";
|
|
InitCommand=function(self)
|
|
self:y(19);
|
|
end;
|
|
};
|
|
};
|
|
t[#t+1] = StandardDecorationFromFileOptional("NewSong","NewSong") .. {
|
|
InitCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
BeginCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
CurrentSongChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
SetCommand=function(self)
|
|
-- local pTargetProfile;
|
|
local sSong;
|
|
-- Start!
|
|
if GAMESTATE:GetCurrentSong() then
|
|
if PROFILEMAN:IsSongNew(GAMESTATE:GetCurrentSong()) then
|
|
self:playcommand("Show");
|
|
else
|
|
self:playcommand("Hide");
|
|
end
|
|
else
|
|
self:playcommand("Hide");
|
|
end
|
|
end;
|
|
};
|
|
t[#t+1] = StandardDecorationFromFileOptional("StageDisplay","StageDisplay");
|
|
end;
|
|
|
|
if GAMESTATE:IsCourseMode() then
|
|
t[#t+1] = StandardDecorationFromFileOptional("NumCourseSongs","NumCourseSongs")..{
|
|
InitCommand=function(self)
|
|
self:horizalign(right);
|
|
end;
|
|
SetCommand=function(self)
|
|
local curSelection= nil;
|
|
local sAppend = "";
|
|
if GAMESTATE:IsCourseMode() then
|
|
curSelection = GAMESTATE:GetCurrentCourse();
|
|
if curSelection then
|
|
sAppend = (curSelection:GetEstimatedNumStages() == 1) and "Stage" or "Stages";
|
|
self:visible(true);
|
|
self:settext( curSelection:GetEstimatedNumStages() .. " " .. sAppend);
|
|
else
|
|
self:visible(false);
|
|
end;
|
|
else
|
|
self:visible(false);
|
|
end;
|
|
end;
|
|
CurrentCourseChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
};
|
|
end
|
|
|
|
t[#t+1] = StandardDecorationFromFileOptional("DifficultyDisplay","DifficultyDisplay");
|
|
t[#t+1] = StandardDecorationFromFileOptional("SortOrderFrame","SortOrderFrame") .. {
|
|
|
|
};
|
|
t[#t+1] = StandardDecorationFromFileOptional("SortOrder","SortOrderText") .. {
|
|
BeginCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
SortOrderChangedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
SetCommand=function(self)
|
|
local s = SortOrderToLocalizedString( GAMESTATE:GetSortOrder() );
|
|
self:settext( s );
|
|
self:playcommand("Sort");
|
|
end;
|
|
};
|
|
t[#t+1] = StandardDecorationFromFileOptional("SongOptionsFrame","SongOptionsFrame") .. {
|
|
ShowPressStartForOptionsCommand=THEME:GetMetric(Var "LoadingScreen","SongOptionsFrameShowCommand");
|
|
ShowEnteringOptionsCommand=THEME:GetMetric(Var "LoadingScreen","SongOptionsFrameEnterCommand");
|
|
HidePressStartForOptionsCommand=THEME:GetMetric(Var "LoadingScreen","SongOptionsFrameHideCommand");
|
|
};
|
|
t[#t+1] = StandardDecorationFromFileOptional("SongOptions","SongOptionsText") .. {
|
|
ShowPressStartForOptionsCommand=THEME:GetMetric(Var "LoadingScreen","SongOptionsShowCommand");
|
|
ShowEnteringOptionsCommand=THEME:GetMetric(Var "LoadingScreen","SongOptionsEnterCommand");
|
|
HidePressStartForOptionsCommand=THEME:GetMetric(Var "LoadingScreen","SongOptionsHideCommand");
|
|
};
|
|
-- Sounds
|
|
t[#t+1] = Def.ActorFrame {
|
|
LoadActor(THEME:GetPathS("_switch","up")) .. {
|
|
SelectMenuOpenedMessageCommand=function(self)
|
|
self:playcommand("Set");
|
|
end;
|
|
};
|
|
LoadActor(THEME:GetPathS("_switch","down")) .. {
|
|
SelectMenuClosedMessageCommand=function(self)
|
|
self:stop();
|
|
self:play();
|
|
end;
|
|
};
|
|
};
|
|
|
|
return t |