turns out these bindings don't work so well.

This commit is contained in:
AJ Kelly
2010-12-21 23:04:59 -06:00
parent d282db4b7c
commit 069bd6cca2
3 changed files with 25 additions and 37 deletions
-2
View File
@@ -17,8 +17,6 @@ sm-ssc v1.2 | 201012xx
-------- --------
* SM5SVN r28586: Only unload fonts if not used by the next screen. [shakesoda] * SM5SVN r28586: Only unload fonts if not used by the next screen. [shakesoda]
* [ScreenSelectMaster] Fix DoSwitchAnyways to actually work again. * [ScreenSelectMaster] Fix DoSwitchAnyways to actually work again.
* [Screen] Added SetNextScreenName(string) and SetPrevScreenName(string)
Lua bindings. [freem]
* [ScreenInstallOverlay] Installs won't jump to SelMusic on Gameplay or System * [ScreenInstallOverlay] Installs won't jump to SelMusic on Gameplay or System
Menus (e.g. Edit Mode) anymore on download completion. [freem] Menus (e.g. Edit Mode) anymore on download completion. [freem]
+23 -31
View File
@@ -81,17 +81,16 @@ void Screen::BeginScreen()
m_bRunning = true; m_bRunning = true;
m_bFirstUpdate = true; m_bFirstUpdate = true;
/* Screens set these when they determine their next screen dynamically. Reset them /* Screens set these when they determine their next screen dynamically. Reset them
* here, so a reused screen doesn't inherit these from the last time it was used. */ * here, so a reused screen doesn't inherit these from the last time it was used. */
m_sNextScreen = RString(); m_sNextScreen = RString();
m_sPrevScreen = RString();
m_fLockInputSecs = 0; m_fLockInputSecs = 0;
this->RunCommands( THEME->GetMetricA(m_sName, "ScreenOnCommand") ); this->RunCommands( THEME->GetMetricA(m_sName, "ScreenOnCommand") );
if( m_fLockInputSecs == 0 ) if( m_fLockInputSecs == 0 )
m_fLockInputSecs = 0.0001f; // always lock for a tiny amount of time so that we throw away any queued inputs during the load. m_fLockInputSecs = 0.0001f; // always lock for a tiny amount of time so that we throw away any queued inputs during the load.
this->PlayCommand( "Begin" ); this->PlayCommand( "Begin" );
} }
@@ -108,33 +107,28 @@ void Screen::Update( float fDeltaTime )
m_fLockInputSecs = max( 0, m_fLockInputSecs-fDeltaTime ); m_fLockInputSecs = max( 0, m_fLockInputSecs-fDeltaTime );
/* /* We need to ensure two things:
* We need to ensure two things: * 1. Messages must be sent in the order of delay. If two messages are sent
* 1. Messages must be sent in the order of delay. If two messages are sent * simultaneously, one with a .001 delay and another with a .002 delay,
* simultaneously, one with a .001 delay and another with a .002 delay, the * the .001 delay message must be sent first.
* .001 delay message must be sent first.
* 2. Messages to be delivered simultaneously must be sent in the order queued. * 2. Messages to be delivered simultaneously must be sent in the order queued.
* *
* Sort by time to ensure #1; use a stable sort to ensure #2. * Sort by time to ensure #1; use a stable sort to ensure #2. */
*/
stable_sort(m_QueuedMessages.begin(), m_QueuedMessages.end(), SortMessagesByDelayRemaining); stable_sort(m_QueuedMessages.begin(), m_QueuedMessages.end(), SortMessagesByDelayRemaining);
/* Update the times of queued ScreenMessages. */ // Update the times of queued ScreenMessages.
for( unsigned i=0; i<m_QueuedMessages.size(); i++ ) for( unsigned i=0; i<m_QueuedMessages.size(); i++ )
{ {
/* Hack: /* Hack:
*
* If we simply subtract time and then send messages, we have a problem. * If we simply subtract time and then send messages, we have a problem.
* Messages are queued to arrive at specific times, and those times line * Messages are queued to arrive at specific times, and those times line
* up with things like tweens finishing. If we send the message at the * up with things like tweens finishing. If we send the message at the
* exact time given, then it'll be on the same cycle that would be rendering * exact time given, then it'll be on the same cycle that would be rendering
* the last frame of a tween (such as an object going off the screen). However, * the last frame of a tween (such as an object going off the screen).
* when we send the message, we're likely to set up a new screen, which * However, when we send the message, we're likely to set up a new screen,
* causes everything to stop in place; this results in actors occasionally * which causes everything to stop in place; this results in actors
* not quite finishing their tweens. * occasionally not quite finishing their tweens.
* * Let's delay all messages that have a non-zero time an extra frame. */
* Let's delay all messages that have a non-zero time an extra frame.
*/
if( m_QueuedMessages[i].fDelayRemaining > 0.0001f ) if( m_QueuedMessages[i].fDelayRemaining > 0.0001f )
{ {
m_QueuedMessages[i].fDelayRemaining -= fDeltaTime; m_QueuedMessages[i].fDelayRemaining -= fDeltaTime;
@@ -146,8 +140,8 @@ void Screen::Update( float fDeltaTime )
} }
} }
/* Now dispatch messages. If the number of messages on the queue changes /* Now dispatch messages. If the number of messages on the queue changes
* within HandleScreenMessage, someone cleared messages on the queue. This * within HandleScreenMessage, someone cleared messages on the queue. This
* means we have no idea where 'i' is, so start over. Since we applied time * means we have no idea where 'i' is, so start over. Since we applied time
* already, this won't cause messages to be mistimed. */ * already, this won't cause messages to be mistimed. */
for( unsigned i=0; i<m_QueuedMessages.size(); i++ ) for( unsigned i=0; i<m_QueuedMessages.size(); i++ )
@@ -155,7 +149,7 @@ void Screen::Update( float fDeltaTime )
if( m_QueuedMessages[i].fDelayRemaining > 0.0f ) if( m_QueuedMessages[i].fDelayRemaining > 0.0f )
continue; /* not yet */ continue; /* not yet */
/* Remove the message from the list. */ // Remove the message from the list.
const ScreenMessage SM = m_QueuedMessages[i].SM; const ScreenMessage SM = m_QueuedMessages[i].SM;
m_QueuedMessages.erase( m_QueuedMessages.begin()+i ); m_QueuedMessages.erase( m_QueuedMessages.begin()+i );
i--; i--;
@@ -172,10 +166,10 @@ void Screen::Update( float fDeltaTime )
} }
} }
/* ScreenManager sends input here first. Overlay screens can use it to get a first /* ScreenManager sends input here first. Overlay screens can use it to get a first
* pass at input. Return true if the input was handled and should not be passed * pass at input. Return true if the input was handled and should not be passed
* to lower screens, or false if not handled. If true is returned, Input() will * to lower screens, or false if not handled. If true is returned, Input() will
* not be called, either. Normal screens should not overload this function. */ * not be called, either. Normal screens should not overload this function. */
bool Screen::OverlayInput( const InputEventPlus &input ) bool Screen::OverlayInput( const InputEventPlus &input )
{ {
return false; return false;
@@ -244,6 +238,7 @@ void Screen::HandleScreenMessage( const ScreenMessage SM )
RString Screen::GetNextScreenName() const RString Screen::GetNextScreenName() const
{ {
LOG->Trace("[Screen::GetNextScreenName]: m_sNextScreen = %s",m_sNextScreen.c_str());
if( !m_sNextScreen.empty() ) if( !m_sNextScreen.empty() )
return m_sNextScreen; return m_sNextScreen;
return NEXT_SCREEN; return NEXT_SCREEN;
@@ -251,6 +246,7 @@ RString Screen::GetNextScreenName() const
RString Screen::GetPrevScreen() const RString Screen::GetPrevScreen() const
{ {
LOG->Trace("[Screen::GetPrevScreen]: m_sPrevScreen = %s",m_sPrevScreen.c_str());
if( !m_sPrevScreen.empty() ) if( !m_sPrevScreen.empty() )
return m_sPrevScreen; return m_sPrevScreen;
return PREV_SCREEN; return PREV_SCREEN;
@@ -286,8 +282,6 @@ class LunaScreen: public Luna<Screen>
public: public:
static int GetNextScreenName( T* p, lua_State *L ) { lua_pushstring(L, p->GetNextScreenName() ); return 1; } static int GetNextScreenName( T* p, lua_State *L ) { lua_pushstring(L, p->GetNextScreenName() ); return 1; }
static int GetPrevScreenName( T* p, lua_State *L ) { lua_pushstring(L, p->GetPrevScreen() ); return 1; } static int GetPrevScreenName( T* p, lua_State *L ) { lua_pushstring(L, p->GetPrevScreen() ); return 1; }
static int SetNextScreenName( T* p, lua_State *L ) { p->SetNextScreen(SArg(1)); return 0; }
static int SetPrevScreenName( T* p, lua_State *L ) { p->SetPrevScreen(SArg(1)); return 0; }
static int lockinput( T* p, lua_State *L ) { p->SetLockInputSecs(FArg(1)); return 0; } static int lockinput( T* p, lua_State *L ) { p->SetLockInputSecs(FArg(1)); return 0; }
DEFINE_METHOD( GetScreenType, GetScreenType() ) DEFINE_METHOD( GetScreenType, GetScreenType() )
@@ -303,8 +297,6 @@ public:
{ {
ADD_METHOD( GetNextScreenName ); ADD_METHOD( GetNextScreenName );
ADD_METHOD( GetPrevScreenName ); ADD_METHOD( GetPrevScreenName );
ADD_METHOD( SetNextScreenName );
ADD_METHOD( SetPrevScreenName );
ADD_METHOD( PostScreenMessage ); ADD_METHOD( PostScreenMessage );
ADD_METHOD( lockinput ); ADD_METHOD( lockinput );
ADD_METHOD( GetScreenType ); ADD_METHOD( GetScreenType );
-2
View File
@@ -97,8 +97,6 @@ protected:
public: public:
RString GetNextScreenName() const; RString GetNextScreenName() const;
RString GetPrevScreen() const; RString GetPrevScreen() const;
void SetNextScreen(RString sNextScreen){ m_sNextScreen = sNextScreen; };
void SetPrevScreen(RString sPrevScreen){ m_sPrevScreen = sPrevScreen; };
// let subclass override if they want // let subclass override if they want
virtual void MenuUp( const InputEventPlus &input ) { } virtual void MenuUp( const InputEventPlus &input ) { }