00001 #include "global.h"
00002 #include "ScreenDebugOverlay.h"
00003 #include "MercuryScreenManager.h"
00004 #include "MercuryInput.h"
00005 #include "MercuryLog.h"
00006 #include "MercuryTheme.h"
00007 #include "MercuryDisplay.h"
00008
00009 KeyMappingWithCode( button_F1, "0-282" );
00010
00011 #include "MercuryObjectFactory.h"
00012 REGISTER_SCREEN_CLASS( ScreenDebugOverlay )
00013
00014 #define MC_INPUTMAPPED 1 //convention: MESSAGE CODE
00015 #define MC_INPUTUNMAPPED 2
00016 #define MC_RENDERSTATS 3
00017 #define MC_TEXTURESTATS 4
00018
00019 ScreenDebugOverlay::~ScreenDebugOverlay()
00020 {
00021 }
00022
00023 void ScreenDebugOverlay::Init()
00024 {
00025 MercuryScreen::Init();
00026
00027
00028
00029 int fontsize = THEME.GetMetricI( GetName(), "FontSize" );
00030 MString font = THEME.GetMetricS( GetName(), "Font" );
00031
00032 m_FPS.SetName("FPSDisplay");
00033 m_FPS.Init();
00034 m_FPS.SetFont(font);
00035 m_FPS.Tweening.AddCommand(THEME.GetMetricS( GetName(), m_FPS.GetName() + "OnCommand" ));
00036 m_FPS.SetSize(fontsize);
00037 AddOrthoObject(&m_FPS);
00038
00039 m_VPF.SetName("VPFDisplay");
00040 m_VPF.Init();
00041 m_VPF.SetFont(font);
00042 m_VPF.Tweening.AddCommand(THEME.GetMetricS( GetName(), m_VPF.GetName() + "OnCommand" ));
00043 m_VPF.SetSize(fontsize);
00044 AddOrthoObject(&m_VPF);
00045
00046 m_VPS.SetName("VPSDisplay");
00047 m_VPS.Init();
00048 m_VPS.SetFont(font);
00049 m_VPS.Tweening.AddCommand(THEME.GetMetricS( GetName(), m_VPS.GetName() + "OnCommand" ));
00050 m_VPS.SetSize(fontsize);
00051 AddOrthoObject(&m_VPS);
00052
00053 m_textureCount.SetName("TextureCountDisplay");
00054 m_textureCount.Init();
00055 m_textureCount.SetFont(font);
00056 m_textureCount.Tweening.AddCommand(THEME.GetMetricS( GetName(), m_textureCount.GetName() + "OnCommand" ));
00057 m_textureCount.SetSize(fontsize);
00058 AddOrthoObject(&m_textureCount);
00059
00060 m_UtextureCount.SetName("UniqueTextureCountDisplay");
00061 m_UtextureCount.Init();
00062 m_UtextureCount.SetFont(font);
00063 m_UtextureCount.Tweening.AddCommand(THEME.GetMetricS( GetName(), m_UtextureCount.GetName() + "OnCommand" ));
00064 m_UtextureCount.SetSize(fontsize);
00065 AddOrthoObject(&m_UtextureCount);
00066
00067 m_cacheCount.SetName("CacheCountDisplay");
00068 m_cacheCount.Init();
00069 m_cacheCount.SetFont(font);
00070 m_cacheCount.Tweening.AddCommand(THEME.GetMetricS( GetName(), m_cacheCount.GetName() + "OnCommand" ));
00071 m_cacheCount.SetSize(fontsize);
00072 AddOrthoObject(&m_cacheCount);
00073
00074 m_UcacheCount.SetName("UniqueCacheCountDisplay");
00075 m_UcacheCount.Init();
00076 m_UcacheCount.SetFont(font);
00077 m_UcacheCount.Tweening.AddCommand(THEME.GetMetricS( GetName(), m_UcacheCount.GetName() + "OnCommand" ));
00078 m_UcacheCount.SetSize(fontsize);
00079 AddOrthoObject(&m_UcacheCount);
00080
00081 m_MercuryLogo.SetName( "MercuryLogoTopScreenText" );
00082 m_MercuryLogo.Init();
00083 m_MercuryLogo.SetFont( font );
00084 m_MercuryLogo.Tweening.AddCommand(THEME.GetMetricS( GetName(), m_MercuryLogo.GetName()+ "OnCommand" ));
00085 m_MercuryLogo.SetSize( fontsize );
00086 m_MercuryLogo.SetText( THEME.GetMetricS( GetName(), m_MercuryLogo.GetName()+ "Text" ) );
00087 AddOrthoObject(&m_MercuryLogo);
00088
00089 this->RegisterMessage( MC_RENDERSTATS, "RenderStats" );
00090 this->RegisterMessage( MC_TEXTURESTATS, "TextureStats" );
00091 this->RegisterMessage( MC_INPUTMAPPED, "mappedinput" );
00092 }
00093
00094 void ScreenDebugOverlay::Message( int Message, PStack & data, const MString & name )
00095 {
00096 switch ( Message )
00097 {
00098 case MC_RENDERSTATS:
00099 {
00100 if ( IsHidden() )
00101 break;
00102 m_FPS.SetText(ssprintf("FPS: %f", data.PeekItem(2).GetValueF()));
00103 m_VPF.SetText(ssprintf("VPF: %f", data.PeekItem(1).GetValueF()));
00104 m_VPS.SetText(ssprintf("VPS: %f", data.PeekItem(0).GetValueF()));
00105 }
00106 break;
00107 case MC_TEXTURESTATS:
00108 {
00109 if ( IsHidden() )
00110 break;
00111 m_textureCount.SetText(ssprintf("TC: %d", data.PeekItem(1).GetValueI()));
00112 m_UtextureCount.SetText(ssprintf("UTC: %d", data.PeekItem(0).GetValueI()));
00113 }
00114 break;
00115 case MC_INPUTMAPPED:
00116 {
00117 InputMessageStruct c(data);
00118 if ( c.code == button_F1 )
00119 {
00120 if ( c.type == IET_RELEASE )
00121 {
00122 SetHide(!GetHide());
00123 }
00124 }
00125 }
00126 break;
00127 };
00128 }
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156