This commit is contained in:
Kyzentun
2014-09-14 21:07:54 -06:00
19 changed files with 1181 additions and 7 deletions
@@ -0,0 +1,172 @@
local cursor_width_padding = 16
local cursor_spacing_value = 30
local heart_xs= {
[PLAYER_1]= SCREEN_CENTER_X * 0.625,
[PLAYER_2]= SCREEN_CENTER_X * 1.375,
}
local heart_entries= {}
for i, pn in ipairs(GAMESTATE:GetEnabledPlayers()) do
local profile= PROFILEMAN:GetProfile(pn)
if profile and profile:GetIgnoreStepCountCalories() then
heart_entries[pn]= new_numpad_entry{
Name= pn .. "_heart_entry",
InitCommand= cmd(xy, heart_xs[pn], SCREEN_CENTER_Y+48),
value = LoadFont("Common Large") .. {
InitCommand=cmd(xy,0,-62),
OnCommand=cmd(zoom,0.75;diffuse,PlayerColor(pn);strokecolor,ColorDarkTone(PlayerColor(pn)));
SetCommand=function(self, param)
self:settext(param[1])
end,
},
button = LoadFont("Common Normal") ..{
InitCommand=cmd(shadowlength,1),
SetCommand=function(self, param)
self:settext(param[1])
end,
OnCommand=cmd(diffuse,color("0.8,0.8,0.8,1");zoom,0.875),
GainFocusCommand=cmd(finishtweening;decelerate,0.125;zoom,1;diffuse,Color.White),
LoseFocusCommand=cmd(finishtweening;smooth,0.1;zoom,0.875;diffuse,color("0.8,0.8,0.8,1"))
},
button_positions = {{-cursor_spacing_value, -cursor_spacing_value}, {0, -cursor_spacing_value}, {cursor_spacing_value, -cursor_spacing_value},
{-cursor_spacing_value, 0}, {0, 0}, {cursor_spacing_value, 0},
{-cursor_spacing_value, cursor_spacing_value}, {0, cursor_spacing_value}, {cursor_spacing_value, cursor_spacing_value},
{-cursor_spacing_value, cursor_spacing_value*2}, {0, cursor_spacing_value*2}, {cursor_spacing_value, cursor_spacing_value*2}},
cursor = Def.ActorFrame {
-- Move whole container
MoveCommand=function(self, param)
self:stoptweening()
self:decelerate(0.15)
self:xy(param[1], param[2])
if param[3] then
self:z(param[3])
end
end,
--
LoadActor( THEME:GetPathG("_frame", "1D"),
{ 2/18, 14/18, 2/18 },
LoadActor(THEME:GetPathB("_frame", "cursors/rounded fill"))
) .. {
OnCommand=cmd(diffuse,PlayerDarkColor(pn)),
FitCommand=function(self, param)
self:playcommand("SetSize",{ Width=param:GetWidth()+cursor_width_padding, tween=cmd(decelerate,0.125)})
end,
},
LoadActor( THEME:GetPathG("_frame", "1D"),
{ 2/18, 14/18, 2/18 },
LoadActor(THEME:GetPathB("_frame", "cursors/rounded gloss"))
) .. {
OnCommand=cmd(diffuse,PlayerColor(pn)),
FitCommand=function(self, param)
self:playcommand("SetSize",{ Width=param:GetWidth()+cursor_width_padding, tween=cmd(decelerate,0.125)})
end,
}
},
cursor_draw= "first",
prompt = LoadFont("Common Bold") .. {
Name="prompt",
Text=THEME:GetString("ScreenHeartEntry", "Heart Rate"),
InitCommand=cmd(xy,0,-96);
OnCommand=cmd(shadowlength,1;skewx,-0.125;diffusebottomedge,color("#DDDDDD");strokecolor,Color.Outline);
},
max_value= 300,
auto_done_value= 100,
}
end
end
local function input(event)
local pn= event.PlayerNumber
if not pn then return end
if event.type == "InputEventType_Release" then return end
if not heart_entries[pn] then return end
local done= heart_entries[pn]:handle_input(event.GameButton)
if done then
SOUND:PlayOnce(THEME:GetPathS("Common", "Start"))
local all_done= true
for pn, entry in pairs(heart_entries) do
if not entry.done then all_done= false break end
end
if all_done then
for pn, entry in pairs(heart_entries) do
local profile= PROFILEMAN:GetProfile(pn)
if profile and profile:GetIgnoreStepCountCalories() then
local calories= profile:CalculateCaloriesFromHeartRate(
entry.value, GAMESTATE:GetLastGameplayDuration())
profile:AddCaloriesToDailyTotal(calories)
end
end
SCREENMAN:GetTopScreen():StartTransitioningScreen("SM_GoToNextScreen")
end
end
end
local timer_text
local function timer_update(self)
local time= math.floor((self:GetSecsIntoEffect() % 60) * 10) / 10
if time < 10 then
timer_text:settext(("0%.1f"):format(time))
else
timer_text:settext(("%.1f"):format(time))
end
end
local args= {
--
Def.ActorFrame{
Name= "timer",
InitCommand= function(self)
self:effectperiod(2^16)
timer_text= self:GetChild("timer_text")
self:SetUpdateFunction(timer_update)
end,
OnCommand= function(self)
SCREENMAN:GetTopScreen():AddInputCallback(input)
end,
Def.BitmapText{
Name= "timer_text", Font= "Common Normal", Text= "00.0",
InitCommand= cmd(xy, SCREEN_CENTER_X, SCREEN_CENTER_Y-80; diffuse, Color.White),
OnCommand= cmd(strokecolor,Color.Outline),
}
},
Def.Quad {
InitCommand=cmd(xy, SCREEN_CENTER_X+1, SCREEN_CENTER_Y-100+1;zoomto,2,2);
OnCommand=cmd(diffuse,Color.Black;diffusealpha,0.5;linear,0.25;zoomtowidth,420;fadeleft,0.25;faderight,0.25);
};
Def.Quad {
InitCommand=cmd(xy, SCREEN_CENTER_X, SCREEN_CENTER_Y-100;zoomto,2,2);
OnCommand=cmd(diffuse,color("#ffd400");shadowcolor,BoostColor(color("#ffd40077"),0.25);linear,0.25;zoomtowidth,420;fadeleft,0.25;faderight,0.25);
};
Def.BitmapText {
Name= "explanation", Font= "Common Large",
Text= string.upper(THEME:GetString("ScreenHeartEntry", "Enter Heart Rate")),
InitCommand= cmd(xy, SCREEN_CENTER_X, SCREEN_CENTER_Y-128; diffuse, Color.White),
OnCommand=cmd(skewx,-0.125;diffuse,color("#ffd400");strokecolor,ColorDarkTone(color("#ffd400")))}
,
Def.BitmapText{
Name= "song_len_label", Font= "Common Normal",
Text= THEME:GetString("ScreenHeartEntry", "Song Length"),
InitCommand= cmd(xy, SCREEN_CENTER_X, SCREEN_CENTER_Y+192-32; diffuse, Color.White),
OnCommand= cmd(shadowlength,1)},
Def.BitmapText{
Name= "song_len", Font= "Common Normal",
Text= SecondsToMMSS(GAMESTATE:GetLastGameplayDuration()),
InitCommand= cmd(xy, SCREEN_CENTER_X, SCREEN_CENTER_Y+192-8; diffuse, Color.White),
OnCommand= cmd(shadowlength,1;zoom,0.75),
}
}
for pn in ivalues(GAMESTATE:GetEnabledPlayers()) do
args[#args+1] = LoadActor(THEME:GetPathB("_frame","3x3"),"rounded black", 128, 192) .. {
InitCommand=cmd(x,heart_xs[pn];y,SCREEN_CENTER_Y+28),
}
end
for pn, entry in pairs(heart_entries) do
args[#args+1]= entry:create_actors()
end
return Def.ActorFrame(args)
@@ -0,0 +1,260 @@
-- Pester Kyzentun for an explanation if you need to customize this screen.
-- Also, this might be rewritten to us a proper customizable lua menu system
-- in the future.
local profile= GAMESTATE:GetEditLocalProfile()
local cursor_width_padding = 16
local cursor_spacing_value = 30
local number_entry= new_numpad_entry{
Name= "number_entry",
InitCommand= cmd(diffusealpha, 0; xy, _screen.cx*1.5, _screen.cy),
value = LoadFont("Common Large") .. {
InitCommand=cmd(xy,0,-62),
OnCommand=cmd(zoom,0.75;diffuse,PlayerColor(PLAYER_1);strokecolor,ColorDarkTone(PlayerColor(PLAYER_1)));
SetCommand=function(self, param)
self:settext(param[1])
end,
},
button = LoadFont("Common Normal") ..{
InitCommand=cmd(shadowlength,1),
SetCommand=function(self, param)
self:settext(param[1])
end,
OnCommand=cmd(diffuse,color("0.8,0.8,0.8,1");zoom,0.875),
GainFocusCommand=cmd(finishtweening;decelerate,0.125;zoom,1;diffuse,Color.White),
LoseFocusCommand=cmd(finishtweening;smooth,0.1;zoom,0.875;diffuse,color("0.8,0.8,0.8,1"))
},
button_positions = {{-cursor_spacing_value, -cursor_spacing_value}, {0, -cursor_spacing_value}, {cursor_spacing_value, -cursor_spacing_value},
{-cursor_spacing_value, 0}, {0, 0}, {cursor_spacing_value, 0},
{-cursor_spacing_value, cursor_spacing_value}, {0, cursor_spacing_value}, {cursor_spacing_value, cursor_spacing_value},
{-cursor_spacing_value, cursor_spacing_value*2}, {0, cursor_spacing_value*2}, {cursor_spacing_value, cursor_spacing_value*2}},
cursor = Def.ActorFrame {
-- Move whole container
MoveCommand=function(self, param)
self:stoptweening()
self:decelerate(0.15)
self:xy(param[1], param[2])
if param[3] then
self:z(param[3])
end
end,
--
LoadActor( THEME:GetPathG("_frame", "1D"),
{ 2/18, 14/18, 2/18 },
LoadActor(THEME:GetPathB("_frame", "cursors/rounded fill"))
) .. {
OnCommand=cmd(diffuse,PlayerDarkColor(PLAYER_1)),
FitCommand=function(self, param)
self:playcommand("SetSize",{ Width=param:GetWidth()+cursor_width_padding, tween=cmd(decelerate,0.125)})
end,
},
LoadActor( THEME:GetPathG("_frame", "1D"),
{ 2/18, 14/18, 2/18 },
LoadActor(THEME:GetPathB("_frame", "cursors/rounded gloss"))
) .. {
OnCommand=cmd(diffuse,PlayerColor(PLAYER_1)),
FitCommand=function(self, param)
self:playcommand("SetSize",{ Width=param:GetWidth()+cursor_width_padding, tween=cmd(decelerate,0.125)})
end,
}
},
cursor_draw= "first",
prompt = LoadFont("Common Bold") .. {
Name="prompt",
InitCommand=cmd(xy,0,-96);
OnCommand=cmd(shadowlength,1;skewx,-0.125;diffusebottomedge,color("#DDDDDD");strokecolor,Color.Outline);
SetCommand= function(self, params)
self:settext(params[1])
end
},
LoadActor(THEME:GetPathB("_frame","3x3"),"rounded black", 128, 192) .. {
InitCommand=cmd(xy, 0, -20)
}
}
local function item_value_to_text(item, value)
if item.item_type == "bool" then
if value then
value= THEME:GetString("ScreenOptionsCustomizeProfile", item.true_text)
else
value= THEME:GetString("ScreenOptionsCustomizeProfile", item.false_text)
end
end
return value
end
local menu_items= {
{name= "weight", get= "GetWeightPounds", set= "SetWeightPounds",
item_type= "number", auto_done= 100},
{name= "voomax", get= "GetVoomax", set= "SetVoomax", item_type= "number",
auto_done= 10},
{name= "birth_year", get= "GetBirthYear", set= "SetBirthYear",
item_type= "number", auto_done= 1000},
{name= "calorie_calc", get= "GetIgnoreStepCountCalories",
set= "SetIgnoreStepCountCalories", item_type= "bool",
true_text= "use_heart", false_text= "use_steps"},
{name= "gender", get= "GetIsMale", set= "SetIsMale", item_type= "bool",
true_text= "male", false_text= "female"},
{name= "exit", item_type= "exit"}
}
local menu_cursor
local menu_pos= 1
local menu_start= 72
local menu_x= 32
local value_x= 300
local fader
local cursor_on_menu= true
local menu_item_actors= {}
local menu_values= {}
local function fade_actor_to(actor, alf)
actor:stoptweening()
actor:linear(.2)
actor:diffusealpha(alf)
end
local function update_menu_cursor()
local item= menu_item_actors[menu_pos]
menu_cursor:playcommand("Move", {item:GetX(), item:GetY()})
menu_cursor:playcommand("Fit", item)
end
local function input(event)
local pn= event.PlayerNumber
if not pn then return false end
if event.type == "InputEventType_Release" then return false end
local button= event.GameButton
if cursor_on_menu then
if button == "Start" then
local item= menu_items[menu_pos]
if item.item_type == "bool" then
local value= not Profile[item.get](profile)
menu_values[menu_pos]:settext(item_value_to_text(item, value))
Profile[item.set](profile, value)
elseif item.item_type == "number" then
fade_actor_to(fader, .8)
fade_actor_to(number_entry.container, 1)
number_entry.value= Profile[item.get](profile)
number_entry.value_actor:playcommand("Set", {number_entry.value})
number_entry.auto_done_value= item.auto_done
number_entry.max_value= item.max
number_entry:update_cursor(number_entry.cursor_start)
number_entry.prompt_actor:playcommand(
"Set", {THEME:GetString("ScreenOptionsCustomizeProfile", item.name)})
cursor_on_menu= false
elseif item.item_type == "exit" then
SCREENMAN:GetTopScreen():StartTransitioningScreen("SM_GoToNextScreen")
SOUND:PlayOnce(THEME:GetPathS("Common", "Start"))
end
else
if button == "MenuLeft" or button == "MenuUp" then
if menu_pos > 1 then menu_pos= menu_pos - 1 end
update_menu_cursor()
elseif button == "MenuRight" or button == "MenuDown" then
if menu_pos < #menu_items then menu_pos= menu_pos + 1 end
update_menu_cursor()
end
end
else
local done= number_entry:handle_input(button)
if done then
local item= menu_items[menu_pos]
Profile[item.set](profile, number_entry.value)
menu_values[menu_pos]:settext(item_value_to_text(item, number_entry.value))
fade_actor_to(fader, 0)
fade_actor_to(number_entry.container, 0)
cursor_on_menu= true
end
end
end
local args= {
Def.Actor{
OnCommand= function(self)
update_menu_cursor()
SCREENMAN:GetTopScreen():AddInputCallback(input)
end
},
Def.ActorFrame {
Name= "menu_cursor", InitCommand= function(self)
menu_cursor= self
end,
-- Move whole container
MoveCommand=function(self, param)
self:stoptweening()
self:decelerate(0.15)
self:xy(param[1], param[2])
if param[3] then
self:z(param[3])
end
end,
FitCommand= function(self, param)
self:addx(param:GetWidth()/2)
end,
--
LoadActor( THEME:GetPathG("_frame", "1D"),
{ 2/18, 14/18, 2/18 },
LoadActor(THEME:GetPathB("_frame", "cursors/rounded fill"))
) .. {
OnCommand=cmd(diffuse,PlayerDarkColor(PLAYER_1)),
FitCommand=function(self, param)
self:playcommand("SetSize",{ Width=param:GetWidth()+cursor_width_padding, tween=cmd(decelerate,0.125)})
end,
},
LoadActor( THEME:GetPathG("_frame", "1D"),
{ 2/18, 14/18, 2/18 },
LoadActor(THEME:GetPathB("_frame", "cursors/rounded gloss"))
) .. {
OnCommand=cmd(diffuse,PlayerColor(PLAYER_1)),
FitCommand=function(self, param)
self:playcommand("SetSize",{ Width=param:GetWidth()+cursor_width_padding, tween=cmd(decelerate,0.125)})
end,
}
},
}
for i, item in ipairs(menu_items) do
local item_y= menu_start + ((i-1) * 24)
args[#args+1]= Def.BitmapText{
Name= "menu_" .. item.name, Font= "Common Normal",
Text= THEME:GetString("ScreenOptionsCustomizeProfile", item.name),
InitCommand= function(self)
menu_item_actors[i]= self
self:xy(menu_x, item_y)
self:diffuse(Color.White)
self:horizalign(left)
end
}
if item.get then
local value_text= item_value_to_text(item, Profile[item.get](profile))
args[#args+1]= Def.BitmapText{
Name= "value_" .. item.name, Font= "Common Normal",
Text= value_text,
InitCommand= function(self)
menu_values[i]= self
self:xy(value_x, menu_start + ((i-1) * 24))
self:diffuse(Color.White)
self:horizalign(left)
end
}
end
end
args[#args+1]= Def.Quad{
Name= "fader", InitCommand= function(self)
fader= self
self:setsize(270, #menu_items * 24)
self:horizalign(left)
self:vertalign(top)
self:xy(menu_x-10, menu_start-12)
self:diffuse(Color.Black)
self:diffusealpha(0)
end
}
args[#args+1]= number_entry:create_actors()
return Def.ActorFrame(args)
Binary file not shown.

After

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

@@ -36,8 +36,8 @@ t[#t+1] = LoadFont("Common Bold") .. {
t[#t+1] = Def.Quad {
Name="Underline";
InitCommand=cmd(x,-SCREEN_CENTER_X+24;y,36;horizalign,left);
OnCommand=cmd(visible,IsVisible();diffuse,color("#ffd400");shadowlength,1;linear,0.25;zoomtowidth,192;faderight,0.5);
InitCommand=cmd(x,-SCREEN_CENTER_X+24-4;y,36;horizalign,left);
OnCommand=cmd(diffuse,color("#ffd400");shadowlength,2;shadowcolor,BoostColor(color("#ffd40077"),0.25);linear,0.25;zoomtowidth,192;fadeleft,8/192;faderight,0.5);
};
t[#t+1] = LoadFont("Common Bold") .. {
@@ -54,5 +54,4 @@ t.BeginCommand=function(self)
self:SetUpdateFunction( Update );
end
return t
+5
View File
@@ -85,6 +85,11 @@ HelpText=
[ScreenGameplay]
HelpText=
[ScreenHeartEntry]
Enter Heart Rate=Enter Heart Rate
Song Length=Song Length
Heart Rate=Heart Rate
[ScreenEvaluation]
HelpText=&BACK; Exit &START; Move On &MENULEFT;+&MENURIGHT; or &SELECT; Snapshot
LifeDifficulty=Life Difficulty: %s
+5
View File
@@ -1628,6 +1628,11 @@ ActiveAttackListP2OffCommand=
[ScreenGameplayShared]
[ScreenHeartEntry]
HeartEntryEnabled=true
ShowHeader=true
ShowFooter=true
[ScreenEvaluation]
Class="ScreenEvaluation"
Fallback="ScreenWithMenuElements"