This commit is contained in:
Jonathan Payne
2014-08-05 15:43:57 -07:00
12 changed files with 161 additions and 26 deletions
+2 -1
View File
@@ -725,7 +725,8 @@
<Function name='IsGameEnabled'/>
<Function name='StepsTypeToLocalizedString'/>
<Function name='SetGame'/>
<Function name='GetEnabledGames'/>
<Function name='GetEnabledGames'/>
<Function name='GetStylesForGame'/>
</Class>
<Class name='GameSoundManager'>
<Function name='DimMusic'/>
+4 -1
View File
@@ -2188,7 +2188,10 @@ save yourself some time, copy this for undocumented things:
</Function>
<Function name='GetEnabledGames' return='{string}'>
Returns a table of all selectable games.
</Function>
</Function>
<Function name='GetStylesForGame' return='{style}' arguments='string game'>
Returns a table of all the styles for the that exist for <code>game</code>.
</Function>
<Function name='SetGame' return='void' arguments='string Game, string Theme' >
Sets the current game to <code>Game</code>. The second argument is optional, and if provided will determine which theme is loaded when the game changes. If the second argument is not provided, the default theme from the preferences for the new game type will be loaded.<br />
If only the game changes, the screen specified by the Common::AfterGameChangeScreen metric will be loaded.<br />
@@ -0,0 +1,34 @@
-- A simple ActorFrame example with a couple Actor children and attributes.
-- An ActorFrame is used to contain other actors, giving them a common origin
-- and organizing them.
Def.ActorFrame{
Name= "Simple frame",
-- Amount to multiply the delta time by when updating.
UpdateRate= 2,
-- The angular width of the field of view used to render children.
-- This will ruin your frame rate, do not use. -1 means no effect.
--FOV= -1,
-- The position of the vanishing point used for the FOV rendering.
--VanishX= _screen.cx,
--VanishY= _screen.cy,
-- Whether to apply lighting. Incomplete implementation, do not use.
--Lighting= true,
-- Different color values used when lighting is applied.
--AmbientColor= ".75,.75,.75",
--DiffuseColor= "0,0,.25",
--SpecularColor= ".25,0,0",
-- A couple children, just to have something to list later.
Def.Actor{Name= "Simple child"},
Def.Actor{Name= "Other child"},
InitCommand= function(self)
local children= self:GetChildren()
for name, child in pairs(children) do
Trace("Has child " .. name)
end
end
}
@@ -0,0 +1,74 @@
-- How actor creation works:
-- Actors are created from tables.
-- The elements in the table are used to set various attributes of the actor
-- or commands that the actor can execute.
-- Unless stated otherwise, assume that all elements are optional, few
-- attributes or commands are required.
-- Different Actor types have different attributes that can be set.
-- Any element with a name that ends in "Command" must be a function and can
-- later be executed by using the playcommand or queuecommand functions on
-- that actor.
-- Any element with a name that ends in "MessageCommand" must be a function
-- and will be executed whenever that message is broadcast.
-- The functions used for commands and messages are automatically passed a
-- "self" parameter, which is the actor. Message functions are also passed
-- a params table containing parameters that were broadcast with the
-- message. playcommand can be used to pass a parameters table to the
-- command, but queuecommand cannot.
-- For ActorFrame and actors that inherit from it, array elements of the
-- table are added as children.
-- Any element in the table that is not recognized as an attribute, command,
-- or child is discarded.
-- Some actors also fetch metrics from metrics.ini to control some aspect.
-- Metrics loaded will be listed in entries for individual actor types.
-- There are some helper functions like LoadActor and LoadFont, which are
-- documented in Docs/Luadoc/lua.xml.
-- This is a simple actor with no visual aspect and basic commands.
Def.Actor{
-- Attributes:
-- You should always supply a name for an actor. The name is used when
-- finding the actor with GetChild.
Name= "simple",
-- The base rotation and zoom. X, Y, and Z are all settable, though only
-- X is listed in this example. Rotation is in degrees.
BaseRotationX= 15,
BaseZoomX= .5,
-- The Init command is run for every actor after all the attributes are set
-- and all children have been loaded.
-- It's important to note that the Init command runs during screen
-- creation, before the screen has changed. If you use
-- SCREENMAN:GetTopScreen() in the Init command, you will not get the
-- screen that is being created because it isn't finished being created.
InitCommand= function(self)
Trace("Init command running for " .. self:GetName())
end,
-- The On command runs after screen creation has finished.
OnCommand= function(self)
Trace("On command running for " .. self:GetName())
-- Queue the Exa command to execute when all tweening has finished.
self:queuecommand("Exa")
end,
ExaCommand= function(self)
Trace("Exa command running for " .. self:GetName())
-- Execute the Tera command right now.
self:playcommand("Tera", {foo= 1, bar= 2})
end,
TeraCommand= function(self, params)
Trace("Exa command running for " .. self:GetName() .. ": " .. params.foo .. ", " .. params.bar)
-- Broadcast a message that will execute the Giga command for every actor
-- that has it.
MESSAGEMAN:Broadcast("Giga", {foo= 1, bar= 2})
end,
GigaMessageCommand= function(self, params)
Trace("Giga command running for " .. self:GetName() .. ": " .. params.foo .. ", " .. params.bar)
end
}
-- It is important to note that the things in Def are functions and you are
-- passing them a table when you use them. "Def.Actor{}", "Def.Actor({})",
-- and "local foo= {} Def.Actor(foo)" are all equivalent in effect, but
-- some forms make is easier to write well organized code.
+3 -2
View File
@@ -1,5 +1,5 @@
[sm-ssc v1.0 public beta 2 | last update 2010/apr 11]
This is a list of all the known Actor classes in sm-ssc. You can use these by
[SM5 public nightly build | last update 2014/aug 04]
This is a list of all the known Actor classes in SM5. You can use these by
prefixing "Def." on the end of the name (e.g. Def.PaneDisplay).
Actor
@@ -9,6 +9,7 @@ ActorMultiTexture
ActorMultiVertex
ActorProxy
ActorScroller
ActorSound
Banner
BGAnimation
BitmapText
+20 -3
View File
@@ -3159,12 +3159,28 @@ public:
return 1;
}
static int GetStylesForGame( T* p, lua_State *L )
{
RString game_name= SArg(1);
const Game *pGame = p->StringToGame(game_name);
if(!pGame)
{
luaL_error(L, "GetStylesForGame: Invalid Game: '%s'", game_name.c_str());
}
vector<Style*> aStyles;
lua_createtable(L, 0, 0);
for( int s=0; pGame->m_apStyles[s]; ++s )
{
Style *pStyle = const_cast<Style *>( pGame->m_apStyles[s] );
pStyle->PushSelf(L);
lua_rawseti(L, -2, s+1);
}
return 1;
}
static int GetEnabledGames( T* p, lua_State *L )
{
vector<const Game*> aGames;
GAMEMAN->GetEnabledGames( aGames );
p->GetEnabledGames( aGames );
vector<RString> vsGames;
FOREACH( const Game*, aGames, g )
{
@@ -3201,6 +3217,7 @@ public:
ADD_METHOD( StepsTypeToLocalizedString );
ADD_METHOD( GetFirstStepsTypeForGame );
ADD_METHOD( IsGameEnabled );
ADD_METHOD( GetStylesForGame );
ADD_METHOD( GetEnabledGames );
ADD_METHOD( SetGame );
};
+1 -11
View File
@@ -555,7 +555,7 @@ void GameSoundManager::Update( float fDeltaTime )
{
/* There's no song playing. Fake it. */
CHECKPOINT_M( ssprintf("%f, delta %f", GAMESTATE->m_Position.m_fMusicSeconds, fDeltaTime) );
GAMESTATE->UpdateSongPosition( GAMESTATE->m_Position.m_fMusicSeconds + fDeltaTime, g_Playing->m_Timing );
GAMESTATE->UpdateSongPosition( GAMESTATE->m_Position.m_fMusicSeconds + fDeltaTime * g_Playing->m_Music->GetPlaybackRate() , g_Playing->m_Timing );
return;
}
@@ -567,9 +567,7 @@ void GameSoundManager::Update( float fDeltaTime )
RageTimer tm;
const float fSeconds = g_Playing->m_Music->GetPositionSeconds( &m_bApproximate, &tm );
//
// Check for song timing skips.
//
if( PREFSMAN->m_bLogSkips && !g_Playing->m_bTimingDelayed )
{
const float fExpectedTimePassed = (tm - GAMESTATE->m_Position.m_LastBeatUpdate) * g_Playing->m_Music->GetPlaybackRate();
@@ -586,10 +584,8 @@ void GameSoundManager::Update( float fDeltaTime )
sLastFile = ThisFile;
}
//
// If g_Playing->m_bTimingDelayed, we're waiting for the new music to actually start
// playing.
//
if( g_Playing->m_bTimingDelayed && !m_bApproximate )
{
/* Load up the new timing data. */
@@ -608,10 +604,7 @@ void GameSoundManager::Update( float fDeltaTime )
GAMESTATE->UpdateSongPosition( fSeconds + fAdjust, g_Playing->m_Timing, tm + fAdjust );
}
//
// Send crossed messages
//
if( GAMESTATE->m_pCurSong )
{
static int iBeatLastCrossed = 0;
@@ -633,10 +626,7 @@ void GameSoundManager::Update( float fDeltaTime )
iBeatLastCrossed = iBeatNow;
}
//
// Update lights
//
NoteData &lights = g_Playing->m_Lights;
if( lights.GetNumTracks() > 0 ) // lights data was loaded
{
+11 -4
View File
@@ -25,11 +25,18 @@ void GradeDisplay::Load( RString sMetricsGroup )
void GradeDisplay::SetGrade( Grade grade )
{
int i = 0;
size_t i = 0;
FOREACH_PossibleGrade( g )
{
m_vSpr[i]->SetVisible( g == grade );
i++;
if(i >= m_vSpr.size())
{
LuaHelpers::ReportScriptError("GradeDisplay:SetGrade: No actor loaded for grade " + GradeToString(g));
}
else
{
m_vSpr[i]->SetVisible( g == grade );
i++;
}
}
}
@@ -47,7 +54,7 @@ public:
}
static int SetGrade( T* p, lua_State *L )
{
Grade g = Enum::Check<Grade>(L, 2);
Grade g = Enum::Check<Grade>(L, 1);
p->SetGrade( g );
return 0;
}
+10 -2
View File
@@ -72,7 +72,7 @@ void RollingNumbers::DrawPrimitives()
void RollingNumbers::Update( float fDeltaTime )
{
if( m_fCurrentNumber != m_fTargetNumber )
if(m_fCurrentNumber != m_fTargetNumber && m_fScoreVelocity > 0)
{
fapproach( m_fCurrentNumber, m_fTargetNumber, fabsf(m_fScoreVelocity) * fDeltaTime );
UpdateText();
@@ -86,7 +86,15 @@ void RollingNumbers::SetTargetNumber( float fTargetNumber )
if( fTargetNumber == m_fTargetNumber ) // no change
return;
m_fTargetNumber = fTargetNumber;
m_fScoreVelocity = (m_fTargetNumber-m_fCurrentNumber) / APPROACH_SECONDS.GetValue();
float approach_secs= APPROACH_SECONDS.GetValue();
if(approach_secs > 0)
{
m_fScoreVelocity= (m_fTargetNumber-m_fCurrentNumber) / approach_secs;
}
else
{
m_fScoreVelocity= (m_fTargetNumber-m_fCurrentNumber);
}
}
void RollingNumbers::UpdateText()
+1 -1
View File
@@ -42,7 +42,7 @@
* @brief The internal version of the cache for StepMania.
*
* Increment this value to invalidate the current cache. */
const int FILE_CACHE_VERSION = 216;
const int FILE_CACHE_VERSION = 217;
/** @brief How long does a song sample last by default? */
const float DEFAULT_MUSIC_SAMPLE_LENGTH = 12.f;
+1 -1
View File
@@ -20,7 +20,7 @@ void FixupPath( RString &path, const RString &sSongPath );
RString GetSongAssetPath( RString sPath, const RString &sSongPath );
/** @brief The version of the .ssc file format. */
const static float STEPFILE_VERSION_NUMBER = 0.81f;
const static float STEPFILE_VERSION_NUMBER = 0.82f;
/** @brief How many edits for this song can each profile have? */
const int MAX_EDITS_PER_SONG_PER_PROFILE = 15;
Binary file not shown.