00001 #include "global.h"
00002 #include "ScreenTitle.h"
00003 #include "MercuryScreenManager.h"
00004 #include "MercuryLoadableModel.h"
00005 #include "MercuryInput.h"
00006 #include "MercuryLog.h"
00007 #include "MercuryTheme.h"
00008 #include "MercuryDisplay.h"
00009 #include "MercuryLoadableModel.h"
00010
00011 #if defined(_EE)
00012 #include "MercuryDisplayEE.h"
00013 #endif
00014 #include "MercuryTheme.h"
00015
00016 KeyMappingWithCode( button_a, "0-97" );
00017 KeyMappingWithCode( button_b, "0-98" );
00018 KeyMappingWithCode( button_c, "0-99" );
00019 KeyMappingWithCode( button_t, "0-116" );
00020 KeyMappingWithCode( button_u, "0-117" );
00021
00022 #include "MercuryObjectFactory.h"
00023 REGISTER_SCREEN_CLASS( ScreenHgTitle )
00024
00025 #define MC_INPUTMAPPED 1 //convention: MESSAGE CODE
00026 #define MC_INPUTUNMAPPED 2
00027
00028 ScreenHgTitle::~ScreenHgTitle()
00029 {
00030 DISPLAY->RemoveLight(&m_light);
00031 SAFE_DELETE(m_mercury);
00032 }
00033
00034 void ScreenHgTitle::Init()
00035 {
00036 MercuryScreen::Init();
00037
00038 m_mercury = new MercuryLoadableModel;
00039 m_mercury->SetName( "Mercury" );
00040 m_mercury->Init();
00041 m_mercury->Load(GET_MODEL_BY_NAME( "Mercury" ));
00042 m_mercury->Tweening.AddCommand( THEME.GetMetricS( m_name, "MercuryTween" ) );
00043 AddPerspObject(m_mercury);
00044
00045
00046 MercuryModel* m_mercuryExplode = new MercuryLoadableModel;
00047 m_mercuryExplode->SetName( "MercuryExplode" );
00048 m_mercuryExplode->Init();
00049 m_mercuryExplode->Load(GET_MODEL_BY_NAME( "Mercury" ));
00050 m_mercuryExplode->Tweening.AddCommand( THEME.GetMetricS( m_name, "MercuryExplodeTween" ) );
00051 AddPerspObject(m_mercuryExplode, true);
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 m_logo.SetName("MercuryEngine");
00063 m_logo.Init();
00064 m_logo.LoadImage( THEME.GetMetricS( m_name, m_logo.GetName()+"Image") );
00065
00066 m_logo.Tweening.AddCommand( THEME.GetMetricS( m_name, m_logo.GetName()+"OnCommand") );
00067 AddOrthoObject(&m_logo);
00068
00069 m_iDirection = 0;
00070 fTotalTime = 0;
00071
00072
00073 m_light.Init();
00074 m_light.SetY(100);
00075 m_light.SetX(-100);
00076 m_light.SetZ(110);
00077 m_light.SetAttenuation(0.001f, Attenuation::LINEAR);
00078
00079 DISPLAY->AddLight(&m_light);
00080
00081
00082
00083
00084
00085 this->RegisterMessage( MC_INPUTMAPPED, "mappedinput" );
00086 }
00087
00088 void ScreenHgTitle::Message( int Message, PStack & data, const MString & name )
00089 {
00090 switch ( Message )
00091 {
00092 case MC_INPUTMAPPED:
00093 {
00094 InputMessageStruct c(data);
00095 if ( c.code == button_c )
00096 {
00097 if ( c.type == IET_DOWN )
00098 {
00099 m_logo.Tweening.StopTweening();
00100 m_logo.Tweening.AddCommand( "hide,0;linear,2;rotationz,0;diffuse,1,1,1,1");
00101 }
00102 if ( c.type == IET_RELEASE )
00103 {
00104 m_logo.Tweening.StopTweening();
00105 m_logo.Tweening.AddCommand( "hide,0;linear,2;rotationz,360;diffuse,1,1,1,1");
00106 }
00107 if ( m_mercury->GetName() == GET_MODEL_BY_NAME( "jupiter" ) )
00108 {
00109 if ( c.type == IET_DOWN )
00110 ((MercuryLoadableModel*)m_mercury)->GetAnimationState( 3 ).Trigger();
00111 else
00112 ((MercuryLoadableModel*)m_mercury)->GetAnimationState( 2 ).Trigger();
00113 }
00114 }
00115 if ( c.code == button_t )
00116 {
00117 if ( c.type == IET_RELEASE )
00118 {
00119 RemoveObject(m_mercury);
00120 SAFE_DELETE(m_mercury);
00121 m_mercury = new MercuryLoadableModel;
00122 m_mercury->SetName( "Jupiter" );
00123 m_mercury->Init();
00124 m_mercury->Load( GET_MODEL_BY_NAME( "jupiter" ) );
00125 m_mercury->Tweening.StopTweening();
00126
00127 MVector< MercuryLoadableModel::LoadableModelAnimationInfo > pTweenCommands;
00128
00129 pTweenCommands.resize(4);
00130 pTweenCommands[0].sAnimationName = "walk_lower";
00131 pTweenCommands[0].fPercent = .5;
00132 pTweenCommands[1].sAnimationName = "walk_upper";
00133 pTweenCommands[1].fPercent = .25;
00134
00135 pTweenCommands[2].sAnimationName = "shootright_upper";
00136 pTweenCommands[2].bLoop = pTweenCommands[2].bRunning = false;
00137 pTweenCommands[3].sAnimationName = "shootleft_upper";
00138 pTweenCommands[3].bLoop = pTweenCommands[3].bRunning = false;
00139 ((MercuryLoadableModel*)m_mercury)->SetAnimationState( pTweenCommands );
00140
00141 this->AddPerspObject(m_mercury);
00142 m_mercury->SetDrawOrder(-1);
00143 m_mercury->SetZ(-400);
00144 m_mercury->MoveY(-20);
00145 }
00146 }
00147 if ( c.code == button_u )
00148 {
00149 if ( c.type == IET_RELEASE )
00150 {
00151 m_logo.LoadImage( THEME.GetMetricS( GetName(), "DownloadImage" ) );
00152
00153 m_mercury->GetMaterial(0)->EditTexture(0)->Tweening.AddCommand( THEME.GetMetricS(m_name, "MercuryTextureTween"));
00154 }
00155 }
00156 }
00157 break;
00158 };
00159 }
00160
00161 void ScreenHgTitle::Update( const float dTime )
00162 {
00163 fTotalTime += dTime;
00164 if ( fTotalTime > THEME.GetMetricF( GetName(), "RestrainInput" ) )
00165 {
00166 int x,y;
00167 INPUTMAN->GetCursorPosition( x, y );
00168 m_mercury->SetRotX( float(y)/3.0f );
00169 m_mercury->SetRotY( float(x)/3.0f );
00170 }
00171 if ( INPUTMAN->IsButtonDown( button_a ) )
00172 {
00173 m_mercury->MoveX( -20*dTime );
00174 }
00175 if ( INPUTMAN->IsButtonDown( button_b ) )
00176 {
00177 m_mercury->MoveX( 20*dTime );
00178 }
00179
00180 MercuryScreen::Update( dTime );
00181 }
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209