Skip to content

Commit

Permalink
hand over control over target tracker goal to lua preferences and pro…
Browse files Browse the repository at this point in the history
…perly add interaction with the pb tracker
  • Loading branch information
MinaciousGrace committed Dec 19, 2016
1 parent bf8419a commit 9d65ca9
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ t[#t+1] = LoadActor("lanecover")
Point differential to AA.
]]

-- Clientside now. All we do is listen for broadcasts for values calculated by the game and then display them.
-- Mostly clientside now. We set our desired target goal and listen to the results rather than calculating ourselves.
local target = playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).TargetGoal
GAMESTATE:GetPlayerState(PLAYER_1):SetTargetGoal(target/100)

d = Def.ActorFrame{
Def.Quad{InitCommand=cmd(xy,60 + mpOffset,(SCREEN_HEIGHT*0.62)-90;zoomto,60,16;diffuse,color("0,0,0,0.4");horizalign,left;vertalign,top)},
-- Displays your current percentage score
Expand All @@ -117,32 +120,46 @@ d = Def.ActorFrame{
},
}

-- We can save space by wrapping the personal best and set percent trackers into one function, however
-- this would make the actor needlessly cumbersome and unnecessarily punish those who don't use the
-- personal best tracker (although everything is efficient enough now it probably wouldn't matter)
if playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).TargetTrackerMode == 0 then
d[#d+1] = LoadFont("Common Normal")..{
Name = "93% Differential",
Name = "Set Percent Differential",
InitCommand=cmd(xy,CenterX+26,SCREEN_CENTER_Y+30;zoom,0.4;halign,0;valign,1),
JudgmentMessageCommand=function(self,msg)
tDiff = msg.WifeDifferential
local tDiff = msg.WifeDifferential
if tDiff >= 0 then
diffuse(self,positive)
else
diffuse(self,negative)
end
self:settextf("%5.2f", tDiff)
self:settextf("%5.2f (%i%%)", tDiff, target)
end
}
else
d[#d+1] = LoadFont("Common Normal")..{
Name = "PB Differential",
InitCommand=cmd(xy,CenterX+26,SCREEN_CENTER_Y+30;zoom,0.4;halign,0;valign,1),
JudgmentMessageCommand=function(self,msg)
tDiff = msg.WifePBDifferential
if tDiff >= 0 then
diffuse(self,color("#00ff00"))
local tDiff = msg.WifePBDifferential
if tDiff then
local pbtarget = msg.WifePBGoal
if tDiff >= 0 then
diffuse(self,color("#00ff00"))
else
diffuse(self,negative)
end
self:settextf("%5.2f (%5.2f%%)", tDiff, pbtarget*100)
else
diffuse(self,negative)
end
self:settextf("%5.2f", tDiff)
tDiff = msg.WifeDifferential
if tDiff >= 0 then
diffuse(self,positive)
else
diffuse(self,negative)
end
self:settextf("%5.2f (%i%%)", tDiff, target)
end
end
}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,39 +156,39 @@ t[#t+1] = LoadFont("Common Normal")..{
}

-- Rescoring stuff
t[#t+1] = LoadFont("Common Normal")..{
Name="Score",
InitCommand=cmd(xy,frameX+offsetX+155,frameY+offsetY+14;zoom,0.5;halign,0),
SetCommand=function(self)
if score ~= nil then
if score:GetWifeScore() == 0 then
self:settextf("NA (%s)", "Wife")
else
self:settextf("%05.2f%% (%s)", notShit.floor(score:RescoreToWifeJudge(4)*10000)/100, "Wife J4")
end
else
self:settextf("00.00%% (%s)", "Wife")
end
end,
ScoreUpdateMessageCommand=cmd(queuecommand,"Set")
}
-- t[#t+1] = LoadFont("Common Normal")..{
-- Name="Score",
-- InitCommand=cmd(xy,frameX+offsetX+155,frameY+offsetY+14;zoom,0.5;halign,0),
-- SetCommand=function(self)
-- if score ~= nil then
-- if score:GetWifeScore() == 0 then
-- self:settextf("NA (%s)", "Wife")
-- else
-- self:settextf("%05.2f%% (%s)", notShit.floor(score:RescoreToWifeJudge(4)*10000)/100, "Wife J4")
-- end
-- else
-- self:settextf("00.00%% (%s)", "Wife")
-- end
-- end,
-- ScoreUpdateMessageCommand=cmd(queuecommand,"Set")
-- }

