Merge pull request #1 from stepmania/master

Latest master pull
This commit is contained in:
blindbox
2016-02-04 18:00:37 +08:00
12 changed files with 192 additions and 23 deletions
+12
View File
@@ -4,6 +4,18 @@ The StepMania 5 Changelog covers all post-sm-ssc changes. For a list of changes
from StepMania 4 alpha 5 to sm-ssc v1.2.5, see Changelog_sm-ssc.txt.
________________________________________________________________________________
2016/02/03
----------
* [ScreenManager] Added PlayInvalidSound, PlayStartSound, PlayCoinSound,
PlayCancelSound, and PlayScreenshotSound lua bindings. [kyzentun]
Added get_input_redirected and set_input_redirected to allow the theme to
disable the normal input functions. (Example: a custom lua menu on
Select Music. When the menu is up, the theme doesn't want the player's
input to move the music wheel.) This is in SCREENMAN so that it will work
on all screens. [kyzentun]
* [ScreenSelectMusic] Added CanOpenOptionsList lua binding. OpenOptionsList
will do nothing if CanOpenOptionsList returns false. [kyzentun]
2016/01/18
----------
* [Edit Mode] Added "Clear timing in region" to timing menu. [kyzentun]
+8
View File
@@ -1488,10 +1488,17 @@
<Class name='ScreenManager'>
<Function name='AddNewScreenToTop'/>
<Function name='GetTopScreen'/>
<Function name='get_input_redirected'/>
<Function name='PlayInvalidSound'/>
<Function name='PlayStartSound'/>
<Function name='PlayCoinSound'/>
<Function name='PlayCancelSound'/>
<Function name='PlayScreenshotSound'/>
<Function name='ReloadOverlayScreens'/>
<Function name='ScreenClassExists'/>
<Function name='ScreenIsPrepped'/>
<Function name='SetNewScreen'/>
<Function name='set_input_redirected'/>
<Function name='SystemMessage'/>
</Class>
<Class base='ScreenWithMenuElements' name='ScreenNameEntryTraditional'>
@@ -1529,6 +1536,7 @@
<Function name='GetSelectionIndex'/>
</Class>
<Class base='ScreenWithMenuElements' name='ScreenSelectMusic'>
<Function name='CanOpenOptionsList'/>
<Function name='GetGoToOptions'/>
<Function name='GetMusicWheel'/>
<Function name='OpenOptionsList'/>
+25
View File
@@ -4389,6 +4389,24 @@ save yourself some time, copy this for undocumented things:
<Function name='GetTopScreen' return='Screen' arguments=''>
Gets the screen at the top of the screen stack.
</Function>
<Function name='get_input_redirected' return='bool' arguments='PlayerNumber pn'>
Returns whether the input for the player has been redirected away from the normal screen input function. Input that has been redirected is only sent to lua input callbacks.
</Function>
<Function name='PlayInvalidSound' return='' arguments=''>
Plays the invalid sound.
</Function>
<Function name='PlayStartSound' return='' arguments=''>
Plays the start sound.
</Function>
<Function name='PlayCoinSound' return='' arguments=''>
Plays the coin sound.
</Function>
<Function name='PlayCancelSound' return='' arguments=''>
Plays the cancel sound.
</Function>
<Function name='PlayScreenshotSound' return='' arguments=''>
Plays the screenshot sound.
</Function>
<Function name='ReloadOverlayScreens' return='void' arguments=''>
Reloads any loaded overlay screens.
</Function>
@@ -4401,6 +4419,10 @@ save yourself some time, copy this for undocumented things:
<Function name='SetNewScreen' return='void' arguments='string s'>
Sets the next screen to <code>s</code>.
</Function>
<Function name='set_input_redirected' return='bool' arguments='PlayerNumber pn, bool redir'>
Sets whether the input for the player has been redirected away from the normal screen input function. Input that has been redirected is only sent to lua input callbacks.<br />
This can be useful when putting a custom menu on a screen, and you want to disable the built in actors while the menu is open. Then you handle input through an input callback until the player closes the menu.
</Function>
<Function name='SystemMessage' return='void' arguments='string s'>
Broadcasts a system message.
</Function>
@@ -4482,6 +4504,9 @@ save yourself some time, copy this for undocumented things:
</Function>
</Class>
<Class name='ScreenSelectMusic'>
<Function name='CanOpenOptionsList' return='bool' arguments=''>
Returns false if the options list is already open or the UseOptionsList metric is false.
</Function>
<Function name='GetGoToOptions' return='bool' arguments=''>
Returns <code>true</code> if the player is going to the options screen.
</Function>
+20 -9
View File
@@ -552,20 +552,31 @@ void CourseID::FromCourse( const Course *p )
Course *CourseID::ToCourse() const
{
// HACK for backwards compatibility:
// Re-add the leading "/". 2005/05/21 file layer changes added a leading slash.
RString sPath2 = sPath;
if( sPath2.Left(1) != "/" )
sPath2 = "/" + sPath2;
Course *pCourse = NULL;
if( m_Cache.Get(&pCourse) )
if(m_Cache.Get(&pCourse))
{
return pCourse;
if( pCourse == NULL && !sPath2.empty() )
pCourse = SONGMAN->GetCourseFromPath( sPath2 );
}
if(!sPath.empty())
{
// HACK for backwards compatibility:
// Re-add the leading "/". 2005/05/21 file layer changes added a leading slash.
RString slash_path = sPath;
if(slash_path.Left(1) != "/")
{
slash_path = "/" + slash_path;
}
if(pCourse == NULL)
{
pCourse = SONGMAN->GetCourseFromPath(slash_path);
}
}
if( pCourse == NULL && !sFullTitle.empty() )
{
pCourse = SONGMAN->GetCourseFromName( sFullTitle );
}
m_Cache.Set( pCourse );
return pCourse;
+1 -1
View File
@@ -610,7 +610,7 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr
{
LuaHelpers::ReportScriptErrorFmt(
"The font definition \"%s\" tries to assign line %i, "
"but the font is only %i characters high."
"but the font is only %i characters high. "
"Line numbers start at 0.",
ini.GetPath().c_str(), first_frame, num_frames_high);
continue;
+8 -2
View File
@@ -86,7 +86,10 @@ RageSound &RageSound::operator=( const RageSound &cpy )
m_bPlaying = false;
m_bDeleteWhenFinished = false;
delete m_pSource;
if(m_pSource != NULL)
{
delete m_pSource;
}
if( cpy.m_pSource )
m_pSource = cpy.m_pSource->Copy();
else
@@ -104,7 +107,10 @@ void RageSound::Unload()
LockMut(m_Mutex);
delete m_pSource;
if(m_pSource != NULL)
{
delete m_pSource;
}
m_pSource = NULL;
m_sFilePath = "";
+6 -1
View File
@@ -46,6 +46,11 @@ static RString ov_ssprintf( int err, const char *fmt, ...)
RString errstr;
switch( err )
{
// OV_FALSE, OV_EOF, and OV_HOLE were added to this switch because
// OV_EOF cases were being reported as unknown. -Kyz
case OV_FALSE: errstr = "OV_FALSE"; break;
case OV_EOF: errstr = "OV_EOF"; break;
case OV_HOLE: errstr = "OV_HOLE"; break;
/* XXX: In the case of OV_EREAD, can we snoop at errno? */
case OV_EREAD: errstr = "Read error"; break;
case OV_EFAULT: errstr = "Internal error"; break;
@@ -123,7 +128,7 @@ int RageSoundReader_Vorbisfile::SetPosition( int iFrame )
if(ret < 0)
{
/* Returns OV_EINVAL on EOF. */
if( ret == OV_EINVAL )
if( ret == OV_EINVAL || ret == OV_EOF)
{
eof = true;
return 0;
+55 -1
View File
@@ -72,6 +72,7 @@
#include "ScreenDimensions.h"
#include "Foreach.h"
#include "ActorUtil.h"
#include "InputEventPlus.h"
ScreenManager* SCREENMAN = NULL; // global and accessible from anywhere in our program
@@ -366,6 +367,24 @@ bool ScreenManager::IsStackedScreen( const Screen *pScreen ) const
return false;
}
bool ScreenManager::get_input_redirected(PlayerNumber pn)
{
if(pn >= m_input_redirected.size())
{
return false;
}
return m_input_redirected[pn];
}
void ScreenManager::set_input_redirected(PlayerNumber pn, bool redir)
{
while(pn >= m_input_redirected.size())
{
m_input_redirected.push_back(false);
}
m_input_redirected[pn]= redir;
}
/* Pop the top screen off the stack, sending SM_LoseFocus messages and
* returning the message the popped screen wants sent to the new top
* screen. Does not send SM_GainFocus. */
@@ -534,7 +553,10 @@ void ScreenManager::Input( const InputEventPlus &input )
if( g_ScreenStack.empty() )
return;
g_ScreenStack.back().m_pScreen->Input( input );
if(!get_input_redirected(input.pn))
{
g_ScreenStack.back().m_pScreen->Input( input );
}
g_ScreenStack.back().m_pScreen->PassInputToLua( input );
}
@@ -945,6 +967,32 @@ public:
//static int GetScreenStackSize( T* p, lua_State *L ) { lua_pushnumber( L, ScreenManagerUtil::g_ScreenStack.size() ); return 1; }
static int ReloadOverlayScreens( T* p, lua_State *L ) { p->ReloadOverlayScreens(); COMMON_RETURN_SELF; }
static int get_input_redirected(T* p, lua_State* L)
{
PlayerNumber pn= Enum::Check<PlayerNumber>(L, 1);
lua_pushboolean(L, p->get_input_redirected(pn));
return 1;
}
static int set_input_redirected(T* p, lua_State* L)
{
PlayerNumber pn= Enum::Check<PlayerNumber>(L, 1);
p->set_input_redirected(pn, BArg(2));
COMMON_RETURN_SELF;
}
#define SCRMAN_PLAY_SOUND(sound_name) \
static int Play##sound_name(T* p, lua_State* L) \
{ \
p->Play##sound_name(); \
COMMON_RETURN_SELF; \
}
SCRMAN_PLAY_SOUND(InvalidSound);
SCRMAN_PLAY_SOUND(StartSound);
SCRMAN_PLAY_SOUND(CoinSound);
SCRMAN_PLAY_SOUND(CancelSound);
SCRMAN_PLAY_SOUND(ScreenshotSound);
#undef SCRMAN_PLAY_SOUND
LunaScreenManager()
{
ADD_METHOD( SetNewScreen );
@@ -955,6 +1003,12 @@ public:
ADD_METHOD( AddNewScreenToTop );
//ADD_METHOD( GetScreenStackSize );
ADD_METHOD( ReloadOverlayScreens );
ADD_METHOD(PlayInvalidSound);
ADD_METHOD(PlayStartSound);
ADD_METHOD(PlayCoinSound);
ADD_METHOD(PlayCancelSound);
ADD_METHOD(PlayScreenshotSound);
ADD_GET_SET_METHODS(input_redirected);
}
};
+11
View File
@@ -3,6 +3,7 @@
#include "ScreenMessage.h"
#include "RageSound.h"
#include "PlayerNumber.h"
class Actor;
class Screen;
@@ -64,6 +65,9 @@ public:
* @return true if it's on the stack while not on the bottom, or false otherwise. */
bool IsStackedScreen( const Screen *pScreen ) const;
bool get_input_redirected(PlayerNumber pn);
void set_input_redirected(PlayerNumber pn, bool redir);
// Lua
void PushSelf( lua_State *L );
@@ -86,6 +90,13 @@ private:
// It's "AfterInput" because the debug overlay carries out actions in Input.
bool m_bReloadOverlayScreensAfterInput;
// m_input_redirected exists to allow the theme to prevent input being
// passed to the normal Screen::Input function, on a per-player basis.
// Input is still passed to lua callbacks, so it's intended for the case
// where someone has a custom menu on a screen and needs to disable normal
// input for navigating the custom menu to work. -Kyz
std::vector<bool> m_input_redirected;
Screen *MakeNewScreen( const RString &sName );
void LoadDelayedScreen();
bool ActivatePreparedScreenAndBackground( const RString &sScreenName );
+33 -1
View File
@@ -2000,6 +2000,23 @@ void ScreenSelectMusic::OnConfirmSongDeletion()
m_pSongAwaitingDeletionConfirmation = NULL;
}
bool ScreenSelectMusic::can_open_options_list(PlayerNumber pn)
{
if(!USE_OPTIONS_LIST)
{
return false;
}
if(pn >= NUM_PLAYERS)
{
return false;
}
if(m_OptionsList[pn].IsOpened())
{
return false;
}
return true;
}
// lua start
#include "LuaBinding.h"
@@ -2013,13 +2030,28 @@ public:
p->GetMusicWheel()->PushSelf(L);
return 1;
}
static int OpenOptionsList( T* p, lua_State *L ) { PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1); p->OpenOptionsList(pn); COMMON_RETURN_SELF; }
static int OpenOptionsList( T* p, lua_State *L )
{
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1);
if(p->can_open_options_list(pn))
{
p->OpenOptionsList(pn);
}
COMMON_RETURN_SELF;
}
static int CanOpenOptionsList( T* p, lua_State *L )
{
PlayerNumber pn = Enum::Check<PlayerNumber>(L, 1);
lua_pushboolean(L, p->can_open_options_list(pn));
return 1;
}
LunaScreenSelectMusic()
{
ADD_METHOD( GetGoToOptions );
ADD_METHOD( GetMusicWheel );
ADD_METHOD( OpenOptionsList );
ADD_METHOD( CanOpenOptionsList );
}
};
+2
View File
@@ -50,6 +50,8 @@ public:
void OpenOptionsList( PlayerNumber pn );
void OnConfirmSongDeletion();
bool can_open_options_list(PlayerNumber pn);
// Lua
virtual void PushSelf( lua_State *L );
+11 -8
View File
@@ -1132,14 +1132,17 @@ Song *SongID::ToSong() const
Song *pRet = NULL;
if( !m_Cache.Get(&pRet) )
{
// HACK for backwards compatibility: Re-add the leading "/".
// 2005/05/21 file layer changes added a leading slash.
RString sDir2 = sDir;
if( sDir2.Left(1) != "/" )
sDir2 = "/" + sDir2;
if( !sDir2.empty() )
pRet = SONGMAN->GetSongFromDir( sDir2 );
if(!sDir.empty())
{
// HACK for backwards compatibility: Re-add the leading "/".
// 2005/05/21 file layer changes added a leading slash.
RString sDir2 = sDir;
if(sDir2.Left(1) != "/")
{
sDir2 = "/" + sDir2;
}
pRet = SONGMAN->GetSongFromDir(sDir2);
}
m_Cache.Set( pRet );
}
return pRet;