revert SubscriptionManager. It makes the line order nondeterministic.

This commit is contained in:
Glenn Maynard
2006-01-24 04:18:05 +00:00
parent 3461ff8901
commit b45b377fa4
+14 -16
View File
@@ -23,7 +23,6 @@
#include "LocalizedString.h" #include "LocalizedString.h"
#include "Profile.h" #include "Profile.h"
#include "SongManager.h" #include "SongManager.h"
#include "SubscriptionManager.h"
#include "GameLoop.h" #include "GameLoop.h"
static bool g_bIsDisplayed = false; static bool g_bIsDisplayed = false;
@@ -35,20 +34,20 @@ static float g_fImageScaleDestination = 1;
// //
// self-registering debug lines // self-registering debug lines
// We don't use SubscriptionManager, because we want to keep the line order.
// //
class IDebugLine; class IDebugLine;
static SubscriptionManager<IDebugLine> g_Subscribers; static vector<IDebugLine*> *g_pvpSubscribers = NULL;
class IDebugLine class IDebugLine
{ {
public: public:
IDebugLine() IDebugLine()
{ {
g_Subscribers.Subscribe( this ); if( g_pvpSubscribers == NULL )
} g_pvpSubscribers = new vector<IDebugLine*>;
virtual ~IDebugLine() g_pvpSubscribers->push_back( this );
{
g_Subscribers.Unsubscribe( this );
} }
virtual ~IDebugLine() { }
virtual RString GetDescription() = 0; virtual RString GetDescription() = 0;
virtual RString GetValue() = 0; virtual RString GetValue() = 0;
virtual bool IsEnabled() = 0; virtual bool IsEnabled() = 0;
@@ -168,7 +167,7 @@ void ScreenDebugOverlay::Init()
m_textHeader.SetText( "Debug Menu" ); m_textHeader.SetText( "Debug Menu" );
this->AddChild( &m_textHeader ); this->AddChild( &m_textHeader );
FOREACHS_CONST( IDebugLine*, g_Subscribers.Get(), p ) FOREACH_CONST( IDebugLine*, *g_pvpSubscribers, p )
{ {
{ {
BitmapText *pT1 = new BitmapText; BitmapText *pT1 = new BitmapText;
@@ -238,10 +237,11 @@ void ScreenDebugOverlay::UpdateText()
const RageColor off(0.6f, 0.6f, 0.6f, 1.0f); const RageColor off(0.6f, 0.6f, 0.6f, 1.0f);
const RageColor on(1, 1, 1, 1); const RageColor on(1, 1, 1, 1);
const unsigned NUM_DEBUG_LINES = g_Subscribers.Get().size(); const unsigned NUM_DEBUG_LINES = g_pvpSubscribers->size();
int i = 0; FOREACH_CONST( IDebugLine*, *g_pvpSubscribers, p )
FOREACHS_CONST( IDebugLine*, g_Subscribers.Get(), p )
{ {
int i = p-g_pvpSubscribers->begin();
BitmapText &txt1 = *m_vptextButton[i]; BitmapText &txt1 = *m_vptextButton[i];
txt1.SetX( SCREEN_CENTER_X-50 ); txt1.SetX( SCREEN_CENTER_X-50 );
txt1.SetY( SCALE(i, 0, NUM_DEBUG_LINES-1, SCREEN_TOP+60, SCREEN_BOTTOM-40) ); txt1.SetY( SCALE(i, 0, NUM_DEBUG_LINES-1, SCREEN_TOP+60, SCREEN_BOTTOM-40) );
@@ -267,8 +267,6 @@ void ScreenDebugOverlay::UpdateText()
if( !s2.empty() ) if( !s2.empty() )
s1 += " - "; s1 += " - ";
txt2.SetText( s1 + s2 ); txt2.SetText( s1 + s2 );
++i;
} }
if( g_bIsHalt ) if( g_bIsHalt )
@@ -298,9 +296,10 @@ bool ScreenDebugOverlay::OverlayInput( const InputEventPlus &input )
g_bIsDisplayed = false; g_bIsDisplayed = false;
} }
int i = 0; FOREACH_CONST( IDebugLine*, *g_pvpSubscribers, p )
FOREACHS_CONST( IDebugLine*, g_Subscribers.Get(), p )
{ {
int i = p-g_pvpSubscribers->begin();
if( (g_bIsDisplayed && input.DeviceI == g_Mappings.debugButton[i]) || if( (g_bIsDisplayed && input.DeviceI == g_Mappings.debugButton[i]) ||
(IsGameplay() && input.DeviceI == g_Mappings.gameplayButton[i]) ) (IsGameplay() && input.DeviceI == g_Mappings.gameplayButton[i]) )
{ {
@@ -322,7 +321,6 @@ bool ScreenDebugOverlay::OverlayInput( const InputEventPlus &input )
UpdateText(); UpdateText();
return true; return true;
} }
++i;
} }
return false; return false;