t[#t+1] = LoadFont("Common Normal")..{
Name="Score",
InitCommand=cmd(xy,frameX+offsetX+155,frameY+offsetY+28;zoom,0.5;halign,0),
SetCommand=function(self)
if score ~= nil then
if score:GetWifeScore() == 0 then
self:settextf("NA (%s)", "Wife")
else
self:settextf("%05.2f%% (%s)", notShit.floor(score:RescoreToDPJudge(4)*10000)/100, "DP J4")
end
else
self:settextf("00.00%% (%s)", "Wife")
end
end,
ScoreUpdateMessageCommand=cmd(queuecommand,"Set")
}
-- t[#t+1] = LoadFont("Common Normal")..{
-- Name="Score",
-- InitCommand=cmd(xy,frameX+offsetX+155,frameY+offsetY+28;zoom,0.5;halign,0),
-- SetCommand=function(self)
-- if score ~= nil then
-- if score:GetWifeScore() == 0 then
-- self:settextf("NA (%s)", "Wife")
-- else
-- self:settextf("%05.2f%% (%s)", notShit.floor(score:RescoreToDPJudge(4)*10000)/100, "DP J4")
-- end
-- else
-- self:settextf("00.00%% (%s)", "Wife")
-- end
-- end,
-- ScoreUpdateMessageCommand=cmd(queuecommand,"Set")
-- }

