25
25
#include "../video/font.h"
26
26
#include "../video/renderer.h"
27
27
#include "../level/level.h"
28
#include "../core/i18n.h"
29
30
/* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */
31
32
cLevel_Exit :: cLevel_Exit( float x, float y )
32
33
: cImageObjectSprite( x, y )
37
cLevel_Exit :: cLevel_Exit( XMLAttributes &attributes )
38
cLevel_Exit :: cLevel_Exit( CEGUI::XMLAttributes &attributes )
38
39
: cImageObjectSprite()
41
Create_from_Stream( attributes );
42
cLevel_Exit::Create_from_Stream( attributes );
44
45
cLevel_Exit :: ~cLevel_Exit( void )
213
209
void cLevel_Exit :: Activate( void )
215
pAudio->FadeOutMusic( 500 );
212
if( dest_level.empty() && dest_entry.empty() )
215
pAudio->Fadeout_Music( 500 );
217
218
// warp player out
218
219
if( exit_type == LEVELEXIT_WARP )
220
pAudio->PlaySound( "enter_pipe.ogg" );
221
pAudio->Play_Sound( "enter_pipe.ogg" );
222
pPlayer->Set_MovingState( STA_FALL );
223
pPlayer->Set_Moving_State( STA_FALL );
223
224
pPlayer->Set_Image( pPlayer->Get_Image() + pPlayer->direction );
224
pPlayer->Stop_ducking();
225
pPlayer->Reset_onGround();
225
pPlayer->Stop_Ducking();
226
pPlayer->Reset_on_Ground();
227
228
// set position and image
228
229
if( direction == DIR_UP || direction == DIR_DOWN )
230
pPlayer->Set_PosX( col_rect.x - pPlayer->col_pos.x + ( col_rect.w * 0.5f ) - ( pPlayer->col_rect.w * 0.5f ) );
231
pPlayer->Set_Pos_X( col_rect.x - pPlayer->col_pos.x + ( col_rect.w * 0.5f ) - ( pPlayer->col_rect.w * 0.5f ) );
232
233
else if( direction == DIR_LEFT || direction == DIR_RIGHT )
234
pPlayer->Set_PosY( col_rect.y - pPlayer->col_pos.y + ( col_rect.h * 0.5f ) - ( pPlayer->col_rect.h * 0.5f ) );
235
pPlayer->Set_Pos_Y( col_rect.y - pPlayer->col_pos.y + ( col_rect.h * 0.5f ) - ( pPlayer->col_rect.h * 0.5f ) );
237
238
if( direction == DIR_RIGHT )
239
pPlayer->Set_RotationZ( 90 );
240
pPlayer->Set_Rotation_Z( 90 );
241
242
else if( direction == DIR_LEFT )
243
pPlayer->Set_RotationZ( 270 );
244
pPlayer->Set_Rotation_Z( 270 );
247
248
float player_posz = pPlayer->posz;
248
pPlayer->posz = 0.0799f; // just before massive
249
// posz just before massive
250
pPlayer->posz = 0.0799f;
250
for( float i = 0; i < ( DESIRED_FPS * 0.9f ); i += pFramerate->speedfactor )
252
for( float i = 0; i < ( speedfactor_fps * 0.9f ); i += pFramerate->speedfactor )
252
254
if( direction == DIR_DOWN )
378
378
void cLevel_Exit :: Editor_Activate( void )
380
WindowManager &wmgr = WindowManager::getSingleton();
380
CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton();
383
383
if( exit_type == LEVELEXIT_WARP )
386
Combobox *combobox = static_cast<Combobox *>(wmgr.createWindow( "TaharezLook/Combobox", "level_exit_direction" ));
387
combobox->getEditbox()->setTooltipText( "Direction" );
388
Editor_Add( combobox, 100, 105 );
390
combobox->addItem( new ListboxTextItem( "up" ) );
391
combobox->addItem( new ListboxTextItem( "down" ) );
392
combobox->addItem( new ListboxTextItem( "right" ) );
393
combobox->addItem( new ListboxTextItem( "left" ) );
394
combobox->setText( Get_Direction_name( start_direction ) );
396
combobox->subscribeEvent( Combobox::EventListSelectionAccepted, Event::Subscriber( &cLevel_Exit::Editor_Direction_Select, this ) );
386
CEGUI::Combobox *combobox = static_cast<CEGUI::Combobox *>(wmgr.createWindow( "TaharezLook/Combobox", "level_exit_direction" ));
387
Editor_Add( UTF8_("Direction"), UTF8_("Direction to move in"), combobox, 100, 105 );
389
combobox->addItem( new CEGUI::ListboxTextItem( "up" ) );
390
combobox->addItem( new CEGUI::ListboxTextItem( "down" ) );
391
combobox->addItem( new CEGUI::ListboxTextItem( "right" ) );
392
combobox->addItem( new CEGUI::ListboxTextItem( "left" ) );
393
combobox->setText( Get_Direction_Name( start_direction ) );
395
combobox->subscribeEvent( CEGUI::Combobox::EventListSelectionAccepted, CEGUI::Event::Subscriber( &cLevel_Exit::Editor_Direction_Select, this ) );
399
398
// destination level
400
Editbox *editbox = static_cast<Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "level_exit_destination_level" ));
401
editbox->setTooltipText( "Destination Level" );
402
Editor_Add( editbox, 150 );
399
CEGUI::Editbox *editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "level_exit_destination_level" ));
400
Editor_Add( UTF8_("Destination Level"), UTF8_("Name of the level that should be entered. If empty uses the current level."), editbox, 150 );
404
402
editbox->setText( Get_Level( 0, 0 ) );
405
editbox->subscribeEvent( Editbox::EventKeyUp, Event::Subscriber( &cLevel_Exit::Editor_Destination_Level_Key, this ) );
403
editbox->subscribeEvent( CEGUI::Editbox::EventKeyUp, CEGUI::Event::Subscriber( &cLevel_Exit::Editor_Destination_Level_Key, this ) );
407
405
// destination entry
408
editbox = static_cast<Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "level_exit_destination_entry" ));
409
editbox->setTooltipText( "Destination Entry" );
410
Editor_Add( editbox, 150 );
406
editbox = static_cast<CEGUI::Editbox *>(wmgr.createWindow( "TaharezLook/Editbox", "level_exit_destination_entry" ));
407
Editor_Add( UTF8_("Destination Entry"), UTF8_("Name of the Entry in the destination level. If empty the entry point is the player start position."), editbox, 150 );
412
409
editbox->setText( dest_entry.c_str() );
413
editbox->subscribeEvent( Editbox::EventKeyUp, Event::Subscriber( &cLevel_Exit::Editor_Destination_Entry_Key, this ) );
410
editbox->subscribeEvent( CEGUI::Editbox::EventKeyUp, CEGUI::Event::Subscriber( &cLevel_Exit::Editor_Destination_Entry_Key, this ) );
419
bool cLevel_Exit :: Editor_Direction_Select( const EventArgs &event )
416
bool cLevel_Exit :: Editor_Direction_Select( const CEGUI::EventArgs &event )
421
const WindowEventArgs &windowEventArgs = static_cast<const WindowEventArgs&>( event );
422
ListboxItem *item = static_cast<Combobox *>( windowEventArgs.window )->getSelectedItem();
418
const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
419
CEGUI::ListboxItem *item = static_cast<CEGUI::Combobox *>( windowEventArgs.window )->getSelectedItem();
424
Set_Direction( Get_Direction_id( item->getText().c_str() ) );
421
Set_Direction( Get_Direction_Id( item->getText().c_str() ) );
429
bool cLevel_Exit :: Editor_Destination_Level_Key( const EventArgs &event )
426
bool cLevel_Exit :: Editor_Destination_Level_Key( const CEGUI::EventArgs &event )
431
const WindowEventArgs &windowEventArgs = static_cast<const WindowEventArgs&>( event );
432
string str_text = static_cast<Editbox *>( windowEventArgs.window )->getText().c_str();
428
const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
429
string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
434
431
Set_Level( str_text );
439
bool cLevel_Exit :: Editor_Destination_Entry_Key( const EventArgs &event )
436
bool cLevel_Exit :: Editor_Destination_Entry_Key( const CEGUI::EventArgs &event )
441
const WindowEventArgs &windowEventArgs = static_cast<const WindowEventArgs&>( event );
442
string str_text = static_cast<Editbox *>( windowEventArgs.window )->getText().c_str();
438
const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
439
string str_text = static_cast<CEGUI::Editbox *>( windowEventArgs.window )->getText().c_str();
444
441
Set_Entry( str_text );