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
+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;