t[#t+1] = LoadFont("Common Normal")..{
Name="ClearType",
Expand Down
8 changes: 3 additions & 5 deletions Themes/Til Death/Languages/en.ini
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,12 @@ DivideByZero=DivideByZero (Noteskin)
2.4x=2.4x
2.5x=2.5x

93% = 93%
39% Mini= 39% Mini
40% Mini= 40% Mini
No Mini= No Mini
[OptionTitles]
ReceptorSize = Receptor Size
JudgeType=Judge Count
JudgmentText = Judgment Text
TargetTracker = Goal Tracker
TargetGoal = Tracker Goal
TargetTrackerMode = Tracker mode
JudgeCounter = Judge Counter
ErrorBar=Error Bar
Expand Down Expand Up @@ -128,7 +125,8 @@ ReceptorSize = Scale the size of the receptors and notes. This will also indirec
JudgeType = Set Judgecount Type.
JudgmentText = Show or hide text associated with judgments.
TargetTracker = Enable Goal Tracker. Displays the differential between your current score and 93% of the maximum score obtainable, or pits you against your personal best.
TargetTrackerMode = Toggle tracker mode between 93% and your personal best. If no PB is available it will default to 93%.
TargetGoal = Set the percentage goal for the target tracker.
TargetTrackerMode = Toggle tracker mode between a set percentage and your personal best. If no PB is available it will default to your set target goal.
JudgeCounter = Enable Judge Counter. Displays your currently obtained judgment counts. This has a moderate impact on performance. Expect about a 10% penalty to average fps.
ErrorBar = Enable Error Bar. Visual representation of your judgments' deviation from the intended mark. This is about as taxing as the judge counter performance-wise, though more useful.
ErrorBarLoc = Set the positioning of the error bar to center or bottom.
Expand Down
2 changes: 1 addition & 1 deletion Themes/Til Death/Scripts/01 player_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ local defaultConfig = {
JudgeType = 1,
AvgScoreType = 0,
GhostScoreType = 1,
GhostTarget = 93,
TargetTracker = true,
TargetGoal = 93,
TargetTrackerMode = 0,
JudgeCounter = true,
ErrorBar = true,
Expand Down
43 changes: 42 additions & 1 deletion Themes/Til Death/Scripts/02 ThemePrefs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,55 @@ function TargetTracker()
return t
end

local tChoices = {}
for i=1,99 do
tChoices[i] = tostring(i)..'%'
end
for i=1,3 do
tChoices[99+i] = tostring(99+i*0.25)..'%'
end
for i=1,4 do
tChoices[#tChoices+1] = tostring(99.96 + i*0.01)..'%'
end
function TargetGoal()
local t = {
Name = "TargetGoal",
LayoutType = "ShowAllInRow",
SelectType = "SelectOne",
OneChoiceForAllPlayers = false,
ExportOnChange = true,
Choices = tChoices,
LoadSelections = function(self, list, pn)
local prefs = playerConfig:get_data(pn_to_profile_slot(pn)).TargetGoal
list[prefs] = true
end,
SaveSelections = function(self, list, pn)
local found = false
for i=1,#list do
if not found then
if list[i] == true then
local value = i
playerConfig:get_data(pn_to_profile_slot(pn)).TargetGoal = value
found = true
end
end
end
playerConfig:set_dirty(pn_to_profile_slot(pn))
playerConfig:save(pn_to_profile_slot(pn))
end
}
setmetatable( t, t )
return t
end

function TargetTrackerMode()
local t = {
Name = "TargetTrackerMode",
LayoutType = "ShowAllInRow",
SelectType = "SelectOne",
OneChoiceForAllPlayers = false,
ExportOnChange = true,
Choices = { THEME:GetString('OptionNames','93%'),'PB'},
Choices = {'Set Percent','Personal Best'},
LoadSelections = function(self, list, pn)
local pref = playerConfig:get_data(pn_to_profile_slot(pn)).TargetTrackerMode
list[pref+1] = true
Expand Down
3 changes: 2 additions & 1 deletion Themes/Til Death/metrics.ini
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,11 @@ StepsTypeSetCommand=%function(self,param) \
end; \

[ScreenPlayerOptions]
LineNames="1,Rate,8,4,RS,14,5,7,10,13,JT,TT,TTM,JC,EB,PI,FB,MB,SF,LC,NPS,16,BG,Fail,Score"
LineNames="1,Rate,8,4,RS,14,5,7,10,13,JT,TT,TG,TTM,JC,EB,PI,FB,MB,SF,LC,NPS,16,BG,Fail,Score"
LineRS="lua,ReceptorSize()"
LineJT="lua,JudgmentText()"
LineTT="lua,TargetTracker()"
LineTG="lua,TargetGoal()"
LineTTM="lua,TargetTrackerMode()"
LineJC="lua,JudgeCounter()"
LineEB="lua,ErrorBar()"
Expand Down
26 changes: 18 additions & 8 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@ void Player::Load()
Profile *pProfile = PROFILEMAN->GetProfile(pn);
wifescorepersonalbest = pProfile->GetWifePBByKey(GAMESTATE->m_pCurSteps[pn]->GetChartKey());
if (wifescorepersonalbest == 0)
wifescorepersonalbest = 0.93f;

wifescorepersonalbest = m_pPlayerState->playertargetgoal;
if (m_pPlayerStageStats)
m_pPlayerStageStats->m_fTimingScale = m_fTimingWindowScale;

Expand Down Expand Up @@ -3144,9 +3144,12 @@ void Player::SetMineJudgment( TapNoteScore tns , int iTrack )
curwifescore -= 8.f;

msg.SetParam("WifePercent", 100 * curwifescore / maxwifescore);
msg.SetParam("WifeDifferential", curwifescore - maxwifescore*0.93f);
msg.SetParam("WifePBDifferential", curwifescore - maxwifescore*wifescorepersonalbest);
msg.SetParam("WifeDifferential", curwifescore - maxwifescore * m_pPlayerState->playertargetgoal);
msg.SetParam("TotalPercent", 100 * curwifescore / totalwifescore);
if (wifescorepersonalbest != m_pPlayerState->playertargetgoal) {
msg.SetParam("WifePBDifferential", curwifescore - maxwifescore * wifescorepersonalbest);
msg.SetParam("WifePBGoal", wifescorepersonalbest);
}
m_pPlayerStageStats->m_fWifeScore = curwifescore / totalwifescore;

MESSAGEMAN->Broadcast( msg );
Expand Down Expand Up @@ -3188,9 +3191,12 @@ void Player::SetJudgment( int iRow, int iTrack, const TapNote &tn, TapNoteScore

maxwifescore += 2;
msg.SetParam("WifePercent", 100*curwifescore/maxwifescore);
msg.SetParam("WifeDifferential", curwifescore - maxwifescore*0.93f);
msg.SetParam("WifePBDifferential", curwifescore - maxwifescore*wifescorepersonalbest);
msg.SetParam("WifeDifferential", curwifescore - maxwifescore * m_pPlayerState->playertargetgoal);
msg.SetParam("TotalPercent", 100 * curwifescore / totalwifescore);
if (wifescorepersonalbest != m_pPlayerState->playertargetgoal) {
msg.SetParam("WifePBDifferential", curwifescore - maxwifescore * wifescorepersonalbest);
msg.SetParam("WifePBGoal", wifescorepersonalbest);
}
if (m_pPlayerStageStats)
{
m_pPlayerStageStats->m_fWifeScore = curwifescore / totalwifescore;
Expand Down Expand Up @@ -3254,9 +3260,13 @@ void Player::SetHoldJudgment( TapNote &tn, int iTrack )
curwifescore -= 6.f;

msg.SetParam("WifePercent", 100 * curwifescore / maxwifescore);
msg.SetParam("WifeDifferential", curwifescore - maxwifescore*0.93f);
msg.SetParam("WifePBDifferential", curwifescore - maxwifescore*wifescorepersonalbest);
msg.SetParam("WifeDifferential", curwifescore - maxwifescore * m_pPlayerState->playertargetgoal);
msg.SetParam("TotalPercent", 100 * curwifescore / totalwifescore);
if (wifescorepersonalbest != m_pPlayerState->playertargetgoal) {
msg.SetParam("WifePBDifferential", curwifescore - maxwifescore * wifescorepersonalbest);
msg.SetParam("WifePBGoal", wifescorepersonalbest);
}

m_pPlayerStageStats->m_fWifeScore = curwifescore / totalwifescore;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class Player: public ActorFrame
void SetLife(float value);
bool m_inside_lua_set_life;

// Mina temp stuff
// Mina perma-temp stuff
vector<int> nerv; // the non empty row vector where we are somehwere in
size_t nervpos = 0; // where we are in the non-empty row vector
float maxwifescore = 0.0001f; // hurr /0 - Mina
Expand Down
5 changes: 5 additions & 0 deletions src/PlayerState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,10 @@ class LunaPlayerState: public Luna<PlayerState>
}
DEFINE_METHOD( GetHealthState, m_HealthState );
DEFINE_METHOD( GetSuperMeterLevel, m_fSuperMeter );
static int SetTargetGoal(T* p, lua_State *L) {
p->playertargetgoal = FArg(1);
return 1;
}

LunaPlayerState()
{
Expand All @@ -283,6 +287,7 @@ class LunaPlayerState: public Luna<PlayerState>
ADD_METHOD( GetSongPosition );
ADD_METHOD( GetHealthState );
ADD_METHOD( GetSuperMeterLevel );
ADD_METHOD( SetTargetGoal );
}
};

Expand Down
1 change: 1 addition & 0 deletions src/PlayerState.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class PlayerState

/* why is the slow getstyles function called every time to get
number of columns in places where it can't change? - Mina */
float playertargetgoal = 0.93f;
int m_NumCols;
void SetNumCols(int ncol) { m_NumCols = ncol; };
int GetNumCols() { return m_NumCols; };
Expand Down

0 comments on commit 9d65ca9

Please sign in to comment.