do some combo stuff in lua
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1,63 @@
|
||||
local c;
|
||||
local player = Var "Player";
|
||||
local ShowComboAt = THEME:GetMetric("Combo", "ShowComboAt");
|
||||
local Pulse = THEME:GetMetric("Combo", "PulseCommand");
|
||||
|
||||
local NumberMinZoom = THEME:GetMetric("Combo", "NumberMinZoom");
|
||||
local NumberMaxZoom = THEME:GetMetric("Combo", "NumberMaxZoom");
|
||||
local NumberMaxZoomAt = THEME:GetMetric("Combo", "NumberMaxZoomAt");
|
||||
|
||||
local t = {
|
||||
LoadFont( "Combo", "numbers" ) .. {
|
||||
Name="Number";
|
||||
OnCommand = THEME:GetMetric("Combo", "NumberOnCommand");
|
||||
};
|
||||
LoadActor("_combo") .. {
|
||||
Name="ComboLabel";
|
||||
OnCommand = THEME:GetMetric("Combo", "LabelOnCommand");
|
||||
};
|
||||
LoadActor("_misses") .. {
|
||||
Name="MissesLabel";
|
||||
OnCommand = THEME:GetMetric("Combo", "LabelOnCommand");
|
||||
};
|
||||
};
|
||||
|
||||
return Def.ActorFrame {
|
||||
children = t;
|
||||
InitCommand = function(self)
|
||||
c = self:GetChildren();
|
||||
c.Number:visible(false);
|
||||
c.ComboLabel:visible(false);
|
||||
c.MissesLabel:visible(false);
|
||||
end;
|
||||
|
||||
ComboCommand=function(self, param)
|
||||
--[[ param.Misses = nil;
|
||||
param.Combo = 123;
|
||||
]] local iCombo = param.Misses or param.Combo;
|
||||
if not iCombo or iCombo < ShowComboAt then
|
||||
c.Number:visible(false);
|
||||
c.ComboLabel:visible(false);
|
||||
c.MissesLabel:visible(false);
|
||||
return;
|
||||
end
|
||||
|
||||
local Label;
|
||||
if param.Combo then
|
||||
Label = c.ComboLabel;
|
||||
else
|
||||
Label = c.MissesLabel;
|
||||
end
|
||||
|
||||
param.Zoom = scale( iCombo, 0, NumberMaxZoomAt, NumberMinZoom, NumberMaxZoom );
|
||||
param.Zoom = clamp( param.Zoom, NumberMinZoom, NumberMaxZoom );
|
||||
|
||||
c.Number:visible(true);
|
||||
Label:visible(true);
|
||||
|
||||
c.Number:settext( string.format("%i", iCombo) );
|
||||
|
||||
Pulse( c.Number, param );
|
||||
Pulse( Label, param );
|
||||
end;
|
||||
};
|
||||
@@ -2484,12 +2484,7 @@ NumberOnCommand=y,SCREEN_CENTER_Y-216;shadowlength,0;HorizAlign,right;VertAlign,
|
||||
NumberMinZoom=1
|
||||
NumberMaxZoom=1
|
||||
NumberMaxZoomAt=2
|
||||
PulseCommand=%function(self) local origZoom=self:GetZoom(); self:zoom(1.2*origZoom); self:linear(0.05); self:zoom(origZoom); end
|
||||
FullComboW3Command=
|
||||
FullComboW2Command=
|
||||
FullComboW1Command=
|
||||
FullComboBrokenCommand=
|
||||
MissComboCommand=%function(self) local origZoom=self:GetZoom(); self:zoom(1.2*origZoom); self:linear(0.05); self:zoom(origZoom); end
|
||||
PulseCommand=%function(self,param) self:stoptweening(); self:zoom(1.2*param.Zoom); self:linear(0.05); self:zoom(param.Zoom); end
|
||||
|
||||
[Player]
|
||||
ReceptorArrowsYStandard=-144
|
||||
|
||||
+17
-105
@@ -5,7 +5,6 @@
|
||||
#include "GameState.h"
|
||||
#include "song.h"
|
||||
#include "PlayerState.h"
|
||||
#include "ActorUtil.h"
|
||||
|
||||
Combo::Combo()
|
||||
{
|
||||
@@ -16,66 +15,20 @@ Combo::Combo()
|
||||
this->SubscribeToMessage( Message_BeatCrossed );
|
||||
}
|
||||
|
||||
void Combo::Load( const PlayerState *pPlayerState, const PlayerStageStats *pPlayerStageStats )
|
||||
void Combo::Load( const RString &sPath, const PlayerState *pPlayerState, const PlayerStageStats *pPlayerStageStats )
|
||||
{
|
||||
ASSERT( m_SubActors.empty() ); // don't load twice
|
||||
|
||||
m_pPlayerState = pPlayerState;
|
||||
m_pPlayerStageStats = pPlayerStageStats;
|
||||
|
||||
SHOW_COMBO_AT .Load(m_sName,"ShowComboAt");
|
||||
NUMBER_MIN_ZOOM .Load(m_sName,"NumberMinZoom");
|
||||
NUMBER_MAX_ZOOM .Load(m_sName,"NumberMaxZoom");
|
||||
NUMBER_MAX_ZOOM_AT .Load(m_sName,"NumberMaxZoomAt");
|
||||
PULSE_COMMAND .Load(m_sName,"PulseCommand");
|
||||
FULL_COMBO_W3_COMMAND .Load(m_sName,"FullComboW3Command");
|
||||
FULL_COMBO_W2_COMMAND .Load(m_sName,"FullComboW2Command");
|
||||
FULL_COMBO_W1_COMMAND .Load(m_sName,"FullComboW1Command");
|
||||
FULL_COMBO_BROKEN_COMMAND .Load(m_sName,"FullComboBrokenCommand");
|
||||
MISS_COMBO_COMMAND .Load(m_sName,"MissComboCommand");
|
||||
|
||||
m_spr100Milestone.Load( THEME->GetPathG(m_sName,"100milestone") );
|
||||
this->AddChild( m_spr100Milestone );
|
||||
|
||||
m_spr1000Milestone.Load( THEME->GetPathG(m_sName,"1000milestone") );
|
||||
this->AddChild( m_spr1000Milestone );
|
||||
|
||||
m_sprComboLabel.Load( THEME->GetPathG(m_sName,"label") );
|
||||
m_sprComboLabel->SetName( "Label" );
|
||||
m_sprComboLabel->SetVisible( false );
|
||||
LOAD_ALL_COMMANDS( m_sprComboLabel );
|
||||
LuaThreadVariable var( "Player", LuaReference::Create(m_pPlayerState->m_PlayerNumber) );
|
||||
m_sprComboLabel.Load( sPath );
|
||||
this->AddChild( m_sprComboLabel );
|
||||
m_sprComboLabel->PlayCommand( "On" );
|
||||
|
||||
m_sprMissesLabel.Load( THEME->GetPathG(m_sName,"misses") );
|
||||
m_sprMissesLabel->SetName( "Label" );
|
||||
m_sprMissesLabel->SetVisible( false );
|
||||
LOAD_ALL_COMMANDS( m_sprMissesLabel );
|
||||
this->AddChild( m_sprMissesLabel );
|
||||
m_sprMissesLabel->PlayCommand( "On" );
|
||||
|
||||
m_textNumber.LoadFromFont( THEME->GetPathF(m_sName,"numbers") );
|
||||
m_textNumber.SetName( "Number" );
|
||||
m_textNumber.SetVisible( false );
|
||||
LOAD_ALL_COMMANDS( m_textNumber );
|
||||
this->AddChild( &m_textNumber );
|
||||
m_textNumber.PlayCommand( "On" );
|
||||
}
|
||||
|
||||
void Combo::SetCombo( int iCombo, int iMisses )
|
||||
{
|
||||
bool bComboOfMisses = iMisses > 0;
|
||||
int iNum = bComboOfMisses ? iMisses : iCombo;
|
||||
bool bShowCombo = iNum >= (int)SHOW_COMBO_AT;
|
||||
|
||||
if( !bShowCombo )
|
||||
{
|
||||
m_sprComboLabel->SetVisible( false );
|
||||
m_sprMissesLabel->SetVisible( false );
|
||||
m_textNumber.SetVisible( false );
|
||||
return;
|
||||
}
|
||||
|
||||
if( m_iLastSeenCombo == -1 ) // first update, don't set bIsMilestone=true
|
||||
m_iLastSeenCombo = iCombo;
|
||||
|
||||
@@ -90,68 +43,27 @@ void Combo::SetCombo( int iCombo, int iMisses )
|
||||
}
|
||||
m_iLastSeenCombo = iCombo;
|
||||
|
||||
m_sprComboLabel->SetVisible( !bComboOfMisses );
|
||||
m_sprMissesLabel->SetVisible( bComboOfMisses );
|
||||
m_textNumber.SetVisible( true );
|
||||
|
||||
RString txt = ssprintf("%d", iNum);
|
||||
|
||||
// Do pulse even if the number isn't changing.
|
||||
|
||||
m_textNumber.SetText( txt );
|
||||
float fNumberZoom = SCALE(iNum,0.f,(float)NUMBER_MAX_ZOOM_AT,(float)NUMBER_MIN_ZOOM,(float)NUMBER_MAX_ZOOM);
|
||||
CLAMP( fNumberZoom, (float)NUMBER_MIN_ZOOM, (float)NUMBER_MAX_ZOOM );
|
||||
m_textNumber.FinishTweening();
|
||||
m_textNumber.SetZoom( fNumberZoom );
|
||||
m_textNumber.RunCommands( PULSE_COMMAND );
|
||||
|
||||
AutoActor &sprLabel = bComboOfMisses ? m_sprMissesLabel : m_sprComboLabel;
|
||||
|
||||
sprLabel->FinishTweening();
|
||||
sprLabel->RunCommands( PULSE_COMMAND );
|
||||
|
||||
if( b100Milestone )
|
||||
m_spr100Milestone->PlayCommand( "Milestone" );
|
||||
this->PlayCommand( "100Milestone" );
|
||||
if( b1000Milestone )
|
||||
m_spr1000Milestone->PlayCommand( "Milestone" );
|
||||
this->PlayCommand( "1000Milestone" );
|
||||
|
||||
// don't show a colored combo until 1/4 of the way through the song
|
||||
bool bPastMidpoint = GAMESTATE->GetCourseSongIndex()>0 ||
|
||||
GAMESTATE->m_fMusicSeconds > GAMESTATE->m_pCurSong->m_fMusicLengthSeconds/4;
|
||||
|
||||
if( bComboOfMisses )
|
||||
{
|
||||
sprLabel->RunCommands( MISS_COMBO_COMMAND );
|
||||
m_textNumber.RunCommands( MISS_COMBO_COMMAND );
|
||||
}
|
||||
else if( bPastMidpoint )
|
||||
{
|
||||
if( m_pPlayerStageStats->FullComboOfScore(TNS_W1) )
|
||||
{
|
||||
sprLabel->RunCommands( FULL_COMBO_W1_COMMAND );
|
||||
m_textNumber.RunCommands( FULL_COMBO_W1_COMMAND );
|
||||
}
|
||||
else if( bPastMidpoint && m_pPlayerStageStats->FullComboOfScore(TNS_W2) )
|
||||
{
|
||||
sprLabel->RunCommands( FULL_COMBO_W2_COMMAND );
|
||||
m_textNumber.RunCommands( FULL_COMBO_W2_COMMAND );
|
||||
}
|
||||
else if( bPastMidpoint && m_pPlayerStageStats->FullComboOfScore(TNS_W3) )
|
||||
{
|
||||
sprLabel->RunCommands( FULL_COMBO_W3_COMMAND );
|
||||
m_textNumber.RunCommands( FULL_COMBO_W3_COMMAND );
|
||||
}
|
||||
else
|
||||
{
|
||||
sprLabel->RunCommands( FULL_COMBO_BROKEN_COMMAND );
|
||||
m_textNumber.RunCommands( FULL_COMBO_BROKEN_COMMAND );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprLabel->RunCommands( FULL_COMBO_BROKEN_COMMAND );
|
||||
m_textNumber.RunCommands( FULL_COMBO_BROKEN_COMMAND );
|
||||
}
|
||||
Message msg("Combo");
|
||||
if( iCombo )
|
||||
msg.SetParam( "Combo", iCombo );
|
||||
if( iMisses )
|
||||
msg.SetParam( "Misses", iMisses );
|
||||
if( bPastMidpoint && m_pPlayerStageStats->FullComboOfScore(TNS_W1) )
|
||||
msg.SetParam( "FullComboW1", true );
|
||||
if( bPastMidpoint && m_pPlayerStageStats->FullComboOfScore(TNS_W2) )
|
||||
msg.SetParam( "FullComboW2", true );
|
||||
if( bPastMidpoint && m_pPlayerStageStats->FullComboOfScore(TNS_W3) )
|
||||
msg.SetParam( "FullComboW3", true );
|
||||
this->HandleMessage( msg );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+2
-19
@@ -5,9 +5,8 @@
|
||||
|
||||
#include "ActorFrame.h"
|
||||
#include "AutoActor.h"
|
||||
#include "BitmapText.h"
|
||||
#include "PlayerNumber.h"
|
||||
#include "ThemeMetric.h"
|
||||
//#include "ThemeMetric.h"
|
||||
class PlayerState;
|
||||
class PlayerStageStats;
|
||||
|
||||
@@ -16,31 +15,15 @@ class Combo : public ActorFrame
|
||||
public:
|
||||
Combo();
|
||||
|
||||
void Load( const PlayerState *pPlayerState, const PlayerStageStats *pPlayerStageStats );
|
||||
void Load( const RString &sPath, const PlayerState *pPlayerState, const PlayerStageStats *pPlayerStageStats );
|
||||
|
||||
void SetCombo( int iCombo, int iMisses );
|
||||
|
||||
protected:
|
||||
ThemeMetric<int> SHOW_COMBO_AT;
|
||||
ThemeMetric<float> NUMBER_MIN_ZOOM;
|
||||
ThemeMetric<float> NUMBER_MAX_ZOOM;
|
||||
ThemeMetric<float> NUMBER_MAX_ZOOM_AT;
|
||||
ThemeMetric<apActorCommands> PULSE_COMMAND;
|
||||
ThemeMetric<float> TWEEN_SECONDS;
|
||||
ThemeMetric<apActorCommands> FULL_COMBO_W3_COMMAND;
|
||||
ThemeMetric<apActorCommands> FULL_COMBO_W2_COMMAND;
|
||||
ThemeMetric<apActorCommands> FULL_COMBO_W1_COMMAND;
|
||||
ThemeMetric<apActorCommands> FULL_COMBO_BROKEN_COMMAND;
|
||||
ThemeMetric<apActorCommands> MISS_COMBO_COMMAND;
|
||||
|
||||
const PlayerState *m_pPlayerState;
|
||||
const PlayerStageStats *m_pPlayerStageStats;
|
||||
|
||||
AutoActor m_spr100Milestone;
|
||||
AutoActor m_spr1000Milestone;
|
||||
AutoActor m_sprComboLabel;
|
||||
AutoActor m_sprMissesLabel;
|
||||
BitmapText m_textNumber;
|
||||
|
||||
int m_iLastSeenCombo;
|
||||
};
|
||||
|
||||
@@ -382,7 +382,7 @@ void Player::Init(
|
||||
if( m_pCombo )
|
||||
{
|
||||
m_pCombo->SetName( "Combo" );
|
||||
m_pCombo->Load( m_pPlayerState, m_pPlayerStageStats );
|
||||
m_pCombo->Load( THEME->GetPathG(sType,"combo"), m_pPlayerState, m_pPlayerStageStats );
|
||||
ActorUtil::LoadAllCommandsAndOnCommand( m_pCombo, sType );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user